From matt at mattwynne.net Tue Jun 1 03:31:35 2010 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 01 Jun 2010 08:31:35 +0100 Subject: [rspec-users] Understanding how to better use stub! and stub_chain Message-ID: Did you try looking at the specs for any examples? I imagine there'd be a couple... ;) Joseph DelCioppio wrote: >I've been looking through the RSpec source to better understand how >RSpec works and I've got a question about the functionality of stub!. >I noticed that you can pass a symbol to stub!, which is usually how I >use it, some combination of stub!(:method).with(inputs). > >However, I'm noticing that you can also pass opts and a &block if you >wanted to? > >Can somebody give me an example of this, or why you'd want to do this? > >Thanks, > >Joe >_______________________________________________ >rspec-users mailing list >rspec-users at rubyforge.org >http://rubyforge.org/mailman/listinfo/rspec-users From joseph.delcioppio at gmail.com Tue Jun 1 09:39:48 2010 From: joseph.delcioppio at gmail.com (Joseph DelCioppio) Date: Tue, 1 Jun 2010 06:39:48 -0700 (PDT) Subject: [rspec-users] Understanding how to better use stub! and stub_chain In-Reply-To: References: Message-ID: <60347a9c-734e-415b-b47f-a7fa5b57010c@o4g2000vbo.googlegroups.com> See that's a great idea. I wish I would have thought of that myself. Thanks Matt. On Jun 1, 3:31?am, Matt Wynne wrote: > Did you try looking at the specs for any examples? I imagine there'd be a couple... ;) > > > > > > Joseph DelCioppio wrote: > >I've been looking through the RSpec source to better understand how > >RSpec works and I've got a question about the functionality of stub!. > >I noticed that you can pass a symbol to stub!, which is usually how I > >use it, some combination of stub!(:method).with(inputs). > > >However, I'm noticing that you can also pass opts and a &block if you > >wanted to? > > >Can somebody give me an example of this, or why you'd want to do this? > > >Thanks, > > >Joe > >_______________________________________________ > >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 From kmandrup at gmail.com Tue Jun 1 17:53:14 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Tue, 1 Jun 2010 14:53:14 -0700 (PDT) Subject: [rspec-users] RSpec book errata #57 - undefined method `include' : what to do? Message-ID: <3b29755e-906f-47dd-8016-dd568efcb06d@y12g2000vbg.googlegroups.com> http://pragprog.com/titles/achbd/errata nr 57: Ruby 1.8.7 expected [] to include "Welcome to Codebreaker!" Ruby 1.9.1 undefined method `include' for # (NoMethodError) --- class Output def messages @messages ||= [] end def puts(message) messages << message end end Then /^I should see "([^\"]*)"$/ do |message| output.messages.should include(message) end --- I am using Ruby 1.9.2 with cucumber 0.7.3 and Rspec 2.0.0.beta.9. Is there a fix for this somewhere for this stack of gems and ruby version? From kmandrup at gmail.com Tue Jun 1 21:08:21 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Tue, 1 Jun 2010 18:08:21 -0700 (PDT) Subject: [rspec-users] RSpec book errata #57 - undefined method `include' : what to do? In-Reply-To: <3b29755e-906f-47dd-8016-dd568efcb06d@y12g2000vbg.googlegroups.com> References: <3b29755e-906f-47dd-8016-dd568efcb06d@y12g2000vbg.googlegroups.com> Message-ID: One hack "solution" looks like this :P output.messages.include?(mark).should From johnf.pub at distb.net Wed Jun 2 08:50:12 2010 From: johnf.pub at distb.net (John Feminella) Date: Wed, 2 Jun 2010 08:50:12 -0400 Subject: [rspec-users] Programmatically counting RSpec tests? In-Reply-To: References: Message-ID: If I have an object `obj` that is a SpecTask, and subsequently invoke it, is there a way to programmatically determine the number of tests that were successful, failed, and pending as a result of running that SpecTask? -- John Feminella Principal Consultant, Distilled Brilliance From dchelimsky at gmail.com Wed Jun 2 09:02:53 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Jun 2010 08:02:53 -0500 Subject: [rspec-users] Programmatically counting RSpec tests? In-Reply-To: References: Message-ID: On Jun 2, 2010, at 7:50 AM, John Feminella wrote: > If I have an object `obj` that is a SpecTask, and subsequently invoke > it, is there a way to programmatically determine the number of tests > that were successful, failed, and pending as a result of running that > SpecTask? You could write a custom reporter to collect that information. Which version of rspec are you using? From johnf.pub at distb.net Wed Jun 2 09:14:25 2010 From: johnf.pub at distb.net (John Feminella) Date: Wed, 2 Jun 2010 09:14:25 -0400 Subject: [rspec-users] Programmatically counting RSpec tests? In-Reply-To: References: Message-ID: This is RSpec 1.3.0. -- John Feminella Principal Consultant, Distilled Brilliance On Wed, Jun 2, 2010 at 09:02, David Chelimsky wrote: > On Jun 2, 2010, at 7:50 AM, John Feminella wrote: > >> If I have an object `obj` that is a SpecTask, and subsequently invoke >> it, is there a way to programmatically determine the number of tests >> that were successful, failed, and pending as a result of running that >> SpecTask? > > You could write a custom reporter to collect that information. Which version of rspec are you using? From dchelimsky at gmail.com Wed Jun 2 09:19:53 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Jun 2010 08:19:53 -0500 Subject: [rspec-users] Programmatically counting RSpec tests? In-Reply-To: References: Message-ID: <90CE3728-70A5-433E-9B77-F62210141F6E@gmail.com> On Jun 2, 2010, at 8:14 AM, John Feminella wrote: > On Wed, Jun 2, 2010 at 09:02, David Chelimsky wrote: >> On Jun 2, 2010, at 7:50 AM, John Feminella wrote: >> >>> If I have an object `obj` that is a SpecTask, and subsequently invoke >>> it, is there a way to programmatically determine the number of tests >>> that were successful, failed, and pending as a result of running that >>> SpecTask? >> >> You could write a custom reporter to collect that information. Which version of rspec are you using? > This is RSpec 1.3.0. Take a look at http://wiki.github.com/dchelimsky/rspec/custom-formatters Also: http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Runner/Formatter/BaseFormatter.html Let us know if you have any questions Cheers, David From johnf.pub at distb.net Wed Jun 2 09:23:58 2010 From: johnf.pub at distb.net (John Feminella) Date: Wed, 2 Jun 2010 09:23:58 -0400 Subject: [rspec-users] Programmatically counting RSpec tests? In-Reply-To: <90CE3728-70A5-433E-9B77-F62210141F6E@gmail.com> References: <90CE3728-70A5-433E-9B77-F62210141F6E@gmail.com> Message-ID: This looks pretty straightforward. I do wish it were possible to access the statistical data after the test rather than having to capture and process it inline via the formatter, but I think this will do. Thank you for your time, David. -- John Feminella Principal Consultant, Distilled Brilliance On Wed, Jun 2, 2010 at 09:19, David Chelimsky wrote: > On Jun 2, 2010, at 8:14 AM, John Feminella wrote: > >> On Wed, Jun 2, 2010 at 09:02, David Chelimsky wrote: >>> On Jun 2, 2010, at 7:50 AM, John Feminella wrote: >>> >>>> If I have an object `obj` that is a SpecTask, and subsequently invoke >>>> it, is there a way to programmatically determine the number of tests >>>> that were successful, failed, and pending as a result of running that >>>> SpecTask? >>> >>> You could write a custom reporter to collect that information. Which version of rspec are you using? > >> This is RSpec 1.3.0. > > Take a look at http://wiki.github.com/dchelimsky/rspec/custom-formatters > > Also: http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Runner/Formatter/BaseFormatter.html > > Let us know if you have any questions > > Cheers, > David From dchelimsky at gmail.com Wed Jun 2 09:27:40 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Jun 2010 08:27:40 -0500 Subject: [rspec-users] Programmatically counting RSpec tests? In-Reply-To: References: <90CE3728-70A5-433E-9B77-F62210141F6E@gmail.com> Message-ID: On Jun 2, 2010, at 8:23 AM, John Feminella wrote: > On Wed, Jun 2, 2010 at 09:19, David Chelimsky wrote: >> On Jun 2, 2010, at 8:14 AM, John Feminella wrote: >> >>> On Wed, Jun 2, 2010 at 09:02, David Chelimsky wrote: >>>> On Jun 2, 2010, at 7:50 AM, John Feminella wrote: >>>> >>>>> If I have an object `obj` that is a SpecTask, and subsequently invoke >>>>> it, is there a way to programmatically determine the number of tests >>>>> that were successful, failed, and pending as a result of running that >>>>> SpecTask? >>>> >>>> You could write a custom reporter to collect that information. Which version of rspec are you using? >> >>> This is RSpec 1.3.0. >> >> Take a look at http://wiki.github.com/dchelimsky/rspec/custom-formatters >> >> Also: http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Runner/Formatter/BaseFormatter.html >> >> Let us know if you have any questions > This looks pretty straightforward. I do wish it were possible to > access the statistical data after the test rather than having to > capture and process it inline via the formatter, This is open source. Your wish is your command. The rspec-2 architecture should make it easier to get what you want. Feel free to look it over and offer up a patch. Cheers, David From lawrence.pit at gmail.com Wed Jun 2 18:57:24 2010 From: lawrence.pit at gmail.com (Lawrence Pit) Date: Thu, 03 Jun 2010 08:57:24 +1000 Subject: [rspec-users] beta 9 Message-ID: <4C06E1D4.6040503@gmail.com> Hi, I've been using rspec 2.0.0 beta 8 for a while. All specs pass. Installed beta 9, and more than half fail. Am I the only one who's seeing this? Not sure what to do to get it all passing using beta 9.. Cheers, Lawrence From dchelimsky at gmail.com Wed Jun 2 19:01:42 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Jun 2010 18:01:42 -0500 Subject: [rspec-users] beta 9 In-Reply-To: <4C06E1D4.6040503@gmail.com> References: <4C06E1D4.6040503@gmail.com> Message-ID: <47231AE6-E86D-45E9-A0C2-06C579B874DA@gmail.com> On Jun 2, 2010, at 5:57 PM, Lawrence Pit wrote: > Hi, > > I've been using rspec 2.0.0 beta 8 for a while. All specs pass. Installed beta 9, and more than half fail. Am I the only one who's seeing this? Not sure what to do to get it all passing using beta 9.. What failures are you seeing? Please post some backtraces (at least one would help). From bcardarella at gmail.com Wed Jun 2 20:49:47 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Wed, 2 Jun 2010 17:49:47 -0700 (PDT) Subject: [rspec-users] Rails 3 + RSpec-Rails 2.0 generators? Message-ID: I followed the instructions on the wiki but I don't seem to have the generator: rails g rspec:install Are the generators not working? btw, I don't see rspec listed when I run 'rails generate' - Brian From dchelimsky at gmail.com Wed Jun 2 21:03:21 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Jun 2010 20:03:21 -0500 Subject: [rspec-users] Rails 3 + RSpec-Rails 2.0 generators? In-Reply-To: References: Message-ID: <271D3A53-EC6D-46D0-AEC2-91D736D26E82@gmail.com> On Jun 2, 2010, at 7:49 PM, Brian Cardarella wrote: > I followed the instructions on the wiki but I don't seem to have the > generator: > > rails g rspec:install > > Are the generators not working? > > btw, I don't see rspec listed when I run 'rails generate' Did you add rspec-rails to your Gemfile? From bcardarella at gmail.com Wed Jun 2 21:13:22 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Wed, 2 Jun 2010 18:13:22 -0700 (PDT) Subject: [rspec-users] Rails 3 + RSpec-Rails 2.0 generators? In-Reply-To: <271D3A53-EC6D-46D0-AEC2-91D736D26E82@gmail.com> References: <271D3A53-EC6D-46D0-AEC2-91D736D26E82@gmail.com> Message-ID: Ah, duh :p On Jun 2, 9:03?pm, David Chelimsky wrote: > On Jun 2, 2010, at 7:49 PM, Brian Cardarella wrote: > > > I followed the instructions on the wiki but I don't seem to have the > > generator: > > > rails g rspec:install > > > Are the generators not working? > > > btw, I don't see rspec listed when I run 'rails generate' > > Did you add rspec-rails to your Gemfile? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Jun 2 21:15:32 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Jun 2010 20:15:32 -0500 Subject: [rspec-users] Rails 3 + RSpec-Rails 2.0 generators? In-Reply-To: References: <271D3A53-EC6D-46D0-AEC2-91D736D26E82@gmail.com> Message-ID: <868992EA-224C-45FA-9128-CBD87C1DF45B@gmail.com> I'll take that to mean you got it working :) On Jun 2, 2010, at 8:13 PM, Brian Cardarella wrote: > Ah, duh :p > > On Jun 2, 9:03 pm, David Chelimsky wrote: >> On Jun 2, 2010, at 7:49 PM, Brian Cardarella wrote: >> >>> I followed the instructions on the wiki but I don't seem to have the >>> generator: >> >>> rails g rspec:install >> >>> Are the generators not working? >> >>> btw, I don't see rspec listed when I run 'rails generate' >> >> Did you add rspec-rails to your Gemfile? >> _______________________________________________ >> 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 From lawrence.pit at gmail.com Wed Jun 2 22:19:32 2010 From: lawrence.pit at gmail.com (Lawrence Pit) Date: Thu, 03 Jun 2010 12:19:32 +1000 Subject: [rspec-users] beta 9 In-Reply-To: <47231AE6-E86D-45E9-A0C2-06C579B874DA@gmail.com> References: <4C06E1D4.6040503@gmail.com> <47231AE6-E86D-45E9-A0C2-06C579B874DA@gmail.com> Message-ID: <4C071134.8030509@gmail.com> I now see all the failures are due to all my controller specs always getting a response.body of type String with the value "RSpec-generated template" when I use the beta 9 version. I'm on rails edge. Any idea where this string might originate from? Can't find it in the rspec nor in the rails source; it's certainly not in my source.. weird. Cheers, Lawrence >> Hi, >> >> I've been using rspec 2.0.0 beta 8 for a while. All specs pass. Installed beta 9, and more than half fail. Am I the only one who's seeing this? Not sure what to do to get it all passing using beta 9.. >> > > What failures are you seeing? Please post some backtraces (at least one would help). > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 2 22:27:47 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Jun 2010 21:27:47 -0500 Subject: [rspec-users] beta 9 In-Reply-To: <4C071134.8030509@gmail.com> References: <4C06E1D4.6040503@gmail.com> <47231AE6-E86D-45E9-A0C2-06C579B874DA@gmail.com> <4C071134.8030509@gmail.com> Message-ID: On Jun 2, 2010, at 9:19 PM, Lawrence Pit wrote: > I now see all the failures are due to all my controller specs always getting a response.body of type String with the value "RSpec-generated template" when I use the beta 9 version. > > I'm on rails edge. > > Any idea where this string might originate from? Can't find it in the rspec nor in the rails source; it's certainly not in my source.. weird. Read the bit about controller specs and rendering views on http://github.com/rspec/rspec-rails. > > > > Cheers, > Lawrence > >>> Hi, >>> >>> I've been using rspec 2.0.0 beta 8 for a while. All specs pass. Installed beta 9, and more than half fail. Am I the only one who's seeing this? Not sure what to do to get it all passing using beta 9.. >>> >> >> What failures are you seeing? Please post some backtraces (at least one would help). >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lawrence.pit at gmail.com Wed Jun 2 23:24:47 2010 From: lawrence.pit at gmail.com (Lawrence Pit) Date: Thu, 03 Jun 2010 13:24:47 +1000 Subject: [rspec-users] beta 9 In-Reply-To: References: <4C06E1D4.6040503@gmail.com> <47231AE6-E86D-45E9-A0C2-06C579B874DA@gmail.com> <4C071134.8030509@gmail.com> Message-ID: <4C07207F.1080706@gmail.com> >> I now see all the failures are due to all my controller specs always getting a response.body of type String with the value "RSpec-generated template" when I use the beta 9 version. >> > Read the bit about controller specs and rendering views on http://github.com/rspec/rspec-rails. > Thanks, all green now with beta 9 Cheers, Lawrence From bcardarella at gmail.com Thu Jun 3 13:00:35 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Thu, 3 Jun 2010 10:00:35 -0700 (PDT) Subject: [rspec-users] Rails 3 + RSpec-Rails 2.0 generators (different question) Message-ID: I just tried 'rails g rspec:model SomeModel' and all I get back are the specs. I checked the generator file and it does seem that only the specs are being generated. Is the behavior we should expect from the rspec-rails generators? I would have thought it would generate the model file and the migrations as well. Should I be running the rails model generator as well? Would it make sense for the rspec-rails generator to call the rails generator? A quick check at the controller generator shows it is similar. - Brian From bcardarella at gmail.com Thu Jun 3 13:18:28 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Thu, 3 Jun 2010 10:18:28 -0700 (PDT) Subject: [rspec-users] Rails 3 + RSpec-Rails 2.0 generators (different question) In-Reply-To: References: Message-ID: <0a060f05-4dce-45c7-843f-b24a76d88369@u7g2000vbq.googlegroups.com> Nevermind, I see that the rspec generators will hook into the rails ones. So if I call 'rails g model SomeModel' it will call the rspec:model generator. Pretty sweet! - Brian On Jun 3, 1:00?pm, Brian Cardarella wrote: > I just tried 'rails g rspec:model SomeModel' and all I get back are > the specs. I checked the generator file and it does seem that only the > specs are being generated. > > Is the behavior we should expect from the rspec-rails generators? I > would have thought it would generate the model file and the migrations > as well. Should I be running the rails model generator as well? Would > it make sense for the rspec-rails generator to call the rails > generator? > > A quick check at the controller generator shows it is similar. > > - Brian > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From bcardarella at gmail.com Sat Jun 5 13:42:30 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 5 Jun 2010 10:42:30 -0700 (PDT) Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? Message-ID: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> Subject pretty much asks the question From dchelimsky at gmail.com Sat Jun 5 14:12:44 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Jun 2010 13:12:44 -0500 Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> Message-ID: <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: > Subject pretty much asks the question You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). From kmandrup at gmail.com Sat Jun 5 15:08:09 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sat, 5 Jun 2010 12:08:09 -0700 (PDT) Subject: [rspec-users] spec.opts is deprecated - Using options file with RSpec 2 Message-ID: <886e5b6c-180c-4ada-adad-d266c65df4f8@a30g2000yqn.googlegroups.com> Using RSpec 2 beta. $ rspec spec * spec/spec.opts is deprecated. * please use .rspec or ~/.rspec instead. I tried renaming the file to .rspec but then it has no effect! # spec/.rspec --format nested --color It works if I copy it to ~/.rspec and it turns out, also if I copy .rspec to the root of my application ;) From dchelimsky at gmail.com Sat Jun 5 15:12:11 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Jun 2010 15:12:11 -0400 Subject: [rspec-users] spec.opts is deprecated - Using options file with RSpec 2 In-Reply-To: <886e5b6c-180c-4ada-adad-d266c65df4f8@a30g2000yqn.googlegroups.com> References: <886e5b6c-180c-4ada-adad-d266c65df4f8@a30g2000yqn.googlegroups.com> Message-ID: On Jun 5, 2010, at 3:08 PM, Kristian Mandrup wrote: > Using RSpec 2 beta. > > $ rspec spec > > * spec/spec.opts is deprecated. > * please use .rspec or ~/.rspec instead. > > I tried renaming the file to .rspec but then it has no effect! > > # spec/.rspec > --format nested > --color > > It works if I copy it to ~/.rspec and it turns out, also if I > copy .rspec to the root of my application ;) That's what ".rspec" means. I'll change it to ./.rspec to make that more clear. From dchelimsky at gmail.com Sat Jun 5 15:33:03 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Jun 2010 15:33:03 -0400 Subject: [rspec-users] spec.opts is deprecated - Using options file with RSpec 2 In-Reply-To: References: <886e5b6c-180c-4ada-adad-d266c65df4f8@a30g2000yqn.googlegroups.com> Message-ID: <7EDCEDF0-3E35-43EA-A6B8-52168E375FC0@gmail.com> On Jun 5, 2010, at 3:12 PM, David Chelimsky wrote: > On Jun 5, 2010, at 3:08 PM, Kristian Mandrup wrote: > >> Using RSpec 2 beta. >> >> $ rspec spec >> >> * spec/spec.opts is deprecated. >> * please use .rspec or ~/.rspec instead. >> >> I tried renaming the file to .rspec but then it has no effect! >> >> # spec/.rspec >> --format nested >> --color >> >> It works if I copy it to ~/.rspec and it turns out, also if I >> copy .rspec to the root of my application ;) > > That's what ".rspec" means. I'll change it to ./.rspec to make that more clear. http://github.com/rspec/rspec-core/commit/8a5486ac1f0c13fdbbb64ac4bcd9529c21743e35 From bcardarella at gmail.com Sat Jun 5 15:34:31 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 5 Jun 2010 12:34:31 -0700 (PDT) Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> Message-ID: David, I'm not seeing that behavior. I have beta.10 and without using database_cleaner data is persisting after each spec and from suite run to suite run. I thought database_cleaner would resolve the issue but it doesn't seem to. - Bran On Jun 5, 2:12?pm, David Chelimsky wrote: > On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: > > > Subject pretty much asks the question > > You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Jun 5 15:42:59 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Jun 2010 15:42:59 -0400 Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> Message-ID: <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> On Jun 5, 2010, at 3:34 PM, Brian Cardarella wrote: > On Jun 5, 2:12 pm, David Chelimsky wrote: >> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: >> >>> Subject pretty much asks the question >> >> You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). > David, > > I'm not seeing that behavior. > > I have beta.10 and without using database_cleaner data is persisting > after each spec and from suite run to suite run. I thought > database_cleaner would resolve the issue but it doesn't seem to. I _am_ seeing that behaviour :) Are you using AR? What does your spec_helper look like? This cucumber feature passes: http://github.com/rspec/rspec-rails/blob/master/features/model_specs/transactional_examples.feature Not sure what's up, but there is something different about your environment. From kmandrup at gmail.com Sat Jun 5 15:43:28 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sat, 5 Jun 2010 12:43:28 -0700 (PDT) Subject: [rspec-users] spec.opts is deprecated - Using options file with RSpec 2 In-Reply-To: References: <886e5b6c-180c-4ada-adad-d266c65df4f8@a30g2000yqn.googlegroups.com> Message-ID: <5a66615e-202e-4e63-987d-32edd52b7bd8@c33g2000yqm.googlegroups.com> Thanks ;) I also tried to follow the instructions on using autospec/autotest, first from the RSpec book then from instructions found on the net. I managed to do the following so far: # config/cucumber.yml default: --format profile features html_report: --format progress --format html -- out=features_report.html features User specific # ~/.autotest require 'autotest/fsevent' require 'autotest/growl' # Skip some paths Autotest.add_hook :initialize do |autotest| %w{.git .DS_Store ._* vendor}.each { |exception| autotest.add_exception(exception) } false end Project specific /.autotest Autotest.add_hook(:initialize) {|at| at.add_exception %r{^\.git} # ignore Version Control System at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again... # at.clear_mappings # take out the default (test/test*rb) at.add_mapping(%r{^lib/.*\.rb$}) {|f, _| Dir['spec/**/*.rb'] } nil } $ autotest loading autotest/cucumber style: Cucumber -------------------------------------------------------------------------------- Using the default profile... But now it only outputs Cucumber feature results. How do I instruct it to ignore Cucumber for the time being and report only on my RSpec 2 specs in my spec dir? Thanks! From kmandrup at gmail.com Sat Jun 5 15:53:18 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sat, 5 Jun 2010 12:53:18 -0700 (PDT) Subject: [rspec-users] Problems running RSpec 2 with autotest/autospec Message-ID: <4f66d4df-b0c0-43ec-960a-56a2a15a2f6d@j4g2000yqh.googlegroups.com> It seems there is no bin/autospec with RSpec 2. So I got it running simply with $ autotest Been looking at instructions here http://wiki.github.com/dchelimsky/rspec/autotest-integration And here http://ph7spot.com/musings/getting-started-with-autotest But... $ RSPEC=true autotest loading autotest/cucumber_rspec Error loading Autotest style autotest/cucumber_rspec (no such file to load -- autotest/rspec). Aborting. What do I do here? I want to run it in "only rspec" mode for the time being. Also if I try to add the "redgreen" plugin # /.autotest require "autotest/restart" $ autotest loading autotest/cucumber style: Cucumber /Users/kristianconsult/.rvm/gems/ruby-1.9.2-head/gems/redgreen-1.2.2/ lib/redgreen/autotest.rb:6:in `': uninitialized constant Object::PLATFORM (NameError) Couldn't find anything on the net related to this error. A ruby 1.9.2 issue? From dchelimsky at gmail.com Sat Jun 5 16:00:51 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Jun 2010 16:00:51 -0400 Subject: [rspec-users] Problems running RSpec 2 with autotest/autospec In-Reply-To: <4f66d4df-b0c0-43ec-960a-56a2a15a2f6d@j4g2000yqh.googlegroups.com> References: <4f66d4df-b0c0-43ec-960a-56a2a15a2f6d@j4g2000yqh.googlegroups.com> Message-ID: On Jun 5, 2010, at 3:53 PM, Kristian Mandrup wrote: > It seems there is no bin/autospec with RSpec 2. So I got it running > simply with $ autotest > > Been looking at instructions here http://wiki.github.com/dchelimsky/rspec/autotest-integration > > And here http://ph7spot.com/musings/getting-started-with-autotest > > But... > > $ RSPEC=true autotest Don't use RSPEC=true for rspec-2. Also, probably need to set AUTOFEATURE=false. > loading autotest/cucumber_rspec > Error loading Autotest style autotest/cucumber_rspec (no such file to > load -- autotest/rspec). Aborting. > > What do I do here? I want to run it in "only rspec" mode for the time > being. > Also if I try to add the "redgreen" plugin You don't need this with rspec because rspec does it's own colorizing. HTH, David > > # /.autotest > require "autotest/restart" > > $ autotest > loading autotest/cucumber > style: Cucumber > /Users/kristianconsult/.rvm/gems/ruby-1.9.2-head/gems/redgreen-1.2.2/ > lib/redgreen/autotest.rb:6:in `': uninitialized > constant Object::PLATFORM (NameError) > > Couldn't find anything on the net related to this error. A ruby 1.9.2 > issue? From bcardarella at gmail.com Sat Jun 5 16:11:38 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 5 Jun 2010 13:11:38 -0700 (PDT) Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> Message-ID: <319e87bd-1e75-4f0b-9732-2e76363ddf6a@m4g2000vbl.googlegroups.com> Yeah, I'm not certain what the deal is. Here is my spec_helper: http://pastie.org/993256 I was using Spork but commented it out to see if that was an issue. Nope. I was using sqlite to see if the lack of a real transactional database was the issue. (changed to postgres) Nope. Not certain if this is of any help but here is my Gemfile: http://pastie.org/993259 (it's a mess, I know) This is confusing. :p - Brian On Jun 5, 3:42?pm, David Chelimsky wrote: > On Jun 5, 2010, at 3:34 PM, Brian Cardarella wrote: > > > On Jun 5, 2:12 pm, David Chelimsky wrote: > >> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: > > >>> Subject pretty much asks the question > > >> You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). > > David, > > > I'm not seeing that behavior. > > > I have beta.10 and without using database_cleaner data is persisting > > after each spec and from suite run to suite run. I thought > > database_cleaner would resolve the issue but it doesn't seem to. > > I _am_ seeing that behaviour :) > > Are you using AR? What does your spec_helper look like? > > This cucumber feature passes: > > http://github.com/rspec/rspec-rails/blob/master/features/model_specs/... > > Not sure what's up, but there is something different about your environment. > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From bcardarella at gmail.com Sat Jun 5 16:12:31 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 5 Jun 2010 13:12:31 -0700 (PDT) Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> Message-ID: <1c916c6b-9a3f-49b9-8f7f-ef9cdfda5d4f@q33g2000vbt.googlegroups.com> Sorry, forgot to answer the other question. I am using ActiveRecord. Just a greenfield Rails 3.0.0.beta3 app - Brian On Jun 5, 3:42?pm, David Chelimsky wrote: > On Jun 5, 2010, at 3:34 PM, Brian Cardarella wrote: > > > On Jun 5, 2:12 pm, David Chelimsky wrote: > >> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: > > >>> Subject pretty much asks the question > > >> You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). > > David, > > > I'm not seeing that behavior. > > > I have beta.10 and without using database_cleaner data is persisting > > after each spec and from suite run to suite run. I thought > > database_cleaner would resolve the issue but it doesn't seem to. > > I _am_ seeing that behaviour :) > > Are you using AR? What does your spec_helper look like? > > This cucumber feature passes: > > http://github.com/rspec/rspec-rails/blob/master/features/model_specs/... > > Not sure what's up, but there is something different about your environment. > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From bcardarella at gmail.com Sat Jun 5 16:20:54 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 5 Jun 2010 13:20:54 -0700 (PDT) Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: <1c916c6b-9a3f-49b9-8f7f-ef9cdfda5d4f@q33g2000vbt.googlegroups.com> References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> <1c916c6b-9a3f-49b9-8f7f-ef9cdfda5d4f@q33g2000vbt.googlegroups.com> Message-ID: Ok, something else is going on because I just generated a brand new app with rspec-2.0.beta.10 and the transactions are working just fine. Sorry about that, I'll track down the issue. - Brian On Jun 5, 4:12?pm, Brian Cardarella wrote: > Sorry, forgot to answer the other question. I am using ActiveRecord. > Just a greenfield Rails 3.0.0.beta3 app > > - Brian > > On Jun 5, 3:42?pm, David Chelimsky wrote: > > > > > On Jun 5, 2010, at 3:34 PM, Brian Cardarella wrote: > > > > On Jun 5, 2:12 pm, David Chelimsky wrote: > > >> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: > > > >>> Subject pretty much asks the question > > > >> You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). > > > David, > > > > I'm not seeing that behavior. > > > > I have beta.10 and without using database_cleaner data is persisting > > > after each spec and from suite run to suite run. I thought > > > database_cleaner would resolve the issue but it doesn't seem to. > > > I _am_ seeing that behaviour :) > > > Are you using AR? What does your spec_helper look like? > > > This cucumber feature passes: > > >http://github.com/rspec/rspec-rails/blob/master/features/model_specs/... > > > Not sure what's up, but there is something different about your environment. > > > _______________________________________________ > > 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 From dchelimsky at gmail.com Sat Jun 5 16:21:16 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Jun 2010 16:21:16 -0400 Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: <319e87bd-1e75-4f0b-9732-2e76363ddf6a@m4g2000vbl.googlegroups.com> References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> <319e87bd-1e75-4f0b-9732-2e76363ddf6a@m4g2000vbl.googlegroups.com> Message-ID: <8BE011AA-1B2F-4692-8173-B5564F7268F2@gmail.com> On Jun 5, 2010, at 4:11 PM, Brian Cardarella wrote: > Yeah, I'm not certain what the deal is. > > Here is my spec_helper: http://pastie.org/993256 > > I was using Spork but commented it out to see if that was an issue. > Nope. > I was using sqlite to see if the lack of a real transactional database > was the issue. (changed to postgres) Nope. > > Not certain if this is of any help but here is my Gemfile: http://pastie.org/993259 I see two rspec-rails references in your Gemfile - not sure if that's the issue, but it could be. > (it's a mess, I know) > > This is confusing. :p > > - Brian > > On Jun 5, 3:42 pm, David Chelimsky wrote: >> On Jun 5, 2010, at 3:34 PM, Brian Cardarella wrote: >> >>> On Jun 5, 2:12 pm, David Chelimsky wrote: >>>> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: >> >>>>> Subject pretty much asks the question >> >>>> You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). >>> David, >> >>> I'm not seeing that behavior. >> >>> I have beta.10 and without using database_cleaner data is persisting >>> after each spec and from suite run to suite run. I thought >>> database_cleaner would resolve the issue but it doesn't seem to. >> >> I _am_ seeing that behaviour :) >> >> Are you using AR? What does your spec_helper look like? >> >> This cucumber feature passes: >> >> http://github.com/rspec/rspec-rails/blob/master/features/model_specs/... >> >> Not sure what's up, but there is something different about your environment. >> >> _______________________________________________ >> 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 From bcardarella at gmail.com Sat Jun 5 17:06:36 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 5 Jun 2010 14:06:36 -0700 (PDT) Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: <8BE011AA-1B2F-4692-8173-B5564F7268F2@gmail.com> References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> <319e87bd-1e75-4f0b-9732-2e76363ddf6a@m4g2000vbl.googlegroups.com> <8BE011AA-1B2F-4692-8173-B5564F7268F2@gmail.com> Message-ID: <0d6174cf-7f67-4b95-997b-cc3931a6c2ae@y11g2000yqm.googlegroups.com> Okay, it's going to be one of those weekends. I forgot to wrap the example in an 'it' block. It was just a bare 'context' block running the code. False alarm! :D - Brian On Jun 5, 4:21?pm, David Chelimsky wrote: > On Jun 5, 2010, at 4:11 PM, Brian Cardarella wrote: > > > Yeah, I'm not certain what the deal is. > > > Here is my spec_helper:http://pastie.org/993256 > > > I was using Spork but commented it out to see if that was an issue. > > Nope. > > I was using sqlite to see if the lack of a real transactional database > > was the issue. (changed to postgres) Nope. > > > Not certain if this is of any help but here is my Gemfile:http://pastie.org/993259 > > I see two rspec-rails references in your Gemfile - not sure if that's the issue, but it could be. > > > > > > > (it's a mess, I know) > > > This is confusing. :p > > > - Brian > > > On Jun 5, 3:42 pm, David Chelimsky wrote: > >> On Jun 5, 2010, at 3:34 PM, Brian Cardarella wrote: > > >>> On Jun 5, 2:12 pm, David Chelimsky wrote: > >>>> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: > > >>>>> Subject pretty much asks the question > > >>>> You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). > >>> David, > > >>> I'm not seeing that behavior. > > >>> I have beta.10 and without using database_cleaner data is persisting > >>> after each spec and from suite run to suite run. I thought > >>> database_cleaner would resolve the issue but it doesn't seem to. > > >> I _am_ seeing that behaviour :) > > >> Are you using AR? What does your spec_helper look like? > > >> This cucumber feature passes: > > >>http://github.com/rspec/rspec-rails/blob/master/features/model_specs/... > > >> Not sure what's up, but there is something different about your environment. > > >> _______________________________________________ > >> 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 From dchelimsky at gmail.com Sat Jun 5 17:17:10 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Jun 2010 17:17:10 -0400 Subject: [rspec-users] Should I be using database_cleaner to tear down data in RSpec 2.0 + Rails 3.0? In-Reply-To: References: <7a8f4639-c81b-4568-ac91-7e4be5992563@q13g2000vbm.googlegroups.com> <053094F8-3508-4E1D-99C4-737DFDF6BF09@gmail.com> <0E47FB0A-83B1-4654-A939-A031965DE661@gmail.com> <1c916c6b-9a3f-49b9-8f7f-ef9cdfda5d4f@q33g2000vbt.googlegroups.com> Message-ID: On Jun 5, 2010, at 4:20 PM, Brian Cardarella wrote: > Ok, something else is going on because I just generated a brand new > app with rspec-2.0.beta.10 and the transactions are working just fine. > Sorry about that, I'll track down the issue. Happens :) Good luck. > > - Brian > > On Jun 5, 4:12 pm, Brian Cardarella wrote: >> Sorry, forgot to answer the other question. I am using ActiveRecord. >> Just a greenfield Rails 3.0.0.beta3 app >> >> - Brian >> >> On Jun 5, 3:42 pm, David Chelimsky wrote: >> >> >> >>> On Jun 5, 2010, at 3:34 PM, Brian Cardarella wrote: >> >>>> On Jun 5, 2:12 pm, David Chelimsky wrote: >>>>> On Jun 5, 2010, at 12:42 PM, Brian Cardarella wrote: >> >>>>>> Subject pretty much asks the question >> >>>>> You _can_, but if you use ActiveRecord and start off with a clean DB, you can use_transactional_examples (alias for use_transactional_fixtures, which defaults to true in beta.10, but will default to false in beta.11). >>>> David, >> >>>> I'm not seeing that behavior. >> >>>> I have beta.10 and without using database_cleaner data is persisting >>>> after each spec and from suite run to suite run. I thought >>>> database_cleaner would resolve the issue but it doesn't seem to. >> >>> I _am_ seeing that behaviour :) >> >>> Are you using AR? What does your spec_helper look like? >> >>> This cucumber feature passes: >> >>> http://github.com/rspec/rspec-rails/blob/master/features/model_specs/... >> >>> Not sure what's up, but there is something different about your environment. >> >>> _______________________________________________ >>> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From kmandrup at gmail.com Sat Jun 5 17:29:12 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sat, 5 Jun 2010 14:29:12 -0700 (PDT) Subject: [rspec-users] Problems running RSpec 2 with autotest/autospec In-Reply-To: References: <4f66d4df-b0c0-43ec-960a-56a2a15a2f6d@j4g2000yqh.googlegroups.com> Message-ID: <13c3e4b1-50f6-4b0e-91d3-3b75db5e4c8a@t10g2000yqg.googlegroups.com> Thanks again David :) > Don't use RSPEC=true for rspec-2. > > Also, probably need to set AUTOFEATURE=false. > OK, when I run it like this $ AUTOFEATURE=false autotest I get an empty autotest output whenever I change and save a spec. The above lets me disable features, but how do I ENABLE specs with rspec 2 if I can't use RSPEC=true? > > You don't need this with rspec because rspec does it's own colorizing. Great! I disabled redgreen from my .autotest file. Now I just need to get autotest working with RSpec 2 and coloring ;) PS: I added an RSpec 2 notes section to the bottom of the autotest instructions at: http://wiki.github.com/dchelimsky/rspec/autotest-integration I know... there is a separate wiki for the rspec account as well, but that wiki seems to have even less instructions. I would like to add some wiki info there when I get all this working! From kmandrup at gmail.com Sat Jun 5 17:38:07 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sat, 5 Jun 2010 14:38:07 -0700 (PDT) Subject: [rspec-users] Problems running RSpec 2 with autotest/autospec In-Reply-To: <4f66d4df-b0c0-43ec-960a-56a2a15a2f6d@j4g2000yqh.googlegroups.com> References: <4f66d4df-b0c0-43ec-960a-56a2a15a2f6d@j4g2000yqh.googlegroups.com> Message-ID: <46a2089e-bcd7-4ebe-adff-ace255afaec4@k39g2000yqb.googlegroups.com> I found the solution here: http://blog.davidchelimsky.net/category/autotest/ -- As of beta.4, you?ll have to do add this configuration manually. Just create an autotest directory in the root of your project, put the following statement in ./autotest/discover.rb: Autotest.add_discovery { "rspec2" } The final 2.0.0 release will include a generator (even for non-rails projects) that will add this for you. -- $ AUTOFEATURE=false autotest (Not running features. To run features in autotest, set AUTOFEATURE=true.) loading autotest/rspec2 style: Rspec2 From kmandrup at gmail.com Sat Jun 5 18:08:57 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sat, 5 Jun 2010 15:08:57 -0700 (PDT) Subject: [rspec-users] Problems running RSpec 2 with autotest/autospec In-Reply-To: References: <4f66d4df-b0c0-43ec-960a-56a2a15a2f6d@j4g2000yqh.googlegroups.com> Message-ID: Thanks! I solved it all now and updated the RSpec 2 wiki about how to set it all up ;) http://wiki.github.com/rspec/rspec/autotest Hope these instructions provides a good base and is helpful to others! From lists at ruby-forum.com Sun Jun 6 13:28:50 2010 From: lists at ruby-forum.com (Rob Lingle) Date: Sun, 6 Jun 2010 19:28:50 +0200 Subject: [rspec-users] Rails 3, Rspec 2, Autotest In-Reply-To: References: <1fe754a00478376a73632b794f3c9f43@ruby-forum.com> <102c797c-8384-4512-80ff-5106f9f1ca75@u7g2000vbq.googlegroups.com> Message-ID: <2c6c11faf2997269c9ab003d319a613e@ruby-forum.com> I found that I could get rid of my original error: loading autotest/rails_rspec2 Autotest style autotest/rails_rspec2 doesn't seem to exist. Aborting. By installing rspec-rails on my system: sudo gem install rspec-rails -v=2.0.0.beta.8 Now when I run autotest in my app- or in the example app from the gist- I get: rodeo:example rob$ autotest loading autotest/rails_rspec2 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -rrubygems /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/bin/rspec /Users/rob/example/spec/views/widgets/new.html.erb_spec.rb /Users/rob/example/spec/controllers/widgets_controller_spec.rb /Users/rob/example/spec/views/widgets/show.html.erb_spec.rb /Users/rob/example/spec/views/widgets/index.html.erb_spec.rb /Users/rob/example/spec/views/widgets/edit.html.erb_spec.rb /Users/rob/example/spec/helpers/widgets_helper_spec.rb /Users/rob/example/spec/models/widget_spec.rb /Users/rob/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.10/lib/rspec/rails/matchers.rb:22: uninitialized constant RSpec::Matchers (NameError) from /Users/rob/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.10/lib/rspec/rails.rb:7 from /Users/rob/example/spec/spec_helper.rb:5 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Users/rob/example/spec/views/widgets/new.html.erb_spec.rb:1 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/configuration.rb:233:in `require_files_to_run' from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/configuration.rb:233:in `map' from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/configuration.rb:233:in `require_files_to_run' from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:37:in `configure' from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:24:in `run' from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:in `autorun' from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/bin/rspec:2 -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Jun 6 13:42:08 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 6 Jun 2010 13:42:08 -0400 Subject: [rspec-users] Rails 3, Rspec 2, Autotest In-Reply-To: <2c6c11faf2997269c9ab003d319a613e@ruby-forum.com> References: <1fe754a00478376a73632b794f3c9f43@ruby-forum.com> <102c797c-8384-4512-80ff-5106f9f1ca75@u7g2000vbq.googlegroups.com> <2c6c11faf2997269c9ab003d319a613e@ruby-forum.com> Message-ID: On Jun 6, 2010, at 1:28 PM, Rob Lingle wrote: > I found that I could get rid of my original error: > > loading autotest/rails_rspec2 > Autotest style autotest/rails_rspec2 doesn't seem to exist. Aborting. > > By installing rspec-rails on my system: > > sudo gem install rspec-rails -v=2.0.0.beta.8 Try beta.10. The backtrace below shows a mix of 8 and 10. HTH > > Now when I run autotest in my app- or in the example app from the > gist- > I get: > > rodeo:example rob$ autotest > loading autotest/rails_rspec2 > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby > -rrubygems /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/bin/ > rspec > /Users/rob/example/spec/views/widgets/new.html.erb_spec.rb > /Users/rob/example/spec/controllers/widgets_controller_spec.rb > /Users/rob/example/spec/views/widgets/show.html.erb_spec.rb > /Users/rob/example/spec/views/widgets/index.html.erb_spec.rb > /Users/rob/example/spec/views/widgets/edit.html.erb_spec.rb > /Users/rob/example/spec/helpers/widgets_helper_spec.rb > /Users/rob/example/spec/models/widget_spec.rb > /Users/rob/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.10/lib/rspec/ > rails/matchers.rb:22: > uninitialized constant RSpec::Matchers (NameError) > from > /Users/rob/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.10/lib/rspec/ > rails.rb:7 > from /Users/rob/example/spec/spec_helper.rb:5 > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require' > from /Users/rob/example/spec/views/widgets/new.html.erb_spec.rb:1 > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require' > from > /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/ > configuration.rb:233:in > `require_files_to_run' > from > /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/ > configuration.rb:233:in > `map' > from > /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/ > configuration.rb:233:in > `require_files_to_run' > from > /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/ > runner.rb:37:in > `configure' > from > /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/ > runner.rb:24:in > `run' > from > /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/ > runner.rb:12:in > `autorun' > from /Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.8/bin/rspec:2 > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sun Jun 6 14:23:20 2010 From: lists at ruby-forum.com (Rob Lingle) Date: Sun, 6 Jun 2010 20:23:20 +0200 Subject: [rspec-users] Rails 3, Rspec 2, Autotest In-Reply-To: References: <1fe754a00478376a73632b794f3c9f43@ruby-forum.com> <102c797c-8384-4512-80ff-5106f9f1ca75@u7g2000vbq.googlegroups.com> <2c6c11faf2997269c9ab003d319a613e@ruby-forum.com> Message-ID: That got it, thanks! -- Posted via http://www.ruby-forum.com/. From kmandrup at gmail.com Sun Jun 6 19:42:00 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sun, 6 Jun 2010 16:42:00 -0700 (PDT) Subject: [rspec-users] Mocking and specing command line (cli) execution, file operations etc. ? Message-ID: <698e9e64-a1bc-4437-88a1-54ea43b7477d@e28g2000vbd.googlegroups.com> What are the options for creating specs for file operations, executing commands in the CLI etc.? If I build a generator or something which runs a lot of things in the command line, how do I check the results of these operations, fx mocking file system updates and/or mocking the STDOUT/STDIN from the terminal? There must be some add-on libraries or options for this out there to make it easy to accomplish. - Kristian From dchelimsky at gmail.com Sun Jun 6 23:06:56 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 6 Jun 2010 23:06:56 -0400 Subject: [rspec-users] Mocking and specing command line (cli) execution, file operations etc. ? In-Reply-To: <698e9e64-a1bc-4437-88a1-54ea43b7477d@e28g2000vbd.googlegroups.com> References: <698e9e64-a1bc-4437-88a1-54ea43b7477d@e28g2000vbd.googlegroups.com> Message-ID: On Jun 6, 2010, at 7:42 PM, Kristian Mandrup wrote: > What are the options for creating specs for file operations, executing > commands in the CLI etc.? > > If I build a generator or something which runs a lot of things in the > command line, how do I check the results of these operations, fx > mocking file system updates and/or mocking the STDOUT/STDIN from the > terminal? > > There must be some add-on libraries or options for this out there to > make it easy to accomplish. Check out Fakefs (http://github.com/defunkt/fakefs) for file operations. There's a cucumber library called aruba (http://github.com/aslakhellesoy/aruba) that was extracted from spec suites for rspec and cucumber specifically to deal with command line applications and their output. It's got cucumber step definitions, but there is a separate api file that has methods you should be able to use to help with this stuff if you're using rspec. Or, you could just use cucumber for that stuff as well. HTH, David From ben.butlercole at gmail.com Mon Jun 7 10:13:23 2010 From: ben.butlercole at gmail.com (Ben Butler-Cole) Date: Mon, 7 Jun 2010 15:13:23 +0100 Subject: [rspec-users] (no subject) Message-ID: Hello. I'm trying to use RSpec's mocks to describe code which passes a block to a collaborator. I want to write an assertion against the value returned by the block. I can't find any explicit support for this in RSpec, but perhaps I have missed something. I have come up with a hack which almost does what I want, by hijacking the and_return block (see http://gist.github.com/428624). But this doesn't work for more complex cases where there are multiple calls in the code under test which pass different blocks. Is there any way to make assertions like this? From looking at the code, I think it would take some significant changes to support this; but it doesn't seem to be a terribly esoteric use case. Thanks for any suggestions. -Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Jun 7 10:25:32 2010 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 7 Jun 2010 15:25:32 +0100 Subject: [rspec-users] (no subject) In-Reply-To: References: Message-ID: On 7 Jun 2010, at 15:13, Ben Butler-Cole wrote: > Hello. > > I'm trying to use RSpec's mocks to describe code which passes a block to a collaborator. I want to write an assertion against the value returned by the block. I can't find any explicit support for this in RSpec, but perhaps I have missed something. > > I have come up with a hack which almost does what I want, by hijacking the and_return block (see http://gist.github.com/428624). But this doesn't work for more complex cases where there are multiple calls in the code under test which pass different blocks. > > Is there any way to make assertions like this? From looking at the code, I think it would take some significant changes to support this; but it doesn't seem to be a terribly esoteric use case. > > Thanks for any suggestions. Have you seen and_yield? I can't quite get my head around what you're trying to do, but it might help anyway: http://rspec.info/documentation/mocks/message_expectations.html cheers, Matt > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at bridesmere.com Mon Jun 7 10:56:50 2010 From: ben at bridesmere.com (Ben Butler-Cole) Date: Mon, 7 Jun 2010 15:56:50 +0100 Subject: [rspec-users] mock assertions on block parameters Message-ID: On 7 June 2010 15:25, Matt Wynne wrote: Have you seen and_yield? I can't quite get my head around what you're trying > to do, but it might help anyway > Thank you, I have. My understanding is that #and_yield has much the same use as #and_return (in its non-bastardized-by-me-form). That is, you specify it in order to make the mocked-out collaborator behave enough like the real collaborator that the object-under-test can work properly. I'll try to explain what I'm aiming for more comprehensibly. If I my object-under-test calls a method with a parameter, I can make assertions against the values passed. The simplest is equality: foo.should_receive(:bar).with(6) The corresponding code in the object-under-test is foo.bar(6) and the real code for the collaborator is something like: class Foo def bar(x) // ... end end Now the collaborator in my case doesn't take a parameter, it takes a block: class Foo2 def bar2(&block) // ... end end and the object-under-test passes in a block which is called later for its return value: foo2.bar2 { 6 } (The real block doesn't return a constant, obviously. It returns something which needs to be evaluated lazily because its dependencies don't exist yet.) I want to test that the block passed in is the block that I expect. Something like (in an imaginary world): foo2.should_receive(:foo2).with(block(yielding(6))) (In fact, in my case I can't just assert equality on the return value from the block. I'm actually going to test its type.) The corresponding test using my obscene #and_return hack looks like this: foo2.should_receive(:foo2).and_return { |block| block.call.should ==6 } But this doesn't scale to multiple calls to #foo2 in the object under test because RSpec (understandably) matches its expectations against invocations based on method name and argument matchers. -Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Jun 7 11:34:00 2010 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 7 Jun 2010 16:34:00 +0100 Subject: [rspec-users] mock assertions on block parameters In-Reply-To: References: Message-ID: On 7 Jun 2010, at 15:56, Ben Butler-Cole wrote: > On 7 June 2010 15:25, Matt Wynne wrote: > > Have you seen and_yield? I can't quite get my head around what you're trying to do, but it might help anyway > > Thank you, I have. My understanding is that #and_yield has much the same use as #and_return (in its non-bastardized-by-me-form). That is, you specify it in order to make the mocked-out collaborator behave enough like the real collaborator that the object-under-test can work properly. > > I'll try to explain what I'm aiming for more comprehensibly. > > If I my object-under-test calls a method with a parameter, I can make assertions against the values passed. The simplest is equality: > > foo.should_receive(:bar).with(6) > > The corresponding code in the object-under-test is > > foo.bar(6) > > and the real code for the collaborator is something like: > > class Foo > def bar(x) > // ... > end > end > > Now the collaborator in my case doesn't take a parameter, it takes a block: > > class Foo2 > def bar2(&block) > // ... > end > end > > and the object-under-test passes in a block which is called later for its return value: > > foo2.bar2 { 6 } > > (The real block doesn't return a constant, obviously. It returns something which needs to be evaluated lazily because its dependencies don't exist yet.) > > I want to test that the block passed in is the block that I expect. Something like (in an imaginary world): > > foo2.should_receive(:foo2).with(block(yielding(6))) > > (In fact, in my case I can't just assert equality on the return value from the block. I'm actually going to test its type.) > > The corresponding test using my obscene #and_return hack looks like this: > > foo2.should_receive(:foo2).and_return { |block| block.call.should ==6 } > > But this doesn't scale to multiple calls to #foo2 in the object under test because RSpec (understandably) matches its expectations against invocations based on method name and argument matchers. I'm still not quite clear what you're trying to achieve. Do you want to assert that a specific block is passed to the collaborator, or do you want to assert that any old block with a particular behaviour is passed to the collaborator? If it's the former, you can test it by creating a test double for the block, and asserting that it's passed to the collaborator, like this: http://gist.github.com/428801 Does that help? > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at bridesmere.com Mon Jun 7 11:52:52 2010 From: ben at bridesmere.com (Ben Butler-Cole) Date: Mon, 7 Jun 2010 16:52:52 +0100 Subject: [rspec-users] mock assertions on block parameters In-Reply-To: References: Message-ID: On 7 June 2010 16:34, Matt Wynne wrote: I'm still not quite clear what you're trying to achieve. Do you want to > assert that a specific block is passed to the collaborator, or do you want > to assert that any old block with a particular behaviour is passed to the > collaborator? > > If it's the former, you can test it by creating a test double for the > block, and asserting that it's passed to the collaborator > The later. The block gets created by the code under test, so I can't create a double for it. -Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Jun 7 12:15:59 2010 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 7 Jun 2010 17:15:59 +0100 Subject: [rspec-users] mock assertions on block parameters In-Reply-To: References: Message-ID: <6C0FBB21-E884-4FAA-A71E-20552D98CDE0@mattwynne.net> On 7 Jun 2010, at 16:52, Ben Butler-Cole wrote: > On 7 June 2010 16:34, Matt Wynne wrote: > > I'm still not quite clear what you're trying to achieve. Do you want to assert that a specific block is passed to the collaborator, or do you want to assert that any old block with a particular behaviour is passed to the collaborator? > > If it's the former, you can test it by creating a test double for the block, and asserting that it's passed to the collaborator > > The later. The block gets created by the code under test, so I can't create a double for it. Aha OK. I don't know how to do that using RSpec's mocking framework. I'd probably just build my own test double for the collaborator, giving it some simple behaviour to test the block. Something like this: http://gist.github.com/428867 There might be a way to do this using custom matchers[1] but I don't know how to do it myself. Hopefully someone else will chime in if there is. cheers, Matt [1]http://wiki.github.com/dchelimsky/rspec/custom-matchers > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Mon Jun 7 17:43:14 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Mon, 7 Jun 2010 16:43:14 -0500 Subject: [rspec-users] How to test the assignment of current_user Message-ID: Hello, This could be rephrased as -- How to test calls of special assigment (setter) methods? I am trying to test the assigmnet of a user object to the current_user=(new_user) method. It is part of an authentication process and finally the object is assigned to the session through this method. I have tried: controller.should_receive(:current_user=).with(@user) post :create, @params And the output is: expected :current_user= with (# ) once, but received it 0 times I do not understand, since current_user=(new_user) is actually being called by the controller: def create current_user = @user end Why's that? Thanks, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinibaggio at gmail.com Mon Jun 7 18:48:33 2010 From: vinibaggio at gmail.com (=?ISO-8859-1?Q?Vin=EDcius_Baggio_Fuentes?=) Date: Mon, 7 Jun 2010 19:48:33 -0300 Subject: [rspec-users] How to test the assignment of current_user In-Reply-To: References: Message-ID: If current_user is an instance variable (as if you did attr_accessor :current_user), you should try: @current_user = @user If not, you should try invoking with self: self.current_user = @user because ruby is creating a local variable named current_user instead of invoking #current_user=. When you do call self, which refers to the object itself, it will use normal method lookup, that will find your #current_user=. On Mon, Jun 7, 2010 at 6:43 PM, Marcelo de Moraes Serpa wrote: > Hello, > > This could be rephrased as -- How to test calls of special assigment > (setter) methods? > > I am trying to test the assigmnet of a user object to the > current_user=(new_user) method. It is part of an authentication process and > finally the object is assigned to the session through this method. I have > tried: > > controller.should_receive(:current_user=).with(@user) > post :create, @params > > And the output is: > > expected :current_user= with (# ) once, but > received it 0 times > > I do not understand, since current_user=(new_user) is actually being called > by the controller: > > def create > > current_user = @user > > end > > Why's that? > > Thanks, > > Marcelo. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinibaggio at gmail.com Mon Jun 7 18:50:00 2010 From: vinibaggio at gmail.com (=?ISO-8859-1?Q?Vin=EDcius_Baggio_Fuentes?=) Date: Mon, 7 Jun 2010 19:50:00 -0300 Subject: [rspec-users] How to test the assignment of current_user In-Reply-To: References: Message-ID: Oh yes, forgot to add that, if you do self.current_user = user, it will call your mock as expected. Sorry for the multitude of emails. 2010/6/7 Vin?cius Baggio Fuentes > If current_user is an instance variable (as if you did attr_accessor > :current_user), you should try: > @current_user = @user > > If not, you should try invoking with self: > self.current_user = @user > > because ruby is creating a local variable named current_user instead of > invoking #current_user=. When you do call self, which refers to the object > itself, it will use normal method lookup, that will find your > #current_user=. > > On Mon, Jun 7, 2010 at 6:43 PM, Marcelo de Moraes Serpa < > celoserpa at gmail.com> wrote: > >> Hello, >> >> This could be rephrased as -- How to test calls of special assigment >> (setter) methods? >> >> I am trying to test the assigmnet of a user object to the >> current_user=(new_user) method. It is part of an authentication process and >> finally the object is assigned to the session through this method. I have >> tried: >> >> controller.should_receive(:current_user=).with(@user) >> post :create, @params >> >> And the output is: >> >> expected :current_user= with (# ) once, but >> received it 0 times >> >> I do not understand, since current_user=(new_user) is actually being >> called by the controller: >> >> def create >> >> current_user = @user >> >> end >> >> Why's that? >> >> Thanks, >> >> Marcelo. >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Mon Jun 7 20:55:06 2010 From: ben at benmabey.com (Ben Mabey) Date: Mon, 07 Jun 2010 18:55:06 -0600 Subject: [rspec-users] Mocking and specing command line (cli) execution, file operations etc. ? In-Reply-To: <698e9e64-a1bc-4437-88a1-54ea43b7477d@e28g2000vbd.googlegroups.com> References: <698e9e64-a1bc-4437-88a1-54ea43b7477d@e28g2000vbd.googlegroups.com> Message-ID: <4C0D94EA.1070903@benmabey.com> Kristian Mandrup wrote: > What are the options for creating specs for file operations, executing > commands in the CLI etc.? > > If I build a generator or something which runs a lot of things in the > command line, how do I check the results of these operations, fx > mocking file system updates and/or mocking the STDOUT/STDIN from the > terminal? > > There must be some add-on libraries or options for this out there to > make it easy to accomplish. > In addition to aruba if you want to just use RSpec with StringIO objects you might find this example group handy: http://github.com/bmabey/clispec/blob/master/lib/clispec/example_groups/runner.rb The example group assumes you follow the "runner" pattern where your Runner class has a ::run method that takes args, out_stream, error_stream. Many libraries use this pattern including Cucumber and RSpec. The RSpec Book CLI app is setup this way as well if you want to see an in-depth example. In general, for simple CLIs aruba is probably the way to go though. This example group is probably best if you want/need to use mocking more to avoid expensive operations. HTH, Ben From amir.nagri at gmail.com Tue Jun 8 04:05:39 2010 From: amir.nagri at gmail.com (Amiruddin Nagri) Date: Tue, 8 Jun 2010 13:35:39 +0530 Subject: [rspec-users] Error while running rspec after unpacking rails gems Message-ID: I have a bunch of rspec test that are running fine when I don't freeze them in the vendor folder. But when I freeze the rails gems, the spec starts failing with the stack /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks': can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.1.0 for ["rspec-rails-1.3.2"] (RuntimeError) from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:134:in `process' from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in `send' from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in `run' from /home/xuser/myprojects/xproject/config/environment.rb:9 from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4:in `require' from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4 from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in `require' from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in `require' from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 I zeroed down the error to this line in spec_helper in spec folder > require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) But when I remove this line the specs starts failing with the below stack /home/xuser/myprojects/xproject/spec/spec_helper.rb:5:in `require': no such file to load -- spec/rails (LoadError) from /home/xuser/myprojects/xproject/spec/spec_helper.rb:5 from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in `require' from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in `require' from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 Is there anything I am missing ? I want to freeze my gems and check them in with the application. Regards, Amiruddin Nagri, Bangalore, 560008, KA India Y! IM : amir_nagri at yahoo.com GTalk : amir.nagri at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jun 8 08:26:00 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 8 Jun 2010 08:26:00 -0400 Subject: [rspec-users] Error while running rspec after unpacking rails gems In-Reply-To: References: Message-ID: On Jun 8, 2010, at 4:05 AM, Amiruddin Nagri wrote: > I have a bunch of rspec test that are running fine when I don't freeze them in the vendor folder. > > But when I freeze the rails gems, the spec starts failing with the stack > > /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks': can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.1.0 for ["rspec-rails-1.3.2"] (RuntimeError) > from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:134:in `process' > from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in `send' > from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in `run' > from /home/xuser/myprojects/xproject/config/environment.rb:9 > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4:in `require' > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4 > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in `require' > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in `require' > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load_files' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 Try using 'script/spec' instead of 'spec'. > > I zeroed down the error to this line in spec_helper in spec folder > > > require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) > > But when I remove this line the specs starts failing with the below stack > > /home/xuser/myprojects/xproject/spec/spec_helper.rb:5:in `require': no such file to load -- spec/rails (LoadError) > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:5 > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in `require' > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in `require' > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load_files' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 > > > Is there anything I am missing ? I want to freeze my gems and check them in with the application. From trey at 12spokes.com Tue Jun 8 10:30:32 2010 From: trey at 12spokes.com (Trey Bean) Date: Tue, 8 Jun 2010 08:30:32 -0600 Subject: [rspec-users] How do I stub a view in rspec-2 Message-ID: Hi, I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that stubbing a view helper method has changed in Rspec 2. It looks like instead of doing template.stub!, we're now supposed to do view.stub!, but I can't seem to get this to work on beta 10. I get an "undefined local variable or method `view' for #" error. I see that in this commit (http://github.com/rspec/rspec-rails/commit/ 0e860f580618045a34c17069b308c093e2e830cb) David removed the view method, but I can't figure out what it was replaced with. Something in ActionView::TestCase::Behavior? I'm on rails 3.0.0.beta3. Any idea what I'm missing? Thanks, Trey -------------- next part -------------- An HTML attachment was scrubbed... URL: From trey at 12spokes.com Tue Jun 8 10:26:09 2010 From: trey at 12spokes.com (Trey Bean) Date: Tue, 8 Jun 2010 08:26:09 -0600 Subject: [rspec-users] How do I stub a view in rspec-2 Message-ID: Hi, I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that stubbing a view helper method has changed in Rspec 2. It looks like instead of doing template.stub!, we're now supposed to do view.stub!, but I can't seem to get this to work on beta 10. I get an "undefined local variable or method `view' for #" error. I see that in this commit (http://github.com/rspec/rspec-rails/commit/ 0e860f580618045a34c17069b308c093e2e830cb) David removed the view method, but I can't figure out what it was replaced with. Something in ActionView::TestCase::Behavior? I'm on rails 3.0.0.beta3. Any idea what I'm missing? Thanks, Trey -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jun 8 12:15:18 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 8 Jun 2010 12:15:18 -0400 Subject: [rspec-users] How do I stub a view in rspec-2 In-Reply-To: References: Message-ID: <0E50DA45-5146-4CA5-BEE4-DB7A66ABCA7B@gmail.com> On Jun 8, 2010, at 10:26 AM, Trey Bean wrote: > Hi, > > I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that > stubbing a view helper method has changed in Rspec 2. It looks like > instead of doing template.stub!, we're now supposed to do view.stub!, > but I can't seem to get this to work on beta 10. I get an "undefined > local variable or method `view' for > #" > error. > > I see that in this commit (http://github.com/rspec/rspec-rails/commit/ > 0e860f580618045a34c17069b308c093e2e830cb) David removed the view > method, but I can't figure out what it was replaced with. Something > in ActionView::TestCase::Behavior? > > I'm on rails 3.0.0.beta3. > > Any idea what I'm missing? Please report this to http://github.com/rspec/rspec-rails/issues Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jun 8 12:41:25 2010 From: dchelimsky at gmail.com (dchelimsky at gmail.com) Date: Tue, 8 Jun 2010 09:41:25 -0700 (PDT) Subject: [rspec-users] How do I stub a view in rspec-2 In-Reply-To: <0E50DA45-5146-4CA5-BEE4-DB7A66ABCA7B@gmail.com> References: <0E50DA45-5146-4CA5-BEE4-DB7A66ABCA7B@gmail.com> Message-ID: On Jun 8, 12:15?pm, David Chelimsky wrote: > On Jun 8, 2010, at 10:26 AM, Trey Bean wrote: > > > > > > > Hi, > > > I'm in the process of upgrading an app to Rails 3/Rspec 2. ?I see that > > stubbing a view helper method has changed in Rspec 2. ?It looks like > > instead of doing template.stub!, we're now supposed to do view.stub!, > > but I can't seem to get this to work on beta 10. ?I get an "undefined > > local variable or method `view' for > > #" > > error. > > > I see that in this commit (http://github.com/rspec/rspec-rails/commit/ > > 0e860f580618045a34c17069b308c093e2e830cb) David removed the view > > method, but I can't figure out what it was replaced with. ?Something > > in ActionView::TestCase::Behavior? > > > I'm on rails 3.0.0.beta3. > > > Any idea what I'm missing? > > Please report this tohttp://github.com/rspec/rspec-rails/issues Nevermind - I've already got it entered and fix on the way: http://github.com/rspec/rspec-rails/issues/issue/73 From celoserpa at gmail.com Tue Jun 8 12:44:10 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Tue, 8 Jun 2010 11:44:10 -0500 Subject: [rspec-users] How to test the assignment of current_user In-Reply-To: References: Message-ID: Thanks Vin?cius ;) 2010/6/7 Vin?cius Baggio Fuentes > Oh yes, forgot to add that, if you do self.current_user = user, it will > call your mock as expected. > > Sorry for the multitude of emails. > > > 2010/6/7 Vin?cius Baggio Fuentes > > If current_user is an instance variable (as if you did attr_accessor >> :current_user), you should try: >> @current_user = @user >> >> If not, you should try invoking with self: >> self.current_user = @user >> >> because ruby is creating a local variable named current_user instead of >> invoking #current_user=. When you do call self, which refers to the object >> itself, it will use normal method lookup, that will find your >> #current_user=. >> >> On Mon, Jun 7, 2010 at 6:43 PM, Marcelo de Moraes Serpa < >> celoserpa at gmail.com> wrote: >> >>> Hello, >>> >>> This could be rephrased as -- How to test calls of special assigment >>> (setter) methods? >>> >>> I am trying to test the assigmnet of a user object to the >>> current_user=(new_user) method. It is part of an authentication process and >>> finally the object is assigned to the session through this method. I have >>> tried: >>> >>> controller.should_receive(:current_user=).with(@user) >>> post :create, @params >>> >>> And the output is: >>> >>> expected :current_user= with (# ) once, but >>> received it 0 times >>> >>> I do not understand, since current_user=(new_user) is actually being >>> called by the controller: >>> >>> def create >>> >>> current_user = @user >>> >>> end >>> >>> Why's that? >>> >>> Thanks, >>> >>> Marcelo. >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trey at 12spokes.com Tue Jun 8 12:46:21 2010 From: trey at 12spokes.com (Trey Bean) Date: Tue, 8 Jun 2010 10:46:21 -0600 Subject: [rspec-users] How do I stub a view in rspec-2 In-Reply-To: References: <0E50DA45-5146-4CA5-BEE4-DB7A66ABCA7B@gmail.com> Message-ID: Thanks David! On Tue, Jun 8, 2010 at 10:41 AM, dchelimsky at gmail.com wrote: > > > On Jun 8, 12:15 pm, David Chelimsky wrote: > > On Jun 8, 2010, at 10:26 AM, Trey Bean wrote: > > > > > > > > > > > > > Hi, > > > > > I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that > > > stubbing a view helper method has changed in Rspec 2. It looks like > > > instead of doing template.stub!, we're now supposed to do view.stub!, > > > but I can't seem to get this to work on beta 10. I get an "undefined > > > local variable or method `view' for > > > #" > > > error. > > > > > I see that in this commit (http://github.com/rspec/rspec-rails/commit/ > > > 0e860f580618045a34c17069b308c093e2e830cb) David removed the view > > > method, but I can't figure out what it was replaced with. Something > > > in ActionView::TestCase::Behavior? > > > > > I'm on rails 3.0.0.beta3. > > > > > Any idea what I'm missing? > > > > Please report this tohttp://github.com/rspec/rspec-rails/issues > > Nevermind - I've already got it entered and fix on the way: > > http://github.com/rspec/rspec-rails/issues/issue/73 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john.topley at gmail.com Tue Jun 1 07:37:25 2010 From: john.topley at gmail.com (John Topley) Date: Tue, 1 Jun 2010 04:37:25 -0700 (PDT) Subject: [rspec-users] How to mock/stub a directory of files and their contents? Message-ID: <518dfe30-5823-4069-8295-8417454f9692@k31g2000vbu.googlegroups.com> Hi, I'm writing a gem that enumerates the files within a specified directory and sub-directories. It's a module that has a single class method that returns an array containing the file names, but that array will also contain elements that represent metadata about the files. For example, one element will be a hash that's computed from the contents of each file, so that if a file is changed a different hash will be returned. I'm pretty new to RSpec and the thing I am struggling with is how to mock or stub not only the files, but also their contents. I know that the implementation will use Find.find, but I don't want to give it a real directory of fixture files for the specs to use because then how will I change the contents of a file to test that a different hash is returned? These are the pending examples I have so far: it "should return a list of files within the specified directory" it "should compute a hash of the files within the specified directory" it "should compute a different hash if the content of a file changes" it "shouldn't include hidden files or directories within the specified directory" Any help would be greatly appreciated! John From jiazh3ng at gmail.com Fri Jun 4 03:32:20 2010 From: jiazh3ng at gmail.com (jia) Date: Fri, 4 Jun 2010 00:32:20 -0700 (PDT) Subject: [rspec-users] slow and high cpu in rails3? Message-ID: <3384ee1b-1449-477c-9798-7d4dcc5b9995@r5g2000yqr.googlegroups.com> Hi, I noticed that compared with rails2.3 with rspec1.3, rails3 takes much longer time for me to execute rspec and cucumber, and the cpu is high(50%+). It seems it takes most of the time for loading the environment; the actual execution is fast. For example, to execute the following scenarios, it takes about 10 seconds wall clock time. Is this normal? 4 scenarios (1 failed, 3 passed) 22 steps (1 failed, 21 passed) 0m1.388s environment: ruby 1.9.3dev (2010-06-03 trunk 28143) [i686-linux] rspec-core-2.0.0.beta.10 rspec (2.0.0.beta.10, 2.0.0.beta.8) rspec-core (2.0.0.beta.10, 2.0.0.beta.8) rspec-expectations (2.0.0.beta.10, 2.0.0.beta.8) rspec-mocks (2.0.0.beta.10, 2.0.0.beta.8) rspec-rails (2.0.0.beta.10, 2.0.0.beta.8) selenium-webdriver (0.0.20) spork (0.8.3) rails 3.0.0.0.beta3 autotest (4.2.10) autotest-notification (2.2.1) autotest-rails (4.1.0) cucumber (0.7.3, 0.7.2) cucumber-rails (0.3.1) From trey at 12spokes.com Sat Jun 5 20:24:15 2010 From: trey at 12spokes.com (Trey) Date: Sat, 5 Jun 2010 17:24:15 -0700 (PDT) Subject: [rspec-users] How do I stub a view in rspec-2 Message-ID: <76db2c0a-acc4-426b-8b32-7367b2b79b3a@r5g2000prf.googlegroups.com> Hi, I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that stubbing a view helper method has changed in Rspec 2. It looks like instead of doing template.stub!, we're now supposed to do view.stub!, but I can't seem to get this to work on beta 10. I get an "undefined local variable or method `view' for #" error. I see that in this commit (http://github.com/rspec/rspec-rails/commit/ 0e860f580618045a34c17069b308c093e2e830cb) David removed the view method, but I can't figure out what it was replaced with. Something in ActionView::TestCase::Behavior? I'm on rails 3.0.0.beta3. Any idea what I'm missing? From dchelimsky at gmail.com Wed Jun 9 08:47:11 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 Jun 2010 08:47:11 -0400 Subject: [rspec-users] Adding custom directories in Rails app breaks RSpec testing In-Reply-To: <58957ab0-5e6e-4798-9253-30dba929b30a@h20g2000prn.googlegroups.com> References: <58957ab0-5e6e-4798-9253-30dba929b30a@h20g2000prn.googlegroups.com> Message-ID: On Sat, May 29, 2010 at 10:08 PM, dyba wrote: > Hi: > > I'm trying to find out why is it when I change the Rails directory > structure like so (app/controllers/physical/) does RSpec no longer > work? I moved all my controller files to app/controllers/physical. > Everything works fine when I run the server. But now I can't test > anymore: I get this message when I type the script/spec command: > > Paintdexter at R0M3 Sat May 29 19:05 >_ script/spec spec/controllers/ > physical/home_controller_spec.rb > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ > dependencies.rb:426:in `load_missing_constant': Expected /Users/ > Paintdexter/Ruby/atlas/app/controllers/physical/ > application_controller.rb to define ApplicationController (LoadError) This is the error right here ^^ though it is missing an important bit of info: app/controllers/physical/application_controller.rb should define Physical::ApplicationController > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:92:in `const_missing' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:437:in `load_missing_constant' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:437:in `load_missing_constant' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:437:in `load_missing_constant' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ > example/helper_example_group.rb:4 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ > example.rb:9 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails.rb: > 17 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require' > ? ? ? ?from /Users/Paintdexter/Ruby/atlas/spec/spec_helper.rb:6 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require' > ? ? ? ?from ./spec/controllers/physical/home_controller_spec.rb:1 > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:147:in > `load_without_new_constant_marking' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:147:in `load' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > example_group_runner.rb:15:in `load_files' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > example_group_runner.rb:14:in `each' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > example_group_runner.rb:14:in `load_files' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > options.rb:133:in `run_examples' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > command_line.rb:9:in `run' > ? ? ? ?from script/spec:10 > Paintdexter at R0M3 Sat May 29 19:06 >_ > > I made sure to add the custom directories in the config/environment.rb > file: > > ?## > ?# Adding load paths for my custom directories > ## > config.load_paths += %W( > #{RAILS_ROOT}/app/models/logical > #{RAILS_ROOT}/app/controllers/physical > #{RAILS_ROOT}/app/controllers/service > #{RAILS_ROOT}/app/views/physical > #{RAILS_ROOT}/spec/controllers/physical > #{RAILS_ROOT}/spec/views/physical > ) > > This however doesn't work. How can I make RSpec aware that the Rails > app directory structure has changed? From dchelimsky at gmail.com Wed Jun 9 08:48:16 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 Jun 2010 08:48:16 -0400 Subject: [rspec-users] How to mock/stub a directory of files and their contents? In-Reply-To: <518dfe30-5823-4069-8295-8417454f9692@k31g2000vbu.googlegroups.com> References: <518dfe30-5823-4069-8295-8417454f9692@k31g2000vbu.googlegroups.com> Message-ID: <65AA3EF1-7990-4A96-8C96-E82524F3AB58@gmail.com> On Jun 1, 2010, at 7:37 AM, John Topley wrote: > Hi, > > I'm writing a gem that enumerates the files within a specified > directory and sub-directories. It's a module that has a single class > method that returns an array containing the file names, but that array > will also contain elements that represent metadata about the files. > For example, one element will be a hash that's computed from the > contents of each file, so that if a file is changed a different hash > will be returned. > > I'm pretty new to RSpec and the thing I am struggling with is how to > mock or stub not only the files, but also their contents. I know that > the implementation will use Find.find, but I don't want to give it a > real directory of fixture files for the specs to use because then how > will I change the contents of a file to test that a different hash is > returned? > > These are the pending examples I have so far: > > it "should return a list of files within the specified directory" > it "should compute a hash of the files within the specified directory" > it "should compute a different hash if the content of a file changes" > it "shouldn't include hidden files or directories within the specified > directory" > > Any help would be greatly appreciated! Take a look at http://github.com/defunkt/fakefs. It stubs the file system for you, allowing you to create files in an in-memory file system that then gets blown away after the example. HTH, David From dchelimsky at gmail.com Wed Jun 9 08:56:11 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 Jun 2010 08:56:11 -0400 Subject: [rspec-users] How do I stub a view in rspec-2 In-Reply-To: <76db2c0a-acc4-426b-8b32-7367b2b79b3a@r5g2000prf.googlegroups.com> References: <76db2c0a-acc4-426b-8b32-7367b2b79b3a@r5g2000prf.googlegroups.com> Message-ID: On Sat, Jun 5, 2010 at 8:24 PM, Trey wrote: > Hi, > > I'm in the process of upgrading an app to Rails 3/Rspec 2. ?I see that > stubbing a view helper method has changed in Rspec 2. ?It looks like > instead of doing template.stub!, we're now supposed to do view.stub!, > but I can't seem to get this to work on beta 10. ?I get an "undefined > local variable or method `view' for > #" > error. > > I see that in this commit (http://github.com/rspec/rspec-rails/commit/ > 0e860f580618045a34c17069b308c093e2e830cb) David removed the view > method, but I can't figure out what it was replaced with. ?Something > in ActionView::TestCase::Behavior? > > I'm on rails 3.0.0.beta3. > > Any idea what I'm missing? This was an omission from beta.10/11 that I just fixed last night and will be updated in beta.12. Short term fix (could be in spec_helper.rb) module ViewMemoizationFix def _view @_view ||= view end alias_method :view, :_view end RSpec.configure do |c| c.include ViewMemoizationFix, :example_group => { :file_path => /\bspec\/views\// } end Let us know if that doesn't work. Cheers, David From dchelimsky at gmail.com Wed Jun 9 08:57:58 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 Jun 2010 08:57:58 -0400 Subject: [rspec-users] slow and high cpu in rails3? In-Reply-To: <3384ee1b-1449-477c-9798-7d4dcc5b9995@r5g2000yqr.googlegroups.com> References: <3384ee1b-1449-477c-9798-7d4dcc5b9995@r5g2000yqr.googlegroups.com> Message-ID: On Fri, Jun 4, 2010 at 3:32 AM, jia wrote: > Hi, > > I noticed that compared with rails2.3 with rspec1.3, rails3 takes much > longer time for me to execute rspec and cucumber, and the cpu is > high(50%+). > > It seems it takes most of the time for loading the environment; the > actual execution is fast. For example, to execute the following > scenarios, it takes about 10 seconds wall clock time. Is this normal? > > 4 scenarios (1 failed, 3 passed) > 22 steps (1 failed, 21 passed) > 0m1.388s > > > environment: > ruby 1.9.3dev (2010-06-03 trunk 28143) [i686-linux] > rspec-core-2.0.0.beta.10 > rspec (2.0.0.beta.10, 2.0.0.beta.8) > rspec-core (2.0.0.beta.10, 2.0.0.beta.8) > rspec-expectations (2.0.0.beta.10, 2.0.0.beta.8) > rspec-mocks (2.0.0.beta.10, 2.0.0.beta.8) > rspec-rails (2.0.0.beta.10, 2.0.0.beta.8) > selenium-webdriver (0.0.20) > spork (0.8.3) > rails 3.0.0.0.beta3 > autotest (4.2.10) > autotest-notification (2.2.1) > autotest-rails (4.1.0) > cucumber (0.7.3, 0.7.2) > cucumber-rails (0.3.1) http://gembundler.com/bundle_lock.html Have you locked your bundle? David From trey at 12spokes.com Wed Jun 9 09:09:46 2010 From: trey at 12spokes.com (Trey Bean) Date: Wed, 9 Jun 2010 07:09:46 -0600 Subject: [rspec-users] How do I stub a view in rspec-2 In-Reply-To: References: <76db2c0a-acc4-426b-8b32-7367b2b79b3a@r5g2000prf.googlegroups.com> Message-ID: I've been using edge since your commit (and rails 3 beta 4) and it's working great. Thanks! On Wed, Jun 9, 2010 at 6:56 AM, David Chelimsky wrote: > On Sat, Jun 5, 2010 at 8:24 PM, Trey wrote: > > Hi, > > > > I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that > > stubbing a view helper method has changed in Rspec 2. It looks like > > instead of doing template.stub!, we're now supposed to do view.stub!, > > but I can't seem to get this to work on beta 10. I get an "undefined > > local variable or method `view' for > > #" > > error. > > > > I see that in this commit (http://github.com/rspec/rspec-rails/commit/ > > 0e860f580618045a34c17069b308c093e2e830cb) David removed the view > > method, but I can't figure out what it was replaced with. Something > > in ActionView::TestCase::Behavior? > > > > I'm on rails 3.0.0.beta3. > > > > Any idea what I'm missing? > > This was an omission from beta.10/11 that I just fixed last night and > will be updated in beta.12. > > Short term fix (could be in spec_helper.rb) > > module ViewMemoizationFix > def _view > @_view ||= view > end > alias_method :view, :_view > end > > RSpec.configure do |c| > c.include ViewMemoizationFix, :example_group => { :file_path => > /\bspec\/views\// } > end > > Let us know if that doesn't work. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups > "rspec" group. > To post to this group, send email to rspec at googlegroups.com. > To unsubscribe from this group, send email to > rspec+unsubscribe at googlegroups.com . > For more options, visit this group at > http://groups.google.com/group/rspec?hl=en. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmandrup at gmail.com Wed Jun 9 12:56:48 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Wed, 9 Jun 2010 09:56:48 -0700 (PDT) Subject: [rspec-users] assigns in RSpec 2 - deprecation warning on rendered? Message-ID: <8077b030-02f2-4d36-9078-9b99b743d6cc@k39g2000yqb.googlegroups.com> I have come to the views_example in the RSpec book, using RSpec 2 all the way. Now I have this spec: -- describe "messages/show.html.erb" do it "displays the text attribute of the message" do assigns[:message] = stub("Message", :text => "Hello world!") puts "assigns @message: #{@message}" @message = stub("Message", :text => "Hello world!") puts "@message: #{@message}" render rendered.should contain("Hello world!") end end -- $ rspec spec/views/messages/show.html.erb_spec.rb assigns @message: @message: #[RSpec::Mocks::Mock:0x8244a124 @name="Message"] ***************************************************************** DEPRECATION WARNING: you are using deprecated behaviour that will be removed from a future version of RSpec. /Users/kristianconsult/Development/Languages/Ruby/Apps/Web-apps/Rails/ Rails-3/Experimental/views_example/spec/views/messages/ show.html.erb_spec.rb:10:in `block (2 levels) in ' * response is deprecated. * please use rendered instead. --- 1) I notice that the assigns doesn't seem to work with RSpec 2. An easy fix is to set the instance var directly. Is this the new way? 2) I changed 'response' to 'rendered' as the variable I get back from calling 'render', but I still get a deprecation warning! Has it been changed to a new name again without the deprecation check having been updated? From trey at 12spokes.com Wed Jun 9 13:21:14 2010 From: trey at 12spokes.com (Trey Bean) Date: Wed, 9 Jun 2010 11:21:14 -0600 Subject: [rspec-users] assigns in RSpec 2 - deprecation warning on rendered? In-Reply-To: <8077b030-02f2-4d36-9078-9b99b743d6cc@k39g2000yqb.googlegroups.com> References: <8077b030-02f2-4d36-9078-9b99b743d6cc@k39g2000yqb.googlegroups.com> Message-ID: Hi Kristian, The new rspec 2 way of doing assigns is assign(variable_name, whats_being_assigned). So your example becomes: assign(:message, stub("Message")) That should get rid of your deprecation message. Cheers, Trey On Wed, Jun 9, 2010 at 10:56 AM, Kristian Mandrup wrote: > I have come to the views_example in the RSpec book, using RSpec 2 all > the way. > Now I have this spec: > -- > describe "messages/show.html.erb" do > it "displays the text attribute of the message" do > assigns[:message] = stub("Message", :text => "Hello world!") > puts "assigns @message: #{@message}" > @message = stub("Message", :text => "Hello world!") > puts "@message: #{@message}" > render > rendered.should contain("Hello world!") > end > end > > -- > $ rspec spec/views/messages/show.html.erb_spec.rb > > assigns @message: > @message: #[RSpec::Mocks::Mock:0x8244a124 @name="Message"] > > ***************************************************************** > DEPRECATION WARNING: you are using deprecated behaviour that will > be removed from a future version of RSpec. > > /Users/kristianconsult/Development/Languages/Ruby/Apps/Web-apps/Rails/ > Rails-3/Experimental/views_example/spec/views/messages/ > show.html.erb_spec.rb:10:in `block (2 levels) in ' > > * response is deprecated. > * please use rendered instead. > --- > > 1) I notice that the assigns doesn't seem to work with RSpec 2. An > easy fix is to set the instance var directly. Is this the new way? > > 2) I changed 'response' to 'rendered' as the variable I get back from > calling 'render', but I still get a deprecation warning! Has it been > changed to a new name again without the deprecation check having been > updated? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 9 16:55:12 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 Jun 2010 16:55:12 -0400 Subject: [rspec-users] Error while running rspec after unpacking rails gems In-Reply-To: References: Message-ID: On Jun 9, 2010, at 4:45 PM, Amiruddin Nagri wrote: > Hi David, > > I am using autospec and it by default runs using 'spec' rather than 'script/spec'. Can you give me a quick direction of how to configure it to use the former. Take a look at http://github.com/rspec/rspec-core/blob/master/Upgrade.markdown. HTH, David > > Thanks, > Amiruddin Nagri, > Bangalore, 560008, KA > India > > Y! IM : amir_nagri at yahoo.com > GTalk : amir.nagri at gmail.com > > > > On Tue, Jun 8, 2010 at 5:56 PM, David Chelimsky wrote: > On Jun 8, 2010, at 4:05 AM, Amiruddin Nagri wrote: > > > I have a bunch of rspec test that are running fine when I don't freeze them in the vendor folder. > > > > But when I freeze the rails gems, the spec starts failing with the stack > > > > /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks': can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.1.0 for ["rspec-rails-1.3.2"] (RuntimeError) > > from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:134:in `process' > > from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in `send' > > from /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in `run' > > from /home/xuser/myprojects/xproject/config/environment.rb:9 > > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4:in `require' > > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4 > > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in `require' > > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 > > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in `require' > > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load_files' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 > > Try using 'script/spec' instead of 'spec'. > > > > > I zeroed down the error to this line in spec_helper in spec folder > > > > > require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) > > > > But when I remove this line the specs starts failing with the below stack > > > > /home/xuser/myprojects/xproject/spec/spec_helper.rb:5:in `require': no such file to load -- spec/rails (LoadError) > > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:5 > > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in `require' > > from /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 > > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in `require' > > from /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load_files' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 > > > > > > Is there anything I am missing ? I want to freeze my gems and check them in with the application. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From amir.nagri at gmail.com Wed Jun 9 16:45:08 2010 From: amir.nagri at gmail.com (Amiruddin Nagri) Date: Thu, 10 Jun 2010 02:15:08 +0530 Subject: [rspec-users] Error while running rspec after unpacking rails gems In-Reply-To: References: Message-ID: Hi David, I am using autospec and it by default runs using 'spec' rather than 'script/spec'. Can you give me a quick direction of how to configure it to use the former. Thanks, Amiruddin Nagri, Bangalore, 560008, KA India Y! IM : amir_nagri at yahoo.com GTalk : amir.nagri at gmail.com On Tue, Jun 8, 2010 at 5:56 PM, David Chelimsky wrote: > On Jun 8, 2010, at 4:05 AM, Amiruddin Nagri wrote: > > > I have a bunch of rspec test that are running fine when I don't freeze > them in the vendor folder. > > > > But when I freeze the rails gems, the spec starts failing with the stack > > > > > /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:271:in > `require_frameworks': can't activate rack (~> 1.0.1, runtime) for [], > already activated rack-1.1.0 for ["rspec-rails-1.3.2"] (RuntimeError) > > from > /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:134:in > `process' > > from > /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in > `send' > > from > /home/xuser/myprojects/xproject/config/../vendor/rails/railties/lib/initializer.rb:113:in > `run' > > from /home/xuser/myprojects/xproject/config/environment.rb:9 > > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4:in > `require' > > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:4 > > from > /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in > `require' > > from > /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 > > from > /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in > `require' > > from > /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in > `load' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in > `load_files' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in > `each' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in > `run_examples' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in > `run' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 > > Try using 'script/spec' instead of 'spec'. > > > > > I zeroed down the error to this line in spec_helper in spec folder > > > > > require > File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) > > > > But when I remove this line the specs starts failing with the below stack > > > > /home/xuser/myprojects/xproject/spec/spec_helper.rb:5:in `require': no > such file to load -- spec/rails (LoadError) > > from /home/xuser/myprojects/xproject/spec/spec_helper.rb:5 > > from > /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1:in > `require' > > from > /home/xuser/myprojects/xproject/spec/controllers/spec_helper.rb:1 > > from > /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1:in > `require' > > from > /home/xuser/myprojects/xproject/spec/controllers/users_controller_spec.rb:1 > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in > `load' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in > `load_files' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in > `each' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in > `run_examples' > > from > /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in > `run' > > from /home/xuser/.gem/ruby/1.8/gems/rspec-1.3.0/bin/spec:5 > > > > > > Is there anything I am missing ? I want to freeze my gems and check them > in with the application. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmandrup at gmail.com Wed Jun 9 17:28:26 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Wed, 9 Jun 2010 14:28:26 -0700 (PDT) Subject: [rspec-users] assigns in RSpec 2 - deprecation warning on rendered? In-Reply-To: References: <8077b030-02f2-4d36-9078-9b99b743d6cc@k39g2000yqb.googlegroups.com> Message-ID: <9baf45e8-1dc9-4dce-9d52-0b2c3fff5946@q12g2000yqj.googlegroups.com> > assign(:message, stub("Message")) > > That should get rid of your deprecation message. Yeah! But strange deprecation message that it mentions: * response is deprecated. * please use rendered instead. When it should be: * assigns is deprecated. * please use assign instead. Also, how do I use this assigned message In my show view I have: <%=h @message.text %> When I run it now: assign(:message, stub("Message")) puts "@message: #{@message.inspect}" render @message: nil <--------- OUCH!!! F 1) messages/show.html.erb displays the text attribute of the message Failure/Error: Unable to find matching line from backtrace Stub "Message" received unexpected message :text with (no args) @message is nil after using assigns! But inside the view it seems at least to recognize the stub called "Message"? Now if I inspect @message in the view instead <%=h @message.inspect %> expected the following element's content to include "Hello world!": # Now I just need to find out how to extract the text from the Stub message... ? From trey at 12spokes.com Wed Jun 9 17:45:18 2010 From: trey at 12spokes.com (Trey Bean) Date: Wed, 9 Jun 2010 15:45:18 -0600 Subject: [rspec-users] assigns in RSpec 2 - deprecation warning on rendered? In-Reply-To: <9baf45e8-1dc9-4dce-9d52-0b2c3fff5946@q12g2000yqj.googlegroups.com> References: <8077b030-02f2-4d36-9078-9b99b743d6cc@k39g2000yqb.googlegroups.com> <9baf45e8-1dc9-4dce-9d52-0b2c3fff5946@q12g2000yqj.googlegroups.com> Message-ID: If you want to use your assigned message within your spec, you can assign it to a variable in the assign call, e.g. assign(:message, @message = stub('message'). Since you're calling text on the message in your view, you should stub that method: assign(:message, @message = stub('message', :text => 'hello world'). As to the deprecation message, if you're still using response, you should be using rendered. The message is correct. Hope the helps ya, Trey On Wed, Jun 9, 2010 at 3:28 PM, Kristian Mandrup wrote: > > assign(:message, stub("Message")) > > > > That should get rid of your deprecation message. > > Yeah! But strange deprecation message that it mentions: > * response is deprecated. > * please use rendered instead. > > When it should be: > * assigns is deprecated. > * please use assign instead. > > Also, how do I use this assigned message > > In my show view I have: > <%=h @message.text %> > > When I run it now: > > assign(:message, stub("Message")) > puts "@message: #{@message.inspect}" > render > > > @message: nil <--------- OUCH!!! > F > > 1) messages/show.html.erb displays the text attribute of the message > Failure/Error: Unable to find matching line from backtrace > Stub "Message" received unexpected message :text with (no args) > > @message is nil after using assigns! But inside the view it seems at > least to recognize the stub called "Message"? > > Now if I inspect @message in the view instead > <%=h @message.inspect %> > > > expected the following element's content to include "Hello world!": > # > > Now I just need to find out how to extract the text from the Stub > message... ? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmandrup at gmail.com Wed Jun 9 17:46:08 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Wed, 9 Jun 2010 14:46:08 -0700 (PDT) Subject: [rspec-users] Rspec2 mock assign - how do I get the value out? Message-ID: assign(:message, stub("Message")) In my view I can access the message, but... <%= @message.to_s %> expected the following element's content to include "Hello world!": #[RSpec::Mocks::Mock:0x81bbd81c @name="Message"] Finally after some trial and error I discovered the solution, an option on the stub call to set the text message (content of the stub) assign(:message, stub("Message", :text => "Hello world!")) and in my view <%= @message.text %> Nice! From kmandrup at gmail.com Wed Jun 9 18:00:12 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Wed, 9 Jun 2010 15:00:12 -0700 (PDT) Subject: [rspec-users] RSpec book examples online for RSpec 2.beta11 + Cucumber 0.8 + Rails 3.beta3 + Capybara Message-ID: <1184e579-86a8-4311-ab7e-fa44a8f231cb@e5g2000yqn.googlegroups.com> http://github.com/kristianmandrup/codebreaker With detailed code instructions for each step in the project wiki and in a markdown file within each app. http://github.com/kristianmandrup/rspec-book-movie-app http://github.com/kristianmandrup/rspec-book-views-example Note: The final example is at page 351 in the b13 version of the book... more to come! Kristian From amir.nagri at gmail.com Wed Jun 9 23:31:39 2010 From: amir.nagri at gmail.com (Amiruddin Nagri) Date: Thu, 10 Jun 2010 09:01:39 +0530 Subject: [rspec-users] Custom Matchers : Shouldn't they follow DRY principle ? Message-ID: I am trying to write custom matchers for RESTful behavior of my controllers. I have created two matchers *be_created *( http://github.com/anagri/rspec_matchers/blob/80d0d021a7ad1e9af2ff18e79b80c004324abdc7/spec/support/http_status_matcher.rb) *have_created_resource *( http://github.com/anagri/rspec_matchers/blob/80d0d021a7ad1e9af2ff18e79b80c004324abdc7/spec/support/restful_resource_matcher.rb) In be_created, I check for the status code to be 201 and a location of the new resource. In have_created_resource, i also pass in the resource that was created and verify it exists (non nil check) as well as that it passes the be_created criteria. Github commit => http://github.com/anagri/rspec_matchers/commit/80d0d021a7ad1e9af2ff18e79b80c004324abdc7 I am getting an error saying be_created not found. Obviously, be_created is not in scope but if I fix it and include the required module it fails for be_nil not found. I am finding this way of reusing the matchers not correct. Is there a standard way of re-using matchers inside matchers ? Have anybody tried it out ? Regards, Amiruddin Nagri, Bangalore, 560008, KA India Y! IM : amir_nagri at yahoo.com GTalk : amir.nagri at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmandrup at gmail.com Thu Jun 10 00:08:01 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Wed, 9 Jun 2010 21:08:01 -0700 (PDT) Subject: [rspec-users] mock_model not working in rspec2? Message-ID: undefined method `model_name' for Message:Class --- # spec/views/messages/new.html.erb_spec.rb class Message; end describe "messages/new.html.erb" do it "renders a form to create a message" do assign(:message, mock_model(Message).as_new_record) render # app/views/messages/new.html.erb <%= form_for @message do |f| %> <%= f.submit "Save" %> <% end %> --- 1) messages/new.html.erb renders a form to create a message Failure/Error: Unable to find matching line from backtrace undefined method `model_name' for Message:Class # On line #1 of /users/kristianconsult/development/languages/ruby/ apps/web-apps/rails/rails-3/experimental/views_example/app/views/ messages/new.html.erb 1: <%= form_for @message do |f| %> 2: <%= f.submit "Save" %> 3: <% end %> From dchelimsky at gmail.com Thu Jun 10 00:49:48 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 10 Jun 2010 00:49:48 -0400 Subject: [rspec-users] mock_model not working in rspec2? In-Reply-To: References: Message-ID: Please report this to http://github.com/rspec/rspec-rails/issues On Thu, Jun 10, 2010 at 12:08 AM, Kristian Mandrup wrote: > undefined method `model_name' for Message:Class > --- > > # spec/views/messages/new.html.erb_spec.rb > > class Message; end > > ?describe "messages/new.html.erb" do > ? ?it "renders a form to create a message" do > ? ? ?assign(:message, mock_model(Message).as_new_record) > ? ? ?render > > > # app/views/messages/new.html.erb > ?<%= form_for @message do |f| %> > ? ?<%= f.submit "Save" %> > ?<% end %> > --- > > 1) messages/new.html.erb renders a form to create a message > ? ?Failure/Error: Unable to find matching line from backtrace > ? ?undefined method `model_name' for Message:Class > ? ?# On line #1 of /users/kristianconsult/development/languages/ruby/ > apps/web-apps/rails/rails-3/experimental/views_example/app/views/ > messages/new.html.erb > > ? ?1: <%= form_for @message do |f| %> > ? ?2: ? <%= f.submit "Save" %> > ? ?3: <% end %> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Jun 10 02:08:17 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 10 Jun 2010 02:08:17 -0400 Subject: [rspec-users] Custom Matchers : Shouldn't they follow DRY principle ? In-Reply-To: References: Message-ID: On Wed, Jun 9, 2010 at 11:31 PM, Amiruddin Nagri wrote: > > I am trying to write custom matchers for RESTful behavior of my controllers. > > I have created two matchers > be_created ( > http://github.com/anagri/rspec_matchers/blob/80d0d021a7ad1e9af2ff18e79b80c004324abdc7/spec/support/http_status_matcher.rb > ) > have_created_resource ( > http://github.com/anagri/rspec_matchers/blob/80d0d021a7ad1e9af2ff18e79b80c004324abdc7/spec/support/restful_resource_matcher.rb > ) > > In be_created, I check for the status code to be 201 and a location of the > new resource. In have_created_resource, i also pass in the resource that was > created and verify it exists (non nil check) as well as that it passes the > be_created criteria. > > Github commit => > http://github.com/anagri/rspec_matchers/commit/80d0d021a7ad1e9af2ff18e79b80c004324abdc7 > > I am getting an error saying be_created not found. Obviously, be_created is > not in scope but if I fix it and include the required module it fails for > be_nil not found. > I am finding this way of reusing the matchers not correct. > > Is there a standard way of re-using matchers inside matchers ? Have anybody > tried it out ? You'll have access to the other matchers in rspec-2 if you use the matcher DSL (see the rdoc on http://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers.rb). Regarding DRY: while it is a very important principle, it is not the only principle. The matches? method in have_created_resource exhibits the Long Method and Feature Envy code smells, and violates the Tell, Don't Ask principle. Using be_created the way it's being used is operating with lower level details of the matcher framework, letting those abstractions leak up to the matcher. I'd just write it like this (using the matcher DSL): RSpec::Matchers.define :have_created_resource do |resource, location| match do |response| response.code == "201" && resource end failure_message_for_should do |response| <<-MESSAGE expected to have created resource, but got: response code: #{response.code} resource: #{resource} MESSAGE end end Now each method does one thing. The match method does what it's supposed to: deciding whether or not to match. The failure_message_for_should does what it's supposed to: create a failure message. The failure message is better aligned with the matcher, and it's always the same format regardless of why it failed. There's also no dependency between the matchers now, so they are free to change independently. HTH, David From joahking at gmail.com Thu Jun 10 05:23:20 2010 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Thu, 10 Jun 2010 11:23:20 +0200 Subject: [rspec-users] [OT] programming (OOP) principles resources Message-ID: hi there, we all know good principles of OOP and P in general. But I found today that would be good to know which links (e.g [1] [2])books|reads would you recommend on the topic greetings, joaquin [1] http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign [2] http://www.industriallogic.com/papers/smellstorefactorings.pdf -- www.least-significant-bit.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From julian at leviston.net Thu Jun 10 05:43:23 2010 From: julian at leviston.net (Julian Leviston) Date: Thu, 10 Jun 2010 19:43:23 +1000 Subject: [rspec-users] [OT] programming (OOP) principles resources In-Reply-To: References: Message-ID: I'm not so sure "We all know good principles of OOP" actually. I'd recommend www.vpri.com.au and looking into the work of Alan Kay. A lot of his stuff can be found for free online, because it's decades old. Julian On 10/06/2010, at 7:23 PM, Joaquin Rivera Padron wrote: > hi there, > we all know good principles of OOP and P in general. But I found today that would be good to know which links (e.g [1] [2])books|reads would you recommend on the topic > > greetings, > joaquin > > [1] http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign > [2] http://www.industriallogic.com/papers/smellstorefactorings.pdf > > -- > www.least-significant-bit.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Jun 10 09:07:09 2010 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 10 Jun 2010 14:07:09 +0100 Subject: [rspec-users] [OT] programming (OOP) principles resources In-Reply-To: References: Message-ID: Link doesn't work typo? On 10 June 2010 10:43, Julian Leviston wrote: > I'm not so sure "We all know good principles of OOP" actually. > > I'd recommend www.vpri.com.au and looking into the work of Alan Kay. A lot > of his stuff can be found for free online, because it's decades old. > > Julian > > On 10/06/2010, at 7:23 PM, Joaquin Rivera Padron wrote: > > hi there, > we all know good principles of OOP and P in general. But I found today that > would be good to know which links (e.g [1] [2])books|reads would you > recommend on the topic > > greetings, > joaquin > > [1] http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign > [2] http://www.industriallogic.com/papers/smellstorefactorings.pdf > > -- > www.least-significant-bit.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmandrup at gmail.com Thu Jun 10 11:38:17 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Thu, 10 Jun 2010 08:38:17 -0700 (PDT) Subject: [rspec-users] RSpec 2 equivalent for: assigns[:message].should == @message Message-ID: describe MessagesController, "POST create" do before(:each) do @message = mock_model(Message, :save => nil) Message.stub(:new).and_return(@message) end context "when the message fails to save" do before(:each) do @message.stub(:save).and_return(false) end it "assigns @message" do post :create assigns[:message].should == @message end --- What is the RSpec 2 equivalent for assigns[:message].should == @message in this context? Failure/Error: assigns[:message].should == @message expected: #, got: nil (using ==) From kmandrup at gmail.com Thu Jun 10 11:49:29 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Thu, 10 Jun 2010 08:49:29 -0700 (PDT) Subject: [rspec-users] RSpec 2: undefined method `controller_name' for :Class (NoMethodError) Message-ID: describe ApplicationController, "handling AccessDenied exceptions" do class FooController < ApplicationController def index raise AccessDenied end end controller_name 'foo' # OUCH!!! it "redirects to the /401.html (access denied) page" do get :index response.should redirect_to('/401.html') end end -- So how do I set the controller name using RSpec 2/Rails 3? From kmandrup at gmail.com Thu Jun 10 12:21:34 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Thu, 10 Jun 2010 09:21:34 -0700 (PDT) Subject: [rspec-users] RSpec 2: uninitialized constant - mocking belongs_to AR relation Message-ID: <1052b8ec-9f9c-4db3-a721-0f410220ab6a@h13g2000yqm.googlegroups.com> gems/ruby-1.9.2-head/bundler/gems/rspec- core-2398fcadf5beb256bed9c548c59445d3b4c8a047-master/lib/rspec/core/ backward_compatibility.rb:26:in `const_missing': uninitialized constant Message::User (NameError) from /Users/kristianconsult/.rvm/gems/ruby-1.9.2-head/bundler/gems/ rspec-expectations-996c752171a0a0e16347e934dadc25767e31186c-master/lib/ rspec/expectations/backward_compatibility.rb:6:in `const_missing' from /Users/kristianconsult/Development/Languages/Ruby/Apps/Web-apps/ Rails/Rails-3/Experimental/views_example/app/models/message.rb:2:in `' from /Users/kristianconsult/Development/Languages/Ruby/Apps/Web-apps/ Rails/Rails-3/Experimental/views_example/app/models/message.rb:1:in `' -- class Message < ActiveRecord::Base belongs_to :recipient, :class_name => User.name validates_presence_of :title, :text, :recipient end -- require 'spec_helper' class User end describe Message do before(:each) do @message = Message.new( :title => "foo", :text => "bar", :recipient => mock_model(User) ) end ... -- If I uncomment the :class_name option on the belongs_to relation of Message: Failure/Error: @message = Message.new( uninitialized constant Message::Recipient Hmm?? From dchelimsky at gmail.com Thu Jun 10 12:57:29 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 10 Jun 2010 12:57:29 -0400 Subject: [rspec-users] RSpec 2 equivalent for: assigns[:message].should == @message In-Reply-To: References: Message-ID: On Thu, Jun 10, 2010 at 11:38 AM, Kristian Mandrup wrote: > describe MessagesController, "POST create" do > > ?before(:each) do > ? ?@message = mock_model(Message, :save => nil) > ? ?Message.stub(:new).and_return(@message) > ?end > > > ?context "when the message fails to save" do > ? ?before(:each) do > ? ? ?@message.stub(:save).and_return(false) > ? ?end > > ? ?it "assigns @message" do > ? ? ?post :create > ? ? ?assigns[:message].should == @message > ? ?end > > --- > What is the RSpec 2 equivalent for assigns[:message].should == > @message in this context? assigns(:message).should eq(@message) HTH, David > > ? ?Failure/Error: assigns[:message].should == @message > ? ?expected: #, > ? ? ? ? got: nil (using ==) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From peter.fitzgibbons at gmail.com Thu Jun 10 14:53:52 2010 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Thu, 10 Jun 2010 13:53:52 -0500 Subject: [rspec-users] Rspec 2 (beta.11) view spec haml Message-ID: <4C1134C0.8010208@gmail.com> Hello All, I'm trying to view-spec with haml require 'spec_helper' describe "user_sessions/new.html.erb" do it "renders blank form" do activate_authlogic user_session = UserSession.new assign :user_session, user_session debugger render render.should have_tag('text.email') end end The response is this Failure : 1) user_sessions/new.html.haml renders blank form Failure/Error: render No route matches {} I have verified that 'new.html.erb' renders and matches OK. Is there a way in rspec 2 to enable Haml rendering ? -- Peter Fitzgibbons (847) 859-9550 peter.fitzgibbons at gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From geetarista at gmail.com Thu Jun 10 15:14:35 2010 From: geetarista at gmail.com (geetarista) Date: Thu, 10 Jun 2010 12:14:35 -0700 (PDT) Subject: [rspec-users] Rails 3 Support/Design Message-ID: Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm wondering why it doesn't use railtie, the new generators, etc. Will it stay this way or is it planned to support that? From dchelimsky at gmail.com Thu Jun 10 16:10:54 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 10 Jun 2010 16:10:54 -0400 Subject: [rspec-users] Rails 3 Support/Design In-Reply-To: References: Message-ID: On Thu, Jun 10, 2010 at 3:14 PM, geetarista wrote: > Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm > wondering why it doesn't use railtie, the new generators, etc. ?Will > it stay this way or is it planned to support that? It does use the new generators, and we do have a railtie, but bundler doesn't support exposing the railtie in the :test group by default, so if you do this: group :test do gem "rspec-rails" end ... then you won't see the rake tasks or the generators. I believe this will be addressed in bundler before it goes final, at which point we'll rely only on the railtie. Cheers, David From dchelimsky at gmail.com Thu Jun 10 16:13:51 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 10 Jun 2010 16:13:51 -0400 Subject: [rspec-users] Rspec 2 (beta.11) view spec haml In-Reply-To: <4C1134C0.8010208@gmail.com> References: <4C1134C0.8010208@gmail.com> Message-ID: On Thu, Jun 10, 2010 at 2:53 PM, Peter Fitzgibbons wrote: > Hello All, > > I'm trying to view-spec with haml > require 'spec_helper' > > describe "user_sessions/new.html.erb" do > ? it "renders blank form" do > ??? activate_authlogic > ??? user_session = UserSession.new > ??? assign :user_session, user_session > ??? debugger > ??? render > ??? render.should have_tag('text.email') > ? end > end > > The response is this Failure : > 1) user_sessions/new.html.haml renders blank form > ??? Failure/Error: render > ??? No route matches {} > > I have verified that 'new.html.erb' renders and matches OK. > > Is there a way in rspec 2 to enable Haml rendering ? new.html.erb or new.html.haml? From joseph.delcioppio at gmail.com Thu Jun 10 22:07:39 2010 From: joseph.delcioppio at gmail.com (Joseph DelCioppio) Date: Thu, 10 Jun 2010 19:07:39 -0700 (PDT) Subject: [rspec-users] Stubbing before_filters with RSpec and stub! Message-ID: <750108d5-6b10-490d-ad85-999a18f2032a@u20g2000pru.googlegroups.com> Guys, I've got a private controller method which acts as a before_filter that I'm trying to stub. class TasksController < ApplicationController before_filter :load_user ...... private def load_user if current_user.id == params[:user_id].to_i @user = current_user else flash[:notice] = "Sorry but you can't view other people's tasks." redirect_to root_path end end end describe TasksController do before(:each) do @user = Factory(:user) sign_in @user @task = Factory(:task) User.stub_chain(:where, :first).and_return(@user) controller.stub!(:load_user).and_return(@user) end ....... end However, even though I'm stubbing load_user, the actual function is still being called, because I can make all my tests either pass/fail if I simply have load_user neglect to return @user. If I have stubbed load_user, should it just always return @user, no matter what I do to the actual controller method? I thought that this was the point of stubbing, that way if I change load_user in the future, only the tests specifically designed to exercise load_user will fail, but the rest of my suite will still pass. I'm going to post my entire controller and spec and provide the Gist links in case the abbreviated versions I gave aren't enough. http://gist.github.com/433942 Thanks in advance, Joe From lbocseg at yahoo.com.br Thu Jun 10 22:35:14 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Thu, 10 Jun 2010 23:35:14 -0300 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat Message-ID: <4C11A0E2.5090509@yahoo.com.br> Hi guys, I'm trying to port an application to Rails 3 but can't get my integration tests to run. I can't call the Webrat's method (yields 'undefined method `visit`', for instance). I don't use Cucumber. Is there any instructions about how to configure Rspec 2 with Webrat on Rails 3? I also have a custom helper that is not working: "config.include MyApp::IntegrationHelper, :type => :integration" (the methods defined in this module are not available in the specs) Any ideas? Thanks, Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From dchelimsky at gmail.com Fri Jun 11 00:10:49 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 Jun 2010 00:10:49 -0400 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <4C11A0E2.5090509@yahoo.com.br> References: <4C11A0E2.5090509@yahoo.com.br> Message-ID: <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> Change the directory name to requests (a la merb) Sent from my iPhone On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas wrote: > Hi guys, > > I'm trying to port an application to Rails 3 but can't get my > integration tests to run. > > I can't call the Webrat's method (yields 'undefined method `visit`', > for instance). I don't use Cucumber. > > Is there any instructions about how to configure Rspec 2 with Webrat > on Rails 3? > > I also have a custom helper that is not working: > > "config.include MyApp::IntegrationHelper, :type > => :integration" (the methods defined in this module are not > available in the specs) > > Any ideas? > > Thanks, > > Rodrigo. > > __________________________________________________ > Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.c > om/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Jun 11 03:08:07 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 Jun 2010 03:08:07 -0400 Subject: [rspec-users] undefined local variable or method `assigns' Message-ID: On Thu, Jun 10, 2010 at 4:41 PM, wrote: > I might be missing something basic here, but I'm stumped on this > error: > > model code: > > class CachedStat < ActiveRecord::Base > ? ?def self.create_stats_days_ago(days_ago, human_id) > ? ?d = Date.today - days_ago.day > ? ?@prs = PageRequest.find(:all, :conditions => [ "owner_type = > 'Human' and owner_id = ? and created_at = ?", human_id, d] ) > ?end > end > > > spec code: > > ?it "should create stats for the specified number of days in the > past" do > ? ?CachedStat.create_stats_days_ago(1, Human.first.id) > ? ?assigns[:prs].should eql("foo") > ?end > > > The error is: undefined local variable or method `assigns' for > # > > > I feel like I'm overlooking something obvious but it's invisible to > me. Any suggestions? assigns is for controller and view specs, not model specs. What is it you're trying to specify here? From rem.gagnon at gmail.com Fri Jun 11 09:34:34 2010 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Fri, 11 Jun 2010 09:34:34 -0400 Subject: [rspec-users] RoutingError in spec for helper Message-ID: Hi, Its maybe not related to rspec but I can't figure out how to fix it. Here is, In my helper(Rails) I got the piece of code : sortie += link_to(entete_colonne + " " + image_sens_tri,* client_journal_activites_path*(:ordre_tri => nom_colonne, :sens_tri => params[:sens_tri],:filtre => params[:filtre])) When I run the spec on this I got the following error. Looks like rspec does not like extra params on the generated route url, I thought it was clean to do that. ActionController::RoutingError: client_journal_activites_url failed to generate from {:controller=>"journal_activites", :action=>"index", :filtre=>"XX", :ordre_tri=>"DATE", :sens_tri=>"DESC"}, expected: {:controller=>"journal_activites", :action=>"index"}, diff: {:filtre=>"XX", :ordre_tri=>"DATE", :sens_tri=>"DESC"} (eval):20:in `client_journal_activites_path' C:/WorkspacesSVN/Cautionnement/app/helpers/journal_activites_helper.rb:43:in `afficher_entete_colonne_activites' C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34:in `send' C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34 C:/WorkspacesSVN/Cautionnement/script/spec:10 C:\ruby\bin/rdebug-ide:19:in `load' Any suggestions? R?mi -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.fitzgibbons at gmail.com Fri Jun 11 10:29:42 2010 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Fri, 11 Jun 2010 09:29:42 -0500 Subject: [rspec-users] Rspec 2 (beta.11) view spec haml In-Reply-To: References: <4C1134C0.8010208@gmail.com> Message-ID: <4C124856.2080806@gmail.com> HI David, I'm not sure what your question was ? To word it differently : Does anyone know what the issue might be with a view spec on 'new.html.haml' : 1) user_sessions/new.html.haml renders blank form Failure/Error: render No route matches {} Peter Fitzgibbons (847) 859-9550 peter.fitzgibbons at gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons at gmail.com On 6/10/10 3:13 PM, David Chelimsky wrote: > On Thu, Jun 10, 2010 at 2:53 PM, Peter Fitzgibbons > wrote: >> Hello All, >> >> I'm trying to view-spec with haml >> require 'spec_helper' >> >> describe "user_sessions/new.html.erb" do >> it "renders blank form" do >> activate_authlogic >> user_session = UserSession.new >> assign :user_session, user_session >> debugger >> render >> render.should have_tag('text.email') >> end >> end >> >> The response is this Failure : >> 1) user_sessions/new.html.haml renders blank form >> Failure/Error: render >> No route matches {} >> >> I have verified that 'new.html.erb' renders and matches OK. >> >> Is there a way in rspec 2 to enable Haml rendering ? > new.html.erb or new.html.haml? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From geetarista at gmail.com Fri Jun 11 10:40:14 2010 From: geetarista at gmail.com (geetarista) Date: Fri, 11 Jun 2010 07:40:14 -0700 (PDT) Subject: [rspec-users] Rails 3 Support/Design In-Reply-To: References: Message-ID: Awesome. Thanks for the clarification! On Jun 10, 1:10?pm, David Chelimsky wrote: > On Thu, Jun 10, 2010 at 3:14 PM, geetarista wrote: > > Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm > > wondering why it doesn't use railtie, the new generators, etc. ?Will > > it stay this way or is it planned to support that? > > It does use the new generators, and we do have a railtie, but bundler > doesn't support exposing the railtie in the :test group by default, so > if you do this: > > group :test do > ? gem "rspec-rails" > end > > ... then you won't see the rake tasks or the generators. I believe > this will be addressed in bundler before it goes final, at which point > we'll rely only on the railtie. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From peter.fitzgibbons at gmail.com Fri Jun 11 10:43:06 2010 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Fri, 11 Jun 2010 09:43:06 -0500 Subject: [rspec-users] Rspec 2 (beta.11) view spec haml In-Reply-To: References: <4C1134C0.8010208@gmail.com> Message-ID: <4C124B7A.8050404@gmail.com> HI David, If you could point me toward the interesting part of the rspec source I would be willing to look into this from the back end. Thanks, Peter Fitzgibbons (847) 859-9550 peter.fitzgibbons at gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons at gmail.com On 6/10/10 3:13 PM, David Chelimsky wrote: > On Thu, Jun 10, 2010 at 2:53 PM, Peter Fitzgibbons > wrote: >> Hello All, >> >> I'm trying to view-spec with haml >> require 'spec_helper' >> >> describe "user_sessions/new.html.erb" do >> it "renders blank form" do >> activate_authlogic >> user_session = UserSession.new >> assign :user_session, user_session >> debugger >> render >> render.should have_tag('text.email') >> end >> end >> >> The response is this Failure : >> 1) user_sessions/new.html.haml renders blank form >> Failure/Error: render >> No route matches {} >> >> I have verified that 'new.html.erb' renders and matches OK. >> >> Is there a way in rspec 2 to enable Haml rendering ? > new.html.erb or new.html.haml? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.denatale at gmail.com Fri Jun 11 10:56:11 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 11 Jun 2010 10:56:11 -0400 Subject: [rspec-users] Rails 3 Support/Design In-Reply-To: References: Message-ID: On Thu, Jun 10, 2010 at 4:10 PM, David Chelimsky wrote: > On Thu, Jun 10, 2010 at 3:14 PM, geetarista wrote: >> Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm >> wondering why it doesn't use railtie, the new generators, etc. ?Will >> it stay this way or is it planned to support that? > > It does use the new generators, and we do have a railtie, but bundler > doesn't support exposing the railtie in the :test group by default, so > if you do this: > > group :test do > ?gem "rspec-rails" > end > > ... then you won't see the rake tasks or the generators. I believe > this will be addressed in bundler before it goes final, at which point > we'll rely only on the railtie. I'm not sure I see how bundler would address this, but couldn't it be addressed by breaking the stuff you need from rspec-rails in the development environment into a separate rspec-rails-dev gem or something like that. Breaking up gems seems to have been a theme in the transition from Rails 2 -> Rails 3. Just an idea -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From rick.denatale at gmail.com Fri Jun 11 11:00:58 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 11 Jun 2010 11:00:58 -0400 Subject: [rspec-users] Rspec 2 (beta.11) view spec haml In-Reply-To: <4C124856.2080806@gmail.com> References: <4C1134C0.8010208@gmail.com> <4C124856.2080806@gmail.com> Message-ID: On Fri, Jun 11, 2010 at 10:29 AM, Peter Fitzgibbons wrote: > HI David, > > I'm not sure what your question was ? I think he was referring to the fact that you are asking about a haml view, but in your original post you have describe "user_sessions/new.html.erb" do rather than describe "user_sessions/new.html.haml" do -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From dchelimsky at gmail.com Fri Jun 11 11:17:43 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 Jun 2010 11:17:43 -0400 Subject: [rspec-users] Rails 3 Support/Design In-Reply-To: References: Message-ID: <0668B2A8-7558-439C-8CBE-FBF638640B16@gmail.com> On Jun 11, 2010, at 10:56 AM, Rick DeNatale wrote: > On Thu, Jun 10, 2010 at 4:10 PM, David Chelimsky wrote: >> On Thu, Jun 10, 2010 at 3:14 PM, geetarista wrote: >>> Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm >>> wondering why it doesn't use railtie, the new generators, etc. Will >>> it stay this way or is it planned to support that? >> >> It does use the new generators, and we do have a railtie, but bundler >> doesn't support exposing the railtie in the :test group by default, so >> if you do this: >> >> group :test do >> gem "rspec-rails" >> end >> >> ... then you won't see the rake tasks or the generators. I believe >> this will be addressed in bundler before it goes final, at which point >> we'll rely only on the railtie. > > I'm not sure I see how bundler would address this, but couldn't it be > addressed by breaking the stuff you need from rspec-rails in the > development environment into a separate rspec-rails-dev gem or > something like that. > > Breaking up gems seems to have been a theme in the transition from > Rails 2 -> Rails 3. > > Just an idea And an interesting one at that, but I think it would add to more confusion than not. Right now you just have to require 'rspec-rails' in the Gemfile and it depends on rspec, which depends on all the other gems. If we separated out a gem for generators/rake tasks, it would need to be outside the test group, so you'd have one rspec gem in one group and one in another. I spoke w/ wycats about this issue at RailsConf and he agreed that railties in the test group should be exposed in development mode. RSpec won't be the only tool that this impacts, nor would RSpec users be the only people. That all make sense? David > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Github: http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR: http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn: http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Jun 11 11:20:43 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 Jun 2010 11:20:43 -0400 Subject: [rspec-users] RoutingError in spec for helper In-Reply-To: References: Message-ID: <6DB7CAD1-625A-4634-B12E-8A1055AEF824@gmail.com> On Jun 11, 2010, at 9:34 AM, Remi Gagnon wrote: > Hi, > > Its maybe not related to rspec but I can't figure out how to fix it. Here is, > > In my helper(Rails) I got the piece of code : > > sortie += link_to(entete_colonne + " " + image_sens_tri,client_journal_activites_path(:ordre_tri => nom_colonne, :sens_tri => params[:sens_tri],:filtre => params[:filtre])) > > > When I run the spec on this I got the following error. Looks like rspec does not like extra params on the generated route url, I thought it was clean to do that. > > > ActionController::RoutingError: client_journal_activites_url failed to generate from {:controller=>"journal_activites", :action=>"index", :filtre=>"XX", :ordre_tri=>"DATE", :sens_tri=>"DESC"}, expected: {:controller=>"journal_activites", :action=>"index"}, diff: {:filtre=>"XX", :ordre_tri=>"DATE", :sens_tri=>"DESC"} > (eval):20:in `client_journal_activites_path' > C:/WorkspacesSVN/Cautionnement/app/helpers/journal_activites_helper.rb:43:in `afficher_entete_colonne_activites' > C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34:in `send' > C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34 > C:/WorkspacesSVN/Cautionnement/script/spec:10 > C:\ruby\bin/rdebug-ide:19:in `load' > > Any suggestions? What versions of rspec/rails are you talking about? Does the route definition know what to do with the extra params? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rem.gagnon at gmail.com Fri Jun 11 11:37:22 2010 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Fri, 11 Jun 2010 11:37:22 -0400 Subject: [rspec-users] RoutingError in spec for helper In-Reply-To: <6DB7CAD1-625A-4634-B12E-8A1055AEF824@gmail.com> References: <6DB7CAD1-625A-4634-B12E-8A1055AEF824@gmail.com> Message-ID: I'm on rails 2.3.5 with rspec 1.3.0, rspec 1.3.2 No, the route def is not aware of these extra params, but it works. But I'm not sure it is clean though. If not, I searched to specify these params in the route, with no sucess. Regards On Fri, Jun 11, 2010 at 11:20 AM, David Chelimsky wrote: > On Jun 11, 2010, at 9:34 AM, Remi Gagnon wrote: > > Hi, > > Its maybe not related to rspec but I can't figure out how to fix it. Here > is, > > In my helper(Rails) I got the piece of code : > > sortie += link_to(entete_colonne + " " + image_sens_tri,* > client_journal_activites_path*(:ordre_tri => nom_colonne, :sens_tri => > params[:sens_tri],:filtre => params[:filtre])) > > > When I run the spec on this I got the following error. Looks like rspec > does not like extra params on the generated route url, I thought it was > clean to do that. > > > ActionController::RoutingError: client_journal_activites_url failed to > generate from {:controller=>"journal_activites", :action=>"index", > :filtre=>"XX", :ordre_tri=>"DATE", :sens_tri=>"DESC"}, expected: > {:controller=>"journal_activites", :action=>"index"}, diff: {:filtre=>"XX", > :ordre_tri=>"DATE", :sens_tri=>"DESC"} > (eval):20:in `client_journal_activites_path' > C:/WorkspacesSVN/Cautionnement/app/helpers/journal_activites_helper.rb:43:in > `afficher_entete_colonne_activites' > C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34:in > `send' > > C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34 > C:/WorkspacesSVN/Cautionnement/script/spec:10 > C:\ruby\bin/rdebug-ide:19:in `load' > > Any suggestions? > > > What versions of rspec/rails are you talking about? > > Does the route definition know what to do with the extra params? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rem.gagnon at gmail.com Fri Jun 11 11:39:25 2010 From: rem.gagnon at gmail.com (Remi Gagnon) Date: Fri, 11 Jun 2010 11:39:25 -0400 Subject: [rspec-users] RoutingError in spec for helper In-Reply-To: References: <6DB7CAD1-625A-4634-B12E-8A1055AEF824@gmail.com> Message-ID: Sorry I mean rails 2.3.5 with rspec 1.3.0, rspec-rails 1.3.2 On Fri, Jun 11, 2010 at 11:37 AM, Remi Gagnon wrote: > I'm on rails 2.3.5 with rspec 1.3.0, rspec 1.3.2 > > No, the route def is not aware of these extra params, but it works. But > I'm not sure it is clean though. If not, I searched to specify these params > in the route, with no sucess. > > Regards > > On Fri, Jun 11, 2010 at 11:20 AM, David Chelimsky wrote: > >> On Jun 11, 2010, at 9:34 AM, Remi Gagnon wrote: >> >> Hi, >> >> Its maybe not related to rspec but I can't figure out how to fix it. Here >> is, >> >> In my helper(Rails) I got the piece of code : >> >> sortie += link_to(entete_colonne + " " + image_sens_tri,* >> client_journal_activites_path*(:ordre_tri => nom_colonne, :sens_tri => >> params[:sens_tri],:filtre => params[:filtre])) >> >> >> When I run the spec on this I got the following error. Looks like rspec >> does not like extra params on the generated route url, I thought it was >> clean to do that. >> >> >> ActionController::RoutingError: client_journal_activites_url failed to >> generate from {:controller=>"journal_activites", :action=>"index", >> :filtre=>"XX", :ordre_tri=>"DATE", :sens_tri=>"DESC"}, expected: >> {:controller=>"journal_activites", :action=>"index"}, diff: {:filtre=>"XX", >> :ordre_tri=>"DATE", :sens_tri=>"DESC"} >> (eval):20:in `client_journal_activites_path' >> C:/WorkspacesSVN/Cautionnement/app/helpers/journal_activites_helper.rb:43:in >> `afficher_entete_colonne_activites' >> C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34:in >> `send' >> >> C:/WorkspacesSVN/Cautionnement/spec/helpers/journal_activites_helper_spec.rb:34 >> C:/WorkspacesSVN/Cautionnement/script/spec:10 >> C:\ruby\bin/rdebug-ide:19:in `load' >> >> Any suggestions? >> >> >> What versions of rspec/rails are you talking about? >> >> Does the route definition know what to do with the extra params? >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lbocseg at yahoo.com.br Fri Jun 11 13:24:59 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Fri, 11 Jun 2010 14:24:59 -0300 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> Message-ID: <4C12716B.2080209@yahoo.com.br> Now I'm getting: no such file to load -- action_controller/integration Am I missing something? Thanks, Rodrigo. Em 11-06-2010 01:10, David Chelimsky escreveu: > Change the directory name to requests (a la merb) > > Sent from my iPhone > > On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas > wrote: > >> Hi guys, >> >> I'm trying to port an application to Rails 3 but can't get my >> integration tests to run. >> >> I can't call the Webrat's method (yields 'undefined method `visit`', >> for instance). I don't use Cucumber. >> >> Is there any instructions about how to configure Rspec 2 with Webrat >> on Rails 3? >> >> I also have a custom helper that is not working: >> >> "config.include MyApp::IntegrationHelper, :type => :integration" (the >> methods defined in this module are not available in the specs) >> >> Any ideas? >> >> Thanks, >> >> Rodrigo. >> >> __________________________________________________ >> Fa??a liga????es para outros computadores com o novo Yahoo! Messenger >> http://br.beta.messenger.yahoo.com/ >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From lbocseg at yahoo.com.br Fri Jun 11 13:30:24 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Fri, 11 Jun 2010 14:30:24 -0300 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> Message-ID: <4C1272B0.6080701@yahoo.com.br> Now I'm getting: no such file to load -- action_controller/integration Am I missing something? Thanks, Rodrigo. P.S.: Sorry if this was sent twice... Em 11-06-2010 01:10, David Chelimsky escreveu: > Change the directory name to requests (a la merb) > > Sent from my iPhone > > On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas > wrote: > >> Hi guys, >> >> I'm trying to port an application to Rails 3 but can't get my >> integration tests to run. >> >> I can't call the Webrat's method (yields 'undefined method `visit`', >> for instance). I don't use Cucumber. >> >> Is there any instructions about how to configure Rspec 2 with Webrat >> on Rails 3? >> >> I also have a custom helper that is not working: >> >> "config.include MyApp::IntegrationHelper, :type => :integration" (the >> methods defined in this module are not available in the specs) >> >> Any ideas? >> >> Thanks, >> >> Rodrigo. >> >> __________________________________________________ >> Fa??a liga????es para outros computadores com o novo Yahoo! Messenger >> http://br.beta.messenger.yahoo.com/ >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From lbocseg at yahoo.com.br Fri Jun 11 13:43:50 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Fri, 11 Jun 2010 14:43:50 -0300 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> Message-ID: <4C1275D6.1070808@yahoo.com.br> Also, changing the directory name didn't affect the custom IntegrationHelper issue... Rodrigo. Em 11-06-2010 01:10, David Chelimsky escreveu: > Change the directory name to requests (a la merb) > > Sent from my iPhone > > On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas > wrote: > >> Hi guys, >> >> I'm trying to port an application to Rails 3 but can't get my >> integration tests to run. >> >> I can't call the Webrat's method (yields 'undefined method `visit`', >> for instance). I don't use Cucumber. >> >> Is there any instructions about how to configure Rspec 2 with Webrat >> on Rails 3? >> >> I also have a custom helper that is not working: >> >> "config.include MyApp::IntegrationHelper, :type => :integration" (the >> methods defined in this module are not available in the specs) >> >> Any ideas? >> >> Thanks, >> >> Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From dchelimsky at gmail.com Fri Jun 11 13:44:40 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 Jun 2010 13:44:40 -0400 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <4C1272B0.6080701@yahoo.com.br> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> <4C1272B0.6080701@yahoo.com.br> Message-ID: Sent from my iPhone On Jun 11, 2010, at 1:30 PM, Rodrigo Rosenfeld Rosas wrote: > Now I'm getting: > > no such file to load -- action_controller/integration Backtrace, please > > Am I missing something? > > Thanks, > > Rodrigo. > > P.S.: Sorry if this was sent twice... > > Em 11-06-2010 01:10, David Chelimsky escreveu: >> Change the directory name to requests (a la merb) >> >> Sent from my iPhone >> >> On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas >> wrote: >> >>> Hi guys, >>> >>> I'm trying to port an application to Rails 3 but can't get my >>> integration tests to run. >>> >>> I can't call the Webrat's method (yields 'undefined method `visit`', >>> for instance). I don't use Cucumber. >>> >>> Is there any instructions about how to configure Rspec 2 with Webrat >>> on Rails 3? >>> >>> I also have a custom helper that is not working: >>> >>> "config.include MyApp::IntegrationHelper, :type >>> => :integration" (the >>> methods defined in this module are not available in the specs) >>> >>> Any ideas? >>> >>> Thanks, >>> >>> Rodrigo. >>> >>> __________________________________________________ >>> Fa??a liga????es para outros computadores com o novo Yahoo! >>> Messenger >>> http://br.beta.messenger.yahoo.com/ >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > __________________________________________________ > Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.c > om/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From peter.fitzgibbons at gmail.com Fri Jun 11 13:45:52 2010 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Fri, 11 Jun 2010 12:45:52 -0500 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <4C1272B0.6080701@yahoo.com.br> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> <4C1272B0.6080701@yahoo.com.br> Message-ID: <4C127650.5090304@gmail.com> remove the :type key from your describe line (it's no longer needed). Peter Fitzgibbons (847) 859-9550 peter.fitzgibbons at gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons at gmail.com On 6/11/10 12:30 PM, Rodrigo Rosenfeld Rosas wrote: > Now I'm getting: > > no such file to load -- action_controller/integration > > Am I missing something? > > Thanks, > > Rodrigo. > > P.S.: Sorry if this was sent twice... > > Em 11-06-2010 01:10, David Chelimsky escreveu: >> Change the directory name to requests (a la merb) >> >> Sent from my iPhone >> >> On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas >> wrote: >> >>> Hi guys, >>> >>> I'm trying to port an application to Rails 3 but can't get my >>> integration tests to run. >>> >>> I can't call the Webrat's method (yields 'undefined method `visit`', >>> for instance). I don't use Cucumber. >>> >>> Is there any instructions about how to configure Rspec 2 with Webrat >>> on Rails 3? >>> >>> I also have a custom helper that is not working: >>> >>> "config.include MyApp::IntegrationHelper, :type => :integration" (the >>> methods defined in this module are not available in the specs) >>> >>> Any ideas? >>> >>> Thanks, >>> >>> Rodrigo. >>> >>> __________________________________________________ >>> Fa?a liga??es para outros computadores com o novo Yahoo! Messenger >>> http://br.beta.messenger.yahoo.com/ >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > __________________________________________________ > Fa?a liga??es para outros computadores com o novo Yahoo! Messenger > http://br.beta.messenger.yahoo.com/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From rogerpack2005 at gmail.com Fri Jun 11 13:49:30 2010 From: rogerpack2005 at gmail.com (rogerdpack) Date: Fri, 11 Jun 2010 10:49:30 -0700 (PDT) Subject: [rspec-users] cleanup wiki Message-ID: The wiki (especially the index on its right hand) http://wiki.github.com/dchelimsky/rspec/ currently (to me) feels a bit hard to navigate. Given that my one request to github to allow for orderable right hand index was denied, I was wondering if some work wants to be done on it to make it easier to navigate. Two options seem to present themselves: 1) rename each page with an "ordering" prefix, like 1 Getting Started 1.1 Installation 1.1.2 Rails 1.2 Troubleshooting 2 Developing 2.1 Contributing 2.2 Getting in touch etc. advantage: the right hand index looks good, looks organized, overall easier to use. disadvantage: harder to edit, since ordering matters. 2) Add an "A Table of contents" page (it will be at the top), similar to http://wiki.github.com/aslakhellesoy/cucumber/a-table-of-content advantage: easier to edit. disadvantage: right hand index looks ugly. Any thoughts in this regard? -rp Any thoughts there? From peter.fitzgibbons at gmail.com Fri Jun 11 14:22:50 2010 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Fri, 11 Jun 2010 13:22:50 -0500 Subject: [rspec-users] Rails 3 Mailer spec with arguments ? Message-ID: <4C127EFA.4000406@gmail.com> This came out of the mailer generator w/ Rspec-rails installed : describe Notifier do it "should deliver activation instructions message" do @expected.subject = "Activation instructions" @expected.to = "to at example.org" @expected.from = "from at example.com" @expected.body = read_fixture("activation_instructions") end Could someone tell me how to modify this spec so that an argument can be sent into Notifier#activation_instructions ? class Notfier < ActionMailer::Base def activation_instructions(user) # ... mail :to => ... end end Thanks, -- Peter Fitzgibbons (847) 859-9550 peter.fitzgibbons at gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.denatale at gmail.com Fri Jun 11 14:53:23 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 11 Jun 2010 14:53:23 -0400 Subject: [rspec-users] Rails 3 Support/Design In-Reply-To: <0668B2A8-7558-439C-8CBE-FBF638640B16@gmail.com> References: <0668B2A8-7558-439C-8CBE-FBF638640B16@gmail.com> Message-ID: On Fri, Jun 11, 2010 at 11:17 AM, David Chelimsky wrote: > On Jun 11, 2010, at 10:56 AM, Rick DeNatale wrote: > >> On Thu, Jun 10, 2010 at 4:10 PM, David Chelimsky wrote: >>> On Thu, Jun 10, 2010 at 3:14 PM, geetarista wrote: >>>> Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm >>>> wondering why it doesn't use railtie, the new generators, etc. ?Will >>>> it stay this way or is it planned to support that? >>> >>> It does use the new generators, and we do have a railtie, but bundler >>> doesn't support exposing the railtie in the :test group by default, so >>> if you do this: >>> >>> group :test do >>> ?gem "rspec-rails" >>> end >>> >>> ... then you won't see the rake tasks or the generators. I believe >>> this will be addressed in bundler before it goes final, at which point >>> we'll rely only on the railtie. >> >> I'm not sure I see how bundler would address this, but couldn't it be >> addressed by breaking the stuff you need from rspec-rails in the >> development environment into a separate rspec-rails-dev gem or >> something like that. >> >> Breaking up gems seems to have been a theme in the transition from >> Rails 2 -> Rails 3. >> >> Just an idea > > And an interesting one at that, but I think it would add to more confusion than not. Right now you just have to require 'rspec-rails' in the Gemfile and it depends on rspec, which depends on all the other gems. If we separated out a gem for generators/rake tasks, it would need to be outside the test group, so you'd have one rspec gem in one group and one in another. > > I spoke w/ wycats about this issue at RailsConf and he agreed that railties in the test group should be exposed in development mode. RSpec won't be the only tool that this impacts, nor would RSpec users be the only people. > > That all make sense? Well if it makes sense to you and Yehuda, that's all that matters. I'm still trying to get my head around the idea of bundler loading part of a gem, but that's probably cuz I really haven't dug into how bundler really works. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From dchelimsky at gmail.com Fri Jun 11 17:24:36 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 Jun 2010 17:24:36 -0400 Subject: [rspec-users] Rails 3 Support/Design In-Reply-To: References: <0668B2A8-7558-439C-8CBE-FBF638640B16@gmail.com> Message-ID: On Fri, Jun 11, 2010 at 2:53 PM, Rick DeNatale wrote: > On Fri, Jun 11, 2010 at 11:17 AM, David Chelimsky wrote: >> On Jun 11, 2010, at 10:56 AM, Rick DeNatale wrote: >> >>> On Thu, Jun 10, 2010 at 4:10 PM, David Chelimsky wrote: >>>> On Thu, Jun 10, 2010 at 3:14 PM, geetarista wrote: >>>>> Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm >>>>> wondering why it doesn't use railtie, the new generators, etc. ?Will >>>>> it stay this way or is it planned to support that? >>>> >>>> It does use the new generators, and we do have a railtie, but bundler >>>> doesn't support exposing the railtie in the :test group by default, so >>>> if you do this: >>>> >>>> group :test do >>>> ?gem "rspec-rails" >>>> end >>>> >>>> ... then you won't see the rake tasks or the generators. I believe >>>> this will be addressed in bundler before it goes final, at which point >>>> we'll rely only on the railtie. >>> >>> I'm not sure I see how bundler would address this, but couldn't it be >>> addressed by breaking the stuff you need from rspec-rails in the >>> development environment into a separate rspec-rails-dev gem or >>> something like that. >>> >>> Breaking up gems seems to have been a theme in the transition from >>> Rails 2 -> Rails 3. >>> >>> Just an idea >> >> And an interesting one at that, but I think it would add to more confusion than not. Right now you just have to require 'rspec-rails' in the Gemfile and it depends on rspec, which depends on all the other gems. If we separated out a gem for generators/rake tasks, it would need to be outside the test group, so you'd have one rspec gem in one group and one in another. >> >> I spoke w/ wycats about this issue at RailsConf and he agreed that railties in the test group should be exposed in development mode. RSpec won't be the only tool that this impacts, nor would RSpec users be the only people. >> >> That all make sense? > > Well if it makes sense to you and Yehuda, that's all that matters. > I'm still trying to get my head around the idea of bundler loading > part of a gem, but that's probably cuz I really haven't dug into how > bundler really works. I hadn't considered that :) I imagine it would have to load the gem. I'll discuss further w/ carlhuda and follow up when I know something new. From juange88 at gmail.com Fri Jun 11 18:54:11 2010 From: juange88 at gmail.com (juange) Date: Fri, 11 Jun 2010 15:54:11 -0700 (PDT) Subject: [rspec-users] Rails 3 , RSpec 2.0.0.beta.11 Message-ID: Hi, I was doing some testing to mi controller and a error raise, and it's driving me crazy. This are the lines that I wanna test: @cloning_vector = CloningVector.new(params[:cloning_vector]) @cloning_vector.sequence = Sequence.new(params[:sequence]) What I'm trying to do is following: @cloning_vector = mock_model(CloningVector) @sequence = mock_model(Sequence) CloningVector.should_receive(:new).with("name" => "New cloning_vector", "cloning_vector_type" => 1).and_return(@cloning_vector) @cloning_vector.sequence.should_receive(:new).with("content" => "New Content").and_return(@sequence) What am I doing wrong?..... Thanks for your help From lbocseg at yahoo.com.br Fri Jun 11 23:12:22 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sat, 12 Jun 2010 00:12:22 -0300 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <4C127650.5090304@gmail.com> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> <4C1272B0.6080701@yahoo.com.br> <4C127650.5090304@gmail.com> Message-ID: <4C12FB16.5000802@yahoo.com.br> Thank you, Peter. Rodrigo. Em 11-06-2010 14:45, Peter Fitzgibbons escreveu: > remove the :type key from your describe line (it's no longer needed). > > Peter Fitzgibbons > (847) 859-9550 > peter.fitzgibbons at gmail.com > IM GTalk: peter.fitzgibbons > IM AOL: peter.fitzgibbons at gmail.com > > On 6/11/10 12:30 PM, Rodrigo Rosenfeld Rosas wrote: >> Now I'm getting: >> >> no such file to load -- action_controller/integration >> >> Am I missing something? >> >> Thanks, >> >> Rodrigo. >> >> P.S.: Sorry if this was sent twice... >> >> Em 11-06-2010 01:10, David Chelimsky escreveu: >>> Change the directory name to requests (a la merb) >>> >>> Sent from my iPhone >>> >>> On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas >>> wrote: >>> >>>> Hi guys, >>>> >>>> I'm trying to port an application to Rails 3 but can't get my >>>> integration tests to run. >>>> >>>> I can't call the Webrat's method (yields 'undefined method `visit`', >>>> for instance). I don't use Cucumber. >>>> >>>> Is there any instructions about how to configure Rspec 2 with Webrat >>>> on Rails 3? >>>> >>>> I also have a custom helper that is not working: >>>> >>>> "config.include MyApp::IntegrationHelper, :type => :integration" (the >>>> methods defined in this module are not available in the specs) >>>> >>>> Any ideas? >>>> >>>> Thanks, >>>> >>>> Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From lbocseg at yahoo.com.br Fri Jun 11 23:17:20 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sat, 12 Jun 2010 00:17:20 -0300 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> <4C1272B0.6080701@yahoo.com.br> Message-ID: <4C12FC40.90602@yahoo.com.br> Apparently Webrat is not yet compatible with Rails 3: http://github.com/brynary/webrat/blob/master/lib/webrat/integrations/rails.rb line 2: require "action_controller/integration" action_controller/integration.rb does exist in Rails 2 but not in Rails 3, but I didn't find any branch for Rails 3 in webrat's repository. I'll give Capybara another try. I had already tried it before but didn't change to it because I couldn't get the Drag & Drop javascript test to work anyway, but it seems to be a good replacement to Webrat's and there seems to be plans to merge them... Does anyone here use Capybara with Rspec2 and Rails 3 without Cucumber to write integration tests successfully? Thanks, Rodrigo. Em 11-06-2010 14:44, David Chelimsky escreveu: > > > Sent from my iPhone > > On Jun 11, 2010, at 1:30 PM, Rodrigo Rosenfeld Rosas > wrote: > >> Now I'm getting: >> >> no such file to load -- action_controller/integration > > Backtrace, please >> >> Am I missing something? >> >> Thanks, >> >> Rodrigo. >> >> P.S.: Sorry if this was sent twice... >> >> Em 11-06-2010 01:10, David Chelimsky escreveu: >>> Change the directory name to requests (a la merb) >>> >>> Sent from my iPhone >>> >>> On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas >>> wrote: >>> >>>> Hi guys, >>>> >>>> I'm trying to port an application to Rails 3 but can't get my >>>> integration tests to run. >>>> >>>> I can't call the Webrat's method (yields 'undefined method `visit`', >>>> for instance). I don't use Cucumber. >>>> >>>> Is there any instructions about how to configure Rspec 2 with Webrat >>>> on Rails 3? >>>> >>>> I also have a custom helper that is not working: >>>> >>>> "config.include MyApp::IntegrationHelper, :type => :integration" (the >>>> methods defined in this module are not available in the specs) >>>> >>>> Any ideas? >>>> >>>> Thanks, >>>> >>>> Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From matt at mattwynne.net Sat Jun 12 03:13:47 2010 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 12 Jun 2010 08:13:47 +0100 Subject: [rspec-users] Rails 3 , RSpec 2.0.0.beta.11 In-Reply-To: References: Message-ID: <4557FA17-33CD-4844-8802-7A1B240A6525@mattwynne.net> On 11 Jun 2010, at 23:54, juange wrote: > Hi, > > I was doing some testing to mi controller and a error raise, and it's > driving me crazy. This are the lines that I wanna test: > > @cloning_vector = CloningVector.new(params[:cloning_vector]) > @cloning_vector.sequence = Sequence.new(params[:sequence]) > > What I'm trying to do is following: > > @cloning_vector = mock_model(CloningVector) > @sequence = mock_model(Sequence) > > CloningVector.should_receive(:new).with("name" => "New > cloning_vector", "cloning_vector_type" => > 1).and_return(@cloning_vector) This line is the one with the mistake on it: > @cloning_vector.sequence.should_receive(:new).with("content" => > "New Content").and_return(@sequence) Which class received the :new message in the code you're testing? Not @cloning_vector.sequence, but Sequence. Just the same way as you've stubbed CloningVector.new, you need to stub Sequence.new. Make sense? > > What am I doing wrong?..... Thanks for your help > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Jun 12 06:31:16 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 Jun 2010 06:31:16 -0400 Subject: [rspec-users] Rails 3 Support/Design In-Reply-To: References: <0668B2A8-7558-439C-8CBE-FBF638640B16@gmail.com> Message-ID: On Fri, Jun 11, 2010 at 5:24 PM, David Chelimsky wrote: > On Fri, Jun 11, 2010 at 2:53 PM, Rick DeNatale wrote: >> On Fri, Jun 11, 2010 at 11:17 AM, David Chelimsky wrote: >>> On Jun 11, 2010, at 10:56 AM, Rick DeNatale wrote: >>> >>>> On Thu, Jun 10, 2010 at 4:10 PM, David Chelimsky wrote: >>>>> On Thu, Jun 10, 2010 at 3:14 PM, geetarista wrote: >>>>>> Since Rspec-Rails 2 is specifically geared toward Rails 3, I'm >>>>>> wondering why it doesn't use railtie, the new generators, etc. ?Will >>>>>> it stay this way or is it planned to support that? >>>>> >>>>> It does use the new generators, and we do have a railtie, but bundler >>>>> doesn't support exposing the railtie in the :test group by default, so >>>>> if you do this: >>>>> >>>>> group :test do >>>>> ?gem "rspec-rails" >>>>> end >>>>> >>>>> ... then you won't see the rake tasks or the generators. I believe >>>>> this will be addressed in bundler before it goes final, at which point >>>>> we'll rely only on the railtie. >>>> >>>> I'm not sure I see how bundler would address this, but couldn't it be >>>> addressed by breaking the stuff you need from rspec-rails in the >>>> development environment into a separate rspec-rails-dev gem or >>>> something like that. >>>> >>>> Breaking up gems seems to have been a theme in the transition from >>>> Rails 2 -> Rails 3. >>>> >>>> Just an idea >>> >>> And an interesting one at that, but I think it would add to more confusion than not. Right now you just have to require 'rspec-rails' in the Gemfile and it depends on rspec, which depends on all the other gems. If we separated out a gem for generators/rake tasks, it would need to be outside the test group, so you'd have one rspec gem in one group and one in another. >>> >>> I spoke w/ wycats about this issue at RailsConf and he agreed that railties in the test group should be exposed in development mode. RSpec won't be the only tool that this impacts, nor would RSpec users be the only people. >>> >>> That all make sense? >> >> Well if it makes sense to you and Yehuda, that's all that matters. >> I'm still trying to get my head around the idea of bundler loading >> part of a gem, but that's probably cuz I really haven't dug into how >> bundler really works. > > I hadn't considered that :) I imagine it would have to load the gem. > I'll discuss further w/ carlhuda and follow up when I know something > new. Remembering back to my conversation with Yehuda, the idea was that the rake command and script/rails g script need bundler to load gems in the test group in order for gems like cucumber-rails and rspec-rails to expose tasks and generators via a railtie. So it's not a bundler issue, but a rails issue. In fact, there's a rails ticket, to which I've added a comment that looks suspiciously like the first sentence in this paragraph. https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3774-gem-generators-are-not-found-by-scriptgenerate#ticket-3774-3 Cheers, David From dchelimsky at gmail.com Sat Jun 12 06:33:28 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 Jun 2010 06:33:28 -0400 Subject: [rspec-users] cleanup wiki In-Reply-To: References: Message-ID: On Fri, Jun 11, 2010 at 1:49 PM, rogerdpack wrote: > The wiki (especially the index on its right hand) http://wiki.github.com/dchelimsky/rspec/ > currently (to me) feels a bit hard to navigate. > > Given that my one request to github to allow for orderable right hand > index was denied, I was wondering if some work wants to be done on it > to make it easier to navigate. > > Two options seem to present themselves: > > 1) rename each page with an "ordering" prefix, like > > ?1 Getting Started > ?1.1 Installation > ?1.1.2 Rails > ?1.2 Troubleshooting > ?2 Developing > ?2.1 Contributing > ?2.2 Getting in touch > > ?etc. > > advantage: the right hand index looks good, looks organized, overall > easier to use. > disadvantage: harder to edit, since ordering matters. > > 2) Add an "A Table of contents" page (it will be at the top), similar > to http://wiki.github.com/aslakhellesoy/cucumber/a-table-of-content > advantage: easier to edit. > disadvantage: right hand index looks ugly. > > Any thoughts in this regard? > -rp > Any thoughts there? I think a TOC would be far easier to maintain, no? From dchelimsky at gmail.com Sat Jun 12 07:01:46 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 Jun 2010 07:01:46 -0400 Subject: [rspec-users] Rails 3 Mailer spec with arguments ? In-Reply-To: <4C127EFA.4000406@gmail.com> References: <4C127EFA.4000406@gmail.com> Message-ID: On Fri, Jun 11, 2010 at 2:22 PM, Peter Fitzgibbons wrote: > This came out of the mailer generator w/ Rspec-rails installed : > > describe Notifier do > ? it "should deliver activation instructions message" do > ??? @expected.subject = "Activation instructions" > ??? @expected.to????? = "to at example.org" > ??? @expected.from??? = "from at example.com" > ??? @expected.body??? = read_fixture("activation_instructions") > ? end > > > Could someone tell me how to modify this spec so that an argument can be > sent into Notifier#activation_instructions ? > > class Notfier < ActionMailer::Base > ??? def activation_instructions(user) > ??? ??? # ... mail :to => ... > ??? end > end user = stub_model(User) @expected.activation_instructions(user) I'm adding a mailer() method to wrap @expected for the next release, but it's the same object. From dchelimsky at gmail.com Sat Jun 12 07:04:00 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 Jun 2010 07:04:00 -0400 Subject: [rspec-users] Rails 3 Mailer spec with arguments ? In-Reply-To: References: <4C127EFA.4000406@gmail.com> Message-ID: On Sat, Jun 12, 2010 at 7:01 AM, David Chelimsky wrote: > On Fri, Jun 11, 2010 at 2:22 PM, Peter Fitzgibbons > wrote: >> This came out of the mailer generator w/ Rspec-rails installed : >> >> describe Notifier do >> ? it "should deliver activation instructions message" do >> ??? @expected.subject = "Activation instructions" >> ??? @expected.to????? = "to at example.org" >> ??? @expected.from??? = "from at example.com" >> ??? @expected.body??? = read_fixture("activation_instructions") >> ? end >> >> >> Could someone tell me how to modify this spec so that an argument can be >> sent into Notifier#activation_instructions ? >> >> class Notfier < ActionMailer::Base >> ??? def activation_instructions(user) >> ??? ??? # ... mail :to => ... >> ??? end >> end > > user = stub_model(User) > @expected.activation_instructions(user) > > I'm adding a mailer() method to wrap @expected for the next release, > but it's the same object. Disregard :) I'll add a mailer method that access the mailer, and a message method that wraps @expected. From dchelimsky at gmail.com Sat Jun 12 07:18:39 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 Jun 2010 07:18:39 -0400 Subject: [rspec-users] Rails 3 Mailer spec with arguments ? In-Reply-To: References: <4C127EFA.4000406@gmail.com> Message-ID: On Sat, Jun 12, 2010 at 7:04 AM, David Chelimsky wrote: > On Sat, Jun 12, 2010 at 7:01 AM, David Chelimsky wrote: >> On Fri, Jun 11, 2010 at 2:22 PM, Peter Fitzgibbons >> wrote: >>> This came out of the mailer generator w/ Rspec-rails installed : >>> >>> describe Notifier do >>> ? it "should deliver activation instructions message" do >>> ??? @expected.subject = "Activation instructions" >>> ??? @expected.to????? = "to at example.org" >>> ??? @expected.from??? = "from at example.com" >>> ??? @expected.body??? = read_fixture("activation_instructions") >>> ? end >>> >>> >>> Could someone tell me how to modify this spec so that an argument can be >>> sent into Notifier#activation_instructions ? >>> >>> class Notfier < ActionMailer::Base >>> ??? def activation_instructions(user) >>> ??? ??? # ... mail :to => ... >>> ??? end >>> end >> >> user = stub_model(User) >> @expected.activation_instructions(user) >> >> I'm adding a mailer() method to wrap @expected for the next release, >> but it's the same object. > > Disregard :) > > I'll add a mailer method that access the mailer, and a message method > that wraps @expected. > For now you can say: Notifier.__send__(:new).activation_instructions(user) From ssmithstone at me.com Sat Jun 12 09:05:31 2010 From: ssmithstone at me.com (Stephen Smithstone) Date: Sat, 12 Jun 2010 14:05:31 +0100 Subject: [rspec-users] Stubbing before_filters with RSpec and stub! In-Reply-To: <750108d5-6b10-490d-ad85-999a18f2032a@u20g2000pru.googlegroups.com> References: <750108d5-6b10-490d-ad85-999a18f2032a@u20g2000pru.googlegroups.com> Message-ID: <4C13861B.1050402@me.com> An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Jun 12 10:49:13 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 Jun 2010 10:49:13 -0400 Subject: [rspec-users] Stubbing before_filters with RSpec and stub! In-Reply-To: <4C13861B.1050402@me.com> References: <750108d5-6b10-490d-ad85-999a18f2032a@u20g2000pru.googlegroups.com> <4C13861B.1050402@me.com> Message-ID: On Jun 12, 2010, at 9:05 AM, Stephen Smithstone wrote: > On 11/06/2010 03:07, Joseph DelCioppio wrote: >> >> Guys, >> >> I've got a private controller method which acts as a before_filter >> that I'm trying to stub. >> >> class TasksController < ApplicationController >> before_filter :load_user >> >> ...... >> >> private >> >> def load_user >> if current_user.id == params[:user_id].to_i >> @user = current_user >> else >> flash[:notice] = "Sorry but you can't view other people's >> tasks." >> redirect_to root_path >> end >> end >> end >> >> >> describe TasksController do >> >> before(:each) do >> @user = Factory(:user) >> sign_in @user >> @task = Factory(:task) >> User.stub_chain(:where, :first).and_return(@user) >> controller.stub!(:load_user).and_return(@user) >> end >> >> ....... >> end >> >> However, even though I'm stubbing load_user, the actual function is >> still being called, because I can make all my tests either pass/fail >> if I simply have load_user neglect to return @user. >> >> If I have stubbed load_user, should it just always return @user, no >> matter what I do to the actual controller method? I thought that this >> was the point of stubbing, that way if I change load_user in the >> future, only the tests specifically designed to exercise load_user >> will fail, but the rest of my suite will still pass. >> >> I'm going to post my entire controller and spec and provide the Gist >> links in case the abbreviated versions I gave aren't enough. >> >> http://gist.github.com/433942 > What I would do maybe not the best solution is to control what is returned in current user so if you want to test that the redirect works then > make current_user return nil then the redirect should work and to get the filter to pass stub the current user to return an instance that has an id that matches the param passed in That's actually a very common solution to this problem. The caller of the filter doesn't actually store the user, it expects the filter to set the @user instance variable. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Jun 12 11:40:36 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 Jun 2010 11:40:36 -0400 Subject: [rspec-users] Rails 3 Mailer spec with arguments ? In-Reply-To: References: <4C127EFA.4000406@gmail.com> Message-ID: On Sat, Jun 12, 2010 at 7:18 AM, David Chelimsky wrote: > On Sat, Jun 12, 2010 at 7:04 AM, David Chelimsky wrote: >> On Sat, Jun 12, 2010 at 7:01 AM, David Chelimsky wrote: >>> On Fri, Jun 11, 2010 at 2:22 PM, Peter Fitzgibbons >>> wrote: >>>> This came out of the mailer generator w/ Rspec-rails installed : >>>> >>>> describe Notifier do >>>> ? it "should deliver activation instructions message" do >>>> ??? @expected.subject = "Activation instructions" >>>> ??? @expected.to????? = "to at example.org" >>>> ??? @expected.from??? = "from at example.com" >>>> ??? @expected.body??? = read_fixture("activation_instructions") >>>> ? end >>>> >>>> >>>> Could someone tell me how to modify this spec so that an argument can be >>>> sent into Notifier#activation_instructions ? >>>> >>>> class Notfier < ActionMailer::Base >>>> ??? def activation_instructions(user) >>>> ??? ??? # ... mail :to => ... >>>> ??? end >>>> end >>> >>> user = stub_model(User) >>> @expected.activation_instructions(user) >>> >>> I'm adding a mailer() method to wrap @expected for the next release, >>> but it's the same object. >> >> Disregard :) >> >> I'll add a mailer method that access the mailer, and a message method >> that wraps @expected. >> > > For now you can say: > > Notifier.__send__(:new).activation_instructions(user) OK - I got a patch into rails so rspec mailer specs can mix in behavior from an ActionMailer::TestCase::Behavior module. I updated mailer specs to use this and updated the generator to generate something more useful. Peter - is activation_instructions an action? If so you just need to say "Notifier.activation_instructions(user)" directly in the example. If it's a helper method, I'd recommend moving it to a helper module and spec'ing it there. WDYT? From kmandrup at gmail.com Sun Jun 13 06:49:59 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sun, 13 Jun 2010 03:49:59 -0700 (PDT) Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: References: Message-ID: assigns(:message).should eq(@message) assign(:message, stub("Message", :text => "Hello world!")) Hmm, so 'assign' to assign a variable and 'assigns' to read an assigned variable? We need to update the RSpec 2 wiki or somewhere with all these API changes so it is clear to everyone. On Jun 11, 9:08?am, David Chelimsky wrote: > On Thu, Jun 10, 2010 at 4:41 PM, wrote: > > I might be missing something basic here, but I'm stumped on this > > error: > > > model code: > > > class CachedStat < ActiveRecord::Base > > ? ?def self.create_stats_days_ago(days_ago, human_id) > > ? ?d = Date.today - days_ago.day > > ? ?@prs = PageRequest.find(:all, :conditions => [ "owner_type = > > 'Human' and owner_id = ? and created_at = ?", human_id, d] ) > > ?end > > end > > > spec code: > > > ?it "should create stats for the specified number of days in the > > past" do > > ? ?CachedStat.create_stats_days_ago(1, Human.first.id) > > ? ?assigns[:prs].should eql("foo") > > ?end > > > The error is: undefined local variable or method `assigns' for > > # > > > I feel like I'm overlooking something obvious but it's invisible to > > me. Any suggestions? > > assigns is for controller and view specs, not model specs. What is it > you're trying to specify here? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From kmandrup at gmail.com Sun Jun 13 07:03:20 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sun, 13 Jun 2010 04:03:20 -0700 (PDT) Subject: [rspec-users] RSpec 2: uninitialized constant - mocking belongs_to AR relation In-Reply-To: <1052b8ec-9f9c-4db3-a721-0f410220ab6a@h13g2000yqm.googlegroups.com> References: <1052b8ec-9f9c-4db3-a721-0f410220ab6a@h13g2000yqm.googlegroups.com> Message-ID: Cause of error: class Message < ActiveRecord::Base belongs_to :recipient #, :class_name => User.name -- it then by convention expects there to be a model class called Recipient. should instead be class Message < ActiveRecord::Base belongs_to :recipient, :class_name => User.name But then the User class must be a subclass of ActiveRecord, or have a name method that returns "User" or even more simple: class Message < ActiveRecord::Base belongs_to :recipient, :class_name => "User" From dchelimsky at gmail.com Sun Jun 13 09:29:15 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 13 Jun 2010 09:29:15 -0400 Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: References: Message-ID: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> On Jun 13, 2010, at 6:49 AM, Kristian Mandrup wrote: > assigns(:message).should eq(@message) > > assign(:message, stub("Message", :text => "Hello world!")) > > Hmm, so 'assign' to assign a variable and 'assigns' to read an > assigned variable? > We need to update the RSpec 2 wiki or somewhere with all these API > changes so it is clear to everyone. There's already info about assign(key, val) on the rspec-rails readme: http://github.com/rspec/rspec-rails. I'll add something about assigns(:key) as well. Keep in mind that assign(k,v) is used in view specs to provide data to the view, whereas assigns(key) is used in controller specs to express expectations about what the controller does. As for the wiki, let's hold off on that for now. There is currently insufficient documentation in too many places, and the wiki has, at times, caused more confusion than benefit. I've got a few thoughts rolling around about how to best address this, and I'll follow up on that in a separate thread in the next couple of days. Cheers, David > On Jun 11, 9:08 am, David Chelimsky wrote: >> On Thu, Jun 10, 2010 at 4:41 PM, wrote: >>> I might be missing something basic here, but I'm stumped on this >>> error: >> >>> model code: >> >>> class CachedStat < ActiveRecord::Base >>> def self.create_stats_days_ago(days_ago, human_id) >>> d = Date.today - days_ago.day >>> @prs = PageRequest.find(:all, :conditions => [ "owner_type = >>> 'Human' and owner_id = ? and created_at = ?", human_id, d] ) >>> end >>> end >> >>> spec code: >> >>> it "should create stats for the specified number of days in the >>> past" do >>> CachedStat.create_stats_days_ago(1, Human.first.id) >>> assigns[:prs].should eql("foo") >>> end >> >>> The error is: undefined local variable or method `assigns' for >>> # >> >>> I feel like I'm overlooking something obvious but it's invisible to >>> me. Any suggestions? >> >> assigns is for controller and view specs, not model specs. What is it >> you're trying to specify here? >> _______________________________________________ >> 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 From tom at experthuman.com Sun Jun 13 16:15:11 2010 From: tom at experthuman.com (Tom Stuart) Date: Sun, 13 Jun 2010 21:15:11 +0100 Subject: [rspec-users] Method stub return values for message expectations Message-ID: <4BB9CCBE-6FF6-41E8-80D1-366856566635@experthuman.com> Hi, RSpec has long had the ability to set a message expectation for a stubbed method without disrupting its (stubbed) return value. This is really helpful for a variety of reasons, not least because it decouples the stubbed method's return value from the expectation that the method will be called, which for example is often necessary when an expectation appears in a shared example group and the corresponding return value is stubbed differently by the different contexts which use that shared group. This still works fine as long as no argument matchers are involved: > > A.stub!(:msg).and_return(:special_value) > > A.should_receive(:msg) > > A.msg > => :special_value But as of http://github.com/dchelimsky/rspec/commit/386e334 (i.e. in 1.3.0) it no longer works when the stub uses an argument matcher: > > A.stub!(:msg).with(:arg).and_return(:special_value) > > A.should_receive(:msg).with(:arg) > > A.msg(:arg) > => nil This is a pain because I always prefer to lock down stubbed methods with argument matchers where possible; while the message expectations verify that a particular set of method calls are necessary, their corresponding stubs + arg matchers verify that the same set of calls is sufficient, i.e. there aren't any other calls to stubbed methods (with unexpected arguments) that you don't know about. So, has something been broken? Or is using argument matchers with stubs unsupported in the first place? Cheers, -Tom From dchelimsky at gmail.com Sun Jun 13 16:20:48 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 13 Jun 2010 16:20:48 -0400 Subject: [rspec-users] Method stub return values for message expectations In-Reply-To: <4BB9CCBE-6FF6-41E8-80D1-366856566635@experthuman.com> References: <4BB9CCBE-6FF6-41E8-80D1-366856566635@experthuman.com> Message-ID: <1D2D531E-FB34-4C11-8098-CCA691A63644@gmail.com> On Jun 13, 2010, at 4:15 PM, Tom Stuart wrote: > Hi, > > RSpec has long had the ability to set a message expectation for a stubbed method without disrupting its (stubbed) return value. This is really helpful for a variety of reasons, not least because it decouples the stubbed method's return value from the expectation that the method will be called, which for example is often necessary when an expectation appears in a shared example group and the corresponding return value is stubbed differently by the different contexts which use that shared group. > > This still works fine as long as no argument matchers are involved: > >>> A.stub!(:msg).and_return(:special_value) >>> A.should_receive(:msg) >>> A.msg >> => :special_value > > But as of http://github.com/dchelimsky/rspec/commit/386e334 (i.e. in 1.3.0) it no longer works when the stub uses an argument matcher: > >>> A.stub!(:msg).with(:arg).and_return(:special_value) >>> A.should_receive(:msg).with(:arg) >>> A.msg(:arg) >> => nil > > This is a pain because I always prefer to lock down stubbed methods with argument matchers where possible; while the message expectations verify that a particular set of method calls are necessary, their corresponding stubs + arg matchers verify that the same set of calls is sufficient, i.e. there aren't any other calls to stubbed methods (with unexpected arguments) that you don't know about. > > So, has something been broken? Or is using argument matchers with stubs unsupported in the first place? That commit was just a refactoring - no intent to change behavior - just missing an example for this particular case. Please report to http://rspec.lighthouseapp.com for rspec-1 and http://github.com/rspec/rspec-mocks for rspec-2 (the two separate places to report bugs is a temporary situation). Thx, David From kmandrup at gmail.com Sun Jun 13 16:35:51 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sun, 13 Jun 2010 13:35:51 -0700 (PDT) Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> References: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> Message-ID: <855c386d-b60e-4253-9115-0cae35c243d4@j8g2000yqd.googlegroups.com> Hi David, Sounds great! Looking forward to more documentation :) I have now gone through all the examples in the RSpec book and got them working with the latest version of RSpec 2 and Rails 3 beta4. I only have one loose end: shared_examples_for "a template that renders the messages/form partial" do it "renders the messages/form partial" do template.should_receive(:render).with( :partial => "form", :locals => { :message => assigns[:message] } ) render end end undefined local variable or method `template' for # Changing template to _view as you instructed previously (I think) _view.should_receive(:render).with( :partial => "form", :locals => { :message => assigns[:message] } ) # received :render with unexpected arguments expected: ({:partial=>"form", :locals=>{:message=>nil}}) got: ({:template=>"messages/edit.html.erb"}, {}) But this is my edit.html <%= render "form", :message => @message %> So _view only contains info on the view. How do I get info on the templates called as part of the rendering process? On Jun 13, 3:29?pm, David Chelimsky wrote: > On Jun 13, 2010, at 6:49 AM, Kristian Mandrup wrote: > > > assigns(:message).should eq(@message) > > > assign(:message, stub("Message", :text => "Hello world!")) > > > Hmm, so 'assign' to assign a variable and 'assigns' to read an > > assigned variable? > > We need to update the RSpec 2 wiki or somewhere with all these API > > changes so it is clear to everyone. > > There's already info about assign(key, val) on the rspec-rails readme:http://github.com/rspec/rspec-rails. I'll add something about assigns(:key) as well. > > Keep in mind that assign(k,v) is used in view specs to provide data to the view, whereas assigns(key) is used in controller specs to express expectations about what the controller does. > > As for the wiki, let's hold off on that for now. There is currently insufficient ?documentation in too many places, and the wiki has, at times, caused more confusion than benefit. I've got a few thoughts rolling around about how to best address this, and I'll follow up on that in a separate thread in the next couple of days. > > Cheers, > David > > > > > On Jun 11, 9:08 am, David Chelimsky wrote: > >> On Thu, Jun 10, 2010 at 4:41 PM, wrote: > >>> I might be missing something basic here, but I'm stumped on this > >>> error: > > >>> model code: > > >>> class CachedStat < ActiveRecord::Base > >>> ? ?def self.create_stats_days_ago(days_ago, human_id) > >>> ? ?d = Date.today - days_ago.day > >>> ? ?@prs = PageRequest.find(:all, :conditions => [ "owner_type = > >>> 'Human' and owner_id = ? and created_at = ?", human_id, d] ) > >>> ?end > >>> end > > >>> spec code: > > >>> ?it "should create stats for the specified number of days in the > >>> past" do > >>> ? ?CachedStat.create_stats_days_ago(1, Human.first.id) > >>> ? ?assigns[:prs].should eql("foo") > >>> ?end > > >>> The error is: undefined local variable or method `assigns' for > >>> # > > >>> I feel like I'm overlooking something obvious but it's invisible to > >>> me. Any suggestions? > > >> assigns is for controller and view specs, not model specs. What is it > >> you're trying to specify here? > >> _______________________________________________ > >> 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 From dchelimsky at gmail.com Sun Jun 13 16:48:07 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 13 Jun 2010 16:48:07 -0400 Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: <855c386d-b60e-4253-9115-0cae35c243d4@j8g2000yqd.googlegroups.com> References: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> <855c386d-b60e-4253-9115-0cae35c243d4@j8g2000yqd.googlegroups.com> Message-ID: On Jun 13, 2010, at 4:35 PM, Kristian Mandrup wrote: > Hi David, > > Sounds great! Looking forward to more documentation :) > I have now gone through all the examples in the RSpec book and got > them working with the latest version of RSpec 2 and Rails 3 beta4. > I only have one loose end: > > shared_examples_for "a template that renders the messages/form > partial" do > it "renders the messages/form partial" do > template.should_receive(:render).with( > :partial => "form", > :locals => { :message => assigns[:message] } > ) > render > end > end > > undefined local variable or method `template' for > # > > Changing template to _view as you instructed previously (I think) > > _view.should_receive(:render).with( > :partial => "form", > :locals => { :message => assigns[:message] } > ) > > # received :render with unexpected > arguments > expected: ({:partial=>"form", :locals=>{:message=>nil}}) > got: ({:template=>"messages/edit.html.erb"}, {}) > > But this is my edit.html > > <%= render "form", :message => @message %> > > So _view only contains info on the view. How do I get info on the > templates called as part of the rendering process? See the bit on View Specs on http://github.com/rspec/rspec-rails/blob/master/Upgrade.markdown > > > On Jun 13, 3:29 pm, David Chelimsky wrote: >> On Jun 13, 2010, at 6:49 AM, Kristian Mandrup wrote: >> >>> assigns(:message).should eq(@message) >> >>> assign(:message, stub("Message", :text => "Hello world!")) >> >>> Hmm, so 'assign' to assign a variable and 'assigns' to read an >>> assigned variable? >>> We need to update the RSpec 2 wiki or somewhere with all these API >>> changes so it is clear to everyone. >> >> There's already info about assign(key, val) on the rspec-rails readme:http://github.com/rspec/rspec-rails. I'll add something about assigns(:key) as well. >> >> Keep in mind that assign(k,v) is used in view specs to provide data to the view, whereas assigns(key) is used in controller specs to express expectations about what the controller does. >> >> As for the wiki, let's hold off on that for now. There is currently insufficient documentation in too many places, and the wiki has, at times, caused more confusion than benefit. I've got a few thoughts rolling around about how to best address this, and I'll follow up on that in a separate thread in the next couple of days. >> >> Cheers, >> David >> >> >> >>> On Jun 11, 9:08 am, David Chelimsky wrote: >>>> On Thu, Jun 10, 2010 at 4:41 PM, wrote: >>>>> I might be missing something basic here, but I'm stumped on this >>>>> error: >> >>>>> model code: >> >>>>> class CachedStat < ActiveRecord::Base >>>>> def self.create_stats_days_ago(days_ago, human_id) >>>>> d = Date.today - days_ago.day >>>>> @prs = PageRequest.find(:all, :conditions => [ "owner_type = >>>>> 'Human' and owner_id = ? and created_at = ?", human_id, d] ) >>>>> end >>>>> end >> >>>>> spec code: >> >>>>> it "should create stats for the specified number of days in the >>>>> past" do >>>>> CachedStat.create_stats_days_ago(1, Human.first.id) >>>>> assigns[:prs].should eql("foo") >>>>> end >> >>>>> The error is: undefined local variable or method `assigns' for >>>>> # >> >>>>> I feel like I'm overlooking something obvious but it's invisible to >>>>> me. Any suggestions? >> >>>> assigns is for controller and view specs, not model specs. What is it >>>> you're trying to specify here? >>>> _______________________________________________ >>>> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From kmandrup at gmail.com Sun Jun 13 18:16:39 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sun, 13 Jun 2010 15:16:39 -0700 (PDT) Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: References: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> <855c386d-b60e-4253-9115-0cae35c243d4@j8g2000yqd.googlegroups.com> Message-ID: <7bd142e9-00e3-4f93-ad1e-cde491118e52@b35g2000yqi.googlegroups.com> Thanks! Just what I needed :) From kmandrup at gmail.com Sun Jun 13 18:32:12 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sun, 13 Jun 2010 15:32:12 -0700 (PDT) Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: References: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> <855c386d-b60e-4253-9115-0cae35c243d4@j8g2000yqd.googlegroups.com> Message-ID: shared_examples_for "a template that renders the messages/form partial" do it "renders the messages/form partial" do view.should_receive(:_render_partial). with(hash_including(:partial => "form")) render end end # new.html.erb <%= render "sidebar", :recent_messages => @recent_messages %> <%= render "form", :message => @message %> 7) messages/new.html.erb renders the messages/form partial Failure/Error: Unable to find matching line from backtrace # received :_render_partial with unexpected arguments expected: (hash_including(:partial=>"form")) got: ({:partial=>"sidebar", :locals=>{:recent_messages=>[]}}) So what to do if I call multiple partials from my view? From johnf.pub at distb.net Sun Jun 13 19:54:47 2010 From: johnf.pub at distb.net (John Feminella) Date: Sun, 13 Jun 2010 19:54:47 -0400 Subject: [rspec-users] Recommendations for ticket #971 workaround? Message-ID: hello, I'm running rspec 1.3.0 on Ruby 1.9.2-dev. It appears that when you use `it` without a corresponding block, the test case is treated not as pending, but instead throws an error inside rspec. I see that there is a bug to this effect filed here: https://rspec.lighthouseapp.com/projects/5645/tickets/971-with-ruby-19-it-without-block-is-not-pending-but-throws-argumenterror Lines 79 through 81 of lib/spec/example/example_group_methods.rb look like this: def pending_implementation lambda { raise(Spec::Example::NotYetImplementedError) } end An argument is passed to the lambda in example_methods.rb. In Ruby 1.9.2, lambdas are stricter about the arguments they accept. In this case, to get the same behavior I think we probably want either `proc { ... }` or `lambda { |a*| ... }`. Given that the official patch isn't in yet, do you recommend that people upgrade to rspec 2.0 (which appears not to have this problem), fall back to 1.9.1, or stay where they are and manually patch? Right now I've patched my example_group_methods.rb to be `proc` instead of `lambda`, but I always feel a little iffy when directly modifying my dependencies. - John From dchelimsky at gmail.com Sun Jun 13 20:30:09 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 13 Jun 2010 19:30:09 -0500 Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: References: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> <855c386d-b60e-4253-9115-0cae35c243d4@j8g2000yqd.googlegroups.com> Message-ID: <39626F36-BF49-45FE-8D3B-CDBBF81076AF@gmail.com> On Jun 13, 2010, at 5:32 PM, Kristian Mandrup wrote: > shared_examples_for "a template that renders the messages/form > partial" do > it "renders the messages/form partial" do > view.should_receive(:_render_partial). > with(hash_including(:partial => "form")) > render > end > end > > # new.html.erb > > <%= render "sidebar", :recent_messages => @recent_messages %> > <%= render "form", :message => @message %> > > 7) messages/new.html.erb renders the messages/form partial > Failure/Error: Unable to find matching line from backtrace > # received :_render_partial > with unexpected arguments > expected: (hash_including(:partial=>"form")) > got: > ({:partial=>"sidebar", :locals=>{:recent_messages=>[]}}) > > So what to do if I call multiple partials from my view? view.stub(:_render_partial) before view.should_receive(:_render_partial) From dchelimsky at gmail.com Sun Jun 13 23:08:50 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 13 Jun 2010 22:08:50 -0500 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <4C12FC40.90602@yahoo.com.br> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> <4C1272B0.6080701@yahoo.com.br> <4C12FC40.90602@yahoo.com.br> Message-ID: <340C2B8D-0D65-48D5-957C-E44C2EAD7D39@gmail.com> On Jun 11, 2010, at 10:17 PM, Rodrigo Rosenfeld Rosas wrote: > Apparently Webrat is not yet compatible with Rails 3: This is incorrect. It's just that webrat needs to be configured for :rack instead of :rails: Webrat.configure do |config| config.mode = :rack end Since you're porting an app, there is probably some code somewhere that says this instead # DO NOT DO THIS WITH RAILS 3 Webrat.configure do |config| config.mode = :rails end Get rid of that and you should be fine. > > http://github.com/brynary/webrat/blob/master/lib/webrat/integrations/rails.rb > > line 2: require "action_controller/integration" > > action_controller/integration.rb does exist in Rails 2 but not in Rails 3, but I didn't find any branch for Rails 3 in webrat's repository. > > I'll give Capybara another try. I had already tried it before but didn't change to it because I couldn't get the Drag & Drop javascript test to work anyway, but it seems to be a good replacement to Webrat's and there seems to be plans to merge them... > > Does anyone here use Capybara with Rspec2 and Rails 3 without Cucumber to write integration tests successfully? > > Thanks, > > Rodrigo. > > Em 11-06-2010 14:44, David Chelimsky escreveu: >> >> >> Sent from my iPhone >> >> On Jun 11, 2010, at 1:30 PM, Rodrigo Rosenfeld Rosas wrote: >> >>> Now I'm getting: >>> >>> no such file to load -- action_controller/integration >> >> Backtrace, please >>> >>> Am I missing something? >>> >>> Thanks, >>> >>> Rodrigo. >>> >>> P.S.: Sorry if this was sent twice... >>> >>> Em 11-06-2010 01:10, David Chelimsky escreveu: >>>> Change the directory name to requests (a la merb) >>>> >>>> Sent from my iPhone >>>> >>>> On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas >>>> wrote: >>>> >>>>> Hi guys, >>>>> >>>>> I'm trying to port an application to Rails 3 but can't get my >>>>> integration tests to run. >>>>> >>>>> I can't call the Webrat's method (yields 'undefined method `visit`', >>>>> for instance). I don't use Cucumber. >>>>> >>>>> Is there any instructions about how to configure Rspec 2 with Webrat >>>>> on Rails 3? >>>>> >>>>> I also have a custom helper that is not working: >>>>> >>>>> "config.include MyApp::IntegrationHelper, :type => :integration" (the >>>>> methods defined in this module are not available in the specs) >>>>> >>>>> Any ideas? >>>>> >>>>> Thanks, >>>>> >>>>> Rodrigo. > > __________________________________________________ > Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tom at experthuman.com Mon Jun 14 04:28:04 2010 From: tom at experthuman.com (Tom Stuart) Date: Mon, 14 Jun 2010 09:28:04 +0100 Subject: [rspec-users] Method stub return values for message expectations In-Reply-To: <1D2D531E-FB34-4C11-8098-CCA691A63644@gmail.com> References: <4BB9CCBE-6FF6-41E8-80D1-366856566635@experthuman.com> <1D2D531E-FB34-4C11-8098-CCA691A63644@gmail.com> Message-ID: On 13 Jun 2010, at 21:20, David Chelimsky wrote: >> But as of http://github.com/dchelimsky/rspec/commit/386e334 (i.e. in 1.3.0) it no longer works when the stub uses an argument matcher: > Please report to http://rspec.lighthouseapp.com for rspec-1 and http://github.com/rspec/rspec-mocks for rspec-2 Done: https://rspec.lighthouseapp.com/projects/5645/tickets/1009, http://github.com/rspec/rspec-mocks/issues#issue/5. Cheers, -Tom From gditrick at fuse.net Mon Jun 14 11:24:56 2010 From: gditrick at fuse.net (Greg Ditrick) Date: Mon, 14 Jun 2010 11:24:56 -0400 Subject: [rspec-users] I'm having a couple of nuisance things happening with jruby and rspec Message-ID: <22593048.1276529096102.JavaMail.root@wmvirt33> Hi all, I have a couple of things that are happening when using jruby. 1) I consistently getting a 'Command failed' raised when using rake. The Kernel.system() call on line ~ 176 of lib/spec/rake/spectask.rb is always returning false. I'm not sure why. The specs run and work. Does anyone or has anyone have this happen? I run without rake and it works fine. It's as if the Kernel.system() call is returning a negative false condition all the time. jruby issue? 2) jruby on Windows does not produce colors. I tried piping to wac and it parses out the color chars, but everything is still mono. If I add a puts in my spec file with color chars that will be in color but the spec run will be in mono. It is like rspec gem is doing something funky with the terminal/console output stream if it is jruby. Any ideas here? jruby 1.5 Here is my gem list: *** LOCAL GEMS *** actionmailer (2.3.8, 2.3.5) actionpack (2.3.8, 2.3.5) activerecord (2.3.8, 2.3.5) activeresource (2.3.8, 2.3.5) activesupport (2.3.8, 2.3.5) builder (2.1.2) columnize (0.3.1) faker (0.3.1) jruby-openssl (0.7) machinist (1.0.6) rack (1.1.0, 1.0.1) rails (2.3.8, 2.3.5) rake (0.8.7) rspec (1.3.0) ruby-debug (0.10.3) ruby-debug-base (0.10.3.2) sequel (3.12.1, 3.11.0) sources (0.0.1) I have to use jruby and windows for these tests. The Rails ENV is used just for convenience of loading gems. This is not a web app. I'm using rspec to unit test DB stored procedures. Thanks in advanced for nay insight to why I'm getting these, GregD From hooligan495 at gmail.com Mon Jun 14 11:59:11 2010 From: hooligan495 at gmail.com (Jay McGaffigan) Date: Mon, 14 Jun 2010 11:59:11 -0400 Subject: [rspec-users] I'm having a couple of nuisance things happening with jruby and rspec In-Reply-To: <22593048.1276529096102.JavaMail.root@wmvirt33> References: <22593048.1276529096102.JavaMail.root@wmvirt33> Message-ID: hmm.. for issue 1) I've found that rake doesn't always give an informative message I've gotten better messages when I run the spec command directly: if you run rake spec you might see something like this after your tests run Command /Users/home/Projects/jruby/jruby-1.5.0/bin/jruby -I"spec:lib" "/Users/home/Projects/rcov/rspec/bin/spec" if you copy and paste everything from JRuby on (e.g. /Users/home/Projects/jruby/jruby-1.5.0/bin/jruby -I"spec:lib" "/Users/home/Projects/rcov/rspec/bin/spec" ) and run that... you might get a better message. On Mon, Jun 14, 2010 at 11:24 AM, Greg Ditrick wrote: > Hi all, > > I have a couple of things that are happening when using jruby. > > 1) I consistently getting a 'Command failed' raised when using rake. ?The Kernel.system() call on line ~ 176 of lib/spec/rake/spectask.rb is always returning false. ?I'm not sure why. The specs run and work. ?Does anyone or has anyone have this happen? ?I run without rake and it works fine. ?It's as if the Kernel.system() call is returning a negative false condition all the time. ?jruby issue? > > 2) jruby on Windows does not produce colors. ?I tried piping to wac and it parses out the color chars, but everything is still mono. ?If I add a puts in my spec file with color chars that will be in color but the spec run will be in mono. ?It is like rspec gem is doing something funky with the terminal/console output stream if it is jruby. ?Any ideas here? > > jruby 1.5 > > Here is my gem list: > > *** LOCAL GEMS *** > > actionmailer (2.3.8, 2.3.5) > actionpack (2.3.8, 2.3.5) > activerecord (2.3.8, 2.3.5) > activeresource (2.3.8, 2.3.5) > activesupport (2.3.8, 2.3.5) > builder (2.1.2) > columnize (0.3.1) > faker (0.3.1) > jruby-openssl (0.7) > machinist (1.0.6) > rack (1.1.0, 1.0.1) > rails (2.3.8, 2.3.5) > rake (0.8.7) > rspec (1.3.0) > ruby-debug (0.10.3) > ruby-debug-base (0.10.3.2) > sequel (3.12.1, 3.11.0) > sources (0.0.1) > > > I have to use jruby and windows for these tests. ?The Rails ENV is used just for convenience of loading gems. ?This is not a web app. ?I'm using rspec to unit test DB stored procedures. > > Thanks in advanced for nay insight to why I'm getting these, > > > GregD > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From gditrick at fuse.net Mon Jun 14 12:55:01 2010 From: gditrick at fuse.net (Greg Ditrick) Date: Mon, 14 Jun 2010 12:55:01 -0400 Subject: [rspec-users] I'm having a couple of nuisance things happening with jruby and rspec Message-ID: <10511913.1276534501389.JavaMail.root@wmvirt99> Jay, Yes, I have done this and yes I don't get any error messages. But the command ran from rake fails and rake aborts. It is like the rake task in rspec using Kernal.system is returning with a negative false here in the code: line 176 in lib/spec/rake/spectask.rb unless system(cmd) STDERR.puts failure_message if failure_message raise("Command #{cmd} failed") if fail_on_error end the cmd does not fail, but returns false. failure_message is nil obviously. Is this a jruby issue? a jruby on windows issue? Hard to figure out why it returns false when the command works. GregD ---- Jay McGaffigan wrote: > hmm.. > > for issue 1) > I've found that rake doesn't always give an informative message > > I've gotten better messages when I run the spec command directly: > > if you run rake spec you might see something like this after your tests run > Command /Users/home/Projects/jruby/jruby-1.5.0/bin/jruby -I"spec:lib" > "/Users/home/Projects/rcov/rspec/bin/spec" > > > if you copy and paste everything from JRuby on (e.g. > /Users/home/Projects/jruby/jruby-1.5.0/bin/jruby -I"spec:lib" > "/Users/home/Projects/rcov/rspec/bin/spec" ) > > and run that... you might get a better message. > > > On Mon, Jun 14, 2010 at 11:24 AM, Greg Ditrick wrote: > > Hi all, > > > > I have a couple of things that are happening when using jruby. > > > > 1) I consistently getting a 'Command failed' raised when using rake. ?The Kernel.system() call on line ~ 176 of lib/spec/rake/spectask.rb is always returning false. ?I'm not sure why. The specs run and work. ?Does anyone or has anyone have this happen? ?I run without rake and it works fine. ?It's as if the Kernel.system() call is returning a negative false condition all the time. ?jruby issue? > > > > 2) jruby on Windows does not produce colors. ?I tried piping to wac and it parses out the color chars, but everything is still mono. ?If I add a puts in my spec file with color chars that will be in color but the spec run will be in mono. ?It is like rspec gem is doing something funky with the terminal/console output stream if it is jruby. ?Any ideas here? > > > > jruby 1.5 > > > > Here is my gem list: > > > > *** LOCAL GEMS *** > > > > actionmailer (2.3.8, 2.3.5) > > actionpack (2.3.8, 2.3.5) > > activerecord (2.3.8, 2.3.5) > > activeresource (2.3.8, 2.3.5) > > activesupport (2.3.8, 2.3.5) > > builder (2.1.2) > > columnize (0.3.1) > > faker (0.3.1) > > jruby-openssl (0.7) > > machinist (1.0.6) > > rack (1.1.0, 1.0.1) > > rails (2.3.8, 2.3.5) > > rake (0.8.7) > > rspec (1.3.0) > > ruby-debug (0.10.3) > > ruby-debug-base (0.10.3.2) > > sequel (3.12.1, 3.11.0) > > sources (0.0.1) > > > > > > I have to use jruby and windows for these tests. ?The Rails ENV is used just for convenience of loading gems. ?This is not a web app. ?I'm using rspec to unit test DB stored procedures. > > > > Thanks in advanced for nay insight to why I'm getting these, > > > > > > GregD > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From celoserpa at gmail.com Mon Jun 14 15:05:57 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Mon, 14 Jun 2010 14:05:57 -0500 Subject: [rspec-users] Undefined method respont_to - rspec Message-ID: Hello list, I have this very simple model spec: require 'spec_helper' describe Token do describe "Associations" do token = Token.new token.should respond_to(:user) end end When I run it, I get the following error: /spec/models/token_spec.rb:7: undefined method `respond_to' for Spec::Rails::Example::ModelExampleGroup::Subclass_1::Subclass_1:Class (NoMethodError) Should not respont_to? be defined and rspec automatically add the ? to the method? I am not getting it :S Thanks in advance, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From trey at 12spokes.com Mon Jun 14 16:04:49 2010 From: trey at 12spokes.com (Trey Bean) Date: Mon, 14 Jun 2010 14:04:49 -0600 Subject: [rspec-users] Undefined method respont_to - rspec In-Reply-To: References: Message-ID: <4858921829323641270@unknownmsgid> It looks like you need to put those lines in an it block. it 'should...' do token... end Trey On Jun 14, 2010, at 1:05 PM, Marcelo de Moraes Serpa wrote: > Hello list, > > I have this very simple model spec: > > require 'spec_helper' > > describe Token do > describe "Associations" do > token = Token.new > token.should respond_to(:user) > end > end > > When I run it, I get the following error: > > /spec/models/token_spec.rb:7: undefined method `respond_to' for Spec::Rails::Example::ModelExampleGroup::Subclass_1::Subclass_1:Class (NoMethodError) > > Should not respont_to? be defined and rspec automatically add the ? to the method? I am not getting it :S > > Thanks in advance, > > Marcelo. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From celoserpa at gmail.com Mon Jun 14 16:38:22 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Mon, 14 Jun 2010 15:38:22 -0500 Subject: [rspec-users] Undefined method respont_to - rspec In-Reply-To: <4858921829323641270@unknownmsgid> References: <4858921829323641270@unknownmsgid> Message-ID: Ah! I thought I could use it / describe / context interchangeably. Thanks, Marcelo. On Mon, Jun 14, 2010 at 3:04 PM, Trey Bean wrote: > It looks like you need to put those lines in an it block. > > it 'should...' do > token... > end > > Trey > > On Jun 14, 2010, at 1:05 PM, Marcelo de Moraes Serpa > wrote: > > > Hello list, > > > > I have this very simple model spec: > > > > require 'spec_helper' > > > > describe Token do > > describe "Associations" do > > token = Token.new > > token.should respond_to(:user) > > end > > end > > > > When I run it, I get the following error: > > > > /spec/models/token_spec.rb:7: undefined method `respond_to' for > Spec::Rails::Example::ModelExampleGroup::Subclass_1::Subclass_1:Class > (NoMethodError) > > > > Should not respont_to? be defined and rspec automatically add the ? to > the method? I am not getting it :S > > > > Thanks in advance, > > > > Marcelo. > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jun 14 17:05:49 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 14 Jun 2010 16:05:49 -0500 Subject: [rspec-users] Undefined method respont_to - rspec In-Reply-To: References: <4858921829323641270@unknownmsgid> Message-ID: <57DDCC85-0B84-456F-BB4B-6C272F2D8860@gmail.com> The primary concepts are example groups and examples. An example group is a group of examples. More technically, an example group is a class, and examples are instances of that class. * example_group, context, and describe all mean the same thing. * example, specify, and it all mean the same thing HTH, David On Jun 14, 2010, at 3:38 PM, Marcelo de Moraes Serpa wrote: > Ah! I thought I could use it / describe / context interchangeably. > > Thanks, > > Marcelo. > > On Mon, Jun 14, 2010 at 3:04 PM, Trey Bean wrote: > It looks like you need to put those lines in an it block. > > it 'should...' do > token... > end > > Trey > > On Jun 14, 2010, at 1:05 PM, Marcelo de Moraes Serpa > wrote: > > > Hello list, > > > > I have this very simple model spec: > > > > require 'spec_helper' > > > > describe Token do > > describe "Associations" do > > token = Token.new > > token.should respond_to(:user) > > end > > end > > > > When I run it, I get the following error: > > > > /spec/models/token_spec.rb:7: undefined method `respond_to' for Spec::Rails::Example::ModelExampleGroup::Subclass_1::Subclass_1:Class (NoMethodError) > > > > Should not respont_to? be defined and rspec automatically add the ? to the method? I am not getting it :S > > > > Thanks in advance, > > > > Marcelo. > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Mon Jun 14 19:38:55 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Mon, 14 Jun 2010 18:38:55 -0500 Subject: [rspec-users] Undefined method respont_to - rspec In-Reply-To: <57DDCC85-0B84-456F-BB4B-6C272F2D8860@gmail.com> References: <4858921829323641270@unknownmsgid> <57DDCC85-0B84-456F-BB4B-6C272F2D8860@gmail.com> Message-ID: Thanks David and Trey ;) Marcelo. On Mon, Jun 14, 2010 at 4:05 PM, David Chelimsky wrote: > The primary concepts are example groups and examples. An example group is a > group of examples. More technically, an example group is a class, and > examples are instances of that class. > > * example_group, context, and describe all mean the same thing. > > * example, specify, and it all mean the same thing > > HTH, > David > > On Jun 14, 2010, at 3:38 PM, Marcelo de Moraes Serpa wrote: > > Ah! I thought I could use it / describe / context interchangeably. > > Thanks, > > Marcelo. > > On Mon, Jun 14, 2010 at 3:04 PM, Trey Bean wrote: > >> It looks like you need to put those lines in an it block. >> >> it 'should...' do >> token... >> end >> >> Trey >> >> On Jun 14, 2010, at 1:05 PM, Marcelo de Moraes Serpa >> wrote: >> >> > Hello list, >> > >> > I have this very simple model spec: >> > >> > require 'spec_helper' >> > >> > describe Token do >> > describe "Associations" do >> > token = Token.new >> > token.should respond_to(:user) >> > end >> > end >> > >> > When I run it, I get the following error: >> > >> > /spec/models/token_spec.rb:7: undefined method `respond_to' for >> Spec::Rails::Example::ModelExampleGroup::Subclass_1::Subclass_1:Class >> (NoMethodError) >> > >> > Should not respont_to? be defined and rspec automatically add the ? to >> the method? I am not getting it :S >> > >> > Thanks in advance, >> > >> > Marcelo. >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Mon Jun 14 19:40:25 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Mon, 14 Jun 2010 18:40:25 -0500 Subject: [rspec-users] Testing render :update Message-ID: Hey guys. I would like to test the following behavior: render :update do |page| page.replace_html 'errors', :partial => 'signup_errors', :locals => { :errors => 'errors'} end } I'm doing: controller.should_receive(:render).with(:update) But I am not sure on how to test the block. Maybe checking out what is the class of the page var and setting up an expection on it? Any suggestions appreciated, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jun 14 20:05:47 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 14 Jun 2010 19:05:47 -0500 Subject: [rspec-users] Testing render :update In-Reply-To: References: Message-ID: <1EF979D1-2464-43BA-8E39-2CC56E512A0D@gmail.com> On Jun 14, 2010, at 6:40 PM, Marcelo de Moraes Serpa wrote: > Hey guys. > > I would like to test the following behavior: > > render :update do |page| > page.replace_html 'errors', :partial => 'signup_errors', :locals => { :errors => 'errors'} > end > } > > I'm doing: > > controller.should_receive(:render).with(:update) > > But I am not sure on how to test the block. Maybe checking out what is the class of the page var and setting up an expection on it? Hmmm. The common idiom for this is: page = double('page') controller.stub(:render).with(:update).and_yield(page) page.should_receive(:replace_html).with(...) This does not seem to work with rspec-2/rails-3. Don't know why yet (won't be able to look for a bit), but my guess is that something (like rspec :) ) is adding render() to the controller even later than this stub does. I'll follow up if I learn something. HTH, David From phillipkoebbe at gmail.com Mon Jun 14 20:09:45 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Mon, 14 Jun 2010 19:09:45 -0500 Subject: [rspec-users] Testing render :update In-Reply-To: References: Message-ID: <4C16C4C9.6000101@gmail.com> On 2010-06-14 6:40 PM, Marcelo de Moraes Serpa wrote: > Hey guys. > > I would like to test the following behavior: > > render :update do |page| > page.replace_html 'errors', :partial => 'signup_errors', > :locals => { :errors => 'errors'} > end > } > > I'm doing: > > controller.should_receive(:render).with(:update) > > But I am not sure on how to test the block. Maybe checking out what is > the class of the page var and setting up an expection on it? > > Any suggestions appreciated, > > Marcelo. I don't know if this is the "right" way to do it, but if I'm going to test this code: render :update do |page| page.replace :flash_messages, :partial => '_partials/web/layouts/flash_messages' end I use this: it 'should render update' do page = mock('page') page.should_receive(:replace).with(:flash_messages, :partial => '_partials/web/layouts/flash_messages') controller.should_receive(:render).with(:update).and_yield(page) xhr :post, :create, end Peace, Phillip From dchelimsky at gmail.com Mon Jun 14 22:35:14 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 14 Jun 2010 21:35:14 -0500 Subject: [rspec-users] Testing render :update In-Reply-To: <1EF979D1-2464-43BA-8E39-2CC56E512A0D@gmail.com> References: <1EF979D1-2464-43BA-8E39-2CC56E512A0D@gmail.com> Message-ID: <85837618-776B-439A-8E19-9F64D37A3E25@gmail.com> On Jun 14, 2010, at 7:05 PM, David Chelimsky wrote: > On Jun 14, 2010, at 6:40 PM, Marcelo de Moraes Serpa wrote: > >> Hey guys. >> >> I would like to test the following behavior: >> >> render :update do |page| >> page.replace_html 'errors', :partial => 'signup_errors', :locals => { :errors => 'errors'} >> end >> } >> >> I'm doing: >> >> controller.should_receive(:render).with(:update) >> >> But I am not sure on how to test the block. Maybe checking out what is the class of the page var and setting up an expection on it? > > Hmmm. The common idiom for this is: > > page = double('page') > controller.stub(:render).with(:update).and_yield(page) > page.should_receive(:replace_html).with(...) > > This does not seem to work with rspec-2/rails-3. Don't know why yet (won't be able to look for a bit), but my guess is that something (like rspec :) ) is adding render() to the controller even later than this stub does. I'll follow up if I learn something. Looks like action_pack calls render twice (the 2nd time in action_controller/metal/implicit_render.rb:10:in `default_render'), so we've got to stub the :render call twice: page = double('page') controller.stub(:render) controller.stub(:render).with(:update).and_yield(page) page.should_receive(:replace_html).with(...) Bummer. It seems like this is a rails bug (render should only get called once, and there is code that prevents it from being called twice, but not _all_ of the time), but I'm not sure if I can make that case or not. I'll try :) Cheers, David From kmandrup at gmail.com Tue Jun 15 01:17:07 2010 From: kmandrup at gmail.com (Kristian Mandrup) Date: Mon, 14 Jun 2010 22:17:07 -0700 (PDT) Subject: [rspec-users] undefined local variable or method `assigns' In-Reply-To: <39626F36-BF49-45FE-8D3B-CDBBF81076AF@gmail.com> References: <49E2AFCE-A564-49A0-BAFA-64381578A690@gmail.com> <855c386d-b60e-4253-9115-0cae35c243d4@j8g2000yqd.googlegroups.com> <39626F36-BF49-45FE-8D3B-CDBBF81076AF@gmail.com> Message-ID: <2e70d52e-b59c-4082-a37d-062301740e86@5g2000yqz.googlegroups.com> Thanks again David :) Pure magic to me, I don't really understand how/ why that makes it work. But it does! On Jun 14, 2:30?am, David Chelimsky wrote: > On Jun 13, 2010, at 5:32 PM, Kristian Mandrup ? > wrote: > > > > > shared_examples_for "a template that renders the messages/form > > partial" do > > ?it "renders the messages/form partial" do > > ? ?view.should_receive(:_render_partial). > > ? ? ?with(hash_including(:partial => "form")) > > ? ?render > > ?end > > end > > > # new.html.erb > > > <%= render "sidebar", :recent_messages => @recent_messages %> > > <%= render "form", :message => @message %> > > > 7) messages/new.html.erb renders the messages/form partial > > ? ?Failure/Error: Unable to find matching line from backtrace > > ? ?# received :_render_partial > > with unexpected arguments > > ? ? ?expected: (hash_including(:partial=>"form")) > > ? ? ? ? ? got: > > ({:partial=>"sidebar", :locals=>{:recent_messages=>[]}}) > > > So what to do if I call multiple partials from my view? > > view.stub(:_render_partial) before view.should_receive(:_render_partial) > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Jun 15 02:57:39 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 15 Jun 2010 01:57:39 -0500 Subject: [rspec-users] blog post on filtering examples in rspec-2 Message-ID: <84E291D3-C18A-4C95-8BF4-CA5D5E9369D9@gmail.com> Hey all, Here's a post on filtering examples in rspec-2: http://blog.davidchelimsky.net/2010/06/14/filtering-examples-in-rspec-2/ Cheers, David From dchelimsky at gmail.com Tue Jun 15 02:58:44 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 15 Jun 2010 01:58:44 -0500 Subject: [rspec-users] request for feedback Message-ID: <402433CE-B9C4-4645-9432-E47BE557D8B2@gmail.com> Hey all, If you're interested in seeing rspec-2 get an API like cucumber tags, please comment on http://github.com/rspec/rspec-core/issues#issue/37. Cheers, David From celoserpa at gmail.com Tue Jun 15 18:15:54 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Tue, 15 Jun 2010 17:15:54 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures Message-ID: Hey all, I have replaced Cucumber with Steak and I like the experience so far. It is not as polished as Cucumber in what comes to configuration, but it is simpler and covers my needs perfectly. I've followed the trick to pass a hash to the example in order to setup Capybara to use a different driver, like so: spec/acceptance/support/javascript.rb Spec::Runner.configure do |config| config.before(:each) do if options[:js] #using culerity Capybara.current_driver = :culerity config.use_transactional_fixtures = false end end config.after(:each) do if options[:js] DatabaseCleaner.clean Capybara.use_default_driver config.use_transactional_fixtures = true end end end As you can see, if an example has an option with :js => true, it will use culerity, and this works fine. What doesn't seem to work is the use_transactional_fixtures = false conf. I still can't access the data outside of the ruby instance (i.e: the app server celerity is accessing doesn't have access to the fixture data). With Cucumber it would be a matter of setting up *Cucumber*::Rails::*World*.use_transactional_fixtures to false. How could I disable transactional fixtures on a per example base when using rspec / steak? Thanks, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Tue Jun 15 18:27:14 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Tue, 15 Jun 2010 17:27:14 -0500 Subject: [rspec-users] Testing render :update In-Reply-To: <85837618-776B-439A-8E19-9F64D37A3E25@gmail.com> References: <1EF979D1-2464-43BA-8E39-2CC56E512A0D@gmail.com> <85837618-776B-439A-8E19-9F64D37A3E25@gmail.com> Message-ID: Thanks for the heads out, David :) On Mon, Jun 14, 2010 at 9:35 PM, David Chelimsky wrote: > > On Jun 14, 2010, at 7:05 PM, David Chelimsky wrote: > > > On Jun 14, 2010, at 6:40 PM, Marcelo de Moraes Serpa wrote: > > > >> Hey guys. > >> > >> I would like to test the following behavior: > >> > >> render :update do |page| > >> page.replace_html 'errors', :partial => 'signup_errors', > :locals => { :errors => 'errors'} > >> end > >> } > >> > >> I'm doing: > >> > >> controller.should_receive(:render).with(:update) > >> > >> But I am not sure on how to test the block. Maybe checking out what is > the class of the page var and setting up an expection on it? > > > > Hmmm. The common idiom for this is: > > > > page = double('page') > > controller.stub(:render).with(:update).and_yield(page) > > page.should_receive(:replace_html).with(...) > > > > This does not seem to work with rspec-2/rails-3. Don't know why yet > (won't be able to look for a bit), but my guess is that something (like > rspec :) ) is adding render() to the controller even later than this stub > does. I'll follow up if I learn something. > > Looks like action_pack calls render twice (the 2nd time in > action_controller/metal/implicit_render.rb:10:in `default_render'), so we've > got to stub the :render call twice: > > page = double('page') > controller.stub(:render) > controller.stub(:render).with(:update).and_yield(page) > page.should_receive(:replace_html).with(...) > > Bummer. It seems like this is a rails bug (render should only get called > once, and there is code that prevents it from being called twice, but not > _all_ of the time), but I'm not sure if I can make that case or not. I'll > try :) > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jun 15 18:32:34 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 15 Jun 2010 17:32:34 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures In-Reply-To: References: Message-ID: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote: > Hey all, > > I have replaced Cucumber with Steak and I like the experience so far. It is not as polished as Cucumber in what comes to configuration, but it is simpler and covers my needs perfectly. I've followed the trick to pass a hash to the example in order to setup Capybara to use a different driver, like so: > > spec/acceptance/support/javascript.rb > > Spec::Runner.configure do |config| > > config.before(:each) do > if options[:js] #using culerity > Capybara.current_driver = :culerity > config.use_transactional_fixtures = false > end > end > > config.after(:each) do > if options[:js] > DatabaseCleaner.clean > Capybara.use_default_driver > config.use_transactional_fixtures = true > end > end > > end > > As you can see, if an example has an option with :js => true, it will use culerity, and this works fine. What doesn't seem to work is the use_transactional_fixtures = false conf. I still can't access the data outside of the ruby instance (i.e: the app server celerity is accessing doesn't have access to the fixture data). With Cucumber it would be a matter of setting up Cucumber::Rails::World.use_transactional_fixtures to false. > > How could I disable transactional fixtures on a per example base when using rspec / steak? As far as I know, this is not easy, or maybe even possible, with the Rails built-in framework. What I'd do is turn off the rails features (config.use_transactional_fixtures = false) and use database_cleaner. Are you familiar w/ database_cleaner? David From dchelimsky at gmail.com Tue Jun 15 18:34:11 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 15 Jun 2010 17:34:11 -0500 Subject: [rspec-users] Testing render :update In-Reply-To: References: <1EF979D1-2464-43BA-8E39-2CC56E512A0D@gmail.com> <85837618-776B-439A-8E19-9F64D37A3E25@gmail.com> Message-ID: Por nada! ps - em ingl?s, a frase ? "heads up" :) On Jun 15, 2010, at 5:27 PM, Marcelo de Moraes Serpa wrote: > Thanks for the heads out, David :) > > On Mon, Jun 14, 2010 at 9:35 PM, David Chelimsky wrote: > > On Jun 14, 2010, at 7:05 PM, David Chelimsky wrote: > > > On Jun 14, 2010, at 6:40 PM, Marcelo de Moraes Serpa wrote: > > > >> Hey guys. > >> > >> I would like to test the following behavior: > >> > >> render :update do |page| > >> page.replace_html 'errors', :partial => 'signup_errors', :locals => { :errors => 'errors'} > >> end > >> } > >> > >> I'm doing: > >> > >> controller.should_receive(:render).with(:update) > >> > >> But I am not sure on how to test the block. Maybe checking out what is the class of the page var and setting up an expection on it? > > > > Hmmm. The common idiom for this is: > > > > page = double('page') > > controller.stub(:render).with(:update).and_yield(page) > > page.should_receive(:replace_html).with(...) > > > > This does not seem to work with rspec-2/rails-3. Don't know why yet (won't be able to look for a bit), but my guess is that something (like rspec :) ) is adding render() to the controller even later than this stub does. I'll follow up if I learn something. > > Looks like action_pack calls render twice (the 2nd time in action_controller/metal/implicit_render.rb:10:in `default_render'), so we've got to stub the :render call twice: > > page = double('page') > controller.stub(:render) > controller.stub(:render).with(:update).and_yield(page) > page.should_receive(:replace_html).with(...) > > Bummer. It seems like this is a rails bug (render should only get called once, and there is code that prevents it from being called twice, but not _all_ of the time), but I'm not sure if I can make that case or not. I'll try :) > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Tue Jun 15 19:09:40 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Tue, 15 Jun 2010 18:09:40 -0500 Subject: [rspec-users] Testing render :update In-Reply-To: References: <1EF979D1-2464-43BA-8E39-2CC56E512A0D@gmail.com> <85837618-776B-439A-8E19-9F64D37A3E25@gmail.com> Message-ID: Ah! Thanks for the heads up about heads out ;) Obrigado, Marcelo. On Tue, Jun 15, 2010 at 5:34 PM, David Chelimsky wrote: > Por nada! > > ps - em ingl?s, a frase ? "heads up" :) > > On Jun 15, 2010, at 5:27 PM, Marcelo de Moraes Serpa wrote: > > Thanks for the heads out, David :) > > On Mon, Jun 14, 2010 at 9:35 PM, David Chelimsky wrote: > >> >> On Jun 14, 2010, at 7:05 PM, David Chelimsky wrote: >> >> > On Jun 14, 2010, at 6:40 PM, Marcelo de Moraes Serpa wrote: >> > >> >> Hey guys. >> >> >> >> I would like to test the following behavior: >> >> >> >> render :update do |page| >> >> page.replace_html 'errors', :partial => 'signup_errors', >> :locals => { :errors => 'errors'} >> >> end >> >> } >> >> >> >> I'm doing: >> >> >> >> controller.should_receive(:render).with(:update) >> >> >> >> But I am not sure on how to test the block. Maybe checking out what is >> the class of the page var and setting up an expection on it? >> > >> > Hmmm. The common idiom for this is: >> > >> > page = double('page') >> > controller.stub(:render).with(:update).and_yield(page) >> > page.should_receive(:replace_html).with(...) >> > >> > This does not seem to work with rspec-2/rails-3. Don't know why yet >> (won't be able to look for a bit), but my guess is that something (like >> rspec :) ) is adding render() to the controller even later than this stub >> does. I'll follow up if I learn something. >> >> Looks like action_pack calls render twice (the 2nd time in >> action_controller/metal/implicit_render.rb:10:in `default_render'), so we've >> got to stub the :render call twice: >> >> page = double('page') >> controller.stub(:render) >> controller.stub(:render).with(:update).and_yield(page) >> page.should_receive(:replace_html).with(...) >> >> Bummer. It seems like this is a rails bug (render should only get called >> once, and there is code that prevents it from being called twice, but not >> _all_ of the time), but I'm not sure if I can make that case or not. I'll >> try :) >> >> Cheers, >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarmo.p at gmail.com Wed Jun 16 10:11:56 2010 From: jarmo.p at gmail.com (Jarmo Pertman) Date: Wed, 16 Jun 2010 07:11:56 -0700 (PDT) Subject: [rspec-users] accessing constants from another module within examples Message-ID: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> Hello. I wanted to include module into ExampleGroup to write less code within examples, but was unable to do so. This seems to be strange, because in regular Class it works and all methods within that module are also accessible. See the example: module MyModule MyConstant = 1 def my_method 2 end end describe "including modules" do include MyModule it "works" do my_method.should == 2 MyModule::MyConstant.should == 1 end it "doesn't work" do MyConstant.should == 1 end end Running this simple spec will produce one failure with this message: 1) NameError in 'including modules doesn't work' uninitialized constant MyConstant Is this an expected behaviour? Is there some other way to access constants from another module without specifying module name within examples? Best Regards, Jarmo From matt at mattwynne.net Wed Jun 16 10:20:22 2010 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 16 Jun 2010 15:20:22 +0100 Subject: [rspec-users] accessing constants from another module within examples In-Reply-To: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> References: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> Message-ID: <0E3D1133-E664-47D5-AEE3-1795C334EB78@mattwynne.net> On 16 Jun 2010, at 15:11, Jarmo Pertman wrote: > Hello. > > I wanted to include module into ExampleGroup to write less code within > examples, but was unable to do so. This seems to be strange, because > in regular Class it works and all methods within that module are also > accessible. See the example: > > module MyModule > MyConstant = 1 > > def my_method > 2 > end > end > > describe "including modules" do > include MyModule > > it "works" do > my_method.should == 2 > MyModule::MyConstant.should == 1 > end > > it "doesn't work" do > MyConstant.should == 1 > end > end > > Running this simple spec will produce one failure with this message: > 1) > NameError in 'including modules doesn't work' > uninitialized constant MyConstant > > Is this an expected behaviour? Is there some other way to access > constants from another module without specifying module name within > examples? That wouldn't work in regular ruby either. You need to run the describe block inside the module / namespace. > > Best Regards, > Jarmo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Jun 16 10:22:15 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 16 Jun 2010 09:22:15 -0500 Subject: [rspec-users] accessing constants from another module within examples In-Reply-To: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> References: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> Message-ID: <50663BC4-D7A7-4F16-8234-58BEAC87E43A@gmail.com> On Jun 16, 2010, at 9:11 AM, Jarmo Pertman wrote: > Hello. > > I wanted to include module into ExampleGroup to write less code within > examples, but was unable to do so. This seems to be strange, because > in regular Class it works and all methods within that module are also > accessible. See the example: > > module MyModule > MyConstant = 1 > > def my_method > 2 > end > end > > describe "including modules" do > include MyModule > > it "works" do > my_method.should == 2 > MyModule::MyConstant.should == 1 > end > > it "doesn't work" do > MyConstant.should == 1 > end > end > > Running this simple spec will produce one failure with this message: > 1) > NameError in 'including modules doesn't work' > uninitialized constant MyConstant > > Is this an expected behaviour? Is there some other way to access > constants from another module without specifying module name within > examples? Seems like a bug. Please submit it to http://github.com/rspec/rspec-core/issues for rspec-2, http://rspec.lighthouseapp.com to make sure it gets backported to rspec-1. Thx, David From jarmo.p at gmail.com Wed Jun 16 10:36:27 2010 From: jarmo.p at gmail.com (Jarmo Pertman) Date: Wed, 16 Jun 2010 07:36:27 -0700 (PDT) Subject: [rspec-users] accessing constants from another module within examples In-Reply-To: <0E3D1133-E664-47D5-AEE3-1795C334EB78@mattwynne.net> References: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> <0E3D1133-E664-47D5-AEE3-1795C334EB78@mattwynne.net> Message-ID: <0171a85b-522c-480d-af3d-d5aaf7dc7b85@x21g2000yqa.googlegroups.com> Why do you think that it's not working in regular Ruby either? Check the following example to see that it does: module MyModule MyConstant = 1 def my_method 2 end end class MyClass include MyModule def initialize p my_method p MyModule::MyConstant p MyConstant end end MyClass.new Jarmo On Jun 16, 5:20?pm, Matt Wynne wrote: > That wouldn't work in regular ruby either. You need to run the describe block inside the module / namespace. From matt at mattwynne.net Wed Jun 16 10:50:49 2010 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 16 Jun 2010 15:50:49 +0100 Subject: [rspec-users] accessing constants from another module within examples In-Reply-To: <0E3D1133-E664-47D5-AEE3-1795C334EB78@mattwynne.net> References: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> <0E3D1133-E664-47D5-AEE3-1795C334EB78@mattwynne.net> Message-ID: <807C1516-0733-4C87-89DF-D17D608D5469@mattwynne.net> On 16 Jun 2010, at 15:20, Matt Wynne wrote: > > On 16 Jun 2010, at 15:11, Jarmo Pertman wrote: > >> Hello. >> >> I wanted to include module into ExampleGroup to write less code within >> examples, but was unable to do so. This seems to be strange, because >> in regular Class it works and all methods within that module are also >> accessible. See the example: >> >> module MyModule >> MyConstant = 1 >> >> def my_method >> 2 >> end >> end >> >> describe "including modules" do >> include MyModule >> >> it "works" do >> my_method.should == 2 >> MyModule::MyConstant.should == 1 >> end >> >> it "doesn't work" do >> MyConstant.should == 1 >> end >> end >> >> Running this simple spec will produce one failure with this message: >> 1) >> NameError in 'including modules doesn't work' >> uninitialized constant MyConstant >> >> Is this an expected behaviour? Is there some other way to access >> constants from another module without specifying module name within >> examples? > > That wouldn't work in regular ruby either. You need to run the describe block inside the module / namespace. I stand corrected. It absolutely does work. Sorry for the duff information. > >> >> Best Regards, >> Jarmo >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jarmo.p at gmail.com Wed Jun 16 10:46:03 2010 From: jarmo.p at gmail.com (Jarmo Pertman) Date: Wed, 16 Jun 2010 07:46:03 -0700 (PDT) Subject: [rspec-users] accessing constants from another module within examples In-Reply-To: <50663BC4-D7A7-4F16-8234-58BEAC87E43A@gmail.com> References: <1994470d-04e1-4521-a343-54464b8dd076@s9g2000yqd.googlegroups.com> <50663BC4-D7A7-4F16-8234-58BEAC87E43A@gmail.com> Message-ID: <1b7b821d-d16a-4c2e-a2d6-ccbe5c20d193@z8g2000yqz.googlegroups.com> Done! Jarmo On Jun 16, 5:22?pm, David Chelimsky wrote: > Seems like a bug. Please submit it tohttp://github.com/rspec/rspec-core/issuesfor rspec-2,http://rspec.lighthouseapp.comto make sure it gets backported to rspec-1. > > Thx, > David From celoserpa at gmail.com Wed Jun 16 14:37:51 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Wed, 16 Jun 2010 13:37:51 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures In-Reply-To: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> References: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> Message-ID: Hi David, Yeah, I'm using DatabaseCleaner, pretty much familiar with it. The issue is that passing it to rspec's yielded config object didn't seem to disable transactional_fixtures: Spec::Runner.configure do |config| > > config.before(:each) do > if options[:js] #using culerity > Capybara.current_driver = :culerity > config.use_transactional_ > fixtures = false > end > end > > config.after(:each) do > if options[:js] > DatabaseCleaner.clean > Capybara.use_default_driver > config.use_transactional_fixtures = true > end > end > > end > Check the lines "config.use_transactional_fixtures" on both callbacks. I doesn't seem to disable them. Any ideas? Marcelo. On Tue, Jun 15, 2010 at 5:32 PM, David Chelimsky wrote: > On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote: > > > Hey all, > > > > I have replaced Cucumber with Steak and I like the experience so far. It > is not as polished as Cucumber in what comes to configuration, but it is > simpler and covers my needs perfectly. I've followed the trick to pass a > hash to the example in order to setup Capybara to use a different driver, > like so: > > > > spec/acceptance/support/javascript.rb > > > > Spec::Runner.configure do |config| > > > > config.before(:each) do > > if options[:js] #using culerity > > Capybara.current_driver = :culerity > > config.use_transactional_fixtures = false > > end > > end > > > > config.after(:each) do > > if options[:js] > > DatabaseCleaner.clean > > Capybara.use_default_driver > > config.use_transactional_fixtures = true > > end > > end > > > > end > > > > As you can see, if an example has an option with :js => true, it will use > culerity, and this works fine. What doesn't seem to work is the > use_transactional_fixtures = false conf. I still can't access the data > outside of the ruby instance (i.e: the app server celerity is accessing > doesn't have access to the fixture data). With Cucumber it would be a matter > of setting up Cucumber::Rails::World.use_transactional_fixtures to false. > > > > How could I disable transactional fixtures on a per example base when > using rspec / steak? > > As far as I know, this is not easy, or maybe even possible, with the Rails > built-in framework. What I'd do is turn off the rails features > (config.use_transactional_fixtures = false) and use database_cleaner. Are > you familiar w/ database_cleaner? > > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 16 14:47:43 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 16 Jun 2010 13:47:43 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures In-Reply-To: References: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> Message-ID: On Jun 16, 2010, at 1:37 PM, Marcelo de Moraes Serpa wrote: > Hi David, > > Yeah, I'm using DatabaseCleaner, pretty much familiar with it. > > The issue is that passing it to rspec's yielded config object didn't seem to disable transactional_fixtures: > > Spec::Runner.configure do |config| > > config.before(:each) do > if options[:js] #using culerity > Capybara.current_driver = :culerity > config.use_transactional_ > fixtures = false > end > end > > config.after(:each) do > if options[:js] > DatabaseCleaner.clean > Capybara.use_default_driver > config.use_transactional_fixtures = true > end > end > > end > > Check the lines "config.use_transactional_fixtures" on both callbacks. I doesn't seem to disable them. Any ideas? Not sure why that doesn't work, but that's not what I was proposing. I'm saying use database cleaner _instead_ of config.use_transactional_fixtures: Spec::Runner.configure do |c| c.use_transactional_fixtures = false c.before do if options[:js] DatabaseCleaner.strategy = :truncation else DatabaseCleaner.strategy = :transaction end DatabaseCleaner.start end c.after do DatabaseCleaner.clean end end Make sense? > > Marcelo. > > > On Tue, Jun 15, 2010 at 5:32 PM, David Chelimsky wrote: > On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote: > > > Hey all, > > > > I have replaced Cucumber with Steak and I like the experience so far. It is not as polished as Cucumber in what comes to configuration, but it is simpler and covers my needs perfectly. I've followed the trick to pass a hash to the example in order to setup Capybara to use a different driver, like so: > > > > spec/acceptance/support/javascript.rb > > > > Spec::Runner.configure do |config| > > > > config.before(:each) do > > if options[:js] #using culerity > > Capybara.current_driver = :culerity > > config.use_transactional_fixtures = false > > end > > end > > > > config.after(:each) do > > if options[:js] > > DatabaseCleaner.clean > > Capybara.use_default_driver > > config.use_transactional_fixtures = true > > end > > end > > > > end > > > > As you can see, if an example has an option with :js => true, it will use culerity, and this works fine. What doesn't seem to work is the use_transactional_fixtures = false conf. I still can't access the data outside of the ruby instance (i.e: the app server celerity is accessing doesn't have access to the fixture data). With Cucumber it would be a matter of setting up Cucumber::Rails::World.use_transactional_fixtures to false. > > > > How could I disable transactional fixtures on a per example base when using rspec / steak? > > As far as I know, this is not easy, or maybe even possible, with the Rails built-in framework. What I'd do is turn off the rails features (config.use_transactional_fixtures = false) and use database_cleaner. Are you familiar w/ database_cleaner? > > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Wed Jun 16 15:02:28 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Wed, 16 Jun 2010 14:02:28 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures In-Reply-To: References: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> Message-ID: Yes, That's what I want to do, but my code is a little bit different. I'm calling config.use_transactional_fixtures inside the block: config.before(:each) do config.use_transactional_fixtures = false end And then enabling it again after: config.after(:each) do DatabaseCleaner.clean #truncation mode doesn't require the start method to be called, so clean is enough. config.use_transactional_fixtures = true end Why? Well, not all example use js (culerity), and for those, I wouldn't want to use DatabaseCleaner. However, it doesn't seem to work. If I create an object from the ruby instance running the specs, and put a breakpoint, I can't see the data outside of it :( Any ideas? Marcelo. On Wed, Jun 16, 2010 at 1:47 PM, David Chelimsky wrote: > On Jun 16, 2010, at 1:37 PM, Marcelo de Moraes Serpa wrote: > > Hi David, > > Yeah, I'm using DatabaseCleaner, pretty much familiar with it. > > The issue is that passing it to rspec's yielded config object didn't seem > to disable transactional_fixtures: > > Spec::Runner.configure do |config| >> >> config.before(:each) do >> if options[:js] #using culerity >> Capybara.current_driver = :culerity >> config.use_transactional_ >> fixtures = false >> end >> end >> >> config.after(:each) do >> if options[:js] >> DatabaseCleaner.clean >> Capybara.use_default_driver >> config.use_transactional_fixtures = true >> end >> end >> >> end >> > > Check the lines "config.use_transactional_fixtures" on both callbacks. I > doesn't seem to disable them. Any ideas? > > > Not sure why that doesn't work, but that's not what I was proposing. I'm > saying use database cleaner _instead_ of config.use_transactional_fixtures: > > Spec::Runner.configure do |c| > c.use_transactional_fixtures = false > c.before do > if options[:js] > DatabaseCleaner.strategy = :truncation > else > DatabaseCleaner.strategy = :transaction > end > DatabaseCleaner.start > end > c.after do > DatabaseCleaner.clean > end > end > > Make sense? > > > Marcelo. > > > On Tue, Jun 15, 2010 at 5:32 PM, David Chelimsky wrote: > >> On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote: >> >> > Hey all, >> > >> > I have replaced Cucumber with Steak and I like the experience so far. It >> is not as polished as Cucumber in what comes to configuration, but it is >> simpler and covers my needs perfectly. I've followed the trick to pass a >> hash to the example in order to setup Capybara to use a different driver, >> like so: >> > >> > spec/acceptance/support/javascript.rb >> > >> > Spec::Runner.configure do |config| >> > >> > config.before(:each) do >> > if options[:js] #using culerity >> > Capybara.current_driver = :culerity >> > config.use_transactional_fixtures = false >> > end >> > end >> > >> > config.after(:each) do >> > if options[:js] >> > DatabaseCleaner.clean >> > Capybara.use_default_driver >> > config.use_transactional_fixtures = true >> > end >> > end >> > >> > end >> > >> > As you can see, if an example has an option with :js => true, it will >> use culerity, and this works fine. What doesn't seem to work is the >> use_transactional_fixtures = false conf. I still can't access the data >> outside of the ruby instance (i.e: the app server celerity is accessing >> doesn't have access to the fixture data). With Cucumber it would be a matter >> of setting up Cucumber::Rails::World.use_transactional_fixtures to false. >> > >> > How could I disable transactional fixtures on a per example base when >> using rspec / steak? >> >> As far as I know, this is not easy, or maybe even possible, with the Rails >> built-in framework. What I'd do is turn off the rails features >> (config.use_transactional_fixtures = false) and use database_cleaner. Are >> you familiar w/ database_cleaner? >> >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Wed Jun 16 15:03:15 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Wed, 16 Jun 2010 14:03:15 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures In-Reply-To: References: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> Message-ID: Oh, the code in the before/after blocks is wrapped in a if options[:js]. Forgot to write it. On Wed, Jun 16, 2010 at 2:02 PM, Marcelo de Moraes Serpa < celoserpa at gmail.com> wrote: > Yes, > > That's what I want to do, but my code is a little bit different. I'm > calling config.use_transactional_fixtures inside the block: > > config.before(:each) do > > config.use_transactional_fixtures = false > end > > And then enabling it again after: > > config.after(:each) do > DatabaseCleaner.clean #truncation mode doesn't require the start method > to be called, so clean is enough. > > config.use_transactional_fixtures = true > end > > Why? Well, not all example use js (culerity), and for those, I wouldn't > want to use DatabaseCleaner. > > However, it doesn't seem to work. If I create an object from the ruby > instance running the specs, and put a breakpoint, I can't see the data > outside of it :( > > Any ideas? > > Marcelo. > > > On Wed, Jun 16, 2010 at 1:47 PM, David Chelimsky wrote: > >> On Jun 16, 2010, at 1:37 PM, Marcelo de Moraes Serpa wrote: >> >> Hi David, >> >> Yeah, I'm using DatabaseCleaner, pretty much familiar with it. >> >> The issue is that passing it to rspec's yielded config object didn't seem >> to disable transactional_fixtures: >> >> Spec::Runner.configure do |config| >>> >>> config.before(:each) do >>> if options[:js] #using culerity >>> Capybara.current_driver = :culerity >>> config.use_transactional_ >>> fixtures = false >>> end >>> end >>> >>> config.after(:each) do >>> if options[:js] >>> DatabaseCleaner.clean >>> Capybara.use_default_driver >>> config.use_transactional_fixtures = true >>> end >>> end >>> >>> end >>> >> >> Check the lines "config.use_transactional_fixtures" on both callbacks. I >> doesn't seem to disable them. Any ideas? >> >> >> Not sure why that doesn't work, but that's not what I was proposing. I'm >> saying use database cleaner _instead_ of config.use_transactional_fixtures: >> >> Spec::Runner.configure do |c| >> c.use_transactional_fixtures = false >> c.before do >> if options[:js] >> DatabaseCleaner.strategy = :truncation >> else >> DatabaseCleaner.strategy = :transaction >> end >> DatabaseCleaner.start >> end >> c.after do >> DatabaseCleaner.clean >> end >> end >> >> Make sense? >> >> >> Marcelo. >> >> >> On Tue, Jun 15, 2010 at 5:32 PM, David Chelimsky wrote: >> >>> On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote: >>> >>> > Hey all, >>> > >>> > I have replaced Cucumber with Steak and I like the experience so far. >>> It is not as polished as Cucumber in what comes to configuration, but it is >>> simpler and covers my needs perfectly. I've followed the trick to pass a >>> hash to the example in order to setup Capybara to use a different driver, >>> like so: >>> > >>> > spec/acceptance/support/javascript.rb >>> > >>> > Spec::Runner.configure do |config| >>> > >>> > config.before(:each) do >>> > if options[:js] #using culerity >>> > Capybara.current_driver = :culerity >>> > config.use_transactional_fixtures = false >>> > end >>> > end >>> > >>> > config.after(:each) do >>> > if options[:js] >>> > DatabaseCleaner.clean >>> > Capybara.use_default_driver >>> > config.use_transactional_fixtures = true >>> > end >>> > end >>> > >>> > end >>> > >>> > As you can see, if an example has an option with :js => true, it will >>> use culerity, and this works fine. What doesn't seem to work is the >>> use_transactional_fixtures = false conf. I still can't access the data >>> outside of the ruby instance (i.e: the app server celerity is accessing >>> doesn't have access to the fixture data). With Cucumber it would be a matter >>> of setting up Cucumber::Rails::World.use_transactional_fixtures to false. >>> > >>> > How could I disable transactional fixtures on a per example base when >>> using rspec / steak? >>> >>> As far as I know, this is not easy, or maybe even possible, with the >>> Rails built-in framework. What I'd do is turn off the rails features >>> (config.use_transactional_fixtures = false) and use database_cleaner. Are >>> you familiar w/ database_cleaner? >>> >>> David >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 16 15:05:28 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 16 Jun 2010 14:05:28 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures In-Reply-To: References: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> Message-ID: On Jun 16, 2010, at 2:02 PM, Marcelo de Moraes Serpa wrote: > Yes, > > That's what I want to do, but my code is a little bit different. I'm calling config.use_transactional_fixtures inside the block: This doesn't work. That's what I was saying. Probably because the transactions is already turned on by active record before this block is executed. Read my last post again - it should solve your problem by using database cleaner's transaction mode for in-memory examples and truncation mode for in-browser examples. > > config.before(:each) do > config.use_transactional_fixtures = false > end > > And then enabling it again after: > > config.after(:each) do > DatabaseCleaner.clean #truncation mode doesn't require the start method to be called, so clean is enough. > config.use_transactional_fixtures = true > end > > Why? Well, not all example use js (culerity), and for those, I wouldn't want to use DatabaseCleaner. > > However, it doesn't seem to work. If I create an object from the ruby instance running the specs, and put a breakpoint, I can't see the data outside of it :( > > Any ideas? > > Marcelo. > > On Wed, Jun 16, 2010 at 1:47 PM, David Chelimsky wrote: > On Jun 16, 2010, at 1:37 PM, Marcelo de Moraes Serpa wrote: > >> Hi David, >> >> Yeah, I'm using DatabaseCleaner, pretty much familiar with it. >> >> The issue is that passing it to rspec's yielded config object didn't seem to disable transactional_fixtures: >> >> Spec::Runner.configure do |config| >> >> config.before(:each) do >> if options[:js] #using culerity >> Capybara.current_driver = :culerity >> config.use_transactional_ >> fixtures = false >> end >> end >> >> config.after(:each) do >> if options[:js] >> DatabaseCleaner.clean >> Capybara.use_default_driver >> config.use_transactional_fixtures = true >> end >> end >> >> end >> >> Check the lines "config.use_transactional_fixtures" on both callbacks. I doesn't seem to disable them. Any ideas? > > Not sure why that doesn't work, but that's not what I was proposing. I'm saying use database cleaner _instead_ of config.use_transactional_fixtures: > > Spec::Runner.configure do |c| > c.use_transactional_fixtures = false > c.before do > if options[:js] > DatabaseCleaner.strategy = :truncation > else > DatabaseCleaner.strategy = :transaction > end > DatabaseCleaner.start > end > c.after do > DatabaseCleaner.clean > end > end > > Make sense? > >> >> Marcelo. >> >> >> On Tue, Jun 15, 2010 at 5:32 PM, David Chelimsky wrote: >> On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote: >> >> > Hey all, >> > >> > I have replaced Cucumber with Steak and I like the experience so far. It is not as polished as Cucumber in what comes to configuration, but it is simpler and covers my needs perfectly. I've followed the trick to pass a hash to the example in order to setup Capybara to use a different driver, like so: >> > >> > spec/acceptance/support/javascript.rb >> > >> > Spec::Runner.configure do |config| >> > >> > config.before(:each) do >> > if options[:js] #using culerity >> > Capybara.current_driver = :culerity >> > config.use_transactional_fixtures = false >> > end >> > end >> > >> > config.after(:each) do >> > if options[:js] >> > DatabaseCleaner.clean >> > Capybara.use_default_driver >> > config.use_transactional_fixtures = true >> > end >> > end >> > >> > end >> > >> > As you can see, if an example has an option with :js => true, it will use culerity, and this works fine. What doesn't seem to work is the use_transactional_fixtures = false conf. I still can't access the data outside of the ruby instance (i.e: the app server celerity is accessing doesn't have access to the fixture data). With Cucumber it would be a matter of setting up Cucumber::Rails::World.use_transactional_fixtures to false. >> > >> > How could I disable transactional fixtures on a per example base when using rspec / steak? >> >> As far as I know, this is not easy, or maybe even possible, with the Rails built-in framework. What I'd do is turn off the rails features (config.use_transactional_fixtures = false) and use database_cleaner. Are you familiar w/ database_cleaner? >> >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Wed Jun 16 15:28:53 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Wed, 16 Jun 2010 14:28:53 -0500 Subject: [rspec-users] rspec (steak) turning off transactional fixtures In-Reply-To: References: <01633934-AE6D-48FB-86D2-65BFDCC41779@gmail.com> Message-ID: Ah, got it! Thanks for your patience, David ;) Cheers, Marcelo. On Wed, Jun 16, 2010 at 2:05 PM, David Chelimsky wrote: > > On Jun 16, 2010, at 2:02 PM, Marcelo de Moraes Serpa wrote: > > Yes, > > That's what I want to do, but my code is a little bit different. I'm > calling config.use_transactional_fixtures inside the block: > > > This doesn't work. That's what I was saying. Probably because the > transactions is already turned on by active record before this block is > executed. > > Read my last post again - it should solve your problem by using database > cleaner's transaction mode for in-memory examples and truncation mode for > in-browser examples. > > > config.before(:each) do > config.use_transactional_fixtures = false > end > > And then enabling it again after: > > config.after(:each) do > DatabaseCleaner.clean #truncation mode doesn't require the start method > to be called, so clean is enough. > config.use_transactional_fixtures = true > end > > Why? Well, not all example use js (culerity), and for those, I wouldn't > want to use DatabaseCleaner. > > However, it doesn't seem to work. If I create an object from the ruby > instance running the specs, and put a breakpoint, I can't see the data > outside of it :( > > Any ideas? > > Marcelo. > > On Wed, Jun 16, 2010 at 1:47 PM, David Chelimsky wrote: > >> On Jun 16, 2010, at 1:37 PM, Marcelo de Moraes Serpa wrote: >> >> Hi David, >> >> Yeah, I'm using DatabaseCleaner, pretty much familiar with it. >> >> The issue is that passing it to rspec's yielded config object didn't seem >> to disable transactional_fixtures: >> >> Spec::Runner.configure do |config| >>> >>> config.before(:each) do >>> if options[:js] #using culerity >>> Capybara.current_driver = :culerity >>> config.use_transactional_ >>> fixtures = false >>> end >>> end >>> >>> config.after(:each) do >>> if options[:js] >>> DatabaseCleaner.clean >>> Capybara.use_default_driver >>> config.use_transactional_fixtures = true >>> end >>> end >>> >>> end >>> >> >> Check the lines "config.use_transactional_fixtures" on both callbacks. I >> doesn't seem to disable them. Any ideas? >> >> >> Not sure why that doesn't work, but that's not what I was proposing. I'm >> saying use database cleaner _instead_ of config.use_transactional_fixtures: >> >> Spec::Runner.configure do |c| >> c.use_transactional_fixtures = false >> c.before do >> if options[:js] >> DatabaseCleaner.strategy = :truncation >> else >> DatabaseCleaner.strategy = :transaction >> end >> DatabaseCleaner.start >> end >> c.after do >> DatabaseCleaner.clean >> end >> end >> >> Make sense? >> >> >> Marcelo. >> >> >> On Tue, Jun 15, 2010 at 5:32 PM, David Chelimsky wrote: >> >>> On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote: >>> >>> > Hey all, >>> > >>> > I have replaced Cucumber with Steak and I like the experience so far. >>> It is not as polished as Cucumber in what comes to configuration, but it is >>> simpler and covers my needs perfectly. I've followed the trick to pass a >>> hash to the example in order to setup Capybara to use a different driver, >>> like so: >>> > >>> > spec/acceptance/support/javascript.rb >>> > >>> > Spec::Runner.configure do |config| >>> > >>> > config.before(:each) do >>> > if options[:js] #using culerity >>> > Capybara.current_driver = :culerity >>> > config.use_transactional_fixtures = false >>> > end >>> > end >>> > >>> > config.after(:each) do >>> > if options[:js] >>> > DatabaseCleaner.clean >>> > Capybara.use_default_driver >>> > config.use_transactional_fixtures = true >>> > end >>> > end >>> > >>> > end >>> > >>> > As you can see, if an example has an option with :js => true, it will >>> use culerity, and this works fine. What doesn't seem to work is the >>> use_transactional_fixtures = false conf. I still can't access the data >>> outside of the ruby instance (i.e: the app server celerity is accessing >>> doesn't have access to the fixture data). With Cucumber it would be a matter >>> of setting up Cucumber::Rails::World.use_transactional_fixtures to false. >>> > >>> > How could I disable transactional fixtures on a per example base when >>> using rspec / steak? >>> >>> As far as I know, this is not easy, or maybe even possible, with the >>> Rails built-in framework. What I'd do is turn off the rails features >>> (config.use_transactional_fixtures = false) and use database_cleaner. Are >>> you familiar w/ database_cleaner? >>> >>> David >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cremes.devlist at mac.com Thu Jun 17 12:07:38 2010 From: cremes.devlist at mac.com (Chuck Remes) Date: Thu, 17 Jun 2010 11:07:38 -0500 Subject: [rspec-users] chain argument expectations? Message-ID: I'm trying to test some code that can loop once or multiple times and assign some values to another object. I want to test one of the values being assigned to the object in the loop. e.g. class Foo def bar values = returns_an_array_of_values baz = Baz.new values.each_with_index do |value, index| baz.field1 = Constant baz.field2 = index baz.field3 = value end end end it "should assign increasing index values to field3" do quxxo = mock Baz.stub!(:new => quxxo) quxxo.should_receive(:field2=).with(1,2,3) end This doesn't work. I tried a few different variants. quxxo.should_receive(:field2=).with(1).with(2).with(3) that doesn't work either. Any suggestions on how to set expectations for a single mock to receive the same message multiple time with different arguments with the express purpose of validating the arguments? Thanks... cr From dchelimsky at gmail.com Thu Jun 17 13:22:07 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 17 Jun 2010 12:22:07 -0500 Subject: [rspec-users] chain argument expectations? In-Reply-To: References: Message-ID: <2180B966-BAA7-440B-A281-B4A535F395B6@gmail.com> On Jun 17, 2010, at 11:07 AM, Chuck Remes wrote: > I'm trying to test some code that can loop once or multiple times and assign some values to another object. I want to test one of the values being assigned to the object in the loop. > > e.g. > > class Foo > def bar > values = returns_an_array_of_values > > baz = Baz.new > > values.each_with_index do |value, index| > baz.field1 = Constant > baz.field2 = index > baz.field3 = value > end > end > end > > > > it "should assign increasing index values to field3" do > quxxo = mock > Baz.stub!(:new => quxxo) > > quxxo.should_receive(:field2=).with(1,2,3) > end > > This doesn't work. I tried a few different variants. > > quxxo.should_receive(:field2=).with(1).with(2).with(3) > > that doesn't work either. > > Any suggestions on how to set expectations for a single mock to receive the same message multiple time with different arguments with the express purpose of validating the arguments? quxxo.stub(:field2=) quxxo.should_receive(:field2=).with(1) quxxo.should_receive(:field2=).with(2) quxxo.should_receive(:field2=).with(3) Cheers, David From rogerdpack at gmail.com Thu Jun 17 15:46:55 2010 From: rogerdpack at gmail.com (rogerdpack) Date: Thu, 17 Jun 2010 12:46:55 -0700 (PDT) Subject: [rspec-users] cleanup wiki In-Reply-To: References: Message-ID: <3f2e588c-dc27-4139-837c-8128fc869d46@y4g2000yqy.googlegroups.com> > > I think a TOC would be far easier to maintain, no? I think so. I'll create one sometime. From cremes.devlist at mac.com Fri Jun 18 12:24:42 2010 From: cremes.devlist at mac.com (Chuck Remes) Date: Fri, 18 Jun 2010 11:24:42 -0500 Subject: [rspec-users] chain argument expectations? In-Reply-To: <2180B966-BAA7-440B-A281-B4A535F395B6@gmail.com> References: <2180B966-BAA7-440B-A281-B4A535F395B6@gmail.com> Message-ID: <2D874AD7-FA14-4D9E-ACA9-214A0F4B97F0@mac.com> On Jun 17, 2010, at 12:22 PM, David Chelimsky wrote: > On Jun 17, 2010, at 11:07 AM, Chuck Remes wrote: > >> it "should assign increasing index values to field3" do >> quxxo = mock >> Baz.stub!(:new => quxxo) >> >> quxxo.should_receive(:field2=).with(1,2,3) >> end >> >> This doesn't work. I tried a few different variants. >> >> quxxo.should_receive(:field2=).with(1).with(2).with(3) >> >> that doesn't work either. >> >> Any suggestions on how to set expectations for a single mock to receive the same message multiple time with different arguments with the express purpose of validating the arguments? > > quxxo.stub(:field2=) > quxxo.should_receive(:field2=).with(1) > quxxo.should_receive(:field2=).with(2) > quxxo.should_receive(:field2=).with(3) Ah, so obvious in retrospect. Many thanks... cr From celoserpa at gmail.com Fri Jun 18 12:46:50 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Fri, 18 Jun 2010 11:46:50 -0500 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests Message-ID: Hello all, I have an acceptance test that aims to bdd a Google Apps OpenID authentication feature. This login screen also uses some JS (in order to switch between the regular / Google OpenID forms). Now, I know this is not something that would prevent me from using the :rack driver for Capybara, but it made me think of the following problem: What to do when you have a JS/Ajax-oriented page that makes web service calls and you need to write an integration/acceptance test for it? The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) means it will need to spawn a different process (Not sure about EnvJS, but I guess it also needs a rails server running? ) for the rails app server. This essentially prevents any mocking/stubbing/faking of requests. I wouldn't want a bunch of acceptance tests that actually make requests to web services, certainly a testing no-no. What do you guys think could be done in these cases? I remember seeing something a long time ago (a lib) that actually tried to solve the problem of mocking while having the two processes open. Or maybe it's too much troube to write integration tests for these kind of features? FYI, I'm using rSpec, Steak and Capybara+Culerity. Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Fri Jun 18 13:02:39 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Fri, 18 Jun 2010 12:02:39 -0500 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests In-Reply-To: References: Message-ID: One thing that just came to my mind is to fake the requests on the app server instance. One simple way to do that would be to just put the FakeWeb call in a cucumber / culerity environment file. However, this is far from being elegant and is not scalable at all, as the call would be contextless to the spec that needs it. Any other ideas? Marcelo. On Fri, Jun 18, 2010 at 11:46 AM, Marcelo de Moraes Serpa < celoserpa at gmail.com> wrote: > Hello all, > > I have an acceptance test that aims to bdd a Google Apps OpenID > authentication feature. This login screen also uses some JS (in order to > switch between the regular / Google OpenID forms). Now, I know this is not > something that would prevent me from using the :rack driver for Capybara, > but it made me think of the following problem: What to do when you have a > JS/Ajax-oriented page that makes web service calls and you need to write an > integration/acceptance test for it? > > The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) means > it will need to spawn a different process (Not sure about EnvJS, but I guess > it also needs a rails server running? ) for the rails app server. This > essentially prevents any mocking/stubbing/faking of requests. I wouldn't > want a bunch of acceptance tests that actually make requests to web > services, certainly a testing no-no. > > What do you guys think could be done in these cases? I remember seeing > something a long time ago (a lib) that actually tried to solve the problem > of mocking while having the two processes open. Or maybe it's too much > troube to write integration tests for these kind of features? > > FYI, I'm using rSpec, Steak and Capybara+Culerity. > > Marcelo. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jun 18 14:18:35 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 18 Jun 2010 13:18:35 -0500 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests In-Reply-To: References: Message-ID: <188CAA9E-4482-44DE-9A91-30674CDC32F1@gmail.com> On Jun 18, 2010, at 12:02 PM, Marcelo de Moraes Serpa wrote: > One thing that just came to my mind is to fake the requests on the app server instance. One simple way to do that would be to just put the FakeWeb call in a cucumber / culerity environment file. However, this is far from being elegant and is not scalable at all, as the call would be contextless to the spec that needs it. How about putting it in a step/step definition before the call gets made? > > Any other ideas? > > Marcelo. > > On Fri, Jun 18, 2010 at 11:46 AM, Marcelo de Moraes Serpa wrote: > Hello all, > > I have an acceptance test that aims to bdd a Google Apps OpenID authentication feature. This login screen also uses some JS (in order to switch between the regular / Google OpenID forms). Now, I know this is not something that would prevent me from using the :rack driver for Capybara, but it made me think of the following problem: What to do when you have a JS/Ajax-oriented page that makes web service calls and you need to write an integration/acceptance test for it? > > The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) means it will need to spawn a different process (Not sure about EnvJS, but I guess it also needs a rails server running? ) for the rails app server. This essentially prevents any mocking/stubbing/faking of requests. I wouldn't want a bunch of acceptance tests that actually make requests to web services, certainly a testing no-no. > > What do you guys think could be done in these cases? I remember seeing something a long time ago (a lib) that actually tried to solve the problem of mocking while having the two processes open. Or maybe it's too much troube to write integration tests for these kind of features? > > FYI, I'm using rSpec, Steak and Capybara+Culerity. > > Marcelo. > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnf.pub at distb.net Fri Jun 18 15:29:13 2010 From: johnf.pub at distb.net (John Feminella) Date: Fri, 18 Jun 2010 15:29:13 -0400 Subject: [rspec-users] Unexpected behavior with Matchers::Change and empty collections Message-ID: The behavior of Spec::Matchers::Change in rspec 1.3.0 appears to overlook a small corner case. When the initial value is `{}` or `[]` but the `from` clause is `nil`, rspec will report that the initial value is correct. Of course, `nil` is not equal to either `{}` or `[]`. Here's a simple test case: describe "Simple hash" do before :each do @c = Class.new do attr_accessor :apple end.new @c.apple = {} # or [] end it "should change values with []= calls" do # False positive! The initial value is {} (or []), not nil. ->{ @c.apple = 100 }.should change(@c, :apple).from(nil).to(100) end end Running this produces no errors. However, if you switch things so that the initial value of `@c.apple` is `nil` and the `from` clause is `[]` or `{}`, rspec's behavior is now what you'd expect to see: ==== 'Simple hash should change values with []= calls' FAILED apple should have initially been {}, but was nil /home/johnf/.rvm/gems/ruby-1.9.1-p378 at standard/gems/rspec-1.3.0/lib/spec/expectations/fail_with.rb:41:in `fail_with' /home/johnf/.rvm/gems/ruby-1.9.1-p378 at standard/gems/rspec-1.3.0/lib/spec/expectations/handler.rb:21:in `handle_matcher' /home/johnf/.rvm/gems/ruby-1.9.1-p378 at standard/gems/rspec-1.3.0/lib/spec/expectations/extensions/kernel.rb:27:in `should' ==== Is this behavior by design? -- John Feminella Principal Consultant, Distilled Brilliance From celoserpa at gmail.com Fri Jun 18 18:02:22 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Fri, 18 Jun 2010 17:02:22 -0500 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests In-Reply-To: <188CAA9E-4482-44DE-9A91-30674CDC32F1@gmail.com> References: <188CAA9E-4482-44DE-9A91-30674CDC32F1@gmail.com> Message-ID: Hi David, thanks for the reply, Hmm, considering we have: 1) The ruby process where the spec is running 2) A mongrel server serving request (test environment) If I call FakeWeb on #1, it won't work on #2, since they are separated processes and FakeWeb would only monkeypatch Net::HTTP for #1. Or am I missing something? Thanks! Marcelo. On Fri, Jun 18, 2010 at 1:18 PM, David Chelimsky wrote: > On Jun 18, 2010, at 12:02 PM, Marcelo de Moraes Serpa wrote: > > One thing that just came to my mind is to fake the requests on the app > server instance. One simple way to do that would be to just put the FakeWeb > call in a cucumber / culerity environment file. However, this is far from > being elegant and is not scalable at all, as the call would be contextless > to the spec that needs it. > > > How about putting it in a step/step definition before the call gets made? > > > Any other ideas? > > Marcelo. > > On Fri, Jun 18, 2010 at 11:46 AM, Marcelo de Moraes Serpa < > celoserpa at gmail.com> wrote: > >> Hello all, >> >> I have an acceptance test that aims to bdd a Google Apps OpenID >> authentication feature. This login screen also uses some JS (in order to >> switch between the regular / Google OpenID forms). Now, I know this is not >> something that would prevent me from using the :rack driver for Capybara, >> but it made me think of the following problem: What to do when you have a >> JS/Ajax-oriented page that makes web service calls and you need to write an >> integration/acceptance test for it? >> >> The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) >> means it will need to spawn a different process (Not sure about EnvJS, but I >> guess it also needs a rails server running? ) for the rails app server. This >> essentially prevents any mocking/stubbing/faking of requests. I wouldn't >> want a bunch of acceptance tests that actually make requests to web >> services, certainly a testing no-no. >> >> What do you guys think could be done in these cases? I remember seeing >> something a long time ago (a lib) that actually tried to solve the problem >> of mocking while having the two processes open. Or maybe it's too much >> troube to write integration tests for these kind of features? >> >> FYI, I'm using rSpec, Steak and Capybara+Culerity. >> >> Marcelo. >> >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jun 18 19:35:24 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 18 Jun 2010 18:35:24 -0500 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests In-Reply-To: References: <188CAA9E-4482-44DE-9A91-30674CDC32F1@gmail.com> Message-ID: <134772D9-90F0-41E0-B741-BAE729257F0B@gmail.com> On Jun 18, 2010, at 5:02 PM, Marcelo de Moraes Serpa wrote: > Hi David, thanks for the reply, > > Hmm, considering we have: > 1) The ruby process where the spec is running > 2) A mongrel server serving request (test environment) > > If I call FakeWeb on #1, it won't work on #2, since they are separated processes and FakeWeb would only monkeypatch Net::HTTP for #1. Or am I missing something? No, I was missing something :) I'm not sure what the best way is here. On the apps I'm working on now, we typically have all the ajax calls go back to the app and then make requests to web services from the server. Makes it easier to test, log failures, etc, etc. Anybody else here testing client side web service calls? > > Thanks! > > Marcelo. > > On Fri, Jun 18, 2010 at 1:18 PM, David Chelimsky wrote: > On Jun 18, 2010, at 12:02 PM, Marcelo de Moraes Serpa wrote: > >> One thing that just came to my mind is to fake the requests on the app server instance. One simple way to do that would be to just put the FakeWeb call in a cucumber / culerity environment file. However, this is far from being elegant and is not scalable at all, as the call would be contextless to the spec that needs it. > > How about putting it in a step/step definition before the call gets made? > >> >> Any other ideas? >> >> Marcelo. >> >> On Fri, Jun 18, 2010 at 11:46 AM, Marcelo de Moraes Serpa wrote: >> Hello all, >> >> I have an acceptance test that aims to bdd a Google Apps OpenID authentication feature. This login screen also uses some JS (in order to switch between the regular / Google OpenID forms). Now, I know this is not something that would prevent me from using the :rack driver for Capybara, but it made me think of the following problem: What to do when you have a JS/Ajax-oriented page that makes web service calls and you need to write an integration/acceptance test for it? >> >> The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) means it will need to spawn a different process (Not sure about EnvJS, but I guess it also needs a rails server running? ) for the rails app server. This essentially prevents any mocking/stubbing/faking of requests. I wouldn't want a bunch of acceptance tests that actually make requests to web services, certainly a testing no-no. >> >> What do you guys think could be done in these cases? I remember seeing something a long time ago (a lib) that actually tried to solve the problem of mocking while having the two processes open. Or maybe it's too much troube to write integration tests for these kind of features? >> >> FYI, I'm using rSpec, Steak and Capybara+Culerity. >> >> Marcelo. >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.sroka at gmail.com Fri Jun 18 19:54:33 2010 From: adam.sroka at gmail.com (Adam Sroka) Date: Fri, 18 Jun 2010 16:54:33 -0700 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests In-Reply-To: <134772D9-90F0-41E0-B741-BAE729257F0B@gmail.com> References: <188CAA9E-4482-44DE-9A91-30674CDC32F1@gmail.com> <134772D9-90F0-41E0-B741-BAE729257F0B@gmail.com> Message-ID: What I typically do is wrap any Ajax calls on the client side with JavaScript objects. Then it is fairly trivial to stub the calls by just redefining the methods that would normally call the server. For acceptance testing I would normally just do it end-to-end and not mock. However, if there is some reason that you don't want to call the real thing (e.g. payment processor, authentication framework, etc.) you could conditionally load the javascript that stubs the Ajax calls, or you could implement a fake (i.e. a real simple implementation of the web service that returns a canned response.) On Fri, Jun 18, 2010 at 4:35 PM, David Chelimsky wrote: > On Jun 18, 2010, at 5:02 PM, Marcelo de Moraes Serpa wrote: > > Hi David, thanks for the reply, > > Hmm, considering we have: > ?1) The ruby process where the spec is running > ?2) A mongrel server serving request (test environment) > > If I call FakeWeb on #1, it won't work on #2, since they are separated > processes and FakeWeb would only monkeypatch Net::HTTP for #1. Or am I > missing something? > > No, I was missing something :) > I'm not sure what the best way is here. On the apps I'm working on now, we > typically have all the ajax calls go back to the app and then make requests > to web services from the server. Makes it easier to test, log failures, etc, > etc. > Anybody else here testing client side web service calls? > > Thanks! > > Marcelo. > > On Fri, Jun 18, 2010 at 1:18 PM, David Chelimsky > wrote: >> >> On Jun 18, 2010, at 12:02 PM, Marcelo de Moraes Serpa wrote: >> >> One thing that just came to my mind is to fake the requests on the app >> server instance. One simple way to do that would be to just put the FakeWeb >> call in a cucumber / culerity environment file. However, this is far from >> being elegant and is not scalable at all, as the call would be contextless >> to the spec that needs it. >> >> How about putting it in a step/step definition before the call gets made? >> >> Any other ideas? >> >> Marcelo. >> >> On Fri, Jun 18, 2010 at 11:46 AM, Marcelo de Moraes Serpa >> wrote: >>> >>> Hello all, >>> >>> I have an acceptance test that aims to bdd a Google Apps OpenID >>> authentication feature. This login screen also uses some JS (in order to >>> switch between the regular / Google OpenID forms). Now, I know this is not >>> something that would prevent me from using the :rack driver for Capybara, >>> but it made me think of the following problem: What to do when you have a >>> JS/Ajax-oriented page that makes web service calls and you need to write an >>> integration/acceptance test for it? >>> >>> The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) >>> means it will need to spawn a different process (Not sure about EnvJS, but I >>> guess it also needs a rails server running? ) for the rails app server. This >>> essentially prevents any mocking/stubbing/faking of requests. I wouldn't >>> want a bunch of acceptance tests that actually make requests to web >>> services, certainly a testing no-no. >>> >>> What do you guys think could be done in these cases? I remember seeing >>> something a long time ago (a lib) that actually tried to solve the problem >>> of mocking while having the two processes open. Or maybe it's too much >>> troube to write integration tests for these kind of features? >>> >>> FYI, I'm using rSpec, Steak and Capybara+Culerity. >>> >>> Marcelo. >>> >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Jun 18 20:50:43 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 18 Jun 2010 19:50:43 -0500 Subject: [rspec-users] Unexpected behavior with Matchers::Change and empty collections In-Reply-To: References: Message-ID: On Jun 18, 2010, at 2:29 PM, John Feminella wrote: > The behavior of Spec::Matchers::Change in rspec 1.3.0 appears to > overlook a small corner case. When the initial value is `{}` or `[]` > but the `from` clause is `nil`, rspec will report that the initial > value is correct. Of course, `nil` is not equal to either `{}` or > `[]`. Here's a simple test case: > > describe "Simple hash" do > before :each do > @c = Class.new do > attr_accessor :apple > end.new > > @c.apple = {} # or [] > end > > it "should change values with []= calls" do > # False positive! The initial value is {} (or []), not nil. > ->{ @c.apple = 100 }.should change(@c, :apple).from(nil).to(100) > end > end > > Running this produces no errors. However, if you switch things so that > the initial value of `@c.apple` is `nil` and the `from` clause is `[]` > or `{}`, rspec's behavior is now what you'd expect to see: > > ==== > 'Simple hash should change values with []= calls' FAILED > apple should have initially been {}, but was nil > /home/johnf/.rvm/gems/ruby-1.9.1-p378 at standard/gems/rspec-1.3.0/lib/spec/expectations/fail_with.rb:41:in > `fail_with' > /home/johnf/.rvm/gems/ruby-1.9.1-p378 at standard/gems/rspec-1.3.0/lib/spec/expectations/handler.rb:21:in > `handle_matcher' > /home/johnf/.rvm/gems/ruby-1.9.1-p378 at standard/gems/rspec-1.3.0/lib/spec/expectations/extensions/kernel.rb:27:in > `should' > ==== > > Is this behavior by design? Yes. We deliberately made it so it would work this way :) Or ... No, please file a bug. http://rspec.lighthouseapp.com for rspec-1 http://github.com/rspec/rspec-expectations/issues for rspec-2 Please include the same backtrace information. Thanks! Cheers, David From lbocseg at yahoo.com.br Sat Jun 19 13:07:04 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sat, 19 Jun 2010 14:07:04 -0300 Subject: [rspec-users] rspec-rails 2 webrat dependency Message-ID: <4C1CF938.1070709@yahoo.com.br> Hi, I've finally make all my tests pass in Rails 3 with Capybara. After removing webrat's dependency in favor of the new Capybara one, I expected that bundle install would remove Webrat dependencie. After a few minutes searching for bundler bugs related to removing dependencies I've tried to uninstall webrat gem. Then I understood that rspec-rails was depending on it... Is there any reason for that? If so, couldn't Rspec use Capybara instead of Webrat if it is not present? Is it possible to depend on Webrat OR Capybara in the gem specs? Thank you all, specially David, for this wonderful piece of software that is Rspec! Best regards, Rodrigo. __________________________________________________ Fale com seus amigos de gra?a com o novo Yahoo! Messenger http://br.messenger.yahoo.com/ From dchelimsky at gmail.com Sat Jun 19 13:14:22 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 19 Jun 2010 12:14:22 -0500 Subject: [rspec-users] rspec-rails 2 webrat dependency In-Reply-To: <4C1CF938.1070709@yahoo.com.br> References: <4C1CF938.1070709@yahoo.com.br> Message-ID: <3BBF5246-EE92-4BEF-9890-FFDF94516180@gmail.com> On Jun 19, 2010, at 12:07 PM, Rodrigo Rosenfeld Rosas wrote: > Hi, I've finally make all my tests pass in Rails 3 with Capybara. > > After removing webrat's dependency in favor of the new Capybara one, I expected that bundle install would remove Webrat dependencie. > > After a few minutes searching for bundler bugs related to removing dependencies I've tried to uninstall webrat gem. Then I understood that rspec-rails was depending on it... > > Is there any reason for that? If so, couldn't Rspec use Capybara instead of Webrat if it is not present? Is it possible to depend on Webrat OR Capybara in the gem specs? > > Thank you all, specially David, for this wonderful piece of software that is Rspec! > > Best regards, > > Rodrigo. There's an open issue on this: http://github.com/rspec/rspec-rails/issues#issue/49 Just a matter of prioritization, and this super low on my priority list. Patches welcome. From bcardarella at gmail.com Sat Jun 19 13:27:30 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 19 Jun 2010 10:27:30 -0700 (PDT) Subject: [rspec-users] RSpec 2.0, Cucumber, ruby-debug Message-ID: <655ab45b-00b4-415e-9ba9-d3080124295d@k39g2000yqd.googlegroups.com> I see that I now need to pas -d or --debug with the rspec command line tool to use ruby-debug. What about with Cucumber? RSpec 2.0 Core overwrites Kernel#debugger that ruby-debug uses. From rick.denatale at gmail.com Sat Jun 19 15:12:24 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 19 Jun 2010 15:12:24 -0400 Subject: [rspec-users] rspec-rails 2 webrat dependency In-Reply-To: <4C1CF938.1070709@yahoo.com.br> References: <4C1CF938.1070709@yahoo.com.br> Message-ID: On Sat, Jun 19, 2010 at 1:07 PM, Rodrigo Rosenfeld Rosas wrote: > Is there any reason for that? If so, couldn't Rspec use Capybara instead of > Webrat if it is not present? Is it possible to depend on Webrat OR Capybara > in the gem specs? Gemspecs don't allow alternative dependencies. I have a similar issue with the RiCal gem. It works with either the activesupport OR tzinfo gems, rather than require either I just document that it requires one or the other and leave it up to the user. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From rogerdpack at gmail.com Sat Jun 19 16:54:58 2010 From: rogerdpack at gmail.com (rogerdpack) Date: Sat, 19 Jun 2010 13:54:58 -0700 (PDT) Subject: [rspec-users] cleaner failure messages? Message-ID: <8e514768-118b-4fb1-a757-82d7f834c7d7@s4g2000prh.googlegroups.com> Hi all. Sorry if this is an old request... Currently when a failure is reported it looks like this: C:\dev\ruby\faster_rubygems\spec>spec spec.faster_rubygems_cacheing.rb F 1) RuntimeError in 'FasterRubyGems cacheing Gem.bin_path should cache and reload Gem.bin_path where possible' assertion failed C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb: 14:in `block (3 levels) in ' This is good because it tells me what line failed, but that's about it. The skinny of this request is that I'd find it more useful to actually have the code displayed that failed on line 14, in this case, the word "fail" so like this: C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb:14: "fail" Instead of the current C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb: 14:in `block (3 levels) in ' So the failure report is good, but could be improved. Another option would be to display the line below what is currently output, like C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb: 14:in `block (3 levels) in ' fail Or something like that. Any thoughts there? Thanks. -rp From dchelimsky at gmail.com Sat Jun 19 17:17:07 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 19 Jun 2010 16:17:07 -0500 Subject: [rspec-users] cleaner failure messages? In-Reply-To: <8e514768-118b-4fb1-a757-82d7f834c7d7@s4g2000prh.googlegroups.com> References: <8e514768-118b-4fb1-a757-82d7f834c7d7@s4g2000prh.googlegroups.com> Message-ID: <96DCFA5E-E1FC-414E-90F1-658AE3CE4020@gmail.com> On Jun 19, 2010, at 3:54 PM, rogerdpack wrote: > Hi all. > Sorry if this is an old request... > > Currently when a failure is reported it looks like this: > > C:\dev\ruby\faster_rubygems\spec>spec > spec.faster_rubygems_cacheing.rb > F > > 1) > RuntimeError in 'FasterRubyGems cacheing Gem.bin_path should cache and > reload Gem.bin_path where possible' > assertion failed > C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb: > 14:in `block (3 levels) in ' > > This is good because it tells me what line failed, but that's about > it. > > The skinny of this request is that I'd find it more useful to actually > have the code displayed that failed on line 14, in this case, the word > "fail" > > so like this: > C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb:14: > "fail" > Instead of the current > C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb: > 14:in `block (3 levels) in ' > > So the failure report is good, but could be improved. > Another option would be to display the line below what is currently > output, like > > C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb: > 14:in `block (3 levels) in ' > fail > > Or something like that. > Any thoughts there? > Thanks. Already done in rspec-2. Likely won't backport it to rspec-1 for some time (if ever). Cheers, David From michael at schuerig.de Sat Jun 19 17:19:29 2010 From: michael at schuerig.de (Michael Schuerig) Date: Sat, 19 Jun 2010 23:19:29 +0200 Subject: [rspec-users] RSpec 2: view example groups don't load helpers? Message-ID: <201006192319.29702.michael@schuerig.de> I'm in the process of moving an app from Rails 2.3.8 to 3. In the view spec I'm currently migrating, I get the error undefined method `link_to_xyz' for # That method is defined in one of my helpers that are loaded in by the app with helpers :all in the ApplicationController. Is this intended behavior to force me to mock/stub all my own helpers? If not, what do I have to do to make the specs aware of helpers? I can call view.extend(MyHelper) just before rendering, but that's a bit cumbersome if several helpers are involved. I'm using rspec-rails 2.0.0.beta.12 with Rails 3.0.0.beta4. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Sat Jun 19 18:08:44 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 19 Jun 2010 17:08:44 -0500 Subject: [rspec-users] RSpec 2: view example groups don't load helpers? In-Reply-To: <201006192319.29702.michael@schuerig.de> References: <201006192319.29702.michael@schuerig.de> Message-ID: <57B9D967-FAF6-403C-A61F-92F6612BEDA1@gmail.com> On Jun 19, 2010, at 4:19 PM, Michael Schuerig wrote: > > I'm in the process of moving an app from Rails 2.3.8 to 3. In the view > spec I'm currently migrating, I get the error > > undefined method `link_to_xyz' for # > > That method is defined in one of my helpers that are loaded in by the > app with helpers :all in the ApplicationController. > > Is this intended behavior to force me to mock/stub all my own helpers? Not at all. > If not, what do I have to do to make the specs aware of helpers? helper(MyHelper, :my_helper, 'other_helper') > I can call view.extend(MyHelper) just before rendering, but that's a bit > cumbersome if several helpers are involved. > I'm using rspec-rails 2.0.0.beta.12 with Rails 3.0.0.beta4. I've got a ticket into rails to make this method work with :all, as documented, but until that's fixed you have to list them all separately. At least you can do it in one statement :) https://rails.lighthouseapp.com/projects/8994/tickets/4775. HTH, David From bcardarella at gmail.com Sat Jun 19 18:24:12 2010 From: bcardarella at gmail.com (Brian Cardarella) Date: Sat, 19 Jun 2010 15:24:12 -0700 (PDT) Subject: [rspec-users] RSpec 2.0, Cucumber, ruby-debug In-Reply-To: <655ab45b-00b4-415e-9ba9-d3080124295d@k39g2000yqd.googlegroups.com> References: <655ab45b-00b4-415e-9ba9-d3080124295d@k39g2000yqd.googlegroups.com> Message-ID: <99ab4094-6a48-43cb-968f-c8ea7a2e13b6@u26g2000yqu.googlegroups.com> My work-around is to just comment out the debugger method defined in kernel_extensions.rb in RSpec-core. This doesn't feel like an ideal solution. On Jun 19, 1:27?pm, Brian Cardarella wrote: > I see that I now need to pas -d or --debug with the rspec command line > tool to use ruby-debug. What about with Cucumber? RSpec 2.0 Core > overwrites Kernel#debugger that ruby-debug uses. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Jun 19 18:35:06 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 19 Jun 2010 17:35:06 -0500 Subject: [rspec-users] RSpec 2.0, Cucumber, ruby-debug In-Reply-To: <99ab4094-6a48-43cb-968f-c8ea7a2e13b6@u26g2000yqu.googlegroups.com> References: <655ab45b-00b4-415e-9ba9-d3080124295d@k39g2000yqd.googlegroups.com> <99ab4094-6a48-43cb-968f-c8ea7a2e13b6@u26g2000yqu.googlegroups.com> Message-ID: <7FD627D7-9930-4D1A-B723-8370D8A39802@gmail.com> On Jun 19, 2010, at 5:24 PM, Brian Cardarella wrote: > On Jun 19, 1:27 pm, Brian Cardarella wrote: >> I see that I now need to pas -d or --debug with the rspec command line >> tool to use ruby-debug. What about with Cucumber? RSpec 2.0 Core >> overwrites Kernel#debugger that ruby-debug uses. > My work-around is to just comment out the debugger method defined in > kernel_extensions.rb in RSpec-core. This doesn't feel like an ideal > solution. What are you experiencing and what are you expecting? From michael at schuerig.de Sat Jun 19 19:51:34 2010 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 20 Jun 2010 01:51:34 +0200 Subject: [rspec-users] RSpec 2: view example groups don't load helpers? In-Reply-To: <57B9D967-FAF6-403C-A61F-92F6612BEDA1@gmail.com> References: <201006192319.29702.michael@schuerig.de> <57B9D967-FAF6-403C-A61F-92F6612BEDA1@gmail.com> Message-ID: <201006200151.34746.michael@schuerig.de> On Sunday 20 June 2010, David Chelimsky wrote: > On Jun 19, 2010, at 4:19 PM, Michael Schuerig wrote: > > If not, what do I have to do to make the specs aware of helpers? > > helper(MyHelper, :my_helper, 'other_helper') I see. Thanks, that works. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From matt at mattwynne.net Sun Jun 20 02:30:12 2010 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 20 Jun 2010 07:30:12 +0100 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests In-Reply-To: <134772D9-90F0-41E0-B741-BAE729257F0B@gmail.com> References: <188CAA9E-4482-44DE-9A91-30674CDC32F1@gmail.com> <134772D9-90F0-41E0-B741-BAE729257F0B@gmail.com> Message-ID: On 19 Jun 2010, at 00:35, David Chelimsky wrote: > On Jun 18, 2010, at 5:02 PM, Marcelo de Moraes Serpa wrote: > >> Hi David, thanks for the reply, >> >> Hmm, considering we have: >> 1) The ruby process where the spec is running >> 2) A mongrel server serving request (test environment) >> >> If I call FakeWeb on #1, it won't work on #2, since they are separated processes and FakeWeb would only monkeypatch Net::HTTP for #1. Or am I missing something? > > No, I was missing something :) > > I'm not sure what the best way is here. On the apps I'm working on now, we typically have all the ajax calls go back to the app and then make requests to web services from the server. Makes it easier to test, log failures, etc, etc. > > Anybody else here testing client side web service calls? David, I think you and the OP are still talking at cross-purposes. Are you saying that when you use Capybara, the SUT runs in the same process as the tests, even when you're doing javascript/ajax tests? > >> >> Thanks! >> >> Marcelo. >> >> On Fri, Jun 18, 2010 at 1:18 PM, David Chelimsky wrote: >> On Jun 18, 2010, at 12:02 PM, Marcelo de Moraes Serpa wrote: >> >>> One thing that just came to my mind is to fake the requests on the app server instance. One simple way to do that would be to just put the FakeWeb call in a cucumber / culerity environment file. However, this is far from being elegant and is not scalable at all, as the call would be contextless to the spec that needs it. >> >> How about putting it in a step/step definition before the call gets made? >> >>> >>> Any other ideas? >>> >>> Marcelo. >>> >>> On Fri, Jun 18, 2010 at 11:46 AM, Marcelo de Moraes Serpa wrote: >>> Hello all, >>> >>> I have an acceptance test that aims to bdd a Google Apps OpenID authentication feature. This login screen also uses some JS (in order to switch between the regular / Google OpenID forms). Now, I know this is not something that would prevent me from using the :rack driver for Capybara, but it made me think of the following problem: What to do when you have a JS/Ajax-oriented page that makes web service calls and you need to write an integration/acceptance test for it? >>> >>> The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) means it will need to spawn a different process (Not sure about EnvJS, but I guess it also needs a rails server running? ) for the rails app server. This essentially prevents any mocking/stubbing/faking of requests. I wouldn't want a bunch of acceptance tests that actually make requests to web services, certainly a testing no-no. >>> >>> What do you guys think could be done in these cases? I remember seeing something a long time ago (a lib) that actually tried to solve the problem of mocking while having the two processes open. Or maybe it's too much troube to write integration tests for these kind of features? >>> >>> FYI, I'm using rSpec, Steak and Capybara+Culerity. >>> >>> Marcelo. >>> >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jun 20 06:40:45 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 05:40:45 -0500 Subject: [rspec-users] Mocking/Faking requests for js/ajax-based tests In-Reply-To: References: <188CAA9E-4482-44DE-9A91-30674CDC32F1@gmail.com> <134772D9-90F0-41E0-B741-BAE729257F0B@gmail.com> Message-ID: <4BF3A7D7-B9E5-47A7-B6BA-98888A036209@gmail.com> On Jun 20, 2010, at 1:30 AM, Matt Wynne wrote: > > On 19 Jun 2010, at 00:35, David Chelimsky wrote: > >> On Jun 18, 2010, at 5:02 PM, Marcelo de Moraes Serpa wrote: >> >>> Hi David, thanks for the reply, >>> >>> Hmm, considering we have: >>> 1) The ruby process where the spec is running >>> 2) A mongrel server serving request (test environment) >>> >>> If I call FakeWeb on #1, it won't work on #2, since they are separated processes and FakeWeb would only monkeypatch Net::HTTP for #1. Or am I missing something? >> >> No, I was missing something :) >> >> I'm not sure what the best way is here. On the apps I'm working on now, we typically have all the ajax calls go back to the app and then make requests to web services from the server. Makes it easier to test, log failures, etc, etc. >> >> Anybody else here testing client side web service calls? > > David, I think you and the OP are still talking at cross-purposes. > > Are you saying that when you use Capybara, the SUT runs in the same process as the tests, even when you're doing javascript/ajax tests? No. That's what I meant by "No, I was missing something" - I had forgotten about the separate processes when I responded earlier. > >> >>> >>> Thanks! >>> >>> Marcelo. >>> >>> On Fri, Jun 18, 2010 at 1:18 PM, David Chelimsky wrote: >>> On Jun 18, 2010, at 12:02 PM, Marcelo de Moraes Serpa wrote: >>> >>>> One thing that just came to my mind is to fake the requests on the app server instance. One simple way to do that would be to just put the FakeWeb call in a cucumber / culerity environment file. However, this is far from being elegant and is not scalable at all, as the call would be contextless to the spec that needs it. >>> >>> How about putting it in a step/step definition before the call gets made? >>> >>>> >>>> Any other ideas? >>>> >>>> Marcelo. >>>> >>>> On Fri, Jun 18, 2010 at 11:46 AM, Marcelo de Moraes Serpa wrote: >>>> Hello all, >>>> >>>> I have an acceptance test that aims to bdd a Google Apps OpenID authentication feature. This login screen also uses some JS (in order to switch between the regular / Google OpenID forms). Now, I know this is not something that would prevent me from using the :rack driver for Capybara, but it made me think of the following problem: What to do when you have a JS/Ajax-oriented page that makes web service calls and you need to write an integration/acceptance test for it? >>>> >>>> The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) means it will need to spawn a different process (Not sure about EnvJS, but I guess it also needs a rails server running? ) for the rails app server. This essentially prevents any mocking/stubbing/faking of requests. I wouldn't want a bunch of acceptance tests that actually make requests to web services, certainly a testing no-no. >>>> >>>> What do you guys think could be done in these cases? I remember seeing something a long time ago (a lib) that actually tried to solve the problem of mocking while having the two processes open. Or maybe it's too much troube to write integration tests for these kind of features? >>>> >>>> FYI, I'm using rSpec, Steak and Capybara+Culerity. >>>> >>>> Marcelo. >>>> >>>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at schuerig.de Sun Jun 20 08:30:53 2010 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 20 Jun 2010 14:30:53 +0200 Subject: [rspec-users] RSpec 2 view example: render_template Message-ID: <201006201430.53463.michael@schuerig.de> On http://github.com/rspec/rspec-rails under "View specs" there's an example describe "events/index.html.erb" do it "renders _event partial for each event" do assign(:events, [stub_model(Event), stub_model(Event)]) render view.should render_template(:partial => "_event", :count => 2) end end Is this indeed correct? From the outset, it looks wrong because it sets an expectation (view.should ...) after the call to render. Then, no matter if I leave that line where it is or put it before the render, I get an exception undefined method `render_template' for # Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Sun Jun 20 09:03:48 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 08:03:48 -0500 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: <201006201430.53463.michael@schuerig.de> References: <201006201430.53463.michael@schuerig.de> Message-ID: <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: > On http://github.com/rspec/rspec-rails under "View specs" there's an > example > > describe "events/index.html.erb" do > it "renders _event partial for each event" do > assign(:events, [stub_model(Event), stub_model(Event)]) > render > view.should render_template(:partial => "_event", :count => 2) > end > end > > Is this indeed correct? From the outset, it looks wrong because it sets > an expectation (view.should ...) after the call to render. > > Then, no matter if I leave that line where it is or put it before the > render, I get an exception > > undefined method `render_template' for > # The README you're looking at is stored in git with git HEAD, and aligns with that code. This feature was added after the last release, and works as advertised if you're working with git HEAD, and will be part of the next release. If you're using an earlier release, then you should follow the README for that release: http://github.com/rspec/rspec-rails/tree/v2.0.0.beta.12 HTH, David From dchelimsky at gmail.com Sun Jun 20 09:06:47 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 08:06:47 -0500 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> Message-ID: On Jun 20, 2010, at 8:03 AM, David Chelimsky wrote: > > On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: > >> On http://github.com/rspec/rspec-rails under "View specs" there's an >> example >> >> describe "events/index.html.erb" do >> it "renders _event partial for each event" do >> assign(:events, [stub_model(Event), stub_model(Event)]) >> render >> view.should render_template(:partial => "_event", :count => 2) >> end >> end >> >> Is this indeed correct? From the outset, it looks wrong because it sets >> an expectation (view.should ...) after the call to render. Yeah - I see that this is confusing. Maybe we should change that to view.should have_rendered("..."). If so, we should also change response.should render_tempate("...") and response.should redirect_to("....") in controller specs. WDTY? >> >> Then, no matter if I leave that line where it is or put it before the >> render, I get an exception >> >> undefined method `render_template' for >> # > > The README you're looking at is stored in git with git HEAD, and aligns with that code. This feature was added after the last release, and works as advertised if you're working with git HEAD, and will be part of the next release. > > If you're using an earlier release, then you should follow the README for that release: http://github.com/rspec/rspec-rails/tree/v2.0.0.beta.12 > > HTH, > David > > From dchelimsky at gmail.com Sun Jun 20 09:09:46 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 08:09:46 -0500 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> Message-ID: <82013522-3D1A-4C1B-B9F6-95ACBA6AA0A9@gmail.com> On Jun 20, 2010, at 8:06 AM, David Chelimsky wrote: > On Jun 20, 2010, at 8:03 AM, David Chelimsky wrote: > >> >> On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: >> >>> On http://github.com/rspec/rspec-rails under "View specs" there's an >>> example >>> >>> describe "events/index.html.erb" do >>> it "renders _event partial for each event" do >>> assign(:events, [stub_model(Event), stub_model(Event)]) >>> render >>> view.should render_template(:partial => "_event", :count => 2) >>> end >>> end >>> >>> Is this indeed correct? From the outset, it looks wrong because it sets >>> an expectation (view.should ...) after the call to render. > > Yeah - I see that this is confusing. Maybe we should change that to view.should have_rendered("..."). If so, we should also change response.should render_tempate("...") and response.should redirect_to("....") in controller specs. > > WDTY? I'm also toying with an idea that would allow you to set an expectation before and have it evaluate at the end. Kind of like message expectations from the outside, but the underlying implementation would be different. Not sure if it would work, and I'm not sure if it would help (might just make things more confusing). WDYT? > >>> >>> Then, no matter if I leave that line where it is or put it before the >>> render, I get an exception >>> >>> undefined method `render_template' for >>> # >> >> The README you're looking at is stored in git with git HEAD, and aligns with that code. This feature was added after the last release, and works as advertised if you're working with git HEAD, and will be part of the next release. >> >> If you're using an earlier release, then you should follow the README for that release: http://github.com/rspec/rspec-rails/tree/v2.0.0.beta.12 >> >> HTH, >> David >> >> > From michael at schuerig.de Sun Jun 20 10:35:06 2010 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 20 Jun 2010 16:35:06 +0200 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> Message-ID: <201006201635.06920.michael@schuerig.de> On Sunday 20 June 2010, David Chelimsky wrote: > On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: > > On http://github.com/rspec/rspec-rails under "View specs" there's > > an example > > > > describe "events/index.html.erb" do > > > > it "renders _event partial for each event" do > > > > assign(:events, [stub_model(Event), stub_model(Event)]) > > render > > view.should render_template(:partial => "_event", :count => 2) > > > > end > > > > end > > > > Is this indeed correct? From the outset, it looks wrong because it > > sets an expectation (view.should ...) after the call to render. > > > > Then, no matter if I leave that line where it is or put it before > > the render, I get an exception > > > > undefined method `render_template' for > > # > > The README you're looking at is stored in git with git HEAD, and > aligns with that code. This feature was added after the last > release, and works as advertised if you're working with git HEAD, > and will be part of the next release. Oops, you're completely right, of course. > If you're using an earlier release, then you should follow the README > for that release: > http://github.com/rspec/rspec-rails/tree/v2.0.0.beta.12 That README doesn't say anything on the topic. This probably means that I have to wait for the next beta. I already found out, that I can set expectations with view.should_receive(:render) like I did in pre-2.0 with template.should_receive(:render). Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From michael at schuerig.de Sun Jun 20 10:38:42 2010 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 20 Jun 2010 16:38:42 +0200 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> Message-ID: <201006201638.42506.michael@schuerig.de> On Sunday 20 June 2010, David Chelimsky wrote: > On Jun 20, 2010, at 8:03 AM, David Chelimsky wrote: > > On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: > >> On http://github.com/rspec/rspec-rails under "View specs" there's > >> an example > >> > >> describe "events/index.html.erb" do > >> it "renders _event partial for each event" do > >> > >> assign(:events, [stub_model(Event), stub_model(Event)]) > >> render > >> view.should render_template(:partial => "_event", :count => 2) > >> > >> end > >> end > >> > >> Is this indeed correct? From the outset, it looks wrong because it > >> sets an expectation (view.should ...) after the call to render. > > Yeah - I see that this is confusing. Maybe we should change that to > view.should have_rendered("..."). If so, we should also change > response.should render_tempate("...") and response.should > redirect_to("....") in controller specs. That behavior would be more useful, in my opinion. In view and controller specs I like to put the render or get/post/... at the end of a begin block and then do the checks in the actual examples. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Sun Jun 20 11:16:31 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 10:16:31 -0500 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: <201006201635.06920.michael@schuerig.de> References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> <201006201635.06920.michael@schuerig.de> Message-ID: On Jun 20, 2010, at 9:35 AM, Michael Schuerig wrote: > On Sunday 20 June 2010, David Chelimsky wrote: >> On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: >>> On http://github.com/rspec/rspec-rails under "View specs" there's >>> an example >>> >>> describe "events/index.html.erb" do >>> >>> it "renders _event partial for each event" do >>> >>> assign(:events, [stub_model(Event), stub_model(Event)]) >>> render >>> view.should render_template(:partial => "_event", :count => 2) >>> >>> end >>> >>> end >>> >>> Is this indeed correct? From the outset, it looks wrong because it >>> sets an expectation (view.should ...) after the call to render. >>> >>> Then, no matter if I leave that line where it is or put it before >>> the render, I get an exception >>> >>> undefined method `render_template' for >>> # >> >> The README you're looking at is stored in git with git HEAD, and >> aligns with that code. This feature was added after the last >> release, and works as advertised if you're working with git HEAD, >> and will be part of the next release. > > Oops, you're completely right, of course. > >> If you're using an earlier release, then you should follow the README >> for that release: >> http://github.com/rspec/rspec-rails/tree/v2.0.0.beta.12 > > That README doesn't say anything on the topic. This probably means that > I have to wait for the next beta. I already found out, that I can set > expectations with view.should_receive(:render) like I did in pre-2.0 > with template.should_receive(:render). That doesn't actually work like it did in 1.x, because the rails internals have changed: it "renders the edit gadget form" do view.should_receive(:render).with(:partial => "_form") render end $ rspec spec/views/gadgets/edit.html.erb_spec.rb F 1) gadgets/edit.html.erb renders the edit gadget form Failure/Error: render # received :render with unexpected arguments expected: ({:partial=>"_form"}) got: ({:template=>"gadgets/edit.html.erb"}, {}) You have to say this instead: it "renders the edit gadget form" do view.should_receive(:_render_partial).with(hash_including(:partial => "form")) render end ... which is a bit of a kludge and subject to changes in rails' internals. That's why I want to use "render_template", which delegates to "assert_template", which is a rails API and less likely to break. Make sense? > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From michael at schuerig.de Sun Jun 20 12:21:23 2010 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 20 Jun 2010 18:21:23 +0200 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: References: <201006201430.53463.michael@schuerig.de> <201006201635.06920.michael@schuerig.de> Message-ID: <201006201821.23642.michael@schuerig.de> On Sunday 20 June 2010, David Chelimsky wrote: > On Jun 20, 2010, at 9:35 AM, Michael Schuerig wrote: > > I already found out, that I > > can set expectations with view.should_receive(:render) like I did > > in pre-2.0 with template.should_receive(:render). > > That doesn't actually work like it did in 1.x, because the rails > internals have changed: Yes, I mis-typed. It should have been "can't". Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From win at wincent.com Sun Jun 20 11:34:19 2010 From: win at wincent.com (Wincent Colaiuta) Date: Sun, 20 Jun 2010 17:34:19 +0200 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: <82013522-3D1A-4C1B-B9F6-95ACBA6AA0A9@gmail.com> References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> <82013522-3D1A-4C1B-B9F6-95ACBA6AA0A9@gmail.com> Message-ID: El 20/06/2010, a las 15:09, David Chelimsky escribi?: > > On Jun 20, 2010, at 8:06 AM, David Chelimsky wrote: > >> On Jun 20, 2010, at 8:03 AM, David Chelimsky wrote: >> >>> >>> On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: >>> >>>> On http://github.com/rspec/rspec-rails under "View specs" there's an >>>> example >>>> >>>> describe "events/index.html.erb" do >>>> it "renders _event partial for each event" do >>>> assign(:events, [stub_model(Event), stub_model(Event)]) >>>> render >>>> view.should render_template(:partial => "_event", :count => 2) >>>> end >>>> end >>>> >>>> Is this indeed correct? From the outset, it looks wrong because it sets >>>> an expectation (view.should ...) after the call to render. >> >> Yeah - I see that this is confusing. Maybe we should change that to view.should have_rendered("..."). If so, we should also change response.should render_tempate("...") and response.should redirect_to("....") in controller specs. >> >> WDTY? > > I'm also toying with an idea that would allow you to set an expectation before and have it evaluate at the end. Kind of like message expectations from the outside, but the underlying implementation would be different. Was going to suggest exactly that. Although the implementation would be different from normal message expectations, I wonder if it could be built on top of them. > Not sure if it would work, and I'm not sure if it would help (might just make things more confusing). WDYT? I'm not sure either, but I suspect it would be more consistent with the way we set up our other expectations. ie. - when we are testing interactions, we usually use message expectations that are set up beforehand - when we are testing state, we perform some action and then inspect the state (usually expressed using present tense eg. "should be") The "should have_rendered" (past tense) idea doesn't really fit in, with those two styles either conceptually or grammatically. Cheers, Wincent From dchelimsky at gmail.com Sun Jun 20 13:59:39 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 12:59:39 -0500 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> <82013522-3D1A-4C1B-B9F6-95ACBA6AA0A9@gmail.com> Message-ID: <83F4487B-EF14-43BA-8CB5-585A39D4270E@gmail.com> On Jun 20, 2010, at 10:34 AM, Wincent Colaiuta wrote: > El 20/06/2010, a las 15:09, David Chelimsky escribi?: > >> >> On Jun 20, 2010, at 8:06 AM, David Chelimsky wrote: >> >>> On Jun 20, 2010, at 8:03 AM, David Chelimsky wrote: >>> >>>> >>>> On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: >>>> >>>>> On http://github.com/rspec/rspec-rails under "View specs" there's an >>>>> example >>>>> >>>>> describe "events/index.html.erb" do >>>>> it "renders _event partial for each event" do >>>>> assign(:events, [stub_model(Event), stub_model(Event)]) >>>>> render >>>>> view.should render_template(:partial => "_event", :count => 2) >>>>> end >>>>> end >>>>> >>>>> Is this indeed correct? From the outset, it looks wrong because it sets >>>>> an expectation (view.should ...) after the call to render. >>> >>> Yeah - I see that this is confusing. Maybe we should change that to view.should have_rendered("..."). If so, we should also change response.should render_tempate("...") and response.should redirect_to("....") in controller specs. >>> >>> WDTY? >> >> I'm also toying with an idea that would allow you to set an expectation before and have it evaluate at the end. Kind of like message expectations from the outside, but the underlying implementation would be different. > > Was going to suggest exactly that. > > Although the implementation would be different from normal message expectations, I wonder if it could be built on top of them. That's the idea. I'm working on a pub/sub API for events like example_started, example_initialized, example_executed, example_finished (do those names make sense to you?). You can see that work on the events branch of rspec-core: http://github.com/rspec/rspec-core/tree/events. Please feel free to provide any feedback on the direction - just note that it is preliminary and incomplete :) I'm pretty sure I'll be able to use that to write matchers that pause evaluation until they receive the example_executed message. >> Not sure if it would work, and I'm not sure if it would help (might just make things more confusing). WDYT? > > I'm not sure either, but I suspect it would be more consistent with the way we set up our other expectations. > > ie. - when we are testing interactions, we usually use message expectations that are set up beforehand > > - when we are testing state, we perform some action and then inspect the state (usually expressed using present tense eg. "should be") > > The "should have_rendered" (past tense) idea doesn't really fit in, with those two styles either conceptually or grammatically. This is an odd bird because it's delegating to a rails method named assert_template, which is intended to be evaluated after the action. The underlying implementation looks at a hash that AC::TestCase::Behavior builds up during the test, so it's not quite a message expectation (verifying upon receipt of the message). So I think have_rendered is more accurate, but you have to understand the implementation to understand that :) The other thing is that message expectations on real objects don't typically invoke the expected methods. In this case, the partial is actually being rendered, so putting "view.should render_template('...')" before the action could be confusing. One thought is to add a custom resolver that finds the first requested template for real, but then stubs out the remaining templates (a la the NullResolver used in controller specs). That would make controller specs and view specs work the same way, maybe with a render_partials method in view specs to tell it to render the partials (like render_views in view specs). An alternative would be to make the "view.should render_template" stub out the suggested template if called before the action? Then it would work a lot more like real message expectations. Thoughts? > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From daniel.amselem at gmail.com Sun Jun 20 14:58:52 2010 From: daniel.amselem at gmail.com (Daniel Salmeron Amselem) Date: Sun, 20 Jun 2010 11:58:52 -0700 (PDT) Subject: [rspec-users] rspec-rails 2.0.0.beta.12 showing undefined method error for route_to Message-ID: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> First of all, I've been trying to find an answer for this problem all over the internet without luck. The thing is that I am using RVM with ruby 1.9.2-head and I created a new empty gemset. Then I installed bundler gem with: gem bundler install That installed the library into the /Users/damselem/.rvm/gems/ ruby-1.9.2-head at rails3/gems directory. Then I went to my rails 3 app directory and I ran "bundle install" which showed this: http://gist.github.com/446011 and when I ran gem list I got: http://gist.github.com/446005 Everything seems perfect, but when running some route specs I got an undefined method error for route_to method. I've checked in the github repository and it actually exists. So I decided to look inside the library but I couldn't find the /rspec/rails/matchers/ routing_spec_matchers.rb directory and either the matchers directory. So, my question is: Why is not the file in there? Why is not the matchers directory either? Then I found under /Users/damselem/.rvm/gems/ruby-1.9.2-head at rails3/ a bundler directory with some gems, and with folder names like: devise-d498cf3a4e1a3fef3f4f071d4feec6a489efe480-master formtastic-8ab93b34c3a97eee21e38185e14bed2f769c81e5-rails3 shoulda-b78dbf514bbce3272023d3a4742474857c2eb3c3-master Why is that? Why there are two different directories for gems? Why are devise, formtastic and shoulda not in the gems directory? Thank you very much, and sorry for asking so many questions, but I'm quite lost with all this. From win at wincent.com Sun Jun 20 15:08:43 2010 From: win at wincent.com (Wincent Colaiuta) Date: Sun, 20 Jun 2010 21:08:43 +0200 Subject: [rspec-users] RSpec 2 view example: render_template In-Reply-To: <83F4487B-EF14-43BA-8CB5-585A39D4270E@gmail.com> References: <201006201430.53463.michael@schuerig.de> <98CCAEF4-16D7-4665-8C52-DA1F8D6D83BF@gmail.com> <82013522-3D1A-4C1B-B9F6-95ACBA6AA0A9@gmail.com> <83F4487B-EF14-43BA-8CB5-585A39D4270E@gmail.com> Message-ID: <9B2714BC-B92F-4516-BB0F-57F7B42CC259@wincent.com> El 20/06/2010, a las 19:59, David Chelimsky escribi?: > On Jun 20, 2010, at 10:34 AM, Wincent Colaiuta wrote: > >> El 20/06/2010, a las 15:09, David Chelimsky escribi?: >> >>> >>> On Jun 20, 2010, at 8:06 AM, David Chelimsky wrote: >>> >>>> On Jun 20, 2010, at 8:03 AM, David Chelimsky wrote: >>>> >>>>> >>>>> On Jun 20, 2010, at 7:30 AM, Michael Schuerig wrote: >>>>> >>>>>> On http://github.com/rspec/rspec-rails under "View specs" there's an >>>>>> example >>>>>> >>>>>> describe "events/index.html.erb" do >>>>>> it "renders _event partial for each event" do >>>>>> assign(:events, [stub_model(Event), stub_model(Event)]) >>>>>> render >>>>>> view.should render_template(:partial => "_event", :count => 2) >>>>>> end >>>>>> end >>>>>> >>>>>> Is this indeed correct? From the outset, it looks wrong because it sets >>>>>> an expectation (view.should ...) after the call to render. >>>> >>>> Yeah - I see that this is confusing. Maybe we should change that to view.should have_rendered("..."). If so, we should also change response.should render_tempate("...") and response.should redirect_to("....") in controller specs. >>>> >>>> WDTY? >>> >>> I'm also toying with an idea that would allow you to set an expectation before and have it evaluate at the end. Kind of like message expectations from the outside, but the underlying implementation would be different. >> >> Was going to suggest exactly that. >> >> Although the implementation would be different from normal message expectations, I wonder if it could be built on top of them. > > That's the idea. I'm working on a pub/sub API for events like example_started, example_initialized, example_executed, example_finished (do those names make sense to you?). You can see that work on the events branch of rspec-core: http://github.com/rspec/rspec-core/tree/events. Please feel free to provide any feedback on the direction - just note that it is preliminary and incomplete :) > > I'm pretty sure I'll be able to use that to write matchers that pause evaluation until they receive the example_executed message. > >>> Not sure if it would work, and I'm not sure if it would help (might just make things more confusing). WDYT? >> >> I'm not sure either, but I suspect it would be more consistent with the way we set up our other expectations. >> >> ie. - when we are testing interactions, we usually use message expectations that are set up beforehand >> >> - when we are testing state, we perform some action and then inspect the state (usually expressed using present tense eg. "should be") >> >> The "should have_rendered" (past tense) idea doesn't really fit in, with those two styles either conceptually or grammatically. > > This is an odd bird because it's delegating to a rails method named assert_template, which is intended to be evaluated after the action. The underlying implementation looks at a hash that AC::TestCase::Behavior builds up during the test, so it's not quite a message expectation (verifying upon receipt of the message). So I think have_rendered is more accurate, but you have to understand the implementation to understand that :) Yes, and being an implementation detail, you shouldn't really be worrying about whether the "language" used by RSpec is "true" to the underlying mechanism or not. I think it's more important for you to design your language first, keeping it consistent with the philosophy behind the design of the rest of RSpec (a philosophy which you probably know better than anyone). > The other thing is that message expectations on real objects don't typically invoke the expected methods. In this case, the partial is actually being rendered, so putting "view.should render_template('...')" before the action could be confusing. > > One thought is to add a custom resolver that finds the first requested template for real, but then stubs out the remaining templates (a la the NullResolver used in controller specs). That would make controller specs and view specs work the same way, maybe with a render_partials method in view specs to tell it to render the partials (like render_views in view specs). > > An alternative would be to make the "view.should render_template" stub out the suggested template if called before the action? Then it would work a lot more like real message expectations. > > Thoughts? I don't know enough about this to speak with much authority, but from my fairly ignorant perspective as a mere "consumer" of the Rails and testing machinery, that last option you suggest immediately sounds like the simplest one, and in general I think simple solutions often end up being the best ones (or at least the ones worth investigating first)... Wincent From michael at schuerig.de Sun Jun 20 16:19:55 2010 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 20 Jun 2010 22:19:55 +0200 Subject: [rspec-users] RSpec 2 view specs: partial mocks Message-ID: <201006202219.55672.michael@schuerig.de> Are partial mocks supposed to work in rails-rspec 2.0.0.beta.12? I'm trying to do things like view.stub(:current_user).and_return(@user) view.stub(:current_page?).and_return(false) However, when I do that, the view uses its "ordinary" functionality, in particular, assigns are no longer available as instance variables. Also, as regards mocking of partials (the rails ones) view.should_receive(:_render_partial). with(hash_including(:partial => "widget/row")) does not work as expected when render is called with objects like this render @article render @articles In these cases the hash[:partial] does not contain the path to the template, but the object(s). I'm right now having little fun in beta hell. That's just how it is and by no means intend to distract you from your good work. I'm not yet reasonably familiar with Rails 3 and RSpec 2 and so I'm stumbling around alot in the sources and inch along in the debugger. One repeating point of bother is that often stacktraces are barely informative when delegation and dynamically generated code are in there. Unfortunately, I can't think of a way to improve on this. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Sun Jun 20 17:48:36 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 16:48:36 -0500 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <201006202219.55672.michael@schuerig.de> References: <201006202219.55672.michael@schuerig.de> Message-ID: On Jun 20, 2010, at 3:19 PM, Michael Schuerig wrote: > Are partial mocks supposed to work in rails-rspec 2.0.0.beta.12? > > I'm trying to do things like > > view.stub(:current_user).and_return(@user) > view.stub(:current_page?).and_return(false) > > However, when I do that, the view uses its "ordinary" functionality, in > particular, assigns are no longer available as instance variables. Are you using rails beta 4? Before that release, the view() method returned a different object every time. > Also, as regards mocking of partials (the rails ones) > > view.should_receive(:_render_partial). > with(hash_including(:partial => "widget/row")) > > does not work as expected when render is called with objects like this > > render @article > render @articles > > In these cases the hash[:partial] does not contain the path to the > template, but the object(s). view.should_receive(:anything_at_all) is specifying rails internals, and has to be 100% precise. In this case, what you need to do is pretty invasive, and I wouldn't recommend it, but here it is: require 'spec_helper' describe "widgets/index.html.erb" do before(:each) do @widgets = assign(:widgets, [ stub_model(Widget), stub_model(Widget) ]) end it "renders a list of widgets" do view.stub(:_render_partial) view.should_receive(:_render_partial).with(hash_including(:partial => @widgets[0])) view.should_receive(:_render_partial).with(hash_including(:partial => @widgets[1])) render end end Can I hear a "blech!!!!!!!!!!!!". Unfortunately, there is not a better way to do this yet, and there may not be for some time. One of the big wins of rspec-rails-2 over rspec-rails-1 is that it does not rely on monkey patches (except in cases in which rails has changed since the last rails release, but rspec-rails needs to work with the last release). This drastically reduces the likelihood that rails releases will break rspec, which has been a big pain-point in the past. The downside of this is that we have to live with what Rails has to offer, and view tests are not nearly as robust as controller tests in rails. Yet :) Cheers, David > I'm right now having little fun in beta hell. That's just how it is and > by no means intend to distract you from your good work. I'm not yet > reasonably familiar with Rails 3 and RSpec 2 and so I'm stumbling around > alot in the sources and inch along in the debugger. One repeating point > of bother is that often stacktraces are barely informative when > delegation and dynamically generated code are in there. Unfortunately, I > can't think of a way to improve on this. > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From michael at schuerig.de Sun Jun 20 18:18:50 2010 From: michael at schuerig.de (Michael Schuerig) Date: Mon, 21 Jun 2010 00:18:50 +0200 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: References: <201006202219.55672.michael@schuerig.de> Message-ID: <201006210018.50458.michael@schuerig.de> On Sunday 20 June 2010, David Chelimsky wrote: > On Jun 20, 2010, at 3:19 PM, Michael Schuerig wrote: > > Are partial mocks supposed to work in rails-rspec 2.0.0.beta.12? > > > > I'm trying to do things like > > > > view.stub(:current_user).and_return(@user) > > view.stub(:current_page?).and_return(false) > > > > However, when I do that, the view uses its "ordinary" > > functionality, in particular, assigns are no longer available as > > instance variables. > > Are you using rails beta 4? Before that release, the view() method > returned a different object every time. Yes, 3.0.0.beta4. TestCase#_view caches its return value. > view.should_receive(:anything_at_all) is specifying rails internals, > and has to be 100% precise. In this case, what you need to do is > pretty invasive, and I wouldn't recommend it, but here it is: > > require 'spec_helper' > > describe "widgets/index.html.erb" do > before(:each) do > @widgets = assign(:widgets, [ > stub_model(Widget), > stub_model(Widget) > ]) > end > > it "renders a list of widgets" do > view.stub(:_render_partial) > > view.should_receive(:_render_partial).with(hash_including(:partial > => @widgets[0])) > view.should_receive(:_render_partial).with(hash_including(:partial > => @widgets[1])) > > render > end > end > > Can I hear a "blech!!!!!!!!!!!!". > > Unfortunately, there is not a better way to do this yet, and there > may not be for some time. It's okay, if I hide away the yucky bits in a helper method. # spec/support/partial_helpers.rb module PartialHelpers def should_render(options) options.assert_valid_keys(:partial, :count) view.should_receive(:_render_partial). with(hash_including(:partial => options[:partial])) end def should_not_render(options) options.assert_valid_keys(:partial, :count) view.should_not_receive(:_render_partial). with(hash_including(:partial => options[:partial])) end end # in spec/spec_helpers.rb config.include PartialHelpers, :example_group => { :description => lambda { |description| # FIXME this is a kludge as there is # currently (rspec 2.0.0.beta.12) # apparently no other way to identify a view # example group. description =~ /\.html\.erb$/ } } Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Sun Jun 20 18:44:17 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 20 Jun 2010 17:44:17 -0500 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <201006210018.50458.michael@schuerig.de> References: <201006202219.55672.michael@schuerig.de> <201006210018.50458.michael@schuerig.de> Message-ID: <81C7FBE0-DB4C-4288-9618-CEA11F9031FC@gmail.com> On Jun 20, 2010, at 5:18 PM, Michael Schuerig wrote: > > # in spec/spec_helpers.rb > config.include PartialHelpers, :example_group => { > :description => lambda { |description| > # FIXME this is a kludge as there is > # currently (rspec 2.0.0.beta.12) > # apparently no other way to identify a view > # example group. > description =~ /\.html\.erb$/ > } > } Here's how rspec-rails-2 does it: http://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example/view_example_group.rb#L106 From michael at schuerig.de Sun Jun 20 18:59:41 2010 From: michael at schuerig.de (Michael Schuerig) Date: Mon, 21 Jun 2010 00:59:41 +0200 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <81C7FBE0-DB4C-4288-9618-CEA11F9031FC@gmail.com> References: <201006202219.55672.michael@schuerig.de> <201006210018.50458.michael@schuerig.de> <81C7FBE0-DB4C-4288-9618-CEA11F9031FC@gmail.com> Message-ID: <201006210059.42349.michael@schuerig.de> On Monday 21 June 2010, David Chelimsky wrote: > On Jun 20, 2010, at 5:18 PM, Michael Schuerig wrote: > > # in spec/spec_helpers.rb > > > > config.include PartialHelpers, :example_group => { > > > > :description => lambda { |description| > > : > > # FIXME this is a kludge as there is > > # currently (rspec 2.0.0.beta.12) > > # apparently no other way to identify a view > > # example group. > > description =~ /\.html\.erb$/ > > > > } > > > > } > > Here's how rspec-rails-2 does it: > http://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/exam > ple/view_example_group.rb#L106 Thanks, that's better. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From daniel.amselem at gmail.com Mon Jun 21 07:56:28 2010 From: daniel.amselem at gmail.com (Daniel Salmeron Amselem) Date: Mon, 21 Jun 2010 04:56:28 -0700 (PDT) Subject: [rspec-users] rspec-rails 2.0.0.beta.12 showing undefined method error for route_to In-Reply-To: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> References: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> Message-ID: <1ffe8b03-6427-4a3b-9cd0-2f1b452b9fe9@y4g2000yqy.googlegroups.com> I forgot to add the error: 1) AccountsController Routes should route to new action with GET Failure/Error: { :get => "/accounts/new" }.should route_to(:controller => "accounts", :action => "new") undefined method `route_to' for # # /Users/damselem/.rvm/gems/ruby-1.9.1-p378 at rails3/gems/ actionpack-3.0.0.beta4/lib/action_dispatch/testing/assertions/ routing.rb:175:in `method_missing' # ./spec/controllers/accounts_controller_spec.rb:8:in `block (3 levels) in ' On Jun 20, 8:58?pm, Daniel Salmeron Amselem wrote: > First of all, I've been trying to find an answer for this problem all > over the internet without luck. > > The thing is that I am using RVM with ruby 1.9.2-head and I created a > new empty gemset. Then I installed bundler gem with: > > gem bundler install > > That installed the library into the /Users/damselem/.rvm/gems/ > ruby-1.9.2-head at rails3/gems directory. Then I went to my rails 3 app > directory and I ran "bundle install" which showed this: > > http://gist.github.com/446011 > > and when I ran gem list I got: > > http://gist.github.com/446005 > > Everything seems perfect, but when running some route specs I got an > undefined method error for route_to method. I've checked in the github > repository and it actually exists. So I decided to look inside the > library but I couldn't find the /rspec/rails/matchers/ > routing_spec_matchers.rb directory and either the matchers directory. > So, my question is: Why is not the file in there? Why is not the > matchers directory either? > > Then I found under /Users/damselem/.rvm/gems/ruby-1.9.2-head at rails3/ a > bundler directory with some gems, and with folder names like: > > devise-d498cf3a4e1a3fef3f4f071d4feec6a489efe480-master > formtastic-8ab93b34c3a97eee21e38185e14bed2f769c81e5-rails3 > shoulda-b78dbf514bbce3272023d3a4742474857c2eb3c3-master > > Why is that? Why there are two different directories for gems? Why are > devise, formtastic and shoulda not in the gems directory? > > Thank you very much, and sorry for asking so many questions, but I'm > quite lost with all this. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lbocseg at yahoo.com.br Mon Jun 21 21:00:38 2010 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Mon, 21 Jun 2010 22:00:38 -0300 Subject: [rspec-users] rspec-rails 2 webrat dependency In-Reply-To: References: <4C1CF938.1070709@yahoo.com.br> Message-ID: <4C200B36.2040300@yahoo.com.br> Em 19-06-2010 16:12, Rick DeNatale escreveu: > On Sat, Jun 19, 2010 at 1:07 PM, Rodrigo Rosenfeld Rosas > wrote: > >> Is there any reason for that? If so, couldn't Rspec use Capybara instead of >> Webrat if it is not present? Is it possible to depend on Webrat OR Capybara >> in the gem specs? >> > Gemspecs don't allow alternative dependencies. > > I have a similar issue with the RiCal gem. It works with either the > activesupport OR tzinfo gems, rather than require either I just > document that it requires one or the other and leave it up to the > user. > Maybe Rspec should keep depending on Webrat instead for allowing easy installation until Gemspecs support alternative dependencies. It is not that bad for those using Capybara and maybe Capybara will merge to Webrat anyway... Thank you for your information, Rodrigo. __________________________________________________ Fale com seus amigos de gra?a com o novo Yahoo! Messenger http://br.messenger.yahoo.com/ From danielvlopes at gmail.com Tue Jun 22 01:05:30 2010 From: danielvlopes at gmail.com (Daniel Lopes) Date: Mon, 21 Jun 2010 22:05:30 -0700 (PDT) Subject: [rspec-users] Issue when run my specs in Textmate but not in terminal Message-ID: Hello, I'm experiencing a weird behavior that I cant find the solution. My specs that depends on Factory Girl with attachment only works in command line and not in Textmate with Command+R or Command +Shift+R. My app uses rspec 1.3, rspec-rails 1.3.2, factory-girl 1.2.4 and Rails 2.3.5 with paperclip. Right now I have a simple factory: Factory.define(:product) do |p| p.display_name "Things for iPhone" p.price 9.99 p.attach "icon", "spec/fixtures/images/app_icon.png", "image/ png" end The attach method above is defined in the same way as below (in a initializer file): http://gist.github.com/447996 Any time that I try use the factory above my specs fail with this message: Validation failed: Icon /var/folders/CT/CT5WXMvBHIWX2jTklhOUh++++TI/- Tmp-/stream20100622-9804-1ynydgk-0 is not recognized by the 'identify' command. Somebody have any idea of what it can be? Thanks a lot. From celoserpa at gmail.com Tue Jun 22 02:16:15 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Tue, 22 Jun 2010 01:16:15 -0500 Subject: [rspec-users] Bundler, rake spec and Steak Message-ID: Hello list, I have noted a few problems when using rake spec. First, it doesn't seem to load the gems from the Gemfile (:test group) I had to add a required for each gem in this group on the spec_helper.rb file when I tried to run the tests vai rake spec, if I use the spec command, it works as expected. Another thing -- I'm using Steak for acceptance testing. Steak puts its tests under spec/acceptance. Each Steak test uses the acceptance_helper.rb helper script. This helper also automatically loads any ruby script from spec/acceptance/support/*.rb. The issue here is that, when I run rake spec, it is running acceptance tests as well, which would not be a problem if some support scripts from it set *not to use transactional fixtures* and setup DatabaseCleaner, and messes up with the rest of the specs. Any ideas on how to exclude acceptance tests from the rake spec? And if anyone else knows how to get it to know about Bundler, better :) Thanks, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rogerdpack at gmail.com Tue Jun 22 03:09:17 2010 From: rogerdpack at gmail.com (rogerdpack) Date: Tue, 22 Jun 2010 00:09:17 -0700 (PDT) Subject: [rspec-users] cleaner failure messages? In-Reply-To: <96DCFA5E-E1FC-414E-90F1-658AE3CE4020@gmail.com> References: <8e514768-118b-4fb1-a757-82d7f834c7d7@s4g2000prh.googlegroups.com> <96DCFA5E-E1FC-414E-90F1-658AE3CE4020@gmail.com> Message-ID: > > The skinny of this request is that I'd find it more useful to actually > > have the code displayed that failed on line 14, in this case, the word > > "fail" ... > Already done in rspec-2. Likely won't backport it to rspec-1 for some time (if ever). Nice. Looks like rspec-2 will fit the bill for me for now, then. 1) Gem speeding Gem.bin_path the fake sick way should fake guess the right path instead of loading full rubygems for now Failure/Error: Unable to find matching line from backtrace # spec.faster_rubygems.rb:29 # spec.faster_rubygems.rb:13 Perhaps it isn't quite windows friendly? Thanks. -rp From win at wincent.com Tue Jun 22 03:37:15 2010 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 22 Jun 2010 09:37:15 +0200 Subject: [rspec-users] Bundler, rake spec and Steak In-Reply-To: References: Message-ID: <9E748F68-C974-4C5C-94E4-DF33CEFD14B3@wincent.com> El 22/06/2010, a las 08:16, Marcelo de Moraes Serpa escribi?: > Hello list, > > I have noted a few problems when using rake spec. First, it doesn't seem to > load the gems from the Gemfile (:test group) I had to add a required for > each gem in this group on the spec_helper.rb file when I tried to run the > tests vai rake spec, if I use the spec command, it works as expected. Unfortunately I can't help you here. At least with the versions I'm using (rspec-rails 2.0.0.beta.12, steak 0.4.0.beta.1, rails 3.0.0.beta.4) I haven't noted any problems. > Another thing -- I'm using Steak for acceptance testing. Steak puts its > tests under spec/acceptance. Each Steak test uses the acceptance_helper.rb > helper script. This helper also automatically loads any ruby script from > spec/acceptance/support/*.rb. The issue here is that, when I run rake spec, > it is running acceptance tests as well, which would not be a problem if some > support scripts from it set *not to use transactional fixtures* and setup > DatabaseCleaner, and messes up with the rest of the specs. > > Any ideas on how to exclude acceptance tests from the rake spec? There is nothing intrinsically "special" about the "spec/acceptance" directory so you could move that somewhere else (for example, Cucumber sticks its features in a top-level "features" directory and you could do the same kind of thing). The only thing is the generator included with Steak will keep putting the files into "spec/acceptance" unless you tweak the generator yourself, or choose not to use it. Also, the "spec:acceptance" Rake task defined by Steak in "lib/tasks/steak.rake" would need to be updated to refer to your new path. If all of this seems like too much work, you could try posting a ticket on the Steak tracker asking Luismi to consider changing the location of the files: http://github.com/cavalle/steak/issues He is usually very responsive, and I'm sure that he'll either give you what your asking for, or explain why it can't be that way. Cheers, Wincent From dchelimsky at gmail.com Tue Jun 22 08:40:19 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 22 Jun 2010 07:40:19 -0500 Subject: [rspec-users] cleaner failure messages? In-Reply-To: References: <8e514768-118b-4fb1-a757-82d7f834c7d7@s4g2000prh.googlegroups.com> <96DCFA5E-E1FC-414E-90F1-658AE3CE4020@gmail.com> Message-ID: On Jun 22, 2010, at 2:09 AM, rogerdpack wrote: >>> The skinny of this request is that I'd find it more useful to actually >>> have the code displayed that failed on line 14, in this case, the word >>> "fail" > ... >> Already done in rspec-2. Likely won't backport it to rspec-1 for some time (if ever). > > Nice. Looks like rspec-2 will fit the bill for me for now, then. > > 1) Gem speeding Gem.bin_path the fake sick way should fake guess the > right path instead of loading full rubygems for now > Failure/Error: Unable to find matching line from backtrace > # spec.faster_rubygems.rb:29 > # spec.faster_rubygems.rb:13 > > Perhaps it isn't quite windows friendly? That happens now and then when the error is in code generated with eval(string) with no file and ref numbers. Has nothing to do with Windows as far as I know, and is the same problem we have with ruby-debug. HTH, David From michael at schuerig.de Tue Jun 22 09:27:09 2010 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 22 Jun 2010 15:27:09 +0200 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <201006202219.55672.michael@schuerig.de> References: <201006202219.55672.michael@schuerig.de> Message-ID: <201006221527.09564.michael@schuerig.de> On Sunday 20 June 2010, Michael Schuerig wrote: > Are partial mocks supposed to work in rails-rspec 2.0.0.beta.12? > > I'm trying to do things like > > view.stub(:current_user).and_return(@user) > view.stub(:current_page?).and_return(false) > > However, when I do that, the view uses its "ordinary" functionality, > in particular, assigns are no longer available as instance > variables. I've found the reason: rspec- rails-2.0.0.beta.12/lib/rspec/rails/monkey/action_view/test_case.rb def _view @_view ||= begin view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller) ... view end end #_view (and #view in turn) creates just one ActionView::Base instance the first time it is called. That's as it is intended. The effect is, however, that only assigns up to that point are passed to that instance. Consequently, later assigns are ignored. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Tue Jun 22 09:58:09 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 22 Jun 2010 08:58:09 -0500 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <201006221527.09564.michael@schuerig.de> References: <201006202219.55672.michael@schuerig.de> <201006221527.09564.michael@schuerig.de> Message-ID: <255BB339-692D-40E6-9023-DDC510E05935@gmail.com> On Jun 22, 2010, at 8:27 AM, Michael Schuerig wrote: > On Sunday 20 June 2010, Michael Schuerig wrote: >> Are partial mocks supposed to work in rails-rspec 2.0.0.beta.12? >> >> I'm trying to do things like >> >> view.stub(:current_user).and_return(@user) >> view.stub(:current_page?).and_return(false) >> >> However, when I do that, the view uses its "ordinary" functionality, >> in particular, assigns are no longer available as instance >> variables. > > I've found the reason: > > rspec- > rails-2.0.0.beta.12/lib/rspec/rails/monkey/action_view/test_case.rb > > def _view > @_view ||= begin > view = ActionView::Base.new(ActionController::Base.view_paths, > _assigns, @controller) > ... > view > end > end > > #_view (and #view in turn) creates just one ActionView::Base instance > the first time it is called. That's as it is intended. The effect is, > however, that only assigns up to that point are passed to that instance. > Consequently, later assigns are ignored. Stubs and assigns are unrelated, so even though this might be a bug, I don't think it's the cause of what you're seeing. From michael at schuerig.de Tue Jun 22 10:58:03 2010 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 22 Jun 2010 16:58:03 +0200 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <255BB339-692D-40E6-9023-DDC510E05935@gmail.com> References: <201006202219.55672.michael@schuerig.de> <201006221527.09564.michael@schuerig.de> <255BB339-692D-40E6-9023-DDC510E05935@gmail.com> Message-ID: <201006221658.04028.michael@schuerig.de> On Tuesday 22 June 2010, David Chelimsky wrote: > On Jun 22, 2010, at 8:27 AM, Michael Schuerig wrote: > > #_view (and #view in turn) creates just one ActionView::Base > > instance the first time it is called. That's as it is intended. > > The effect is, however, that only assigns up to that point are > > passed to that instance. Consequently, later assigns are ignored. > > Stubs and assigns are unrelated, so even though this might be a bug, > I don't think it's the cause of what you're seeing. It is. If I put all the assign(:x, value) before I first access #view, everything works as expected. The problem I had is entirely unrelated to stubs. It's just that when I do things in this order view.stub(:something).and_return('foo') assign(:bar, 10) The assign doesn't have an effect. I might as well have view.flash[:notice] = 'Something is rotten.' assign(:bar, 10) and the effect would be the same. Assigns that come after the view is first initialized are ignored. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Tue Jun 22 11:06:43 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 22 Jun 2010 10:06:43 -0500 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <201006221658.04028.michael@schuerig.de> References: <201006202219.55672.michael@schuerig.de> <201006221527.09564.michael@schuerig.de> <255BB339-692D-40E6-9023-DDC510E05935@gmail.com> <201006221658.04028.michael@schuerig.de> Message-ID: <9C65ECC6-BBA0-4120-9C54-B3AE2F971CF4@gmail.com> On Jun 22, 2010, at 9:58 AM, Michael Schuerig wrote: > On Tuesday 22 June 2010, David Chelimsky wrote: >> On Jun 22, 2010, at 8:27 AM, Michael Schuerig wrote: > >>> #_view (and #view in turn) creates just one ActionView::Base >>> instance the first time it is called. That's as it is intended. >>> The effect is, however, that only assigns up to that point are >>> passed to that instance. Consequently, later assigns are ignored. >> >> Stubs and assigns are unrelated, so even though this might be a bug, >> I don't think it's the cause of what you're seeing. > > It is. If I put all the assign(:x, value) before I first access #view, > everything works as expected. The problem I had is entirely unrelated to > stubs. Well, to be fair, the initial problem you cited in this thread (even in the subject line) is "partial mocks", not "assigns." That said, yes, this is a bug. I'll see if we can do something about that in Rails proper rather than rspec, which is just decorating the rails behavior. Cheers, David > It's just that when I do things in this order > > view.stub(:something).and_return('foo') > assign(:bar, 10) > > The assign doesn't have an effect. I might as well have > > view.flash[:notice] = 'Something is rotten.' > assign(:bar, 10) > > and the effect would be the same. Assigns that come after the view is > first initialized are ignored. From dchelimsky at gmail.com Tue Jun 22 11:16:21 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 22 Jun 2010 10:16:21 -0500 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <9C65ECC6-BBA0-4120-9C54-B3AE2F971CF4@gmail.com> References: <201006202219.55672.michael@schuerig.de> <201006221527.09564.michael@schuerig.de> <255BB339-692D-40E6-9023-DDC510E05935@gmail.com> <201006221658.04028.michael@schuerig.de> <9C65ECC6-BBA0-4120-9C54-B3AE2F971CF4@gmail.com> Message-ID: <45AD562E-FBBB-46E3-B337-691EDFAF7391@gmail.com> On Jun 22, 2010, at 10:06 AM, David Chelimsky wrote: > > On Jun 22, 2010, at 9:58 AM, Michael Schuerig wrote: > >> On Tuesday 22 June 2010, David Chelimsky wrote: >>> On Jun 22, 2010, at 8:27 AM, Michael Schuerig wrote: >> >>>> #_view (and #view in turn) creates just one ActionView::Base >>>> instance the first time it is called. That's as it is intended. >>>> The effect is, however, that only assigns up to that point are >>>> passed to that instance. Consequently, later assigns are ignored. >>> >>> Stubs and assigns are unrelated, so even though this might be a bug, >>> I don't think it's the cause of what you're seeing. >> >> It is. If I put all the assign(:x, value) before I first access #view, >> everything works as expected. The problem I had is entirely unrelated to >> stubs. > > Well, to be fair, the initial problem you cited in this thread (even in the subject line) is "partial mocks", not "assigns." > > That said, yes, this is a bug. I'll see if we can do something about that in Rails proper rather than rspec, which is just decorating the rails behavior. https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4931 > > Cheers, > David > >> It's just that when I do things in this order >> >> view.stub(:something).and_return('foo') >> assign(:bar, 10) >> >> The assign doesn't have an effect. I might as well have >> >> view.flash[:notice] = 'Something is rotten.' >> assign(:bar, 10) >> >> and the effect would be the same. Assigns that come after the view is >> first initialized are ignored. > > From rogerdpack at gmail.com Tue Jun 22 11:27:24 2010 From: rogerdpack at gmail.com (rogerdpack) Date: Tue, 22 Jun 2010 08:27:24 -0700 (PDT) Subject: [rspec-users] cleaner failure messages? In-Reply-To: References: <8e514768-118b-4fb1-a757-82d7f834c7d7@s4g2000prh.googlegroups.com> <96DCFA5E-E1FC-414E-90F1-658AE3CE4020@gmail.com> Message-ID: <309acfa0-f9a5-4459-8e69-3c37977d824a@18g2000vbh.googlegroups.com> > > ? ?Failure/Error: Unable to find matching line from backtrace > > Perhaps it isn't quite windows friendly? > > That happens now and then when the error is in code generated with eval(string) with no file and ref numbers. Has nothing to do with Windows as far as I know, and is the same problem we have with ruby-debug. Interesting. I get the same thing with Linux. If I add the word "fail" to an rspec, it says the same (not an eval string...)... Here's the output if I run it -b 1) Gem speeding Gem.bin_path the fake sick way should fake guess the right path instead of loading full rubygems for now Failure/Error: Unable to find matching line from backtrace # spec.faster_rubygems.rb:29:in `block (3 levels) in
' # /home/rdp/installs/ruby-1.9.1-p376_installed/lib/ruby/gems/1.9.1/ gems/rspec-core-2.0.0.beta.12/lib/rspec/core/example.rb:47:in `instance_eval' Hmm. -r From michael at schuerig.de Tue Jun 22 11:30:43 2010 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 22 Jun 2010 17:30:43 +0200 Subject: [rspec-users] RSpec 2 view specs: partial mocks In-Reply-To: <45AD562E-FBBB-46E3-B337-691EDFAF7391@gmail.com> References: <201006202219.55672.michael@schuerig.de> <9C65ECC6-BBA0-4120-9C54-B3AE2F971CF4@gmail.com> <45AD562E-FBBB-46E3-B337-691EDFAF7391@gmail.com> Message-ID: <201006221730.43508.michael@schuerig.de> On Tuesday 22 June 2010, David Chelimsky wrote: > On Jun 22, 2010, at 10:06 AM, David Chelimsky wrote: > > On Jun 22, 2010, at 9:58 AM, Michael Schuerig wrote: > >>> Stubs and assigns are unrelated, so even though this might be a > >>> bug, I don't think it's the cause of what you're seeing. > >> > >> It is. If I put all the assign(:x, value) before I first access > >> #view, everything works as expected. The problem I had is > >> entirely unrelated to stubs. > > > > Well, to be fair, the initial problem you cited in this thread > > (even in the subject line) is "partial mocks", not "assigns." Yes, indeed. That's because I was confused by the behavior I was seeing. I found the root cause only because I had to dig in there for another reason. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Tue Jun 22 12:08:37 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 22 Jun 2010 11:08:37 -0500 Subject: [rspec-users] cleaner failure messages? In-Reply-To: <309acfa0-f9a5-4459-8e69-3c37977d824a@18g2000vbh.googlegroups.com> References: <8e514768-118b-4fb1-a757-82d7f834c7d7@s4g2000prh.googlegroups.com> <96DCFA5E-E1FC-414E-90F1-658AE3CE4020@gmail.com> <309acfa0-f9a5-4459-8e69-3c37977d824a@18g2000vbh.googlegroups.com> Message-ID: <02C5C7BB-5AAE-4A65-B884-AB3128949E1B@gmail.com> On Jun 22, 2010, at 10:27 AM, rogerdpack wrote: >>> Failure/Error: Unable to find matching line from backtrace > >>> Perhaps it isn't quite windows friendly? >> >> That happens now and then when the error is in code generated with eval(string) with no file and ref numbers. Has nothing to do with Windows as far as I know, and is the same problem we have with ruby-debug. > > Interesting. > I get the same thing with Linux. > If I add the word "fail" to an rspec, it says the same (not an eval > string...)... > > Here's the output if I run it -b > > 1) Gem speeding Gem.bin_path the fake sick way should fake guess the > right path instead of loading full rubygems for now > Failure/Error: Unable to find matching line from backtrace > # spec.faster_rubygems.rb:29:in `block (3 levels) in
' > # /home/rdp/installs/ruby-1.9.1-p376_installed/lib/ruby/gems/1.9.1/ > gems/rspec-core-2.0.0.beta.12/lib/rspec/core/example.rb:47:in > `instance_eval' Please file an issue at http://github.com/rspec/rspec-core/issues Feel free to reference the method that handles this: http://github.com/rspec/rspec-core/blob/master/lib/rspec/core/formatters/base_formatter.rb#L118 Thanks From celoserpa at gmail.com Tue Jun 22 14:44:55 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Tue, 22 Jun 2010 13:44:55 -0500 Subject: [rspec-users] Bundler, rake spec and Steak In-Reply-To: <9E748F68-C974-4C5C-94E4-DF33CEFD14B3@wincent.com> References: <9E748F68-C974-4C5C-94E4-DF33CEFD14B3@wincent.com> Message-ID: Thanks Wincent, I'll do that. On Tue, Jun 22, 2010 at 2:37 AM, Wincent Colaiuta wrote: > El 22/06/2010, a las 08:16, Marcelo de Moraes Serpa escribi?: > > > Hello list, > > > > I have noted a few problems when using rake spec. First, it doesn't seem > to > > load the gems from the Gemfile (:test group) I had to add a required for > > each gem in this group on the spec_helper.rb file when I tried to run the > > tests vai rake spec, if I use the spec command, it works as expected. > > Unfortunately I can't help you here. At least with the versions I'm using > (rspec-rails 2.0.0.beta.12, steak 0.4.0.beta.1, rails 3.0.0.beta.4) I > haven't noted any problems. > > > Another thing -- I'm using Steak for acceptance testing. Steak puts its > > tests under spec/acceptance. Each Steak test uses the > acceptance_helper.rb > > helper script. This helper also automatically loads any ruby script from > > spec/acceptance/support/*.rb. The issue here is that, when I run rake > spec, > > it is running acceptance tests as well, which would not be a problem if > some > > support scripts from it set *not to use transactional fixtures* and setup > > DatabaseCleaner, and messes up with the rest of the specs. > > > > Any ideas on how to exclude acceptance tests from the rake spec? > > There is nothing intrinsically "special" about the "spec/acceptance" > directory so you could move that somewhere else (for example, Cucumber > sticks its features in a top-level "features" directory and you could do the > same kind of thing). > > The only thing is the generator included with Steak will keep putting the > files into "spec/acceptance" unless you tweak the generator yourself, or > choose not to use it. > > Also, the "spec:acceptance" Rake task defined by Steak in > "lib/tasks/steak.rake" would need to be updated to refer to your new path. > > If all of this seems like too much work, you could try posting a ticket on > the Steak tracker asking Luismi to consider changing the location of the > files: > > http://github.com/cavalle/steak/issues > > He is usually very responsive, and I'm sure that he'll either give you what > your asking for, or explain why it can't be that way. > > Cheers, > Wincent > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Jun 23 08:51:21 2010 From: lists at ruby-forum.com (Julien Palmas) Date: Wed, 23 Jun 2010 14:51:21 +0200 Subject: [rspec-users] rspec-rails 2.0.0.beta.12 showing undefined method error for route_to In-Reply-To: <1ffe8b03-6427-4a3b-9cd0-2f1b452b9fe9@y4g2000yqy.googlegroups.com> References: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> <1ffe8b03-6427-4a3b-9cd0-2f1b452b9fe9@y4g2000yqy.googlegroups.com> Message-ID: Daniel, your post saved my day! I got the same undefined method `route_to' error with rspec-rails v2.0.0.beta.12 and did not understand why ... Seems like this method has been added after the v2.0.0.beta.12 tag. You'll have to use the tip of the repo to get that working, until v2.0.0.beta.13 or RC is out -- Posted via http://www.ruby-forum.com/. From daniel.amselem at gmail.com Wed Jun 23 09:03:22 2010 From: daniel.amselem at gmail.com (Daniel Salmeron Amselem) Date: Wed, 23 Jun 2010 06:03:22 -0700 (PDT) Subject: [rspec-users] rspec-rails 2.0.0.beta.12 showing undefined method error for route_to In-Reply-To: References: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> <1ffe8b03-6427-4a3b-9cd0-2f1b452b9fe9@y4g2000yqy.googlegroups.com> Message-ID: <599d3eb4-5968-412b-a69e-ff83d581d172@z8g2000yqz.googlegroups.com> Hmm... So what do you have in your gemfile? Just gem rspec-rails, without the version? Do you know why there are some gems that are installed in the bundler directory? Thank you very much ! On Jun 23, 2:51?pm, Julien Palmas wrote: > Daniel, your post saved my day! > > I got the same undefined method `route_to' error with rspec-rails > v2.0.0.beta.12 and did not understand why ... > > Seems like this method has been added after the v2.0.0.beta.12 tag. > You'll have to use the tip of the repo to get that working, until > v2.0.0.beta.13 or RC is out > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Jun 23 09:16:38 2010 From: lists at ruby-forum.com (Julien Palmas) Date: Wed, 23 Jun 2010 15:16:38 +0200 Subject: [rspec-users] rspec-rails 2.0.0.beta.12 showing undefined method error for route_to In-Reply-To: <599d3eb4-5968-412b-a69e-ff83d581d172@z8g2000yqz.googlegroups.com> References: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> <1ffe8b03-6427-4a3b-9cd0-2f1b452b9fe9@y4g2000yqy.googlegroups.com> <599d3eb4-5968-412b-a69e-ff83d581d172@z8g2000yqz.googlegroups.com> Message-ID: <285bb111837cd47f6556e911ffd347da@ruby-forum.com> Daniel A. wrote: > Hmm... So what do you have in your gemfile? Just gem rspec-rails, > without the version? Do you know why there are some gems that are > installed in the bundler directory? Thank you very much ! In my gem file, for rspec-rails gem 'rspec-rails', :git => 'http://github.com/rspec/rspec-rails.git' what you see in the bundler dir are, AFAIK, gem specified with git repos, just like the line above. (ie : gems build from source by bundler) -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Jun 23 09:21:36 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 Jun 2010 08:21:36 -0500 Subject: [rspec-users] rspec-rails 2.0.0.beta.12 showing undefined method error for route_to In-Reply-To: <285bb111837cd47f6556e911ffd347da@ruby-forum.com> References: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> <1ffe8b03-6427-4a3b-9cd0-2f1b452b9fe9@y4g2000yqy.googlegroups.com> <599d3eb4-5968-412b-a69e-ff83d581d172@z8g2000yqz.googlegroups.com> <285bb111837cd47f6556e911ffd347da@ruby-forum.com> Message-ID: <844FA692-A870-430F-8E95-A06ACFFBBB52@gmail.com> On Jun 23, 2010, at 8:16 AM, Julien Palmas wrote: > Daniel A. wrote: >> Hmm... So what do you have in your gemfile? Just gem rspec-rails, >> without the version? Do you know why there are some gems that are >> installed in the bundler directory? Thank you very much ! > > In my gem file, for rspec-rails > gem 'rspec-rails', :git => 'http://github.com/rspec/rspec-rails.git' > > what you see in the bundler dir are, AFAIK, gem specified with git > repos, just like the line above. (ie : gems build from source by > bundler) Keep a couple of things in mind that when you use this approach: 1. You are using unreleased software. Expect additional headaches, but please report them so we know what's broken. 2. You have to run 'bundle install' or 'bundle update' to get the latest code. Cheers, David From daniel.amselem at gmail.com Wed Jun 23 09:24:59 2010 From: daniel.amselem at gmail.com (Daniel Salmeron Amselem) Date: Wed, 23 Jun 2010 06:24:59 -0700 (PDT) Subject: [rspec-users] rspec-rails 2.0.0.beta.12 showing undefined method error for route_to In-Reply-To: <285bb111837cd47f6556e911ffd347da@ruby-forum.com> References: <45fd0174-0f61-4f17-a534-161bcc9f4f39@z8g2000yqz.googlegroups.com> <1ffe8b03-6427-4a3b-9cd0-2f1b452b9fe9@y4g2000yqy.googlegroups.com> <599d3eb4-5968-412b-a69e-ff83d581d172@z8g2000yqz.googlegroups.com> <285bb111837cd47f6556e911ffd347da@ruby-forum.com> Message-ID: Ok, thanks! That would make sense if I installed some gems via "gem install" and other using "bundle install", right? In my case I installed all gems using bundler. Don't know... Anyways, thanks. On Jun 23, 3:16?pm, Julien Palmas wrote: > Daniel A. wrote: > > Hmm... So what do you have in your gemfile? Just gem rspec-rails, > > without the version? Do you know why there are some gems that are > > installed in the bundler directory? Thank you very much ! > > In my gem file, for rspec-rails > gem 'rspec-rails', :git => 'http://github.com/rspec/rspec-rails.git' > > what you see in the bundler dir are, AFAIK, gem specified with git > repos, just like the line above. (ie : gems build from source by > bundler) > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From patrick at collinatorstudios.com Wed Jun 23 13:07:34 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Wed, 23 Jun 2010 10:07:34 -0700 (PDT) Subject: [rspec-users] weirdness with rake spec! Message-ID: Hi everyone. I am totally confused by this... If I run rake spec, I get a bunch of failures in a particular file, but if I run script/spec on that individual file, all examples pass. The error I am getting is with the pluralize method. I put a debugger statement in my code to inspect what is happening: (rdb:1) pluralize(5, 'foo') ArgumentError Exception: wrong number of arguments (2 for 0) ... This is a situation where I am doing the "self-shunt" method, because I don't know of a better way to accomplish this. In other words, I am doing: class Foo def initialize(template, number) @template = template @number = number end def bar pluralize(@number, 'foo') end def bar_link link_to bar, foo_bar_path end def method_missing(*args, &block) @template.send(*args, &block) end end ......... Then in my spec I do: Foo.new(self, 2).bar.should == "foos" .......... And like I said, if I run this spec individually, it passes, but with rake spec, it gives me that wrong number of arguments error. I would love to structure this differently so that I don't need to pass self into the class initializer, but I am at a total loss for how to do that. If I do: include ActionView::Helpers include ActionController::UrlWriter Then I get "can't convert string into hash" errors when ever I try to access a named route with link_to. This is a problem I have had to face over and over, and has proven to be quite frustrating. The only solution I have found is to pass self into the method.. So if anyone has any other suggestions, I'd love to hear it. Thank you. Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Wed Jun 23 13:55:42 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 Jun 2010 12:55:42 -0500 Subject: [rspec-users] weirdness with rake spec! In-Reply-To: References: Message-ID: On Jun 23, 2010, at 12:07 PM, Patrick J. Collins wrote: > Hi everyone. > > I am totally confused by this... If I run rake spec, I get a bunch of failures > in a particular file, but if I run script/spec on that individual file, all > examples pass. > > The error I am getting is with the pluralize method. I put a debugger > statement in my code to inspect what is happening: > > (rdb:1) pluralize(5, 'foo') > ArgumentError Exception: wrong number of arguments (2 for 0) > > ... > > This is a situation where I am doing the "self-shunt" method, because I don't > know of a better way to accomplish this. In other words, I am doing: > > class Foo > > def initialize(template, number) > @template = template > @number = number > end > > def bar > pluralize(@number, 'foo') > end > > def bar_link > link_to bar, foo_bar_path > end > > def method_missing(*args, &block) > @template.send(*args, &block) > end > > end > > ......... > > Then in my spec I do: > > Foo.new(self, 2).bar.should == "foos" > > .......... > > And like I said, if I run this spec individually, it passes, but with rake > spec, it gives me that wrong number of arguments error. > > I would love to structure this differently so that I don't need to pass self > into the class initializer, but I am at a total loss for how to do that. > > If I do: > > include ActionView::Helpers > include ActionController::UrlWriter > > Then I get "can't convert string into hash" errors when ever I try to access a > named route with link_to. > > This is a problem I have had to face over and over, and has proven to be quite > frustrating. The only solution I have found is to pass self into the method.. > So if anyone has any other suggestions, I'd love to hear it. Is this a rails helper module? Is the spec in spec/helpers? From patrick at collinatorstudios.com Wed Jun 23 14:38:48 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Wed, 23 Jun 2010 11:38:48 -0700 (PDT) Subject: [rspec-users] weirdness with rake spec! In-Reply-To: References: Message-ID: > Is this a rails helper module? Is the spec in spec/helpers? Well it's not a module-- as in it's not getting mixed into any other class. It's just being instantiated from helpers (and inside the spec).. But since it utilizes helper methods, I did put it in the helpers folder-- It's actually in: spec/helpers/renderers Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Wed Jun 23 15:41:49 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 Jun 2010 14:41:49 -0500 Subject: [rspec-users] weirdness with rake spec! In-Reply-To: References: Message-ID: <4AF15A89-D071-4DCA-84F4-0C48A3E7B696@gmail.com> On Jun 23, 2010, at 1:38 PM, Patrick J. Collins wrote: >> Is this a rails helper module? Is the spec in spec/helpers? > > Well it's not a module-- as in it's not getting mixed into any other class. > It's just being instantiated from helpers (and inside the spec).. But > since it utilizes helper methods, I did put it in the helpers folder-- It's > actually in: > > spec/helpers/renderers Why not just use a rails helper? Then you get all the other helpers and environment for free. From patrick at collinatorstudios.com Wed Jun 23 16:25:14 2010 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Wed, 23 Jun 2010 13:25:14 -0700 (PDT) Subject: [rspec-users] weirdness with rake spec! In-Reply-To: <4AF15A89-D071-4DCA-84F4-0C48A3E7B696@gmail.com> References: <4AF15A89-D071-4DCA-84F4-0C48A3E7B696@gmail.com> Message-ID: > Why not just use a rails helper? Then you get all the other helpers and environment for free. Well, these are usually complex helpers that build a lot of html, and I utilize a lot of instance variables to share between methods... My practice has been to put these things in their own class so that I won't have conflicts with other instance variables... I don't understand though why rake spec would fail but script/spec wouldn't... Is there something different about the environment when rake spec is called? Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Wed Jun 23 18:11:56 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 Jun 2010 17:11:56 -0500 Subject: [rspec-users] weirdness with rake spec! In-Reply-To: References: <4AF15A89-D071-4DCA-84F4-0C48A3E7B696@gmail.com> Message-ID: On Jun 23, 2010, at 3:25 PM, Patrick J. Collins wrote: >> Why not just use a rails helper? Then you get all the other helpers and environment for free. > > Well, these are usually complex helpers that build a lot of html, and I utilize > a lot of instance variables to share between methods... My practice has been > to put these things in their own class so that I won't have conflicts with > other instance variables... I'd recommend slinging values around rather than storing them in instance variables. Passing values around makes each method much easier to test, and you don't have to concern yourself with values persisting across requests, etc, etc. > I don't understand though why rake spec would fail but script/spec wouldn't... > Is there something different about the environment when rake spec is called? There can be. It depends on what else is going on in your app. For one thing, running rake loads all of the .rake files in the lib/tasks directories of your app and all installed plugins. Could also be a load order thing. The fact that you sometimes get an argument error on pluralize suggests that there is more than one definition of pluralize in your app or one of its dependencies, and they're not getting loaded in the same order with both commands. Not sure if that helps solve your problem, but hopefully it sheds some light on it. Cheers, David From lists at ruby-forum.com Thu Jun 24 04:05:29 2010 From: lists at ruby-forum.com (Ivo Wever) Date: Thu, 24 Jun 2010 10:05:29 +0200 Subject: [rspec-users] RSpec 2: what should I replace 'params_from' with? Message-ID: <2238efe899347bbc70027a287897ca32@ruby-forum.com> Hey, I'm migrating an app to Rails 3 + RSpec 2 and, as expected, a number of specs broke. Unfortunately, I can't really find how to fix them. For instance, there is a spec: describe SessionsController do describe "route recognition" do it "should generate params from GET /login correctly" do params_from(:get, '/login').should == {:controller => 'sessions', :action => 'new'} end end This spec is located in Rails.root + /spec/controllers/sessions_controller_spec.rb The error is: SessionsController route recognition should generate params from POST /session correctly Failure/Error: params_from(:post, '/session').should == {:controller => 'sessions', :action => 'create'} undefined method `params_from' for # # ./vendor/gems/actionpack-3.0.0.beta4/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing' # ./spec/controllers/sessions_controller_spec.rb:121 Also note the 'RSpec::Core::ExampleGroup': it seems like it doesn't correctly infer it should be RSpec::Rails::ControllerExampleGroup? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jun 24 04:36:45 2010 From: lists at ruby-forum.com (Ivo Wever) Date: Thu, 24 Jun 2010 10:36:45 +0200 Subject: [rspec-users] RSpec 2: what should I replace 'params_from' with? In-Reply-To: <2238efe899347bbc70027a287897ca32@ruby-forum.com> References: <2238efe899347bbc70027a287897ca32@ruby-forum.com> Message-ID: Some additional info: * I'm on Rails 3 beta4 and RSpec 2 beta 13. * It doesn't matter whether I invoke the spec as bundle exec spec spec/controllers/sessions_controller_spec.rb or bundle exec rake spec -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Jun 24 06:59:05 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 05:59:05 -0500 Subject: [rspec-users] RSpec 2: what should I replace 'params_from' with? In-Reply-To: <2238efe899347bbc70027a287897ca32@ruby-forum.com> References: <2238efe899347bbc70027a287897ca32@ruby-forum.com> Message-ID: On Jun 24, 2010, at 3:05 AM, Ivo Wever wrote: > Hey, > > I'm migrating an app to Rails 3 + RSpec 2 and, as expected, a number of > specs broke. Unfortunately, I can't really find how to fix them. For > instance, there is a spec: > > describe SessionsController do > describe "route recognition" do > it "should generate params from GET /login correctly" do > params_from(:get, '/login').should == > {:controller => 'sessions', :action => 'new'} > end > end Route specs work like this now: { :get => "/login" }.should route_to(:controller => 'sessions', :action => 'new') { :put => "/widgets/1" }.should_not be_routable This was introduced in 1.2.9, but, unfortunately, I never deprecated the way you're doing it now. I'll do so in a 1.3.3 release, but that won't be for a little bit, and I don't plan to forward port it to 2.x. > This spec is located in Rails.root + > /spec/controllers/sessions_controller_spec.rb As of 2.0.0.beta.13, the route_to and be_routable matchers are only exposed to routing specs (in spec/routing). I've added a github issue to add them to controller specs as well. In the mean time, if you want to use them in your controller specs, just do this in spec_helper.rb RSpec.configure do |c| c.include RSpec::Rails::RoutingSpecMatchers, :example_group => { :file_path => /\bspec\/controllers\// } end Note that the name RSpec::Rails::RoutingSpecMatchers might change in the next beta, so this is not a formal API or anything - just a workaround for you to get by until the next release. HTH, David > > The error is: > > SessionsController route recognition should generate params from POST > /session correctly > Failure/Error: params_from(:post, '/session').should == {:controller > => 'sessions', :action => 'create'} > undefined method `params_from' for > # > # > ./vendor/gems/actionpack-3.0.0.beta4/lib/action_dispatch/testing/assertions/routing.rb:175:in > `method_missing' > # ./spec/controllers/sessions_controller_spec.rb:121 > > > Also note the 'RSpec::Core::ExampleGroup': it seems like it doesn't > correctly infer it should be RSpec::Rails::ControllerExampleGroup? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Thu Jun 24 09:12:26 2010 From: lists at ruby-forum.com (Ivo Wever) Date: Thu, 24 Jun 2010 15:12:26 +0200 Subject: [rspec-users] RSpec 2: what should I replace 'params_from' with? In-Reply-To: References: <2238efe899347bbc70027a287897ca32@ruby-forum.com> Message-ID: Hey, Thanks, that works fine and makes sense. Now there are also a few specs that assert the inverse direction: describe SessionsController do describe "route generation" do it "should route the destroy sessions action correctly" do route_for(:controller => 'sessions', :action => 'destroy').should == "/logout" end end end I understand the route_for method is similarly deprecated; what would be the idiomatic way to spec that now? > Note that the name RSpec::Rails::RoutingSpecMatchers might change in the > next beta, so this is not a formal API or anything - just a workaround > for you to get by until the next release. > OK, thanks for the warning. As we consciously chose to move to -beta software, these kinds of things are expected :). all the best, -- Ivo -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Jun 24 09:16:29 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 08:16:29 -0500 Subject: [rspec-users] RSpec 2: what should I replace 'params_from' with? In-Reply-To: References: <2238efe899347bbc70027a287897ca32@ruby-forum.com> Message-ID: <56EAC1EC-2C8F-45A4-8107-5E009B0291CC@gmail.com> On Jun 24, 2010, at 8:12 AM, Ivo Wever wrote: > Hey, > > Thanks, that works fine and makes sense. Now there are also a few specs > that assert the inverse direction: > > describe SessionsController do > describe "route generation" do > it "should route the destroy sessions action correctly" do > route_for(:controller => 'sessions', :action => 'destroy').should > == "/logout" > end > end > end route_to delegates to assert_routing, which tests both sides (recognizes and generates). > I understand the route_for method is similarly deprecated; what would be > the idiomatic way to spec that now? > >> Note that the name RSpec::Rails::RoutingSpecMatchers might change in the >> next beta, so this is not a formal API or anything - just a workaround >> for you to get by until the next release. >> > OK, thanks for the warning. As we consciously chose to move to -beta > software, these kinds of things are expected :). From lists at ruby-forum.com Thu Jun 24 10:30:18 2010 From: lists at ruby-forum.com (Valentino Lun) Date: Thu, 24 Jun 2010 16:30:18 +0200 Subject: [rspec-users] Cucumber - organize scenario outline example Message-ID: Dear all For the scenario outline example: Example: | start | eat | left | | 12 | 5 | 7 | | 20 | 5 | 15 | If my examples got 30 columns and 1000 rows. It would be difficult to organize in the .feature file. Can the example store in a csv file or an active record model? What is your practice? Please advise. Many thanks Valentino -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Jun 24 10:34:49 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 09:34:49 -0500 Subject: [rspec-users] Cucumber - organize scenario outline example In-Reply-To: References: Message-ID: On Jun 24, 2010, at 9:30 AM, Valentino Lun wrote: > Dear all > > For the scenario outline example: > > Example: > | start | eat | left | > | 12 | 5 | 7 | > | 20 | 5 | 15 | > > If my examples got 30 columns and 1000 rows. It would be difficult to > organize in the .feature file. Can the example store in a csv file or an > active record model? What is your practice? Please advise. Cucumber has its own list: http://groups.google.com/group/cukes Cheers, David From danielvlopes at gmail.com Thu Jun 24 12:11:05 2010 From: danielvlopes at gmail.com (Daniel Lopes) Date: Thu, 24 Jun 2010 09:11:05 -0700 (PDT) Subject: [rspec-users] Issue when run my specs in Textmate but not in terminal In-Reply-To: References: Message-ID: Fixed, the problem was the path of my textmate. The solution is open preferences, go to advanced/shell variables and make sure that your PATH entry includes the path of your imagemagick (in my casa, with homebrew is /usr/local/bin). On Jun 22, 2:05?am, Daniel Lopes wrote: > Hello, I'm experiencing a weird behavior that I cant find the > solution. My specs that depends on Factory Girl with attachment only > works in command line and not in Textmate with Command+R or Command > +Shift+R. > > My app uses rspec 1.3, rspec-rails 1.3.2, factory-girl 1.2.4 and Rails > 2.3.5 with paperclip. > > Right now I have a simple factory: > > Factory.define(:product) do |p| > ? p.display_name ?"Things for iPhone" > ? p.price ? ? ? ? 9.99 > ? p.attach ? ? ? ?"icon", "spec/fixtures/images/app_icon.png", "image/ > png" > end > > The attach method above is defined in the same way as below (in a > initializer file): > > http://gist.github.com/447996 > > Any time that I try use the factory above my specs fail with this > message: > > Validation failed: Icon /var/folders/CT/CT5WXMvBHIWX2jTklhOUh++++TI/- > Tmp-/stream20100622-9804-1ynydgk-0 is not recognized by the 'identify' > command. > > Somebody have any idea of what it can be? > > Thanks a lot. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From geetarista at gmail.com Thu Jun 24 14:23:54 2010 From: geetarista at gmail.com (geetarista) Date: Thu, 24 Jun 2010 11:23:54 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 Message-ID: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> I just upgraded to beta.13 and I'm running into an issue where when I run 'rake spec', I get an 'uninitialized constant Comment' error. Comment is the first model (alphabetically) in my project. If I switch back to beta.12, it works. If I use 'spec .' and not 'rake spec', it also works. Environment: Rails master, Mongoid master. From dchelimsky at gmail.com Thu Jun 24 15:03:44 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 14:03:44 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> Message-ID: <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> On Jun 24, 2010, at 1:23 PM, geetarista wrote: > I just upgraded to beta.13 and I'm running into an issue where when I > run 'rake spec', I get an 'uninitialized constant Comment' error. > Comment is the first model (alphabetically) in my project. If I > switch back to beta.12, it works. If I use 'spec .' and not 'rake > spec', it also works. > > Environment: Rails master, Mongoid master. Did you run 'bundle update'? From geetarista at gmail.com Thu Jun 24 15:24:42 2010 From: geetarista at gmail.com (geetarista) Date: Thu, 24 Jun 2010 12:24:42 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> Message-ID: <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> I did both 'bundle install' and 'bundle update'. On Jun 24, 12:03?pm, David Chelimsky wrote: > On Jun 24, 2010, at 1:23 PM, geetarista wrote: > > > I just upgraded to beta.13 and I'm running into an issue where when I > > run 'rake spec', I get an 'uninitialized constant Comment' error. > > Comment is the first model (alphabetically) in my project. ?If I > > switch back to beta.12, it works. ?If I use 'spec .' and not 'rake > > spec', it also works. > > > Environment: Rails master, Mongoid master. > > Did you run 'bundle update'? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From knarayanan88 at gmail.com Sun Jun 20 02:37:49 2010 From: knarayanan88 at gmail.com (Narayanan) Date: Sat, 19 Jun 2010 23:37:49 -0700 (PDT) Subject: [rspec-users] [RSpec]Doubt while Testing with RSpec Message-ID: <23b81ee1-a41c-4706-bcec-12fa95cebd77@g1g2000pro.googlegroups.com> Hi, I have a library of RSpec Test examples. Now, from an upper ruby layer, I need to run only individual separate test example from the library that matches a particular string in the upper layer. For Example: My RSpec library file contains many test examples like: describe arithmetic do it "should provide a sum of two numbers" do (1 + 2).should == 3 end it "should provide a difference of two numbers" do (5-4).should == 1 end .. .. .. end Now there is a ruby layer above from where I need to run the first test i.e when my input is test_add the it "should provide a sum of two numbers" must only run and give me results of test. Similarly, if in the input I am accepting in my upper ruby code is test_subtract, the 2nd test must run (it "should provide a difference of two numbers") and show the result of test. Is this possible with RSpec ? Thanks in advance, Regards, Narayanan From tatu.kairi at gmail.com Mon Jun 21 09:02:31 2010 From: tatu.kairi at gmail.com (Tattoo) Date: Mon, 21 Jun 2010 06:02:31 -0700 (PDT) Subject: [rspec-users] Autospec doing nothing In-Reply-To: References: Message-ID: To get this working, I had to comment out line 21: SPEC_PROGRAM = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')) My output said that I already had SPEC_PROGRAM initialized and also this line made it point to ../../bin/spec where I do not have spec installed (correct place for me was ~/.gem/ruby/1.8/bin/spec). I doubt for many, the situation is the same. Are you sure this line is necessary? On May 29, 4:26?am, Rodrigo Flores wrote: > I discovered the solution > > I have to put this on the .autotest file > > http://pastie.textmate.org/982730 > > > > > > On Sun, May 9, 2010 at 09:56, Rodrigo Flores wrote: > > Ops > > > I searched on the list archive and I found a topic from a month ago about > > this. My ZenTest version is 4.3.1 > > > My .autotest file is in my ~ and contains only > > require "autotest/growl" > > > rake spec is running succesfully. > > > On Sun, May 9, 2010 at 09:45, Rodrigo Flores wrote: > > >> Hi > > >> When I run autospec on a rails project I get nothing. > > >> flores at Suomi(9:41)~/Code/Sabbre/camisa10 % autospec > >> (Not running features. ?To run features in autotest, set > >> AUTOFEATURE=true.) > >> (Not running features. ?To run features in autotest, set > >> AUTOFEATURE=true.) > >> loading autotest/rails_rspec > >> style: RailsRspec > > >> --------------------------------------------------------------------------- ----- > > >> (a bunch of blank lines) > > >> flores at Suomi(9:41)~/Code/Sabbre/camisa10 % > > >> Any ideas ? > > >> My Operating System is Mac OS X Snow Leopard, my ruby is 1.8.7. > > >> Rspec: 1.3.0 > >> Rspec-Rails: 1.3.2 > >> autotest: 4.2.9 > >> autotest-growl : 0.2.4, 0.2.3 > >> autotest-rails: 4.1.0 > > >> -- > >> =================== > >> Rodrigo L. M. Flores > >> Computer Science Msc. Student - IME - USP > >> Computer Science Degree - IME - USP > >> Homepage (en):http://www.rodrigoflores.org > >> Blog (pt-BR):http://blog.rodrigoflores.org > >> Linux User # : 351304 > >> Jabber: i... at rodrigoflores.org > > > -- > > =================== > > Rodrigo L. M. Flores > > Computer Science Msc. Student - IME - USP > > Computer Science Degree - IME - USP > > Homepage (en):http://www.rodrigoflores.org > > Blog (pt-BR):http://blog.rodrigoflores.org > > Linux User # : 351304 > > Jabber: i... at rodrigoflores.org > > -- > =================== > Rodrigo L. M. Flores > Computer Science Msc. Student - IME - USP > Computer Science Degree - IME - USP > Homepage (en):http://www.rodrigoflores.org > Blog (pt-BR):http://blog.rodrigoflores.org > Linux User # : 351304 > Jabber: i... at rodrigoflores.org > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dark.red.and.yellow at googlemail.com Tue Jun 22 04:29:44 2010 From: dark.red.and.yellow at googlemail.com (=?ISO-8859-1?Q?Timo_R=F6=DFner?=) Date: Tue, 22 Jun 2010 01:29:44 -0700 (PDT) Subject: [rspec-users] rails 3 + latest rspec 2: route set not finalized Message-ID: <0d54685a-ab1f-450c-a378-9a52e7cee10f@e5g2000yqn.googlegroups.com> Hey guys, i have a problem with latest rails 3 and rspec2.0.0.12beta. When running most of my (with rails 2 and rspec 1 working) controller specs i get: route set not finalized I reduced the problem to the max: $ cat config/routes.rb Foo::Application.routes.draw do |map| resources :profiles end $ cat spec/controllers/profiles_controller_spec.rb require 'spec_helper' describe ProfilesController do describe 'GET index' do it 'should render the index template' do get 'index' response.should render_template(:index) end end end -> The spec-run: $ bundle exec spec spec/controllers/profiles_controller_spec.rb F 1) ProfilesController GET index should render the index template Failure/Error: get 'index' route set not finalized # ~/.bundle/ruby/1.8/gems/rack-mount-0.6.6/lib/rack/mount/ route_set.rb:208:in `generate' # ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.8/lib/rspec/rails/ monkey/action_controller/test_case.rb:111:in `process' # ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.8/lib/rspec/rails/ monkey/action_controller/test_case.rb:59:in `get' # ./spec/controllers/profiles_controller_spec.rb:7 Finished in 0.04356 seconds 1 example, 1 failures I do realize that the error comes from rack-mount, not rspec itself. However, the application itself is working as expected, so it has to be something specific about the way rspec and rack-mount interact. The relevant part of the Gemfile: gem 'rspec', :git => 'git://github.com/dchelimsky/rspec.git' gem 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec- rails.git' $ rails -v Rails 3.0.0.beta4 Os: Ubuntu Lucid Any ideas? From magoldbe at gmail.com Tue Jun 22 12:10:07 2010 From: magoldbe at gmail.com (Miriam) Date: Tue, 22 Jun 2010 09:10:07 -0700 (PDT) Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <340C2B8D-0D65-48D5-957C-E44C2EAD7D39@gmail.com> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> <4C1272B0.6080701@yahoo.com.br> <4C12FC40.90602@yahoo.com.br> <340C2B8D-0D65-48D5-957C-E44C2EAD7D39@gmail.com> Message-ID: <09d719ef-67c3-4f8c-90ee-48a8f44ae015@a42g2000vbl.googlegroups.com> I'm having the same problem the OP mentions -- undefined method "visit" Trying to upgrade from Rails 2.3 to Rails 3.0.beta4 My test stack: webrat (0.7.1) cucumber (0.8.3) pickle (0.2.1) factory_girl (1.3.0) factory_girl_rails (1.0) I changed config.mode = :rack, as suggested, but I"m still getting the error. This is what I have in features/support/env.rb: require 'webrat' require 'webrat/core/matchers' Webrat.configure do |config| config.mode = :rack config.open_error_files = false # Set to true if you want error pages to pop up in the browser end This is the error I'm getting: Given I am logged in as a buyer # features/ step_definitions/user_steps.rb:15 undefined method `visit' for # (NoMethodError) ./features/step_definitions/user_steps.rb:6:in `log_out' ./features/step_definitions/user_steps.rb:37:in `do_login' ./features/step_definitions/user_steps.rb:17:in `/^I\ am\ logged \ in\ as\ a\ (.*)$/' features/buyer_account.feature:7:in `Given I am logged in as a buyer' On Jun 13, 11:08?pm, David Chelimsky wrote: > On Jun 11, 2010, at 10:17 PM, Rodrigo Rosenfeld Rosas wrote: > > > Apparently Webrat is not yet compatible with Rails 3: > > This is incorrect. It's just that webrat needs to be configured for :rack instead of :rails: > > ? ? ? Webrat.configure do |config| > ? ? ? ? config.mode = :rack > ? ? ? end > > Since you're porting an app, there is probably some code somewhere that says this instead > > ? ? ? # DO NOT DO THIS WITH RAILS 3 > ? ? ? Webrat.configure do |config| > ? ? ? ? config.mode = :rails > ? ? ? end > > Get rid of that and you should be fine. > > > > > > >http://github.com/brynary/webrat/blob/master/lib/webrat/integrations/... > > > line 2: require "action_controller/integration" > > > action_controller/integration.rb does exist in Rails 2 but not in Rails 3, but I didn't find any branch for Rails 3 in webrat's repository. > > > I'll give Capybara another try. I had already tried it before but didn't change to it because I couldn't get the Drag & Drop javascript test to work anyway, but it seems to be a good replacement to Webrat's and there seems to be plans to merge them... > > > Does anyone here use Capybara with Rspec2 and Rails 3 without Cucumber to write integration tests successfully? > > > Thanks, > > > Rodrigo. > > > Em 11-06-2010 14:44, David Chelimsky escreveu: > > >> Sent from my iPhone > > >> On Jun 11, 2010, at 1:30 PM, Rodrigo Rosenfeld Rosas wrote: > > >>> Now I'm getting: > > >>> no such file to load -- action_controller/integration > > >> Backtrace, please > > >>> Am I missing something? > > >>> Thanks, > > >>> Rodrigo. > > >>> P.S.: Sorry if this was sent twice... > > >>> Em 11-06-2010 01:10, David Chelimsky escreveu: > >>>> Change the directory name to requests ?(a la merb) > > >>>> Sent from my iPhone > > >>>> On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas > >>>> wrote: > > >>>>> Hi guys, > > >>>>> I'm trying to port an application to Rails 3 but can't get my > >>>>> integration tests to run. > > >>>>> I can't call the Webrat's method (yields 'undefined method `visit`', > >>>>> for instance). I don't use Cucumber. > > >>>>> Is there any instructions about how to configure Rspec 2 with Webrat > >>>>> on Rails 3? > > >>>>> I also have a custom helper that is not working: > > >>>>> "config.include MyApp::IntegrationHelper, :type => :integration" (the > >>>>> methods defined in this module are not available in the specs) > > >>>>> Any ideas? > > >>>>> Thanks, > > >>>>> Rodrigo. > > > __________________________________________________ > > Fa?a liga??es para outros computadores com o novo Yahoo! Messengerhttp://br.beta.messenger.yahoo.com/ > > _______________________________________________ > > 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 From awinning at bingmail.com.au Tue Jun 22 21:10:05 2010 From: awinning at bingmail.com.au (antonyw) Date: Tue, 22 Jun 2010 18:10:05 -0700 (PDT) Subject: [rspec-users] RSpec, plugins and stubbing controller methods Message-ID: <28966280.post@talk.nabble.com> Hello, I have some code that is going to be used in other applications, so I decided to bundle the code (mostly controllers and views) into a plugin to make sharing easier. I copied the RSpec tests for the controllers into the plugin as well. The plugin RSpec tests run, however when it gets to stubbing controller methods it does not work. For example: controller.stub!(:get_json_settings).and_return(Hash["host", "localhost", "port", "1234"]) results in an error 'undefined local variable or method controller'. I know this code was working fine before, since I could run the RSpec tests against the controller prior to it becoming a plugin. So, I wondered when it starts up what must RSpec be missing when running in the plugin? Doing a --trace on rake spec and rake spec:plugin show the same the things being invoked and executed. Just wondering if anyone might have come across this issue before, or have any suggestions? Thanks.... -- View this message in context: http://old.nabble.com/RSpec%2C-plugins-and-stubbing-controller-methods-tp28966280p28966280.html Sent from the rspec-users mailing list archive at Nabble.com. From eydaimon at gmail.com Thu Jun 24 02:37:53 2010 From: eydaimon at gmail.com (anywho) Date: Wed, 23 Jun 2010 23:37:53 -0700 (PDT) Subject: [rspec-users] rspec(-rails).2.0.0.beta.13: no such file to load -- action_view/testing/resolvers Message-ID: <88dfa442-aa28-4686-944b-5023927d559b@k39g2000yqb.googlegroups.com> Running into issues with latest rspec beta. Beta.12 works flawlessly. Any insights are appriciated. /mnt/bob/bob.building.app/vendor/bundle/gems/activesupport-3.0.0.beta3/ lib/active_support/dependencies.rb:209:in `require': no such file to load -- action_view/testing/resolvers (LoadError) from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `block in require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in `load_dependency' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- rails-2.0.0.beta.13/lib/rspec/rails/view_rendering.rb:2:in `' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `block in require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in `load_dependency' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- rails-2.0.0.beta.13/lib/rspec/rails.rb:4:in `' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `block in require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in `load_dependency' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/spec/spec_helper.rb:5:in `' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `block in require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in `load_dependency' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/spec/models/landings_variation_spec.rb: 1:in `' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `block in require' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in `load_dependency' from /mnt/bob/bob.building.app/vendor/bundle/gems/ activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/configuration.rb:250:in `block in require_files_to_run' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/configuration.rb:250:in `map' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/configuration.rb:250:in `require_files_to_run' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/command_line.rb:12:in `initialize' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/runner.rb:46:in `new' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/runner.rb:46:in `run_in_process' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/runner.rb:37:in `run' from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- core-2.0.0.beta.13/lib/rspec/core/runner.rb:22:in `block in autorun' From dchelimsky at gmail.com Thu Jun 24 21:45:32 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 20:45:32 -0500 Subject: [rspec-users] RSpec, plugins and stubbing controller methods In-Reply-To: <28966280.post@talk.nabble.com> References: <28966280.post@talk.nabble.com> Message-ID: On Jun 22, 2010, at 8:10 PM, antonyw wrote: > Hello, > > I have some code that is going to be used in other applications, so I > decided to bundle the code (mostly controllers and views) into a plugin to > make sharing easier. I copied the RSpec tests for the controllers into the > plugin as well. > > The plugin RSpec tests run, however when it gets to stubbing controller > methods it does not work. For example: > > controller.stub!(:get_json_settings).and_return(Hash["host", > "localhost", "port", "1234"]) > > results in an error 'undefined local variable or method controller'. > > I know this code was working fine before, since I could run the RSpec tests > against the controller prior to it becoming a plugin. So, I wondered when it > starts up what must RSpec be missing when running in the plugin? Doing a > --trace on rake spec and rake spec:plugin show the same the things being > invoked and executed. > > Just wondering if anyone might have come across this issue before, or have > any suggestions? What versions of RSpec and Rails? From dchelimsky at gmail.com Thu Jun 24 21:47:14 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 20:47:14 -0500 Subject: [rspec-users] rspec(-rails).2.0.0.beta.13: no such file to load -- action_view/testing/resolvers In-Reply-To: <88dfa442-aa28-4686-944b-5023927d559b@k39g2000yqb.googlegroups.com> References: <88dfa442-aa28-4686-944b-5023927d559b@k39g2000yqb.googlegroups.com> Message-ID: <899B34CD-A4A0-41D2-8F9B-73D865FE3213@gmail.com> On Jun 24, 2010, at 1:37 AM, anywho wrote: > Running into issues with latest rspec beta. > > Beta.12 works flawlessly. Any insights are appriciated. > > /mnt/bob/bob.building.app/vendor/bundle/gems/activesupport-3.0.0.beta3/ rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. HTH, David > lib/active_support/dependencies.rb:209:in `require': no such file to > load -- action_view/testing/resolvers (LoadError) > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `block in require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in > `load_dependency' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > rails-2.0.0.beta.13/lib/rspec/rails/view_rendering.rb:2:in ` (required)>' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `block in require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in > `load_dependency' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > rails-2.0.0.beta.13/lib/rspec/rails.rb:4:in `' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `block in require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in > `load_dependency' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/spec/spec_helper.rb:5:in ` (required)>' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `block in require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in > `load_dependency' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/spec/models/landings_variation_spec.rb: > 1:in `' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `block in require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:197:in > `load_dependency' > from /mnt/bob/bob.building.app/vendor/bundle/gems/ > activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in > `require' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/configuration.rb:250:in `block in > require_files_to_run' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/configuration.rb:250:in `map' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/configuration.rb:250:in > `require_files_to_run' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/command_line.rb:12:in `initialize' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/runner.rb:46:in `new' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/runner.rb:46:in `run_in_process' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/runner.rb:37:in `run' > from /mnt/bob/bob.building.app/vendor/bundle/gems/rspec- > core-2.0.0.beta.13/lib/rspec/core/runner.rb:22:in `block in autorun' > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Jun 24 21:50:41 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 20:50:41 -0500 Subject: [rspec-users] rails 3 + latest rspec 2: route set not finalized In-Reply-To: <0d54685a-ab1f-450c-a378-9a52e7cee10f@e5g2000yqn.googlegroups.com> References: <0d54685a-ab1f-450c-a378-9a52e7cee10f@e5g2000yqn.googlegroups.com> Message-ID: On Jun 22, 2010, at 3:29 AM, Timo R??ner wrote: > Hey guys, > > i have a problem with latest rails 3 and rspec2.0.0.12beta. > When running most of my (with rails 2 and rspec 1 working) controller > specs i get: > > route set not finalized > > I reduced the problem to the max: > > $ cat config/routes.rb > Foo::Application.routes.draw do |map| > resources :profiles > end > > $ cat spec/controllers/profiles_controller_spec.rb > > require 'spec_helper' > describe ProfilesController do > describe 'GET index' do > it 'should render the index template' do > get 'index' > response.should render_template(:index) > end > end > end > > -> The spec-run: > > $ bundle exec spec spec/controllers/profiles_controller_spec.rb > > F > > 1) ProfilesController GET index should render the index template > Failure/Error: get 'index' > route set not finalized > # ~/.bundle/ruby/1.8/gems/rack-mount-0.6.6/lib/rack/mount/ > route_set.rb:208:in `generate' > # ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.8/lib/rspec/rails/ > monkey/action_controller/test_case.rb:111:in `process' > # ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.8/lib/rspec/rails/ > monkey/action_controller/test_case.rb:59:in `get' > # ./spec/controllers/profiles_controller_spec.rb:7 > > > Finished in 0.04356 seconds > 1 example, 1 failures > > I do realize that the error comes from rack-mount, not rspec itself. > However, the application itself > is working as expected, so it has to be something specific about the > way rspec and rack-mount interact. > > The relevant part of the Gemfile: > > gem 'rspec', :git => 'git://github.com/dchelimsky/rspec.git' > gem 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git' > $ rails -v > Rails 3.0.0.beta4 > Os: Ubuntu Lucid > > Any ideas? The gemfile points to github, but the backtrace above shows rspec-rails-2.0.0.beta.8 installed. Not sure why there is a conflict. Have you run bundle update lately? From dchelimsky at gmail.com Thu Jun 24 21:52:37 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 20:52:37 -0500 Subject: [rspec-users] [RSpec]Doubt while Testing with RSpec In-Reply-To: <23b81ee1-a41c-4706-bcec-12fa95cebd77@g1g2000pro.googlegroups.com> References: <23b81ee1-a41c-4706-bcec-12fa95cebd77@g1g2000pro.googlegroups.com> Message-ID: <248435AF-7E48-4F58-9D5E-11202195D35E@gmail.com> On Jun 20, 2010, at 1:37 AM, Narayanan wrote: > Hi, > > I have a library of RSpec Test examples. Now, from an upper ruby > layer, I need to run only individual separate test example from the > library that matches a particular string in the upper layer. > > For Example: > > My RSpec library file contains many test examples like: > > describe arithmetic do > > it "should provide a sum of two numbers" do > (1 + 2).should == 3 > end > > it "should provide a difference of two numbers" do > (5-4).should == 1 > end > > end > > Now there is a ruby layer above from where I need to run the first > test i.e when my input is test_add the it "should provide a sum of > two numbers" must only run and give me results of test. > Similarly, if in the input I am accepting in my upper ruby code is > test_subtract, the 2nd test must run (it "should provide a difference > of two numbers") and show the result of test. > > Is this possible with RSpec ? Yes. What version of RSpec are you using? From dchelimsky at gmail.com Thu Jun 24 22:05:28 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 21:05:28 -0500 Subject: [rspec-users] rspec-rails-2.0.0.beta.13 requires rails-3.0.0.beta4 Message-ID: <2B9EB677-A396-48B5-A17A-D90FB88B46E6@gmail.com> PLEASE NOTE: rspec-rails-2.0.0.beta.13 requires rails-3.0.0.beta4. If you are upgrading to rspec-rails-2.0.0.beta.13, you must also upgrade to rails-3.0.0.beta4. Apologies for any confusion caused by my not making an announcement about it earlier. Cheers, David From dchelimsky at gmail.com Thu Jun 24 22:08:10 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 21:08:10 -0500 Subject: [rspec-users] Rspec 2, Rails 3 and Webrat In-Reply-To: <09d719ef-67c3-4f8c-90ee-48a8f44ae015@a42g2000vbl.googlegroups.com> References: <4C11A0E2.5090509@yahoo.com.br> <59A897EC-0FDF-4256-A60C-C79032059CCE@gmail.com> <4C1272B0.6080701@yahoo.com.br> <4C12FC40.90602@yahoo.com.br> <340C2B8D-0D65-48D5-957C-E44C2EAD7D39@gmail.com> <09d719ef-67c3-4f8c-90ee-48a8f44ae015@a42g2000vbl.googlegroups.com> Message-ID: <6D2F5E1E-D863-48DA-8735-18ED7C95A818@gmail.com> On Jun 22, 2010, at 11:10 AM, Miriam wrote: > I'm having the same problem the OP mentions -- undefined method > "visit" > > Trying to upgrade from Rails 2.3 to Rails 3.0.beta4 > > My test stack: > webrat (0.7.1) > cucumber (0.8.3) > pickle (0.2.1) > factory_girl (1.3.0) > factory_girl_rails (1.0) > > I changed config.mode = :rack, as suggested, but I"m still getting the > error. > > This is what I have in features/support/env.rb: > > require 'webrat' > require 'webrat/core/matchers' > > Webrat.configure do |config| > config.mode = :rack > config.open_error_files = false # Set to true if you want error > pages to pop up in the browser > end > > This is the error I'm getting: > > Given I am logged in as a > buyer # features/ > step_definitions/user_steps.rb:15 > undefined method `visit' for # > (NoMethodError) > ./features/step_definitions/user_steps.rb:6:in `log_out' > ./features/step_definitions/user_steps.rb:37:in `do_login' > ./features/step_definitions/user_steps.rb:17:in `/^I\ am\ logged > \ in\ as\ a\ (.*)$/' > features/buyer_account.feature:7:in `Given I am logged in as a > buyer' Up until now, this thread has been about an issue with RSpec. You are having an issue with Cucumber. I'd recommend posting it to the Cucumber google group: http://groups.google.com/group/cukes I'm sure someone there can advise. Cheers, David > > > On Jun 13, 11:08 pm, David Chelimsky wrote: >> On Jun 11, 2010, at 10:17 PM, Rodrigo Rosenfeld Rosas wrote: >> >>> Apparently Webrat is not yet compatible with Rails 3: >> >> This is incorrect. It's just that webrat needs to be configured for :rack instead of :rails: >> >> Webrat.configure do |config| >> config.mode = :rack >> end >> >> Since you're porting an app, there is probably some code somewhere that says this instead >> >> # DO NOT DO THIS WITH RAILS 3 >> Webrat.configure do |config| >> config.mode = :rails >> end >> >> Get rid of that and you should be fine. >> >> >> >> >> >>> http://github.com/brynary/webrat/blob/master/lib/webrat/integrations/... >> >>> line 2: require "action_controller/integration" >> >>> action_controller/integration.rb does exist in Rails 2 but not in Rails 3, but I didn't find any branch for Rails 3 in webrat's repository. >> >>> I'll give Capybara another try. I had already tried it before but didn't change to it because I couldn't get the Drag & Drop javascript test to work anyway, but it seems to be a good replacement to Webrat's and there seems to be plans to merge them... >> >>> Does anyone here use Capybara with Rspec2 and Rails 3 without Cucumber to write integration tests successfully? >> >>> Thanks, >> >>> Rodrigo. >> >>> Em 11-06-2010 14:44, David Chelimsky escreveu: >> >>>> Sent from my iPhone >> >>>> On Jun 11, 2010, at 1:30 PM, Rodrigo Rosenfeld Rosas wrote: >> >>>>> Now I'm getting: >> >>>>> no such file to load -- action_controller/integration >> >>>> Backtrace, please >> >>>>> Am I missing something? >> >>>>> Thanks, >> >>>>> Rodrigo. >> >>>>> P.S.: Sorry if this was sent twice... >> >>>>> Em 11-06-2010 01:10, David Chelimsky escreveu: >>>>>> Change the directory name to requests (a la merb) >> >>>>>> Sent from my iPhone >> >>>>>> On Jun 10, 2010, at 10:35 PM, Rodrigo Rosenfeld Rosas >>>>>> wrote: >> >>>>>>> Hi guys, >> >>>>>>> I'm trying to port an application to Rails 3 but can't get my >>>>>>> integration tests to run. >> >>>>>>> I can't call the Webrat's method (yields 'undefined method `visit`', >>>>>>> for instance). I don't use Cucumber. >> >>>>>>> Is there any instructions about how to configure Rspec 2 with Webrat >>>>>>> on Rails 3? >> >>>>>>> I also have a custom helper that is not working: >> >>>>>>> "config.include MyApp::IntegrationHelper, :type => :integration" (the >>>>>>> methods defined in this module are not available in the specs) >> >>>>>>> Any ideas? >> >>>>>>> Thanks, >> >>>>>>> Rodrigo. >> >>> __________________________________________________ >>> Fa?a liga??es para outros computadores com o novo Yahoo! Messengerhttp://br.beta.messenger.yahoo.com/ >>> _______________________________________________ >>> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Jun 24 22:10:39 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 21:10:39 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> Message-ID: <58B15845-873A-40B8-9539-57570E253D41@gmail.com> On Jun 24, 2010, at 2:24 PM, geetarista wrote: > On Jun 24, 12:03 pm, David Chelimsky wrote: >> On Jun 24, 2010, at 1:23 PM, geetarista wrote: >> >>> I just upgraded to beta.13 and I'm running into an issue where when I >>> run 'rake spec', I get an 'uninitialized constant Comment' error. >>> Comment is the first model (alphabetically) in my project. If I >>> switch back to beta.12, it works. If I use 'spec .' and not 'rake >>> spec', it also works. >> >>> Environment: Rails master, Mongoid master. >> >> Did you run 'bundle update'? > I did both 'bundle install' and 'bundle update'. Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. HTH, David From geetarista at gmail.com Thu Jun 24 23:12:32 2010 From: geetarista at gmail.com (geetarista) Date: Thu, 24 Jun 2010 20:12:32 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <58B15845-873A-40B8-9539-57570E253D41@gmail.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> Message-ID: <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> I'm using Rails master. On Jun 24, 7:10?pm, David Chelimsky wrote: > On Jun 24, 2010, at 2:24 PM, geetarista wrote: > > > On Jun 24, 12:03 pm, David Chelimsky wrote: > >> On Jun 24, 2010, at 1:23 PM, geetarista wrote: > > >>> I just upgraded to beta.13 and I'm running into an issue where when I > >>> run 'rake spec', I get an 'uninitialized constant Comment' error. > >>> Comment is the first model (alphabetically) in my project. ?If I > >>> switch back to beta.12, it works. ?If I use 'spec .' and not 'rake > >>> spec', it also works. > > >>> Environment: Rails master, Mongoid master. > > >> Did you run 'bundle update'? > > I did both 'bundle install' and 'bundle update'. > > Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Jun 24 23:21:51 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 22:21:51 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> Message-ID: On Thu, Jun 24, 2010 at 10:12 PM, geetarista wrote: > > On Jun 24, 7:10?pm, David Chelimsky wrote: >> On Jun 24, 2010, at 2:24 PM, geetarista wrote: >> >> > On Jun 24, 12:03 pm, David Chelimsky wrote: >> >> On Jun 24, 2010, at 1:23 PM, geetarista wrote: >> >> >>> I just upgraded to beta.13 and I'm running into an issue where when I >> >>> run 'rake spec', I get an 'uninitialized constant Comment' error. >> >>> Comment is the first model (alphabetically) in my project. ?If I >> >>> switch back to beta.12, it works. ?If I use 'spec .' and not 'rake >> >>> spec', it also works. >> >> >>> Environment: Rails master, Mongoid master. >> >> >> Did you run 'bundle update'? >> > I did both 'bundle install' and 'bundle update'. >> >> Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. > > I'm using Rails master. I'm at a loss. Please run "rake spec --trace" and post the full backtrace. From geetarista at gmail.com Thu Jun 24 23:36:32 2010 From: geetarista at gmail.com (geetarista) Date: Thu, 24 Jun 2010 20:36:32 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> Message-ID: <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> Here's the backtrace and the spec file: http://gist.github.com/452355 Also, if I delete that spec file, it just goes to the next alphabetical file and gives the same error for that model name. On Jun 24, 8:21?pm, David Chelimsky wrote: > On Thu, Jun 24, 2010 at 10:12 PM, geetarista wrote: > > > On Jun 24, 7:10?pm, David Chelimsky wrote: > >> On Jun 24, 2010, at 2:24 PM, geetarista wrote: > > >> > On Jun 24, 12:03 pm, David Chelimsky wrote: > >> >> On Jun 24, 2010, at 1:23 PM, geetarista wrote: > > >> >>> I just upgraded to beta.13 and I'm running into an issue where when I > >> >>> run 'rake spec', I get an 'uninitialized constant Comment' error. > >> >>> Comment is the first model (alphabetically) in my project. ?If I > >> >>> switch back to beta.12, it works. ?If I use 'spec .' and not 'rake > >> >>> spec', it also works. > > >> >>> Environment: Rails master, Mongoid master. > > >> >> Did you run 'bundle update'? > >> > I did both 'bundle install' and 'bundle update'. > > >> Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. > > > I'm using Rails master. > > I'm at a loss. Please run "rake spec --trace" and post the full backtrace. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Jun 24 23:49:30 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 Jun 2010 22:49:30 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> Message-ID: <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> On Jun 24, 2010, at 10:36 PM, geetarista wrote: > On Jun 24, 8:21 pm, David Chelimsky wrote: >> On Thu, Jun 24, 2010 at 10:12 PM, geetarista wrote: >> >>> On Jun 24, 7:10 pm, David Chelimsky wrote: >>>> On Jun 24, 2010, at 2:24 PM, geetarista wrote: >> >>>>> On Jun 24, 12:03 pm, David Chelimsky wrote: >>>>>> On Jun 24, 2010, at 1:23 PM, geetarista wrote: >> >>>>>>> I just upgraded to beta.13 and I'm running into an issue where when I >>>>>>> run 'rake spec', I get an 'uninitialized constant Comment' error. >>>>>>> Comment is the first model (alphabetically) in my project. If I >>>>>>> switch back to beta.12, it works. If I use 'spec .' and not 'rake >>>>>>> spec', it also works. >> >>>>>>> Environment: Rails master, Mongoid master. >> >>>>>> Did you run 'bundle update'? >>>>> I did both 'bundle install' and 'bundle update'. >> >>>> Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. >> >>> I'm using Rails master. >> >> I'm at a loss. Please run "rake spec --trace" and post the full backtrace. > Here's the backtrace and the spec file: http://gist.github.com/452355 > > Also, if I delete that spec file, it just goes to the next > alphabetical file and gives the same error for that model name. What's in spec_helper.rb? The backtace makes It look as though the rails framework is not loaded. From geetarista at gmail.com Fri Jun 25 00:05:46 2010 From: geetarista at gmail.com (geetarista) Date: Thu, 24 Jun 2010 21:05:46 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> Message-ID: <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> http://gist.github.com/452385 (It's the default generated from rails g rspec:install). I'm not sure what else it could be. I literally change my Gemfile from beta.12 (where specs work) to beta.13 run 'bundle install/update' and it then fails. On Jun 24, 8:49?pm, David Chelimsky wrote: > On Jun 24, 2010, at 10:36 PM, geetarista wrote: > > > > > > > On Jun 24, 8:21 pm, David Chelimsky wrote: > >> On Thu, Jun 24, 2010 at 10:12 PM, geetarista wrote: > > >>> On Jun 24, 7:10 pm, David Chelimsky wrote: > >>>> On Jun 24, 2010, at 2:24 PM, geetarista wrote: > > >>>>> On Jun 24, 12:03 pm, David Chelimsky wrote: > >>>>>> On Jun 24, 2010, at 1:23 PM, geetarista wrote: > > >>>>>>> I just upgraded to beta.13 and I'm running into an issue where when I > >>>>>>> run 'rake spec', I get an 'uninitialized constant Comment' error. > >>>>>>> Comment is the first model (alphabetically) in my project. ?If I > >>>>>>> switch back to beta.12, it works. ?If I use 'spec .' and not 'rake > >>>>>>> spec', it also works. > > >>>>>>> Environment: Rails master, Mongoid master. > > >>>>>> Did you run 'bundle update'? > >>>>> I did both 'bundle install' and 'bundle update'. > > >>>> Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. > > >>> I'm using Rails master. > > >> I'm at a loss. Please run "rake spec --trace" and post the full backtrace. > > Here's the backtrace and the spec file:http://gist.github.com/452355 > > > Also, if I delete that spec file, it just goes to the next > > alphabetical file and gives the same error for that model name. > > What's in spec_helper.rb? The backtace makes It look as though the rails framework is not loaded. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Jun 25 06:41:24 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 Jun 2010 05:41:24 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> Message-ID: <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> On Jun 24, 2010, at 11:05 PM, geetarista wrote: > http://gist.github.com/452385 > > (It's the default generated from rails g rspec:install). > > I'm not sure what else it could be. I literally change my Gemfile > from beta.12 (where specs work) to beta.13 run 'bundle install/update' > and it then fails. I seriously doubt this will fix the problem, but try changing Rspec to RSpec on line 11. > > On Jun 24, 8:49 pm, David Chelimsky wrote: >> On Jun 24, 2010, at 10:36 PM, geetarista wrote: >> >> >> >> >> >>> On Jun 24, 8:21 pm, David Chelimsky wrote: >>>> On Thu, Jun 24, 2010 at 10:12 PM, geetarista wrote: >> >>>>> On Jun 24, 7:10 pm, David Chelimsky wrote: >>>>>> On Jun 24, 2010, at 2:24 PM, geetarista wrote: >> >>>>>>> On Jun 24, 12:03 pm, David Chelimsky wrote: >>>>>>>> On Jun 24, 2010, at 1:23 PM, geetarista wrote: >> >>>>>>>>> I just upgraded to beta.13 and I'm running into an issue where when I >>>>>>>>> run 'rake spec', I get an 'uninitialized constant Comment' error. >>>>>>>>> Comment is the first model (alphabetically) in my project. If I >>>>>>>>> switch back to beta.12, it works. If I use 'spec .' and not 'rake >>>>>>>>> spec', it also works. >> >>>>>>>>> Environment: Rails master, Mongoid master. >> >>>>>>>> Did you run 'bundle update'? >>>>>>> I did both 'bundle install' and 'bundle update'. >> >>>>>> Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. >> >>>>> I'm using Rails master. >> >>>> I'm at a loss. Please run "rake spec --trace" and post the full backtrace. >>> Here's the backtrace and the spec file:http://gist.github.com/452355 >> >>> Also, if I delete that spec file, it just goes to the next >>> alphabetical file and gives the same error for that model name. >> >> What's in spec_helper.rb? The backtace makes It look as though the rails framework is not loaded. >> _______________________________________________ >> 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 From geetarista at gmail.com Fri Jun 25 09:38:54 2010 From: geetarista at gmail.com (geetarista) Date: Fri, 25 Jun 2010 06:38:54 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> Message-ID: <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> That did not fix it. On Jun 25, 3:41?am, David Chelimsky wrote: > On Jun 24, 2010, at 11:05 PM, geetarista wrote: > > >http://gist.github.com/452385 > > > (It's the default generated from rails g rspec:install). > > > I'm not sure what else it could be. ?I literally change my Gemfile > > from beta.12 (where specs work) to beta.13 run 'bundle install/update' > > and it then fails. > > I seriously doubt this will fix the problem, but try changing Rspec to RSpec on line 11. > > > > > > > > > On Jun 24, 8:49 pm, David Chelimsky wrote: > >> On Jun 24, 2010, at 10:36 PM, geetarista wrote: > > >>> On Jun 24, 8:21 pm, David Chelimsky wrote: > >>>> On Thu, Jun 24, 2010 at 10:12 PM, geetarista wrote: > > >>>>> On Jun 24, 7:10 pm, David Chelimsky wrote: > >>>>>> On Jun 24, 2010, at 2:24 PM, geetarista wrote: > > >>>>>>> On Jun 24, 12:03 pm, David Chelimsky wrote: > >>>>>>>> On Jun 24, 2010, at 1:23 PM, geetarista wrote: > > >>>>>>>>> I just upgraded to beta.13 and I'm running into an issue where when I > >>>>>>>>> run 'rake spec', I get an 'uninitialized constant Comment' error. > >>>>>>>>> Comment is the first model (alphabetically) in my project. ?If I > >>>>>>>>> switch back to beta.12, it works. ?If I use 'spec .' and not 'rake > >>>>>>>>> spec', it also works. > > >>>>>>>>> Environment: Rails master, Mongoid master. > > >>>>>>>> Did you run 'bundle update'? > >>>>>>> I did both 'bundle install' and 'bundle update'. > > >>>>>> Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4. > > >>>>> I'm using Rails master. > > >>>> I'm at a loss. Please run "rake spec --trace" and post the full backtrace. > >>> Here's the backtrace and the spec file:http://gist.github.com/452355 > > >>> Also, if I delete that spec file, it just goes to the next > >>> alphabetical file and gives the same error for that model name. > > >> What's in spec_helper.rb? The backtace makes It look as though the rails framework is not loaded. > >> _______________________________________________ > >> 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 From win at wincent.com Fri Jun 25 10:41:27 2010 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 25 Jun 2010 16:41:27 +0200 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> Message-ID: El 25/06/2010, a las 15:38, geetarista escribi?: > That did not fix it. What have you got in your Gemfile? Cheers, Wincent From geetarista at gmail.com Fri Jun 25 11:44:41 2010 From: geetarista at gmail.com (geetarista) Date: Fri, 25 Jun 2010 08:44:41 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> Message-ID: <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> Gemfile: http://gist.github.com/453032 On Jun 25, 7:41?am, Wincent Colaiuta wrote: > El 25/06/2010, a las 15:38, geetarista escribi?: > > > That did not fix it. > > What have you got in your Gemfile? > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From rick.denatale at gmail.com Fri Jun 25 12:36:34 2010 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 25 Jun 2010 12:36:34 -0400 Subject: [rspec-users] Quickie blog article about dealing with Bundler, RSpec and Rake Message-ID: http://talklikeaduck.denhaven2.com/2010/06/25/making-rspec-rake-and-bundler-play-well-together Note this is for Rails 2.3, not sure if Rails 3 and Rspec 2 would be different. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From win at wincent.com Fri Jun 25 14:18:53 2010 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 25 Jun 2010 20:18:53 +0200 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> Message-ID: <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> El 25/06/2010, a las 17:44, geetarista escribi?: > Gemfile: http://gist.github.com/453032 > > On Jun 25, 7:41 am, Wincent Colaiuta wrote: >> El 25/06/2010, a las 15:38, geetarista escribi?: >> >>> That did not fix it. >> >> What have you got in your Gemfile? (Aside: please don't top-post; it makes your replies cumbersome to read.) Was kind of hoping I'd see something glaringly weird in your Gemfile, but nothing leaps out at me. Why do you have the ":require => nil" for RSpec in your test environment? AFAIK this won't explain the failure you're seeing, but I still wonder why you're doing it. On a tangent, you're 10 releases of Haml behind, and a lot of Rails 3 fixes have been made since 3.0.3. Cheers, Wincent From celoserpa at gmail.com Fri Jun 25 14:56:11 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Fri, 25 Jun 2010 13:56:11 -0500 Subject: [rspec-users] Testing only for a redirect Message-ID: Hello guys, Quick question: How could I just test if a redirect was made, without URL whatsoever? Thanks, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jun 25 15:18:10 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 Jun 2010 14:18:10 -0500 Subject: [rspec-users] Testing only for a redirect In-Reply-To: References: Message-ID: On Fri, Jun 25, 2010 at 1:56 PM, Marcelo de Moraes Serpa wrote: > Hello guys, > > Quick question: How could I just test if a redirect was made, without URL > whatsoever? In rspec-1/rails-2: response.should be_redirect This is not in rspec-rails-2 yet, so you can just go with the rails assertion for now: assert_response :redirect HTH, David From celoserpa at gmail.com Fri Jun 25 17:00:12 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Fri, 25 Jun 2010 16:00:12 -0500 Subject: [rspec-users] Testing only for a redirect In-Reply-To: References: Message-ID: Thanks David! :) Marcelo. On Fri, Jun 25, 2010 at 2:18 PM, David Chelimsky wrote: > On Fri, Jun 25, 2010 at 1:56 PM, Marcelo de Moraes Serpa > wrote: > > Hello guys, > > > > Quick question: How could I just test if a redirect was made, without URL > > whatsoever? > > In rspec-1/rails-2: > > response.should be_redirect > > This is not in rspec-rails-2 yet, so you can just go with the rails > assertion for now: > > assert_response :redirect > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jun 25 17:33:41 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 Jun 2010 16:33:41 -0500 Subject: [rspec-users] Testing only for a redirect In-Reply-To: References: Message-ID: <0BD037CE-8E6A-4DCD-BF81-E90B1DF2E692@gmail.com> On Jun 25, 2010, at 4:00 PM, Marcelo de Moraes Serpa wrote: > On Fri, Jun 25, 2010 at 2:18 PM, David Chelimsky wrote: > On Fri, Jun 25, 2010 at 1:56 PM, Marcelo de Moraes Serpa > wrote: > > Hello guys, > > > > Quick question: How could I just test if a redirect was made, without URL > > whatsoever? > > In rspec-1/rails-2: > > response.should be_redirect > > This is not in rspec-rails-2 yet, so you can just go with the rails > assertion for now: > > assert_response :redirect > > Thanks David! :) Sure. FYI - looks like you can use be_redirect in rspec-rails-2 because the TestResponse object responds to redirect?(). Give it a shot: response.should be_redirect Work? -------------- next part -------------- An HTML attachment was scrubbed... URL: From geetarista at gmail.com Fri Jun 25 17:51:12 2010 From: geetarista at gmail.com (geetarista) Date: Fri, 25 Jun 2010 14:51:12 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> Message-ID: Sorry about that. For some reason I thought Google Reader stripped that automatically. I added ":require => nil" because I had read somewhere that it was good to do so. Can't remember why or where. Taking it out does not fix the failure. I just haven't upgraded Haml because it's not top priority and I haven't run into any issues yet. From patgannon at gmail.com Fri Jun 25 18:02:36 2010 From: patgannon at gmail.com (Patrick Gannon) Date: Fri, 25 Jun 2010 15:02:36 -0700 Subject: [rspec-users] [Rails] Can't get controller test working with RSpec 2 and edge Rails 3 Message-ID: Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to get a standard controller test working - it seems that the 'get' method can't be found. I have a controller test that looks like this (named "discrepancies_controller_spec.rb" in spec/controllers directory): require 'spec_helper' describe DiscrepanciesController do before :each do Discrepancy.delete_all end it "resolves a discrepancy" do discrepancy = Discrepancy.create(:my_number=>"12345", :status=>"Open") get :resolve, :id => discrepancy.id retrieved_discrepancy = Discrepancy.find_by_my_number("12345") retrieved_discrepancy.status.should == "Resolved" end end (Yes, I'm aware of the security implications of modifying data with an HTTP/GET - that's a separate issue...) When I run it with rake, I get the following error: 1) DiscrepanciesController resolves a discrepancy Failure/Error: Unable to find C to read failed line undefined method `get' for # # ./spec/controllers/discrepancies_controller_spec.rb:38* (ignore the line number, commented out code was removed from the sample)* # C:/Users/Patrick_Gannon/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/dependencies.rb:212:in `inject' # C:/Ruby187/bin/rake:19:in `load' # C:/Ruby187/bin/rake:19 I can manage to test the controller action by instantiating the controller myself and calling the controller action directly, and it works, but its ugly because I have to mock out things like 'respond_to' and 'params'. Other pertinent information: I am running Windows 7 32-bit, Ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-wingw32], edge Rails 3 and MongoDB/MongoMapper. Here is my list of installed gems (via 'bundle gem' - all my installed gems were installed by Bundler) * abstract (1.0.0) * actionmailer (3.0.0.beta4) * actionpack (3.0.0.beta4) * activemodel (3.0.0.beta4) * activerecord (3.0.0.beta4) * activeresource (3.0.0.beta4) * activesupport (3.0.0.beta4) * arel (0.4.0) * bcrypt-ruby (2.1.2) * bson (1.0.3) * bson_ext (1.0.1) * builder (2.1.2) * bundler (0.9.26) * capistrano (2.5.19) * capybara (0.3.8 a94f99) * cucumber (0.8.3) * cucumber-rails (0.3.2 master-b75110) * culerity (0.2.10) * database_cleaner (0.5.2 7ea99d) * devise (1.1.rc1 88ab2f) * diff-lcs (1.1.2) * erubis (2.6.5) * factory_girl (1.3.0) * factory_girl_rails (1.0) * faker (0.3.1) * ffi (0.6.3) * gherkin (2.0.2) * highline (1.5.2) * i18n (0.4.1) * jnunemaker-validatable (1.8.4) * joint (0.3.2 11a094) * json_pure (1.4.3) * mail (2.2.5) * mime-types (1.16) * mongo (1.0.3) * mongo_mapper (0.8.2) * net-scp (1.0.2) * net-sftp (2.0.4) * net-ssh (2.0.23) * net-ssh-gateway (1.0.1) * nokogiri (1.4.2.1) * plucky (0.3.2) * polyglot (0.3.1) * rack (1.1.0) * rack-mount (0.6.6) * rack-test (0.5.4) * rails (3.0.0.beta4 6682cc) * railties (3.0.0.beta4) * rake (0.8.7) * rspec (2.0.0.beta.13) * rspec-core (2.0.0.beta.13) * rspec-expectations (2.0.0.beta.13) * rspec-mocks (2.0.0.beta.13) * rspec-rails (2.0.0.beta.13) * selenium-webdriver (0.0.24) * term-ansicolor (1.0.5) * thor (0.13.6) * treetop (1.4.8) * trollop (1.16.2) * tzinfo (0.3.22) * wand (0.2.1) * warden (0.10.7) * webrat (0.7.1) I also added a puts statement in the test to show what methods are available in the test fixture, and "get" is not in the list. Here is what is in the list: "__memoized", "__should_for_example_group__", "__should_not_for_example_group__", "_fixture_class_names", "_fixture_path", "_fixture_table_names", "_pre_loaded_fixtures", "_setup_mocks", "_teardown_mocks", "_use_instantiated_fixtures", "_use_transactional_fixtures", "_verify_mocks", "a_kind_of", "allow_message_expectations_on_nil", "an_instance_of", "any_args", "anything", "assert", "assert_block", "assert_equal", "assert_in_delta", "assert_instance_of", "assert_kind_of", "assert_match", "assert_nil", "assert_no_match", "assert_not_equal", "assert_not_nil", "assert_not_same", "assert_nothing_raised", "assert_nothing_thrown", "assert_operator", "assert_raise", "assert_raises", "assert_respond_to", "assert_same", "assert_send", "assert_throws", "be", "be_a", "be_a_kind_of", "be_a_new", "be_an", "be_an_instance_of", "be_close", "be_false", "be_instance_of", "be_kind_of", "be_nil", "be_true", "boolean", "build_message", "change", "described_class", "double", "duck_type", "eq", "eql", "equal", "example", "example=", "exist", "expect", "fixture_class_names", "fixture_class_names?", "fixture_path", "fixture_path?", "fixture_table_names", "fixture_table_names?", "flunk", "hash_including", "hash_not_including", "have", "have_at_least", "have_at_most", "have_exactly", "include", "instance_of", "kind_of", "match", "method_missing", "method_name", "mock", "mock_discrepancy", "mock_model", "no_args", "pending", "pre_loaded_fixtures", "pre_loaded_fixtures?", "raise_error", "respond_to", "run_in_transaction?", "running_example", "satisfy", "setup_fixtures", "stub_model", "subject", "teardown_fixtures", "throw_symbol", "use_instantiated_fixtures", "use_instantiated_fixtures?", "use_transactional_fixtures", "use_transactional_fixtures?" Thanks in advance for any help you can provide - sorry for the long email (didn't want to exclude anything...) Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Fri Jun 25 19:15:14 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Fri, 25 Jun 2010 18:15:14 -0500 Subject: [rspec-users] Testing only for a redirect In-Reply-To: <0BD037CE-8E6A-4DCD-BF81-E90B1DF2E692@gmail.com> References: <0BD037CE-8E6A-4DCD-BF81-E90B1DF2E692@gmail.com> Message-ID: I'm still on the Rails 2 era.. so, it worked like a charm with response.should be_redirect. Thanks, Marcelo. On Fri, Jun 25, 2010 at 4:33 PM, David Chelimsky wrote: > > On Jun 25, 2010, at 4:00 PM, Marcelo de Moraes Serpa wrote: > > On Fri, Jun 25, 2010 at 2:18 PM, David Chelimsky wrote: > >> On Fri, Jun 25, 2010 at 1:56 PM, Marcelo de Moraes Serpa >> wrote: >> > Hello guys, >> > >> > Quick question: How could I just test if a redirect was made, without >> URL >> > whatsoever? >> >> In rspec-1/rails-2: >> >> response.should be_redirect >> >> This is not in rspec-rails-2 yet, so you can just go with the rails >> assertion for now: >> >> assert_response :redirect >> >> > Thanks David! :) > > > Sure. > > FYI - looks like you can use be_redirect in rspec-rails-2 because the > TestResponse object responds to redirect?(). Give it a shot: > > response.should be_redirect > > Work? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From celoserpa at gmail.com Fri Jun 25 19:15:34 2010 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Fri, 25 Jun 2010 18:15:34 -0500 Subject: [rspec-users] Testing only for a redirect In-Reply-To: References: <0BD037CE-8E6A-4DCD-BF81-E90B1DF2E692@gmail.com> Message-ID: I meant rspec1.x :) On Fri, Jun 25, 2010 at 6:15 PM, Marcelo de Moraes Serpa < celoserpa at gmail.com> wrote: > I'm still on the Rails 2 era.. so, it worked like a charm with > response.should be_redirect. > > Thanks, > > Marcelo. > > On Fri, Jun 25, 2010 at 4:33 PM, David Chelimsky wrote: > >> >> On Jun 25, 2010, at 4:00 PM, Marcelo de Moraes Serpa wrote: >> >> On Fri, Jun 25, 2010 at 2:18 PM, David Chelimsky wrote: >> >>> On Fri, Jun 25, 2010 at 1:56 PM, Marcelo de Moraes Serpa >>> wrote: >>> > Hello guys, >>> > >>> > Quick question: How could I just test if a redirect was made, without >>> URL >>> > whatsoever? >>> >>> In rspec-1/rails-2: >>> >>> response.should be_redirect >>> >>> This is not in rspec-rails-2 yet, so you can just go with the rails >>> assertion for now: >>> >>> assert_response :redirect >>> >>> >> Thanks David! :) >> >> >> Sure. >> >> FYI - looks like you can use be_redirect in rspec-rails-2 because the >> TestResponse object responds to redirect?(). Give it a shot: >> >> response.should be_redirect >> >> Work? >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jun 25 22:21:01 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 Jun 2010 21:21:01 -0500 Subject: [rspec-users] [Rails] Can't get controller test working with RSpec 2 and edge Rails 3 In-Reply-To: References: Message-ID: <201BD3E3-C65A-48C7-940C-42EEEFE02666@gmail.com> On Jun 25, 2010, at 5:02 PM, Patrick Gannon wrote: > Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to get a standard controller test working - it seems that the 'get' method can't be found. > > I have a controller test that looks like this (named "discrepancies_controller_spec.rb" in spec/controllers directory): > > require 'spec_helper' > > describe DiscrepanciesController do > before :each do > Discrepancy.delete_all > end > > it "resolves a discrepancy" do > discrepancy = Discrepancy.create(:my_number=>"12345", :status=>"Open") > > get :resolve, :id => discrepancy.id > > retrieved_discrepancy = Discrepancy.find_by_my_number("12345") > retrieved_discrepancy.status.should == "Resolved" > end > end > > (Yes, I'm aware of the security implications of modifying data with an HTTP/GET - that's a separate issue...) > When I run it with rake, I get the following error: > > 1) DiscrepanciesController resolves a discrepancy > Failure/Error: Unable to find C to read failed line > undefined method `get' for # > # ./spec/controllers/discrepancies_controller_spec.rb:38 (ignore the line number, commented out code was removed from the sample) > # C:/Users/Patrick_Gannon/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/dependencies.rb:212:in `inject' > # C:/Ruby187/bin/rake:19:in `load' > # C:/Ruby187/bin/rake:19 I'm surprised this is the first time this has come up with rspec-2, but here we are :) This is a path-separator bug that I'll resolve in the next release. For now, you can do this in your controller specs: describe DiscrepanciesController do include RSpec::Rails::ControllerExampleGroup That should work fine. If you want to do a more global workaround, add this to your spec_helper config: RSpec.configure do |c| c.include RSpec::Rails::ControllerExampleGroup, :example_group => { :file_path => /\bspec[\\\/]controllers[\\\/]/ } end HTH, David > > I can manage to test the controller action by instantiating the controller myself and calling the controller action directly, and it works, but its ugly because I have to mock out things like 'respond_to' and 'params'. > > Other pertinent information: I am running Windows 7 32-bit, Ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-wingw32], edge Rails 3 and MongoDB/MongoMapper. Here is my list of installed gems (via 'bundle gem' - all my installed gems were installed by Bundler) > > * abstract (1.0.0) > * actionmailer (3.0.0.beta4) > * actionpack (3.0.0.beta4) > * activemodel (3.0.0.beta4) > * activerecord (3.0.0.beta4) > * activeresource (3.0.0.beta4) > * activesupport (3.0.0.beta4) > * arel (0.4.0) > * bcrypt-ruby (2.1.2) > * bson (1.0.3) > * bson_ext (1.0.1) > * builder (2.1.2) > * bundler (0.9.26) > * capistrano (2.5.19) > * capybara (0.3.8 a94f99) > * cucumber (0.8.3) > * cucumber-rails (0.3.2 master-b75110) > * culerity (0.2.10) > * database_cleaner (0.5.2 7ea99d) > * devise (1.1.rc1 88ab2f) > * diff-lcs (1.1.2) > * erubis (2.6.5) > * factory_girl (1.3.0) > * factory_girl_rails (1.0) > * faker (0.3.1) > * ffi (0.6.3) > * gherkin (2.0.2) > * highline (1.5.2) > * i18n (0.4.1) > * jnunemaker-validatable (1.8.4) > * joint (0.3.2 11a094) > * json_pure (1.4.3) > * mail (2.2.5) > * mime-types (1.16) > * mongo (1.0.3) > * mongo_mapper (0.8.2) > * net-scp (1.0.2) > * net-sftp (2.0.4) > * net-ssh (2.0.23) > * net-ssh-gateway (1.0.1) > * nokogiri (1.4.2.1) > * plucky (0.3.2) > * polyglot (0.3.1) > * rack (1.1.0) > * rack-mount (0.6.6) > * rack-test (0.5.4) > * rails (3.0.0.beta4 6682cc) > * railties (3.0.0.beta4) > * rake (0.8.7) > * rspec (2.0.0.beta.13) > * rspec-core (2.0.0.beta.13) > * rspec-expectations (2.0.0.beta.13) > * rspec-mocks (2.0.0.beta.13) > * rspec-rails (2.0.0.beta.13) > * selenium-webdriver (0.0.24) > * term-ansicolor (1.0.5) > * thor (0.13.6) > * treetop (1.4.8) > * trollop (1.16.2) > * tzinfo (0.3.22) > * wand (0.2.1) > * warden (0.10.7) > * webrat (0.7.1) > > I also added a puts statement in the test to show what methods are available in the test fixture, and "get" is not in the list. Here is what is in the list: > > "__memoized", "__should_for_example_group__", "__should_not_for_example_group__", "_fixture_class_names", "_fixture_path", "_fixture_table_names", "_pre_loaded_fixtures", "_setup_mocks", "_teardown_mocks", "_use_instantiated_fixtures", "_use_transactional_fixtures", "_verify_mocks", "a_kind_of", "allow_message_expectations_on_nil", "an_instance_of", "any_args", "anything", "assert", "assert_block", "assert_equal", "assert_in_delta", "assert_instance_of", "assert_kind_of", "assert_match", "assert_nil", "assert_no_match", "assert_not_equal", "assert_not_nil", > "assert_not_same", "assert_nothing_raised", "assert_nothing_thrown", "assert_operator", "assert_raise", "assert_raises", "assert_respond_to", "assert_same", "assert_send", "assert_throws", "be", "be_a", "be_a_kind_of", "be_a_new", "be_an", "be_an_instance_of", "be_close", "be_false", "be_instance_of", "be_kind_of", "be_nil", "be_true", "boolean", "build_message", "change", "described_class", "double", "duck_type", "eq", "eql", "equal", "example", "example=", "exist", "expect", "fixture_class_names", "fixture_class_names?", "fixture_path", "fixture_path?", "fixture_table_names", > "fixture_table_names?", "flunk", "hash_including", "hash_not_including", "have", "have_at_least", "have_at_most", "have_exactly", "include", "instance_of", "kind_of", "match", "method_missing", "method_name", "mock", "mock_discrepancy", "mock_model", "no_args", "pending", "pre_loaded_fixtures", "pre_loaded_fixtures?", "raise_error", "respond_to", "run_in_transaction?", "running_example", "satisfy", "setup_fixtures", "stub_model", "subject", "teardown_fixtures", "throw_symbol", "use_instantiated_fixtures", "use_instantiated_fixtures?", "use_transactional_fixtures", "use_transactional_fixtures?" > > Thanks in advance for any help you can provide - sorry for the long email (didn't want to exclude anything...) > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Jun 26 01:43:25 2010 From: dchelimsky at gmail.com (dchelimsky at gmail.com) Date: Fri, 25 Jun 2010 22:43:25 -0700 (PDT) Subject: [rspec-users] [Rails] Can't get controller test working with RSpec 2 and edge Rails 3 In-Reply-To: <201BD3E3-C65A-48C7-940C-42EEEFE02666@gmail.com> References: <201BD3E3-C65A-48C7-940C-42EEEFE02666@gmail.com> Message-ID: <244d9712-d604-4ecd-a269-304617cd6359@e5g2000yqn.googlegroups.com> On Jun 25, 9:21?pm, David Chelimsky wrote: > On Jun 25, 2010, at 5:02 PM, Patrick Gannon wrote: > > > > > > > Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to get a standard controller test working - it seems that the 'get' method can't be found. > > > I have a controller test that looks like this (named "discrepancies_controller_spec.rb" in spec/controllers directory): > > > require 'spec_helper' > > > describe DiscrepanciesController do > > ? before :each do > > ? ? Discrepancy.delete_all > > ? end > > > ? it "resolves a discrepancy" do > > ? ?discrepancy = Discrepancy.create(:my_number=>"12345", :status=>"Open") > > > ? ?get :resolve, :id => discrepancy.id > > > ? ?retrieved_discrepancy = Discrepancy.find_by_my_number("12345") > > ? ?retrieved_discrepancy.status.should == "Resolved" > > ? end > > end > > > (Yes, I'm aware of the security implications of modifying data with an HTTP/GET - that's a separate issue...) > > When I run it with rake, I get the following error: > > > 1) DiscrepanciesController resolves a discrepancy > > ? ? Failure/Error: Unable to find C to read failed line > > ? ? undefined method `get' for # > > ? ? # ./spec/controllers/discrepancies_controller_spec.rb:38 (ignore the line number, commented out code was removed from the sample) > > ? ? # C:/Users/Patrick_Gannon/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649f fac24fd5873b875daf66212ad-master/activesupport/lib/active_support/dependenc ies.rb:212:in `inject' > > ? ? # C:/Ruby187/bin/rake:19:in `load' > > ? ? # C:/Ruby187/bin/rake:19 > > I'm surprised this is the first time this has come up with rspec-2, but here we are :) > > This is a path-separator bug that I'll resolve in the next release. For now, you can do this in your controller specs: > > describe DiscrepanciesController do > ? include RSpec::Rails::ControllerExampleGroup > > That should work fine. > > If you want to do a more global workaround, add this to your spec_helper config: > > RSpec.configure do |c| > ? c.include RSpec::Rails::ControllerExampleGroup, :example_group => { :file_path => /\bspec[\\\/]controllers[\\\/]/ } > end > > HTH, > David FYI: http://github.com/rspec/rspec-rails/issues/99 > > > > > > > I can manage to test the controller action by instantiating the controller myself and calling the controller action directly, and it works, but its ugly because I have to mock out things like 'respond_to' and 'params'. > > > Other pertinent information: I am running Windows 7 32-bit, Ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-wingw32], edge Rails 3 and MongoDB/MongoMapper. ?Here is my list of installed gems (via 'bundle gem' - all my installed gems were installed by Bundler) > > > ? * abstract (1.0.0) > > ? * actionmailer (3.0.0.beta4) > > ? * actionpack (3.0.0.beta4) > > ? * activemodel (3.0.0.beta4) > > ? * activerecord (3.0.0.beta4) > > ? * activeresource (3.0.0.beta4) > > ? * activesupport (3.0.0.beta4) > > ? * arel (0.4.0) > > ? * bcrypt-ruby (2.1.2) > > ? * bson (1.0.3) > > ? * bson_ext (1.0.1) > > ? * builder (2.1.2) > > ? * bundler (0.9.26) > > ? * capistrano (2.5.19) > > ? * capybara (0.3.8 a94f99) > > ? * cucumber (0.8.3) > > ? * cucumber-rails (0.3.2 master-b75110) > > ? * culerity (0.2.10) > > ? * database_cleaner (0.5.2 7ea99d) > > ? * devise (1.1.rc1 88ab2f) > > ? * diff-lcs (1.1.2) > > ? * erubis (2.6.5) > > ? * factory_girl (1.3.0) > > ? * factory_girl_rails (1.0) > > ? * faker (0.3.1) > > ? * ffi (0.6.3) > > ? * gherkin (2.0.2) > > ? * highline (1.5.2) > > ? * i18n (0.4.1) > > ? * jnunemaker-validatable (1.8.4) > > ? * joint (0.3.2 11a094) > > ? * json_pure (1.4.3) > > ? * mail (2.2.5) > > ? * mime-types (1.16) > > ? * mongo (1.0.3) > > ? * mongo_mapper (0.8.2) > > ? * net-scp (1.0.2) > > ? * net-sftp (2.0.4) > > ? * net-ssh (2.0.23) > > ? * net-ssh-gateway (1.0.1) > > ? * nokogiri (1.4.2.1) > > ? * plucky (0.3.2) > > ? * polyglot (0.3.1) > > ? * rack (1.1.0) > > ? * rack-mount (0.6.6) > > ? * rack-test (0.5.4) > > ? * rails (3.0.0.beta4 6682cc) > > ? * railties (3.0.0.beta4) > > ? * rake (0.8.7) > > ? * rspec (2.0.0.beta.13) > > ? * rspec-core (2.0.0.beta.13) > > ? * rspec-expectations (2.0.0.beta.13) > > ? * rspec-mocks (2.0.0.beta.13) > > ? * rspec-rails (2.0.0.beta.13) > > ? * selenium-webdriver (0.0.24) > > ? * term-ansicolor (1.0.5) > > ? * thor (0.13.6) > > ? * treetop (1.4.8) > > ? * trollop (1.16.2) > > ? * tzinfo (0.3.22) > > ? * wand (0.2.1) > > ? * warden (0.10.7) > > ? * webrat (0.7.1) > > > I also added a puts statement in the test to show what methods are available in the test fixture, and "get" is not in the list. ?Here is what is in the list: > > > "__memoized", "__should_for_example_group__", "__should_not_for_example_group__", "_fixture_class_names", "_fixture_path", "_fixture_table_names", "_pre_loaded_fixtures", "_setup_mocks", "_teardown_mocks", "_use_instantiated_fixtures", "_use_transactional_fixtures", "_verify_mocks", "a_kind_of", "allow_message_expectations_on_nil", "an_instance_of", "any_args", "anything", "assert", "assert_block", "assert_equal", "assert_in_delta", "assert_instance_of", "assert_kind_of", "assert_match", "assert_nil", "assert_no_match", "assert_not_equal", "assert_not_nil", > > "assert_not_same", "assert_nothing_raised", "assert_nothing_thrown", "assert_operator", "assert_raise", "assert_raises", "assert_respond_to", "assert_same", "assert_send", "assert_throws", "be", "be_a", "be_a_kind_of", "be_a_new", "be_an", "be_an_instance_of", "be_close", "be_false", "be_instance_of", "be_kind_of", "be_nil", "be_true", "boolean", "build_message", "change", "described_class", "double", "duck_type", "eq", "eql", "equal", "example", "example=", "exist", "expect", "fixture_class_names", "fixture_class_names?", "fixture_path", "fixture_path?", "fixture_table_names", > > "fixture_table_names?", "flunk", "hash_including", "hash_not_including", "have", "have_at_least", "have_at_most", "have_exactly", "include", "instance_of", "kind_of", "match", "method_missing", "method_name", "mock", "mock_discrepancy", "mock_model", "no_args", "pending", "pre_loaded_fixtures", "pre_loaded_fixtures?", "raise_error", "respond_to", "run_in_transaction?", "running_example", "satisfy", "setup_fixtures", "stub_model", "subject", "teardown_fixtures", "throw_symbol", "use_instantiated_fixtures", "use_instantiated_fixtures?", "use_transactional_fixtures", "use_transactional_fixtures?" > > > Thanks in advance for any help you can provide - sorry for the long email (didn't want to exclude anything...) > > > Pat > > _______________________________________________ > > 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 From dchelimsky at gmail.com Sat Jun 26 10:24:41 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 26 Jun 2010 09:24:41 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> Message-ID: On Jun 25, 2010, at 4:51 PM, geetarista wrote: > Sorry about that. For some reason I thought Google Reader stripped > that automatically. > > I added ":require => nil" because I had read somewhere that it was > good to do so. Can't remember why or where. Taking it out does not > fix the failure. > > I just haven't upgraded Haml because it's not top priority and I > haven't run into any issues yet. I figured out the problem. It boils down to these two lines in spec/spec_helper.rb ENV["RAILS_ENV"] ||= 'test' require File.dirname(__FILE__) + "/../config/environment" unless defined?(Rails) I'm changing those to this for the next release: ENV['RAILS_ENV'] = ENV['RSPEC_RAILS_ENV'] || 'test' require File.expand_path("../../config/environment", __FILE__) Do that in your spec_helper now and it should work correctly. Please confirm. Thx, David From dark.red.and.yellow at googlemail.com Sat Jun 26 12:53:05 2010 From: dark.red.and.yellow at googlemail.com (=?ISO-8859-1?Q?Timo_R=F6=DFner?=) Date: Sat, 26 Jun 2010 09:53:05 -0700 (PDT) Subject: [rspec-users] rails 3 + latest rspec 2: route set not finalized In-Reply-To: References: <0d54685a-ab1f-450c-a378-9a52e7cee10f@e5g2000yqn.googlegroups.com> Message-ID: <6c94245c-a3f4-4a1c-8995-1f16cfc62d45@y4g2000yqy.googlegroups.com> Hey, it turns out that the culprit was neither rspec nor rails but haml 3.0.11 (seriously). I can reproduce the problem easily: - Set haml-gem to 3.0.11, run "bundle install" -> there is the problem. - Set haml-gem to 3.0.10, run "bundle install" -> everything is ok. The error message was - uhm - misleading at best...:-) I will create a corresponding issue in the haml-group, Cheers. On Jun 25, 3:50?am, David Chelimsky wrote: > On Jun 22, 2010, at 3:29 AM, Timo R??ner wrote: > > > > > Hey guys, > > > i have a problem with latest rails 3 and rspec2.0.0.12beta. > > When running most of my (with rails 2 and rspec 1 working) controller > > specs i get: > > > ? ?route set not finalized > > > I reduced the problem to the max: > > > $ cat config/routes.rb > > Foo::Application.routes.draw do |map| > > ?resources :profiles > > end > > > $ cat spec/controllers/profiles_controller_spec.rb > > > require 'spec_helper' > > describe ProfilesController do > > ?describe 'GET index' do > > ? ?it 'should render the index template' do > > ? ? ?get 'index' > > ? ? ?response.should render_template(:index) > > ? ?end > > ?end > > end > > > -> The spec-run: > > > $ bundle exec spec spec/controllers/profiles_controller_spec.rb > > > F > > > 1) ProfilesController GET index should render the index template > > ? ?Failure/Error: get 'index' > > ? ?route set not finalized > > ? ?# ~/.bundle/ruby/1.8/gems/rack-mount-0.6.6/lib/rack/mount/ > > route_set.rb:208:in `generate' > > ? ?# ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.8/lib/rspec/rails/ > > monkey/action_controller/test_case.rb:111:in `process' > > ? ?# ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.8/lib/rspec/rails/ > > monkey/action_controller/test_case.rb:59:in `get' > > ? ?# ./spec/controllers/profiles_controller_spec.rb:7 > > > Finished in 0.04356 seconds > > 1 example, 1 failures > > > I do realize that the error comes from rack-mount, not rspec itself. > > However, the application itself > > is working as expected, so it has to be something specific about the > > way rspec and rack-mount interact. > > > The relevant part of the Gemfile: > > > gem 'rspec', :git => 'git://github.com/dchelimsky/rspec.git' > > gem 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git' > > $ rails -v > > Rails 3.0.0.beta4 > > Os: Ubuntu Lucid > > > Any ideas? > > The gemfile points to github, but the backtrace above shows rspec-rails-2.0.0.beta.8 installed. Not sure why there is a conflict. Have you run bundle update lately? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Jun 26 13:13:10 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 26 Jun 2010 12:13:10 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> Message-ID: <636AC471-4A56-49B9-A275-3E90E83231E0@gmail.com> On Jun 25, 2010, at 4:51 PM, geetarista wrote: > Sorry about that. For some reason I thought Google Reader stripped > that automatically. > > I added ":require => nil" because I had read somewhere that it was > good to do so. Can't remember why or where. Taking it out does not > fix the failure. > > I just haven't upgraded Haml because it's not top priority and I > haven't run into any issues yet. I've been able to reproduce the issue, and should have a fix in place soon. Assuming I've got the fix, I'll explain what happened once it's pushed to github. Cheers, David From dchelimsky at gmail.com Sat Jun 26 13:30:55 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 26 Jun 2010 12:30:55 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <636AC471-4A56-49B9-A275-3E90E83231E0@gmail.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <07893BC6-BCE1-4012-9914-4836C8079FAC@gmail.com> <331be4a5-af33-4c17-b490-3909b3ff30e0@a30g2000yqn.googlegroups.com> <58B15845-873A-40B8-9539-57570E253D41@gmail.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> <636AC471-4A56-49B9-A275-3E90E83231E0@gmail.com> Message-ID: <363B89C1-B2FA-4CA3-8F38-832BF36DE2F0@gmail.com> On Jun 26, 2010, at 12:13 PM, David Chelimsky wrote: > On Jun 25, 2010, at 4:51 PM, geetarista wrote: > >> Sorry about that. For some reason I thought Google Reader stripped >> that automatically. >> >> I added ":require => nil" because I had read somewhere that it was >> good to do so. Can't remember why or where. Taking it out does not >> fix the failure. >> >> I just haven't upgraded Haml because it's not top priority and I >> haven't run into any issues yet. > > I've been able to reproduce the issue, and should have a fix in place soon. > > Assuming I've got the fix, I'll explain what happened once it's pushed to github. What I believe to be the fix is now up in github. Geetarista, would you do me a favor and update your gemfile to point to the git repos: gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" gem "rspec-expectations", :git => "git://github.com/rspec/rspec-expectations.git" gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" gem "rspec", :git => "git://github.com/rspec/rspec.git" Need to get all of them from git for this to work (just temporary until I get a release out). Then 'bundle install' and 'rake spec' and let me know if all is well. Thanks, David From geetarista at gmail.com Sat Jun 26 23:38:25 2010 From: geetarista at gmail.com (geetarista) Date: Sat, 26 Jun 2010 20:38:25 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <363B89C1-B2FA-4CA3-8F38-832BF36DE2F0@gmail.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> <636AC471-4A56-49B9-A275-3E90E83231E0@gmail.com> <363B89C1-B2FA-4CA3-8F38-832BF36DE2F0@gmail.com> Message-ID: That fixed it. Thanks so much, David! > What I believe to be the fix is now up in github. Geetarista, would you do me a favor and update your gemfile to point to the git repos: > > gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" > gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" > gem "rspec-expectations", :git => "git://github.com/rspec/rspec-expectations.git" > gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" > gem "rspec", :git => "git://github.com/rspec/rspec.git" > > Need to get all of them from git for this to work (just temporary until I get a release out). > > Then 'bundle install' and 'rake spec' and let me know if all is well. > > Thanks, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Jun 26 23:39:58 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 26 Jun 2010 22:39:58 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <846b0936-c7d1-46d8-be1d-0f1a02794e6a@c10g2000yqi.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> <636AC471-4A56-49B9-A275-3E90E83231E0@gmail.com> <363B89C1-B2FA-4CA3-8F38-832BF36DE2F0@gmail.com> Message-ID: On Jun 26, 2010, at 10:38 PM, geetarista wrote: >> What I believe to be the fix is now up in github. Geetarista, would you do me a favor and update your gemfile to point to the git repos: >> >> gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" >> gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" >> gem "rspec-expectations", :git => "git://github.com/rspec/rspec-expectations.git" >> gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" >> gem "rspec", :git => "git://github.com/rspec/rspec.git" >> >> Need to get all of them from git for this to work (just temporary until I get a release out). >> >> Then 'bundle install' and 'rake spec' and let me know if all is well. >> >> Thanks, >> David > That fixed it. Thanks so much, David! Great. Thanks. Release coming in the next day or so. From dchelimsky at gmail.com Sun Jun 27 09:05:26 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 Jun 2010 08:05:26 -0500 Subject: [rspec-users] [rspec-rails-2] conflict with view isolation and respond_with Message-ID: <982AAB10-CC35-40CB-A83C-58B87ED1DD0F@gmail.com> Hey all, For those of you interested in view isolation in controller specs, an issue has been reported with ActionController's new respond_with method. Please take a look at http://github.com/rspec/rspec-rails/issues/103 and add comments if you have any thoughts on the matter. Thanks, David From dhf0820 at gmail.com Sun Jun 27 19:51:01 2010 From: dhf0820 at gmail.com (Don French) Date: Sun, 27 Jun 2010 16:51:01 -0700 (PDT) Subject: [rspec-users] Autotest just returns Message-ID: <5314e6a4-815e-4868-b52a-80f4d6e4a4ed@18g2000prq.googlegroups.com> I am trying to use rspec2 rails with rails3 beta 4. I created a simple project and a couple of models. The basic test spec files are there. When I run bundle spec:models I get what I expect. When I run bundle autotest I get: mauidev:testme dhf$ bundle exec autotest loading autotest/rails_rspec2 mauidev:testme dhf$ and that is it. My Gemfile contains: gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" gem "rspec-expectations", :git => "git://github.com/rspec/rspec- expectations.git" gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" gem "rspec", :git => "git://github.com/rspec/rspec.git" gem 'autotest-rails' gem 'autotest' gem 'autotest-fsevent' gem 'autotest-growl' Any Ideas? Don French From dchelimsky at gmail.com Sun Jun 27 20:09:28 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 Jun 2010 19:09:28 -0500 Subject: [rspec-users] Autotest just returns In-Reply-To: <5314e6a4-815e-4868-b52a-80f4d6e4a4ed@18g2000prq.googlegroups.com> References: <5314e6a4-815e-4868-b52a-80f4d6e4a4ed@18g2000prq.googlegroups.com> Message-ID: <595FB788-F777-4BAD-BE3F-FD66DB15EEAB@gmail.com> On Jun 27, 2010, at 6:51 PM, Don French wrote: > I am trying to use rspec2 rails with rails3 beta 4. I created a simple > project and a couple of models. The basic test spec files are there. > When I run bundle spec:models I get what I expect. When I run bundle > autotest I get: > > mauidev:testme dhf$ bundle exec autotest > loading autotest/rails_rspec2 > mauidev:testme dhf$ > > and that is it. > > My Gemfile contains: > > gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" > gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" > gem "rspec-expectations", :git => "git://github.com/rspec/rspec- > expectations.git" > gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" > gem "rspec", :git => "git://github.com/rspec/rspec.git" > gem 'autotest-rails' > gem 'autotest' > gem 'autotest-fsevent' > gem 'autotest-growl' > > > Any Ideas? Have you run "script/rails g rspec:install"? Otherwise everything looks right to me. From dhf0820 at gmail.com Sun Jun 27 21:14:23 2010 From: dhf0820 at gmail.com (Don French) Date: Sun, 27 Jun 2010 18:14:23 -0700 (PDT) Subject: [rspec-users] Autotest just returns In-Reply-To: <595FB788-F777-4BAD-BE3F-FD66DB15EEAB@gmail.com> References: <5314e6a4-815e-4868-b52a-80f4d6e4a4ed@18g2000prq.googlegroups.com> <595FB788-F777-4BAD-BE3F-FD66DB15EEAB@gmail.com> Message-ID: <960c5155-59d5-43df-a3f2-03ea8b030e66@y19g2000pro.googlegroups.com> Sure did. Just ran it again: identical .rspec exist spec identical spec/spec_helper.rb exist lib identical lib/tasks/rspec.rake identical config/initializers/rspec_generator.rb exist autotest identical autotest/discover.rb I am running everything under bundle exec. That is correct, right On Jun 27, 2:09?pm, David Chelimsky wrote: > On Jun 27, 2010, at 6:51 PM, Don French wrote: > > > > > I am trying to use rspec2 rails with rails3 beta 4. I created a simple > > project and a couple of models. The basic test spec files are there. > > When I run bundle spec:models I get what I expect. When I run bundle > > autotest I get: > > > mauidev:testme dhf$ bundle exec autotest > > loading autotest/rails_rspec2 > > mauidev:testme dhf$ > > > and that is it. > > > My Gemfile contains: > > > gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" > > gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" > > gem "rspec-expectations", :git => "git://github.com/rspec/rspec- > > expectations.git" > > gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" > > gem "rspec", :git => "git://github.com/rspec/rspec.git" > > gem 'autotest-rails' > > gem 'autotest' > > gem 'autotest-fsevent' > > gem 'autotest-growl' > > > Any Ideas? > > Have you run "script/rails g rspec:install"? Otherwise everything looks right to me. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sun Jun 27 23:32:33 2010 From: lists at ruby-forum.com (Woody Peterson) Date: Mon, 28 Jun 2010 05:32:33 +0200 Subject: [rspec-users] have_tag matcher in rspec 2? Message-ID: <5634bf06e0c4b7c264f24e8b5ac98c57@ruby-forum.com> I always assumed have_tag was part of rspec, but it's not in rspec 2, and looking now I don't see it in rspec 1 either. Webrat defines it, but that seems like a coincidence (I tried requiring webrat/core/matchers to no avail). Is it depricated, not yet implemented, or does it work for everyone else? My project is from scratch, rspec-rails 2b13, using generated spec_helper. Thanks in advance! -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Jun 27 23:42:14 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 Jun 2010 22:42:14 -0500 Subject: [rspec-users] have_tag matcher in rspec 2? In-Reply-To: <5634bf06e0c4b7c264f24e8b5ac98c57@ruby-forum.com> References: <5634bf06e0c4b7c264f24e8b5ac98c57@ruby-forum.com> Message-ID: <2FF1F4E7-6589-4235-B8D7-609D2B59DE8E@gmail.com> On Jun 27, 2010, at 10:32 PM, Woody Peterson wrote: > I always assumed have_tag was part of rspec, but it's not in rspec 2, > and looking now I don't see it in rspec 1 either. Webrat defines it, but > that seems like a coincidence (I tried requiring webrat/core/matchers to > no avail). > > Is it depricated, not yet implemented, or does it work for everyone > else? > > My project is from scratch, rspec-rails 2b13, using generated > spec_helper. RSpec-2 will not include have_tag. Use webrat's have_selector matcher instead. HTH, David From alex at alexcrichton.com Mon Jun 28 01:22:01 2010 From: alex at alexcrichton.com (Alex Crichton) Date: Sun, 27 Jun 2010 22:22:01 -0700 (PDT) Subject: [rspec-users] ApplicationController helper methods in view specs? Message-ID: I've got some helper methods in my ApplicationController which the views use. In the view specs the methods are all undefined, however. Is this intended and is there some setting I need to use to get the methods included? From julien.palmas at gmail.com Mon Jun 28 07:10:17 2010 From: julien.palmas at gmail.com (Julien) Date: Mon, 28 Jun 2010 04:10:17 -0700 (PDT) Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> <636AC471-4A56-49B9-A275-3E90E83231E0@gmail.com> <363B89C1-B2FA-4CA3-8F38-832BF36DE2F0@gmail.com> Message-ID: <846c3d62-aea9-449c-8364-c9c640fb1a02@c33g2000yqm.googlegroups.com> Thank you all for this discussion and the fix I ran into the same issue this morning, but with "Factory" being the class that was undefined (using Factory Girl) The fix explained in this discussion worked for me. As a reminder for others : 1 - update spec_helper require File.expand_path("../../config/environment", __FILE__) instead of require File.dirname(__FILE__) + "/../config/environment" unless defined?(Rails) 2 - update gemfile gem 'rspec-rails', "2.0.0.beta.14.1" 3 - bundle install or bundle update (depending on your version of bundler) On Jun 27, 5:39?am, David Chelimsky wrote: > On Jun 26, 2010, at 10:38 PM, geetarista wrote: > > >> What I believe to be the fix is now up in github. Geetarista, would you do me a favor and update your gemfile to point to the git repos: > > >> gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" > >> gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" > >> gem "rspec-expectations", :git => "git://github.com/rspec/rspec-expectations.git" > >> gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" > >> gem "rspec", :git => "git://github.com/rspec/rspec.git" > > >> Need to get all of them from git for this to work (just temporary until I get a release out). > > >> Then 'bundle install' and 'rake spec' and let me know if all is well. > > >> Thanks, > >> David > > That fixed it. ?Thanks so much, David! > > Great. Thanks. Release coming in the next day or so. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Jun 28 07:51:13 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 06:51:13 -0500 Subject: [rspec-users] Autotest just returns In-Reply-To: <960c5155-59d5-43df-a3f2-03ea8b030e66@y19g2000pro.googlegroups.com> References: <5314e6a4-815e-4868-b52a-80f4d6e4a4ed@18g2000prq.googlegroups.com> <595FB788-F777-4BAD-BE3F-FD66DB15EEAB@gmail.com> <960c5155-59d5-43df-a3f2-03ea8b030e66@y19g2000pro.googlegroups.com> Message-ID: On Sun, Jun 27, 2010 at 8:14 PM, Don French wrote: > On Jun 27, 2:09?pm, David Chelimsky wrote: >> On Jun 27, 2010, at 6:51 PM, Don French wrote: >> >> > I am trying to use rspec2 rails with rails3 beta 4. I created a simple >> > project and a couple of models. The basic test spec files are there. >> > When I run bundle spec:models I get what I expect. When I run bundle >> > autotest I get: >> >> > mauidev:testme dhf$ bundle exec autotest >> > loading autotest/rails_rspec2 >> > mauidev:testme dhf$ >> >> > and that is it. >> >> > My Gemfile contains: >> >> > gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" >> > gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" >> > gem "rspec-expectations", :git => "git://github.com/rspec/rspec- >> > expectations.git" >> > gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" >> > gem "rspec", :git => "git://github.com/rspec/rspec.git" >> > gem 'autotest-rails' >> > gem 'autotest' >> > gem 'autotest-fsevent' >> > gem 'autotest-growl' >> >> > Any Ideas? >> >> Have you run "script/rails g rspec:install"? Otherwise everything looks right to me. > Sure did. Just ran it again: > ? identical ?.rspec > ? ? ? exist ?spec > ? identical ?spec/spec_helper.rb > ? ? ? exist ?lib > ? identical ?lib/tasks/rspec.rake > ? identical ?config/initializers/rspec_generator.rb > ? ? ? exist ?autotest > ? identical ?autotest/discover.rb > > I am running everything under bundle exec. That is correct, right What OS, Ruby version, etc? ps - please post in-line or at the bottom so we can follow the thread (I moved your top post down). From dchelimsky at gmail.com Mon Jun 28 08:45:46 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 07:45:46 -0500 Subject: [rspec-users] Rake spec failure in beta.13 In-Reply-To: <846c3d62-aea9-449c-8364-c9c640fb1a02@c33g2000yqm.googlegroups.com> References: <5701b960-9566-4e8c-9fa7-8f9a4492be59@k39g2000yqb.googlegroups.com> <34c0c945-209e-4a6c-8562-89a9940b8836@5g2000yqz.googlegroups.com> <37A3CA3F-3F8B-4EF6-9A93-7C70D22B07D0@gmail.com> <6065cdcc-61d0-4f47-b24f-58fcb12ae981@e5g2000yqn.googlegroups.com> <5E9032CF-3083-4ED0-9020-9847FF505A24@gmail.com> <8788ab97-857d-4d3f-8c69-30b14016057f@g19g2000yqc.googlegroups.com> <841028e0-58f9-45a2-aa3e-ded7bbe4f881@k39g2000yqb.googlegroups.com> <6A61F1A2-2DE2-48D5-B019-527FFF5D7989@wincent.com> <636AC471-4A56-49B9-A275-3E90E83231E0@gmail.com> <363B89C1-B2FA-4CA3-8F38-832BF36DE2F0@gmail.com> <846c3d62-aea9-449c-8364-c9c640fb1a02@c33g2000yqm.googlegroups.com> Message-ID: <96B88712-A011-4E7C-BBFB-1B01C8D7E24C@gmail.com> On Jun 28, 2010, at 6:10 AM, Julien wrote: > On Jun 27, 5:39 am, David Chelimsky wrote: >> On Jun 26, 2010, at 10:38 PM, geetarista wrote: >> >>>> What I believe to be the fix is now up in github. Geetarista, would you do me a favor and update your gemfile to point to the git repos: >> >>>> gem "rspec-rails", :git => "git://github.com/rspec/rspec-rails.git" >>>> gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" >>>> gem "rspec-expectations", :git => "git://github.com/rspec/rspec-expectations.git" >>>> gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" >>>> gem "rspec", :git => "git://github.com/rspec/rspec.git" >> >>>> Need to get all of them from git for this to work (just temporary until I get a release out). >> >>>> Then 'bundle install' and 'rake spec' and let me know if all is well. >> >>>> Thanks, >>>> David >>> That fixed it. Thanks so much, David! >> >> Great. Thanks. Release coming in the next day or so. > Thank you all for this discussion and the fix > > I ran into the same issue this morning, but with "Factory" being the > class that was undefined (using Factory Girl) > > The fix explained in this discussion worked for me. > As a reminder for others : > > 1 - update spec_helper > require File.expand_path("../../config/environment", __FILE__) > instead of > require File.dirname(__FILE__) + "/../config/environment" unless > defined?(Rails) This is already updated in 2.0.0.beta.14.1 - you just have to follow the installation instructions and re-run 'script/rails generate rspec-install' > > 2 - update gemfile > gem 'rspec-rails', "2.0.0.beta.14.1" > > 3 - bundle install or bundle update (depending on your version of > bundler) From dchelimsky at gmail.com Mon Jun 28 08:48:33 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 07:48:33 -0500 Subject: [rspec-users] ApplicationController helper methods in view specs? In-Reply-To: References: Message-ID: <7A77BFB7-F9B6-46CE-AC01-19D3894375FC@gmail.com> On Jun 28, 2010, at 12:22 AM, Alex Crichton wrote: > I've got some helper methods in my ApplicationController which the > views use. In the view specs the methods are all undefined, however. > Is this intended and is there some setting I need to use to get the > methods included? View specs don't know anything about your controllers, so if you're defining helpers in controllers you have to stub them in view specs. Why not put them a helper instead? From dark.red.and.yellow at googlemail.com Mon Jun 28 11:00:01 2010 From: dark.red.and.yellow at googlemail.com (=?ISO-8859-1?Q?Timo_R=F6=DFner?=) Date: Mon, 28 Jun 2010 08:00:01 -0700 (PDT) Subject: [rspec-users] rspec 2 not cleaning up after examples run? Message-ID: Hey guys, I let the code speak for itself: Below are my currently failing specs, please don't pay too much attention to the specs themselves, I just want to give you a "real life example" of what's happening - the only interesting thing about the specs is that there is a call to Factory(:challenge) in each of them and a before-each-call putting out what's currently in the database: describe 'featuring' do before(:each) do puts "Before Each:" puts "Featured Challenges size: #{Challenge.featured.size}" puts "Challenges count: #{Challenge.count}" end it 'should tell if a challenge is featured' do challenge = Factory(:challenge, :feature_position => 1) challenge.should be_featured end it 'should tell if a challenge is not featured' do challenge = Factory(:challenge, :feature_position => 0) challenge.should_not be_featured end it 'should feature a challenge' do challenge = Factory(:challenge) challenge.feature! Challenge.featured.should == [challenge] end it 'should unfeature a challenge' do challenge = Factory(:challenge, :feature_position => 1) challenge.unfeature! Challenge.featured.should be_empty end end Now to the interesting part: A spec run using rails 2.3.5 and rspec 1: bundle exec spec spec/models/challenge_spec.rb Before Each: Featured Challenges size: 0 Challenges count: 0 .Before Each: Featured Challenges size: 0 Challenges count: 0 .Before Each: Featured Challenges size: 0 Challenges count: 0 .Before Each: Featured Challenges size: 0 Challenges count: 0 .............................. -> Looks good. Here's the exact same spec run with rspec-2.0.0.beta.13 and rails-3.0.0.beta4: Before Each: Featured Challenges size: 0 Challenges count: 0 Before Each: Featured Challenges size: 1 Challenges count: 1 .Before Each: Featured Challenges size: 1 Challenges count: 2 Before Each: Featured Challenges size: 2 Challenges count: 3 So apparently the latest rspec doesn't clean up after examples at all? Is this a bug or a feature? From dchelimsky at gmail.com Mon Jun 28 11:03:55 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 10:03:55 -0500 Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: References: Message-ID: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: > Hey guys, > > I let the code speak for itself: > > Below are my currently failing specs, please don't pay too much > attention to the specs themselves, I just want to give you a "real > life example" of what's happening - the only interesting thing about > the specs is that there is a call to Factory(:challenge) in each of > them and a before-each-call putting out what's currently in the > database: > > describe 'featuring' do > > before(:each) do > puts "Before Each:" > puts "Featured Challenges size: #{Challenge.featured.size}" > puts "Challenges count: #{Challenge.count}" > end > > it 'should tell if a challenge is featured' do > challenge = Factory(:challenge, :feature_position => 1) > challenge.should be_featured > end > > it 'should tell if a challenge is not featured' do > challenge = Factory(:challenge, :feature_position => 0) > challenge.should_not be_featured > end > > it 'should feature a challenge' do > challenge = Factory(:challenge) > challenge.feature! > Challenge.featured.should == [challenge] > end > > it 'should unfeature a challenge' do > challenge = Factory(:challenge, :feature_position => 1) > challenge.unfeature! > Challenge.featured.should be_empty > end > end > > Now to the interesting part: > > A spec run using rails 2.3.5 and rspec 1: > > bundle exec spec spec/models/challenge_spec.rb > Before Each: > Featured Challenges size: 0 > Challenges count: 0 > .Before Each: > Featured Challenges size: 0 > Challenges count: 0 > .Before Each: > Featured Challenges size: 0 > Challenges count: 0 > .Before Each: > Featured Challenges size: 0 > Challenges count: 0 > .............................. > > -> Looks good. > > Here's the exact same spec run with rspec-2.0.0.beta.13 and > rails-3.0.0.beta4: > > Before Each: > Featured Challenges size: 0 > Challenges count: 0 > Before Each: > Featured Challenges size: 1 > Challenges count: 1 > .Before Each: > Featured Challenges size: 1 > Challenges count: 2 > Before Each: > Featured Challenges size: 2 > Challenges count: 3 > > So apparently the latest rspec doesn't clean up after examples at all? > > Is this a bug or a feature? Bug, but please check if it's still true of beta.14.1. Thx From dark.red.and.yellow at googlemail.com Mon Jun 28 11:30:40 2010 From: dark.red.and.yellow at googlemail.com (=?ISO-8859-1?Q?Timo_R=F6=DFner?=) Date: Mon, 28 Jun 2010 08:30:40 -0700 (PDT) Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> Message-ID: <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> Hey David, I just tried it out using the latest rspec and rspec-rails: Gemfile: gem 'rspec', '2.0.0.beta.14' gem 'rspec-rails', '2.0.0.beta.14.1 $ bundle show rspec ~/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.14 $bundle show rspec-rails ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.14.1 Unfortunately, the bug still exists when using this configuration: Before Each: Featured Challenges size: 0 Challenges count: 0 .Before Each: Featured Challenges size: 1 Challenges count: 1 .Before Each: Featured Challenges size: 1 Challenges count: 2 FBefore Each: Featured Challenges size: 2 Challenges count: 3 On Jun 28, 5:03?pm, David Chelimsky wrote: > On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: > > > > > Hey guys, > > > I let the code speak for itself: > > > Below are my currently failing specs, please don't pay too much > > attention to the specs themselves, I just want to give you a "real > > life example" of what's happening - the only interesting thing about > > the specs is that there is a call to Factory(:challenge) in each of > > them and a before-each-call putting out what's currently in the > > database: > > > ?describe 'featuring' do > > > ? ?before(:each) do > > ? ? ?puts "Before Each:" > > ? ? ?puts "Featured Challenges size: #{Challenge.featured.size}" > > ? ? ?puts "Challenges count: #{Challenge.count}" > > ? ?end > > > ? ?it 'should tell if a challenge is featured' do > > ? ? ?challenge = Factory(:challenge, :feature_position => 1) > > ? ? ?challenge.should be_featured > > ? ?end > > > ? ?it 'should tell if a challenge is not featured' do > > ? ? ?challenge = Factory(:challenge, :feature_position => 0) > > ? ? ?challenge.should_not be_featured > > ? ?end > > > ? ?it 'should feature a challenge' do > > ? ? ?challenge = Factory(:challenge) > > ? ? ?challenge.feature! > > ? ? ?Challenge.featured.should == [challenge] > > ? ?end > > > ? ?it 'should unfeature a challenge' do > > ? ? ?challenge = Factory(:challenge, :feature_position => 1) > > ? ? ?challenge.unfeature! > > ? ? ?Challenge.featured.should be_empty > > ? ?end > > ?end > > > Now to the interesting part: > > > A spec run using rails 2.3.5 and rspec 1: > > > bundle exec spec spec/models/challenge_spec.rb > > Before Each: > > Featured Challenges size: 0 > > Challenges count: 0 > > .Before Each: > > Featured Challenges size: 0 > > Challenges count: 0 > > .Before Each: > > Featured Challenges size: 0 > > Challenges count: 0 > > .Before Each: > > Featured Challenges size: 0 > > Challenges count: 0 > > .............................. > > > -> Looks good. > > > Here's the exact same spec run with rspec-2.0.0.beta.13 and > > rails-3.0.0.beta4: > > > Before Each: > > Featured Challenges size: 0 > > Challenges count: 0 > > Before Each: > > Featured Challenges size: 1 > > Challenges count: 1 > > .Before Each: > > Featured Challenges size: 1 > > Challenges count: 2 > > Before Each: > > Featured Challenges size: 2 > > Challenges count: 3 > > > So apparently the latest rspec doesn't clean up after examples at all? > > > Is this a bug or a feature? > > Bug, but please check if it's still true of beta.14.1. > > Thx > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Jun 28 11:35:02 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 10:35:02 -0500 Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> Message-ID: On Jun 28, 2010, at 10:30 AM, Timo R??ner wrote: > On Jun 28, 5:03 pm, David Chelimsky wrote: >> On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: >> >> >> >>> Hey guys, >> >>> I let the code speak for itself: >> >>> Below are my currently failing specs, please don't pay too much >>> attention to the specs themselves, I just want to give you a "real >>> life example" of what's happening - the only interesting thing about >>> the specs is that there is a call to Factory(:challenge) in each of >>> them and a before-each-call putting out what's currently in the >>> database: >> >>> describe 'featuring' do >> >>> before(:each) do >>> puts "Before Each:" >>> puts "Featured Challenges size: #{Challenge.featured.size}" >>> puts "Challenges count: #{Challenge.count}" >>> end >> >>> it 'should tell if a challenge is featured' do >>> challenge = Factory(:challenge, :feature_position => 1) >>> challenge.should be_featured >>> end >> >>> it 'should tell if a challenge is not featured' do >>> challenge = Factory(:challenge, :feature_position => 0) >>> challenge.should_not be_featured >>> end >> >>> it 'should feature a challenge' do >>> challenge = Factory(:challenge) >>> challenge.feature! >>> Challenge.featured.should == [challenge] >>> end >> >>> it 'should unfeature a challenge' do >>> challenge = Factory(:challenge, :feature_position => 1) >>> challenge.unfeature! >>> Challenge.featured.should be_empty >>> end >>> end >> >>> Now to the interesting part: >> >>> A spec run using rails 2.3.5 and rspec 1: >> >>> bundle exec spec spec/models/challenge_spec.rb >>> Before Each: >>> Featured Challenges size: 0 >>> Challenges count: 0 >>> .Before Each: >>> Featured Challenges size: 0 >>> Challenges count: 0 >>> .Before Each: >>> Featured Challenges size: 0 >>> Challenges count: 0 >>> .Before Each: >>> Featured Challenges size: 0 >>> Challenges count: 0 >>> .............................. >> >>> -> Looks good. >> >>> Here's the exact same spec run with rspec-2.0.0.beta.13 and >>> rails-3.0.0.beta4: >> >>> Before Each: >>> Featured Challenges size: 0 >>> Challenges count: 0 >>> Before Each: >>> Featured Challenges size: 1 >>> Challenges count: 1 >>> .Before Each: >>> Featured Challenges size: 1 >>> Challenges count: 2 >>> Before Each: >>> Featured Challenges size: 2 >>> Challenges count: 3 >> >>> So apparently the latest rspec doesn't clean up after examples at all? >> >>> Is this a bug or a feature? >> >> Bug, but please check if it's still true of beta.14.1. >> > Hey David, > > I just tried it out using the latest rspec and rspec-rails: > > Gemfile: > > gem 'rspec', '2.0.0.beta.14' > gem 'rspec-rails', '2.0.0.beta.14.1 > > $ bundle show rspec > ~/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.14 > > $bundle show rspec-rails > ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.14.1 > > Unfortunately, the bug still exists when using this configuration: > > Before Each: > Featured Challenges size: 0 > Challenges count: 0 > .Before Each: > Featured Challenges size: 1 > Challenges count: 1 > .Before Each: > Featured Challenges size: 1 > Challenges count: 2 > FBefore Each: > Featured Challenges size: 2 > Challenges count: 3 What's in your Gemfile and spec/spec_helper.rb? ps - please post in-line or at the bottom so we can follow the thread. From muchira at gmail.com Mon Jun 28 14:14:19 2010 From: muchira at gmail.com (bertly_the_coder) Date: Mon, 28 Jun 2010 11:14:19 -0700 (PDT) Subject: [rspec-users] undefined method Message-ID: <84be0f1e-3108-41e2-972f-fd021e6d9319@5g2000yqz.googlegroups.com> Hey Guys, I am working on my first TDD/BDDD example and running into a problem, when I run 'ruby app.rb" The app seems to run fine, but when I run it's rspec 'spec app_spec.rb" I get a no method defined. app.rb require 'rubygems' require 'open-uri' require 'hpricot' class Timer #this is the retrieve method used to retrieve the contents of the xml file def self.retrieve doc = Hpricot(open('some site')) #get the times times = doc/"//times" puts times end end Timer.retrieve - this works fine rspec require 'app' describe Timer do it "should retrieve the xml info from the site" do Timer.should retrieve end end error: NameError in 'Timer should retrieve the xml info from the site' undefined local variable or method `retrieve' for # ./app.rb:7: Hope that's clear enough, I am a tad confused about what's going on, it looks pretty clear cut. From curtis.schofield at gmail.com Mon Jun 28 14:31:53 2010 From: curtis.schofield at gmail.com (Curtis j Schofield) Date: Mon, 28 Jun 2010 11:31:53 -0700 Subject: [rspec-users] Rspec Message-ID: Hi - I extracted some methods in a refactor and put them into a nice module and i'm in the process of making sure it is covered as a first-class unit. I'm getting some strange behavior with what seems really straight forward code. https://gist.github.com/6d54448d70b07a126c51 From dchelimsky at gmail.com Mon Jun 28 14:50:11 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 13:50:11 -0500 Subject: [rspec-users] Rspec In-Reply-To: References: Message-ID: <57CBEBAB-DEE9-437A-8121-FE6C3616E712@gmail.com> On Jun 28, 2010, at 1:31 PM, Curtis j Schofield wrote: > Hi - I extracted some methods in a refactor and put them into a nice > module and i'm in the process of making sure it is covered as a > first-class unit. > > I'm getting some strange behavior with what seems really straight forward code. > > https://gist.github.com/6d54448d70b07a126c51 should_receive replaces the method in question, so when you say: @foo.should_receive(:toad_string) the actual toad_string method is never invoked, hence control is not passed on to toad_nokogiri_xml_document. In general, mocking and stubbing methods on the object your testing should be avoided, for exactly this reason. HTH, David From dchelimsky at gmail.com Mon Jun 28 15:00:45 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 14:00:45 -0500 Subject: [rspec-users] undefined method In-Reply-To: <84be0f1e-3108-41e2-972f-fd021e6d9319@5g2000yqz.googlegroups.com> References: <84be0f1e-3108-41e2-972f-fd021e6d9319@5g2000yqz.googlegroups.com> Message-ID: On Jun 28, 2010, at 1:14 PM, bertly_the_coder wrote: > Hey Guys, > I am working on my first TDD/BDDD example and running into a problem, > when I run 'ruby app.rb" The app seems to run fine, but when I run > it's rspec 'spec app_spec.rb" I get a no method defined. > > app.rb > require 'rubygems' > require 'open-uri' > require 'hpricot' > > class Timer > #this is the retrieve method used to retrieve the contents of the xml > file > > def self.retrieve > doc = Hpricot(open('some site')) > #get the times > times = doc/"//times" > puts times > end > end > > Timer.retrieve - this works fine > > rspec > require 'app' > > describe Timer do > it "should retrieve the xml info from the site" do > Timer.should retrieve > end > > end > > error: > NameError in 'Timer should retrieve the xml info from the site' > undefined local variable or method `retrieve' for > # > ./app.rb:7: This error tells you that there is no retrieve() method on the example itself, but the expression "Timer.should retrieve" expects there to be. Try something like this: describe Timer do it "retrieves xml from the site" do Timer.retrieve.should == "whatever you're expecting" end end > Hope that's clear enough, I am a tad confused about what's going on, > it looks pretty clear cut. From curtis.schofield at gmail.com Mon Jun 28 16:03:18 2010 From: curtis.schofield at gmail.com (Curtis j Schofield) Date: Mon, 28 Jun 2010 13:03:18 -0700 Subject: [rspec-users] Rspec In-Reply-To: <57CBEBAB-DEE9-437A-8121-FE6C3616E712@gmail.com> References: <57CBEBAB-DEE9-437A-8121-FE6C3616E712@gmail.com> Message-ID: Any suggestions for how to detect that the methods are getting executed that need to get executed? On Mon, Jun 28, 2010 at 11:50 AM, David Chelimsky wrote: > On Jun 28, 2010, at 1:31 PM, Curtis j Schofield wrote: > >> Hi - I extracted some methods in a refactor and put them into a nice >> module and i'm in the process of making sure it is covered as a >> first-class unit. >> >> I'm getting some strange behavior with what seems really straight forward code. >> >> https://gist.github.com/6d54448d70b07a126c51 > > should_receive replaces the method in question, so when you say: > > ?@foo.should_receive(:toad_string) > > the actual toad_string method is never invoked, hence control is not passed on to toad_nokogiri_xml_document. > > In general, mocking and stubbing methods on the object your testing should be avoided, for exactly this reason. > > HTH, > David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Jun 28 16:32:54 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Jun 2010 15:32:54 -0500 Subject: [rspec-users] Rspec In-Reply-To: References: <57CBEBAB-DEE9-437A-8121-FE6C3616E712@gmail.com> Message-ID: <262FB37B-357E-42AF-9238-F64957A73822@gmail.com> On Jun 28, 2010, at 3:03 PM, Curtis j Schofield wrote: > On Mon, Jun 28, 2010 at 11:50 AM, David Chelimsky wrote: >> On Jun 28, 2010, at 1:31 PM, Curtis j Schofield wrote: >> >>> Hi - I extracted some methods in a refactor and put them into a nice >>> module and i'm in the process of making sure it is covered as a >>> first-class unit. >>> >>> I'm getting some strange behavior with what seems really straight forward code. >>> >>> https://gist.github.com/6d54448d70b07a126c51 >> >> should_receive replaces the method in question, so when you say: >> >> @foo.should_receive(:toad_string) >> >> the actual toad_string method is never invoked, hence control is not passed on to toad_nokogiri_xml_document. >> >> In general, mocking and stubbing methods on the object your testing should be avoided, for exactly this reason. > Any suggestions for how to detect that the methods are getting executed that need to get executed? In general, I'd recommend avoiding this sort of binding to internal implementation. This is not the same thing as specifying that an object plays correctly with another object, in which case mocking methods on the _other_ object is a common practice. In this case, however, you have a single object that has an API and produces different results depending on what you send to it. So I'd specify that. If you really feel that you need to specify the internal delegation, then do it one method at a time: describe Foo do describe "a" do it "delegates to b" do foo = Foo.new foo.should_receive(:b) foo.a end end describe "b" do it "delegates to c" do foo = Foo.new foo.should_receive(:c) foo.b end end end class Foo def a b end def b c end def c "end of the line" end end HTH, David PS - I moved your post from the top. Please post in line or at the bottom so readers can follow the thread. From programmer2188 at gmail.com Mon Jun 28 22:58:25 2010 From: programmer2188 at gmail.com (Brandon Olivares) Date: Mon, 28 Jun 2010 22:58:25 -0400 Subject: [rspec-users] Using RSpec and Cucumber with Rails 3 Engines Message-ID: <01e801cb1736$f2ae1980$d80a4c80$@com> Hi, I recently upgraded to Rails 3 beta, a few weeks ago. One thing I would really like to do is to develop components of my application, because some of them I'd really like to be able to reuse on other projects. I know how to make engines well enough, but it seems difficult or impossible to test them with RSpec and Cucumber. At least with Cucumber, it won't run because it's not a normal Rails application. Is there a way to get around this, or what alternative would you recommend? Thanks, Brandon From muchira at gmail.com Mon Jun 28 18:49:07 2010 From: muchira at gmail.com (bertly_the_coder) Date: Mon, 28 Jun 2010 15:49:07 -0700 (PDT) Subject: [rspec-users] undefined method In-Reply-To: References: <84be0f1e-3108-41e2-972f-fd021e6d9319@5g2000yqz.googlegroups.com> Message-ID: <0b477a63-fc49-49f0-af85-f9981a50ebce@j4g2000yqh.googlegroups.com> Thanks David, That helps a lot and makes a lot of sense. Neat article by the way, was following to get a hang on rspec. Cheers! On Jun 28, 3:00?pm, David Chelimsky wrote: > On Jun 28, 2010, at 1:14 PM, bertly_the_coder wrote: > > > > > Hey Guys, > > I am working on my first TDD/BDDD example and running into a problem, > > when I run 'ruby app.rb" The app seems to run fine, but when I run > > it's rspec 'spec app_spec.rb" I get a no method defined. > > > app.rb > > require 'rubygems' > > require 'open-uri' > > require 'hpricot' > > > class Timer > > ? ?#this is the retrieve method used to retrieve the contents of the xml > > file > > > ? ?def self.retrieve > > ? ? ? ? ? ?doc = Hpricot(open('some site')) > > ? ? ? ? ? ?#get the times > > ? ? ? ? ? ?times = doc/"//times" > > ? ? ? ? ? ?puts times > > ? ?end > > end > > > Timer.retrieve - this works fine > > > rspec > > require 'app' > > > describe Timer do > > ? ?it "should retrieve the xml info from the site" do > > ? ? ? ? ? ?Timer.should retrieve > > ?end > > > end > > > error: > > NameError in 'Timer should retrieve the xml info from the site' > > undefined local variable or method `retrieve' for > > # > > ./app.rb:7: > > This error tells you that there is no retrieve() method on the example itself, but the expression "Timer.should retrieve" expects there to be. > > Try something like this: > > describe Timer do > ? it "retrieves xml from the site" do > ? ? Timer.retrieve.should == "whatever you're expecting" > ? end > end > > > Hope that's clear enough, I am a tad confused about what's going on, > > it looks pretty clear cut. > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Tue Jun 29 01:54:10 2010 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 29 Jun 2010 07:54:10 +0200 Subject: [rspec-users] Using RSpec and Cucumber with Rails 3 Engines In-Reply-To: <01e801cb1736$f2ae1980$d80a4c80$@com> References: <01e801cb1736$f2ae1980$d80a4c80$@com> Message-ID: On Tue, Jun 29, 2010 at 4:58 AM, Brandon Olivares wrote: > Hi, > > I recently upgraded to Rails 3 beta, a few weeks ago. One thing I would > really like to do is to develop components of my application, because some > of them I'd really like to be able to reuse on other projects. I know how to > make engines well enough, but it seems difficult or impossible to test them > with RSpec and Cucumber. At least with Cucumber, it won't run because it's > not a normal Rails application. > > Is there a way to get around this, or what alternative would you recommend? > Have a test app that uses your engine, and that has cucumber and rspec tests. Aslak > Thanks, > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dark.red.and.yellow at googlemail.com Tue Jun 29 03:50:43 2010 From: dark.red.and.yellow at googlemail.com (=?ISO-8859-1?Q?Timo_R=F6=DFner?=) Date: Tue, 29 Jun 2010 00:50:43 -0700 (PDT) Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> Message-ID: <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> Hi David, Gemfile and spec/spec_helper (not sure what you mean with "in-line posting"? I hope it's ok like that, if not, let me know): -> http://gist.github.com/456941 On Jun 28, 5:35?pm, David Chelimsky wrote: > On Jun 28, 2010, at 10:30 AM, Timo R??ner wrote: > > > > > On Jun 28, 5:03 pm, David Chelimsky wrote: > >> On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: > > >>> Hey guys, > > >>> I let the code speak for itself: > > >>> Below are my currently failing specs, please don't pay too much > >>> attention to the specs themselves, I just want to give you a "real > >>> life example" of what's happening - the only interesting thing about > >>> the specs is that there is a call to Factory(:challenge) in each of > >>> them and a before-each-call putting out what's currently in the > >>> database: > > >>> ?describe 'featuring' do > > >>> ? ?before(:each) do > >>> ? ? ?puts "Before Each:" > >>> ? ? ?puts "Featured Challenges size: #{Challenge.featured.size}" > >>> ? ? ?puts "Challenges count: #{Challenge.count}" > >>> ? ?end > > >>> ? ?it 'should tell if a challenge is featured' do > >>> ? ? ?challenge = Factory(:challenge, :feature_position => 1) > >>> ? ? ?challenge.should be_featured > >>> ? ?end > > >>> ? ?it 'should tell if a challenge is not featured' do > >>> ? ? ?challenge = Factory(:challenge, :feature_position => 0) > >>> ? ? ?challenge.should_not be_featured > >>> ? ?end > > >>> ? ?it 'should feature a challenge' do > >>> ? ? ?challenge = Factory(:challenge) > >>> ? ? ?challenge.feature! > >>> ? ? ?Challenge.featured.should == [challenge] > >>> ? ?end > > >>> ? ?it 'should unfeature a challenge' do > >>> ? ? ?challenge = Factory(:challenge, :feature_position => 1) > >>> ? ? ?challenge.unfeature! > >>> ? ? ?Challenge.featured.should be_empty > >>> ? ?end > >>> ?end > > >>> Now to the interesting part: > > >>> A spec run using rails 2.3.5 and rspec 1: > > >>> bundle exec spec spec/models/challenge_spec.rb > >>> Before Each: > >>> Featured Challenges size: 0 > >>> Challenges count: 0 > >>> .Before Each: > >>> Featured Challenges size: 0 > >>> Challenges count: 0 > >>> .Before Each: > >>> Featured Challenges size: 0 > >>> Challenges count: 0 > >>> .Before Each: > >>> Featured Challenges size: 0 > >>> Challenges count: 0 > >>> .............................. > > >>> -> Looks good. > > >>> Here's the exact same spec run with rspec-2.0.0.beta.13 and > >>> rails-3.0.0.beta4: > > >>> Before Each: > >>> Featured Challenges size: 0 > >>> Challenges count: 0 > >>> Before Each: > >>> Featured Challenges size: 1 > >>> Challenges count: 1 > >>> .Before Each: > >>> Featured Challenges size: 1 > >>> Challenges count: 2 > >>> Before Each: > >>> Featured Challenges size: 2 > >>> Challenges count: 3 > > >>> So apparently the latest rspec doesn't clean up after examples at all? > > >>> Is this a bug or a feature? > > >> Bug, but please check if it's still true of beta.14.1. > > > Hey David, > > > I just tried it out using the latest rspec and rspec-rails: > > > Gemfile: > > > ?gem 'rspec', '2.0.0.beta.14' > > ?gem 'rspec-rails', '2.0.0.beta.14.1 > > > $ bundle show rspec > > ~/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.14 > > > $bundle show rspec-rails > > ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.14.1 > > > Unfortunately, the bug still exists when using this configuration: > > > Before Each: > > Featured Challenges size: 0 > > Challenges count: 0 > > .Before Each: > > Featured Challenges size: 1 > > Challenges count: 1 > > .Before Each: > > Featured Challenges size: 1 > > Challenges count: 2 > > FBefore Each: > > Featured Challenges size: 2 > > Challenges count: 3 > > What's in your Gemfile and spec/spec_helper.rb? > > ps - please post in-line or at the bottom so we can follow the thread. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From win at wincent.com Tue Jun 29 03:55:25 2010 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 29 Jun 2010 09:55:25 +0200 Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> Message-ID: <6688E364-609C-4E0C-B4FB-646C6D7ED191@wincent.com> El 29/06/2010, a las 09:50, Timo R??ner escribi?: > Hi David, > > Gemfile and spec/spec_helper (not sure what you mean with "in-line > posting"? I hope it's ok like that, if not, let me know): He means, don't top-post. http://idallen.com/topposting.html http://en.wikipedia.org/wiki/Posting_style#Top-posting Cheers, Wincent From dchelimsky at gmail.com Tue Jun 29 06:14:50 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 Jun 2010 05:14:50 -0500 Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> Message-ID: On Jun 29, 2010, at 2:50 AM, Timo R??ner wrote: > On Jun 28, 5:35 pm, David Chelimsky wrote: >> On Jun 28, 2010, at 10:30 AM, Timo R??ner wrote: >>> On Jun 28, 5:03 pm, David Chelimsky wrote: >>>> On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: >> >>>>> Hey guys, >> >>>>> I let the code speak for itself: >> >>>>> Below are my currently failing specs, please don't pay too much >>>>> attention to the specs themselves, I just want to give you a "real >>>>> life example" of what's happening - the only interesting thing about >>>>> the specs is that there is a call to Factory(:challenge) in each of >>>>> them and a before-each-call putting out what's currently in the >>>>> database: >> >>>>> describe 'featuring' do >> >>>>> before(:each) do >>>>> puts "Before Each:" >>>>> puts "Featured Challenges size: #{Challenge.featured.size}" >>>>> puts "Challenges count: #{Challenge.count}" >>>>> end >> >>>>> it 'should tell if a challenge is featured' do >>>>> challenge = Factory(:challenge, :feature_position => 1) >>>>> challenge.should be_featured >>>>> end >> >>>>> it 'should tell if a challenge is not featured' do >>>>> challenge = Factory(:challenge, :feature_position => 0) >>>>> challenge.should_not be_featured >>>>> end >> >>>>> it 'should feature a challenge' do >>>>> challenge = Factory(:challenge) >>>>> challenge.feature! >>>>> Challenge.featured.should == [challenge] >>>>> end >> >>>>> it 'should unfeature a challenge' do >>>>> challenge = Factory(:challenge, :feature_position => 1) >>>>> challenge.unfeature! >>>>> Challenge.featured.should be_empty >>>>> end >>>>> end >> >>>>> Now to the interesting part: >> >>>>> A spec run using rails 2.3.5 and rspec 1: >> >>>>> bundle exec spec spec/models/challenge_spec.rb >>>>> Before Each: >>>>> Featured Challenges size: 0 >>>>> Challenges count: 0 >>>>> .Before Each: >>>>> Featured Challenges size: 0 >>>>> Challenges count: 0 >>>>> .Before Each: >>>>> Featured Challenges size: 0 >>>>> Challenges count: 0 >>>>> .Before Each: >>>>> Featured Challenges size: 0 >>>>> Challenges count: 0 >>>>> .............................. >> >>>>> -> Looks good. >> >>>>> Here's the exact same spec run with rspec-2.0.0.beta.13 and >>>>> rails-3.0.0.beta4: >> >>>>> Before Each: >>>>> Featured Challenges size: 0 >>>>> Challenges count: 0 >>>>> Before Each: >>>>> Featured Challenges size: 1 >>>>> Challenges count: 1 >>>>> .Before Each: >>>>> Featured Challenges size: 1 >>>>> Challenges count: 2 >>>>> Before Each: >>>>> Featured Challenges size: 2 >>>>> Challenges count: 3 >> >>>>> So apparently the latest rspec doesn't clean up after examples at all? >> >>>>> Is this a bug or a feature? >> >>>> Bug, but please check if it's still true of beta.14.1. >> >>> Hey David, >> >>> I just tried it out using the latest rspec and rspec-rails: >> >>> Gemfile: >> >>> gem 'rspec', '2.0.0.beta.14' >>> gem 'rspec-rails', '2.0.0.beta.14.1 >> >>> $ bundle show rspec >>> ~/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.14 >> >>> $bundle show rspec-rails >>> ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.14.1 >> >>> Unfortunately, the bug still exists when using this configuration: >> >>> Before Each: >>> Featured Challenges size: 0 >>> Challenges count: 0 >>> .Before Each: >>> Featured Challenges size: 1 >>> Challenges count: 1 >>> .Before Each: >>> Featured Challenges size: 1 >>> Challenges count: 2 >>> FBefore Each: >>> Featured Challenges size: 2 >>> Challenges count: 3 >> >> What's in your Gemfile and spec/spec_helper.rb? >> >> ps - please post in-line or at the bottom so we can follow the thread. > Hi David, > > -> http://gist.github.com/456941 I forked and made a couple of changes: http://gist.github.com/457034 * Added :development to the group declaration on line 31 * Changed rspec-rails to beta.14.2 * Removed the rspec declaration (it's a dependency of rspec-rails, so unnecessary) * Changed what is now line 44 to what gets generated now Not sure if this will fix anything, but let's see. From matt at mattwynne.net Tue Jun 29 11:59:21 2010 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 29 Jun 2010 16:59:21 +0100 Subject: [rspec-users] Using RSpec and Cucumber with Rails 3 Engines In-Reply-To: References: <01e801cb1736$f2ae1980$d80a4c80$@com> Message-ID: <85F8ED71-0552-4796-A4A4-05A74182CADA@mattwynne.net> On 29 Jun 2010, at 06:54, aslak hellesoy wrote: > On Tue, Jun 29, 2010 at 4:58 AM, Brandon Olivares > wrote: >> Hi, >> >> I recently upgraded to Rails 3 beta, a few weeks ago. One thing I would >> really like to do is to develop components of my application, because some >> of them I'd really like to be able to reuse on other projects. I know how to >> make engines well enough, but it seems difficult or impossible to test them >> with RSpec and Cucumber. At least with Cucumber, it won't run because it's >> not a normal Rails application. >> >> Is there a way to get around this, or what alternative would you recommend? >> > > Have a test app that uses your engine, and that has cucumber and rspec tests. > > Aslak A good example of an engine tested with Cucumber is: http://github.com/21croissants/courgette There's a rails app in fixtures_rails_root. Check out the neat trick in the config/environment.rb[1] to load the engine from wherever you want. [1] http://github.com/21croissants/courgette/blob/master/fixture_rails_root/config/environment.rb > >> Thanks, >> Brandon >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ed.howland at gmail.com Tue Jun 29 19:34:07 2010 From: ed.howland at gmail.com (Ed Howland) Date: Tue, 29 Jun 2010 19:34:07 -0400 Subject: [rspec-users] Autospec doing nothing In-Reply-To: References: Message-ID: Hi, does anyone know how to modify this to work on Lucid? I have libnotify installed, but haven't figured out how to get ZenTest 4.3 to work with growl on Ubuntu. Cheers, Ed Ed Howland http://greenprogrammer.wordpress.com http://twitter.com/ed_howland On Mon, Jun 21, 2010 at 9:02 AM, Tattoo wrote: > To get this working, I had to comment out line 21: > > SPEC_PROGRAM = File.expand_path(File.join(File.dirname(__FILE__), > '..', '..', 'bin', 'spec')) > > My output said that I already had SPEC_PROGRAM initialized and also > this line made it point to ../../bin/spec where I do not have spec > installed (correct place for me was ~/.gem/ruby/1.8/bin/spec). I doubt > for many, the situation is the same. > > Are you sure this line is necessary? > > > On May 29, 4:26?am, Rodrigo Flores wrote: >> I discovered the solution >> >> I have to put this on the .autotest file >> >> http://pastie.textmate.org/982730 >> >> >> >> >> >> On Sun, May 9, 2010 at 09:56, Rodrigo Flores wrote: >> > Ops >> >> > I searched on the list archive and I found a topic from a month ago about >> > this. My ZenTest version is 4.3.1 >> >> > My .autotest file is in my ~ and contains only >> > require "autotest/growl" >> >> > rake spec is running succesfully. >> >> > On Sun, May 9, 2010 at 09:45, Rodrigo Flores wrote: >> >> >> Hi >> >> >> When I run autospec on a rails project I get nothing. >> >> >> flores at Suomi(9:41)~/Code/Sabbre/camisa10 % autospec >> >> (Not running features. ?To run features in autotest, set >> >> AUTOFEATURE=true.) >> >> (Not running features. ?To run features in autotest, set >> >> AUTOFEATURE=true.) >> >> loading autotest/rails_rspec >> >> style: RailsRspec >> >> >> --------------------------------------------------------------------------- ----- >> >> >> (a bunch of blank lines) >> >> >> flores at Suomi(9:41)~/Code/Sabbre/camisa10 % >> >> >> Any ideas ? >> >> >> My Operating System is Mac OS X Snow Leopard, my ruby is 1.8.7. >> >> >> Rspec: 1.3.0 >> >> Rspec-Rails: 1.3.2 >> >> autotest: 4.2.9 >> >> autotest-growl : 0.2.4, 0.2.3 >> >> autotest-rails: 4.1.0 >> >> >> -- >> >> =================== >> >> Rodrigo L. M. Flores >> >> Computer Science Msc. Student - IME - USP >> >> Computer Science Degree - IME - USP >> >> Homepage (en):http://www.rodrigoflores.org >> >> Blog (pt-BR):http://blog.rodrigoflores.org >> >> Linux User # : 351304 >> >> Jabber: i... at rodrigoflores.org >> >> > -- >> > =================== >> > Rodrigo L. M. Flores >> > Computer Science Msc. Student - IME - USP >> > Computer Science Degree - IME - USP >> > Homepage (en):http://www.rodrigoflores.org >> > Blog (pt-BR):http://blog.rodrigoflores.org >> > Linux User # : 351304 >> > Jabber: i... at rodrigoflores.org >> >> -- >> =================== >> Rodrigo L. M. Flores >> Computer Science Msc. Student - IME - USP >> Computer Science Degree - IME - USP >> Homepage (en):http://www.rodrigoflores.org >> Blog (pt-BR):http://blog.rodrigoflores.org >> Linux User # : 351304 >> Jabber: i... at rodrigoflores.org >> >> _______________________________________________ >> 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 > From totochicote at gmail.com Wed Jun 30 09:45:40 2010 From: totochicote at gmail.com (Marcos Chicote) Date: Wed, 30 Jun 2010 10:45:40 -0300 Subject: [rspec-users] Exception handling Message-ID: Hello, I'm new in Rspec and I would like to ask a question. Suppose I have a test that fails raising an exception. I do not want the test to raise an exception and I'm not expecting one, but something fails and an exception occurs. Is there some way to handle that exception and do something in that case? I was thinking of some way of checking that a test failed in *after(:each)*method and handle the error there (I want to clear some variables and re-start others). Is that possible? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 30 09:58:48 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 Jun 2010 08:58:48 -0500 Subject: [rspec-users] Exception handling In-Reply-To: References: Message-ID: On Jun 30, 2010, at 8:45 AM, Marcos Chicote wrote: > Hello, > I'm new in Rspec and I would like to ask a question. > Suppose I have a test that fails raising an exception. I do not want the test to raise an exception and I'm not expecting one, but something fails and an exception occurs. > Is there some way to handle that exception and do something in that case? > > I was thinking of some way of checking that a test failed in after(:each) method and handle the error there (I want to clear some variables and re-start others). > > Is that possible? Exceptions in before/after(:all) will bubble up as exceptions, but exceptions in before/after(:each) or in the examples are handled and treated as failures. Are you experiencing something different? -------------- next part -------------- An HTML attachment was scrubbed... URL: From totochicote at gmail.com Wed Jun 30 10:05:20 2010 From: totochicote at gmail.com (Marcos Chicote) Date: Wed, 30 Jun 2010 11:05:20 -0300 Subject: [rspec-users] Exception handling In-Reply-To: References: Message-ID: I don't think so, but I don't really know how to check it programatically. I don't mean exceptions in *before/after *methos, but inside *it()* method I would like to write something like this: after(:each) do if exception_occured_on_it_method? do_something end end Is that possible? On Wed, Jun 30, 2010 at 10:58 AM, David Chelimsky wrote: > On Jun 30, 2010, at 8:45 AM, Marcos Chicote wrote: > > Hello, > I'm new in Rspec and I would like to ask a question. > Suppose I have a test that fails raising an exception. I do not want the > test to raise an exception and I'm not expecting one, but something fails > and an exception occurs. > Is there some way to handle that exception and do something in that case? > > I was thinking of some way of checking that a test failed in *after(:each) > * method and handle the error there (I want to clear some variables and > re-start others). > > Is that possible? > > > Exceptions in before/after(:all) will bubble up as exceptions, but > exceptions in before/after(:each) or in the examples are handled and treated > as failures. Are you experiencing something different? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 30 10:12:56 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 Jun 2010 09:12:56 -0500 Subject: [rspec-users] Exception handling In-Reply-To: References: Message-ID: <4036F9D5-520A-40BC-BDB8-6943D5BCCFDB@gmail.com> On Jun 30, 2010, at 9:05 AM, Marcos Chicote wrote: > I don't think so, but I don't really know how to check it > programatically. > I don't mean exceptions in before/after methos, but inside it() method > > I would like to write something like this: > after(:each) do > if exception_occured_on_it_method? > do_something > end > end > > Is that possible? What problem are you trying to solve? > > On Wed, Jun 30, 2010 at 10:58 AM, David Chelimsky > wrote: > On Jun 30, 2010, at 8:45 AM, Marcos Chicote wrote: > >> Hello, >> I'm new in Rspec and I would like to ask a question. >> Suppose I have a test that fails raising an exception. I do not >> want the test to raise an exception and I'm not expecting one, but >> something fails and an exception occurs. >> Is there some way to handle that exception and do something in that >> case? >> >> I was thinking of some way of checking that a test failed in after >> (:each) method and handle the error there (I want to clear some >> variables and re-start others). >> >> Is that possible? > > Exceptions in before/after(:all) will bubble up as exceptions, but > exceptions in before/after(:each) or in the examples are handled and > treated as failures. Are you experiencing something different? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From totochicote at gmail.com Wed Jun 30 10:29:25 2010 From: totochicote at gmail.com (Marcos Chicote) Date: Wed, 30 Jun 2010 11:29:25 -0300 Subject: [rspec-users] Exception handling In-Reply-To: <4036F9D5-520A-40BC-BDB8-6943D5BCCFDB@gmail.com> References: <4036F9D5-520A-40BC-BDB8-6943D5BCCFDB@gmail.com> Message-ID: On Wed, Jun 30, 2010 at 11:12 AM, David Chelimsky wrote: > On Jun 30, 2010, at 9:05 AM, Marcos Chicote wrote: > > I don't think so, but I don't really know how to check it programatically. > I don't mean exceptions in *before/after *methos, but inside *it()* method > > I would like to write something like this: > after(:each) do > if exception_occured_on_it_method? > do_something > end > end > > Is that possible? > > > What problem are you trying to solve? > I'm using rspec to build tests using Watir. On *before(:each)*, I create the browser instance and login lazily to a web page (if the browser exists, I use that instance, if it does not, I create a new one). I'm using this lazy approach in order to save the time of openning a new browser and login for each test (I could close the browser on * after(:each)* but this is faster). I most cases (when test are passed), everything works great. The problem is that sometimes the page I'm trying to access doesn't load (or there is some other non functional problem), the browser keeps wating and an timer that I implemented timesout.This timeout raises an exception that makes the test fail, but does not close the browsers windows (that keeps wating for the response), making following tests to fail. If I could handle timeout exception in the way I posted before, I could close the browser and the next test will open a fresh one. (Note: this is only and example, there are some other exceptions thay might occur, html element missing for example, that I want to handle the same way and that's why I need a unified mechanism) Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 30 11:31:39 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 Jun 2010 10:31:39 -0500 Subject: [rspec-users] Exception handling In-Reply-To: References: <4036F9D5-520A-40BC-BDB8-6943D5BCCFDB@gmail.com> Message-ID: <1FA182F6-F8F0-4587-8098-A1EA2008F5FF@gmail.com> On Jun 30, 2010, at 9:29 AM, Marcos Chicote wrote: > On Wed, Jun 30, 2010 at 11:12 AM, David Chelimsky wrote: > On Jun 30, 2010, at 9:05 AM, Marcos Chicote wrote: > >> I don't think so, but I don't really know how to check it programatically. >> I don't mean exceptions in before/after methos, but inside it() method >> >> I would like to write something like this: >> after(:each) do >> if exception_occured_on_it_method? >> do_something >> end >> end >> >> Is that possible? > > What problem are you trying to solve? > > I'm using rspec to build tests using Watir. > > On before(:each), I create the browser instance and login lazily to a web page (if the browser exists, I use that instance, if it does not, I create a new one). I'm using this lazy approach in order to save the time of openning a new browser and login for each test (I could close the browser on after(:each) but this is faster). > > I most cases (when test are passed), everything works great. The problem is that sometimes the page I'm trying to access doesn't load (or there is some other non functional problem), the browser keeps wating and an timer that I implemented timesout.This timeout raises an exception that makes the test fail, but does not close the browsers windows (that keeps wating for the response), making following tests to fail. > > If I could handle timeout exception in the way I posted before, I could close the browser and the next test will open a fresh one. > > (Note: this is only and example, there are some other exceptions thay might occur, html element missing for example, that I want to handle the same way and that's why I need a unified mechanism) There's nothing in RSpec to explicitly handle this for you. There are tools that will likely be available in RSpec-2 by the time we do a final release, but they won't work yet for your goal, so for the short run I think you need to manage this in each example manually. I'd recommend something like: def capture(exception) begin yield rescue Exception => e case e if OneType # do something elsif AnotherType # do something different end end end it "..." do capture do # do stuff end end It's not perfect, but it should work. HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From totochicote at gmail.com Wed Jun 30 11:46:43 2010 From: totochicote at gmail.com (Marcos Chicote) Date: Wed, 30 Jun 2010 12:46:43 -0300 Subject: [rspec-users] Exception handling In-Reply-To: <1FA182F6-F8F0-4587-8098-A1EA2008F5FF@gmail.com> References: <4036F9D5-520A-40BC-BDB8-6943D5BCCFDB@gmail.com> <1FA182F6-F8F0-4587-8098-A1EA2008F5FF@gmail.com> Message-ID: On Wed, Jun 30, 2010 at 12:31 PM, David Chelimsky wrote: > On Jun 30, 2010, at 9:29 AM, Marcos Chicote wrote: > > On Wed, Jun 30, 2010 at 11:12 AM, David Chelimsky wrote: > >> On Jun 30, 2010, at 9:05 AM, Marcos Chicote >> wrote: >> >> I don't think so, but I don't really know how to check it programatically. >> I don't mean exceptions in *before/after *methos, but inside *it()*method >> >> I would like to write something like this: >> after(:each) do >> if exception_occured_on_it_method? >> do_something >> end >> end >> >> Is that possible? >> >> >> What problem are you trying to solve? >> > > I'm using rspec to build tests using Watir. > > On *before(:each)*, I create the browser instance and login lazily to a > web page (if the browser exists, I use that instance, if it does not, I > create a new one). I'm using this lazy approach in order to save the time of > openning a new browser and login for each test (I could close the browser on > *after(:each)* but this is faster). > > I most cases (when test are passed), everything works great. The problem is > that sometimes the page I'm trying to access doesn't load (or there is some > other non functional problem), the browser keeps wating and an timer that I > implemented timesout.This timeout raises an exception that makes the test > fail, but does not close the browsers windows (that keeps wating for the > response), making following tests to fail. > > If I could handle timeout exception in the way I posted before, I could > close the browser and the next test will open a fresh one. > > (Note: this is only and example, there are some other exceptions thay might > occur, html element missing for example, that I want to handle the same way > and that's why I need a unified mechanism) > > > There's nothing in RSpec to explicitly handle this for you. There are tools > that will likely be available in RSpec-2 by the time we do a final release, > but they won't work yet for your goal, so for the short run I think you need > to manage this in each example manually. I'd recommend something like: > > def capture(exception) > begin > yield > rescue Exception => e > case e > if OneType > # do something > elsif AnotherType > # do something different > end > end > end > > it "..." do > capture do > # do stuff > end > end > > It's not perfect, but it should work. > > HTH, > David > > Thanks David. I'm looking forward to RSpec-2. Is there an estimate on the release date? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 30 11:52:40 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 Jun 2010 10:52:40 -0500 Subject: [rspec-users] Exception handling In-Reply-To: References: <4036F9D5-520A-40BC-BDB8-6943D5BCCFDB@gmail.com> <1FA182F6-F8F0-4587-8098-A1EA2008F5FF@gmail.com> Message-ID: On Jun 30, 2010, at 10:46 AM, Marcos Chicote wrote: > On Wed, Jun 30, 2010 at 12:31 PM, David Chelimsky wrote: > On Jun 30, 2010, at 9:29 AM, Marcos Chicote wrote: > >> On Wed, Jun 30, 2010 at 11:12 AM, David Chelimsky wrote: >> On Jun 30, 2010, at 9:05 AM, Marcos Chicote wrote: >> >>> I don't think so, but I don't really know how to check it programatically. >>> I don't mean exceptions in before/after methos, but inside it() method >>> >>> I would like to write something like this: >>> after(:each) do >>> if exception_occured_on_it_method? >>> do_something >>> end >>> end >>> >>> Is that possible? >> >> What problem are you trying to solve? >> >> I'm using rspec to build tests using Watir. >> >> On before(:each), I create the browser instance and login lazily to a web page (if the browser exists, I use that instance, if it does not, I create a new one). I'm using this lazy approach in order to save the time of openning a new browser and login for each test (I could close the browser on after(:each) but this is faster). >> >> I most cases (when test are passed), everything works great. The problem is that sometimes the page I'm trying to access doesn't load (or there is some other non functional problem), the browser keeps wating and an timer that I implemented timesout.This timeout raises an exception that makes the test fail, but does not close the browsers windows (that keeps wating for the response), making following tests to fail. >> >> If I could handle timeout exception in the way I posted before, I could close the browser and the next test will open a fresh one. >> >> (Note: this is only and example, there are some other exceptions thay might occur, html element missing for example, that I want to handle the same way and that's why I need a unified mechanism) > > There's nothing in RSpec to explicitly handle this for you. There are tools that will likely be available in RSpec-2 by the time we do a final release, but they won't work yet for your goal, so for the short run I think you need to manage this in each example manually. I'd recommend something like: > > def capture(exception) > begin > yield > rescue Exception => e > case e > if OneType > # do something > elsif AnotherType > # do something different > end > end > end > > it "..." do > capture do > # do stuff > end > end > > It's not perfect, but it should work. > > HTH, > David > > > Thanks David. I'm looking forward to RSpec-2. Is there an estimate on the release date? It's been in beta for a while - I released beta.15 this morning. Planning to do an RC sometime in July, at which point it will be feature complete and we'll just do bug fixes and documentation enhancements for the final release. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dark.red.and.yellow at googlemail.com Wed Jun 30 12:49:30 2010 From: dark.red.and.yellow at googlemail.com (=?ISO-8859-1?Q?Timo_R=F6=DFner?=) Date: Wed, 30 Jun 2010 09:49:30 -0700 (PDT) Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> Message-ID: <3c0d01b0-4589-4dc2-8aad-272fc24b4ead@g19g2000yqc.googlegroups.com> On Jun 29, 12:14?pm, David Chelimsky wrote: > On Jun 29, 2010, at 2:50 AM, Timo R??ner wrote: > > > > > On Jun 28, 5:35 pm, David Chelimsky wrote: > >> On Jun 28, 2010, at 10:30 AM, Timo R??ner wrote: > >>> On Jun 28, 5:03 pm, David Chelimsky wrote: > >>>> On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: > > >>>>> Hey guys, > > >>>>> I let the code speak for itself: > > >>>>> Below are my currently failing specs, please don't pay too much > >>>>> attention to the specs themselves, I just want to give you a "real > >>>>> life example" of what's happening - the only interesting thing about > >>>>> the specs is that there is a call to Factory(:challenge) in each of > >>>>> them and a before-each-call putting out what's currently in the > >>>>> database: > > >>>>> ?describe 'featuring' do > > >>>>> ? ?before(:each) do > >>>>> ? ? ?puts "Before Each:" > >>>>> ? ? ?puts "Featured Challenges size: #{Challenge.featured.size}" > >>>>> ? ? ?puts "Challenges count: #{Challenge.count}" > >>>>> ? ?end > > >>>>> ? ?it 'should tell if a challenge is featured' do > >>>>> ? ? ?challenge = Factory(:challenge, :feature_position => 1) > >>>>> ? ? ?challenge.should be_featured > >>>>> ? ?end > > >>>>> ? ?it 'should tell if a challenge is not featured' do > >>>>> ? ? ?challenge = Factory(:challenge, :feature_position => 0) > >>>>> ? ? ?challenge.should_not be_featured > >>>>> ? ?end > > >>>>> ? ?it 'should feature a challenge' do > >>>>> ? ? ?challenge = Factory(:challenge) > >>>>> ? ? ?challenge.feature! > >>>>> ? ? ?Challenge.featured.should == [challenge] > >>>>> ? ?end > > >>>>> ? ?it 'should unfeature a challenge' do > >>>>> ? ? ?challenge = Factory(:challenge, :feature_position => 1) > >>>>> ? ? ?challenge.unfeature! > >>>>> ? ? ?Challenge.featured.should be_empty > >>>>> ? ?end > >>>>> ?end > > >>>>> Now to the interesting part: > > >>>>> A spec run using rails 2.3.5 and rspec 1: > > >>>>> bundle exec spec spec/models/challenge_spec.rb > >>>>> Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .............................. > > >>>>> -> Looks good. > > >>>>> Here's the exact same spec run with rspec-2.0.0.beta.13 and > >>>>> rails-3.0.0.beta4: > > >>>>> Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> Before Each: > >>>>> Featured Challenges size: 1 > >>>>> Challenges count: 1 > >>>>> .Before Each: > >>>>> Featured Challenges size: 1 > >>>>> Challenges count: 2 > >>>>> Before Each: > >>>>> Featured Challenges size: 2 > >>>>> Challenges count: 3 > > >>>>> So apparently the latest rspec doesn't clean up after examples at all? > > >>>>> Is this a bug or a feature? > > >>>> Bug, but please check if it's still true of beta.14.1. > > >>> Hey David, > > >>> I just tried it out using the latest rspec and rspec-rails: > > >>> Gemfile: > > >>> ?gem 'rspec', '2.0.0.beta.14' > >>> ?gem 'rspec-rails', '2.0.0.beta.14.1 > > >>> $ bundle show rspec > >>> ~/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.14 > > >>> $bundle show rspec-rails > >>> ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.14.1 > > >>> Unfortunately, the bug still exists when using this configuration: > > >>> Before Each: > >>> Featured Challenges size: 0 > >>> Challenges count: 0 > >>> .Before Each: > >>> Featured Challenges size: 1 > >>> Challenges count: 1 > >>> .Before Each: > >>> Featured Challenges size: 1 > >>> Challenges count: 2 > >>> FBefore Each: > >>> Featured Challenges size: 2 > >>> Challenges count: 3 > > >> What's in your Gemfile and spec/spec_helper.rb? > > >> ps - please post in-line or at the bottom so we can follow the thread. > > Hi David, > > > ->http://gist.github.com/456941 > > I forked and made a couple of changes:http://gist.github.com/457034 > > * Added :development to the group declaration on line 31 > * Changed rspec-rails to beta.14.2 > * Removed the rspec declaration (it's a dependency of rspec-rails, so unnecessary) > * Changed what is now line 44 to what gets generated now > > Not sure if this will fix anything, but let's see. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users Hey, @Wincent alright, thanks. @David I changed my Gemfile and my spec_helper as you suggested (right now they are exactly the same as in your gist) and ran "bundle install". Unfortunately this setup seems to cause another problem: ( $ ) bundle exec spec spec/models/challenge_spec.rb /usr/lib/ruby/gems/1.8/gems/bundler-0.9.26/lib/bundler/ shared_helpers.rb:153:in `bin_path': can't find executable spec (Gem::Exception) from ~/.bundle/ruby/1.8/bin/spec:19 ( $ ) bundle show rspec ~.bundle/ruby/1.8/gems/rspec-2.0.0.beta.15 From dark.red.and.yellow at googlemail.com Wed Jun 30 12:55:30 2010 From: dark.red.and.yellow at googlemail.com (=?ISO-8859-1?Q?Timo_R=F6=DFner?=) Date: Wed, 30 Jun 2010 09:55:30 -0700 (PDT) Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> Message-ID: On Jun 29, 12:14?pm, David Chelimsky wrote: > On Jun 29, 2010, at 2:50 AM, Timo R??ner wrote: > > > > > On Jun 28, 5:35 pm, David Chelimsky wrote: > >> On Jun 28, 2010, at 10:30 AM, Timo R??ner wrote: > >>> On Jun 28, 5:03 pm, David Chelimsky wrote: > >>>> On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: > > >>>>> Hey guys, > > >>>>> I let the code speak for itself: > > >>>>> Below are my currently failing specs, please don't pay too much > >>>>> attention to the specs themselves, I just want to give you a "real > >>>>> life example" of what's happening - the only interesting thing about > >>>>> the specs is that there is a call to Factory(:challenge) in each of > >>>>> them and a before-each-call putting out what's currently in the > >>>>> database: > > >>>>> ?describe 'featuring' do > > >>>>> ? ?before(:each) do > >>>>> ? ? ?puts "Before Each:" > >>>>> ? ? ?puts "Featured Challenges size: #{Challenge.featured.size}" > >>>>> ? ? ?puts "Challenges count: #{Challenge.count}" > >>>>> ? ?end > > >>>>> ? ?it 'should tell if a challenge is featured' do > >>>>> ? ? ?challenge = Factory(:challenge, :feature_position => 1) > >>>>> ? ? ?challenge.should be_featured > >>>>> ? ?end > > >>>>> ? ?it 'should tell if a challenge is not featured' do > >>>>> ? ? ?challenge = Factory(:challenge, :feature_position => 0) > >>>>> ? ? ?challenge.should_not be_featured > >>>>> ? ?end > > >>>>> ? ?it 'should feature a challenge' do > >>>>> ? ? ?challenge = Factory(:challenge) > >>>>> ? ? ?challenge.feature! > >>>>> ? ? ?Challenge.featured.should == [challenge] > >>>>> ? ?end > > >>>>> ? ?it 'should unfeature a challenge' do > >>>>> ? ? ?challenge = Factory(:challenge, :feature_position => 1) > >>>>> ? ? ?challenge.unfeature! > >>>>> ? ? ?Challenge.featured.should be_empty > >>>>> ? ?end > >>>>> ?end > > >>>>> Now to the interesting part: > > >>>>> A spec run using rails 2.3.5 and rspec 1: > > >>>>> bundle exec spec spec/models/challenge_spec.rb > >>>>> Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> .............................. > > >>>>> -> Looks good. > > >>>>> Here's the exact same spec run with rspec-2.0.0.beta.13 and > >>>>> rails-3.0.0.beta4: > > >>>>> Before Each: > >>>>> Featured Challenges size: 0 > >>>>> Challenges count: 0 > >>>>> Before Each: > >>>>> Featured Challenges size: 1 > >>>>> Challenges count: 1 > >>>>> .Before Each: > >>>>> Featured Challenges size: 1 > >>>>> Challenges count: 2 > >>>>> Before Each: > >>>>> Featured Challenges size: 2 > >>>>> Challenges count: 3 > > >>>>> So apparently the latest rspec doesn't clean up after examples at all? > > >>>>> Is this a bug or a feature? > > >>>> Bug, but please check if it's still true of beta.14.1. > > >>> Hey David, > > >>> I just tried it out using the latest rspec and rspec-rails: > > >>> Gemfile: > > >>> ?gem 'rspec', '2.0.0.beta.14' > >>> ?gem 'rspec-rails', '2.0.0.beta.14.1 > > >>> $ bundle show rspec > >>> ~/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.14 > > >>> $bundle show rspec-rails > >>> ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.14.1 > > >>> Unfortunately, the bug still exists when using this configuration: > > >>> Before Each: > >>> Featured Challenges size: 0 > >>> Challenges count: 0 > >>> .Before Each: > >>> Featured Challenges size: 1 > >>> Challenges count: 1 > >>> .Before Each: > >>> Featured Challenges size: 1 > >>> Challenges count: 2 > >>> FBefore Each: > >>> Featured Challenges size: 2 > >>> Challenges count: 3 > > >> What's in your Gemfile and spec/spec_helper.rb? > > >> ps - please post in-line or at the bottom so we can follow the thread. > > Hi David, > > > ->http://gist.github.com/456941 > > I forked and made a couple of changes:http://gist.github.com/457034 > > * Added :development to the group declaration on line 31 > * Changed rspec-rails to beta.14.2 > * Removed the rspec declaration (it's a dependency of rspec-rails, so unnecessary) > * Changed what is now line 44 to what gets generated now > > Not sure if this will fix anything, but let's see. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users Hey, @Wincent alright, thanks. @David I changed my Gemfile and my spec_helper as you suggested (right now they are exactly the same as in your gist) and ran "bundle install". Unfortunately this setup seems to cause another problem: ( $ ) bundle exec spec spec/models/challenge_spec.rb /usr/lib/ruby/gems/1.8/gems/bundler-0.9.26/lib/bundler/ shared_helpers.rb:153:in `bin_path': can't find executable spec (Gem::Exception) from ~/.bundle/ruby/1.8/bin/spec:19 ( $ ) bundle show rspec ~.bundle/ruby/1.8/gems/rspec-2.0.0.beta.15 From dchelimsky at gmail.com Wed Jun 30 13:26:30 2010 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 Jun 2010 12:26:30 -0500 Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> Message-ID: On Jun 30, 2010, at 11:55 AM, Timo R??ner wrote: > On Jun 29, 12:14 pm, David Chelimsky wrote: >> On Jun 29, 2010, at 2:50 AM, Timo R??ner wrote: >> >> >> >>> On Jun 28, 5:35 pm, David Chelimsky wrote: >>>> On Jun 28, 2010, at 10:30 AM, Timo R??ner wrote: >>>>> On Jun 28, 5:03 pm, David Chelimsky wrote: >>>>>> On Jun 28, 2010, at 10:00 AM, Timo R??ner wrote: >> >>>>>>> Hey guys, >> >>>>>>> I let the code speak for itself: >> >>>>>>> Below are my currently failing specs, please don't pay too much >>>>>>> attention to the specs themselves, I just want to give you a "real >>>>>>> life example" of what's happening - the only interesting thing about >>>>>>> the specs is that there is a call to Factory(:challenge) in each of >>>>>>> them and a before-each-call putting out what's currently in the >>>>>>> database: >> >>>>>>> describe 'featuring' do >> >>>>>>> before(:each) do >>>>>>> puts "Before Each:" >>>>>>> puts "Featured Challenges size: #{Challenge.featured.size}" >>>>>>> puts "Challenges count: #{Challenge.count}" >>>>>>> end >> >>>>>>> it 'should tell if a challenge is featured' do >>>>>>> challenge = Factory(:challenge, :feature_position => 1) >>>>>>> challenge.should be_featured >>>>>>> end >> >>>>>>> it 'should tell if a challenge is not featured' do >>>>>>> challenge = Factory(:challenge, :feature_position => 0) >>>>>>> challenge.should_not be_featured >>>>>>> end >> >>>>>>> it 'should feature a challenge' do >>>>>>> challenge = Factory(:challenge) >>>>>>> challenge.feature! >>>>>>> Challenge.featured.should == [challenge] >>>>>>> end >> >>>>>>> it 'should unfeature a challenge' do >>>>>>> challenge = Factory(:challenge, :feature_position => 1) >>>>>>> challenge.unfeature! >>>>>>> Challenge.featured.should be_empty >>>>>>> end >>>>>>> end >> >>>>>>> Now to the interesting part: >> >>>>>>> A spec run using rails 2.3.5 and rspec 1: >> >>>>>>> bundle exec spec spec/models/challenge_spec.rb >>>>>>> Before Each: >>>>>>> Featured Challenges size: 0 >>>>>>> Challenges count: 0 >>>>>>> .Before Each: >>>>>>> Featured Challenges size: 0 >>>>>>> Challenges count: 0 >>>>>>> .Before Each: >>>>>>> Featured Challenges size: 0 >>>>>>> Challenges count: 0 >>>>>>> .Before Each: >>>>>>> Featured Challenges size: 0 >>>>>>> Challenges count: 0 >>>>>>> .............................. >> >>>>>>> -> Looks good. >> >>>>>>> Here's the exact same spec run with rspec-2.0.0.beta.13 and >>>>>>> rails-3.0.0.beta4: >> >>>>>>> Before Each: >>>>>>> Featured Challenges size: 0 >>>>>>> Challenges count: 0 >>>>>>> Before Each: >>>>>>> Featured Challenges size: 1 >>>>>>> Challenges count: 1 >>>>>>> .Before Each: >>>>>>> Featured Challenges size: 1 >>>>>>> Challenges count: 2 >>>>>>> Before Each: >>>>>>> Featured Challenges size: 2 >>>>>>> Challenges count: 3 >> >>>>>>> So apparently the latest rspec doesn't clean up after examples at all? >> >>>>>>> Is this a bug or a feature? >> >>>>>> Bug, but please check if it's still true of beta.14.1. >> >>>>> Hey David, >> >>>>> I just tried it out using the latest rspec and rspec-rails: >> >>>>> Gemfile: >> >>>>> gem 'rspec', '2.0.0.beta.14' >>>>> gem 'rspec-rails', '2.0.0.beta.14.1 >> >>>>> $ bundle show rspec >>>>> ~/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.14 >> >>>>> $bundle show rspec-rails >>>>> ~/.bundle/ruby/1.8/gems/rspec-rails-2.0.0.beta.14.1 >> >>>>> Unfortunately, the bug still exists when using this configuration: >> >>>>> Before Each: >>>>> Featured Challenges size: 0 >>>>> Challenges count: 0 >>>>> .Before Each: >>>>> Featured Challenges size: 1 >>>>> Challenges count: 1 >>>>> .Before Each: >>>>> Featured Challenges size: 1 >>>>> Challenges count: 2 >>>>> FBefore Each: >>>>> Featured Challenges size: 2 >>>>> Challenges count: 3 >> >>>> What's in your Gemfile and spec/spec_helper.rb? >> >>>> ps - please post in-line or at the bottom so we can follow the thread. >>> Hi David, >> >>> ->http://gist.github.com/456941 >> >> I forked and made a couple of changes:http://gist.github.com/457034 >> >> * Added :development to the group declaration on line 31 >> * Changed rspec-rails to beta.14.2 >> * Removed the rspec declaration (it's a dependency of rspec-rails, so unnecessary) >> * Changed what is now line 44 to what gets generated now >> >> Not sure if this will fix anything, but let's see. >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > Hey, > > @Wincent alright, thanks. > > @David > > I changed my Gemfile and my spec_helper as you suggested (right now > they are exactly the same as in your gist) and ran "bundle install". > > Unfortunately this setup seems to cause another problem: > > ( $ ) bundle exec spec spec/models/challenge_spec.rb > /usr/lib/ruby/gems/1.8/gems/bundler-0.9.26/lib/bundler/ > shared_helpers.rb:153:in `bin_path': can't find executable spec > (Gem::Exception) > from ~/.bundle/ruby/1.8/bin/spec:19 > > ( $ ) bundle show rspec > ~.bundle/ruby/1.8/gems/rspec-2.0.0.beta.15 The command is rspec in rspec 2. Try: bundle exec rspec spec/models/challenge_spec.rb Cheers, David From amir.nagri at gmail.com Wed Jun 30 13:44:11 2010 From: amir.nagri at gmail.com (Amiruddin Nagri) Date: Wed, 30 Jun 2010 23:14:11 +0530 Subject: [rspec-users] rspec 2 not cleaning up after examples run? In-Reply-To: References: <6951BE91-9D73-4166-A0E4-7696E4AFF343@gmail.com> <522ebcc2-1d53-4e80-8302-67b224aa9bdb@k39g2000yqd.googlegroups.com> <2f27edf8-a9d4-4151-ad71-3e2500d99936@j4g2000yqh.googlegroups.com> Message-ID: I am not sure if this will help or not but I was also getting data not cleared properly when run specs through rake but when ran using script/spec it was cleaning up the data Amir On Jun 30, 2010 10:56 PM, "David Chelimsky" wrote: On Jun 30, 2010, at 11:55 AM, Timo R??ner wrote: > On Jun 29, 12:14 pm, David Chelimsky From joshua.clayton at gmail.com Tue Jun 29 17:05:50 2010 From: joshua.clayton at gmail.com (Josh Clayton) Date: Tue, 29 Jun 2010 14:05:50 -0700 (PDT) Subject: [rspec-users] Cookie assignment and reading Message-ID: Hello all, I'm running the latest stable rspec/rspec-rails (1.3.0/1.3.2) in a Rails 2.3.8 app and am having trouble testing that a cookie gets deleted. In a semi-convoluted manner, I am essentially running code from the rdoc as such: describe MyController, "GET index" do let(:cookie_value) { "of course" } it "should delete the cookie" do cookies[:awesome] = cookie_value get :index cookies[:awesome].should == cookie_value end end This is obviously example code but the outcome effect is the same - trying to find the value of a cookie I set with RSpec fails. For my specific, real-life example, I'm assigning a cooking and performing a request in the before block and testing that the cookie is deleted. It's passing, but incorrectly (since I haven't performed the deletion in my controller action). Any insight would be appreciated; thanks! From marcioa1 at gmail.com Tue Jun 29 18:08:56 2010 From: marcioa1 at gmail.com (marcioa1) Date: Tue, 29 Jun 2010 15:08:56 -0700 (PDT) Subject: [rspec-users] How to test index method of a controller ? Message-ID: <0b66dfe3-6a59-421d-8e00-ec911d0a9251@k39g2000yqb.googlegroups.com> Hi, My index methods def index @galleries = Gallery.filtered_by(params.reverse_merge!(:per_page => 10)) end My spec: it "should list all galleries" do get :index response.should render_template("index") end And the error message should list all galleries can't convert Spec::Mocks::Mock into Array The problem is with the filtered_by method. What should I pass ? Thanks Marcio From sagar.amin4 at gmail.com Tue Jun 29 19:44:01 2010 From: sagar.amin4 at gmail.com (tester86) Date: Tue, 29 Jun 2010 16:44:01 -0700 (PDT) Subject: [rspec-users] Entering text into a text field using rspec Message-ID: <1c3916b9-9d61-4a84-914e-d1b63927cf30@t10g2000yqg.googlegroups.com> HI I am new to rspec. I am at a web page and in that page I want to enter in some text and then click send. it "will enter in some text 'asf'" do end what command would I used to enter in the text as I have searched google but I cannot find any thing helpful. I do not want to use watir as it relies on the ID and in our app the IDs change every time the page is loaded. I tried :textfield => 'asf' But I get and error as it does not like the '. From ericmilford at gmail.com Wed Jun 30 13:00:22 2010 From: ericmilford at gmail.com (ericindc) Date: Wed, 30 Jun 2010 10:00:22 -0700 (PDT) Subject: [rspec-users] Shoulda and explicit subject Message-ID: <13f56045-f2d1-4c88-8186-b481739cef81@b35g2000yqi.googlegroups.com> I am trying to use Shoulda matchers with the latest beta version of RSpec for Rails 3. I've managed to track down the cause of my errors to needing to explicitly set the subject, but the Shoulda examples make no mention of requiring this step. I've pastied the errors I'm receiving and adding subject { controller } seems to resolve them. Is this behavior expected? http://pastie.org/1020788 Thanks