I need to create some integration tests without cucumber. Can anyone point me in the right direction for how to do that in rails? I tried creating specs under ''spec/integration/'' but no matchers are being included. I also tried rspec_integration plugin (http://github.com/ tricycle/rspec-integration) but that only defines a few matchers and response.should be_success doesn''t work properly. Any help you can provide would be much appreciated!
drewB wrote:> I need to create some integration tests without cucumber. Can anyone > point me in the right direction for how to do that in rails? I tried > creating specs under ''spec/integration/'' but no matchers are being > included. I also tried rspec_integration plugin (http://github.com/ > tricycle/rspec-integration) but that only defines a few matchers and > response.should be_success doesn''t work properly. > > Any help you can provide would be much appreciated! >You should not need any magic to get rspec working. In order to run integration specs I''ve been using a very simple spec_helper.rb. Maybe this can be some help to you; http://gist.github.com/318821 -- Joseph Wilk http://blog.josephwilk.net http://www.songkick.com mob: +44(0)7812816431> _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >
El 01/03/2010, a las 21:32, drewB escribi?:> I need to create some integration tests without cucumber. Can anyone > point me in the right direction for how to do that in rails? I tried > creating specs under ''spec/integration/'' but no matchers are being > included. I also tried rspec_integration plugin (http://github.com/ > tricycle/rspec-integration) but that only defines a few matchers and > response.should be_success doesn''t work properly. > > Any help you can provide would be much appreciated!You could try Steak: http://github.com/cavalle/steak Cheers, Wincent
Belwo is a spec that when used with the default spec_helper fails with: NoMethodError in ''test matchers should be able to find be_success'' undefined method `be_success'' for #<ActionController::Integration::Session:0x7fc081ef13e0> ---------- require ''spec_helper'' describe "test matchers" do it "should be able to find be_success" do get ''/'' response.should be_success end end -------------
On Mon, Mar 1, 2010 at 4:59 PM, drewB <dbatshaw at gmail.com> wrote:> Belwo is a spec that when used with the default spec_helper fails > with: > > NoMethodError in ''test matchers should be able to find be_success'' > undefined method `be_success'' for > #<ActionController::Integration::Session:0x7fc081ef13e0> > > ---------- > > require ''spec_helper'' > > describe "test matchers" do > ?it "should be able to find be_success" do > ? ?get ''/'' > ? ?response.should be_success > ?end > > endTry adding this to spec/spec_helper.rb Spec::Runner.configure {|c| c.include Spec::Matchers}
That fixed it! Thanks! Any idea why that was needed for integration specs and not MVCs? On Mar 1, 3:04?pm, David Chelimsky <dchelim... at gmail.com> wrote:> On Mon, Mar 1, 2010 at 4:59 PM, drewB <dbats... at gmail.com> wrote: > > Belwo is a spec that when used with the default spec_helper fails > > with: > > > NoMethodError in ''test matchers should be able to find be_success'' > > undefined method `be_success'' for > > #<ActionController::Integration::Session:0x7fc081ef13e0> > > > ---------- > > > require ''spec_helper'' > > > describe "test matchers" do > > ?it "should be able to find be_success" do > > ? ?get ''/'' > > ? ?response.should be_success > > ?end > > > end > > Try adding this to spec/spec_helper.rb > > Spec::Runner.configure {|c| c.include Spec::Matchers} > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Looks like I spoke too soon. I made a mistake when testing your suggest. When I add that I still get the same failure. On Mar 1, 4:06?pm, drewB <dbats... at gmail.com> wrote:> That fixed it! Thanks! > > Any idea why that was needed for integration specs and not MVCs? > > On Mar 1, 3:04?pm, David Chelimsky <dchelim... at gmail.com> wrote: > > > On Mon, Mar 1, 2010 at 4:59 PM, drewB <dbats... at gmail.com> wrote: > > > Belwo is a spec that when used with the default spec_helper fails > > > with: > > > > NoMethodError in ''test matchers should be able to find be_success'' > > > undefined method `be_success'' for > > > #<ActionController::Integration::Session:0x7fc081ef13e0> > > > > ---------- > > > > require ''spec_helper'' > > > > describe "test matchers" do > > > ?it "should be able to find be_success" do > > > ? ?get ''/'' > > > ? ?response.should be_success > > > ?end > > > > end > > > Try adding this to spec/spec_helper.rb > > > Spec::Runner.configure {|c| c.include Spec::Matchers} > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
On Tue, Mar 2, 2010 at 11:53 AM, drewB <dbatshaw at gmail.com> wrote:> Looks like I spoke too soon. ?I made a mistake when testing your > suggest. ?When I add that I still get the same failure.I just did the following using rails 2.3.5, rspec 1.3.2 and rspec-rails 1.3.0: $ rails foo $ cd foo $ script/generate rspec $ mkdir spec/integration $ script/generate integration_spec widgets $ rake db:migrate && db:test:prepare Then I modified spec/integration/widgets_spec.rb as follows: require ''spec_helper'' describe "Widgets" do it "shows me the list" do get "/widgets" response.should be_success end end Then I ran this: $ script/spec spec/integration/ And here''s the output I saw: F 1) ''Widgets ..'' FAILED expected success? to return true, got false /Users/dchelimsky/tmp/foo/spec/integration/widgets_spec.rb:6: So everything is working as it should on a fresh app. Did you update spec/spec_helper.rb the last time you upgraded the app? Are you using an earlier version of rspec-rails or rspec?> > On Mar 1, 4:06?pm, drewB <dbats... at gmail.com> wrote: >> That fixed it! Thanks! >> >> Any idea why that was needed for integration specs and not MVCs? >> >> On Mar 1, 3:04?pm, David Chelimsky <dchelim... at gmail.com> wrote: >> >> > On Mon, Mar 1, 2010 at 4:59 PM, drewB <dbats... at gmail.com> wrote: >> > > Belwo is a spec that when used with the default spec_helper fails >> > > with: >> >> > > NoMethodError in ''test matchers should be able to find be_success'' >> > > undefined method `be_success'' for >> > > #<ActionController::Integration::Session:0x7fc081ef13e0> >> >> > > ---------- >> >> > > require ''spec_helper'' >> >> > > describe "test matchers" do >> > > ?it "should be able to find be_success" do >> > > ? ?get ''/'' >> > > ? ?response.should be_success >> > > ?end >> >> > > end >> >> > Try adding this to spec/spec_helper.rb >> >> > Spec::Runner.configure {|c| c.include Spec::Matchers}
Let me start by saying thank you for the time you are spending helping me. It appears to be a rails version issue. I ran though the same steps you outlined on my machine and continued to get the same error message, "undefined method `be_success''". I am running rspec 1.3.0, rspec-rails 1.3.2, rails 2.3.4. When I upgraded to rails 2.3.5 and tried again, everything worked. The project I am working on is frozen at rails 2.1.2 so am still looking for a way to get this to work with rails 2.1.2. Should I downgrade to an earlier version of RSpec or spec-rails? If so, which one? On Mar 2, 3:54?pm, David Chelimsky <dchelim... at gmail.com> wrote:> On Tue, Mar 2, 2010 at 11:53 AM, drewB <dbats... at gmail.com> wrote: > > Looks like I spoke too soon. ?I made a mistake when testing your > > suggest. ?When I add that I still get the same failure. > > I just did the following using rails 2.3.5, rspec 1.3.2 and rspec-rails 1.3.0: > > $ rails foo > $ cd foo > $ script/generate rspec > $ mkdir spec/integration > $ script/generate integration_spec widgets > $ rake db:migrate && db:test:prepare > > Then I modified spec/integration/widgets_spec.rb as follows: > > require ''spec_helper'' > > describe "Widgets" do > ? it "shows me the list" do > ? ? get "/widgets" > ? ? response.should be_success > ? end > end > > Then I ran this: > > $ script/spec spec/integration/ > > And here''s the output I saw: > > F > > 1) > ''Widgets ..'' FAILED > expected success? to return true, got false > /Users/dchelimsky/tmp/foo/spec/integration/widgets_spec.rb:6: > > So everything is working as it should on a fresh app. Did you update > spec/spec_helper.rb the last time you upgraded the app? Are you using > an earlier version of rspec-rails or rspec? > > > > > > > On Mar 1, 4:06?pm, drewB <dbats... at gmail.com> wrote: > >> That fixed it! Thanks! > > >> Any idea why that was needed for integration specs and not MVCs? > > >> On Mar 1, 3:04?pm, David Chelimsky <dchelim... at gmail.com> wrote: > > >> > On Mon, Mar 1, 2010 at 4:59 PM, drewB <dbats... at gmail.com> wrote: > >> > > Belwo is a spec that when used with the default spec_helper fails > >> > > with: > > >> > > NoMethodError in ''test matchers should be able to find be_success'' > >> > > undefined method `be_success'' for > >> > > #<ActionController::Integration::Session:0x7fc081ef13e0> > > >> > > ---------- > > >> > > require ''spec_helper'' > > >> > > describe "test matchers" do > >> > > ?it "should be able to find be_success" do > >> > > ? ?get ''/'' > >> > > ? ?response.should be_success > >> > > ?end > > >> > > end > > >> > Try adding this to spec/spec_helper.rb > > >> > Spec::Runner.configure {|c| c.include Spec::Matchers} > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
On Wed, Mar 3, 2010 at 12:24 PM, drewB <dbatshaw at gmail.com> wrote:> Let me start by saying thank you for the time you are spending helping > me.You''re welcome.> It appears to be a rails version issue. ?I ran though the same steps > you outlined on my machine and continued to get the same error > message, "undefined method `be_success''". ?I am running rspec 1.3.0, > rspec-rails 1.3.2, rails 2.3.4. ?When I upgraded to rails 2.3.5 and > tried again, everything worked. > > The project I am working on is frozen at rails 2.1.2 so am still > looking for a way to get this to work with rails 2.1.2. ?Should I > downgrade to an earlier version of RSpec or spec-rails? ?If so, which > one?1.3.2 is tested against the last fix release of each series: 2.3.5, 2.2.2, 2.1.2, 2.0.5. So it should work with 2.1.2. If not, it''s a bug, so go ahead and file a bug report at http://rspec.lighthouseapp.com - feel free to reference this thread. Cheers, David> > On Mar 2, 3:54?pm, David Chelimsky <dchelim... at gmail.com> wrote: >> On Tue, Mar 2, 2010 at 11:53 AM, drewB <dbats... at gmail.com> wrote: >> > Looks like I spoke too soon. ?I made a mistake when testing your >> > suggest. ?When I add that I still get the same failure. >> >> I just did the following using rails 2.3.5, rspec 1.3.2 and rspec-rails 1.3.0: >> >> $ rails foo >> $ cd foo >> $ script/generate rspec >> $ mkdir spec/integration >> $ script/generate integration_spec widgets >> $ rake db:migrate && db:test:prepare >> >> Then I modified spec/integration/widgets_spec.rb as follows: >> >> require ''spec_helper'' >> >> describe "Widgets" do >> ? it "shows me the list" do >> ? ? get "/widgets" >> ? ? response.should be_success >> ? end >> end >> >> Then I ran this: >> >> $ script/spec spec/integration/ >> >> And here''s the output I saw: >> >> F >> >> 1) >> ''Widgets ..'' FAILED >> expected success? to return true, got false >> /Users/dchelimsky/tmp/foo/spec/integration/widgets_spec.rb:6: >> >> So everything is working as it should on a fresh app. Did you update >> spec/spec_helper.rb the last time you upgraded the app? Are you using >> an earlier version of rspec-rails or rspec? >> >> >> >> >> >> > On Mar 1, 4:06?pm, drewB <dbats... at gmail.com> wrote: >> >> That fixed it! Thanks! >> >> >> Any idea why that was needed for integration specs and not MVCs? >> >> >> On Mar 1, 3:04?pm, David Chelimsky <dchelim... at gmail.com> wrote: >> >> >> > On Mon, Mar 1, 2010 at 4:59 PM, drewB <dbats... at gmail.com> wrote: >> >> > > Belwo is a spec that when used with the default spec_helper fails >> >> > > with: >> >> >> > > NoMethodError in ''test matchers should be able to find be_success'' >> >> > > undefined method `be_success'' for >> >> > > #<ActionController::Integration::Session:0x7fc081ef13e0> >> >> >> > > ---------- >> >> >> > > require ''spec_helper'' >> >> >> > > describe "test matchers" do >> >> > > ?it "should be able to find be_success" do >> >> > > ? ?get ''/'' >> >> > > ? ?response.should be_success >> >> > > ?end >> >> >> > > end >> >> >> > Try adding this to spec/spec_helper.rb >> >> >> > Spec::Runner.configure {|c| c.include Spec::Matchers} >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Bug filed. Any idea about an earlier version that I might try? On Mar 3, 10:38?am, David Chelimsky <dchelim... at gmail.com> wrote:> On Wed, Mar 3, 2010 at 12:24 PM, drewB <dbats... at gmail.com> wrote: > > Let me start by saying thank you for the time you are spending helping > > me. > > You''re welcome. > > > It appears to be a rails version issue. ?I ran though the same steps > > you outlined on my machine and continued to get the same error > > message, "undefined method `be_success''". ?I am running rspec 1.3.0, > > rspec-rails 1.3.2, rails 2.3.4. ?When I upgraded to rails 2.3.5 and > > tried again, everything worked. > > > The project I am working on is frozen at rails 2.1.2 so am still > > looking for a way to get this to work with rails 2.1.2. ?Should I > > downgrade to an earlier version of RSpec or spec-rails? ?If so, which > > one? > > 1.3.2 is tested against the last fix release of each series: 2.3.5, > 2.2.2, 2.1.2, 2.0.5. So it should work with 2.1.2. If not, it''s a bug, > so go ahead and file a bug report athttp://rspec.lighthouseapp.com- > feel free to reference this thread. > > Cheers, > David > > > > > > > On Mar 2, 3:54?pm, David Chelimsky <dchelim... at gmail.com> wrote: > >> On Tue, Mar 2, 2010 at 11:53 AM, drewB <dbats... at gmail.com> wrote: > >> > Looks like I spoke too soon. ?I made a mistake when testing your > >> > suggest. ?When I add that I still get the same failure. > > >> I just did the following using rails 2.3.5, rspec 1.3.2 and rspec-rails 1.3.0: > > >> $ rails foo > >> $ cd foo > >> $ script/generate rspec > >> $ mkdir spec/integration > >> $ script/generate integration_spec widgets > >> $ rake db:migrate && db:test:prepare > > >> Then I modified spec/integration/widgets_spec.rb as follows: > > >> require ''spec_helper'' > > >> describe "Widgets" do > >> ? it "shows me the list" do > >> ? ? get "/widgets" > >> ? ? response.should be_success > >> ? end > >> end > > >> Then I ran this: > > >> $ script/spec spec/integration/ > > >> And here''s the output I saw: > > >> F > > >> 1) > >> ''Widgets ..'' FAILED > >> expected success? to return true, got false > >> /Users/dchelimsky/tmp/foo/spec/integration/widgets_spec.rb:6: > > >> So everything is working as it should on a fresh app. Did you update > >> spec/spec_helper.rb the last time you upgraded the app? Are you using > >> an earlier version of rspec-rails or rspec? > > >> > On Mar 1, 4:06?pm, drewB <dbats... at gmail.com> wrote: > >> >> That fixed it! Thanks! > > >> >> Any idea why that was needed for integration specs and not MVCs? > > >> >> On Mar 1, 3:04?pm, David Chelimsky <dchelim... at gmail.com> wrote: > > >> >> > On Mon, Mar 1, 2010 at 4:59 PM, drewB <dbats... at gmail.com> wrote: > >> >> > > Belwo is a spec that when used with the default spec_helper fails > >> >> > > with: > > >> >> > > NoMethodError in ''test matchers should be able to find be_success'' > >> >> > > undefined method `be_success'' for > >> >> > > #<ActionController::Integration::Session:0x7fc081ef13e0> > > >> >> > > ---------- > > >> >> > > require ''spec_helper'' > > >> >> > > describe "test matchers" do > >> >> > > ?it "should be able to find be_success" do > >> >> > > ? ?get ''/'' > >> >> > > ? ?response.should be_success > >> >> > > ?end > > >> >> > > end > > >> >> > Try adding this to spec/spec_helper.rb > > >> >> > Spec::Runner.configure {|c| c.include Spec::Matchers} > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users