From aslak.hellesoy at gmail.com Tue May 1 07:43:14 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 1 May 2007 13:43:14 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.1 released Message-ID: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> The RSpec team is pleased to announce RSpec 0.9.1 (we skipped 0.9.0). RSpec is a framework that provides programmers with a Domain Specific Language to describe the behaviour of Ruby code with readable, executable examples that guide you in the design process and serve well as both documentation as tests. This release includes a complete overhaul of the API, which can be summarised as follows: * "context" is now "describe" (we call the blocks behaviours) * "specify" is now "it" (we call the blocks examples) * "should_something" is now "should something" (magic underscores are gone) In order to ease the transition from older specs, RSpec also includes a translator that will translate your old specs. In addition to these major changes, this release has over 60 applied RFEs and bug fixes, many of them related to Spec::Rails - the Ruby on Rails plugin for RSpec. To install RSpec: gem install rspec (you may have to wait a few hours for the gems to replicate) To translate old specs: spec_translator from_dir to_dir (can be the same dir if you use source control and know how to revert) To see the full list of changes: http://rspec.rubyforge.org/rdoc/files/CHANGES.html The RSpec home page: http://rspec.rubyforge.org/ How to use RSpec with Rails: http://rspec.rubyforge.org/documentation/rails/index.html [Regards, The RSpec team] From chris.c.hoffman at gmail.com Tue May 1 08:09:10 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Tue, 1 May 2007 08:09:10 -0400 Subject: [rspec-users] [ANN] RSpec 0.9.1 released In-Reply-To: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> References: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> Message-ID: <63c5d3820705010509k4bb7a3deg95848a30afc05a62@mail.gmail.com> Hello, I am currently on the HEAD of the svn repository, and I am trying to run the spec_translator. I chmod'd, shabanged, and tried to execute the following: ./vendor/plugins/rspec/bin/spec_translator spec spec And got the following response: : No such file or directory I should note that I'm doing this within a rails directory tree. Is there something I'm missing? Thanks. -Chris On 5/1/07, aslak hellesoy wrote: > The RSpec team is pleased to announce RSpec 0.9.1 (we skipped 0.9.0). > > RSpec is a framework that provides programmers with a Domain Specific > Language to describe the behaviour of Ruby code with readable, > executable examples that guide you in the > design process and serve well as both documentation as tests. > > This release includes a complete overhaul of the API, which can be > summarised as follows: > * "context" is now "describe" (we call the blocks behaviours) > * "specify" is now "it" (we call the blocks examples) > * "should_something" is now "should something" (magic underscores are gone) > > In order to ease the transition from older specs, RSpec also includes > a translator that will translate your old specs. > > In addition to these major changes, this release has over 60 applied > RFEs and bug fixes, many of them related to Spec::Rails - the Ruby on > Rails plugin for RSpec. > > To install RSpec: > > gem install rspec (you may have to wait a few hours for the gems to replicate) > > To translate old specs: > > spec_translator from_dir to_dir (can be the same dir if you use > source control and know how to revert) > > To see the full list of changes: > > http://rspec.rubyforge.org/rdoc/files/CHANGES.html > > The RSpec home page: > > http://rspec.rubyforge.org/ > > How to use RSpec with Rails: > > http://rspec.rubyforge.org/documentation/rails/index.html > > [Regards, The RSpec team] > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue May 1 08:30:47 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 1 May 2007 07:30:47 -0500 Subject: [rspec-users] rspec and autotest Message-ID: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> If you want to use rspec-0.9.2 with autotest (ZenTest-3.5.2), you'll want to read this blog: http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and-autotest-zentest-3-5-2 Enjoy! David From chris.c.hoffman at gmail.com Tue May 1 09:47:02 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Tue, 1 May 2007 09:47:02 -0400 Subject: [rspec-users] [ANN] RSpec 0.9.1 released In-Reply-To: <63c5d3820705010509k4bb7a3deg95848a30afc05a62@mail.gmail.com> References: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> <63c5d3820705010509k4bb7a3deg95848a30afc05a62@mail.gmail.com> Message-ID: <63c5d3820705010647p294587e9u256d273c25684d9f@mail.gmail.com> I have attached a patch file, which adds a rake task for this translation. As this is my first rake task, it is very likely in need of rework, but hopefully someone finds it useful. On 5/1/07, Chris Hoffman wrote: > Hello, > I am currently on the HEAD of the svn repository, and I am trying to > run the spec_translator. I chmod'd, shabanged, and tried to execute > the following: > > ./vendor/plugins/rspec/bin/spec_translator spec spec > > And got the following response: > : No such file or directory > > I should note that I'm doing this within a rails directory tree. Is > there something I'm missing? Thanks. > > -Chris > > On 5/1/07, aslak hellesoy wrote: > > The RSpec team is pleased to announce RSpec 0.9.1 (we skipped 0.9.0). > > > > RSpec is a framework that provides programmers with a Domain Specific > > Language to describe the behaviour of Ruby code with readable, > > executable examples that guide you in the > > design process and serve well as both documentation as tests. > > > > This release includes a complete overhaul of the API, which can be > > summarised as follows: > > * "context" is now "describe" (we call the blocks behaviours) > > * "specify" is now "it" (we call the blocks examples) > > * "should_something" is now "should something" (magic underscores are gone) > > > > In order to ease the transition from older specs, RSpec also includes > > a translator that will translate your old specs. > > > > In addition to these major changes, this release has over 60 applied > > RFEs and bug fixes, many of them related to Spec::Rails - the Ruby on > > Rails plugin for RSpec. > > > > To install RSpec: > > > > gem install rspec (you may have to wait a few hours for the gems to replicate) > > > > To translate old specs: > > > > spec_translator from_dir to_dir (can be the same dir if you use > > source control and know how to revert) > > > > To see the full list of changes: > > > > http://rspec.rubyforge.org/rdoc/files/CHANGES.html > > > > The RSpec home page: > > > > http://rspec.rubyforge.org/ > > > > How to use RSpec with Rails: > > > > http://rspec.rubyforge.org/documentation/rails/index.html > > > > [Regards, The RSpec team] > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: translator_rake_task.patch Type: text/x-patch Size: 663 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070501/1e64bef5/attachment.bin From chris.c.hoffman at gmail.com Tue May 1 10:08:15 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Tue, 1 May 2007 10:08:15 -0400 Subject: [rspec-users] Migrating spec_helper with modifications In-Reply-To: <57c63afe0704301415g51251fa9q998bbc55b8f8f094@mail.gmail.com> References: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> <57c63afe0704301231q3d0f4605gd7d0e53abad4b69a@mail.gmail.com> <63c5d3820704301241v2264cda7o4819d9b54ebae12f@mail.gmail.com> <57c63afe0704301245p27ebaf29l1cefb7d610aae59b@mail.gmail.com> <63c5d3820704301249g56f10e2bj7dc11ab59fd43927@mail.gmail.com> <57c63afe0704301253o72fce72ayf1c5b621815471c7@mail.gmail.com> <57c63afe0704301415g51251fa9q998bbc55b8f8f094@mail.gmail.com> Message-ID: <63c5d3820705010708u24ce1c91sa39c7d42c3b58a92@mail.gmail.com> Nice work! -Chris On 4/30/07, David Chelimsky wrote: > DONE - I added support for config.include to rev 1851. So you should > be able to do this: > > Spec::Runner.configure do |config| > config.include MyModule > end > > and it's the same as doing this: > > describe Something do > include MyModule > end > > in every description. > > Cheers, > David > > On 4/30/07, David Chelimsky wrote: > > On 4/30/07, Chris Hoffman wrote: > > > Okay, I got it working with the following: > > > > > > Spec::Runner.configure do |config| > > > config.use_transactional_fixtures = true > > > config.use_instantiated_fixtures = false > > > config.fixture_path = RAILS_ROOT + '/spec/fixtures' > > > Spec::DSL::Behaviour.send(:include, Breakpoint) > > > Spec::DSL::Behaviour.send(:include, HpricotSpecHelper) > > > end > > > > > > I couldn't call include directly, as it's a private method. > > > > > > Should I be using this mailing list for these HEAD issues, or is there > > > a better place? > > > > As long as you have a workaround, go ahead and use that for now. I'll > > get the support for config.include in place in the next day or so - > > possibly even today. > > > > rspec-devel is probably better, but this list is fine. Lots of > > trunksters on this list. > > > > Cheers, > > David > > > > > > > > -Chris > > > > > > On 4/30/07, David Chelimsky wrote: > > > > On 4/30/07, Chris Hoffman wrote: > > > > > That doesn't seem to work for me: > > > > > > > > > > Spec::Runner.configure do |config| > > > > > config.use_transactional_fixtures = true > > > > > config.use_instantiated_fixtures = false > > > > > config.fixture_path = RAILS_ROOT + '/spec/fixtures' > > > > > config.include Breakpoint > > > > > end > > > > > > > > > > Gives me an undefined method 'include' > > > > > > > > > > ./spec/models/../spec_helper.rb:13: undefined method `include' for > > > > > # (NoMethodError) > > > > > > > > UGH - that was the intent - I have to add that. > > > > > > > > In the mean time, you can use Spec::DSL::Behaviour.include - but that > > > > is subject to change. That's just what it is today. I'll follow up > > > > when I add config.include. > > > > > > > > Cheers, > > > > David > > > > > > > > > > > > > > > > > > -Chris > > > > > > > > > > On 4/30/07, David Chelimsky wrote: > > > > > > On 4/30/07, Chris Hoffman wrote: > > > > > > > Hello, > > > > > > > > > > > > > > After moving into the HEAD of rspec, I am greeted with a mountain of errors, > > > > > > > which I expected, due to my specs not being migrated. > > > > > > > > > > > > > > I use hpricot for a lot of my view tests, as it is extremely simple to > > > > > > > traverse the DOM with it. I used to include HpricotSpecHelper in > > > > > > > spec_helper.rb, like so: > > > > > > > > > > > > > > require 'hpricot_spec_helper' > > > > > > > > > > > > > > module Spec > > > > > > > module Rails > > > > > > > module Runner > > > > > > > class EvalContext < Test::Unit::TestCase > > > > > > > include HpricotSpecHelper > > > > > > > end > > > > > > > end > > > > > > > end > > > > > > > end > > > > > > > > > > > > > > However, I am now getting errors that indicate that this inclusion no longer > > > > > > > does what I want. Is there a different class in which I should be including > > > > > > > this module? > > > > > > > > > > > > > > The errors I'm getting are of the following type: > > > > > > > > > > > > > > undefined method `elements' for > > > > > > > #<#:0xb6eb8ff0> > > > > > > > > > > > > > > element(s) is a top-level method, so I would do things like the following: > > > > > > > > > > > > > > element("p").inner_text.should == "Hello World" > > > > > > > > > > > > > > The following link shows HpricotSpecHelper (with syntax highlighting): > > > > > > > > > > > > > > http://src.chrishoffman.net/lib/hpricot_spec_helper.rb > > > > > > > > > > > > > > Please let me know if I am not being clear with my difficulty. Thanks for > > > > > > > the help. > > > > > > > > > > > > The easy way to include modules now is like this: > > > > > > > > > > > > Spec::Runner.configure do |config| > > > > > > config.include SomeModule > > > > > > end > > > > > > > > > > > > That gets included in every behaviour. > > > > > > > > > > > > That help? > > > > > > > > > > > > > > > > > > > > -Chris > > > > > > > > > > > > > > _______________________________________________ > > > > > > > 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 > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris.c.hoffman at gmail.com Tue May 1 13:03:25 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Tue, 1 May 2007 13:03:25 -0400 Subject: [rspec-users] release 0.9 'modifies' specs at each rake invocation? Message-ID: <63c5d3820705011003r507e5f2bq31bf7b17b063db65@mail.gmail.com> Hello, I am getting some odd behaviour. If I execute rake spec, and then try to modify a spec file that I have open in vi, and then go to save this file, vi warns me that the file has been modified outside of vi. However, if I execute only this file via script/spec, this modification does not take place. I file doesn't appear to be getting substantively modified, so I'm guessing it is just that it is being opened with a write flag inadvertently. I am on HEAD for both rspec and rspec_on_rails, btw. -Chris From armin.joellenbeck at googlemail.com Tue May 1 13:11:27 2007 From: armin.joellenbeck at googlemail.com (Armin Joellenbeck) Date: Tue, 1 May 2007 19:11:27 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.1 released In-Reply-To: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> References: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> Message-ID: <4a117bfc0705011011g1d2fcb78r89951d7aa98aa837@mail.gmail.com> Hello, I am missing in the subversion history: tags/REL_0_9_1/rspec tags/REL_0_9_1/rspec_on_rails Regards, Armin From aslak.hellesoy at gmail.com Tue May 1 13:32:35 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 1 May 2007 19:32:35 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.1 released In-Reply-To: <4a117bfc0705011011g1d2fcb78r89951d7aa98aa837@mail.gmail.com> References: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> <4a117bfc0705011011g1d2fcb78r89951d7aa98aa837@mail.gmail.com> Message-ID: <8d961d900705011032y321ee840ka5fa681b94d84589@mail.gmail.com> On 5/1/07, Armin Joellenbeck wrote: > Hello, > > I am missing in the subversion history: > What do you mean? Aslak > tags/REL_0_9_1/rspec > tags/REL_0_9_1/rspec_on_rails > > Regards, Armin > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From armin.joellenbeck at googlemail.com Tue May 1 14:08:47 2007 From: armin.joellenbeck at googlemail.com (Armin Joellenbeck) Date: Tue, 1 May 2007 20:08:47 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.1 released In-Reply-To: <8d961d900705011032y321ee840ka5fa681b94d84589@mail.gmail.com> References: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> <4a117bfc0705011011g1d2fcb78r89951d7aa98aa837@mail.gmail.com> <8d961d900705011032y321ee840ka5fa681b94d84589@mail.gmail.com> Message-ID: <4a117bfc0705011108k661f9e56j928ebeec0783ae78@mail.gmail.com> > > I am missing in the subversion history: > > > > What do you mean? > > Aslak > > > tags/REL_0_9_1/rspec > > tags/REL_0_9_1/rspec_on_rails > > > > Regards, Armin I want to install rspec and rspec_on_rails with version 0.9.1 as rails plugins. When I took a look in the subversion repository at rubyforge, see http://viewvc.rubyforge.mmmultiworks.com/cgi/viewvc.cgi/tags/?root=rspec I missed the tag REL_0_9_1. The last one is REL_0_9_0_BETA_2. I hope, I have now better explained what I am missing. Regards, Armin From aslak.hellesoy at gmail.com Tue May 1 14:24:50 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 1 May 2007 20:24:50 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.1 released In-Reply-To: <4a117bfc0705011108k661f9e56j928ebeec0783ae78@mail.gmail.com> References: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> <4a117bfc0705011011g1d2fcb78r89951d7aa98aa837@mail.gmail.com> <8d961d900705011032y321ee840ka5fa681b94d84589@mail.gmail.com> <4a117bfc0705011108k661f9e56j928ebeec0783ae78@mail.gmail.com> Message-ID: <8d961d900705011124v20da8028y35fe7d2c8e92321e@mail.gmail.com> On 5/1/07, Armin Joellenbeck wrote: > > > I am missing in the subversion history: > > > > > > > What do you mean? > > > > Aslak > > > > > tags/REL_0_9_1/rspec > > > tags/REL_0_9_1/rspec_on_rails > > > > > > Regards, Armin > > I want to install rspec and rspec_on_rails with version 0.9.1 as rails > plugins. When I took a look in the subversion repository at rubyforge, > see > > http://viewvc.rubyforge.mmmultiworks.com/cgi/viewvc.cgi/tags/?root=rspec > It looks like the ViewVC on RubyForge is running against a copy of the subversion repo that is about 24 hours old - probably for performance reasons - I don't know. Anyway, the tag is really there. Proof: svn ls svn://rubyforge.org/var/svn/rspec/tags REL_0_5_10/ REL_0_5_11/ REL_0_5_12/ REL_0_5_13/ REL_0_5_14/ REL_0_5_15/ REL_0_5_16/ REL_0_5_6/ REL_0_5_7/ REL_0_5_8/ REL_0_5_9/ REL_0_6_0/ REL_0_6_1/ REL_0_6_2/ REL_0_6_3/ REL_0_6_4/ REL_0_7_0/ REL_0_7_1/ REL_0_7_2/ REL_0_7_3/ REL_0_7_4/ REL_0_7_5/ REL_0_7_5_1/ REL_0_8_0/ REL_0_8_0_RC1/ REL_0_8_1/ REL_0_8_2/ REL_0_9_0_BETA_1/ REL_0_9_0_BETA_2/ REL_0_9_1/ Are you having problems checking out the tag? Aslak > I missed the tag REL_0_9_1. The last one is REL_0_9_0_BETA_2. > > I hope, I have now better explained what I am missing. > > Regards, Armin > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From armin.joellenbeck at googlemail.com Tue May 1 14:34:51 2007 From: armin.joellenbeck at googlemail.com (Armin Joellenbeck) Date: Tue, 1 May 2007 20:34:51 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.1 released In-Reply-To: <8d961d900705011124v20da8028y35fe7d2c8e92321e@mail.gmail.com> References: <8d961d900705010443h65eb9389n44905a45cae601b9@mail.gmail.com> <4a117bfc0705011011g1d2fcb78r89951d7aa98aa837@mail.gmail.com> <8d961d900705011032y321ee840ka5fa681b94d84589@mail.gmail.com> <4a117bfc0705011108k661f9e56j928ebeec0783ae78@mail.gmail.com> <8d961d900705011124v20da8028y35fe7d2c8e92321e@mail.gmail.com> Message-ID: <4a117bfc0705011134i6c27820ftf801d4dc2bd679c@mail.gmail.com> > It looks like the ViewVC on RubyForge is running against a copy of the > subversion repo that is about 24 hours old - probably for performance > reasons - I don't know. Sorry, my fault to trust an out of date repository viewer. I have checked out version 0.9.1 without problems. Regards, Armin From cwdinfo at gmail.com Tue May 1 14:49:04 2007 From: cwdinfo at gmail.com (s.ross) Date: Tue, 1 May 2007 11:49:04 -0700 Subject: [rspec-users] rspec and autotest In-Reply-To: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> References: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> Message-ID: I just installed the rspec plugin from trunk and zentest 3.5.2. I applied the patch and get: lacosta:~/bitscribe/maxius_unified sxross$ autotest loading rspec_rails_autotest /Users/sxross/.autotest:5: undefined method `spec_command=' for # (NoMethodError) Any idea what's up with this? Thanks On May 1, 2007, at 5:30 AM, David Chelimsky wrote: > If you want to use rspec-0.9.2 with autotest (ZenTest-3.5.2), you'll > want to read this blog: > > http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and- > autotest-zentest-3-5-2 > > Enjoy! > > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue May 1 14:56:22 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 1 May 2007 13:56:22 -0500 Subject: [rspec-users] rspec and autotest In-Reply-To: References: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> Message-ID: <57c63afe0705011156u1a0c92e5n81296bc7dc06917a@mail.gmail.com> On 5/1/07, s.ross wrote: > I just installed the rspec plugin from trunk and zentest 3.5.2. I > applied the patch and get: > > lacosta:~/bitscribe/maxius_unified sxross$ autotest > loading rspec_rails_autotest > /Users/sxross/.autotest:5: undefined method `spec_command=' for > # (NoMethodError) > > > Any idea what's up with this? If you followed all the instructions on the blog, no idea at all. Anybody else? > > Thanks > > On May 1, 2007, at 5:30 AM, David Chelimsky wrote: > > > If you want to use rspec-0.9.2 with autotest (ZenTest-3.5.2), you'll > > want to read this blog: > > > > http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and- > > autotest-zentest-3-5-2 > > > > Enjoy! > > > > 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 > From cwdinfo at gmail.com Tue May 1 15:07:40 2007 From: cwdinfo at gmail.com (s.ross) Date: Tue, 1 May 2007 12:07:40 -0700 Subject: [rspec-users] rspec and autotest In-Reply-To: <57c63afe0705011156u1a0c92e5n81296bc7dc06917a@mail.gmail.com> References: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> <57c63afe0705011156u1a0c92e5n81296bc7dc06917a@mail.gmail.com> Message-ID: <5AE8D82E-2289-4E34-9666-1F34A2D619F6@gmail.com> Just followed all the instructions again...no luck. Steve On May 1, 2007, at 11:56 AM, David Chelimsky wrote: > On 5/1/07, s.ross wrote: >> I just installed the rspec plugin from trunk and zentest 3.5.2. I >> applied the patch and get: >> >> lacosta:~/bitscribe/maxius_unified sxross$ autotest >> loading rspec_rails_autotest >> /Users/sxross/.autotest:5: undefined method `spec_command=' for >> # (NoMethodError) >> >> >> Any idea what's up with this? > > If you followed all the instructions on the blog, no idea at all. > Anybody else? > >> >> Thanks >> >> On May 1, 2007, at 5:30 AM, David Chelimsky wrote: >> >>> If you want to use rspec-0.9.2 with autotest (ZenTest-3.5.2), you'll >>> want to read this blog: >>> >>> http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and- >>> autotest-zentest-3-5-2 >>> >>> Enjoy! >>> >>> 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 From dchelimsky at gmail.com Tue May 1 15:57:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 1 May 2007 14:57:17 -0500 Subject: [rspec-users] rspec and autotest In-Reply-To: <5AE8D82E-2289-4E34-9666-1F34A2D619F6@gmail.com> References: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> <57c63afe0705011156u1a0c92e5n81296bc7dc06917a@mail.gmail.com> <5AE8D82E-2289-4E34-9666-1F34A2D619F6@gmail.com> Message-ID: <57c63afe0705011257xea99fc6te7ad84e47ad13898@mail.gmail.com> On 5/1/07, s.ross wrote: > Just followed all the instructions again...no luck. I just noticed this in your error message: /Users/sxross/.autotest If you're using my patch, you shouldn't need a .autotest file. I wonder if there is a conflict. Try moving that file somewhere or renaming it and see what happens. David > > Steve > > On May 1, 2007, at 11:56 AM, David Chelimsky wrote: > > > On 5/1/07, s.ross wrote: > >> I just installed the rspec plugin from trunk and zentest 3.5.2. I > >> applied the patch and get: > >> > >> lacosta:~/bitscribe/maxius_unified sxross$ autotest > >> loading rspec_rails_autotest > >> /Users/sxross/.autotest:5: undefined method `spec_command=' for > >> # (NoMethodError) > >> > >> > >> Any idea what's up with this? > > > > If you followed all the instructions on the blog, no idea at all. > > Anybody else? > > > >> > >> Thanks > >> > >> On May 1, 2007, at 5:30 AM, David Chelimsky wrote: > >> > >>> If you want to use rspec-0.9.2 with autotest (ZenTest-3.5.2), you'll > >>> want to read this blog: > >>> > >>> http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and- > >>> autotest-zentest-3-5-2 > >>> > >>> Enjoy! > >>> > >>> 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 > From cwdinfo at gmail.com Tue May 1 16:02:09 2007 From: cwdinfo at gmail.com (s.ross) Date: Tue, 1 May 2007 13:02:09 -0700 Subject: [rspec-users] rspec and autotest In-Reply-To: <57c63afe0705011257xea99fc6te7ad84e47ad13898@mail.gmail.com> References: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> <57c63afe0705011156u1a0c92e5n81296bc7dc06917a@mail.gmail.com> <5AE8D82E-2289-4E34-9666-1F34A2D619F6@gmail.com> <57c63afe0705011257xea99fc6te7ad84e47ad13898@mail.gmail.com> Message-ID: <282D4EAD-CC2E-4478-A176-2BD496379D29@gmail.com> Incredible! This was another of those "until zentest and rspec sync up" hacks to keep everything happy. I just totally missed it. Thanks so much. Steve On May 1, 2007, at 12:57 PM, David Chelimsky wrote: > On 5/1/07, s.ross wrote: >> Just followed all the instructions again...no luck. > > I just noticed this in your error message: > > /Users/sxross/.autotest > > If you're using my patch, you shouldn't need a .autotest file. I > wonder if there is a conflict. Try moving that file somewhere or > renaming it and see what happens. > > David > > >> >> Steve >> >> On May 1, 2007, at 11:56 AM, David Chelimsky wrote: >> >>> On 5/1/07, s.ross wrote: >>>> I just installed the rspec plugin from trunk and zentest 3.5.2. I >>>> applied the patch and get: >>>> >>>> lacosta:~/bitscribe/maxius_unified sxross$ autotest >>>> loading rspec_rails_autotest >>>> /Users/sxross/.autotest:5: undefined method `spec_command=' for >>>> # (NoMethodError) >>>> >>>> >>>> Any idea what's up with this? >>> >>> If you followed all the instructions on the blog, no idea at all. >>> Anybody else? >>> >>>> >>>> Thanks >>>> >>>> On May 1, 2007, at 5:30 AM, David Chelimsky wrote: >>>> >>>>> If you want to use rspec-0.9.2 with autotest (ZenTest-3.5.2), >>>>> you'll >>>>> want to read this blog: >>>>> >>>>> http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1- >>>>> and- >>>>> autotest-zentest-3-5-2 >>>>> >>>>> Enjoy! >>>>> >>>>> 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 From dchelimsky at gmail.com Tue May 1 16:26:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 1 May 2007 15:26:29 -0500 Subject: [rspec-users] rspec and autotest In-Reply-To: <282D4EAD-CC2E-4478-A176-2BD496379D29@gmail.com> References: <57c63afe0705010530g751d046ct4552202e7a9a9bf@mail.gmail.com> <57c63afe0705011156u1a0c92e5n81296bc7dc06917a@mail.gmail.com> <5AE8D82E-2289-4E34-9666-1F34A2D619F6@gmail.com> <57c63afe0705011257xea99fc6te7ad84e47ad13898@mail.gmail.com> <282D4EAD-CC2E-4478-A176-2BD496379D29@gmail.com> Message-ID: <57c63afe0705011326n60eceb0ene0c1663e1721a12f@mail.gmail.com> On 5/1/07, s.ross wrote: > Incredible! This was another of those "until zentest and rspec sync > up" hacks to keep everything happy. I'm working on it but it takes two to tango. > I just totally missed it. Glad I caught it. Cheers, David > > Thanks so much. > > Steve > > On May 1, 2007, at 12:57 PM, David Chelimsky wrote: > > > On 5/1/07, s.ross wrote: > >> Just followed all the instructions again...no luck. > > > > I just noticed this in your error message: > > > > /Users/sxross/.autotest > > > > If you're using my patch, you shouldn't need a .autotest file. I > > wonder if there is a conflict. Try moving that file somewhere or > > renaming it and see what happens. > > > > David > > > > > >> > >> Steve > >> > >> On May 1, 2007, at 11:56 AM, David Chelimsky wrote: > >> > >>> On 5/1/07, s.ross wrote: > >>>> I just installed the rspec plugin from trunk and zentest 3.5.2. I > >>>> applied the patch and get: > >>>> > >>>> lacosta:~/bitscribe/maxius_unified sxross$ autotest > >>>> loading rspec_rails_autotest > >>>> /Users/sxross/.autotest:5: undefined method `spec_command=' for > >>>> # (NoMethodError) > >>>> > >>>> > >>>> Any idea what's up with this? > >>> > >>> If you followed all the instructions on the blog, no idea at all. > >>> Anybody else? > >>> > >>>> > >>>> Thanks > >>>> > >>>> On May 1, 2007, at 5:30 AM, David Chelimsky wrote: > >>>> > >>>>> If you want to use rspec-0.9.2 with autotest (ZenTest-3.5.2), > >>>>> you'll > >>>>> want to read this blog: > >>>>> > >>>>> http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1- > >>>>> and- > >>>>> autotest-zentest-3-5-2 > >>>>> > >>>>> Enjoy! > >>>>> > >>>>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at kikobu.com Wed May 2 11:03:43 2007 From: lists at kikobu.com (Morten) Date: Wed, 02 May 2007 17:03:43 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? Message-ID: <4638A84F.4030507@kikobu.com> Hi. I'm upgrading a project from an 0.8.0 pre-release gem to 0.8.2. I've installed the 0.8.2 gem, and the rspec_on_rails 0.8.2 plugin: ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec When I try to run my specs though, I get the below error. It's as if the spec_helper cannot find "spec/rails". I've noticed that "spec/rails" is part of the rspec plugin, but I'm using the gem and cannot find spec/rails.rb (it's required in spec_helper.rb). I'm stuck and banging my head against the walls. Things fall out. Any tips much appreciated. Morten white:~/svn/novalis morten$ rake spec (in /Users/morten/svn/novalis) /opt/local/bin/ruby -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" "spec/controllers/account_controller_spec.rb" "spec/controllers/admin_controller_spec.rb" "spec/controllers/auhtenticate_controller_spec.rb" "spec/controllers/bar_controller_spec.rb" "spec/controllers/calendar_test_controller_spec.rb" "spec/controllers/manager_controller_spec.rb" "spec/controllers/reports_controller_spec.rb" "spec/controllers/stress_profiles_controller_spec.rb" "spec/controllers/therapist_controller_spec.rb" --options "/Users/morten/svn/novalis/config/../spec/spec.opts" /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- spec/rails (MissingSourceFile) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require' from /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' from /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require' from ./spec/controllers/../spec_helper.rb:5 from ./spec/controllers/account_controller_spec.rb:1 From aslak.hellesoy at gmail.com Wed May 2 11:39:49 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 2 May 2007 17:39:49 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <4638A84F.4030507@kikobu.com> References: <4638A84F.4030507@kikobu.com> Message-ID: <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> On 5/2/07, Morten wrote: > > Hi. I'm upgrading a project from an 0.8.0 pre-release gem to 0.8.2. > I've installed the 0.8.2 gem, and the rspec_on_rails 0.8.2 plugin: > > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec > > When I try to run my specs though, I get the below error. It's as if the > spec_helper cannot find "spec/rails". I've noticed that "spec/rails" is > part of the rspec plugin, but I'm using the gem and cannot find > spec/rails.rb (it's required in spec_helper.rb). I'm stuck and banging > my head against the walls. Things fall out. > > Any tips much appreciated. > Did you rerun script/generate rspec after upgrading? Could you try to upgrade to RSpec 0.9.1? Aslak > Morten > > white:~/svn/novalis morten$ rake spec > (in /Users/morten/svn/novalis) > /opt/local/bin/ruby > -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" > "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" > "spec/controllers/account_controller_spec.rb" > "spec/controllers/admin_controller_spec.rb" > "spec/controllers/auhtenticate_controller_spec.rb" > "spec/controllers/bar_controller_spec.rb" > "spec/controllers/calendar_test_controller_spec.rb" > "spec/controllers/manager_controller_spec.rb" > "spec/controllers/reports_controller_spec.rb" > "spec/controllers/stress_profiles_controller_spec.rb" > "spec/controllers/therapist_controller_spec.rb" --options > "/Users/morten/svn/novalis/config/../spec/spec.opts" > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- spec/rails > (MissingSourceFile) > from > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > from > /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in > `require' > from > /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in > `new_constants_in' > from > /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in > `require' > from ./spec/controllers/../spec_helper.rb:5 > from ./spec/controllers/account_controller_spec.rb:1 > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 2 11:40:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 May 2007 10:40:05 -0500 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <4638A84F.4030507@kikobu.com> References: <4638A84F.4030507@kikobu.com> Message-ID: <57c63afe0705020840s4b91fefetcc9712ffb7baaba@mail.gmail.com> Since you're upgrading, why don't you upgrade to 0.9.1? That's the latest and greatest. David On 5/2/07, Morten wrote: > > Hi. I'm upgrading a project from an 0.8.0 pre-release gem to 0.8.2. > I've installed the 0.8.2 gem, and the rspec_on_rails 0.8.2 plugin: > > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec > > When I try to run my specs though, I get the below error. It's as if the > spec_helper cannot find "spec/rails". I've noticed that "spec/rails" is > part of the rspec plugin, but I'm using the gem and cannot find > spec/rails.rb (it's required in spec_helper.rb). I'm stuck and banging > my head against the walls. Things fall out. > > Any tips much appreciated. > > Morten > > white:~/svn/novalis morten$ rake spec > (in /Users/morten/svn/novalis) > /opt/local/bin/ruby > -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" > "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" > "spec/controllers/account_controller_spec.rb" > "spec/controllers/admin_controller_spec.rb" > "spec/controllers/auhtenticate_controller_spec.rb" > "spec/controllers/bar_controller_spec.rb" > "spec/controllers/calendar_test_controller_spec.rb" > "spec/controllers/manager_controller_spec.rb" > "spec/controllers/reports_controller_spec.rb" > "spec/controllers/stress_profiles_controller_spec.rb" > "spec/controllers/therapist_controller_spec.rb" --options > "/Users/morten/svn/novalis/config/../spec/spec.opts" > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- spec/rails > (MissingSourceFile) > from > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > from > /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in > `require' > from > /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in > `new_constants_in' > from > /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in > `require' > from ./spec/controllers/../spec_helper.rb:5 > from ./spec/controllers/account_controller_spec.rb:1 > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at kikobu.com Wed May 2 11:40:52 2007 From: lists at kikobu.com (Morten) Date: Wed, 02 May 2007 17:40:52 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> Message-ID: <4638B104.90708@kikobu.com> aslak hellesoy wrote: > On 5/2/07, Morten wrote: >> Hi. I'm upgrading a project from an 0.8.0 pre-release gem to 0.8.2. >> I've installed the 0.8.2 gem, and the rspec_on_rails 0.8.2 plugin: >> >> ruby script/plugin install >> svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec >> >> When I try to run my specs though, I get the below error. It's as if the >> spec_helper cannot find "spec/rails". I've noticed that "spec/rails" is >> part of the rspec plugin, but I'm using the gem and cannot find >> spec/rails.rb (it's required in spec_helper.rb). I'm stuck and banging >> my head against the walls. Things fall out. >> >> Any tips much appreciated. >> > > Did you rerun script/generate rspec after upgrading? Yes. > Could you try to upgrade to RSpec 0.9.1? Hmm.. I tried that path but it changed a lot of specs to non-working. Br, Morten > > Aslak > >> Morten >> >> white:~/svn/novalis morten$ rake spec >> (in /Users/morten/svn/novalis) >> /opt/local/bin/ruby >> -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" >> "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" >> "spec/controllers/account_controller_spec.rb" >> "spec/controllers/admin_controller_spec.rb" >> "spec/controllers/auhtenticate_controller_spec.rb" >> "spec/controllers/bar_controller_spec.rb" >> "spec/controllers/calendar_test_controller_spec.rb" >> "spec/controllers/manager_controller_spec.rb" >> "spec/controllers/reports_controller_spec.rb" >> "spec/controllers/stress_profiles_controller_spec.rb" >> "spec/controllers/therapist_controller_spec.rb" --options >> "/Users/morten/svn/novalis/config/../spec/spec.opts" >> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in >> `gem_original_require': no such file to load -- spec/rails >> (MissingSourceFile) >> from >> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in >> `require' >> from >> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in >> `require' >> from >> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in >> `new_constants_in' >> from >> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in >> `require' >> from ./spec/controllers/../spec_helper.rb:5 >> from ./spec/controllers/account_controller_spec.rb:1 >> >> >> >> _______________________________________________ >> 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 Wed May 2 11:43:25 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 May 2007 10:43:25 -0500 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <4638B104.90708@kikobu.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> Message-ID: <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> On 5/2/07, Morten wrote: > aslak hellesoy wrote: > > On 5/2/07, Morten wrote: > >> Hi. I'm upgrading a project from an 0.8.0 pre-release gem to 0.8.2. > >> I've installed the 0.8.2 gem, and the rspec_on_rails 0.8.2 plugin: > >> > >> ruby script/plugin install > >> svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec > >> > >> When I try to run my specs though, I get the below error. It's as if the > >> spec_helper cannot find "spec/rails". I've noticed that "spec/rails" is > >> part of the rspec plugin, but I'm using the gem and cannot find > >> spec/rails.rb (it's required in spec_helper.rb). I'm stuck and banging > >> my head against the walls. Things fall out. > >> > >> Any tips much appreciated. > >> > > > > Did you rerun script/generate rspec after upgrading? > > Yes. > > > Could you try to upgrade to RSpec 0.9.1? > > Hmm.. I tried that path but it changed a lot of specs to non-working. Did you read http://rspec.rubyforge.org/upgrade.html? > > Br, > > Morten > > > > > > > Aslak > > > >> Morten > >> > >> white:~/svn/novalis morten$ rake spec > >> (in /Users/morten/svn/novalis) > >> /opt/local/bin/ruby > >> -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" > >> "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" > >> "spec/controllers/account_controller_spec.rb" > >> "spec/controllers/admin_controller_spec.rb" > >> "spec/controllers/auhtenticate_controller_spec.rb" > >> "spec/controllers/bar_controller_spec.rb" > >> "spec/controllers/calendar_test_controller_spec.rb" > >> "spec/controllers/manager_controller_spec.rb" > >> "spec/controllers/reports_controller_spec.rb" > >> "spec/controllers/stress_profiles_controller_spec.rb" > >> "spec/controllers/therapist_controller_spec.rb" --options > >> "/Users/morten/svn/novalis/config/../spec/spec.opts" > >> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > >> `gem_original_require': no such file to load -- spec/rails > >> (MissingSourceFile) > >> from > >> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > >> `require' > >> from > >> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in > >> `require' > >> from > >> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in > >> `new_constants_in' > >> from > >> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in > >> `require' > >> from ./spec/controllers/../spec_helper.rb:5 > >> from ./spec/controllers/account_controller_spec.rb:1 > >> > >> > >> > >> _______________________________________________ > >> 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 lists at kikobu.com Wed May 2 12:03:26 2007 From: lists at kikobu.com (Morten) Date: Wed, 02 May 2007 18:03:26 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> Message-ID: <4638B64E.3060507@kikobu.com> Hope you don't get this message all 3 times I sent it, got a headache from all this and sent it from the wrong sender account :-) Found the problem (thanks to Yurii Rashkovskii). The plugin installation from http://rspec.rubyforge.org/documentation/rails/install.html doesn't work with the 0.8.2 SVN structure. white:~/tmp/kano morten$ ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails white:~/tmp/kano morten$ find vendor/plugins/rspec_on_rails/ -name "rails*" vendor/plugins/rspec_on_rails//public/images/rails.png vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/generators/rspec/templates/script/rails_spec_server vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails.rb vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/spec/rails vendor/plugins/rspec_on_rails//vendor/rails Using the following works better: piston import svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails/vendor/plugins/rspec_on_rails Br, Morten From dchelimsky at gmail.com Wed May 2 12:08:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 May 2007 11:08:03 -0500 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <4638B64E.3060507@kikobu.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> <4638B64E.3060507@kikobu.com> Message-ID: <57c63afe0705020908y4ca7c251i58fe2e2724741583@mail.gmail.com> On 5/2/07, Morten wrote: > > Hope you don't get this message all 3 times I sent it, got a headache > from all this and sent it from the wrong sender account :-) > > Found the problem (thanks to Yurii Rashkovskii). The plugin installation > from http://rspec.rubyforge.org/documentation/rails/install.html doesn't > work with the 0.8.2 SVN structure. > > white:~/tmp/kano morten$ ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails Read the bottom of that page. > > white:~/tmp/kano morten$ find vendor/plugins/rspec_on_rails/ -name "rails*" > vendor/plugins/rspec_on_rails//public/images/rails.png > vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/generators/rspec/templates/script/rails_spec_server > vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails > vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails.rb > vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/spec/rails > vendor/plugins/rspec_on_rails//vendor/rails > > Using the following works better: > > piston import > svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails/vendor/plugins/rspec_on_rails > > Br, > > Morten > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From morten at kikobu.com Wed May 2 11:59:38 2007 From: morten at kikobu.com (Morten Primdahl) Date: Wed, 02 May 2007 17:59:38 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> Message-ID: <4638B56A.9030409@kikobu.com> Found the problem (thanks to Yurii Rashkovskii). The plugin installation from http://rspec.rubyforge.org/documentation/rails/install.html doesn't work with the 0.8.2 SVN structure. white:~/tmp/kano morten$ ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails white:~/tmp/kano morten$ find vendor/plugins/rspec_on_rails/ -name "rails*" vendor/plugins/rspec_on_rails//public/images/rails.png vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/generators/rspec/templates/script/rails_spec_server vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails.rb vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/spec/rails vendor/plugins/rspec_on_rails//vendor/rails Using the following works better: piston import svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails/vendor/plugins/rspec_on_rails Br, Morten David Chelimsky wrote: > On 5/2/07, Morten wrote: >> aslak hellesoy wrote: >>> On 5/2/07, Morten wrote: >>>> Hi. I'm upgrading a project from an 0.8.0 pre-release gem to 0.8.2. >>>> I've installed the 0.8.2 gem, and the rspec_on_rails 0.8.2 plugin: >>>> >>>> ruby script/plugin install >>>> svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec >>>> >>>> When I try to run my specs though, I get the below error. It's as if the >>>> spec_helper cannot find "spec/rails". I've noticed that "spec/rails" is >>>> part of the rspec plugin, but I'm using the gem and cannot find >>>> spec/rails.rb (it's required in spec_helper.rb). I'm stuck and banging >>>> my head against the walls. Things fall out. >>>> >>>> Any tips much appreciated. >>>> >>> Did you rerun script/generate rspec after upgrading? >> Yes. >> >>> Could you try to upgrade to RSpec 0.9.1? >> Hmm.. I tried that path but it changed a lot of specs to non-working. > > Did you read http://rspec.rubyforge.org/upgrade.html? > >> Br, >> >> Morten >> >> >> >>> Aslak >>> >>>> Morten >>>> >>>> white:~/svn/novalis morten$ rake spec >>>> (in /Users/morten/svn/novalis) >>>> /opt/local/bin/ruby >>>> -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" >>>> "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" >>>> "spec/controllers/account_controller_spec.rb" >>>> "spec/controllers/admin_controller_spec.rb" >>>> "spec/controllers/auhtenticate_controller_spec.rb" >>>> "spec/controllers/bar_controller_spec.rb" >>>> "spec/controllers/calendar_test_controller_spec.rb" >>>> "spec/controllers/manager_controller_spec.rb" >>>> "spec/controllers/reports_controller_spec.rb" >>>> "spec/controllers/stress_profiles_controller_spec.rb" >>>> "spec/controllers/therapist_controller_spec.rb" --options >>>> "/Users/morten/svn/novalis/config/../spec/spec.opts" >>>> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in >>>> `gem_original_require': no such file to load -- spec/rails >>>> (MissingSourceFile) >>>> from >>>> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in >>>> `require' >>>> from >>>> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in >>>> `require' >>>> from >>>> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in >>>> `new_constants_in' >>>> from >>>> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in >>>> `require' >>>> from ./spec/controllers/../spec_helper.rb:5 >>>> from ./spec/controllers/account_controller_spec.rb:1 >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 morten at kikobu.com Wed May 2 12:02:05 2007 From: morten at kikobu.com (Morten Primdahl) Date: Wed, 02 May 2007 18:02:05 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> Message-ID: <4638B5FD.3010100@kikobu.com> Found the problem (thanks to Yurii Rashkovskii). The plugin installation from http://rspec.rubyforge.org/documentation/rails/install.html doesn't work with the 0.8.2 SVN structure. white:~/tmp/kano morten$ ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails white:~/tmp/kano morten$ find vendor/plugins/rspec_on_rails/ -name "rails*" vendor/plugins/rspec_on_rails//public/images/rails.png vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/generators/rspec/templates/script/rails_spec_server vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/lib/spec/rails.rb vendor/plugins/rspec_on_rails//vendor/plugins/rspec_on_rails/spec/rails vendor/plugins/rspec_on_rails//vendor/rails Using the following works better: piston import svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails/vendor/plugins/rspec_on_rails Br, Morten From morten at kikobu.com Wed May 2 11:45:57 2007 From: morten at kikobu.com (Morten Primdahl) Date: Wed, 02 May 2007 17:45:57 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> Message-ID: <4638B235.7010005@kikobu.com> David Chelimsky wrote: > On 5/2/07, Morten wrote: >> aslak hellesoy wrote: >>> On 5/2/07, Morten wrote: >>>> Hi. I'm upgrading a project from an 0.8.0 pre-release gem to 0.8.2. >>>> I've installed the 0.8.2 gem, and the rspec_on_rails 0.8.2 plugin: >>>> >>>> ruby script/plugin install >>>> svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec >>>> >>>> When I try to run my specs though, I get the below error. It's as if the >>>> spec_helper cannot find "spec/rails". I've noticed that "spec/rails" is >>>> part of the rspec plugin, but I'm using the gem and cannot find >>>> spec/rails.rb (it's required in spec_helper.rb). I'm stuck and banging >>>> my head against the walls. Things fall out. >>>> >>>> Any tips much appreciated. >>>> >>> Did you rerun script/generate rspec after upgrading? >> Yes. >> >>> Could you try to upgrade to RSpec 0.9.1? >> Hmm.. I tried that path but it changed a lot of specs to non-working. > > Did you read http://rspec.rubyforge.org/upgrade.html? Yeah, the converter didn't work properly. I'll give it a shot and manually correct the specs. Br, Morten > >> Br, >> >> Morten >> >> >> >>> Aslak >>> >>>> Morten >>>> >>>> white:~/svn/novalis morten$ rake spec >>>> (in /Users/morten/svn/novalis) >>>> /opt/local/bin/ruby >>>> -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" >>>> "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" >>>> "spec/controllers/account_controller_spec.rb" >>>> "spec/controllers/admin_controller_spec.rb" >>>> "spec/controllers/auhtenticate_controller_spec.rb" >>>> "spec/controllers/bar_controller_spec.rb" >>>> "spec/controllers/calendar_test_controller_spec.rb" >>>> "spec/controllers/manager_controller_spec.rb" >>>> "spec/controllers/reports_controller_spec.rb" >>>> "spec/controllers/stress_profiles_controller_spec.rb" >>>> "spec/controllers/therapist_controller_spec.rb" --options >>>> "/Users/morten/svn/novalis/config/../spec/spec.opts" >>>> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in >>>> `gem_original_require': no such file to load -- spec/rails >>>> (MissingSourceFile) >>>> from >>>> /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in >>>> `require' >>>> from >>>> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in >>>> `require' >>>> from >>>> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in >>>> `new_constants_in' >>>> from >>>> /Users/morten/svn/novalis/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in >>>> `require' >>>> from ./spec/controllers/../spec_helper.rb:5 >>>> from ./spec/controllers/account_controller_spec.rb:1 >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 aslak.hellesoy at gmail.com Wed May 2 12:12:18 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 2 May 2007 18:12:18 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <4638B235.7010005@kikobu.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> <4638B235.7010005@kikobu.com> Message-ID: <8d961d900705020912j68b792a1o127b17e1ea88ddd6@mail.gmail.com> > > Did you read http://rspec.rubyforge.org/upgrade.html? > > Yeah, the converter didn't work properly. I'll give it a shot and > manually correct the specs. > If you tell us what you did and how it didn't work we may be able to improve it. Aslak > Br, > From lists at kikobu.com Wed May 2 12:12:34 2007 From: lists at kikobu.com (Morten) Date: Wed, 02 May 2007 18:12:34 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <57c63afe0705020908y4ca7c251i58fe2e2724741583@mail.gmail.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> <4638B64E.3060507@kikobu.com> <57c63afe0705020908y4ca7c251i58fe2e2724741583@mail.gmail.com> Message-ID: <4638B872.6050501@kikobu.com> David Chelimsky wrote: > On 5/2/07, Morten wrote: >> Hope you don't get this message all 3 times I sent it, got a headache >> from all this and sent it from the wrong sender account :-) >> >> Found the problem (thanks to Yurii Rashkovskii). The plugin installation >> from http://rspec.rubyforge.org/documentation/rails/install.html doesn't >> work with the 0.8.2 SVN structure. >> >> white:~/tmp/kano morten$ ruby script/plugin install >> svn://rubyforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails > > Read the bottom of that page. Ouch. Beers on me, and pardon the spam. Morten From lists at kikobu.com Wed May 2 12:21:06 2007 From: lists at kikobu.com (Morten) Date: Wed, 02 May 2007 18:21:06 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <8d961d900705020912j68b792a1o127b17e1ea88ddd6@mail.gmail.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> <4638B235.7010005@kikobu.com> <8d961d900705020912j68b792a1o127b17e1ea88ddd6@mail.gmail.com> Message-ID: <4638BA72.1070307@kikobu.com> aslak hellesoy wrote: >>> Did you read http://rspec.rubyforge.org/upgrade.html? >> Yeah, the converter didn't work properly. I'll give it a shot and >> manually correct the specs. >> > > If you tell us what you did and how it didn't work we may be able to improve it. In these 2 conversions the parenthesis are wrong: Before: controller.should_redirect_to 'http://not_existing_domain_for_novalis.test.host/404.html' After: controller.should be_redirect_to('http:)//not_existing_domain_for_novalis.test.host/404.html' Before: controller.should_redirect_to :subdomain => account.subdomain, :controller => 'authenticate', :action => 'login' After: controller.should be_redirect_to(:subdomain)=> account.subdomain, :controller => 'authenticate', :action => 'login' Br, Morten From aslak.hellesoy at gmail.com Wed May 2 12:49:34 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 2 May 2007 18:49:34 +0200 Subject: [rspec-users] RSpec 0.8.2 pain, missing spec/rails? In-Reply-To: <4638BA72.1070307@kikobu.com> References: <4638A84F.4030507@kikobu.com> <8d961d900705020839u4320cbffv372233faf9fd756c@mail.gmail.com> <4638B104.90708@kikobu.com> <57c63afe0705020843n1fef8e71re7ec9ecaa6666c2c@mail.gmail.com> <4638B235.7010005@kikobu.com> <8d961d900705020912j68b792a1o127b17e1ea88ddd6@mail.gmail.com> <4638BA72.1070307@kikobu.com> Message-ID: <8d961d900705020949y17d4b70fj26d7be703769685f@mail.gmail.com> On 5/2/07, Morten wrote: > aslak hellesoy wrote: > >>> Did you read http://rspec.rubyforge.org/upgrade.html? > >> Yeah, the converter didn't work properly. I'll give it a shot and > >> manually correct the specs. > >> > > > > If you tell us what you did and how it didn't work we may be able to improve it. > > In these 2 conversions the parenthesis are wrong: > > Before: > controller.should_redirect_to > 'http://not_existing_domain_for_novalis.test.host/404.html' > > After: > controller.should > be_redirect_to('http:)//not_existing_domain_for_novalis.test.host/404.html' > > Before: > controller.should_redirect_to :subdomain => account.subdomain, > :controller => 'authenticate', :action => 'login' > > After: > controller.should be_redirect_to(:subdomain)=> account.subdomain, > :controller => 'authenticate', :action => 'login' > Thanks a bunch. Another bug in the translator is plugged on trunk. Cheers, Aslak > Br, > > Morten > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 3 00:17:36 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 May 2007 23:17:36 -0500 Subject: [rspec-users] predicate matchers Message-ID: <57c63afe0705022117n1e53f10cyd78695d89072733e@mail.gmail.com> Hey all, If any of you are using the new predicate_matchers feature, I just committed a change to it in trunk. See http://rubyforge.org/tracker/index.php?func=detail&aid=10542&group_id=797&atid=3152 for more details, but the high level is that instead of this: predicate_matchers[:method_on_object] = :method_in_spec It now (as of rev 1898 - soon to be released in 0.9.2) does this: predicate_matchers[:method_in_spec] = :method_on_object I (and I'm apparently not alone) think this reads better. Here's an example: predicate_matchers[:eat] = :eats? sheep.should eat('grass') # passes if sheep.eats?('grass') Apologies for those of you who jumped on this feature. Hopefully it hasn't proven itself that useful yet ;) Cheers, David From jeff at jefdean.com Thu May 3 00:37:45 2007 From: jeff at jefdean.com (Jeff Dean) Date: Thu, 3 May 2007 00:37:45 -0400 Subject: [rspec-users] Note of praise Message-ID: <6586e070705022137n30b16b55l4188391d69b083b3@mail.gmail.com> I don't mean to litter the mailing list with junk, but I just wanted to say thanks to everyone who's been working on rspec for this release. I particularly like your attention to natural language and thorough documentation/examples. I'm not at the point yet where I can contribute much to the code side of things, but if there were a donate button I would use it. Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070503/3bf0c181/attachment.html From mailing_lists at railsnewbie.com Thu May 3 01:05:24 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 3 May 2007 01:05:24 -0400 Subject: [rspec-users] before method Message-ID: Would it be desirable to have before and after take a spec name as well as :each and :all? Scott From dchelimsky at gmail.com Thu May 3 01:08:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 May 2007 00:08:45 -0500 Subject: [rspec-users] before method In-Reply-To: References: Message-ID: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> On 5/3/07, Scott Taylor wrote: > > Would it be desirable to have before and after take a spec name as > well as :each and :all? What do YOU think? > > Scott > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeff at jefdean.com Thu May 3 02:46:26 2007 From: jeff at jefdean.com (Jeff Dean) Date: Thu, 3 May 2007 02:46:26 -0400 Subject: [rspec-users] before method In-Reply-To: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> References: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> Message-ID: <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> Having custom before statements might reduce readability a bit - I would argue that if you have many "it" statements that share a common setup, they probably deserve a separate context (a different known state). The shared context makes it possible to reduce duplication that might otherwise come from splitting up contexts, and basically does the same thing as custom before statements would do - only it keeps each context a little more atomic - IMO On 5/3/07, David Chelimsky wrote: > > On 5/3/07, Scott Taylor wrote: > > > > Would it be desirable to have before and after take a spec name as > > well as :each and :all? > > What do YOU think? > > > > > Scott > > _______________________________________________ > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070503/4f7cebf1/attachment.html From aslak.hellesoy at gmail.com Thu May 3 04:06:24 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 3 May 2007 10:06:24 +0200 Subject: [rspec-users] Note of praise In-Reply-To: <6586e070705022137n30b16b55l4188391d69b083b3@mail.gmail.com> References: <6586e070705022137n30b16b55l4188391d69b083b3@mail.gmail.com> Message-ID: <8d961d900705030106l657ae4f0h8a7a804ba4de973@mail.gmail.com> On 5/3/07, Jeff Dean wrote: > I don't mean to litter the mailing list with junk, but I just wanted to say > thanks to everyone who's been working on rspec for this release. I > particularly like your attention to natural language and thorough > documentation/examples. I'm not at the point yet where I can contribute > much to the code side of things, but if there were a donate button I would > use it. > Your praise is great contribution! Thanks a lot, Aslak > Jeff > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu May 3 04:11:28 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 3 May 2007 10:11:28 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.2 Message-ID: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> Behind every great release is a maintenance release. Go get it while it's hot. We've also reworked the website a little - trying to scare off fewer people. Aslak From mailing_lists at railsnewbie.com Thu May 3 04:16:58 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 3 May 2007 04:16:58 -0400 Subject: [rspec-users] Note of praise In-Reply-To: <8d961d900705030106l657ae4f0h8a7a804ba4de973@mail.gmail.com> References: <6586e070705022137n30b16b55l4188391d69b083b3@mail.gmail.com> <8d961d900705030106l657ae4f0h8a7a804ba4de973@mail.gmail.com> Message-ID: <8BB64A47-906D-4D62-B1BA-0C99D2202C58@railsnewbie.com> On May 3, 2007, at 4:06 AM, aslak hellesoy wrote: > On 5/3/07, Jeff Dean wrote: >> I don't mean to litter the mailing list with junk, but I just >> wanted to say >> thanks to everyone who's been working on rspec for this release. I >> particularly like your attention to natural language and thorough >> documentation/examples. I'm not at the point yet where I can >> contribute >> much to the code side of things, but if there were a donate button >> I would >> use it. >> > > Your praise is great contribution! > > Thanks a lot, > Aslak Seriously, though, Aslak, (David, & co.): You should think about getting a paypal account. Not that you have to plaster it all over the rspec website and solicit donations...but if one wants to give, they should feel free to do so. You guys have worked hard on this thing, and it shows. If nothing else, it should at least buy you guys a treat every once in a while (a nice dinner, a well deserved trip to the bar...), or maybe it should help fund your trip to rails/ ruby conf. Scott From mlangenberg at gmail.com Thu May 3 04:39:20 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Thu, 3 May 2007 10:39:20 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.2 In-Reply-To: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> References: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> Message-ID: <27c0ac6d0705030139i7387e744k6755699d92930a72@mail.gmail.com> Website looks pretty neat! Good job! On 5/3/07, aslak hellesoy wrote: > Behind every great release is a maintenance release. > Go get it while it's hot. > > We've also reworked the website a little - trying to scare off fewer people. > > Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 3 07:23:40 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 May 2007 06:23:40 -0500 Subject: [rspec-users] before method In-Reply-To: <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> References: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> Message-ID: <57c63afe0705030423n5627ba06pcb0dd3b3d9975b22@mail.gmail.com> On 5/3/07, Jeff Dean wrote: > Having custom before statements might reduce readability a bit - I would > argue that if you have many "it" statements that share a common setup, they > probably deserve a separate context (a different known state). The shared > context makes it possible to reduce duplication that might otherwise come > from splitting up contexts, and basically does the same thing as custom > before statements would do - only it keeps each context a little more atomic > - IMO Scott - I would agree w/ Jeff here, but I am interested to know what you had in my mind. > > > On 5/3/07, David Chelimsky wrote: > > On 5/3/07, Scott Taylor wrote: > > > > > > Would it be desirable to have before and after take a spec name as > > > well as :each and :all? > > > > What do YOU think? > > > > > > > > Scott > > > _______________________________________________ > > > 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 benilov at gmail.com Thu May 3 10:08:29 2007 From: benilov at gmail.com (Jake Benilov) Date: Thu, 3 May 2007 16:08:29 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.2 In-Reply-To: <27c0ac6d0705030139i7387e744k6755699d92930a72@mail.gmail.com> References: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> <27c0ac6d0705030139i7387e744k6755699d92930a72@mail.gmail.com> Message-ID: <6fc165060705030708j5b610f9fj5d310b6cede4954d@mail.gmail.com> Is it me or is the installation page for Spec::Rails (http://rspec.rubyforge.org/documentation/rails/install.html) no longer accessible through the breadcrumb? I only found it through google ... On 5/3/07, Matthijs Langenberg wrote: > Website looks pretty neat! Good job! > > On 5/3/07, aslak hellesoy wrote: > > Behind every great release is a maintenance release. > > Go get it while it's hot. > > > > We've also reworked the website a little - trying to scare off fewer people. > > > > Aslak > > _______________________________________________ > > 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 Thu May 3 10:13:23 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 May 2007 09:13:23 -0500 Subject: [rspec-users] [ANN] RSpec 0.9.2 In-Reply-To: <6fc165060705030708j5b610f9fj5d310b6cede4954d@mail.gmail.com> References: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> <27c0ac6d0705030139i7387e744k6755699d92930a72@mail.gmail.com> <6fc165060705030708j5b610f9fj5d310b6cede4954d@mail.gmail.com> Message-ID: <57c63afe0705030713k1458c8c7r7d5401b458e16b75@mail.gmail.com> On 5/3/07, Jake Benilov wrote: > Is it me or is the installation page for Spec::Rails > (http://rspec.rubyforge.org/documentation/rails/install.html) no > longer accessible through the breadcrumb? > I only found it through google ... The breadcrumbs on that page show you the path: Home >> Documentation >> Rails >> Install We'll make it more accessible though. Cheers, David > > > On 5/3/07, Matthijs Langenberg wrote: > > Website looks pretty neat! Good job! > > > > On 5/3/07, aslak hellesoy wrote: > > > Behind every great release is a maintenance release. > > > Go get it while it's hot. > > > > > > We've also reworked the website a little - trying to scare off fewer people. > > > > > > Aslak > > > _______________________________________________ > > > 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 t.lucas at toolmantim.com Thu May 3 10:16:02 2007 From: t.lucas at toolmantim.com (Tim Lucas) Date: Fri, 4 May 2007 00:16:02 +1000 Subject: [rspec-users] [ANN] RSpec 0.9.2 In-Reply-To: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> References: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> Message-ID: <9D1DCDA5-1B45-40D5-876D-26677713AF2C@toolmantim.com> On 03/05/2007, at 6:11 PM, aslak hellesoy wrote: > We've also reworked the website a little - trying to scare off > fewer people. Great work on the website. Can I give a spec for a small suggestion: TheRSpecWebsite - should take into account most visitors will be rails developers - should take into account many visitors will be using textmate - should have install & getting started instructions on the homepage that take the above into account - should at least provide links to those instructions if the homepage becomes cluttered -- tim From t.lucas at toolmantim.com Thu May 3 10:17:48 2007 From: t.lucas at toolmantim.com (Tim Lucas) Date: Fri, 4 May 2007 00:17:48 +1000 Subject: [rspec-users] [ANN] RSpec 0.9.2 In-Reply-To: <57c63afe0705030713k1458c8c7r7d5401b458e16b75@mail.gmail.com> References: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> <27c0ac6d0705030139i7387e744k6755699d92930a72@mail.gmail.com> <6fc165060705030708j5b610f9fj5d310b6cede4954d@mail.gmail.com> <57c63afe0705030713k1458c8c7r7d5401b458e16b75@mail.gmail.com> Message-ID: <846152AB-B876-4AA2-8502-E3F084EE0D5F@toolmantim.com> On 04/05/2007, at 12:13 AM, David Chelimsky wrote: > On 5/3/07, Jake Benilov wrote: >> Is it me or is the installation page for Spec::Rails >> (http://rspec.rubyforge.org/documentation/rails/install.html) no >> longer accessible through the breadcrumb? >> I only found it through google ... > > The breadcrumbs on that page show you the path: > > Home >> Documentation >> Rails >> Install > > We'll make it more accessible though. hah! Beat me by 2 minutes. Great news though :) -- tim From chris.c.hoffman at gmail.com Thu May 3 11:24:57 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Thu, 3 May 2007 11:24:57 -0400 Subject: [rspec-users] Breakpoint support Message-ID: <63c5d3820705030824m699092edi8664d4f36fbad2e@mail.gmail.com> Hello, Since release 0.9.x, I haven't been able to get breakpoint support fully working. I am able to execute a breakpoint, but I don't seem to have access to local variables when inside. Are others able to access these variables? -Chris From cwdinfo at gmail.com Thu May 3 12:23:28 2007 From: cwdinfo at gmail.com (s.ross) Date: Thu, 3 May 2007 09:23:28 -0700 Subject: [rspec-users] rSpec on CruiseControl.rb In-Reply-To: <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> References: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> Message-ID: Has anyone gotten CC to use rSpec as a builder? There was some comment on their list about this in February, but I wondered if anyone here is using CC (or is there some other ci tool that might be more suitable)? Thx From mlangenberg at gmail.com Thu May 3 12:45:06 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Thu, 3 May 2007 18:45:06 +0200 Subject: [rspec-users] rSpec on CruiseControl.rb In-Reply-To: References: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> Message-ID: <27c0ac6d0705030945l6fb816d8m7ad305717e2eb49d@mail.gmail.com> I didn't have any troubles to get it working at all, I just created a Rakefile with a custom 'cruise' task: require 'rake' require 'spec/rake/spectask' task :cruise do Rake::Task["spec"].invoke end Spec::Rake::SpecTask.new do |t| t.spec_opts = ['-f s'] t.spec_files = 'SMSer_spec.rb' end What problems are you running into, or are you talking about a Rails project? On 5/3/07, s. ross wrote: > Has anyone gotten CC to use rSpec as a builder? There was some > comment on their list about this in February, but I wondered if > anyone here is using CC (or is there some other ci tool that might be > more suitable)? > > Thx > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cowboysolitude at gmail.com Thu May 3 13:08:26 2007 From: cowboysolitude at gmail.com (J.D. Hollis) Date: Thu, 3 May 2007 13:08:26 -0400 Subject: [rspec-users] unexpected failures with --reverse Message-ID: I'm having trouble figuring out why one of my specs passes when run without --reverse and then fails with --reverse. What am I missing? I'm using the plugin versions of both rspec and rspec_on_rails 0.9.2. Here is the offending spec (Bill is an ActiveRecord model in a Rails app): ---------- describe Bill, " when valid" do def valid_bill_attributes { :uuid => "ec5e943f-a819-433b-b786-ee847bb144e2", :date => Date.today, :amount => Money.new(15000) } end it "should have a uuid" do bill = Bill.create(valid_bill_attributes) bill.uuid = nil bill.should have(2).errors_on(:uuid) end it "should have a uuid that is no longer than 36 characters" do bill = Bill.create(valid_bill_attributes) bill.uuid = bill.uuid + "1" bill.should have(1).error_on(:uuid) end it "should have a uuid that is no shorter than 36 characters" do bill = Bill.create(valid_bill_attributes) bill.uuid = bill.uuid[0..34] bill.should have(1).error_on(:uuid) end it "should have a case-insensitive, unique uuid" do bill = Bill.create(valid_bill_attributes) another = Bill.new(valid_bill_attributes) another.should have(1).error_on(:uuid) another.uuid = valid_bill_attributes[:uuid].upcase another.should have(1).error_on(:uuid) end it "should have a date" do bill = Bill.new(valid_bill_attributes.except(:date)) bill.should have(1).error_on(:date) end it "should have an amount_currency" do bill = Bill.new(valid_bill_attributes) bill.amount_currency = nil bill.should have(1).error_on(:amount_currency) end it "should have an amount_cents greater than 0" do bill = Bill.new(valid_bill_attributes) bill.amount_cents = 0 bill.should have(1).error_on(:amount_cents) bill.amount_cents = -2 bill.should have(1).error_on(:amount_cents) end end describe Bill do before(:each) do @bill = Bill.new @date = mock("date") end it "should return self.date.month when asked for :month" do month = mock("month") @bill.should_receive(:date).and_return(@date) @date.should_receive(:month).and_return(month) @bill.month.should == month end it "should return self.date.year when asked for :year" do year = mock("year") @bill.should_receive(:date).and_return(@date) @date.should_receive(:year).and_return(year) @bill.year.should == year end after(:each) do @bill = nil @date = nil end end ---------- And here is the output when I run the spec using the stock 0.9.2 spec.opts via 'spec -O spec/spec.opts spec/models/bill_spec.rb' (it also fails when I run it via 'rake spec:models'): ---------- FFFFFFFFF 1) NameError in 'Bill should return self.date.year when asked for :year' undefined method `date' for class `Bill' ./spec/models/bill_spec.rb:71: 2) NameError in 'Bill should return self.date.month when asked for :month' undefined method `date' for class `Bill' ./spec/models/bill_spec.rb:64: 3) NameError in 'Bill when valid should have an amount_cents greater than 0' undefined method `proxied_by_rspec__date' for class `Bill' 4) NameError in 'Bill when valid should have an amount_currency' undefined method `proxied_by_rspec__date' for class `Bill' 5) NameError in 'Bill when valid should have a date' undefined method `proxied_by_rspec__date' for class `Bill' 6) NameError in 'Bill when valid should have a case-insensitive, unique uuid' undefined method `proxied_by_rspec__date' for class `Bill' 7) NameError in 'Bill when valid should have a uuid that is no shorter than 36 characters' undefined method `proxied_by_rspec__date' for class `Bill' 8) NameError in 'Bill when valid should have a uuid that is no longer than 36 characters' undefined method `proxied_by_rspec__date' for class `Bill' 9) NameError in 'Bill when valid should have a uuid' undefined method `proxied_by_rspec__date' for class `Bill' ---------- From chris.c.hoffman at gmail.com Thu May 3 13:09:35 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Thu, 3 May 2007 13:09:35 -0400 Subject: [rspec-users] 0.9.2 redirect_to no longer accepts hash? Message-ID: <63c5d3820705031009j513265d6y3a76b717d2369533@mail.gmail.com> Why am I now getting these errors? expected redirect to {:action=>"index"}, got redirect to "http://test.host/authenticated_users" I know in the AuthenticatedUsersController, the redirect call is redirect_to :action => 'index' So why should I have to convert this to a url in my specs? From cowboysolitude at gmail.com Thu May 3 13:29:42 2007 From: cowboysolitude at gmail.com (J.D. Hollis) Date: Thu, 3 May 2007 13:29:42 -0400 Subject: [rspec-users] unexpected failures with --reverse Message-ID: Actually, nevermind. Figured it out. It seems that ActiveRecord is lazy in creating readers for model attributes, waiting until the attribute is accessed, so the mocking framework had no way to alias :date because it didn't exist as a method yet. Adding '@bill.date' to the before block seems to have resolved the issue. From cwdinfo at gmail.com Thu May 3 13:37:12 2007 From: cwdinfo at gmail.com (s.ross) Date: Thu, 3 May 2007 10:37:12 -0700 Subject: [rspec-users] rSpec on CruiseControl.rb In-Reply-To: <27c0ac6d0705030945l6fb816d8m7ad305717e2eb49d@mail.gmail.com> References: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> <27c0ac6d0705030945l6fb816d8m7ad305717e2eb49d@mail.gmail.com> Message-ID: It's Rails. I'm running the plugin version of rSpec but using cc invokes the gem version giving me a version mismatch. Any thoughts? Thx On May 3, 2007, at 9:45 AM, Matthijs Langenberg wrote: > I didn't have any troubles to get it working at all, I just created a > Rakefile with a custom 'cruise' task: > > require 'rake' > require 'spec/rake/spectask' > > task :cruise do > Rake::Task["spec"].invoke > end > > Spec::Rake::SpecTask.new do |t| > t.spec_opts = ['-f s'] > t.spec_files = 'SMSer_spec.rb' > end > > What problems are you running into, or are you talking about a > Rails project? > > On 5/3/07, s. ross wrote: >> Has anyone gotten CC to use rSpec as a builder? There was some >> comment on their list about this in February, but I wondered if >> anyone here is using CC (or is there some other ci tool that might be >> more suitable)? >> >> Thx >> _______________________________________________ >> 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 Thu May 3 13:57:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 May 2007 12:57:17 -0500 Subject: [rspec-users] 0.9.2 redirect_to no longer accepts hash? In-Reply-To: <63c5d3820705031009j513265d6y3a76b717d2369533@mail.gmail.com> References: <63c5d3820705031009j513265d6y3a76b717d2369533@mail.gmail.com> Message-ID: <57c63afe0705031057j1caca67awb4570df7311092da@mail.gmail.com> What is the spec that is failing? On 5/3/07, Chris Hoffman wrote: > Why am I now getting these errors? > > expected redirect to {:action=>"index"}, got redirect to > "http://test.host/authenticated_users" > > I know in the AuthenticatedUsersController, the redirect call is > > redirect_to :action => 'index' > > So why should I have to convert this to a url in my specs? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Thu May 3 14:30:25 2007 From: cwdinfo at gmail.com (s.ross) Date: Thu, 3 May 2007 11:30:25 -0700 Subject: [rspec-users] rSpec on CruiseControl.rb In-Reply-To: <27c0ac6d0705030945l6fb816d8m7ad305717e2eb49d@mail.gmail.com> References: <57c63afe0705022208v8772a17h6f8c5cb73d97370e@mail.gmail.com> <6586e070705022346n194182d6i479e1f4cc0a0bb7d@mail.gmail.com> <27c0ac6d0705030945l6fb816d8m7ad305717e2eb49d@mail.gmail.com> Message-ID: <1988E5FC-7374-49DA-B892-2A2D778E4E0A@gmail.com> I'll answer my own question. This seems to work ok: require File.join(RAILS_ROOT, '/vendor/plugins/rspec/lib/spec/rake/ spectask') task :cruise do Rake::Task["cruise_spec"].invoke end Spec::Rake::SpecTask.new(:cruise_spec) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['spec/**/*_spec.rb'] end The formatting isn't great, but it succeeds when it should and fails when a bad checkin is made. On May 3, 2007, at 9:45 AM, Matthijs Langenberg wrote: > I didn't have any troubles to get it working at all, I just created a > Rakefile with a custom 'cruise' task: > > require 'rake' > require 'spec/rake/spectask' > > task :cruise do > Rake::Task["spec"].invoke > end > > Spec::Rake::SpecTask.new do |t| > t.spec_opts = ['-f s'] > t.spec_files = 'SMSer_spec.rb' > end > > What problems are you running into, or are you talking about a > Rails project? > > On 5/3/07, s. ross wrote: >> Has anyone gotten CC to use rSpec as a builder? There was some >> comment on their list about this in February, but I wondered if >> anyone here is using CC (or is there some other ci tool that might be >> more suitable)? >> >> Thx >> _______________________________________________ >> 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 chris.c.hoffman at gmail.com Thu May 3 15:08:32 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Thu, 3 May 2007 15:08:32 -0400 Subject: [rspec-users] 0.9.2 redirect_to no longer accepts hash? In-Reply-To: <57c63afe0705031057j1caca67awb4570df7311092da@mail.gmail.com> References: <63c5d3820705031009j513265d6y3a76b717d2369533@mail.gmail.com> <57c63afe0705031057j1caca67awb4570df7311092da@mail.gmail.com> Message-ID: <63c5d3820705031208p5fc7d42dkb003690c45a80985@mail.gmail.com> Hi David, I'm sorry, I didn't set up my specs correctly again. It has just been difficult sorting through what was caused by the translator (I'm still migrating to 0.9.x) versus what I'm actually doing wrong. Sorry for my confused rant. -Chris On 5/3/07, David Chelimsky wrote: > What is the spec that is failing? > > On 5/3/07, Chris Hoffman wrote: > > Why am I now getting these errors? > > > > expected redirect to {:action=>"index"}, got redirect to > > "http://test.host/authenticated_users" > > > > I know in the AuthenticatedUsersController, the redirect call is > > > > redirect_to :action => 'index' > > > > So why should I have to convert this to a url in my specs? > > _______________________________________________ > > 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 Thu May 3 15:11:56 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 May 2007 14:11:56 -0500 Subject: [rspec-users] 0.9.2 redirect_to no longer accepts hash? In-Reply-To: <63c5d3820705031208p5fc7d42dkb003690c45a80985@mail.gmail.com> References: <63c5d3820705031009j513265d6y3a76b717d2369533@mail.gmail.com> <57c63afe0705031057j1caca67awb4570df7311092da@mail.gmail.com> <63c5d3820705031208p5fc7d42dkb003690c45a80985@mail.gmail.com> Message-ID: <57c63afe0705031211y1225e363yd2d73af3fea7b197@mail.gmail.com> On 5/3/07, Chris Hoffman wrote: > Hi David, > I'm sorry, I didn't set up my specs correctly again. It has just > been difficult sorting through what was caused by the translator (I'm > still migrating to 0.9.x) versus what I'm actually doing wrong. Sorry > for my confused rant. No worries. The translator isn't perfect (that would have cost too much!) - so keep letting us know if we can help. Cheers, David > > -Chris > > On 5/3/07, David Chelimsky wrote: > > What is the spec that is failing? > > > > On 5/3/07, Chris Hoffman wrote: > > > Why am I now getting these errors? > > > > > > expected redirect to {:action=>"index"}, got redirect to > > > "http://test.host/authenticated_users" > > > > > > I know in the AuthenticatedUsersController, the redirect call is > > > > > > redirect_to :action => 'index' > > > > > > So why should I have to convert this to a url in my specs? > > > _______________________________________________ > > > 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 brian.takita at gmail.com Thu May 3 15:43:36 2007 From: brian.takita at gmail.com (Brian Takita) Date: Thu, 3 May 2007 12:43:36 -0700 Subject: [rspec-users] [rspec-devel] [ANN] RSpec 0.9.2 In-Reply-To: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> References: <8d961d900705030111q60a9f50cu4918f31502a45a54@mail.gmail.com> Message-ID: <1d7ddd110705031243r763c6d6dnb014b40a8e75ddcb@mail.gmail.com> Mmmm. Breadcrumbs! On 5/3/07, aslak hellesoy wrote: > > Behind every great release is a maintenance release. > Go get it while it's hot. > > We've also reworked the website a little - trying to scare off fewer > people. > > Aslak > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070503/0499cf43/attachment.html From marcus at ahnve.com Fri May 4 07:18:06 2007 From: marcus at ahnve.com (Marcus Ahnve) Date: Fri, 4 May 2007 13:18:06 +0200 Subject: [rspec-users] Capistrano and RSpec Message-ID: <4d4e79cc0705040418m75e2d72cr8346c6a2429de3ea@mail.gmail.com> I use Capistrano for deployment, and for reasons unknown to me, "cap migrate" requires the RSpec rake file. As RSpec is only loaded in the test environment, the migration fails. This may be a Capistrano question, but I figured I start here to see if anyone else has had the same problem. Cheers /Marcus -- http://marcus.ahnve.net From chris.c.hoffman at gmail.com Fri May 4 11:25:03 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 4 May 2007 11:25:03 -0400 Subject: [rspec-users] spec template for CRUD? Message-ID: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> Hello, Has anyone already come up with a set of shared behaviours that someone could leverage when adhering to a CRUD concept, with respect to controllers? Relatedly, it would be nice if there were a way to share generalized behaviour specs. -Chris From dchelimsky at gmail.com Fri May 4 11:33:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 10:33:05 -0500 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> Message-ID: <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> On 5/4/07, Chris Hoffman wrote: > Hello, > > Has anyone already come up with a set of shared behaviours that > someone could leverage when adhering to a CRUD concept, with respect > to controllers? > > Relatedly, it would be nice if there were a way to share generalized > behaviour specs. Shared behaviours already allow you to do this, unless I'm missing your meaning. What is it that you're looking for that shared behaviours as/is doesn't cover? > > -Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris.c.hoffman at gmail.com Fri May 4 11:37:52 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 4 May 2007 11:37:52 -0400 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> Message-ID: <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> Oh there is nothing wrong with the code, I just wonder if anyone has actually taken it further and implemented the behaviours required to exercise the CRUD operations in controllers (e.g., #show, #new, #edit, etc.). And as to sharing, I mean in a colloquial way, as in collaboration. -Chris On 5/4/07, David Chelimsky wrote: > On 5/4/07, Chris Hoffman wrote: > > Hello, > > > > Has anyone already come up with a set of shared behaviours that > > someone could leverage when adhering to a CRUD concept, with respect > > to controllers? > > > > Relatedly, it would be nice if there were a way to share generalized > > behaviour specs. > > Shared behaviours already allow you to do this, unless I'm missing > your meaning. What is it that you're looking for that shared > behaviours as/is doesn't cover? > > > > > -Chris > > _______________________________________________ > > 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 May 4 11:51:28 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 10:51:28 -0500 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> Message-ID: <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> On 5/4/07, Chris Hoffman wrote: > Oh there is nothing wrong with the code, I just wonder if anyone has > actually taken it further and implemented the behaviours required to > exercise the CRUD operations in controllers (e.g., #show, #new, #edit, > etc.). I understood that part - that you wanted to see if someone had tackled the problem. > > And as to sharing, I mean in a colloquial way, as in collaboration. This was the part I was talking about, and now I get it. Besides posting code on blogs, what would you propose to better enable this so that anybody who wants to contribute can, but everyone keeps control over their own contributions? Cheers, David > > -Chris > > On 5/4/07, David Chelimsky wrote: > > On 5/4/07, Chris Hoffman wrote: > > > Hello, > > > > > > Has anyone already come up with a set of shared behaviours that > > > someone could leverage when adhering to a CRUD concept, with respect > > > to controllers? > > > > > > Relatedly, it would be nice if there were a way to share generalized > > > behaviour specs. > > > > Shared behaviours already allow you to do this, unless I'm missing > > your meaning. What is it that you're looking for that shared > > behaviours as/is doesn't cover? > > > > > > > > -Chris > > > _______________________________________________ > > > 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 chris.c.hoffman at gmail.com Fri May 4 12:01:10 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 4 May 2007 12:01:10 -0400 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> Message-ID: <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> Well, I guess posting code on blogs is fine, as long as there is a centralized way of accessing this code. Perhaps some kind of aggregator would suffice? I don't know if sites like technorati or del.icio.us can help in this respect. My initial thought was a wiki, but if you think people will want to control their own contributions, than obviously this is a poor idea. -Chris On 5/4/07, David Chelimsky wrote: > On 5/4/07, Chris Hoffman wrote: > > Oh there is nothing wrong with the code, I just wonder if anyone has > > actually taken it further and implemented the behaviours required to > > exercise the CRUD operations in controllers (e.g., #show, #new, #edit, > > etc.). > > I understood that part - that you wanted to see if someone had tackled > the problem. > > > > > And as to sharing, I mean in a colloquial way, as in collaboration. > > This was the part I was talking about, and now I get it. Besides > posting code on blogs, what would you propose to better enable this so > that anybody who wants to contribute can, but everyone keeps control > over their own contributions? > > Cheers, > David > > > > > -Chris > > > > On 5/4/07, David Chelimsky wrote: > > > On 5/4/07, Chris Hoffman wrote: > > > > Hello, > > > > > > > > Has anyone already come up with a set of shared behaviours that > > > > someone could leverage when adhering to a CRUD concept, with respect > > > > to controllers? > > > > > > > > Relatedly, it would be nice if there were a way to share generalized > > > > behaviour specs. > > > > > > Shared behaviours already allow you to do this, unless I'm missing > > > your meaning. What is it that you're looking for that shared > > > behaviours as/is doesn't cover? > > > > > > > > > > > -Chris > > > > _______________________________________________ > > > > 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 chris.c.hoffman at gmail.com Fri May 4 15:17:08 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 4 May 2007 15:17:08 -0400 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> Message-ID: <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> Hello, So, here is my first stab at generalized CRUD behaviours. I would appreciate your thoughts on my approach. Be gentle :) describe "RUD", :shared => true do before(:each) do @model = @controller_class.to_s.sub(/Controller$/,'').singularize.constantize @obj = mock_model(@model) end it "should populate the object related to the model when given a valid id" do @model.should_receive(:find_by_id).with('1').and_return(@obj) get @action, :id => 1 assigns[@model.to_s.underscore].should be(@obj) end it "should redirect_to #index when given an invalid id" do @model.should_receive(:find_by_id) get @action response.should redirect_to(:action => 'index') end it "should populate the flash with a message indicating that the record wasn't found, when given an invalid id" do @model.should_receive(:find_by_id) process @action flash[:notice].should == "#{@model} not found" end end describe "R", :shared => true do it "should render the appropriate template when given a valid id" do @model.should_receive(:find_by_id).and_return(@obj) get @action response.should render_template(@action) end it_should_behave_like "RUD" end describe "show", :shared => true do before(:each) do @action = "show" end it_should_behave_like "R" end On 5/4/07, Chris Hoffman wrote: > Well, I guess posting code on blogs is fine, as long as there is a > centralized way of accessing this code. Perhaps some kind of > aggregator would suffice? I don't know if sites like technorati or > del.icio.us can help in this respect. > > My initial thought was a wiki, but if you think people will want to > control their own contributions, than obviously this is a poor idea. > > -Chris > > On 5/4/07, David Chelimsky wrote: > > On 5/4/07, Chris Hoffman wrote: > > > Oh there is nothing wrong with the code, I just wonder if anyone has > > > actually taken it further and implemented the behaviours required to > > > exercise the CRUD operations in controllers (e.g., #show, #new, #edit, > > > etc.). > > > > I understood that part - that you wanted to see if someone had tackled > > the problem. > > > > > > > > And as to sharing, I mean in a colloquial way, as in collaboration. > > > > This was the part I was talking about, and now I get it. Besides > > posting code on blogs, what would you propose to better enable this so > > that anybody who wants to contribute can, but everyone keeps control > > over their own contributions? > > > > Cheers, > > David > > > > > > > > -Chris > > > > > > On 5/4/07, David Chelimsky wrote: > > > > On 5/4/07, Chris Hoffman wrote: > > > > > Hello, > > > > > > > > > > Has anyone already come up with a set of shared behaviours that > > > > > someone could leverage when adhering to a CRUD concept, with respect > > > > > to controllers? > > > > > > > > > > Relatedly, it would be nice if there were a way to share generalized > > > > > behaviour specs. > > > > > > > > Shared behaviours already allow you to do this, unless I'm missing > > > > your meaning. What is it that you're looking for that shared > > > > behaviours as/is doesn't cover? > > > > > > > > > > > > > > -Chris > > > > > _______________________________________________ > > > > > 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 luislavena at gmail.com Fri May 4 18:47:21 2007 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 4 May 2007 19:47:21 -0300 Subject: [rspec-users] Custom Matcher and NAME NOT GENERATED annoyance Message-ID: <71166b3b0705041547o4aa18fbeu9990566106885408@mail.gmail.com> Hello RSpec users, Have been using RSpec since 0.8.2 (not too long ago, I must say). and been creating my custom matchers since was defined as "good practice". Also, auto-generated names for the examples is very helpful, I'm trying to take advantage of it. Since I often prior code/define all the "examples", I have created a few matchers to fulfill associations and validations of attributes. Example: describe "A User (in general)" do before(:each) do @user = User.new end it { @user.should have_many(:contest_public_votes) } it { @user.should have_many(:design_industry_user_interests) } it { @user.should have_one(:user_extension) } end That creates the following descriptions: A User (in general) - should has_many contest_public_votes - should has_many design_industry_user_interests - should has_one user_extension A new User - should not be valid without first_name - should not be valid without last_name - should not be valid without login - should not be valid without email - should not be valid without password - should not be valid without password_confirmation - should not be valid without city - should not be valid without postal_code - should not be valid without country - should not be valid with duplicate login - should not be valid with duplicate email (I omitted the second description). Anyway, the problem started with latest release, which if someone my matcher shows a problem, NAME NOT GENERATED was put in the description instead of my fancy, nicely done name ;-) Attached I have included a faulty matcher that shows the issue. If someone could point me in the right direction to patch rspec, I'll really apreciate. Is not critical, but is a bit "disturbing" during the matchers creation process ;-) Regards and thanks in advance, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi -------------- next part -------------- A non-text attachment was scrubbed... Name: matcher_spec.rb Type: application/octet-stream Size: 980 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070504/11cc961f/attachment.obj From aslak.hellesoy at gmail.com Fri May 4 19:30:40 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 5 May 2007 01:30:40 +0200 Subject: [rspec-users] Custom Matcher and NAME NOT GENERATED annoyance In-Reply-To: <71166b3b0705041547o4aa18fbeu9990566106885408@mail.gmail.com> References: <71166b3b0705041547o4aa18fbeu9990566106885408@mail.gmail.com> Message-ID: <8d961d900705041630l7e689539ud0cf634b6b8848a6@mail.gmail.com> This is a bug in RSpec. Could you file a bug report (for the record) while I'm fixing it please? Aslak On 5/5/07, Luis Lavena wrote: > Hello RSpec users, > > Have been using RSpec since 0.8.2 (not too long ago, I must say). and > been creating my custom matchers since was defined as "good practice". > > Also, auto-generated names for the examples is very helpful, I'm > trying to take advantage of it. > > Since I often prior code/define all the "examples", I have created a > few matchers to fulfill associations and validations of attributes. > Example: > > describe "A User (in general)" do > before(:each) do > @user = User.new > end > > it { @user.should have_many(:contest_public_votes) } > it { @user.should have_many(:design_industry_user_interests) } > it { @user.should have_one(:user_extension) } > end > > That creates the following descriptions: > > A User (in general) > - should has_many contest_public_votes > - should has_many design_industry_user_interests > - should has_one user_extension > > A new User > - should not be valid without first_name > - should not be valid without last_name > - should not be valid without login > - should not be valid without email > - should not be valid without password > - should not be valid without password_confirmation > - should not be valid without city > - should not be valid without postal_code > - should not be valid without country > - should not be valid with duplicate login > - should not be valid with duplicate email > > (I omitted the second description). > > Anyway, the problem started with latest release, which if someone my > matcher shows a problem, NAME NOT GENERATED was put in the description > instead of my fancy, nicely done name ;-) > > Attached I have included a faulty matcher that shows the issue. > > If someone could point me in the right direction to patch rspec, I'll > really apreciate. > > Is not critical, but is a bit "disturbing" during the matchers > creation process ;-) > > Regards and thanks in advance, > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From luislavena at gmail.com Fri May 4 19:35:42 2007 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 4 May 2007 20:35:42 -0300 Subject: [rspec-users] Custom Matcher and NAME NOT GENERATED annoyance In-Reply-To: <8d961d900705041630l7e689539ud0cf634b6b8848a6@mail.gmail.com> References: <71166b3b0705041547o4aa18fbeu9990566106885408@mail.gmail.com> <8d961d900705041630l7e689539ud0cf634b6b8848a6@mail.gmail.com> Message-ID: <71166b3b0705041635m32cfe267te306464271d47cd9@mail.gmail.com> On 5/4/07, aslak hellesoy wrote: > This is a bug in RSpec. Could you file a bug report (for the record) > while I'm fixing it please? > > Aslak > Filled :-) [#10594] Failing Custom Matcher show NAME NOT GENERATED description http://rubyforge.org/tracker/index.php?func=detail&aid=10594&group_id=797&atid=3149 Thank you Aslak for the quick reply. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From jeff at jefdean.com Fri May 4 21:18:23 2007 From: jeff at jefdean.com (Jeff Dean) Date: Fri, 4 May 2007 21:18:23 -0400 Subject: [rspec-users] Translating tests Message-ID: <6586e070705041818m3d60ac0ci55ce72de138319c3@mail.gmail.com> Is test2spec still around? If so, are there any special instructions for running it against edge? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070504/bb164e29/attachment.html From crafterm at gmail.com Fri May 4 22:35:50 2007 From: crafterm at gmail.com (Marcus Crafter) Date: Sat, 5 May 2007 12:35:50 +1000 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> Message-ID: <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> Hi Chris, Looks good mate. Is there also a way of being able to get the name of the controller or some other variables into the 'it' strings to make the verbalisations read well for shared specs? like: it "should assign #{@model.to_s.underscore} for the view....." do ... end and so on, I tried the above, but no go yet. Cheers, Marcus On 05/05/2007, at 5:17 AM, Chris Hoffman wrote: > Hello, > > So, here is my first stab at generalized CRUD behaviours. I would > appreciate your thoughts on my approach. Be gentle :) > > describe "RUD", :shared => true do > before(:each) do > @model = @controller_class.to_s.sub(/Controller > $/,'').singularize.constantize > @obj = mock_model(@model) > end > > it "should populate the object related to the model when given a > valid id" do > @model.should_receive(:find_by_id).with('1').and_return(@obj) > get @action, :id => 1 > assigns[@model.to_s.underscore].should be(@obj) > end > > it "should redirect_to #index when given an invalid id" do > @model.should_receive(:find_by_id) > get @action > response.should redirect_to(:action => 'index') > end > > it "should populate the flash with a message indicating that the > record wasn't found, when given an invalid id" do > @model.should_receive(:find_by_id) > process @action > flash[:notice].should == "#{@model} not found" > end > end > > describe "R", :shared => true do > it "should render the appropriate template when given a valid id" do > @model.should_receive(:find_by_id).and_return(@obj) > get @action > response.should render_template(@action) > end > > it_should_behave_like "RUD" > end > > describe "show", :shared => true do > before(:each) do > @action = "show" > end > > it_should_behave_like "R" > end > > On 5/4/07, Chris Hoffman wrote: >> Well, I guess posting code on blogs is fine, as long as there is a >> centralized way of accessing this code. Perhaps some kind of >> aggregator would suffice? I don't know if sites like technorati or >> del.icio.us can help in this respect. >> >> My initial thought was a wiki, but if you think people will want to >> control their own contributions, than obviously this is a poor idea. >> >> -Chris >> >> On 5/4/07, David Chelimsky wrote: >>> On 5/4/07, Chris Hoffman wrote: >>>> Oh there is nothing wrong with the code, I just wonder if anyone >>>> has >>>> actually taken it further and implemented the behaviours >>>> required to >>>> exercise the CRUD operations in controllers (e.g., #show, #new, >>>> #edit, >>>> etc.). >>> >>> I understood that part - that you wanted to see if someone had >>> tackled >>> the problem. >>> >>>> >>>> And as to sharing, I mean in a colloquial way, as in collaboration. >>> >>> This was the part I was talking about, and now I get it. Besides >>> posting code on blogs, what would you propose to better enable >>> this so >>> that anybody who wants to contribute can, but everyone keeps control >>> over their own contributions? >>> >>> Cheers, >>> David >>> >>>> >>>> -Chris >>>> >>>> On 5/4/07, David Chelimsky wrote: >>>>> On 5/4/07, Chris Hoffman wrote: >>>>>> Hello, >>>>>> >>>>>> Has anyone already come up with a set of shared behaviours that >>>>>> someone could leverage when adhering to a CRUD concept, with >>>>>> respect >>>>>> to controllers? >>>>>> >>>>>> Relatedly, it would be nice if there were a way to share >>>>>> generalized >>>>>> behaviour specs. >>>>> >>>>> Shared behaviours already allow you to do this, unless I'm missing >>>>> your meaning. What is it that you're looking for that shared >>>>> behaviours as/is doesn't cover? >>>>> >>>>>> >>>>>> -Chris >>>>>> _______________________________________________ >>>>>> 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 From dchelimsky at gmail.com Fri May 4 22:57:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 21:57:45 -0500 Subject: [rspec-users] autogenerated it (was 'Custom Matcher and NAME NOT GENERATED annoyance') Message-ID: <57c63afe0705041957s326b29d1ob6129d0aad57f826@mail.gmail.com> > On 5/5/07, Luis Lavena wrote: > > describe "A User (in general)" do > > before(:each) do > > @user = User.new > > end > > > > it { @user.should have_many(:contest_public_votes) } > > it { @user.should have_many(:design_industry_user_interests) } > > it { @user.should have_one(:user_extension) } > > end > > When I've used the autogenerated names, I've used specify: specify { @user.should have_many(:contest_public_votes) } specify { @user.should have_many(:design_industry_user_interests) } specify { @user.should have_one(:user_extension) } That reads better than 'it' in my view, but I'm not happy w/ 'specify' either. What other words would make sense in this situation? One thing that occurs to me in this particular example is 'the': describe User do the { @user.should have_many(:contest_public_votes) } the { @user.should have_many(:design_industry_user_interests) } the { @user.should have_one(:user_extension) } But I don't know if that would work that often. Other ideas? David From dchelimsky at gmail.com Fri May 4 22:58:08 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 21:58:08 -0500 Subject: [rspec-users] Translating tests In-Reply-To: <6586e070705041818m3d60ac0ci55ce72de138319c3@mail.gmail.com> References: <6586e070705041818m3d60ac0ci55ce72de138319c3@mail.gmail.com> Message-ID: <57c63afe0705041958x3997ee68oa6f24691f7be007f@mail.gmail.com> On 5/4/07, Jeff Dean wrote: > Is test2spec still around? If so, are there any special instructions for > running it against edge? That died months and months ago. Sorry. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri May 4 22:59:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 21:59:33 -0500 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> Message-ID: <57c63afe0705041959l2e2a174ep7be39dc93c7f2b1d@mail.gmail.com> On 5/4/07, Marcus Crafter wrote: > Hi Chris, > > Looks good mate. Is there also a way of being able to get the name of > the controller or some other variables into the 'it' strings to make > the verbalisations read well for shared specs? > > like: > > it "should assign #{@model.to_s.underscore} for the view....." do How about ... it "should assign #{@model.humanize} for the view....." do > ... > end > > and so on, I tried the above, but no go yet. > > Cheers, > > Marcus > > > On 05/05/2007, at 5:17 AM, Chris Hoffman wrote: > > > Hello, > > > > So, here is my first stab at generalized CRUD behaviours. I would > > appreciate your thoughts on my approach. Be gentle :) > > > > describe "RUD", :shared => true do > > before(:each) do > > @model = @controller_class.to_s.sub(/Controller > > $/,'').singularize.constantize > > @obj = mock_model(@model) > > end > > > > it "should populate the object related to the model when given a > > valid id" do > > @model.should_receive(:find_by_id).with('1').and_return(@obj) > > get @action, :id => 1 > > assigns[@model.to_s.underscore].should be(@obj) > > end > > > > it "should redirect_to #index when given an invalid id" do > > @model.should_receive(:find_by_id) > > get @action > > response.should redirect_to(:action => 'index') > > end > > > > it "should populate the flash with a message indicating that the > > record wasn't found, when given an invalid id" do > > @model.should_receive(:find_by_id) > > process @action > > flash[:notice].should == "#{@model} not found" > > end > > end > > > > describe "R", :shared => true do > > it "should render the appropriate template when given a valid id" do > > @model.should_receive(:find_by_id).and_return(@obj) > > get @action > > response.should render_template(@action) > > end > > > > it_should_behave_like "RUD" > > end > > > > describe "show", :shared => true do > > before(:each) do > > @action = "show" > > end > > > > it_should_behave_like "R" > > end > > > > On 5/4/07, Chris Hoffman wrote: > >> Well, I guess posting code on blogs is fine, as long as there is a > >> centralized way of accessing this code. Perhaps some kind of > >> aggregator would suffice? I don't know if sites like technorati or > >> del.icio.us can help in this respect. > >> > >> My initial thought was a wiki, but if you think people will want to > >> control their own contributions, than obviously this is a poor idea. > >> > >> -Chris > >> > >> On 5/4/07, David Chelimsky wrote: > >>> On 5/4/07, Chris Hoffman wrote: > >>>> Oh there is nothing wrong with the code, I just wonder if anyone > >>>> has > >>>> actually taken it further and implemented the behaviours > >>>> required to > >>>> exercise the CRUD operations in controllers (e.g., #show, #new, > >>>> #edit, > >>>> etc.). > >>> > >>> I understood that part - that you wanted to see if someone had > >>> tackled > >>> the problem. > >>> > >>>> > >>>> And as to sharing, I mean in a colloquial way, as in collaboration. > >>> > >>> This was the part I was talking about, and now I get it. Besides > >>> posting code on blogs, what would you propose to better enable > >>> this so > >>> that anybody who wants to contribute can, but everyone keeps control > >>> over their own contributions? > >>> > >>> Cheers, > >>> David > >>> > >>>> > >>>> -Chris > >>>> > >>>> On 5/4/07, David Chelimsky wrote: > >>>>> On 5/4/07, Chris Hoffman wrote: > >>>>>> Hello, > >>>>>> > >>>>>> Has anyone already come up with a set of shared behaviours that > >>>>>> someone could leverage when adhering to a CRUD concept, with > >>>>>> respect > >>>>>> to controllers? > >>>>>> > >>>>>> Relatedly, it would be nice if there were a way to share > >>>>>> generalized > >>>>>> behaviour specs. > >>>>> > >>>>> Shared behaviours already allow you to do this, unless I'm missing > >>>>> your meaning. What is it that you're looking for that shared > >>>>> behaviours as/is doesn't cover? > >>>>> > >>>>>> > >>>>>> -Chris > >>>>>> _______________________________________________ > >>>>>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris.c.hoffman at gmail.com Fri May 4 23:01:02 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 4 May 2007 23:01:02 -0400 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> Message-ID: <63c5d3820705042001q2c54cd97y18bf7bc127ea06ef@mail.gmail.com> Hi Marcus, I couldn't get variables into the descriptions, as they seem to get compiled (for lack of a better word) and are immutable when executed by other methods (via the 'it_should_behave_like' method call). Perhaps someone that has more experience with this code base could figure something out. I'm also wondering if I am reinventing the wheel. Since DHH's "World of Resources" talk, I have been out of the loop as far as the push towards CRUDy architecture. I wonder if something has already been done to address this repetition in Test:Unit, which could be translated to RSpec. It's really too bad that RSpec isn't the default "testing" framework in Rails. Anyway, enough preaching to the choir. -Chris On 5/4/07, Marcus Crafter wrote: > Hi Chris, > > Looks good mate. Is there also a way of being able to get the name of > the controller or some other variables into the 'it' strings to make > the verbalisations read well for shared specs? > > like: > > it "should assign #{@model.to_s.underscore} for the view....." do > ... > end > > and so on, I tried the above, but no go yet. > > Cheers, > > Marcus > > > On 05/05/2007, at 5:17 AM, Chris Hoffman wrote: > > > Hello, > > > > So, here is my first stab at generalized CRUD behaviours. I would > > appreciate your thoughts on my approach. Be gentle :) > > > > describe "RUD", :shared => true do > > before(:each) do > > @model = @controller_class.to_s.sub(/Controller > > $/,'').singularize.constantize > > @obj = mock_model(@model) > > end > > > > it "should populate the object related to the model when given a > > valid id" do > > @model.should_receive(:find_by_id).with('1').and_return(@obj) > > get @action, :id => 1 > > assigns[@model.to_s.underscore].should be(@obj) > > end > > > > it "should redirect_to #index when given an invalid id" do > > @model.should_receive(:find_by_id) > > get @action > > response.should redirect_to(:action => 'index') > > end > > > > it "should populate the flash with a message indicating that the > > record wasn't found, when given an invalid id" do > > @model.should_receive(:find_by_id) > > process @action > > flash[:notice].should == "#{@model} not found" > > end > > end > > > > describe "R", :shared => true do > > it "should render the appropriate template when given a valid id" do > > @model.should_receive(:find_by_id).and_return(@obj) > > get @action > > response.should render_template(@action) > > end > > > > it_should_behave_like "RUD" > > end > > > > describe "show", :shared => true do > > before(:each) do > > @action = "show" > > end > > > > it_should_behave_like "R" > > end > > > > On 5/4/07, Chris Hoffman wrote: > >> Well, I guess posting code on blogs is fine, as long as there is a > >> centralized way of accessing this code. Perhaps some kind of > >> aggregator would suffice? I don't know if sites like technorati or > >> del.icio.us can help in this respect. > >> > >> My initial thought was a wiki, but if you think people will want to > >> control their own contributions, than obviously this is a poor idea. > >> > >> -Chris > >> > >> On 5/4/07, David Chelimsky wrote: > >>> On 5/4/07, Chris Hoffman wrote: > >>>> Oh there is nothing wrong with the code, I just wonder if anyone > >>>> has > >>>> actually taken it further and implemented the behaviours > >>>> required to > >>>> exercise the CRUD operations in controllers (e.g., #show, #new, > >>>> #edit, > >>>> etc.). > >>> > >>> I understood that part - that you wanted to see if someone had > >>> tackled > >>> the problem. > >>> > >>>> > >>>> And as to sharing, I mean in a colloquial way, as in collaboration. > >>> > >>> This was the part I was talking about, and now I get it. Besides > >>> posting code on blogs, what would you propose to better enable > >>> this so > >>> that anybody who wants to contribute can, but everyone keeps control > >>> over their own contributions? > >>> > >>> Cheers, > >>> David > >>> > >>>> > >>>> -Chris > >>>> > >>>> On 5/4/07, David Chelimsky wrote: > >>>>> On 5/4/07, Chris Hoffman wrote: > >>>>>> Hello, > >>>>>> > >>>>>> Has anyone already come up with a set of shared behaviours that > >>>>>> someone could leverage when adhering to a CRUD concept, with > >>>>>> respect > >>>>>> to controllers? > >>>>>> > >>>>>> Relatedly, it would be nice if there were a way to share > >>>>>> generalized > >>>>>> behaviour specs. > >>>>> > >>>>> Shared behaviours already allow you to do this, unless I'm missing > >>>>> your meaning. What is it that you're looking for that shared > >>>>> behaviours as/is doesn't cover? > >>>>> > >>>>>> > >>>>>> -Chris > >>>>>> _______________________________________________ > >>>>>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Fri May 4 23:03:27 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 5 May 2007 00:03:27 -0300 Subject: [rspec-users] autogenerated it (was 'Custom Matcher and NAME NOT GENERATED annoyance') In-Reply-To: <57c63afe0705041957s326b29d1ob6129d0aad57f826@mail.gmail.com> References: <57c63afe0705041957s326b29d1ob6129d0aad57f826@mail.gmail.com> Message-ID: <71166b3b0705042003k29bc763fnb36d533023237c52@mail.gmail.com> On 5/4/07, David Chelimsky wrote: > > On 5/5/07, Luis Lavena wrote: > > > describe "A User (in general)" do > > > before(:each) do > > > @user = User.new > > > end > > > > > > it { @user.should have_many(:contest_public_votes) } > > > it { @user.should have_many(:design_industry_user_interests) } > > > it { @user.should have_one(:user_extension) } > > > end > > > > > When I've used the autogenerated names, I've used specify: > > specify { @user.should have_many(:contest_public_votes) } > specify { @user.should have_many(:design_industry_user_interests) } > specify { @user.should have_one(:user_extension) } > > That reads better than 'it' in my view, but I'm not happy w/ 'specify' > either. What other words would make sense in this situation? One thing > that occurs to me in this particular example is 'the': > > describe User do > the { @user.should have_many(:contest_public_votes) } > the { @user.should have_many(:design_industry_user_interests) } > the { @user.should have_one(:user_extension) } > > But I don't know if that would work that often. > > Other ideas? > David, 'the' is a good term to describe it, but there aren't too many cases (er, examples) that could use that alias of it. I only see use for one expectation, auto-generated ones. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Fri May 4 23:08:41 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 22:08:41 -0500 Subject: [rspec-users] autogenerated it (was 'Custom Matcher and NAME NOT GENERATED annoyance') In-Reply-To: <71166b3b0705042003k29bc763fnb36d533023237c52@mail.gmail.com> References: <57c63afe0705041957s326b29d1ob6129d0aad57f826@mail.gmail.com> <71166b3b0705042003k29bc763fnb36d533023237c52@mail.gmail.com> Message-ID: <57c63afe0705042008h54c44f3dq6ee9bfa86a522c74@mail.gmail.com> On 5/4/07, Luis Lavena wrote: > On 5/4/07, David Chelimsky wrote: > > > On 5/5/07, Luis Lavena wrote: > > > > describe "A User (in general)" do > > > > before(:each) do > > > > @user = User.new > > > > end > > > > > > > > it { @user.should have_many(:contest_public_votes) } > > > > it { @user.should have_many(:design_industry_user_interests) } > > > > it { @user.should have_one(:user_extension) } > > > > end > > > > > > > > When I've used the autogenerated names, I've used specify: > > > > specify { @user.should have_many(:contest_public_votes) } > > specify { @user.should have_many(:design_industry_user_interests) } > > specify { @user.should have_one(:user_extension) } > > > > That reads better than 'it' in my view, but I'm not happy w/ 'specify' > > either. What other words would make sense in this situation? One thing > > that occurs to me in this particular example is 'the': > > > > describe User do > > the { @user.should have_many(:contest_public_votes) } > > the { @user.should have_many(:design_industry_user_interests) } > > the { @user.should have_one(:user_extension) } > > > > But I don't know if that would work that often. > > > > Other ideas? > > > > David, > > 'the' is a good term to describe it, but there aren't too many cases > (er, examples) that could use that alias of it. > > I only see use for one expectation, auto-generated ones. That's what I'm talking about. In other words, "it" definitely works for non-auto-generated names: describe Thing do it "should do stuff" do I'm specifically looking for an alias that works well for auto-generated names, so if "the" only works well in that situation I'm OK w/ that. The thing I'm wondering is whether "the" would work for the majority of auto-generated-name examples, and whether it pushes you psychologically towards a certain type of example. It makes sense when you say: describe Thing do the { @thing.should do_something } or..... describe Thing do a { @thing.should do_something } But what other shapes do we need to consider? > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Fri May 4 23:22:01 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 5 May 2007 00:22:01 -0300 Subject: [rspec-users] autogenerated it (was 'Custom Matcher and NAME NOT GENERATED annoyance') In-Reply-To: <57c63afe0705042008h54c44f3dq6ee9bfa86a522c74@mail.gmail.com> References: <57c63afe0705041957s326b29d1ob6129d0aad57f826@mail.gmail.com> <71166b3b0705042003k29bc763fnb36d533023237c52@mail.gmail.com> <57c63afe0705042008h54c44f3dq6ee9bfa86a522c74@mail.gmail.com> Message-ID: <71166b3b0705042022t229204adpcea2b764fd1ab462@mail.gmail.com> On 5/5/07, David Chelimsky wrote: [...] > > I only see use for one expectation, auto-generated ones. > > That's what I'm talking about. In other words, "it" definitely works > for non-auto-generated names: > > describe Thing do > it "should do stuff" do > > I'm specifically looking for an alias that works well for > auto-generated names, so if "the" only works well in that situation > I'm OK w/ that. > > The thing I'm wondering is whether "the" would work for the majority > of auto-generated-name examples, and whether it pushes you > psychologically towards a certain type of example. It makes sense when > you say: > > describe Thing do > the { @thing.should do_something } > > or..... > > describe Thing do > a { @thing.should do_something } > > But what other shapes do we need to consider? > 'a' or 'the' could cover almost everything when talking of a specific model/object instance, like the examples I provided. for other cases, like the ones present in examples/ folder (auto_spec_description_example.rb) will sound a bit awkward: it { 3.should be < 5 } it { ["a"].should include("a") } it { [1,2,3].should respond_to(:size) } WTH, even 'it' sounds weird in that context. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Fri May 4 23:25:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 22:25:12 -0500 Subject: [rspec-users] have_one and have_present Message-ID: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> >Comment By: Luis Lavena (luislavena) > Date: 2007-05-04 23:37 > describe "An Asset" do > before(:each) do > @asset = Asset.new > end > > it { @asset.should have_one(:attachment) } > it { @asset.should have_present(:something) } > end Food for thought on these. I like have_one a lot. It speaks to me as a Rails developer and I think it speaks to a customer as well. On the flip side, 'have_present' doesn't really tell me what is interesting about having it present, or why it should be present. I think 'require_attribute' would be nice ('require' would be even better, but obviously that is a keyword). Or 'validate_presence_of': an { @asset.should validate_presence_of(:something) } That's a little more Rails-developer-friendly than customer-friendly, but it still 'speaks' better than 'have_present' for me. FYI - Jay Fields has a Validatable framework that includes some test/unit assertions that look like this: Foo.must_validate do presence_of :name format_of(:name).with(/^[A-Z]/) numericality_of(:age).only_integer(true) end Because Spec::Rails behaviours inherit from Test::Unit::TestCase, you can install the validations gem (gem install validatable) and use these as/is with RSpec. Or, if you want it to feel more spec'ish, you could monkey patch an alias: Foo.should_validate do presence_of :name format_of(:name).with(/^[A-Z]/) numericality_of(:age).only_integer(true) end Whether you choose to use his framework or write your own, I think there is something to be learned from its expressiveness. Cheers, David From dchelimsky at gmail.com Fri May 4 23:26:38 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 22:26:38 -0500 Subject: [rspec-users] autogenerated it (was 'Custom Matcher and NAME NOT GENERATED annoyance') In-Reply-To: <71166b3b0705042022t229204adpcea2b764fd1ab462@mail.gmail.com> References: <57c63afe0705041957s326b29d1ob6129d0aad57f826@mail.gmail.com> <71166b3b0705042003k29bc763fnb36d533023237c52@mail.gmail.com> <57c63afe0705042008h54c44f3dq6ee9bfa86a522c74@mail.gmail.com> <71166b3b0705042022t229204adpcea2b764fd1ab462@mail.gmail.com> Message-ID: <57c63afe0705042026t2f5ff9bajad6d2dd9baec4511@mail.gmail.com> On 5/4/07, Luis Lavena wrote: > On 5/5/07, David Chelimsky wrote: > [...] > > > I only see use for one expectation, auto-generated ones. > > > > That's what I'm talking about. In other words, "it" definitely works > > for non-auto-generated names: > > > > describe Thing do > > it "should do stuff" do > > > > I'm specifically looking for an alias that works well for > > auto-generated names, so if "the" only works well in that situation > > I'm OK w/ that. > > > > The thing I'm wondering is whether "the" would work for the majority > > of auto-generated-name examples, and whether it pushes you > > psychologically towards a certain type of example. It makes sense when > > you say: > > > > describe Thing do > > the { @thing.should do_something } > > > > or..... > > > > describe Thing do > > a { @thing.should do_something } > > > > But what other shapes do we need to consider? > > > > 'a' or 'the' could cover almost everything when talking of a specific > model/object instance, like the examples I provided. > > for other cases, like the ones present in examples/ folder > (auto_spec_description_example.rb) will sound a bit awkward: > > it { 3.should be < 5 } > > it { ["a"].should include("a") } > > it { [1,2,3].should respond_to(:size) } > > > WTH, even 'it' sounds weird in that context. Those examples have not grown w/ the framework - we need to revisit them. > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri May 4 23:29:57 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 22:29:57 -0500 Subject: [rspec-users] have_one and have_present In-Reply-To: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> Message-ID: <57c63afe0705042029l59a825c4u8de36e87f2d3c84e@mail.gmail.com> On 5/4/07, David Chelimsky wrote: > >Comment By: Luis Lavena (luislavena) > > Date: 2007-05-04 23:37 > > > describe "An Asset" do > > before(:each) do > > @asset = Asset.new > > end > > > > it { @asset.should have_one(:attachment) } > > it { @asset.should have_present(:something) } > > end > > Food for thought on these. I like have_one a lot. It speaks to me as a > Rails developer and I think it speaks to a customer as well. > > On the flip side, 'have_present' doesn't really tell me what is > interesting about having it present, or why it should be present. I > think 'require_attribute' would be nice ('require' would be even > better, but obviously that is a keyword). Or 'validate_presence_of': > > an { @asset.should validate_presence_of(:something) } > > That's a little more Rails-developer-friendly than customer-friendly, > but it still 'speaks' better than 'have_present' for me. > > FYI - Jay Fields has a Validatable framework that includes some > test/unit assertions that look like this: > > Foo.must_validate do > presence_of :name > format_of(:name).with(/^[A-Z]/) > numericality_of(:age).only_integer(true) > end > > Because Spec::Rails behaviours inherit from Test::Unit::TestCase, you > can install the validations gem (gem install validatable) and use > these as/is with RSpec. Or, if you want it to feel more spec'ish, you > could monkey patch an alias: > > Foo.should_validate do > presence_of :name > format_of(:name).with(/^[A-Z]/) > numericality_of(:age).only_integer(true) > end D'oh!! Foo.should validate do ... > Whether you choose to use his framework or write your own, I think > there is something to be learned from its expressiveness. > > Cheers, > David > From luislavena at gmail.com Fri May 4 23:34:41 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 5 May 2007 00:34:41 -0300 Subject: [rspec-users] have_one and have_present In-Reply-To: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> Message-ID: <71166b3b0705042034k5a8a328ah90816257bb08d962@mail.gmail.com> On 5/5/07, David Chelimsky wrote: > >Comment By: Luis Lavena (luislavena) > > Date: 2007-05-04 23:37 > > > describe "An Asset" do > > before(:each) do > > @asset = Asset.new > > end > > > > it { @asset.should have_one(:attachment) } > > it { @asset.should have_present(:something) } > > end > > Food for thought on these. I like have_one a lot. It speaks to me as a > Rails developer and I think it speaks to a customer as well. > > On the flip side, 'have_present' doesn't really tell me what is > interesting about having it present, or why it should be present. I > think 'require_attribute' would be nice ('require' would be even > better, but obviously that is a keyword). Or 'validate_presence_of': > > an { @asset.should validate_presence_of(:something) } > > That's a little more Rails-developer-friendly than customer-friendly, > but it still 'speaks' better than 'have_present' for me. > yeah, have_present was due "require" been reserved word :-P validate_presence_of was another option, but that will force me to use validate_uniqueness_of, etc... A lot of typing just for one liner of example :-P > FYI - Jay Fields has a Validatable framework that includes some > test/unit assertions that look like this: > > Foo.must_validate do > presence_of :name > format_of(:name).with(/^[A-Z]/) > numericality_of(:age).only_integer(true) > end > > Because Spec::Rails behaviours inherit from Test::Unit::TestCase, you > can install the validations gem (gem install validatable) and use > these as/is with RSpec. Or, if you want it to feel more spec'ish, you > could monkey patch an alias: > I wasn't aware of it, thanks for the tip. > Foo.should_validate do > presence_of :name > format_of(:name).with(/^[A-Z]/) > numericality_of(:age).only_integer(true) > end > > Whether you choose to use his framework or write your own, I think > there is something to be learned from its expressiveness. > Of course, I often try to keep small the set of plugins/gems I use during development, which require I do gem install there to get the functionality. Piston the gem just for testing is also questionable, but doable. > Cheers, > David Again, thank for your your feedback, Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Fri May 4 23:38:35 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 May 2007 22:38:35 -0500 Subject: [rspec-users] have_one and have_present In-Reply-To: <71166b3b0705042034k5a8a328ah90816257bb08d962@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> <71166b3b0705042034k5a8a328ah90816257bb08d962@mail.gmail.com> Message-ID: <57c63afe0705042038h41f65cbbi11c60e5daac595db@mail.gmail.com> On 5/4/07, Luis Lavena wrote: > On 5/5/07, David Chelimsky wrote: > > >Comment By: Luis Lavena (luislavena) > > > Date: 2007-05-04 23:37 > > > > > describe "An Asset" do > > > before(:each) do > > > @asset = Asset.new > > > end > > > > > > it { @asset.should have_one(:attachment) } > > > it { @asset.should have_present(:something) } > > > end > > > > Food for thought on these. I like have_one a lot. It speaks to me as a > > Rails developer and I think it speaks to a customer as well. > > > > On the flip side, 'have_present' doesn't really tell me what is > > interesting about having it present, or why it should be present. I > > think 'require_attribute' would be nice ('require' would be even > > better, but obviously that is a keyword). Or 'validate_presence_of': > > > > an { @asset.should validate_presence_of(:something) } > > > > That's a little more Rails-developer-friendly than customer-friendly, > > but it still 'speaks' better than 'have_present' for me. > > > > yeah, have_present was due "require" been reserved word :-P > > validate_presence_of was another option, but that will force me to use > validate_uniqueness_of, etc... > > A lot of typing just for one liner of example :-P FWIW, you only have to type these things once each time you type them. You're going to read them hundreds of times. It's worth the extra typing in my view! If the examples are documentation, they should tell you, with as little mental mapping as possible, what it is that's being described. Using 'validate_presence_of' tells me EXACTLY what the code should look like. That's worth a lot to me. Cheers, David > > > FYI - Jay Fields has a Validatable framework that includes some > > test/unit assertions that look like this: > > > > Foo.must_validate do > > presence_of :name > > format_of(:name).with(/^[A-Z]/) > > numericality_of(:age).only_integer(true) > > end > > > > Because Spec::Rails behaviours inherit from Test::Unit::TestCase, you > > can install the validations gem (gem install validatable) and use > > these as/is with RSpec. Or, if you want it to feel more spec'ish, you > > could monkey patch an alias: > > > > I wasn't aware of it, thanks for the tip. > > > Foo.should_validate do > > presence_of :name > > format_of(:name).with(/^[A-Z]/) > > numericality_of(:age).only_integer(true) > > end > > > > Whether you choose to use his framework or write your own, I think > > there is something to be learned from its expressiveness. > > > > Of course, I often try to keep small the set of plugins/gems I use > during development, which require I do gem install there to get the > functionality. > > Piston the gem just for testing is also questionable, but doable. > > > Cheers, > > David > > Again, thank for your your feedback, > > Regards, > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Fri May 4 23:45:13 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 5 May 2007 00:45:13 -0300 Subject: [rspec-users] have_one and have_present In-Reply-To: <57c63afe0705042038h41f65cbbi11c60e5daac595db@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> <71166b3b0705042034k5a8a328ah90816257bb08d962@mail.gmail.com> <57c63afe0705042038h41f65cbbi11c60e5daac595db@mail.gmail.com> Message-ID: <71166b3b0705042045w642cc8afvb30ee814e364779a@mail.gmail.com> On 5/5/07, David Chelimsky wrote: [...] > > yeah, have_present was due "require" been reserved word :-P > > > > validate_presence_of was another option, but that will force me to use > > validate_uniqueness_of, etc... > > > > A lot of typing just for one liner of example :-P > > FWIW, you only have to type these things once each time you type them. > You're going to read them hundreds of times. It's worth the extra > typing in my view! If the examples are documentation, they should tell > you, with as little mental mapping as possible, what it is that's > being described. Using 'validate_presence_of' tells me EXACTLY what > the code should look like. That's worth a lot to me. > Valid point, Prior matchers I was using eval to create the specifys... should_validate_presence_of, uniqueness_of, etc. I tried to make shorter, but descriptives versions since upgrade. # Here start the accessor for examples: # it { @model.should have_present(:attr) } => should not be valid without :attr # it { @model.should have_unique(:attr) } => should not be valid with duplicate :attr # it { @model.should have_one(:attr, :through => :assoc) } => should has_one :attr through :assoc # it { @model.should belongs_to(:attr, :through => :assoc) } => should belongs_to :attr through :assoc # it { @model.should have_many(:attr, :through => :assoc) } => should has_many :attr through :assoc # it { @model.should have_and_belongs_to_many(:attr, :through => :assoc) } => should has_and_belongs_to_many :attr through :assoc # it { @model.should have_no_errors } => should have no errors Suggestions are welcome ;-) -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From crafterm at gmail.com Sat May 5 01:58:11 2007 From: crafterm at gmail.com (Marcus Crafter) Date: Sat, 5 May 2007 15:58:11 +1000 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <57c63afe0705041959l2e2a174ep7be39dc93c7f2b1d@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> <57c63afe0705041959l2e2a174ep7be39dc93c7f2b1d@mail.gmail.com> Message-ID: Hi David, On 05/05/2007, at 12:59 PM, David Chelimsky wrote: > On 5/4/07, Marcus Crafter wrote: >> Hi Chris, >> >> Looks good mate. Is there also a way of being able to get the name of >> the controller or some other variables into the 'it' strings to make >> the verbalisations read well for shared specs? >> >> like: >> >> it "should assign #{@model.to_s.underscore} for the view....." do > > How about ... > > it "should assign #{@model.humanize} for the view....." do Much better and would be fine with me, but the variable replacement currently doesn't resolve @model,etc at all unfortunately. Any thoughts where to look? Digging deeper.. Cheers, Marcus From aslak.hellesoy at gmail.com Sat May 5 04:32:49 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 5 May 2007 10:32:49 +0200 Subject: [rspec-users] Translating tests In-Reply-To: <57c63afe0705041958x3997ee68oa6f24691f7be007f@mail.gmail.com> References: <6586e070705041818m3d60ac0ci55ce72de138319c3@mail.gmail.com> <57c63afe0705041958x3997ee68oa6f24691f7be007f@mail.gmail.com> Message-ID: <8d961d900705050132h7a0539eap1656c129a8bb5af4@mail.gmail.com> On 5/5/07, David Chelimsky wrote: > On 5/4/07, Jeff Dean wrote: > > Is test2spec still around? If so, are there any special instructions for > > running it against edge? > > That died months and months ago. Sorry. > However, old releases are still available, so you could try to install the latest RSpec release that had it (I believe that's 0.6.4) and also install a compatible RubyInline and ParseTree (The latest releases won't work). It would be great to hear back if you found a combo that works. test2spec should still work ok! We're not supporting any of it though. Of course, after you run test2spec, you must install RSpec 0.9.2 and translate your specs to the new style. Aslak > > > > _______________________________________________ > > 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 Sat May 5 08:17:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 May 2007 07:17:54 -0500 Subject: [rspec-users] spec template for CRUD? In-Reply-To: References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> <57c63afe0705041959l2e2a174ep7be39dc93c7f2b1d@mail.gmail.com> Message-ID: <57c63afe0705050517q55e55e0ax878c627badc9f3eb@mail.gmail.com> On 5/5/07, Marcus Crafter wrote: > Hi David, > > On 05/05/2007, at 12:59 PM, David Chelimsky wrote: > > > On 5/4/07, Marcus Crafter wrote: > >> Hi Chris, > >> > >> Looks good mate. Is there also a way of being able to get the name of > >> the controller or some other variables into the 'it' strings to make > >> the verbalisations read well for shared specs? > >> > >> like: > >> > >> it "should assign #{@model.to_s.underscore} for the view....." do > > > > How about ... > > > > it "should assign #{@model.humanize} for the view....." do > > Much better and would be fine with me, but the variable replacement > currently doesn't resolve @model,etc at all unfortunately. Oh, I see what you mean. Unfortunately, there's not really a good way to do this so the variable is available for both the example name and the example, so for now you'd have to duplicate: describe SomeController do @model = MyModel #this is available for names it_should_behave_like "A CRUD Controller" before(:each) { @model = MyModel } #this is available within examples end What if we were to let it_should_behave_like take some initialization variables as well? it_should_behave_like "A CRUD Controller for", MyModel ??? > > Any thoughts where to look? Digging deeper.. > > Cheers, > > Marcus > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at ekenosen.net Sat May 5 10:45:18 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Sat, 5 May 2007 10:45:18 -0400 Subject: [rspec-users] have_one and have_present In-Reply-To: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> Message-ID: <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> On 5/4/07, David Chelimsky wrote: > FYI - Jay Fields has a Validatable framework that includes some > test/unit assertions that look like this: > > Foo.must_validate do > presence_of :name > format_of(:name).with(/^[A-Z]/) > numericality_of(:age).only_integer(true) > end ... > Whether you choose to use his framework or write your own, I think > there is something to be learned from its expressiveness. Something doesn't sit right with me for both Jay Field's test validations and also http://spicycode.com/2007/4/2/rspec-expecation-matchers-part-ii To me, it feels like both of them are testing the implementation too closely, rather than checking the expected behavior. I think that this problem is best exhibited by format_of. What am I verifying? That the production code contains the exact same regex as my spec code? That seems a bit silly to me, when the regex itself is the item that should be tested most! It's what is carrying the behavior. And, while the simple "first character should be a capital letter" may seem like a silly one to worry about, what about a more complicated regex, such as an email address validation? I would seriously distrust any spec containing a complicated regex which is attempting to validate another complicated regex. What I'd *really* like is something a lot simpler (even if more verbose), that focuses entirely on examples and the behavior exhibited for those examples. Basically, I want to give a set of invalid examples, and verify that they are indeed invalid, as well as some valid examples, and verify that they pass validation. But I'm still having a hard time coming up with a nice syntax for this. I was having a discussion with a coworker about this earlier in the week, and I pastied my first thoughts about this here: http://pastie.caboo.se/58438 After resting on it a bit, I also came up with another syntax, pastied here: http://pastie.caboo.se/59162 I'll readily admit that Jay Field's DSL looks much nicer than what I've come up with so far... but I'd rather stick with the plain vanilla rspec, and be certain that I'm asserting an expected model behavior against examples than expect the implementation details of which ActiveRecord validation was used. Am I just making things harder for myself? Am I missing the boat on a useful simplification? -- Nick From luislavena at gmail.com Sat May 5 12:25:57 2007 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 5 May 2007 13:25:57 -0300 Subject: [rspec-users] have_one and have_present In-Reply-To: <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> Message-ID: <71166b3b0705050925n34edd002hf248bba5286a9e11@mail.gmail.com> On 5/5/07, nicholas a. evans wrote: > ... > > Something doesn't sit right with me for both Jay Field's test > validations and also > http://spicycode.com/2007/4/2/rspec-expecation-matchers-part-ii > > To me, it feels like both of them are testing the implementation too > closely, rather than checking the expected behavior. I think that > this problem is best exhibited by format_of. What am I verifying? > That the production code contains the exact same regex as my spec > code? That seems a bit silly to me, when the regex itself is the item > that should be tested most! It's what is carrying the behavior. And, > while the simple "first character should be a capital letter" may seem > like a silly one to worry about, what about a more complicated regex, > such as an email address validation? I would seriously distrust any > spec containing a complicated regex which is attempting to validate > another complicated regex. > Nick, most of the validations I do about presence of a field, uniqueness of a field, or even the associations are based (and most of them) translated from requirements customer shared with me. I needed to find a way to show them I'm following they rules, their requirements, but also be useful for me. > What I'd *really* like is something a lot simpler (even if more > verbose), that focuses entirely on examples and the behavior exhibited > for those examples. Basically, I want to give a set of invalid > examples, and verify that they are indeed invalid, as well as some > valid examples, and verify that they pass validation. > > But I'm still having a hard time coming up with a nice syntax for > this. I was having a discussion with a coworker about this earlier in > the week, and I pastied my first thoughts about this here: > http://pastie.caboo.se/58438 After resting on it a bit, I also came > up with another syntax, pastied here: http://pastie.caboo.se/59162 > Both pasties looks interesting, since you're testing for valid and invalid values, something I disregard on my matchers. To not generate false possitives, I've should validte them and later provide a valid value instead... will stick that in my TODO list. > I'll readily admit that Jay Field's DSL looks much nicer than what > I've come up with so far... but I'd rather stick with the plain > vanilla rspec, and be certain that I'm asserting an expected model > behavior against examples than expect the implementation details of > which ActiveRecord validation was used. > > Am I just making things harder for myself? Am I missing the boat on a > useful simplification? My idea of specs (er, examples) are useful for me and my customer during the first design/implementation phase, but uses for rspec are too broad ;-) Regards and good weekend everyone. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Sat May 5 13:02:43 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 May 2007 12:02:43 -0500 Subject: [rspec-users] have_one and have_present In-Reply-To: <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> Message-ID: <57c63afe0705051002t465714cfqd5f567bf63b7fd25@mail.gmail.com> On 5/5/07, nicholas a. evans wrote: > On 5/4/07, David Chelimsky wrote: > > FYI - Jay Fields has a Validatable framework that includes some > > test/unit assertions that look like this: > > > > Foo.must_validate do > > presence_of :name > > format_of(:name).with(/^[A-Z]/) > > numericality_of(:age).only_integer(true) > > end > ... > > Whether you choose to use his framework or write your own, I think > > there is something to be learned from its expressiveness. > > Something doesn't sit right with me for both Jay Field's test > validations and also > http://spicycode.com/2007/4/2/rspec-expecation-matchers-part-ii > > To me, it feels like both of them are testing the implementation too > closely, rather than checking the expected behavior. I think that > this problem is best exhibited by format_of. What am I verifying? > That the production code contains the exact same regex as my spec > code? That seems a bit silly to me, when the regex itself is the item > that should be tested most! It's what is carrying the behavior. And, > while the simple "first character should be a capital letter" may seem > like a silly one to worry about, what about a more complicated regex, > such as an email address validation? I would seriously distrust any > spec containing a complicated regex which is attempting to validate > another complicated regex. > > What I'd *really* like is something a lot simpler (even if more > verbose), that focuses entirely on examples and the behavior exhibited > for those examples. Basically, I want to give a set of invalid > examples, and verify that they are indeed invalid, as well as some > valid examples, and verify that they pass validation. > > But I'm still having a hard time coming up with a nice syntax for > this. I was having a discussion with a coworker about this earlier in > the week, and I pastied my first thoughts about this here: > http://pastie.caboo.se/58438 After resting on it a bit, I also came > up with another syntax, pastied here: http://pastie.caboo.se/59162 > > I'll readily admit that Jay Field's DSL looks much nicer than what > I've come up with so far... but I'd rather stick with the plain > vanilla rspec, and be certain that I'm asserting an expected model > behavior against examples than expect the implementation details of > which ActiveRecord validation was used. > > Am I just making things harder for myself? Am I missing the boat on a > useful simplification? This is a very gray area. I can see arguments for Jay's approach and for the approach you're going for as well. The trick is to not get up in the dogma of any given approach and understand why it might or might not be valuable, and in what situations. Why do we care about avoiding implementation details in tests? Because they make tests brittle. Why? Because implementations tend to change more than interfaces. What about our model implementation might change? Are we going to possibly change from ActiveRecord::Base to some other persistence framework? Assuming very low likelihood that we'll decouple our Rails apps from AR, then I think it's OK to do these simpler but more implementation focused tests. They cover a LOT of ground in a very clear way. Here's another way to look at it. There is a rule of thumb in TDD that says "test YOUR code, not somebody else's." The idea is that when you're using someone else's API, you should hide it behind an adapter that is catered to the needs of your application. In tests of your code, you specify that they should use the wrapper correctly using mock implementations of the wrapper. Then you have a small suite of tests that verifies that your wrapper interacts correctly w/ the 3rd partly API. This allows you great flexibility in switching to a different API. In that case, nobody would blink an eye if you used the mocks to specify that your model interacts correctly with the adapter. Accepting that approach, then what is the difference, really, between that and Jay's approach, which essentially mocks AR and lets you specify that your model class interacts with it correctly? From aslak.hellesoy at gmail.com Sun May 6 06:31:44 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 6 May 2007 12:31:44 +0200 Subject: [rspec-users] NetBeans gets RSpec support Message-ID: <8d961d900705060331p6e85c48ew8989c96f9ce96a17@mail.gmail.com> It looks like the lates NetBeans milestone can run RSpec specifications: http://wiki.netbeans.org/wiki/view/NewAndNoteWorthyMilestone9 I haven't tried it myself, but if anyone else does please tell us about your experience. Aslak From aslak.hellesoy at gmail.com Sun May 6 07:40:39 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 6 May 2007 13:40:39 +0200 Subject: [rspec-users] NetBeans gets RSpec support In-Reply-To: <8d961d900705060331p6e85c48ew8989c96f9ce96a17@mail.gmail.com> References: <8d961d900705060331p6e85c48ew8989c96f9ce96a17@mail.gmail.com> Message-ID: <8d961d900705060440h55e2606eq5e62553e5d3f5252@mail.gmail.com> On 5/6/07, aslak hellesoy wrote: > It looks like the lates NetBeans milestone can run RSpec specifications: > > http://wiki.netbeans.org/wiki/view/NewAndNoteWorthyMilestone9 > > I haven't tried it myself, but if anyone else does please tell us > about your experience. > Ok, here is mine. I'm a NetBeans newb. I downloaded it from http://bits.netbeans.org/download/6.0/milestones/m9/latest/installers/ I also found some RSpec info here: http://wiki.netbeans.org/wiki/view/RubyRecentChanges It was a rather lengthy download (150 Mb) and install process - turns out I get a whole J2EE server bundled with the IDE :-/. Mmmm EJBs... :-) Firing up NetBeans was a breeze, and I easily found the "new project" button. I selected "Existing Ruby project" and navigated my way to the RSpec core. First surprise: I'm asked to say where my source code folder is, and my *tests*. First of all, I wished it guessed that for me, but since it had to ask, it should also ask me where my *specs* are. Anyway, I selected the spec folder for the "test" folder. Now that I had my project up I navigated to one of RSpec's own specs (translator_spec.rb). I double clicked the file, got the source up in the browser and hit the big green "play"-like button in the toolbar. I was presented with a very confusing dialog box that asked me to select the project's "Main file". Then I looked at the menus and found out that SHIFT-F6 will run the file I'm in. I did, and it ran the spec! The output was just like any old console output though - no gui progress bar or anything. However, when I deliberately made one of the examples fail, I was able to click on the backtrace and be taken to the source code. Backtrace linking works for any old Ruby code though, so this doesn't seem like an RSpec feature. I was unable to find out how to change the RSpec settings (like using a custom spec.opts file). My overall impression? It's cool that NetBeans adds RSpec support, but I couldn't find any RSpec-specific features beyond basic Ruby support. Aslak > Aslak > From aslak.hellesoy at gmail.com Sun May 6 10:20:19 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 6 May 2007 16:20:19 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.3 Message-ID: <8d961d900705060720n683988bcwd761d29d82a5ef95@mail.gmail.com> Nothing big this time, but it's released From michael.s.klishin at gmail.com Sun May 6 23:54:37 2007 From: michael.s.klishin at gmail.com (Michael Klishin) Date: Mon, 7 May 2007 07:54:37 +0400 Subject: [rspec-users] NetBeans gets RSpec support In-Reply-To: <8d961d900705060440h55e2606eq5e62553e5d3f5252@mail.gmail.com> References: <8d961d900705060331p6e85c48ew8989c96f9ce96a17@mail.gmail.com> <8d961d900705060440h55e2606eq5e62553e5d3f5252@mail.gmail.com> Message-ID: <709de1d10705062054m4a6c9dc1j51bd1a6ea5b5e603@mail.gmail.com> Tor Norbye added this after enhancement ticket submission to their IssueZilla. So they are open to ideas. On 06/05/07, aslak hellesoy wrote: > My overall impression? It's cool that NetBeans adds RSpec support, but > I couldn't find any RSpec-specific features beyond basic Ruby support. -- This was freedom. Losing all hope was freedom. Chasing the beauty in programming: www.ruby-lang.org | www.rubyonrails.org From dchelimsky at gmail.com Mon May 7 07:43:49 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 7 May 2007 06:43:49 -0500 Subject: [rspec-users] mock frameworks Message-ID: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> Just curious - now that rspec (as of 0.9) let's you choose your mock framework, how many of you are actually using (or planning to use) mocha or flexmock? Anybody planning to use any other mock framework besides rspec, mocha or flexmock? Thanks, David From michael.s.klishin at gmail.com Mon May 7 07:48:11 2007 From: michael.s.klishin at gmail.com (Michael Klishin) Date: Mon, 7 May 2007 15:48:11 +0400 Subject: [rspec-users] mock frameworks In-Reply-To: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> References: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> Message-ID: <709de1d10705070448m5fe76eeaoeddd466352608a00@mail.gmail.com> I think we may move to FlexMock in near future with new projects. It is similar to RSpec's built in frameworks but a bit more flexible to my mind. Unfortunately I have no experience with Mocha. On 07/05/07, David Chelimsky wrote: > Just curious - now that rspec (as of 0.9) let's you choose your mock > framework, how many of you are actually using (or planning to use) > mocha or flexmock? > > Anybody planning to use any other mock framework besides rspec, mocha > or flexmock? -- This was freedom. Losing all hope was freedom. Chasing the beauty in programming: www.ruby-lang.org | www.rubyonrails.org From micah at 8thlight.com Mon May 7 08:56:52 2007 From: micah at 8thlight.com (Micah Martin) Date: Mon, 7 May 2007 07:56:52 -0500 Subject: [rspec-users] mock frameworks In-Reply-To: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> References: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> Message-ID: <8032DE1C-920B-4D91-82ED-DBA81DB768B2@8thlight.com> I've got tons of code using the rspecs mocks. I won't be switching to mocha or flex any time soon. Micah Martin 8th Light, Inc. 8thlight.com On May 7, 2007, at 6:43 AM, David Chelimsky wrote: > Just curious - now that rspec (as of 0.9) let's you choose your mock > framework, how many of you are actually using (or planning to use) > mocha or flexmock? > > Anybody planning to use any other mock framework besides rspec, mocha > or flexmock? > > Thanks, > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070507/0759dd8a/attachment-0001.html From mlangenberg at gmail.com Mon May 7 10:52:46 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Mon, 7 May 2007 16:52:46 +0200 Subject: [rspec-users] mock frameworks In-Reply-To: <8032DE1C-920B-4D91-82ED-DBA81DB768B2@8thlight.com> References: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> <8032DE1C-920B-4D91-82ED-DBA81DB768B2@8thlight.com> Message-ID: <27c0ac6d0705070752g1b642bd4u5b5c95b18bf0f695@mail.gmail.com> I've never used another mocking framework besides RPecs', I've got no reason to switch actually. On 5/7/07, Micah Martin wrote: > I've got tons of code using the rspecs mocks. I won't be switching to mocha > or flex any time soon. > > Micah Martin > 8th Light, Inc. > 8thlight.com > > > > > > On May 7, 2007, at 6:43 AM, David Chelimsky wrote: > > Just curious - now that rspec (as of 0.9) let's you choose your mock > framework, how many of you are actually using (or planning to use) > mocha or flexmock? > > Anybody planning to use any other mock framework besides rspec, mocha > or flexmock? > > Thanks, > 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 > From nick at ekenosen.net Mon May 7 12:44:40 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Mon, 7 May 2007 12:44:40 -0400 Subject: [rspec-users] have_one and have_present In-Reply-To: <57c63afe0705051002t465714cfqd5f567bf63b7fd25@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> <57c63afe0705051002t465714cfqd5f567bf63b7fd25@mail.gmail.com> Message-ID: <276ff9870705070944n56c48289vecfa2e9348914b02@mail.gmail.com> On 5/5/07, David Chelimsky wrote: > This is a very gray area. Agreed. ;-) > Why do we care about avoiding implementation details in tests? > Because they make tests brittle. I think that there is another reason, which is sometimes more important (and sometimes less): doing this communicates the actual system requirements better than do implementation details. > Are we going to possibly change from ActiveRecord::Base to > some other persistence framework? No. However, just for the sake of argument, I will bring up that I have recently had to change my persistence framework from ActiveRecord::Base (version 1.1.6) to ActiveRecord::Base (version 1.2.2). Various other incompatibilities (largely brought on ourselves by working too closely with private APIs) are still fresh in my mind. But I agree with your point here; the core validations aren't likely to be changing much from one version of AR::Base to the next. > They cover a LOT of ground in a very clear way. I still have misgivings about just how clear it actually is. > Here's another way to look at it. There is a rule of thumb in TDD that > says "test YOUR code, not somebody else's." ... > Accepting that approach, then what is the difference, really, between > that and Jay's approach, which essentially mocks AR and lets you > specify that your model class interacts with it correctly? I usually come down rather heavily in the "isolation test with all dependencies mocked out" camp. I'm really not sure how to consistently resolve my double standard here. I simply feel very uneasy using mock expectations for model validations. on readability: Granted, "validates_presence_of" is incredibly simple and easy for anyone to understand and validates_numericality_of and validates_confirmation_of may speak to us as rails programmers, but do they speak to our BAs and PMs? "Numericality" isn't even an english word! :-) Wouldn't it be much simpler and far more communicative if we said, "when the object's attributes are set to these values, the object is marked as invalid, can't be saved, and has this error message"? From a business user's perspective, isn't that what they really care about? on changing the implementation after the fact (and brittle tests): I think that most apps don't need to use much beyond the basic rails-provided validations, so this approach probably works better for them than for my company. But my apps have relatively few validates_presence_of, compared to a large number of state based (or other complicated) validations (when this attribute is set to such and such, or when the model is in such and such a state, then these other conditions must be valid"). When we do use the standard rails validations, we often also pass in an :if or :unless block. The further you stray from the simple use case of just adding the validation to the model with no extra parameters, the more it looks like you are just copying and pasting code from your specs into your production code. (Unless you aren't working TDD/BDD, in which case the copying goes in the opposite direction!) If you were to use valid/invalid examples, then you wouldn't need to change each example every time you add another condition to your validations... you would simply add/modify/remove the examples that make sense. I would argue that this makes more sense from a TDD/BDD perspective, as well as from a "brittle tests" perspective. on meaningful specs: validates_format_of (or other similarly complicated validations, such as using :if or :unless) is really where I have my biggest problem. Ignore all of the above as an misguided ideological rant, and I'll be completely fine with that. In time, I might even agree with you. ;-) But what does the following mean: model.should validate_format_of(:email, /\w+@\w+\.\w+/) oh, that was rather naive, it isn't catching "foo bar blatz at test.com" as invalid. Okay, let's change the code and the spec: model.should validate_format_of(:email, /^\w+@\w+\.\w+$/) oh, now we have one of my pet peeves, "foo+bar at test.com" isn't considered valid, nor is "foo at test.domain.com". "foo_bar at test.com" is still valid, but "foo-bar at test.com" is not. Do you see my point? These are very simple regular expressions, but they are already non-trivial and less obvious to read than what they are able accomplish. Sure, I could go onto the net and borrow someone else's pre-built email regex validation... but that only helps with email addresses. What about some other complicated problem more in your specific domain? What about a problem that you originally *thought* you could solve with a regex, but you later found something that a regex couldn't handle or you found a more performant or a simpler implementation. That we are calling "validates_format_of" with a specific regular expression has almost *nothing* to do with our requirements. That we consider certain classes of strings to be valid and certain to be invalid, *that* is what matters. My fear is that by adopting this style of validations, we make things a little bit more concise where we need it the least (with the very very simple validations), but encourage a style that will be detrimental for the even the mildly complicated validations. Here's another attempt at a syntax that is hopefully simple and readable: valid_model.should validate(:with_message => "Unacceptable email address.") do valid :email => "foo at bar.com" valid :email => "foo+extension at bar.com" valid :email => "foo-bar at test.com" valid :email => "foo-bar at test.domain.com" invalid :email => "no spaces please foo at bar.com" invalid :email => "@no.username.com" invalid :email => "only_tld at com" invalid({:email => ""}, :with_message => "Should provide email address") valid :email => "", :status => "registration incomplete" valid :email => "", :user_role => "fake" valid :email => "", :user_role => "admin" end Keeping in mind, of course, that real business rules tend to be even crazier than a simple email address validation. I'm not even saying that all of the above rules above make sense, but that doesn't mean that rules of that level of complexity won't be demanded by our customers. ;-) I think that the above style communicates much more clearly than: model.should validate_format_of(cryptic_regex).with(:option1 => "blahblahblah", :option2 => "blahblahblah") But again, I might be tilting at windmills, so I'm looking for some validation of my thoughts. ;-) (pun unfortunately intended) -- Nick From George.Anderson at erickson.com Mon May 7 12:58:44 2007 From: George.Anderson at erickson.com (GAnderson) Date: Mon, 07 May 2007 12:58:44 -0400 Subject: [rspec-users] Installing plugins without svn:// access Message-ID: Hi, I'm trying to get up and running with rspec on a new project. I'd like to install the rspec and rspec_on_rails plugins (per http://rspec.rubyforge.org/documentation/rails/install.html), but my corporate firewall blocks port 3690 so I can't access the repository via svn:// I searched the docs and the mailing-list archive to figure out how to install the plugins manually, but I came up empty. Can someone give me a gentle shove in the right direction? Thanks, /g -- George Anderson Sr. Software Engineer - Point Solutions Erickson Communities 701 Maiden Choice Lane Catonsville, MD 21228 The information in this email is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmissions, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you receive this email in error, please contact the sender and delete the material from any computer.. From nick at ekenosen.net Mon May 7 13:51:25 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Mon, 7 May 2007 13:51:25 -0400 Subject: [rspec-users] mock frameworks In-Reply-To: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> References: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> Message-ID: <276ff9870705071051j426fc2bbh6a3f9a71f3bfbd3d@mail.gmail.com> On 5/7/07, David Chelimsky wrote: > Anybody planning to use any other mock framework besides rspec, mocha > or flexmock? We have some tests written in test/unit and using Mocha, but we were planning on converting it all to rspec (including rspec mocks) eventually. Maybe we'll consider using Mocha for that code, if it makes the conversion go more smoothly. -- Nick From mailing_lists at railsnewbie.com Mon May 7 16:00:53 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 7 May 2007 16:00:53 -0400 Subject: [rspec-users] Installing plugins without svn:// access In-Reply-To: References: Message-ID: <656C32A9-1B26-4BD3-8323-2DCA758E2A3B@railsnewbie.com> Personally I know of no way. But if no one else has an idea, I could possibly set up an rspec mirror on http... Scott On May 7, 2007, at 12:58 PM, GAnderson wrote: > Hi, > > I'm trying to get up and running with rspec on a new project. I'd > like to > install the rspec and rspec_on_rails plugins (per > http://rspec.rubyforge.org/documentation/rails/install.html), but my > corporate firewall blocks port 3690 so I can't access the > repository via > svn:// > > I searched the docs and the mailing-list archive to figure out how to > install the plugins manually, but I came up empty. Can someone > give me a > gentle shove in the right direction? > > Thanks, > > /g > -- > George Anderson > Sr. Software Engineer - Point Solutions > > Erickson Communities > 701 Maiden Choice Lane > Catonsville, MD 21228 > > > > > > The information in this email is intended only for the person or > entity to which it is addressed and may contain confidential and/or > privileged material. Any review, retransmissions, dissemination or > other use of or taking of any action in reliance upon this > information by persons or entities other than the intended > recipient is prohibited. If you receive this email in error, please > contact the sender and delete the material from any computer.. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From nick at ekenosen.net Mon May 7 19:32:28 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Mon, 7 May 2007 19:32:28 -0400 Subject: [rspec-users] have_one and have_present In-Reply-To: <276ff9870705070944n56c48289vecfa2e9348914b02@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> <57c63afe0705051002t465714cfqd5f567bf63b7fd25@mail.gmail.com> <276ff9870705070944n56c48289vecfa2e9348914b02@mail.gmail.com> Message-ID: <276ff9870705071632l4586f3ffh1cc1d24921e26b7@mail.gmail.com> On 5/7/07, nicholas a. evans wrote: > validates_format_of (or other similarly complicated validations, such > as using :if or :unless) is really where I have my biggest problem. Sorry that my last email was such a long rant. I'll try to restate the important part more clearly, so you can ignore the other email. ;-) As an example, let's try BDD with email address validation. We'll start with something simple like: model.should validate_format_of(:email, /\w+@\w+\.\w+/) and then add this to the model, to make the spec pass: validate_format_of :email, :with => /\w+@\w+\.\w+/ Oh, that was rather naive; "foo bar blatz at test.com" is still valid. Okay then, that old spec line was wrong; let's change it to: model.should validate_format_of(:email, /^\w+@\w+\.\w+$/) and then change the model to: validate_format_of :email, :with => /^\w+@\w+\.\w+$/ Strange, this feels like I'm copying and pasting from my spec to my code! Unfortunately, "foo+bar at test.com" isn't considered valid, nor is "foo at test.domain.com". "foo_bar at test.com" is still valid, but "foo-bar at test.com" is not. And so on, ad-infinitum, except that the specs provide no fall-back guarantee that something that used to work will still work, because I'm completely rewriting the spec at each step along the way. This testing style feels rather brittle, and I'm still only using ActiveRecord. At some point, I think that I'd give up on TDD/BDD, and just write the code first, then copy it back to the validation spec. So, what happens when I want to say this? validate_format_of :with => cryptic_email_regex, :unless => lambda { |user| user.type == "local" } These are very simple regular expressions, and very simple business rules, but they are already non-trivial and nuanced enough that the validation method that is called is unimportant, and simple examples of what is valid or invalid are far less confusing than a cryptic but powerful regex. What I prefer to do: first I would add a simple example of a valid value, and make sure that works prior to having any validations in place. Then I'd add a simple example of an invalid value, run the code, see that it fails, then add the simplest validation necessary to pass the specs. Then I'd add another example, see it fail, and make it work. I'd look closely at my implementation to see if there are any edge-cases and then I'd make examples of them to see if any of them fail, and I'd make them work. And so on. When the business requirements change, most likely I'll not need to change any examples, I'll just need to add another. At the end, I might wind up with something similar to the following (another validation DSL attempt): valid_model.should validate(:with_message => "Unacceptable email address.") do valid :email => "foo at bar.com" valid :email => "foo+extension at bar.com" valid :email => "foo-bar at test.com" valid :email => "foo-bar at test.domain.com" invalid :email => "anything at domain.we.dont.like" invalid :email => "no spaces please foo at bar.com" invalid :email => "@no.username.com" invalid :email => "only_tld at com" invalid({:email => ""}, :with_message => "Should provide email address") valid :email => "", :status => "registration incomplete" valid :email => "", :user_role => "fake" valid :email => "", :user_role => "admin" valid :email => "username", :type => "local" valid :email => "username at local.domain", :type => "local" invalid({:email => "username at domain.com", :type => "local"}, :with_message => "local users must use a local username") end Please ignore whether or not the above validations are reasonable. My imaginary business analyst tells me they are all very important. The level of complexity should be reasonable, despite my bad examples. :-) This style feels much more compatible with TDD/BDD, and far less brittle. I also think that it is much clearer and more communicative. It just isn't as concise. But then again, it might be clear from my rambling emails that I don't place enough value on being concise. ;-) -- Nick From lachiec at gmail.com Mon May 7 19:32:58 2007 From: lachiec at gmail.com (Lachie) Date: Tue, 8 May 2007 09:32:58 +1000 Subject: [rspec-users] Installing plugins without svn:// access In-Reply-To: References: Message-ID: <2c5e719e0705071632n1c78eaaag1326c351513beaed@mail.gmail.com> Hi George, I have the same problem. I've repeatedly asked for svn access from my corporate masters, and just as repeatedly been knocked back :( 1. run ssh on your home box on port 443 (https) 2. get http://www.agroman.net/corkscrew/ 3. ssh to home (using corkscrew) 4. svn export svn://.../rspec_on_rails 5. tar jcvf rspec_on_rails.tar.bz2 6. scp lachie at homebox:rspec_on_rails.tar.bz2 . (using corkscrew) Yes, it really sucks. Scott, an http mirror would rock, or it could be mirrored at google code, using their http-viewable svn repos. Even an automatically created tarball of trunk in rubyforge would be better. Lachie On 5/8/07, GAnderson wrote: > Hi, > > I'm trying to get up and running with rspec on a new project. I'd like to > install the rspec and rspec_on_rails plugins (per > http://rspec.rubyforge.org/documentation/rails/install.html), but my > corporate firewall blocks port 3690 so I can't access the repository via > svn:// > > I searched the docs and the mailing-list archive to figure out how to > install the plugins manually, but I came up empty. Can someone give me a > gentle shove in the right direction? > > Thanks, > > /g > -- > George Anderson > Sr. Software Engineer - Point Solutions > > Erickson Communities > 701 Maiden Choice Lane > Catonsville, MD 21228 > > > > > > The information in this email is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmissions, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you receive this email in error, please contact the sender and delete the material from any computer.. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Lachie http://lachie.info/ http://www.flickr.com/photos/lachie/ From chris.c.hoffman at gmail.com Mon May 7 19:55:49 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Mon, 7 May 2007 19:55:49 -0400 Subject: [rspec-users] spec template for CRUD? In-Reply-To: <57c63afe0705050517q55e55e0ax878c627badc9f3eb@mail.gmail.com> References: <63c5d3820705040825p9e9ddf9ud6c4d4574442cefc@mail.gmail.com> <57c63afe0705040833q409384b3xc43427ccb7efd59b@mail.gmail.com> <63c5d3820705040837y774ab2f9xb9d72aa03bfd1d96@mail.gmail.com> <57c63afe0705040851i175e3fajd7f2a52993281a34@mail.gmail.com> <63c5d3820705040901y35ec0229g8b855825591b5a76@mail.gmail.com> <63c5d3820705041217n2978d885m445a7ef58d6d6331@mail.gmail.com> <9B31C05A-0021-40A7-9C73-2B1F7FD7C3F0@gmail.com> <57c63afe0705041959l2e2a174ep7be39dc93c7f2b1d@mail.gmail.com> <57c63afe0705050517q55e55e0ax878c627badc9f3eb@mail.gmail.com> Message-ID: <63c5d3820705071655v3a6e4388i87843b08634ba785@mail.gmail.com> An argument indeed would be effective. As long as things like instance variables are obeying particular conventions, we can make assumptions based on this model class that is passed. For example: describe "list", :shared => true do it "should populate #{model.to_s.underscore.pluralize} by calling #{model}.find(:all)" ... -Chris On 5/5/07, David Chelimsky wrote: > On 5/5/07, Marcus Crafter wrote: > > Hi David, > > > > On 05/05/2007, at 12:59 PM, David Chelimsky wrote: > > > > > On 5/4/07, Marcus Crafter wrote: > > >> Hi Chris, > > >> > > >> Looks good mate. Is there also a way of being able to get the name of > > >> the controller or some other variables into the 'it' strings to make > > >> the verbalisations read well for shared specs? > > >> > > >> like: > > >> > > >> it "should assign #{@model.to_s.underscore} for the view....." do > > > > > > How about ... > > > > > > it "should assign #{@model.humanize} for the view....." do > > > > Much better and would be fine with me, but the variable replacement > > currently doesn't resolve @model,etc at all unfortunately. > > Oh, I see what you mean. Unfortunately, there's not really a good way > to do this so the variable is available for both the example name and > the example, so for now you'd have to duplicate: > > describe SomeController do > @model = MyModel #this is available for names > it_should_behave_like "A CRUD Controller" > > before(:each) { @model = MyModel } #this is available within examples > end > > What if we were to let it_should_behave_like take some initialization > variables as well? > > it_should_behave_like "A CRUD Controller for", MyModel > > ??? > > > > > > Any thoughts where to look? Digging deeper.. > > > > Cheers, > > > > Marcus > > > > _______________________________________________ > > 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 mailing_lists at railsnewbie.com Tue May 8 06:38:10 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 8 May 2007 06:38:10 -0400 Subject: [rspec-users] Installing plugins without svn:// access In-Reply-To: <2c5e719e0705071632n1c78eaaag1326c351513beaed@mail.gmail.com> References: <2c5e719e0705071632n1c78eaaag1326c351513beaed@mail.gmail.com> Message-ID: <60782B66-E409-48BA-A2E9-F8E5F8DF66EA@railsnewbie.com> > Scott, an http mirror would rock, or it could be mirrored at google > code, using their http-viewable svn repos. Can you point me to a page on google with more info? Or should I just google it? I will set up a mirror with svnsync if the admins can setup a "pre- revprop-change hook". Although I should say this: the server is an experimental one - so don't be surprised if it suddenly stops working. I could also look into using svk to sync the repos. Scott From mailing_lists at railsnewbie.com Tue May 8 07:58:07 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 8 May 2007 07:58:07 -0400 Subject: [rspec-users] Installing plugins without svn:// access In-Reply-To: <2c5e719e0705071632n1c78eaaag1326c351513beaed@mail.gmail.com> References: <2c5e719e0705071632n1c78eaaag1326c351513beaed@mail.gmail.com> Message-ID: <87F6775D-07DF-4374-9F51-468C2373DFEA@railsnewbie.com> On May 7, 2007, at 7:32 PM, Lachie wrote: > Hi George, > I have the same problem. I've repeatedly asked for svn access from my > corporate masters, and just as repeatedly been knocked back :( > > 1. run ssh on your home box on port 443 (https) > 2. get http://www.agroman.net/corkscrew/ > 3. ssh to home (using corkscrew) > 4. svn export svn://.../rspec_on_rails > 5. tar jcvf rspec_on_rails.tar.bz2 > 6. scp lachie at homebox:rspec_on_rails.tar.bz2 . (using corkscrew) > > Yes, it really sucks. > Scott, an http mirror would rock, or it could be mirrored at google > code, using their http-viewable svn repos. Ok - I've got an http read only mirror going. Like I've said, this server is just being used right now for some of my own learning about server admin - so don't be surprised if it mysteriously stops working some day. I'm paying for access, so please only use it if you can't access the rubyforge repository. You can access trunk through this url: http://thmadb.com/mirrors/rspec/trunk or the whole of the repository through: http://thmadb.com/mirrors/rspec I'm only syncing once every hour, so trunk will be an hour off. Also revision numbers will be one higher than they are if you checkout from from the real svn repos. Happy hacking! Scott From aslak.hellesoy at gmail.com Tue May 8 08:36:34 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 8 May 2007 14:36:34 +0200 Subject: [rspec-users] Installing plugins without svn:// access In-Reply-To: <87F6775D-07DF-4374-9F51-468C2373DFEA@railsnewbie.com> References: <2c5e719e0705071632n1c78eaaag1326c351513beaed@mail.gmail.com> <87F6775D-07DF-4374-9F51-468C2373DFEA@railsnewbie.com> Message-ID: <8d961d900705080536x26661085qb9c5b7ddae27d791@mail.gmail.com> On 5/8/07, Scott Taylor wrote: > > On May 7, 2007, at 7:32 PM, Lachie wrote: > > > Hi George, > > I have the same problem. I've repeatedly asked for svn access from my > > corporate masters, and just as repeatedly been knocked back :( > > > > 1. run ssh on your home box on port 443 (https) > > 2. get http://www.agroman.net/corkscrew/ > > 3. ssh to home (using corkscrew) > > 4. svn export svn://.../rspec_on_rails > > 5. tar jcvf rspec_on_rails.tar.bz2 > > 6. scp lachie at homebox:rspec_on_rails.tar.bz2 . (using corkscrew) > > > > Yes, it really sucks. > > Scott, an http mirror would rock, or it could be mirrored at google > > code, using their http-viewable svn repos. > > Ok - I've got an http read only mirror going. > > Like I've said, this server is just being used right now for some of > my own learning about server admin - so don't be surprised if it > mysteriously stops working some day. I'm paying for access, so > please only use it if you can't access the rubyforge repository. > > > You can access trunk through this url: > > http://thmadb.com/mirrors/rspec/trunk > > or the whole of the repository through: > > http://thmadb.com/mirrors/rspec > > > I'm only syncing once every hour, so trunk will be an hour off. Also > revision numbers will be one higher than they are if you checkout > from from the real svn repos. > Thanks a lot Scott! Because the repository may go away I recommend that anyone using this to install Spec::Rails to *not* use the -x switch in script/plugin unless you can live with an unavailable repo. Aslak > Happy hacking! > > Scott > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From George.Anderson at erickson.com Tue May 8 09:42:50 2007 From: George.Anderson at erickson.com (GAnderson) Date: Tue, 08 May 2007 09:42:50 -0400 Subject: [rspec-users] Installing plugins without svn:// access In-Reply-To: <87F6775D-07DF-4374-9F51-468C2373DFEA@railsnewbie.com> Message-ID: Thanks, Scott and Lachie, for your help. I'm hoping to get svn:// through the firewall soon. I just started a new job (2 weeks ago) and one of my first official act was to request they open port 3690 (svn://). I think I raised some eyebrows because the next day I got a lunch meeting request from the CTO. Not sure if that's good or bad;) /g On 5/8/07 7:58 AM, "Scott Taylor" wrote: > > On May 7, 2007, at 7:32 PM, Lachie wrote: > >> Hi George, >> I have the same problem. I've repeatedly asked for svn access from my >> corporate masters, and just as repeatedly been knocked back :( >> >> 1. run ssh on your home box on port 443 (https) >> 2. get http://www.agroman.net/corkscrew/ >> 3. ssh to home (using corkscrew) >> 4. svn export svn://.../rspec_on_rails >> 5. tar jcvf rspec_on_rails.tar.bz2 >> 6. scp lachie at homebox:rspec_on_rails.tar.bz2 . (using corkscrew) >> >> Yes, it really sucks. >> Scott, an http mirror would rock, or it could be mirrored at google >> code, using their http-viewable svn repos. > > Ok - I've got an http read only mirror going. > > Like I've said, this server is just being used right now for some of > my own learning about server admin - so don't be surprised if it > mysteriously stops working some day. I'm paying for access, so > please only use it if you can't access the rubyforge repository. > > > You can access trunk through this url: > > http://thmadb.com/mirrors/rspec/trunk > > or the whole of the repository through: > > http://thmadb.com/mirrors/rspec > > > I'm only syncing once every hour, so trunk will be an hour off. Also > revision numbers will be one higher than they are if you checkout > from from the real svn repos. > > Happy hacking! > > Scott > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- George Anderson Sr. Software Engineer - Point Solutions Erickson Communities 701 Maiden Choice Lane Catonsville, MD 21228 The information in this email is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmissions, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you receive this email in error, please contact the sender and delete the material from any computer.. From George.Anderson at erickson.com Tue May 8 10:05:04 2007 From: George.Anderson at erickson.com (GAnderson) Date: Tue, 08 May 2007 10:05:04 -0400 Subject: [rspec-users] Installing plugins without svn:// access In-Reply-To: <8d961d900705080536x26661085qb9c5b7ddae27d791@mail.gmail.com> Message-ID: Good point, Aslak. Another option is using Piston ( http://piston.rubyforge.org/). You get the benefits of svn:externals with better control over updates. You can also "switch" the location of the repository. Good stuff. /g On 5/8/07 8:36 AM, "aslak hellesoy" wrote: > On 5/8/07, Scott Taylor wrote: >> >> Ok - I've got an http read only mirror going. >> >> Like I've said, this server is just being used right now for some of >> my own learning about server admin - so don't be surprised if it >> mysteriously stops working some day. I'm paying for access, so >> please only use it if you can't access the rubyforge repository. >> >> >> You can access trunk through this url: >> >> http://thmadb.com/mirrors/rspec/trunk >> >> or the whole of the repository through: >> >> http://thmadb.com/mirrors/rspec >> >> >> I'm only syncing once every hour, so trunk will be an hour off. Also >> revision numbers will be one higher than they are if you checkout >> from from the real svn repos. >> > > Thanks a lot Scott! > > Because the repository may go away I recommend that anyone using this > to install Spec::Rails to *not* use the -x switch in script/plugin > unless you can live with an unavailable repo. > > Aslak > >> Happy hacking! >> >> Scott >> >> >> >> >> _______________________________________________ >> 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 -- George Anderson Sr. Software Engineer - Point Solutions Erickson Communities 701 Maiden Choice Lane Catonsville, MD 21228 The information in this email is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmissions, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you receive this email in error, please contact the sender and delete the material from any computer.. From jerry.west at ntlworld.com Tue May 8 10:28:39 2007 From: jerry.west at ntlworld.com (Jerry West) Date: Tue, 08 May 2007 15:28:39 +0100 Subject: [rspec-users] have_one and have_present In-Reply-To: <276ff9870705071632l4586f3ffh1cc1d24921e26b7@mail.gmail.com> References: <57c63afe0705042025x7ba302d0icb6243730e3c7732@mail.gmail.com> <276ff9870705050745n3ccbc32fi86a4611f9374520@mail.gmail.com> <57c63afe0705051002t465714cfqd5f567bf63b7fd25@mail.gmail.com> <276ff9870705070944n56c48289vecfa2e9348914b02@mail.gmail.com> <276ff9870705071632l4586f3ffh1cc1d24921e26b7@mail.gmail.com> Message-ID: <46408917.8080904@ntlworld.com> I have to agree, Nick. Specs should be about behaviour and not implementation, though the two will inevitably overlap. Even specifying associations (another recent discussion) might be too much - what the client is really interested in is the behaviour associations offer (or rather the problem-specific solutions that behaviour allows you to offer). So long as one regards such a spec as being shorthand for the end behaviour there should be no problem, but if we are too specific in our specifications we might end up dictating implementation choices which are neither necessary nor, perhaps desirable. I like your valid/invalid syntax too. Best wishes, Jerry PS: "Independent" confirmation of an implementation detail ('did I type it right?') can be very helpful and I know I have used tests & specs for exactly that purpose, but in my case I suspect it's really a lack of confidence in my own abilities and understanding! Is it really the role of a spec to double check that the coder has typed the right thing? From steve.odom at gmail.com Tue May 8 11:07:32 2007 From: steve.odom at gmail.com (Steve Odom) Date: Tue, 8 May 2007 10:07:32 -0500 Subject: [rspec-users] help with rspec'ing controller Message-ID: <42664051-65F0-4418-B047-F1CC07700E8C@gmail.com> Hi, I'm a rspec newbie. I'm having trouble with rspec'ing a simple controller to Create a record. I've tried a couple of approaches and still get errors: Mock 'remedy' expected :save! with (any args) once, but received it 0 times -or- Mock 'Remedy' received unexpected message :save with (no args). Here are my two sample approaches: describe "Create with a valid product and authenticated user" do controller_name :products before(:each) do @product= mock(Product) Product.stub!(:new).and_return(@product) end it "should tell the Product model to create a new product" do #mock_user_authentication(true) Product.should_receive(:new).with(:params).and_return(@product) post 'create', :product => :params end end describe "Create with a valid product and authenticated user with everything in setup" do controller_name :product setup do @product= mock(:product, :null_object => true) Product.stub!(:new).and_return(@product) @product.should_receive(:save!).and_return(true) #mock_user_authentication(true) post :create, :product => {'name' => 'a new product', 'description' => 'an editable description', 'user_id' => 1, 'klass' => 1} end specify "should redirect to list" do response.should redirect_to(:action => 'list') end Any ideas what I am doing wrong? Thanks, Steve From aslak.hellesoy at gmail.com Tue May 8 11:42:05 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 8 May 2007 17:42:05 +0200 Subject: [rspec-users] help with rspec'ing controller In-Reply-To: <42664051-65F0-4418-B047-F1CC07700E8C@gmail.com> References: <42664051-65F0-4418-B047-F1CC07700E8C@gmail.com> Message-ID: <8d961d900705080842n521e1e24r38a09017be07c350@mail.gmail.com> Looks like you've configured your mock to receive a call to #save! while your controller is actually calling #save. #save! is not the same as #save! On 5/8/07, Steve Odom wrote: > Hi, > > I'm a rspec newbie. I'm having trouble with rspec'ing a simple > controller to Create a record. > > I've tried a couple of approaches and still get errors: > Mock 'remedy' expected :save! with (any args) once, but received it 0 > times > > -or- > > Mock 'Remedy' received unexpected message :save with (no args). > > Here are my two sample approaches: > > describe "Create with a valid product and authenticated user" do > controller_name :products > > before(:each) do > @product= mock(Product) > Product.stub!(:new).and_return(@product) > end > > it "should tell the Product model to create a new product" do > #mock_user_authentication(true) > Product.should_receive(:new).with(:params).and_return(@product) > post 'create', :product => :params > end > end > > describe "Create with a valid product and authenticated user with > everything in setup" do > controller_name :product > > setup do > @product= mock(:product, :null_object => true) > Product.stub!(:new).and_return(@product) > @product.should_receive(:save!).and_return(true) > #mock_user_authentication(true) > > post :create, :product => {'name' => 'a new product', > 'description' => 'an editable description', > 'user_id' => 1, 'klass' => 1} > end > > specify "should redirect to list" do > response.should redirect_to(:action => 'list') > end > > Any ideas what I am doing wrong? > > Thanks, > > Steve > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From michael.s.klishin at gmail.com Tue May 8 11:43:41 2007 From: michael.s.klishin at gmail.com (Michael Klishin) Date: Tue, 8 May 2007 19:43:41 +0400 Subject: [rspec-users] help with rspec'ing controller In-Reply-To: <42664051-65F0-4418-B047-F1CC07700E8C@gmail.com> References: <42664051-65F0-4418-B047-F1CC07700E8C@gmail.com> Message-ID: <709de1d10705080843i5dda20b8we86443cb88364299@mail.gmail.com> Steve, First concern is that your mock objects got stubbed after it is returned by new method stub. I alway tend to prepair mock/stub completely before I use it as argument or any other way. Second is that tyou try to check that your controller's setup creates a valid product, but you use mocks, it's up to you to decide whether your model is valid or not, what it expects to receive and what it returns. It looks like you get this idea from your models specs where such a check is useful. Anyway I feel your problem is that you stub :save! but use :save that is unexpected. Could you post your controller code please (create action)? On 08/05/07, Steve Odom wrote: > Hi, > > I'm a rspec newbie. I'm having trouble with rspec'ing a simple > controller to Create a record. > > I've tried a couple of approaches and still get errors: > Mock 'remedy' expected :save! with (any args) once, but received it 0 > times > > -or- > > Mock 'Remedy' received unexpected message :save with (no args). > > Here are my two sample approaches: > > describe "Create with a valid product and authenticated user" do > controller_name :products > > before(:each) do > @product= mock(Product) > Product.stub!(:new).and_return(@product) > end > > it "should tell the Product model to create a new product" do > #mock_user_authentication(true) > Product.should_receive(:new).with(:params).and_return(@product) > post 'create', :product => :params > end > end > > describe "Create with a valid product and authenticated user with > everything in setup" do > controller_name :product > > setup do > @product= mock(:product, :null_object => true) > Product.stub!(:new).and_return(@product) > @product.should_receive(:save!).and_return(true) > #mock_user_authentication(true) > > post :create, :product => {'name' => 'a new product', > 'description' => 'an editable description', > 'user_id' => 1, 'klass' => 1} > end > > specify "should redirect to list" do > response.should redirect_to(:action => 'list') > end > > Any ideas what I am doing wrong? > > Thanks, > > Steve > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- This was freedom. Losing all hope was freedom. Chasing the beauty in programming: www.ruby-lang.org | www.rubyonrails.org From steve.odom at gmail.com Tue May 8 12:05:20 2007 From: steve.odom at gmail.com (Steve Odom) Date: Tue, 8 May 2007 11:05:20 -0500 Subject: [rspec-users] help with rspec'ing controller In-Reply-To: <709de1d10705080843i5dda20b8we86443cb88364299@mail.gmail.com> References: <42664051-65F0-4418-B047-F1CC07700E8C@gmail.com> <709de1d10705080843i5dda20b8we86443cb88364299@mail.gmail.com> Message-ID: <44E695E2-1BC0-4D77-A531-5D7D34A5105B@gmail.com> Thanks Aslak and Michael. You were both right. Changing save! to save in my second context made that test pass. Michael also mentioned... >First concern is that your mock objects got stubbed after it is >returned by new method stub. I alway tend to prepair mock/stub >completely before I use it as argument or any other way. I'm not sure what you mean by prepair mock/stub completely. Can you provide a sample of how you would rspec a simple create action, such as: def create @product = Product.new(params[:product]) if @product.save flash[:notice] = 'Product was successfully created.' redirect_to :action => 'list' else render :action => 'new' end end >Second is that tyou try to check that your controller's setup creates >a valid product, but you use mocks, it's up to you to decide whether >your model is valid or not, what it expects to receive and what it >returns. It looks like you get this idea from your models specs where >such a check is useful. I might be misunderstanding you, but I thought it was preferable to mock/stub all the ActiveRecord instances in your controller and only focus on the controller responsibilities. thanks for the help. Steve On May 8, 2007, at 10:43 AM, Michael Klishin wrote: > t -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070508/4cb7eba5/attachment.html From michael.s.klishin at gmail.com Tue May 8 13:13:21 2007 From: michael.s.klishin at gmail.com (Michael Klishin) Date: Tue, 8 May 2007 21:13:21 +0400 Subject: [rspec-users] help with rspec'ing controller In-Reply-To: <44E695E2-1BC0-4D77-A531-5D7D34A5105B@gmail.com> References: <42664051-65F0-4418-B047-F1CC07700E8C@gmail.com> <709de1d10705080843i5dda20b8we86443cb88364299@mail.gmail.com> <44E695E2-1BC0-4D77-A531-5D7D34A5105B@gmail.com> Message-ID: <709de1d10705081013w539adb95id21009be2d494252@mail.gmail.com> On 08/05/07, Steve Odom wrote: > I'm not sure what you mean by prepair mock/stub completely. Can you provide > a sample of how you would rspec a simple create action, such as: > > def create > @product = Product.new(params[:product]) > if @product.save > flash[:notice] = 'Product was successfully created.' > redirect_to :action => 'list' > else > render :action => 'new' > end > end I am still using 0.8.2 so: specify "should save valid object and redirect to list of objects" do @model = mock("model") @model.should_receive(:save).and_return(true) post :create, { :product => @model } assigns[:product].should be_instance_of(Product) # not nil and instance of right class # save call verified by mock object response.should be_redirect # redirect controller.should_redirect_to(:action => :list) # redirected to :list end specify "should redirect to new object page if instance cannot be saved" do @model = mock("model") @model.should_receive(:save).and_return(false) post :create, { :product => @model } assigns[:product].should be_instance_of(Product) # not nil and instance of right class # save call verified by mock object response.should be_redirect # redirect controller.should_redirect_to(:action => :new) # redirected to :new end > I might be misunderstanding you, but I thought it was preferable to > mock/stub all the ActiveRecord instances in your controller and only focus > on the controller responsibilities. Exactly. But no need to verify that your mock creates valid object :) If I got the idea of last example right... It was what you trying to do. -- This was freedom. Losing all hope was freedom. Chasing the beauty in programming: www.ruby-lang.org | www.rubyonrails.org From tischler at purplecoffeecup.com Wed May 9 01:06:41 2007 From: tischler at purplecoffeecup.com (Tim Tischler) Date: Wed, 9 May 2007 00:06:41 -0500 Subject: [rspec-users] UI testing framework? (w/o selenium) Message-ID: <43c39cbf0705082206v47193e27j6317b537a43cae66@mail.gmail.com> Hey all, I am currently working on coming up w/ an easy to use, developer-centric web testing framework to test a J2EE app with. (I have 3 rails apps in production, love rspec, and am currently at a java shop). I've looked at selenium, and it just doesn't seem like it is ready for prime time, and the target audience is developers. So, having said that, does the rspec community want a "functional" test framework? Are you happy w/ selenium, and is it working? Unless someone convinces me of selenium, I'm planning on taking the basics and concepts of rspec, and focus it more towards testing web applications, and am happy to contribute. My company is totally cool with contributing to open source projects if it makes sense. Any thoughts or suggestions? Here is a sketch of what I think I'd like: server "http://localhost:8080" do test '/' do page.status.should_be "200" page.should_have :image, "logo.gif" page.should_have :string, "Copyright 2006-Present SomeCo, Inc. All rights reserved." page.should_have :div, :id => 'copyright' page.should_include :css, 'default.css' page.should_have.no_broken_links page.should_have.at_least.3 :div, :class => "bbxBody" page.should_have.at_most.6 :div, :class => "someClassName" # page.[name_of_form]_form. page.search_form.submit :name => "California" do result.status.should_be :success result.should_have :image, "logo.gif" result.url.should_contain "some_page.html" end page.should_have :div, :class => 'something else' page.should_have :div, :id => 'foo', :class => 'bar' page.should_have '/div[1]/div[2]/td' end test '/some/url.html?id=35' do page.should_redirect :to => '/foobar.html' end end -- Tim Tischler ttischler at homeaway.com tischler at purplecoffeecup.com 512-565-4750 AIM:tjtischler512 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070509/1656c839/attachment.html From bob.cotton at rallydev.com Wed May 9 08:05:14 2007 From: bob.cotton at rallydev.com (Bob Cotton) Date: Wed, 09 May 2007 06:05:14 -0600 Subject: [rspec-users] UI testing framework? (w/o selenium) In-Reply-To: <43c39cbf0705082206v47193e27j6317b537a43cae66@mail.gmail.com> (Tim Tischler's message of "Wed, 9 May 2007 00:06:41 -0500") References: <43c39cbf0705082206v47193e27j6317b537a43cae66@mail.gmail.com> Message-ID: "Tim Tischler" writes: > Hey all, > > I am currently working on coming up w/ an easy to use, developer-centric > web testing framework to test a J2EE app with. (I have 3 rails apps in > production, love rspec, and am currently at a java shop). > > I've looked at selenium, and it just doesn't seem like it is ready for > prime time, and the target audience is developers. So, having said that, > does the rspec community want a "functional" test framework? Are you > happy w/ selenium, and is it working? We have re-written our functional test framework 4 times, and finally settled on Selenium. No other open-source tool gets you the cross-browser, cross-platform support. We use the Ruby bindings for Selenium-RC. > Unless someone convinces me of selenium, I'm planning on taking the basics > and concepts of rspec, and focus it more towards testing web applications, > and am happy to contribute. My company is totally cool with contributing > to open source projects if it makes sense. > Rspec sits at the core of our acceptance testing process. At the beginning of an iteration, we define our acceptance tests using rspec and product skeleton behaviors: describe "this part of the system, in these conditions" do it "should behave like this" end etc... > Any thoughts or suggestions? Here is a sketch of what I think I'd > like: > > server " http://localhost:8080" do > > test '/' do > page.status.should_be "200" > page.should_have :image, "logo.gif" > page.should_have :string, "Copyright 2006-Present SomeCo, Inc. All > rights reserved." > page.should_have :div, :id => 'copyright' [...] To me, this framework is "talking" at the wrong level of abstraction. The domain of its "language" has to do with the underlying technology, in this case HTML. Tests written at this level will be brittle and hard to maintain as the application changes. Our approach has been to build a framework that models our application and provides a language in the domain of that application, i.e. it uses the nouns and verbs of our application to provide an API for testing the app. It is in essence a Domain Specific Language for testing our application. For example, when the user creates "things" in our app, they use an "Editor", and abstraction of an HTML form. The editor framework allows you to write code that looks like this: user_page.click_create do |editor| editor.first_name = "John" editor.last_name = "Smith" end click_create handles the saving of the form (i.e. clicking save) for you. The Editor class might look something like this: class UserEditor element_accessor :first_name, element_locator("first_name") element_accessor :last_name, element_locator("last_name") end where 'element_writer' and 'element_locator' are wrappers dealing with input fields in Selenium. Then you can check the values in the form: editor.first_name.should == "John" Now your tests don't talk about HTML. -Bob From tischler at purplecoffeecup.com Wed May 9 11:23:21 2007 From: tischler at purplecoffeecup.com (Tim Tischler) Date: Wed, 9 May 2007 10:23:21 -0500 Subject: [rspec-users] UI testing framework? (w/o selenium) In-Reply-To: References: <43c39cbf0705082206v47193e27j6317b537a43cae66@mail.gmail.com> Message-ID: <43c39cbf0705090823k5b21658fpea2c2d0ad253c072@mail.gmail.com> > We have re-written our functional test framework 4 times, and finally > settled on Selenium. No other open-source tool gets you the > cross-browser, cross-platform support. > > We use the Ruby bindings for Selenium-RC. How is it working? How long did it take you from initial download of selenium to continuous integration deployment running tests and all, and how stable is it? The documentation for selenium is horrid, and we kept having our very simple tests, on multiple machines, hang indefinitely. We were primarily using the java flavor, as I hadn't sold anyone on ruby anywhere yet. Should I look again? > > To me, this framework is "talking" at the wrong level of > abstraction. The domain of its "language" has to do with the > underlying technology, in this case HTML. I hear you. At some level, you do have assertions on the HTML, right? You abstract them away into some class, but you do need to know that the, say... "left nav menu" exists on each page, right? Tests written at this level will be brittle and hard to maintain as > the application changes. Agreed. > > Now your tests don't talk about HTML. Cool, thanks. So, I'm taking it that you think I should look again at seleium, and that it's ready for prime time. I guess I'll give it a shot. Thanks, Tim -Bob > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Tim Tischler ttischler at homeaway.com tischler at purplecoffeecup.com 512-565-4750 AIM:tjtischler512 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070509/cfbf4bf7/attachment-0001.html From bob.cotton at rallydev.com Wed May 9 11:38:20 2007 From: bob.cotton at rallydev.com (Bob Cotton) Date: Wed, 09 May 2007 09:38:20 -0600 Subject: [rspec-users] UI testing framework? (w/o selenium) In-Reply-To: <43c39cbf0705090823k5b21658fpea2c2d0ad253c072@mail.gmail.com> (Tim Tischler's message of "Wed, 9 May 2007 10:23:21 -0500") References: <43c39cbf0705082206v47193e27j6317b537a43cae66@mail.gmail.com> <43c39cbf0705090823k5b21658fpea2c2d0ad253c072@mail.gmail.com> Message-ID: "Tim Tischler" writes: > We have re-written our functional test framework 4 times, and finally > settled on Selenium. No other open-source tool gets you the > cross-browser, cross-platform support. > > We use the Ruby bindings for Selenium-RC. > > How is it working? How long did it take you from initial download of > selenium to continuous integration deployment running tests and all, and > how stable is it? The documentation for selenium is horrid, and we kept > having our very simple tests, on multiple machines, hang > indefinitely. I don't know if the hanging is a result of timing issues. But they are things you have to bake into your framework. Checking to make sure that elements are present before you try to touch them. > We were primarily using the java flavor, as I hadn't sold anyone on > ruby anywhere yet. The language features of Ruby, plus things like rspec make a compelling argument. > Should I look again? I think so. > To me, this framework is "talking" at the wrong level of > abstraction. The domain of its "language" has to do with the > underlying technology, in this case HTML. > > I hear you. At some level, you do have assertions on the HTML, right? > You abstract them away into some class, but you do need to know that the, > say... "left nav menu" exists on each page, right? Yep, hide the details in the framework classes. We have a validate method that gets called on construction, that checks interesting things on the page. Then things like '"left nav menu" exists on each page' gets baked into the framework. When using Ruby, you can mix-in these sorts of things. > Cool, thanks. So, I'm taking it that you think I should look again at > seleium, and that it's ready for prime time. I guess I'll give it a shot. We've had a very good experience with it. -Bob From david.smalley.lists at googlemail.com Wed May 9 12:32:08 2007 From: david.smalley.lists at googlemail.com (David Smalley) Date: Wed, 9 May 2007 17:32:08 +0100 Subject: [rspec-users] rspec and engines Message-ID: <59CBFBA6-94D9-4A57-914D-51F24FA073DB@googlemail.com> Hi, I've got an app that has most of the functionality packaged away in a rails engine. Thats all working great but there seem to be loads of problems with running my rspecs when nearly all the app code is in the form of /vendor/plugins/plugin_name /app / controllers / models / spec / ... Just wondered if anyone on the list had a good working setup for rspec with engines and what they had to do. I've already written a custom rake task that tests the controllers/models/views of a particular plugin using rake spec:plugin:models etc. but its a terrible hack that I've put together and it'd be great if anyone had anything that looks more elegant. Cheers, David From david.smalley.lists at googlemail.com Wed May 9 12:40:04 2007 From: david.smalley.lists at googlemail.com (David Smalley) Date: Wed, 9 May 2007 17:40:04 +0100 Subject: [rspec-users] engines causing problems with mocks Message-ID: As I delve further into using engines and rspec together I am noticing more strange issues. describe "Requesting /admin/collections using get" do controller_name :admin_collections before(:each) do Collection.stub!(:paginate) end it "should return a collection of collection objects" do get 'index' response.should be_success end end Gives me this error undefined method `callback_events' for # /Users/davidsmalley/Development/incutio/skeleton/config/../vendor/ plugins/engines/lib/engines/rails_extensions/dependencies.rb:139 :in `require_or_load' ./vendor/plugins/sor_core/spec/controllers/ admin_collections_controller_spec.rb:7 137 # if we managed to load a file, return true. If not, default to the original method. 138 # Note that this relies on the RHS of a boolean || not to be evaluated if the LHS is true. 139 file_loaded || require_or_load_without_engine_additions (file_name, const_path) 140 end 141 end This looks like its coming from engines - but it could just be that engines has assumed responsibility for loading dependencies and that the error is really from rspec. Any ideas? I'm very keen to work on a project to create some rspec tasks that cater for people wanting to use it in conjunction with engines if anyone else has a similar problem. Something along the lines of being able to say: rake spec:engines:an_engine rake spec:engines:an_engine:controllers rake spec:engines:an_engine:models ... Cheers, David From dchelimsky at gmail.com Wed May 9 12:43:57 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 May 2007 11:43:57 -0500 Subject: [rspec-users] engines causing problems with mocks In-Reply-To: References: Message-ID: <57c63afe0705090943j6bd90b11v92f2de3ab46a112a@mail.gmail.com> Looks like you're using mixed versions of rspec and rspec_on_rails. before(:each) didn't really show up until 0.9, but in 0.9 there is no Spec::Runner::Specification. Make sure to follow the install instructions on http://rspec.rubyforge.org/documentation/rails/install.html, and please let us know if that helps. Cheers, David On 5/9/07, David Smalley wrote: > As I delve further into using engines and rspec together I am > noticing more strange issues. > > describe "Requesting /admin/collections using get" do > controller_name :admin_collections > > before(:each) do > Collection.stub!(:paginate) > end > > it "should return a collection of collection objects" do > get 'index' > response.should be_success > end > end > > Gives me this error > > undefined method `callback_events' for > # > /Users/davidsmalley/Development/incutio/skeleton/config/../vendor/ > plugins/engines/lib/engines/rails_extensions/dependencies.rb:139 :in > `require_or_load' > ./vendor/plugins/sor_core/spec/controllers/ > admin_collections_controller_spec.rb:7 > 137 # if we managed to load a file, return true. If not, default > to the original method. > 138 # Note that this relies on the RHS of a boolean || not to be > evaluated if the LHS is true. > 139 file_loaded || require_or_load_without_engine_additions > (file_name, const_path) > 140 end > 141 end > > This looks like its coming from engines - but it could just be that > engines has assumed responsibility for loading dependencies and that > the error is really from rspec. > > Any ideas? > > I'm very keen to work on a project to create some rspec tasks that > cater for people wanting to use it in conjunction with engines if > anyone else has a similar problem. > > Something along the lines of being able to say: > > rake spec:engines:an_engine > rake spec:engines:an_engine:controllers > rake spec:engines:an_engine:models > ... > > Cheers, > > David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From david.smalley.lists at googlemail.com Wed May 9 12:56:09 2007 From: david.smalley.lists at googlemail.com (David Smalley) Date: Wed, 9 May 2007 17:56:09 +0100 Subject: [rspec-users] engines causing problems with mocks In-Reply-To: <57c63afe0705090943j6bd90b11v92f2de3ab46a112a@mail.gmail.com> References: <57c63afe0705090943j6bd90b11v92f2de3ab46a112a@mail.gmail.com> Message-ID: Thanks David - that worked! Cheers for the quick response and helpful advice. David On 9 May 2007, at 17:43, David Chelimsky wrote: > Looks like you're using mixed versions of rspec and rspec_on_rails. > before(:each) didn't really show up until 0.9, but in 0.9 there is no > Spec::Runner::Specification. > > Make sure to follow the install instructions on > http://rspec.rubyforge.org/documentation/rails/install.html, and > please let us know if that helps. > > Cheers, > David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070509/a5b2ed45/attachment.html From dchelimsky at gmail.com Wed May 9 12:58:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 May 2007 11:58:34 -0500 Subject: [rspec-users] engines causing problems with mocks In-Reply-To: References: <57c63afe0705090943j6bd90b11v92f2de3ab46a112a@mail.gmail.com> Message-ID: <57c63afe0705090958u4c04bfa5jc477a3586afda746@mail.gmail.com> On 5/9/07, David Smalley wrote: > Thanks David - that worked! > > Cheers for the quick response and helpful advice. Glad to help when I can. Cheers > > David > > > > On 9 May 2007, at 17:43, David Chelimsky wrote: > > > Looks like you're using mixed versions of rspec and rspec_on_rails. > > before(:each) didn't really show up until 0.9, but in 0.9 there is no > > Spec::Runner::Specification. > > > > > Make sure to follow the install instructions on > > http://rspec.rubyforge.org/documentation/rails/install.html, > and > > please let us know if that helps. > > > > > Cheers, > > David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ed.howland at gmail.com Wed May 9 18:13:20 2007 From: ed.howland at gmail.com (Ed Howland) Date: Wed, 9 May 2007 17:13:20 -0500 Subject: [rspec-users] mock frameworks In-Reply-To: <276ff9870705071051j426fc2bbh6a3f9a71f3bfbd3d@mail.gmail.com> References: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> <276ff9870705071051j426fc2bbh6a3f9a71f3bfbd3d@mail.gmail.com> Message-ID: <3df642dd0705091513k67b899abuf6765b1c01b7db78@mail.gmail.com> On 5/7/07, nicholas a. evans wrote: > On 5/7/07, David Chelimsky wrote: > > Anybody planning to use any other mock framework besides rspec, mocha > > or flexmock? > > We have some tests written in test/unit and using Mocha, but we were > planning on converting it all to rspec (including rspec mocks) > eventually. Maybe we'll consider using Mocha for that code, if it > makes the conversion go more smoothly. I am echoing this. Most of my tests are in RSpec, but some legacy ones remain from before I learned about RSpec. Those Test::Unit ones used mocha/stubba. When I convereted over to rspec, I lamented my loss. Now that it is back, I rejoice! I'll finally be able to convert the remainder of the tests. Ed > > -- > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Ed Howland http://greenprogrammer.blogspot.com From aslak.hellesoy at gmail.com Thu May 10 06:39:57 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 10 May 2007 12:39:57 +0200 Subject: [rspec-users] UI testing framework? (w/o selenium) In-Reply-To: <43c39cbf0705082206v47193e27j6317b537a43cae66@mail.gmail.com> References: <43c39cbf0705082206v47193e27j6317b537a43cae66@mail.gmail.com> Message-ID: <8d961d900705100339l4ab1e7e5mfd4eda4d68512703@mail.gmail.com> On 5/9/07, Tim Tischler wrote: > Hey all, > > I am currently working on coming up w/ an easy to use, developer-centric web > testing framework to test a J2EE app with. (I have 3 rails apps in > production, love rspec, and am currently at a java shop). > One of the biggest projects in my company (BEKK Consulting) is using RSpec to drive Watir, and we have about 400 examples (it blocks). At the core of this we're using Spec::Ui, which is an RSpec extension specially designed for Watir and Selenium-RC. Spec::Ui extends the standard RSpec HTML report with: * screenshot at the time of failure * HTML source code of the browser at the time of failure These detailed reports is something the teams have become completely dependent upon. It really kicks ass. Spec::Ui also has custom RSpec matchers Watir (I haven't made any for Selenium-RC yet, but we're accepting patches). These matchers allow you to do things like this: @ie.should have_link(:url, "http://rspec.rubyforge.org") @ie.should_not have_button(:name, "delete") etc. All of Watir's "element lookup" methods have a corresponding have_* method. Spec::Ui has been in RSpec's trunk for several months (trunk/spec_ui), but I have deliberately kept mostly quiet about it because it has been somewhat immature. However, it has stabilised a lot lately, and I encourage you to take a look at it. There are examples both for Watir and Selenium-RC. See separate email releasing RSpec 0.9.4. > I've looked at selenium, and it just doesn't seem like it is ready for prime > time, and the target audience is developers. Do you think Selenium is more developer-targeted than Watir? Have you seen the FIT-style markup for Selenium? > So, having said that, does > the rspec community want a "functional" test framework? Are you happy w/ > selenium, and is it working? > I hope Spec::Ui is what you're looking for. Both Watir and Selenium-RC are working great with RSpec/Spec::Ui. There are some minor caveats with Selenium-RC on OS X though (see README.txt in the selenium example). > Unless someone convinces me of selenium, I'm planning on taking the basics > and concepts of rspec, and focus it more towards testing web applications, > and am happy to contribute. My company is totally cool with contributing to > open source projects if it makes sense. > > Any thoughts or suggestions? Here is a sketch of what I think I'd like: > > server " http://localhost:8080" do > > test '/' do > page.status.should_be "200" > page.should_have :image, "logo.gif" > page.should_have :string, "Copyright 2006-Present SomeCo, Inc. All > rights reserved." > page.should_have :div, :id => 'copyright' > > page.should_include :css, 'default.css' > > page.should_have.no_broken_links > page.should_have.at_least.3 :div, :class => "bbxBody" > page.should_have.at_most.6 :div, :class => "someClassName" > > # page.[name_of_form]_form. > page.search_form.submit :name => "California" do > result.status.should_be :success > result.should_have :image, "logo.gif" > result.url.should_contain "some_page.html" > end > > page.should_have :div, :class => 'something else' > page.should_have :div, :id => 'foo', :class => 'bar' > page.should_have '/div[1]/div[2]/td' > end > > test '/some/url.html?id=35' do > page.should_redirect :to => '/foobar.html' > end > end > This is quite similar to what Spec::Ui us doing today. The syntax is a little different for Watir and Selenium-RC, but I hope we can unify it with custom RSpec matchers with similar APIs. This should make it easier to switch transparently(ish) between Selenium-RC and Watir. I second Bob's recommendation to not use this API extensively in your own specs though, but rather implement your own domain-specific API around it and use that instead. We have also done this at the project I mentioned above, and it makes for much more readable and maintainable specs. Aslak > -- > Tim Tischler > ttischler at homeaway.com > tischler at purplecoffeecup.com > 512-565-4750 > AIM:tjtischler512 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu May 10 06:57:50 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 10 May 2007 12:57:50 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.4 Message-ID: <8d961d900705100357r5c7c217ay364039a71829e52c@mail.gmail.com> RSpec 0.9.4 has just been released. Gems haven't rsync'ed around the globe yet, so you might have to wait a few hours to install it. The big news this time is Spec::Ui 0.2.0, which has been released along with RSpec core. This RSpec extension gives you custom Watir matchers (custom Selenium-RC matchers are not implemented yet). Moreover, it comes with a custom KICK ASS formatter that, for each failing example, puts a screenshot of your browser - and its HTML source - straight into the report. And it all gets embedded into one single HTML file. Spec::Ui is not documented on the website yet (there are some READMEs and examples in the source though). But here is the gist of it: == Install == gem install rspec -r 0.9.4 gem install spec_ui -r 0.2.0 === Windows users - if you want screenshots === gem install win32screenshot Install RMagick (special install procedure) == Configure == === Rakefile === require 'spec/rake/spectask' desc "Run UI Specs" Spec::Rake::SpecTask.new('spec:ui') do |t| t.spec_files = FileList['spec/**/*.rb'] t.spec_opts = [ '--require', 'spec/spec_helper', '--format', 'Spec::Ui::ScreenshotFormatter:spec_report.html', '--format', 'progress', ] end === spec_helper.rb === # require this file from all your specs under MYAPP/spec/watir or MYAPP/spec/selenium require 'rubygems' require 'spec' require 'spec/ui' require 'spec/ui/watir' class Spec::DSL::Behaviour def before_eval # This gives us Watir matchers. Sorry - Selenium-RC users must use the low level API include Spec::Matchers::Watir end end === before and after blocks === All of your specs need some carefully designed before and after blocks: before(:all) do @browser = Watir::Browser.new #@browser = Selenium::SeleniumDriver.new("localhost", 4444, "*safari", "http://www.google.no", 10000) end after(:each) do # This is needed to make screenshots work Spec::Ui::ScreenshotFormatter.browser = @browser end after(:all) do @browser.kill! rescue nil end From aslak.hellesoy at gmail.com Thu May 10 07:53:36 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 10 May 2007 13:53:36 +0200 Subject: [rspec-users] [ANN] RSpec 0.9.4 In-Reply-To: <8d961d900705100357r5c7c217ay364039a71829e52c@mail.gmail.com> References: <8d961d900705100357r5c7c217ay364039a71829e52c@mail.gmail.com> Message-ID: <8d961d900705100453s7feb8a9fk9ecffaba69ae826d@mail.gmail.com> On 5/10/07, aslak hellesoy wrote: > RSpec 0.9.4 has just been released. Gems haven't rsync'ed around the > globe yet, so you might have to wait a few hours to install it. > > The big news this time is Spec::Ui 0.2.0, which has been released > along with RSpec core. This RSpec extension gives you custom Watir > matchers (custom Selenium-RC matchers are not implemented yet). > Moreover, it comes with a custom KICK ASS formatter that, for each > failing example, puts a screenshot of your browser - and its HTML > source - straight into the report. And it all gets embedded into one > single HTML file. > > Spec::Ui is not documented on the website yet (there are some READMEs > and examples in the source though). But here is the gist of it: > > == Install == > gem install rspec -r 0.9.4 > gem install spec_ui -r 0.2.0 > > === Windows users - if you want screenshots === > gem install win32screenshot > Install RMagick (special install procedure) > > == Configure == > > === Rakefile === > require 'spec/rake/spectask' > > desc "Run UI Specs" > Spec::Rake::SpecTask.new('spec:ui') do |t| > t.spec_files = FileList['spec/**/*.rb'] > t.spec_opts = [ > '--require', 'spec/spec_helper', > '--format', 'Spec::Ui::ScreenshotFormatter:spec_report.html', > '--format', 'progress', > ] > end > > === spec_helper.rb === > # require this file from all your specs under MYAPP/spec/watir or > MYAPP/spec/selenium > require 'rubygems' > require 'spec' > require 'spec/ui' > require 'spec/ui/watir' > > class Spec::DSL::Behaviour > def before_eval > # This gives us Watir matchers. Sorry - Selenium-RC users must use > the low level API > include Spec::Matchers::Watir > end > end > Actually, use this instead: Spec::Runner.configure do |config| config.include Spec::Matchers::Watir end I've also attached a sample report so you can see what it's all about. > === before and after blocks === > All of your specs need some carefully designed before and after blocks: > > before(:all) do > @browser = Watir::Browser.new > #@browser = Selenium::SeleniumDriver.new("localhost", 4444, > "*safari", "http://www.google.no", 10000) > end > > after(:each) do > # This is needed to make screenshots work > Spec::Ui::ScreenshotFormatter.browser = @browser > end > > after(:all) do > @browser.kill! rescue nil > end > -------------- next part -------------- A non-text attachment was scrubbed... Name: spec_report.html.gz Type: application/x-gzip Size: 251020 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070510/6f968dbc/attachment-0001.gz From ed.howland at gmail.com Thu May 10 10:37:02 2007 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 10 May 2007 09:37:02 -0500 Subject: [rspec-users] Problem with translator Message-ID: <3df642dd0705100737j7c1823c5oe6c56b18fc5a2ddd@mail.gmail.com> Hi, Just installed 0.9.4 (from 0.8 series) and ran the spec translator. It messed up specs that had the should include() where the argument to include is a string (using no parens for the arg) IOW, given: context "OldSchool" do class OldSchool attr_accessor collection def initialize @collection = [] end def add_new(item) @collection << item end end specify "should include string with '?'" do school = OldSchool.new school.add_item 'like ?' school.collection.should_include 'like ?' end end The resulting translation is: it "should include string with '?'" do school = OldSchool.new school.add_item 'like ?' school.collection.should include('like)?' end It works ok if the original line is parenthesized school.collection.should_include('like ?') Ed -- Ed Howland http://greenprogrammer.blogspot.com From greg at mydigitallife.com Thu May 10 13:02:12 2007 From: greg at mydigitallife.com (Greg Spurrier) Date: Thu, 10 May 2007 10:02:12 -0700 Subject: [rspec-users] shared descriptions -- a couple of issues Message-ID: Hello All, I've just upgraded to rspec/rspec_on_rails 0.9.3 and am very excited about shared descriptions. They couldn't have come at a better time: I just finished refactoring some REST controllers so that the bulk of the actions are inherited from a superclass. Now I can write the specs once, too. :) I've hit a couple of snags, though. I thought I'd mention them here before logging bugs or attempting to fix them myself, to make sure that I'm not missing the point somewhere. Issue 1 -- multiple inclusion of shared behaviors ======= I've put the shared descriptions in their own file and am requiring it into the files that use it. This is no problem when I run spec on an individual file, but when I do 'rake spec' or run spec on a directory, I get the error: Shared Behaviour 'foo' already exists (ArgumentError) It appears that there are no protections against pulling in the file multiple times. I've worked around this in rails for now by naming the shared file XXX_shared.rb instead of XXX_spec.rb so that the rake task doesn't pick it up, but it seems like something that should be fixed. To reproduce, create the following files: a_spec.rb --------- describe "shared", :shared => true do it "should do something" do end end b_spec.rb --------- require 'a_spec' describe "not shared" do it_should_behave_like "shared" end Now, try it out: % spec b_spec.rb . Finished in 0.018853 seconds 1 example, 0 failures % spec *_spec.rb /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/dsl/ behaviour.rb:9:in `add_shared_behaviour': Shared Behaviour 'shared' already exists (ArgumentError) from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ runner/extensions/kernel.rb:16:in `register_behaviour' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ runner/extensions/kernel.rb:4:in `describe' from ./a_spec.rb:1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:21:in `require' from ./b_spec.rb:1 from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ runner/behaviour_runner.rb:85:in `load_specs' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ runner/behaviour_runner.rb:84:in `load_specs' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ runner/behaviour_runner.rb:22:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ runner/command_line.rb:17:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/bin/spec:3 from /usr/local/bin/spec:18 Issue 2 -- Helper functions declared in shared behaviors don't work ======= I've declared a helper function in the shared behavior, but it isn't found when the shared behavior is invoked with it_should_behave_like. For example: a_spec.rb --------- describe "shared", :shared => true do def foobar 37 end it "foobar should be 37" do foobar.should == 37 end end describe "not shared" do it_should_behave_like "shared" end yields: % spec a_spec.rb F 1) NameError in 'not shared foobar should be 37' undefined local variable or method `foobar' for #<#: 0x1065188> ./a_spec.rb:7: Finished in 0.006112 seconds 1 example, 1 failure In order to get this to work, I have to declare the foobar method in the non-shared description. I imagine I can work around this by putting that method in a module and doing something like: describe "non-shared" do include SharedHelpers it_should_behave_like "shared" end but it's be much better if it would work as I'd expected it to work in the failing example. Thoughts? Comments? Am I approaching this the wrong way, or is it that shared descriptions are still a little rough around the edges? Thanks, Greg From dchelimsky at gmail.com Thu May 10 13:27:53 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 10 May 2007 12:27:53 -0500 Subject: [rspec-users] shared descriptions -- a couple of issues In-Reply-To: References: Message-ID: <57c63afe0705101027y5b91054cwbfcd18619f8b003b@mail.gmail.com> On 5/10/07, Greg Spurrier wrote: > Hello All, > > I've just upgraded to rspec/rspec_on_rails 0.9.3 and am very excited > about shared descriptions. They couldn't have come at a better time: I > just finished refactoring some REST controllers so that the bulk of > the actions are inherited from a superclass. Now I can write the > specs once, too. :) > > I've hit a couple of snags, though. I thought I'd mention them here > before logging bugs or attempting to fix them myself, to make sure > that I'm not missing the point somewhere. > > > Issue 1 -- multiple inclusion of shared behaviors > ======= > I've put the shared descriptions in their own file and am requiring it > into the files that use it. This is no problem when I run spec on an > individual file, but when I do 'rake spec' or run spec on a directory, > I get the error: > > Shared Behaviour 'foo' already exists (ArgumentError) > > It appears that there are no protections against pulling in the file > multiple times. I've worked around this in rails for now by naming > the shared file XXX_shared.rb instead of XXX_spec.rb so that the rake > task doesn't pick it up, but it seems like something that should be > fixed. > > To reproduce, create the following files: > > a_spec.rb > --------- > describe "shared", :shared => true do > it "should do something" do > end > end > > b_spec.rb > --------- > require 'a_spec' > > describe "not shared" do > it_should_behave_like "shared" > end > > Now, try it out: > > % spec b_spec.rb > . > > Finished in 0.018853 seconds > > 1 example, 0 failures > % spec *_spec.rb > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/dsl/ > behaviour.rb:9:in `add_shared_behaviour': Shared Behaviour 'shared' > already exists (ArgumentError) > from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ > runner/extensions/kernel.rb:16:in `register_behaviour' > from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ > runner/extensions/kernel.rb:4:in `describe' > from ./a_spec.rb:1 > from /usr/local/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:21:in `require' > from ./b_spec.rb:1 > from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ > runner/behaviour_runner.rb:85:in `load_specs' > from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ > runner/behaviour_runner.rb:84:in `load_specs' > from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ > runner/behaviour_runner.rb:22:in `run' > from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/ > runner/command_line.rb:17:in `run' > from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/bin/spec:3 > from /usr/local/bin/spec:18 > > > Issue 2 -- Helper functions declared in shared behaviors don't work > ======= > I've declared a helper function in the shared behavior, but it isn't > found when the shared behavior is invoked with it_should_behave_like. > For example: > > a_spec.rb > --------- > describe "shared", :shared => true do > def foobar > 37 > end > > it "foobar should be 37" do > foobar.should == 37 > end > end > > describe "not shared" do > it_should_behave_like "shared" > end > > > yields: > > % spec a_spec.rb > F > > 1) > NameError in 'not shared foobar should be 37' > undefined local variable or method `foobar' for #<#: > 0x1065188> > ./a_spec.rb:7: > > Finished in 0.006112 seconds > > 1 example, 1 failure > > In order to get this to work, I have to declare the foobar method in > the non-shared description. I imagine I can work around this by > putting that method in a module and doing something like: > > describe "non-shared" do > include SharedHelpers > it_should_behave_like "shared" > end > > but it's be much better if it would work as I'd expected it to work in > the failing example. > > > Thoughts? Comments? Am I approaching this the wrong way, or is it > that shared descriptions are still a little rough around the edges? You've got it right. Shared descriptions are brand new, so yes, still rough around the edges. Please submit RFEs for both issues (separate please). Thanks, David > > Thanks, > Greg > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From greg at mydigitallife.com Thu May 10 13:37:25 2007 From: greg at mydigitallife.com (Greg Spurrier) Date: Thu, 10 May 2007 10:37:25 -0700 Subject: [rspec-users] shared descriptions -- a couple of issues In-Reply-To: <57c63afe0705101027y5b91054cwbfcd18619f8b003b@mail.gmail.com> References: <57c63afe0705101027y5b91054cwbfcd18619f8b003b@mail.gmail.com> Message-ID: <7075BF68-D674-47C1-A8DA-FC6EC339431E@mydigitallife.com> > > You've got it right. Shared descriptions are brand new, so yes, still > rough around the edges. Please submit RFEs for both issues (separate > please). > > Thanks, > David Perfectly understandable. Will do. Greg From chris.c.hoffman at gmail.com Thu May 10 13:50:21 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Thu, 10 May 2007 13:50:21 -0400 Subject: [rspec-users] Shared behavior and_raise problem, and site aestetics Message-ID: <63c5d3820705101050l303d6f3bja6a82f9e8aa05091@mail.gmail.com> Hello, Is anyone else having trouble with the and_raise method on mocks, with respect to shared behaviors? If I do the following instead: foo.should_receive(:bar).and_return { raise } everything seems to work. I have been supplying no arguments to and_raise, by the way. Also, you may want to make the background in the code examples on the home page a little lighter. I am hardly able to read the darker-colored bits. Thanks. -Chris From aslak.hellesoy at gmail.com Thu May 10 14:37:50 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 10 May 2007 20:37:50 +0200 Subject: [rspec-users] Problem with translator In-Reply-To: <3df642dd0705100737j7c1823c5oe6c56b18fc5a2ddd@mail.gmail.com> References: <3df642dd0705100737j7c1823c5oe6c56b18fc5a2ddd@mail.gmail.com> Message-ID: <8d961d900705101137i159f494au927123b6b2140387@mail.gmail.com> On 5/10/07, Ed Howland wrote: > Hi, > > Just installed 0.9.4 (from 0.8 series) and ran the spec translator. It > messed up specs that had the should include() where the argument to > include is a string (using no parens for the arg) > > IOW, given: > context "OldSchool" do > class OldSchool > attr_accessor collection > def initialize > @collection = [] > end > def add_new(item) > @collection << item > end > end > > specify "should include string with '?'" do > school = OldSchool.new > school.add_item 'like ?' > school.collection.should_include 'like ?' > end > end > > The resulting translation is: > > it "should include string with '?'" do > school = OldSchool.new > school.add_item 'like ?' > school.collection.should include('like)?' > end > > It works ok if the original line is parenthesized > school.collection.should_include('like ?') > you can submit a patch or bug report, but we might not fix it. we're not aiming for a 100% perfect translator - just in the upper nineties. aslak > Ed > > > > > > > -- > Ed Howland > http://greenprogrammer.blogspot.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ed.howland at gmail.com Thu May 10 15:39:51 2007 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 10 May 2007 14:39:51 -0500 Subject: [rspec-users] Problem with translator In-Reply-To: <8d961d900705101137i159f494au927123b6b2140387@mail.gmail.com> References: <3df642dd0705100737j7c1823c5oe6c56b18fc5a2ddd@mail.gmail.com> <8d961d900705101137i159f494au927123b6b2140387@mail.gmail.com> Message-ID: <3df642dd0705101239x14c9d78bqdfdc0bba3143bf74@mail.gmail.com> On 5/10/07, aslak hellesoy wrote: > On 5/10/07, Ed Howland wrote: > > you can submit a patch or bug report, but we might not fix it. we're > not aiming for a 100% perfect translator - just in the upper nineties. > > aslak > I'll do a bug report. A note in the docs about this one should suffice for now. Just say your "should include args" the args to include should be parenthesized. Ed -- Ed Howland http://greenprogrammer.blogspot.com From aslak.hellesoy at gmail.com Thu May 10 16:35:22 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 10 May 2007 22:35:22 +0200 Subject: [rspec-users] Shared behavior and_raise problem, and site aestetics In-Reply-To: <63c5d3820705101050l303d6f3bja6a82f9e8aa05091@mail.gmail.com> References: <63c5d3820705101050l303d6f3bja6a82f9e8aa05091@mail.gmail.com> Message-ID: <8d961d900705101335h73443046i1ef5d0354013e6d9@mail.gmail.com> On 5/10/07, Chris Hoffman wrote: > Hello, > Is anyone else having trouble with the and_raise method on mocks, > with respect to shared behaviors? If I do the following instead: > > foo.should_receive(:bar).and_return { raise } > > everything seems to work. I have been supplying no arguments to > and_raise, by the way. > please supply an example that illustrates your case. one that we can execute. > Also, you may want to make the background in the code examples on the > home page a little lighter. I am hardly able to read the > darker-colored bits. > what colour (hexcode) would be better? aslak > Thanks. > > -Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sldowney at berkeley.edu Thu May 10 22:58:43 2007 From: sldowney at berkeley.edu (Steve Downey) Date: Thu, 10 May 2007 19:58:43 -0700 Subject: [rspec-users] [Somewhat OT] Integrating RSpec and RCov results in Gem's RDoc Message-ID: <4643DBE3.6080403@berkeley.edu> I have a Gem on which the testing is done with RSpec. I would like to include the results of RSpec and the RCov html files in the RDoc. The problem is that when I have RDoc include the files, it winds up escaping all the html. Is there a way to get HTML into RDoc unprocessed? Or is there some other way I can distribute the RSpec/RCov results with my Gem integrated with RDoc? I can include them in the Gem spec, but that doesn't get them into RDoc. Thanks, Steve From mailing_lists at railsnewbie.com Fri May 11 02:47:05 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 11 May 2007 02:47:05 -0400 Subject: [rspec-users] rubyforge svn access Message-ID: <22C664FE-4EE8-4102-9669-2F43AE2F4F39@railsnewbie.com> Is anyone else having intermittent svn access with rspec? Occasionally I'm getting: euclid% svn update svn: Connection closed unexpectedly Scott From aslak.hellesoy at gmail.com Fri May 11 03:00:43 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 11 May 2007 09:00:43 +0200 Subject: [rspec-users] [Somewhat OT] Integrating RSpec and RCov results in Gem's RDoc In-Reply-To: <4643DBE3.6080403@berkeley.edu> References: <4643DBE3.6080403@berkeley.edu> Message-ID: <8d961d900705110000k66027985h4260c006f4792f20@mail.gmail.com> On 5/11/07, Steve Downey wrote: > I have a Gem on which the testing is done with RSpec. I would like to > include the results of RSpec and the RCov html files in the RDoc. > > The problem is that when I have RDoc include the files, it winds up > escaping all the html. Is there a way to get HTML into RDoc > unprocessed? Or is there some other way I can distribute the RSpec/RCov > results with my Gem integrated with RDoc? I can include them in the Gem > spec, but that doesn't get them into RDoc. > I have no idea. I'd ask on ruby-talk. Aslak > Thanks, > Steve > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chandrahasanreddy.k at hotmail.com Fri May 11 03:20:13 2007 From: chandrahasanreddy.k at hotmail.com (Chandrahas Reddy) Date: Fri, 11 May 2007 07:20:13 +0000 Subject: [rspec-users] rubyforge svn access Message-ID: svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_4/rspec_on_rails. You Can use this URL through svn checkout... ---------------------------------------- > To: rspec-users at rubyforge.org > From: mailing_lists at railsnewbie.com > Date: Fri, 11 May 2007 02:47:05 -0400 > Subject: [rspec-users] rubyforge svn access > > > Is anyone else having intermittent svn access with rspec? > Occasionally I'm getting: > > euclid% svn update > svn: Connection closed unexpectedly > > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users _________________________________________________________________ Want to look great? Get expert opinion on beauty and skin care. http://content.msn.co.in/Lifestyle/AskExpert/Default01.htm From mailing_lists at railsnewbie.com Fri May 11 03:44:36 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 11 May 2007 03:44:36 -0400 Subject: [rspec-users] rubyforge svn access In-Reply-To: References: Message-ID: <3ADD4A9E-5CBA-4840-939A-23B6EADDAA9F@railsnewbie.com> Yep. That's the url I'm using (see below). My guess is that it is a rubyforge problem. I'll file a bug report with them if it persists until tomorrow. I'm pretty sure its not my connection, as the mirror that I've set up had the same problem, and was a few revisions behind. Scott euclid% svn info Path: . URL: svn://rubyforge.org/var/svn/rspec/trunk Repository Root: svn://rubyforge.org/var/svn/rspec Repository UUID: 410327ef-2207-0410-a325-f78bbcb22a5a Revision: 1942 Node Kind: directory Schedule: normal Last Changed Author: dchelimsky Last Changed Rev: 1942 Last Changed Date: 2007-05-10 21:25:18 -0400 (Thu, 10 May 2007) euclid% svn update svn: Connection closed unexpectedly On May 11, 2007, at 3:20 AM, Chandrahas Reddy wrote: > > svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_4/rspec_on_rails. > You Can use this URL through svn checkout... > > > > > > ---------------------------------------- >> To: rspec-users at rubyforge.org >> From: mailing_lists at railsnewbie.com >> Date: Fri, 11 May 2007 02:47:05 -0400 >> Subject: [rspec-users] rubyforge svn access >> >> >> Is anyone else having intermittent svn access with rspec? >> Occasionally I'm getting: >> >> euclid% svn update >> svn: Connection closed unexpectedly >> >> >> Scott >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _________________________________________________________________ > Want to look great? Get expert opinion on beauty and skin care. > http://content.msn.co.in/Lifestyle/AskExpert/Default01.htm > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Fri May 11 03:48:10 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 11 May 2007 09:48:10 +0200 Subject: [rspec-users] rubyforge svn access In-Reply-To: <3ADD4A9E-5CBA-4840-939A-23B6EADDAA9F@railsnewbie.com> References: <3ADD4A9E-5CBA-4840-939A-23B6EADDAA9F@railsnewbie.com> Message-ID: <8d961d900705110048r1c18d752ob223967f70cfcde4@mail.gmail.com> On 5/11/07, Scott Taylor wrote: > > Yep. That's the url I'm using (see below). My guess is that it is a > rubyforge problem. I'll file a bug report with them if it persists > until tomorrow. I'm pretty sure its not my connection, as the mirror > that I've set up had the same problem, and was a few revisions behind. > > Scott > Please direct any questions about Rubyforge infrastructure to the Rubyforge team. There is nothing we can do about it, Aslak > > euclid% svn info > Path: . > URL: svn://rubyforge.org/var/svn/rspec/trunk > Repository Root: svn://rubyforge.org/var/svn/rspec > Repository UUID: 410327ef-2207-0410-a325-f78bbcb22a5a > Revision: 1942 > Node Kind: directory > Schedule: normal > Last Changed Author: dchelimsky > Last Changed Rev: 1942 > Last Changed Date: 2007-05-10 21:25:18 -0400 (Thu, 10 May 2007) > > euclid% svn update > svn: Connection closed unexpectedly > > > > > On May 11, 2007, at 3:20 AM, Chandrahas Reddy wrote: > > > > > svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_4/rspec_on_rails. > > You Can use this URL through svn checkout... > > > > > > > > > > > > ---------------------------------------- > >> To: rspec-users at rubyforge.org > >> From: mailing_lists at railsnewbie.com > >> Date: Fri, 11 May 2007 02:47:05 -0400 > >> Subject: [rspec-users] rubyforge svn access > >> > >> > >> Is anyone else having intermittent svn access with rspec? > >> Occasionally I'm getting: > >> > >> euclid% svn update > >> svn: Connection closed unexpectedly > >> > >> > >> Scott > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > _________________________________________________________________ > > Want to look great? Get expert opinion on beauty and skin care. > > http://content.msn.co.in/Lifestyle/AskExpert/Default01.htm > > _______________________________________________ > > 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 mlangenberg at gmail.com Fri May 11 05:12:22 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Fri, 11 May 2007 11:12:22 +0200 Subject: [rspec-users] spec a replace_html with a partial Message-ID: <27c0ac6d0705110212pa90035fs108541e330c2bd9a@mail.gmail.com> I wanted to use ARTS to add RJS in a behaviour driven way to my application, but I'm having some trouble asserting a replace_html with a partial. I've created a pastie (http://pastie.caboo.se/60694) which contains the RJS I want to spec, the spec which I already wrote and its failure message. I'm currently using RSpec-0.9.2 From mlangenberg at gmail.com Fri May 11 05:30:52 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Fri, 11 May 2007 11:30:52 +0200 Subject: [rspec-users] spec a replace_html with a partial In-Reply-To: <27c0ac6d0705110212pa90035fs108541e330c2bd9a@mail.gmail.com> References: <27c0ac6d0705110212pa90035fs108541e330c2bd9a@mail.gmail.com> Message-ID: <27c0ac6d0705110230g700dfa42g843671d7c897e494@mail.gmail.com> I've replaced the mock model with a real AR object, but the spec is still failing: ==== Changed spec: require File.dirname(__FILE__) + '/../../spec_helper' describe "/pos_orderlines/create.rjs" do before(:each) do @orderlines = [stub('orderlines', :to_param => "2", :item => stub('item', :description => 'an item', :price => 10))] @order = stub('order', :id => 1, :pos_orderlines => @orderlines, :total_price => 10, :payments => stub('payments', :empty? => true)) @the_order = PosOrder.create! assigns[:order] = @the_order end it "should replace orderlines div" do render "/pos_orderlines/create.rjs" assert_rjs :replace_html, :orderlines, :partial => 'pos_orders/orderlines', :locals => { :order => @the_order } end end ==== failes with: Test::Unit::AssertionFailedError in '/pos_orderlines/create.rjs should replace orderlines div' No replace_html call found on div: 'orderlines' and content: {partial: "pos_orders/orderlines", locals: {order: {items: [], payments: [], errors: [], attributes: {id: 65, state: "open", created_at: {}}, new_record_before_save: true, new_record: false, pos_orderlines: []}}} in response: Element.update("orderlines", "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n
descriptionprice
Total$0.00
");. is not true. ==== Any ideas? On 5/11/07, Matthijs Langenberg wrote: > I wanted to use ARTS to add RJS in a behaviour driven way to my > application, but I'm having some trouble asserting a replace_html with > a partial. > I've created a pastie (http://pastie.caboo.se/60694) which contains > the RJS I want to spec, the spec which I already wrote and its failure > message. > > I'm currently using RSpec-0.9.2 > From chris.c.hoffman at gmail.com Fri May 11 07:14:29 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 11 May 2007 07:14:29 -0400 Subject: [rspec-users] Shared behavior and_raise problem, and site aestetics In-Reply-To: <8d961d900705101335h73443046i1ef5d0354013e6d9@mail.gmail.com> References: <63c5d3820705101050l303d6f3bja6a82f9e8aa05091@mail.gmail.com> <8d961d900705101335h73443046i1ef5d0354013e6d9@mail.gmail.com> Message-ID: <63c5d3820705110414p181c8ce3uf8dbf49aeedbde85@mail.gmail.com> I was thinking that just a gray would suffice, such as #BBBBBB . As far as the raise problem, I will submit a proper bug with executable code. -Chris On 5/10/07, aslak hellesoy wrote: > On 5/10/07, Chris Hoffman wrote: > > Hello, > > Is anyone else having trouble with the and_raise method on mocks, > > with respect to shared behaviors? If I do the following instead: > > > > foo.should_receive(:bar).and_return { raise } > > > > everything seems to work. I have been supplying no arguments to > > and_raise, by the way. > > > > please supply an example that illustrates your case. one that we can execute. > > > Also, you may want to make the background in the code examples on the > > home page a little lighter. I am hardly able to read the > > darker-colored bits. > > > > what colour (hexcode) would be better? > > aslak > > > Thanks. > > > > -Chris > > _______________________________________________ > > 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 May 11 07:35:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 May 2007 06:35:30 -0500 Subject: [rspec-users] spec a replace_html with a partial In-Reply-To: <27c0ac6d0705110230g700dfa42g843671d7c897e494@mail.gmail.com> References: <27c0ac6d0705110212pa90035fs108541e330c2bd9a@mail.gmail.com> <27c0ac6d0705110230g700dfa42g843671d7c897e494@mail.gmail.com> Message-ID: <57c63afe0705110435n225cd104p77269379647c61c9@mail.gmail.com> On 5/11/07, Matthijs Langenberg wrote: > I've replaced the mock model with a real AR object, but the spec is > still failing: > ==== Changed spec: > require File.dirname(__FILE__) + '/../../spec_helper' > > describe "/pos_orderlines/create.rjs" do > > before(:each) do > @orderlines = [stub('orderlines', :to_param => "2", :item => > stub('item', :description => 'an item', :price => 10))] > @order = stub('order', :id => 1, :pos_orderlines => @orderlines, > :total_price => 10, :payments => stub('payments', :empty? => true)) > > @the_order = PosOrder.create! > assigns[:order] = @the_order > end > > it "should replace orderlines div" do > render "/pos_orderlines/create.rjs" > assert_rjs :replace_html, :orderlines, :partial => > 'pos_orders/orderlines', :locals => { :order => @the_order } > end > > end Looking at http://glu.ttono.us/articles/2006/05/29/guide-test-driven-rjs-with-arts, you need to do an xhr request, which isn't supported yet in view specs. Please try doing the same thing in a controller spec using integrate_views and do the request using xhr and see if that works. In the mean time I'll submit an RFE to support this directly in view specs. > > ==== failes with: > Test::Unit::AssertionFailedError in '/pos_orderlines/create.rjs should > replace orderlines div' > No replace_html call found on div: 'orderlines' and content: > {partial: "pos_orders/orderlines", locals: {order: {items: [], > payments: [], errors: [], attributes: {id: 65, state: "open", > created_at: {}}, new_record_before_save: true, new_record: false, > pos_orderlines: []}}} > in response: > Element.update("orderlines", " id=\"orderlines\">\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\n
description class=\"price\">price
class=\"total\">Total class=\"price\">$0.00
");. > is not true. > ==== > > Any ideas? > > > On 5/11/07, Matthijs Langenberg wrote: > > I wanted to use ARTS to add RJS in a behaviour driven way to my > > application, but I'm having some trouble asserting a replace_html with > > a partial. > > I've created a pastie (http://pastie.caboo.se/60694) which contains > > the RJS I want to spec, the spec which I already wrote and its failure > > message. > > > > I'm currently using RSpec-0.9.2 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris.c.hoffman at gmail.com Fri May 11 09:34:25 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 11 May 2007 09:34:25 -0400 Subject: [rspec-users] Shared behavior and_raise problem, and site aestetics In-Reply-To: <63c5d3820705110414p181c8ce3uf8dbf49aeedbde85@mail.gmail.com> References: <63c5d3820705101050l303d6f3bja6a82f9e8aa05091@mail.gmail.com> <8d961d900705101335h73443046i1ef5d0354013e6d9@mail.gmail.com> <63c5d3820705110414p181c8ce3uf8dbf49aeedbde85@mail.gmail.com> Message-ID: <63c5d3820705110634u181d93aata132f40911d5969@mail.gmail.com> Okay, so maybe it is just my nascence with respect to Ruby. Why do you call Kernel::raise as opposed to just raise in vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb Thanks for helping me along with this problem. -Chris On 5/11/07, Chris Hoffman wrote: > I was thinking that just a gray would suffice, such as #BBBBBB . As > far as the raise problem, I will submit a proper bug with executable > code. > > -Chris > > On 5/10/07, aslak hellesoy wrote: > > On 5/10/07, Chris Hoffman wrote: > > > Hello, > > > Is anyone else having trouble with the and_raise method on mocks, > > > with respect to shared behaviors? If I do the following instead: > > > > > > foo.should_receive(:bar).and_return { raise } > > > > > > everything seems to work. I have been supplying no arguments to > > > and_raise, by the way. > > > > > > > please supply an example that illustrates your case. one that we can execute. > > > > > Also, you may want to make the background in the code examples on the > > > home page a little lighter. I am hardly able to read the > > > darker-colored bits. > > > > > > > what colour (hexcode) would be better? > > > > aslak > > > > > Thanks. > > > > > > -Chris > > > _______________________________________________ > > > 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 May 11 09:38:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 May 2007 08:38:45 -0500 Subject: [rspec-users] Shared behavior and_raise problem, and site aestetics In-Reply-To: <63c5d3820705110634u181d93aata132f40911d5969@mail.gmail.com> References: <63c5d3820705101050l303d6f3bja6a82f9e8aa05091@mail.gmail.com> <8d961d900705101335h73443046i1ef5d0354013e6d9@mail.gmail.com> <63c5d3820705110414p181c8ce3uf8dbf49aeedbde85@mail.gmail.com> <63c5d3820705110634u181d93aata132f40911d5969@mail.gmail.com> Message-ID: <57c63afe0705110638r6cd2128xacf896b1d29ad71b@mail.gmail.com> On 5/11/07, Chris Hoffman wrote: > Okay, so maybe it is just my nascence with respect to Ruby. Why do > you call Kernel::raise as opposed to just raise in > vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb That's actually left over from when the matcher was "should raise" instead of "should raise_error". The reason at that time because we were defining a different raise method. At this point, it could probably just call raise, though that invokes Kernel#raise, so there's no harm in having it explicit. > > Thanks for helping me along with this problem. > > -Chris > > On 5/11/07, Chris Hoffman wrote: > > I was thinking that just a gray would suffice, such as #BBBBBB . As > > far as the raise problem, I will submit a proper bug with executable > > code. > > > > -Chris > > > > On 5/10/07, aslak hellesoy wrote: > > > On 5/10/07, Chris Hoffman wrote: > > > > Hello, > > > > Is anyone else having trouble with the and_raise method on mocks, > > > > with respect to shared behaviors? If I do the following instead: > > > > > > > > foo.should_receive(:bar).and_return { raise } > > > > > > > > everything seems to work. I have been supplying no arguments to > > > > and_raise, by the way. > > > > > > > > > > please supply an example that illustrates your case. one that we can execute. > > > > > > > Also, you may want to make the background in the code examples on the > > > > home page a little lighter. I am hardly able to read the > > > > darker-colored bits. > > > > > > > > > > what colour (hexcode) would be better? > > > > > > aslak > > > > > > > Thanks. > > > > > > > > -Chris > > > > _______________________________________________ > > > > 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 chris.c.hoffman at gmail.com Fri May 11 11:43:09 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 11 May 2007 11:43:09 -0400 Subject: [rspec-users] Shared behavior and_raise problem, and site aestetics In-Reply-To: <57c63afe0705110638r6cd2128xacf896b1d29ad71b@mail.gmail.com> References: <63c5d3820705101050l303d6f3bja6a82f9e8aa05091@mail.gmail.com> <8d961d900705101335h73443046i1ef5d0354013e6d9@mail.gmail.com> <63c5d3820705110414p181c8ce3uf8dbf49aeedbde85@mail.gmail.com> <63c5d3820705110634u181d93aata132f40911d5969@mail.gmail.com> <57c63afe0705110638r6cd2128xacf896b1d29ad71b@mail.gmail.com> Message-ID: <63c5d3820705110843n23d73d70x15ac5a3fbebd3fd@mail.gmail.com> Well, I can't reproduce the problem outside of my code base, so I'm guessing something is just funky with how I am setting up mocks, or some such. I will keep an eye on it. For now I am plowing blindly ahead, as I have soaked up enough time trying to decipher the problem. -Chris On 5/11/07, David Chelimsky wrote: > On 5/11/07, Chris Hoffman wrote: > > Okay, so maybe it is just my nascence with respect to Ruby. Why do > > you call Kernel::raise as opposed to just raise in > > vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb > > That's actually left over from when the matcher was "should raise" > instead of "should raise_error". The reason at that time because we > were defining a different raise method. At this point, it could > probably just call raise, though that invokes Kernel#raise, so there's > no harm in having it explicit. > > > > > Thanks for helping me along with this problem. > > > > -Chris > > > > On 5/11/07, Chris Hoffman wrote: > > > I was thinking that just a gray would suffice, such as #BBBBBB . As > > > far as the raise problem, I will submit a proper bug with executable > > > code. > > > > > > -Chris > > > > > > On 5/10/07, aslak hellesoy wrote: > > > > On 5/10/07, Chris Hoffman wrote: > > > > > Hello, > > > > > Is anyone else having trouble with the and_raise method on mocks, > > > > > with respect to shared behaviors? If I do the following instead: > > > > > > > > > > foo.should_receive(:bar).and_return { raise } > > > > > > > > > > everything seems to work. I have been supplying no arguments to > > > > > and_raise, by the way. > > > > > > > > > > > > > please supply an example that illustrates your case. one that we can execute. > > > > > > > > > Also, you may want to make the background in the code examples on the > > > > > home page a little lighter. I am hardly able to read the > > > > > darker-colored bits. > > > > > > > > > > > > > what colour (hexcode) would be better? > > > > > > > > aslak > > > > > > > > > Thanks. > > > > > > > > > > -Chris > > > > > _______________________________________________ > > > > > 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 malavoi at gmail.com Fri May 11 15:56:33 2007 From: malavoi at gmail.com (Bolo) Date: Fri, 11 May 2007 15:56:33 -0400 Subject: [rspec-users] tutorial Message-ID: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> Hello, Hello Where i can found a good tutorial about Rspec ? thanks From cwdinfo at gmail.com Fri May 11 16:18:18 2007 From: cwdinfo at gmail.com (s.ross) Date: Fri, 11 May 2007 13:18:18 -0700 Subject: [rspec-users] tutorial In-Reply-To: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> Message-ID: <102E287A-81F9-4254-A2AE-E778639AF8EC@gmail.com> I don't know if it's good, but I wrote some blog entries on http:// calicowebdev.com/blog. It's pretty Rails-centric. On May 11, 2007, at 12:56 PM, Bolo wrote: > Hello, Hello > > Where i can found a good tutorial about Rspec ? > > thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From malavoi at gmail.com Fri May 11 16:26:23 2007 From: malavoi at gmail.com (Bolo) Date: Fri, 11 May 2007 16:26:23 -0400 Subject: [rspec-users] tutorial In-Reply-To: <102E287A-81F9-4254-A2AE-E778639AF8EC@gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <102E287A-81F9-4254-A2AE-E778639AF8EC@gmail.com> Message-ID: Thanks for your answer. You tuto is for newbee ? Le 11 mai 07 ? 16:18, s.ross a ?crit : > I don't know if it's good, but I wrote some blog entries on http:// > calicowebdev.com/blog. It's pretty Rails-centric. > > On May 11, 2007, at 12:56 PM, Bolo wrote: > >> Hello, Hello >> >> Where i can found a good tutorial about Rspec ? >> >> thanks >> _______________________________________________ >> 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 May 11 16:29:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 May 2007 15:29:55 -0500 Subject: [rspec-users] tutorial In-Reply-To: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> Message-ID: <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> On 5/11/07, Bolo wrote: > Hello, Hello > > Where i can found a good tutorial about Rspec ? There used to be a tutorial on rspec.rubyforge.org, but I yanked it because it got outdated in syntax and philosophy. There will be another sooner or later - probably later (sorry). > > thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Fri May 11 16:30:41 2007 From: cwdinfo at gmail.com (s.ross) Date: Fri, 11 May 2007 13:30:41 -0700 Subject: [rspec-users] tutorial In-Reply-To: References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <102E287A-81F9-4254-A2AE-E778639AF8EC@gmail.com> Message-ID: <859F1249-A4E4-4325-82F8-33C8272B10CA@gmail.com> If you're a noob, I'll leave that up to you to decide. On May 11, 2007, at 1:26 PM, Bolo wrote: > Thanks for your answer. > > You tuto is for newbee ? > > Le 11 mai 07 ? 16:18, s.ross a ?crit : > >> I don't know if it's good, but I wrote some blog entries on http:// >> calicowebdev.com/blog. It's pretty Rails-centric. >> >> On May 11, 2007, at 12:56 PM, Bolo wrote: >> >>> Hello, Hello >>> >>> Where i can found a good tutorial about Rspec ? >>> >>> thanks >>> _______________________________________________ >>> 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 malavoi at gmail.com Fri May 11 16:33:11 2007 From: malavoi at gmail.com (Bolo) Date: Fri, 11 May 2007 16:33:11 -0400 Subject: [rspec-users] tutorial In-Reply-To: <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> Message-ID: <23F268DE-42A4-45E7-A8F7-ED9D2300FCC4@gmail.com> Le 11 mai 07 ? 16:29, David Chelimsky a ?crit : > On 5/11/07, Bolo wrote: >> Hello, Hello >> >> Where i can found a good tutorial about Rspec ? > > There used to be a tutorial on rspec.rubyforge.org, but I yanked it > because it got outdated in syntax and philosophy. There will be > another sooner or later - probably later (sorry). not too late, I hope :) > >> >> thanks >> _______________________________________________ >> 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 mailing_lists at railsnewbie.com Fri May 11 17:09:24 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 11 May 2007 17:09:24 -0400 Subject: [rspec-users] tutorial In-Reply-To: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> Message-ID: <13C46D5C-7F65-43E5-82D7-0A3547269027@railsnewbie.com> What happened to the stack tutorial that used to be on the rspec website? I thought that was a pretty good intro. Scott On May 11, 2007, at 3:56 PM, Bolo wrote: > Hello, Hello > > Where i can found a good tutorial about Rspec ? > > thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Fri May 11 17:20:05 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 11 May 2007 17:20:05 -0400 Subject: [rspec-users] tutorial In-Reply-To: <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> Message-ID: <367FAC3E-EB31-40B2-A9FA-D2733194B459@railsnewbie.com> I'd update it. Is it still in the webgen source tree? Scott On May 11, 2007, at 4:29 PM, David Chelimsky wrote: > On 5/11/07, Bolo wrote: >> Hello, Hello >> >> Where i can found a good tutorial about Rspec ? > > There used to be a tutorial on rspec.rubyforge.org, but I yanked it > because it got outdated in syntax and philosophy. There will be > another sooner or later - probably later (sorry). > >> >> thanks >> _______________________________________________ >> 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 May 11 17:27:57 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 May 2007 16:27:57 -0500 Subject: [rspec-users] tutorial In-Reply-To: <367FAC3E-EB31-40B2-A9FA-D2733194B459@railsnewbie.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> <367FAC3E-EB31-40B2-A9FA-D2733194B459@railsnewbie.com> Message-ID: <57c63afe0705111427g77c93e82ra2218c39d0eea9cd@mail.gmail.com> On 5/11/07, Scott Taylor wrote: > > I'd update it. Is it still in the webgen source tree? That's a really generous offer Scott, but I'd just as soon let that dog rest in peace and replace it with something that is more up to date in philosophy as well as syntax. > > Scott > > > On May 11, 2007, at 4:29 PM, David Chelimsky wrote: > > > On 5/11/07, Bolo wrote: > >> Hello, Hello > >> > >> Where i can found a good tutorial about Rspec ? > > > > There used to be a tutorial on rspec.rubyforge.org, but I yanked it > > because it got outdated in syntax and philosophy. There will be > > another sooner or later - probably later (sorry). > > > >> > >> thanks > >> _______________________________________________ > >> 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 mailing_lists at railsnewbie.com Fri May 11 18:00:11 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 11 May 2007 18:00:11 -0400 Subject: [rspec-users] tutorial In-Reply-To: <57c63afe0705111427g77c93e82ra2218c39d0eea9cd@mail.gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> <367FAC3E-EB31-40B2-A9FA-D2733194B459@railsnewbie.com> <57c63afe0705111427g77c93e82ra2218c39d0eea9cd@mail.gmail.com> Message-ID: <300BBDF6-73AA-4D3E-9EBB-9A3A4286B161@railsnewbie.com> On May 11, 2007, at 5:27 PM, David Chelimsky wrote: > On 5/11/07, Scott Taylor wrote: >> >> I'd update it. Is it still in the webgen source tree? > > That's a really generous offer Scott, but I'd just as soon let that > dog rest in peace and replace it with something that is more up to > date in philosophy as well as syntax. What in philosophy has changed? Scott From dchelimsky at gmail.com Fri May 11 18:05:23 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 11 May 2007 17:05:23 -0500 Subject: [rspec-users] tutorial In-Reply-To: <300BBDF6-73AA-4D3E-9EBB-9A3A4286B161@railsnewbie.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <57c63afe0705111329m51a68038x191299dca2cc652c@mail.gmail.com> <367FAC3E-EB31-40B2-A9FA-D2733194B459@railsnewbie.com> <57c63afe0705111427g77c93e82ra2218c39d0eea9cd@mail.gmail.com> <300BBDF6-73AA-4D3E-9EBB-9A3A4286B161@railsnewbie.com> Message-ID: <57c63afe0705111505l4ac0c6b3waa59c12345d71618@mail.gmail.com> On 5/11/07, Scott Taylor wrote: > > On May 11, 2007, at 5:27 PM, David Chelimsky wrote: > > > On 5/11/07, Scott Taylor wrote: > >> > >> I'd update it. Is it still in the webgen source tree? > > > > That's a really generous offer Scott, but I'd just as soon let that > > dog rest in peace and replace it with something that is more up to > > date in philosophy as well as syntax. > > What in philosophy has changed? Too much focus on context. That's one approach. ObjectMother is another approach. Both have value and should get equal time. I'm sure there are other things as well - but that's one issue. > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Fri May 11 22:09:34 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 11 May 2007 22:09:34 -0400 Subject: [rspec-users] accessing the session after a request Message-ID: <403FA08E-614A-4853-924A-9A2DF3AA9E02@railsnewbie.com> Is there an easier way to access the session *after* the request then this: assigns[:_session] ? Scott From mailing_lists at railsnewbie.com Sat May 12 04:34:36 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 12 May 2007 04:34:36 -0400 Subject: [rspec-users] [OT] - In Memory Databases Message-ID: <18D3C862-12E3-4878-8B3D-B010A45C204F@railsnewbie.com> My specs are still taking to long to run in a rails app. Is anyone using an in-memory database to run their specs? Any pointers or tips? Scott From chris.c.hoffman at gmail.com Sat May 12 09:53:03 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Sat, 12 May 2007 09:53:03 -0400 Subject: [rspec-users] Custom form fields in tracker? Message-ID: <63c5d3820705120653n9a73fc0l579ae139b9889642@mail.gmail.com> Hello, I was just reading the following bug ticket: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10744&group_id=797 I notice that you devs have to repeat yourselves quite a bit about requiring the different types of data that are required to diagnose bugs. Could you modify the RubyForge tracker to accommodate this information? You could even make them all required fields or something, so that you can be assured that you get the adequate information. Just a thought. -Chris From dchelimsky at gmail.com Sat May 12 11:32:35 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 12 May 2007 10:32:35 -0500 Subject: [rspec-users] Custom form fields in tracker? In-Reply-To: <63c5d3820705120653n9a73fc0l579ae139b9889642@mail.gmail.com> References: <63c5d3820705120653n9a73fc0l579ae139b9889642@mail.gmail.com> Message-ID: <57c63afe0705120832l72935b35x2e730a40388731d0@mail.gmail.com> On 5/12/07, Chris Hoffman wrote: > Hello, > I was just reading the following bug ticket: > > http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10744&group_id=797 > > I notice that you devs have to repeat yourselves quite a bit about > requiring the different types of data that are required to diagnose > bugs. Could you modify the RubyForge tracker to accommodate this > information? You could even make them all required fields or > something, so that you can be assured that you get the adequate > information. I don't believe that we have the ability to make any of them required. Even if we did, I think that requiring 5 or 6 additional fields would turn people off from submitting more than the occasional "we don't have enough info" email. Not to mention the fact that we'd have to update the options in each one every release (more management for us). So really, sending a canned response is the simplest, most flexible way for us to deal with this issue. Thanks for your concern though! Cheers, David > > Just a thought. > -Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeff at jefdean.com Sat May 12 11:34:44 2007 From: jeff at jefdean.com (Jeff Dean) Date: Sat, 12 May 2007 11:34:44 -0400 Subject: [rspec-users] [OT] - In Memory Databases In-Reply-To: <18D3C862-12E3-4878-8B3D-B010A45C204F@railsnewbie.com> References: <18D3C862-12E3-4878-8B3D-B010A45C204F@railsnewbie.com> Message-ID: <6586e070705120834i640e3ea1l8fa789e5727c4e2@mail.gmail.com> Are you using mocks/stubs for the controllers and views? This has made the biggest difference in my specs. The other thing that's sped up my specs is making sure I'm only loading fixtures for the specs that absolutely need it on the models. But no - I've never used in-memory databases, so I can't help you there. On 5/12/07, Scott Taylor wrote: > > > My specs are still taking to long to run in a rails app. Is anyone > using an in-memory database to run their specs? Any pointers or tips? > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070512/40144a24/attachment.html From mailing_lists at railsnewbie.com Sat May 12 17:14:33 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 12 May 2007 17:14:33 -0400 Subject: [rspec-users] [OT] - In Memory Databases In-Reply-To: <6586e070705120834i640e3ea1l8fa789e5727c4e2@mail.gmail.com> References: <18D3C862-12E3-4878-8B3D-B010A45C204F@railsnewbie.com> <6586e070705120834i640e3ea1l8fa789e5727c4e2@mail.gmail.com> Message-ID: Is there someway to remove all fixture processing? Can I set the following two lines in spec_helper.rb to remove all fixture processing ? config.use_transactional_fixtures = false config.use_instantiated_fixtures = false I was actually able to setup a sqlite in-memory database without a problem, using topfunky's plugin. Even with drb, mocks & stubs, and an in-memory database, and no (used) fixtures, things seem to be quite slow. Maybe this is more of a reflection on my aged Mac than anything else... I think the real bottleneck is occurring in rake. I'll have to checkout a profiler. Thanks, Scott On May 12, 2007, at 11:34 AM, Jeff Dean wrote: > Are you using mocks/stubs for the controllers and views? This has > made the biggest difference in my specs. The other thing that's > sped up my specs is making sure I'm only loading fixtures for the > specs that absolutely need it on the models. > > But no - I've never used in-memory databases, so I can't help you > there. > > On 5/12/07, Scott Taylor < mailing_lists at railsnewbie.com> wrote: > My specs are still taking to long to run in a rails app. Is anyone > using an in-memory database to run their specs? Any pointers or tips? > > Scott > > _______________________________________________ > 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 jeff at jefdean.com Sun May 13 01:05:05 2007 From: jeff at jefdean.com (Jeff Dean) Date: Sun, 13 May 2007 01:05:05 -0400 Subject: [rspec-users] [OT] - In Memory Databases In-Reply-To: References: <18D3C862-12E3-4878-8B3D-B010A45C204F@railsnewbie.com> <6586e070705120834i640e3ea1l8fa789e5727c4e2@mail.gmail.com> Message-ID: <6586e070705122205x4cc85384i34ae35ca7aca57f2@mail.gmail.com> Those two lines will only start to come into play when you actually load fixtures. If you have no fixtures, it shouldn't matter what you set them to. Someone on the list should correct me if I'm wrong, but transactional fixtures typically reduce the time it takes to run specs. How many examples are you running? I've got a few apps now with several hundred examples, all of my model specs use fixtures and everything is quite fast for me now that non-model specs use mocks/stubs. For me, the longest part of running specs is loading the rails framework. To isolate that, just run script/console on the same app and see how long it takes. On 5/12/07, Scott Taylor wrote: > > Is there someway to remove all fixture processing? Can I set the > following two lines in spec_helper.rb to remove all fixture processing ? > > config.use_transactional_fixtures = false > config.use_instantiated_fixtures = false > > I was actually able to setup a sqlite in-memory database without a > problem, using topfunky's plugin. > > Even with drb, mocks & stubs, and an in-memory database, and no > (used) fixtures, things seem to be quite slow. Maybe this is more of > a reflection on my aged Mac than anything else... > > I think the real bottleneck is occurring in rake. I'll have to > checkout a profiler. > > Thanks, > > Scott > > > > On May 12, 2007, at 11:34 AM, Jeff Dean wrote: > > > Are you using mocks/stubs for the controllers and views? This has > > made the biggest difference in my specs. The other thing that's > > sped up my specs is making sure I'm only loading fixtures for the > > specs that absolutely need it on the models. > > > > But no - I've never used in-memory databases, so I can't help you > > there. > > > > On 5/12/07, Scott Taylor < mailing_lists at railsnewbie.com> wrote: > > My specs are still taking to long to run in a rails app. Is anyone > > using an in-memory database to run their specs? Any pointers or tips? > > > > Scott > > > > _______________________________________________ > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070513/ecfe6fc7/attachment.html From brian.takita at gmail.com Mon May 14 00:56:18 2007 From: brian.takita at gmail.com (Brian Takita) Date: Sun, 13 May 2007 21:56:18 -0700 Subject: [rspec-users] [rspec-devel] mock frameworks In-Reply-To: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> References: <57c63afe0705070443p12046c05off053706e844c129@mail.gmail.com> Message-ID: <1d7ddd110705132156vb51eb70vd1c0f6f657a62057@mail.gmail.com> I'm considering using Mocha + Mocha Shot. http://rubyforge.org/projects/mocha-shot There are some things that are in Rspec's mocking framework that are missing in Mocha though. For example, in spec/mock, #and_return takes a block that gets executed and accepts the arguments passed to the method. Oh well, I guess nothing is "perfect" :) On 5/7/07, David Chelimsky wrote: > > Just curious - now that rspec (as of 0.9) let's you choose your mock > framework, how many of you are actually using (or planning to use) > mocha or flexmock? > > Anybody planning to use any other mock framework besides rspec, mocha > or flexmock? > > Thanks, > David > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070513/063b475a/attachment.html From dchelimsky at gmail.com Mon May 14 09:25:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 14 May 2007 08:25:05 -0500 Subject: [rspec-users] tutorial In-Reply-To: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> Message-ID: <57c63afe0705140625qb829f95v180050d20cb6ed82@mail.gmail.com> On 5/11/07, Bolo wrote: > Hello, Hello > > Where i can found a good tutorial about Rspec ? I've just posted Part I of an introductory tutorial. http://blog.davidchelimsky.net/articles/2007/05/14/an-introduction-to-rspec-part-i I would love some feedback, but please provide it on the blog itself, rather than in this thread. Cheers, David > > thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From malavoi at gmail.com Mon May 14 09:26:46 2007 From: malavoi at gmail.com (Bolo) Date: Mon, 14 May 2007 09:26:46 -0400 Subject: [rspec-users] tutorial In-Reply-To: <57c63afe0705140625qb829f95v180050d20cb6ed82@mail.gmail.com> References: <93F4F35B-06D0-4B13-8B59-F514C329ECA6@gmail.com> <57c63afe0705140625qb829f95v180050d20cb6ed82@mail.gmail.com> Message-ID: <1C6033AC-7BA7-478B-9E59-262677D6D405@gmail.com> Thanks Le 14 mai 07 ? 09:25, David Chelimsky a ?crit : > On 5/11/07, Bolo wrote: >> Hello, Hello >> >> Where i can found a good tutorial about Rspec ? > > I've just posted Part I of an introductory tutorial. > > http://blog.davidchelimsky.net/articles/2007/05/14/an-introduction- > to-rspec-part-i > > I would love some feedback, but please provide it on the blog itself, > rather than in this thread. > > Cheers, > David > >> >> thanks >> _______________________________________________ >> 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 fbrubacher at gmail.com Mon May 14 22:39:03 2007 From: fbrubacher at gmail.com (Federico Brubacher) Date: Mon, 14 May 2007 23:39:03 -0300 Subject: [rspec-users] NOOB question RSPEC Message-ID: <206c53410705141939i48779858v2d4f157ac7c63c6c@mail.gmail.com> Hi all !! I have this code: require 'account' describe Account, "when first created" do before do @account = Account.new end it "should have a balance of $0" do @account.balance.should eql(Money.new(0, :dollars)) end after do @account = nil end end How can I pass the @account.balance.should eql(Money.new(0, :dollars)) spec. From my understanding you .eql? in ruby is true if the object are the same (reference points to same object) or if one inherits the other. I thought of using this code for Account : class Account attr_accessor :balance def initialize self.balance = Money.new(0, :dollars) end end class Money < Account attr_accessor :amount, :currency def initialize(amount, currency) @amount = amount @currency = currency end end But still can make it work. It does not pass the spec. Thanks ! -- Federico Brubacher www.fbrubacher.com Colonial Duty Free Shop www.colonial.com.uy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070514/a6d01241/attachment.html From dchelimsky at gmail.com Mon May 14 23:02:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 14 May 2007 22:02:29 -0500 Subject: [rspec-users] NOOB question RSPEC In-Reply-To: <206c53410705141939i48779858v2d4f157ac7c63c6c@mail.gmail.com> References: <206c53410705141939i48779858v2d4f157ac7c63c6c@mail.gmail.com> Message-ID: <57c63afe0705142002m5808d84n7feb0ae3f890f034@mail.gmail.com> On 5/14/07, Federico Brubacher wrote: > > Hi all !! > > > I have this code: > require 'account' > > > describe Account, "when first created" do > before do > @account = Account.new > end > > > it "should have a balance of $0" do > @account.balance.should eql(Money.new(0, :dollars)) > end > > > after do > @account = nil > end > end > > > How can I pass the @account.balance.should eql(Money.new(0, :dollars)) > spec. From my understanding you .eql? in ruby is true if the object > are the same (reference points to same object) or if one inherits the > other. This is only true for certain classes in the Ruby libraries, but not for the Ruby language. By default, equal?, eql? and even == only return true for the same Object. Here's evidence: irb(main):001:0> class Arbitrary irb(main):002:1> def initialize irb(main):003:2> @member = 1 irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> a = Arbitrary.new => # irb(main):007:0> a2 = Arbitrary.new => # irb(main):008:0> a == a2 => false irb(main):009:0> a.eql?(a2) => false irb(main):010:0> a.equal?(a2) => false irb(main):011:0> a == a => true irb(main):012:0> a.eql?(a) => true irb(main):013:0> a.equal?(a) => true > > > I thought of using this code for Account : > > class Account > attr_accessor :balance > def initialize > self.balance = Money.new(0, :dollars) > end > end > > class Money < Account > attr_accessor :amount, :currency > def initialize(amount, currency) > @amount = amount > @currency = currency > end > end >From an OO perspective this is probably not what you want. Account and Money are different concepts and don't belong in any sort of hierarchical relationship together. This really is a Ruby question, not an RSpec question. I'd recommend that you simply override eql? or == (or both) on your Money class. Do that spec-first separately. Then the example you provided above should pass. Please let us know if that works for you. Cheers, David ps - there's no need to have after(:each) { @account = nil }. Each example gets run in a new instance of Object, so instance variables are out of scope from example to example. > > > But still can make it work. It does not pass the spec. > Thanks ! > -- > Federico Brubacher > www.fbrubacher.com > > Colonial Duty Free Shop > www.colonial.com.uy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Tue May 15 02:30:53 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 14 May 2007 23:30:53 -0700 Subject: [rspec-users] Testing Ajax Controller Methods In-Reply-To: <57c63afe0705142002m5808d84n7feb0ae3f890f034@mail.gmail.com> References: <206c53410705141939i48779858v2d4f157ac7c63c6c@mail.gmail.com> <57c63afe0705142002m5808d84n7feb0ae3f890f034@mail.gmail.com> Message-ID: <7F212B7D-20EF-40D0-A862-6A17BD2E8EC7@gmail.com> I have a bunch of little toggler methods in controllers that look sorta like this: # This method is only intended to toggle the approved attribute via Ajax def toggle_approved if request.xhr? post = Post.find(params[:id]) post.toggle!('approved') if post end render :nothing => true end There's essentially nothing here to spec other than: it "should very silently change the state of the 'approved' field" But AR takes care of that... and because I'm not exposing the intermediary post variable as an instance variable, I can't even see whether I did anything without going back and querying the database. That feels like stuff I shouldn't be doing in a spec. The other side of the coin is that a spec should describe the functionality of the controller and one component of that functionality is that it can toggle the state of the 'approved' field. So the conundrum is this: Do I rewrite the code to make it more verifiable, changing post to @post? Do I actually take before and after snapshots of the 'approved' field? Do I trust AR to do the right thing and stop obsessing? Any thoughts? From mlangenberg at gmail.com Tue May 15 02:55:49 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Tue, 15 May 2007 08:55:49 +0200 Subject: [rspec-users] Testing Ajax Controller Methods In-Reply-To: <7F212B7D-20EF-40D0-A862-6A17BD2E8EC7@gmail.com> References: <206c53410705141939i48779858v2d4f157ac7c63c6c@mail.gmail.com> <57c63afe0705142002m5808d84n7feb0ae3f890f034@mail.gmail.com> <7F212B7D-20EF-40D0-A862-6A17BD2E8EC7@gmail.com> Message-ID: <27c0ac6d0705142355q3fe9ffa5j30f099eef12a0f49@mail.gmail.com> Mock objects are great for this! it "should very silently change the state of the 'approved' field" do post = mock('post') post.should_receive(:toggle!).with('approved') Post.should_receive(:find).with("1").and_return(post) xhr post :toggle_approved, :id => 1 end On 5/15/07, s.ross wrote: > I have a bunch of little toggler methods in controllers that look > sorta like this: > > # This method is only intended to toggle the approved attribute > via Ajax > def toggle_approved > if request.xhr? > post = Post.find(params[:id]) > post.toggle!('approved') if post > end > render :nothing => true > end > > There's essentially nothing here to spec other than: > > it "should very silently change the state of the 'approved' field" > > But AR takes care of that... and because I'm not exposing the > intermediary post variable as an instance variable, I can't even see > whether I did anything without going back and querying the database. > That feels like stuff I shouldn't be doing in a spec. The other side > of the coin is that a spec should describe the functionality of the > controller and one component of that functionality is that it can > toggle the state of the 'approved' field. > > So the conundrum is this: Do I rewrite the code to make it more > verifiable, changing post to @post? Do I actually take before and > after snapshots of the 'approved' field? Do I trust AR to do the > right thing and stop obsessing? > > Any thoughts? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pocketsized at tiscali.co.uk Tue May 15 04:29:29 2007 From: pocketsized at tiscali.co.uk (David Green) Date: Tue, 15 May 2007 09:29:29 +0100 Subject: [rspec-users] spec_server Message-ID: <9612333e0705150129y677db8dxe97ecd94d234e87d@mail.gmail.com> hi all I'm trying to use spec_server to run my specs in rails, but the specs don't seem to be running any faster, and it looks like they're being run twice when I use the --drb option ..? The app I'm testing is just a basic rails app with 2 empty models and a hello world controller. The specs are just the default ones created by the generators. I was previously using rspec 0.8.2 and those specs ran a LOT faster. does anyone know what the problem might be? thanks dave x at holly:~/rails/allison$ ruby script/spec spec/models ... Finished in 0.057578 seconds 3 examples, 0 failures *** now with the --drb option and spec_server running *** x at holly:~/rails/allison$ ruby script/spec spec/models --drb ... Finished in 0.067976 seconds 3 examples, 0 failures ... Finished in 0.064153 seconds 3 examples, 0 failures x at holly:~/rails/allison$ From mailing_lists at railsnewbie.com Tue May 15 04:37:11 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 15 May 2007 04:37:11 -0400 Subject: [rspec-users] spec_server In-Reply-To: <9612333e0705150129y677db8dxe97ecd94d234e87d@mail.gmail.com> References: <9612333e0705150129y677db8dxe97ecd94d234e87d@mail.gmail.com> Message-ID: <5D76BD14-141D-42C3-A4BF-98D5BFF26A8C@railsnewbie.com> On May 15, 2007, at 4:29 AM, David Green wrote: > hi all > > I'm trying to use spec_server to run my specs in rails, but the specs > don't seem to be running any faster, and it looks like they're being > run twice when I use the --drb option ..? The app I'm testing is just > a basic rails app with 2 empty models and a hello world controller. > The specs are just the default ones created by the generators. > Well, this was a bug fixed in trunk recently. You may want to run an 'svn update' if you have rspec on externals, or run ./script/plugin install again. This should help speed up the running of the specs. The difference in performance is caused by the bug. I've also learned that on my Mac G4 Dual 800, closing Mail.app and other running programs can dramatically speed up my specs. Let us know if that helps, Scott > I was previously using rspec 0.8.2 and those specs ran a LOT faster. > does anyone know what the problem might be? > > thanks > dave > > > x at holly:~/rails/allison$ ruby script/spec spec/models > ... > > Finished in 0.057578 seconds > > 3 examples, 0 failures > > *** now with the --drb option and spec_server running *** > > x at holly:~/rails/allison$ ruby script/spec spec/models --drb > ... > > Finished in 0.067976 seconds > > 3 examples, 0 failures > ... > > Finished in 0.064153 seconds > > 3 examples, 0 failures > x at holly:~/rails/allison$ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pocketsized at tiscali.co.uk Tue May 15 08:19:32 2007 From: pocketsized at tiscali.co.uk (David Green) Date: Tue, 15 May 2007 13:19:32 +0100 Subject: [rspec-users] spec_server In-Reply-To: <5D76BD14-141D-42C3-A4BF-98D5BFF26A8C@railsnewbie.com> References: <9612333e0705150129y677db8dxe97ecd94d234e87d@mail.gmail.com> <5D76BD14-141D-42C3-A4BF-98D5BFF26A8C@railsnewbie.com> Message-ID: <9612333e0705150519m17e80426qdbad49507dc8edf0@mail.gmail.com> On 15/05/07, Scott Taylor wrote: > > Well, this was a bug fixed in trunk recently. You may want to run an > 'svn update' if you have rspec on externals, or run ./script/plugin > install again. This should help speed up the running of the specs. > > The difference in performance is caused by the bug. > > I've also learned that on my Mac G4 Dual 800, closing Mail.app and > other running programs can dramatically speed up my specs. > > Let us know if that helps, > > Scott thanks for your reply Scott, but no joy I'm afraid. I tried again with a new rails app and just a generated User model, following the instructions at http://rspec.rubyforge.org/documentation/rails/install.html I get the same result. From dchelimsky at gmail.com Tue May 15 08:23:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 15 May 2007 07:23:16 -0500 Subject: [rspec-users] spec_server In-Reply-To: <9612333e0705150519m17e80426qdbad49507dc8edf0@mail.gmail.com> References: <9612333e0705150129y677db8dxe97ecd94d234e87d@mail.gmail.com> <5D76BD14-141D-42C3-A4BF-98D5BFF26A8C@railsnewbie.com> <9612333e0705150519m17e80426qdbad49507dc8edf0@mail.gmail.com> Message-ID: <57c63afe0705150523p5a4e1810u888a8a9b760a157f@mail.gmail.com> On 5/15/07, David Green wrote: > On 15/05/07, Scott Taylor wrote: > > > > Well, this was a bug fixed in trunk recently. You may want to run an > > 'svn update' if you have rspec on externals, or run ./script/plugin > > install again. This should help speed up the running of the specs. > > > > The difference in performance is caused by the bug. > > > > I've also learned that on my Mac G4 Dual 800, closing Mail.app and > > other running programs can dramatically speed up my specs. > > > > Let us know if that helps, > > > > Scott > > thanks for your reply Scott, but no joy I'm afraid. I tried again with > a new rails app and just a generated User model, following the > instructions at > http://rspec.rubyforge.org/documentation/rails/install.html David - did you follow the instructions for getting the trunk or the current release? You'll need the trunk to get this bugfix as it has not been released yet. > > I get the same result. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pocketsized at tiscali.co.uk Tue May 15 08:46:27 2007 From: pocketsized at tiscali.co.uk (David Green) Date: Tue, 15 May 2007 13:46:27 +0100 Subject: [rspec-users] spec_server In-Reply-To: <57c63afe0705150523p5a4e1810u888a8a9b760a157f@mail.gmail.com> References: <9612333e0705150129y677db8dxe97ecd94d234e87d@mail.gmail.com> <5D76BD14-141D-42C3-A4BF-98D5BFF26A8C@railsnewbie.com> <9612333e0705150519m17e80426qdbad49507dc8edf0@mail.gmail.com> <57c63afe0705150523p5a4e1810u888a8a9b760a157f@mail.gmail.com> Message-ID: <9612333e0705150546p6094411h91416f9f166efb4f@mail.gmail.com> On 15/05/07, David Chelimsky wrote: > David - did you follow the instructions for getting the trunk or the > current release? You'll need the trunk to get this bugfix as it has > not been released yet. > oops. I thought I'd followed instructions for trunk but it was in fact the 0.9.4 release (yet another reason not to blindly copy/paste). thanks for your help David, it works now. From dchelimsky at gmail.com Tue May 15 08:47:46 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 15 May 2007 07:47:46 -0500 Subject: [rspec-users] spec_server In-Reply-To: <9612333e0705150546p6094411h91416f9f166efb4f@mail.gmail.com> References: <9612333e0705150129y677db8dxe97ecd94d234e87d@mail.gmail.com> <5D76BD14-141D-42C3-A4BF-98D5BFF26A8C@railsnewbie.com> <9612333e0705150519m17e80426qdbad49507dc8edf0@mail.gmail.com> <57c63afe0705150523p5a4e1810u888a8a9b760a157f@mail.gmail.com> <9612333e0705150546p6094411h91416f9f166efb4f@mail.gmail.com> Message-ID: <57c63afe0705150547p62efb8a0w19db698422c2fea6@mail.gmail.com> On 5/15/07, David Green wrote: > On 15/05/07, David Chelimsky wrote: > > David - did you follow the instructions for getting the trunk or the > > current release? You'll need the trunk to get this bugfix as it has > > not been released yet. > > > > oops. I thought I'd followed instructions for trunk but it was in fact > the 0.9.4 release (yet another reason not to blindly copy/paste). > thanks for your help David, it works now. Great. Enjoy. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris.c.hoffman at gmail.com Tue May 15 14:00:32 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Tue, 15 May 2007 14:00:32 -0400 Subject: [rspec-users] nested blocks Message-ID: <63c5d3820705151100p74ae1787x51a0d5682bcf023a@mail.gmail.com> Hello, Does anyone have an explanation for why the following code results in the error that follows? I also would value any criticisms of my approach (i.e., defining it_should_populate_collections). Thanks -Chris #Code def it_should_populate_collections(condition=nil) it "should populate any necessary collections #{condition}" do [*@collections_to_populate].each do |collection| collection_model = collection.to_s.classify.constantize collection_model.should_receive(:find).with(:all).and_return("the #{collection}") end yield [*@collections_to_populate].each do |collection| assigns[collection].should == "the #{collection}" end end end describe "Foo" do before(:all) do @collections_to_populate = :bars end before(:each) do @obj = Foo.new end it_should_populate_collections "on a save failure" do @obj.should_receive(:save) post @action end end #Error undefined method `post' for # From dchelimsky at gmail.com Tue May 15 14:49:25 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 15 May 2007 13:49:25 -0500 Subject: [rspec-users] nested blocks In-Reply-To: <63c5d3820705151100p74ae1787x51a0d5682bcf023a@mail.gmail.com> References: <63c5d3820705151100p74ae1787x51a0d5682bcf023a@mail.gmail.com> Message-ID: <57c63afe0705151149g35abab64rbc6cf6b387594cf1@mail.gmail.com> On 5/15/07, Chris Hoffman wrote: > Hello, > > Does anyone have an explanation for why the following code results in > the error that follows? I also would value any criticisms of my > approach (i.e., defining it_should_populate_collections). Thanks > > -Chris > > #Code > > def it_should_populate_collections(condition=nil) > it "should populate any necessary collections #{condition}" do > [*@collections_to_populate].each do |collection| > collection_model = collection.to_s.classify.constantize > collection_model.should_receive(:find).with(:all).and_return("the > #{collection}") > end > yield > [*@collections_to_populate].each do |collection| > assigns[collection].should == "the #{collection}" > end > end > end > > describe "Foo" do > before(:all) do > @collections_to_populate = :bars > end > > before(:each) do > @obj = Foo.new > end > > it_should_populate_collections "on a save failure" do > @obj.should_receive(:save) > post @action > end > end > > #Error > > undefined method `post' for # post is only available in controller specs, identified by living in spec/controllers or by saying: describe "Foo", :behaviour_type => :controller do My guess is that you're doing this in spec/models, but that's just a guess (please include complete error messages instead of just one line when you post questions like this). As for the approach: 1. I'd recommend only using before(:all) for expensive operations like initializing databases. In this example, there is no benefit to using before(:all). Not even a runtime benefit, because any instance vars that you set up get copied around which is no less expensive than simply re-creating them before(:each) example. Using before(:all) and before(:each) together just makes things confusing. 2. "it_should_populate_collections" speaks very nicely from a documentation standpoint, but from a failure isolation standpoint (i.e. understanding quickly why something fails when it does) I think it's a bit problematic. There's just no way to understand what's going on in the example without looking at the definition of it_should_populate_collections. It's very clever, but takes attention away from where it should be. The fact that it yields back to the current block makes it even more confusing. I'd stay away from that in specs. In general, I'd encourage you to use custom matchers rather than adding "it_blah" methods (i.e. @model.should populate_collections(:a, :b) ). I think that will make it much easier for other people to look at your specs and understand them from a documentation perspective, and a failure isolation perspective. 2 cents Cheers, David From chris.c.hoffman at gmail.com Tue May 15 15:16:48 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Tue, 15 May 2007 15:16:48 -0400 Subject: [rspec-users] nested blocks In-Reply-To: <57c63afe0705151149g35abab64rbc6cf6b387594cf1@mail.gmail.com> References: <63c5d3820705151100p74ae1787x51a0d5682bcf023a@mail.gmail.com> <57c63afe0705151149g35abab64rbc6cf6b387594cf1@mail.gmail.com> Message-ID: <63c5d3820705151216s24909527g52dd66189876db58@mail.gmail.com> Sorry about being incomplete; here is the whole error message: NoMethodError in 'PagesController#new should populate any necessary collections ' undefined method `get' for # ./spec/controllers/../controllers/crud_spec_helper.rb:88: ./spec/controllers/../controllers/crud_spec_helper.rb:17:in `it_should_populate_collections' script/spec:4: On 5/15/07, David Chelimsky wrote: > On 5/15/07, Chris Hoffman wrote: > > Hello, > > > > Does anyone have an explanation for why the following code results in > > the error that follows? I also would value any criticisms of my > > approach (i.e., defining it_should_populate_collections). Thanks > > > > -Chris > > > > #Code > > > > def it_should_populate_collections(condition=nil) > > it "should populate any necessary collections #{condition}" do > > [*@collections_to_populate].each do |collection| > > collection_model = collection.to_s.classify.constantize > > collection_model.should_receive(:find).with(:all).and_return("the > > #{collection}") > > end > > yield > > [*@collections_to_populate].each do |collection| > > assigns[collection].should == "the #{collection}" > > end > > end > > end > > > > describe "Foo" do > > before(:all) do > > @collections_to_populate = :bars > > end > > > > before(:each) do > > @obj = Foo.new > > end > > > > it_should_populate_collections "on a save failure" do > > @obj.should_receive(:save) > > post @action > > end > > end > > > > #Error > > > > undefined method `post' for # > > post is only available in controller specs, identified by living in > spec/controllers or by saying: > > describe "Foo", :behaviour_type => :controller do > > My guess is that you're doing this in spec/models, but that's just a > guess (please include complete error messages instead of just one line > when you post questions like this). > > As for the approach: > > 1. I'd recommend only using before(:all) for expensive operations like > initializing databases. In this example, there is no benefit to using > before(:all). Not even a runtime benefit, because any instance vars > that you set up get copied around which is no less expensive than > simply re-creating them before(:each) example. Using before(:all) and > before(:each) together just makes things confusing. > > 2. "it_should_populate_collections" speaks very nicely from a > documentation standpoint, but from a failure isolation standpoint > (i.e. understanding quickly why something fails when it does) I think > it's a bit problematic. There's just no way to understand what's going > on in the example without looking at the definition of > it_should_populate_collections. It's very clever, but takes attention > away from where it should be. The fact that it yields back to the > current block makes it even more confusing. I'd stay away from that in > specs. > > In general, I'd encourage you to use custom matchers rather than > adding "it_blah" methods (i.e. @model.should populate_collections(:a, > :b) ). I think that will make it much easier for other people to look > at your specs and understand them from a documentation perspective, > and a failure isolation perspective. > > 2 cents > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeem at hughesorama.com Wed May 16 01:37:37 2007 From: jeem at hughesorama.com (Jim Hughes) Date: Wed, 16 May 2007 00:37:37 -0500 Subject: [rspec-users] very odd controller spec problem Message-ID: <242025D5-D6A3-4068-BBF7-91AB0F22E5AC@hughesorama.com> Here's a snippet: it "should provide the fund" do get(:timesheet,{:id=>@fund.id}) assigns[:fund].should == @fund end Works fine on my box, fails on my CI server. Here's the output: NoMethodError in 'The FundController timesheet should provide the fund' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[]= ./spec/controllers/fund_controller_spec.rb:19: ./script/spec:4: The line raising is the "get" line. I don't see a foo[bar] = x, implied anywhere in the statement. Has anyone seen this? Thanks for any help. Jim From jeff at jefdean.com Wed May 16 01:57:40 2007 From: jeff at jefdean.com (Jeff Dean) Date: Wed, 16 May 2007 01:57:40 -0400 Subject: [rspec-users] very odd controller spec problem In-Reply-To: <242025D5-D6A3-4068-BBF7-91AB0F22E5AC@hughesorama.com> References: <242025D5-D6A3-4068-BBF7-91AB0F22E5AC@hughesorama.com> Message-ID: <6586e070705152257t4e4b872vf804c9c88d63149@mail.gmail.com> Is @fund nil? I'm guessing here, but the []= could be from the underlying attributes (@fund.id is the same as @fund.attributes['id']). On 5/16/07, Jim Hughes wrote: > > Here's a snippet: > > it "should provide the fund" do > get(:timesheet,{:id=>@fund.id}) > assigns[:fund].should == @fund > end > > Works fine on my box, fails on my CI server. Here's the output: > > NoMethodError in 'The FundController timesheet should provide the fund' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.[]= > ./spec/controllers/fund_controller_spec.rb:19: > ./script/spec:4: > > The line raising is the "get" line. I don't see a foo[bar] = x, > implied anywhere in the statement. > > Has anyone seen this? > > Thanks for any help. > > Jim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070516/27b5a1fe/attachment.html From jeem at hughesorama.com Wed May 16 02:13:12 2007 From: jeem at hughesorama.com (Jim Hughes) Date: Wed, 16 May 2007 01:13:12 -0500 Subject: [rspec-users] very odd controller spec problem In-Reply-To: <6586e070705152257t4e4b872vf804c9c88d63149@mail.gmail.com> References: <242025D5-D6A3-4068-BBF7-91AB0F22E5AC@hughesorama.com> <6586e070705152257t4e4b872vf804c9c88d63149@mail.gmail.com> Message-ID: <458698CC-F253-4C2E-97AD-D8896D4D7E78@hughesorama.com> Thank you for the reply. Doesn't look like it. The setup does this: @fund = mock_model(Fund) Fund.should_receive(:find).with(@fund.id.to_s).and_return(@fund) I changed setup to say @fund = mock_model(Fund) @fund_id = @fund.id Fund.should_receive(:find).with(@fund.id.to_s).and_return(@fund) And the test to it "should provide the fund" do @fund_id.should_not be(nil) get(:timesheet,{:id=>@fund_id}) assigns[:fund].should == @fund end Still gives the same error on the "get" line. Jim On May 16, 2007, at 12:57 AM, Jeff Dean wrote: > Is @fund nil? I'm guessing here, but the []= could be from the > underlying attributes (@fund.id is the same as @fund.attributes > ['id']). > > On 5/16/07, Jim Hughes wrote: > Here's a snippet: > > it "should provide the fund" do > get(:timesheet,{:id=>@fund.id}) > assigns[:fund].should == @fund > end > > Works fine on my box, fails on my CI server. Here's the output: > > NoMethodError in 'The FundController timesheet should provide the > fund' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.[]= > ./spec/controllers/fund_controller_spec.rb:19: > ./script/spec:4: > > The line raising is the "get" line. I don't see a foo[bar] = x, > implied anywhere in the statement. > > Has anyone seen this? > > Thanks for any help. > > Jim > _______________________________________________ > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070516/f97224d0/attachment.html From chris.c.hoffman at gmail.com Wed May 16 10:27:16 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Wed, 16 May 2007 10:27:16 -0400 Subject: [rspec-users] nested blocks In-Reply-To: <63c5d3820705151216s24909527g52dd66189876db58@mail.gmail.com> References: <63c5d3820705151100p74ae1787x51a0d5682bcf023a@mail.gmail.com> <57c63afe0705151149g35abab64rbc6cf6b387594cf1@mail.gmail.com> <63c5d3820705151216s24909527g52dd66189876db58@mail.gmail.com> Message-ID: <63c5d3820705160727o22318182m95ebe0eb97b588f7@mail.gmail.com> Okay, I killed two birds with one stone, I hope. I saw what you meant by my overly clever approach not making much sense to someone who is trying to read the code. I have made a custom matcher instead. I would appreciate any more comments you may have. I have made every controller spec define its necessary collections, which is what feeds into the matcher. I wouldn't mind a more elegant approach, such as some keyword in the model association definition that declares it to be assigned by the model. For example: class Foo < AR::Base belongs_to :bar, :assignable end Anyway, here is what I have so far for the custom matcher. module CustomCRUDMatchers class BePopulatedWith def initialize(collections_to_populate=nil) @collections_to_populate = [*collections_to_populate] end def matches?(assigns) @assigns = assigns #not sure why I need this to get inside the following block @collections_to_populate.each do |collection| unless @assigns[collection].eql? "the #{collection}" @failed_collection = collection return false end end end def failure_message "expected #{@failed_collection} to be populated with 'the #{@failed_collection}', got #{@assigns[@failed_collection].inspect} instead" end def negative_failure_message "expected #{@failed_collection} not to be populated, got #{@assigns[@failed_collection].inspect} instead" end end def be_populated_with(collections) BePopulatedWith.new(collections) end end describe "Foo#new" do include CustomCRUDMatchers before(:each) do @action = "new" @collections_to_populate = :bars end it "should render the '#@action' template" do get @action response.should render_template(@action) end it "should populate collections relevant to the form" do get @action assigns.should be_populated_with(@collections_to_populate) end end On 5/15/07, Chris Hoffman wrote: > Sorry about being incomplete; here is the whole error message: > > NoMethodError in 'PagesController#new should populate any necessary > collections ' > undefined method `get' for # > ./spec/controllers/../controllers/crud_spec_helper.rb:88: > ./spec/controllers/../controllers/crud_spec_helper.rb:17:in > `it_should_populate_collections' > script/spec:4: > > On 5/15/07, David Chelimsky wrote: > > On 5/15/07, Chris Hoffman wrote: > > > Hello, > > > > > > Does anyone have an explanation for why the following code results in > > > the error that follows? I also would value any criticisms of my > > > approach (i.e., defining it_should_populate_collections). Thanks > > > > > > -Chris > > > > > > #Code > > > > > > def it_should_populate_collections(condition=nil) > > > it "should populate any necessary collections #{condition}" do > > > [*@collections_to_populate].each do |collection| > > > collection_model = collection.to_s.classify.constantize > > > collection_model.should_receive(:find).with(:all).and_return("the > > > #{collection}") > > > end > > > yield > > > [*@collections_to_populate].each do |collection| > > > assigns[collection].should == "the #{collection}" > > > end > > > end > > > end > > > > > > describe "Foo" do > > > before(:all) do > > > @collections_to_populate = :bars > > > end > > > > > > before(:each) do > > > @obj = Foo.new > > > end > > > > > > it_should_populate_collections "on a save failure" do > > > @obj.should_receive(:save) > > > post @action > > > end > > > end > > > > > > #Error > > > > > > undefined method `post' for # > > > > post is only available in controller specs, identified by living in > > spec/controllers or by saying: > > > > describe "Foo", :behaviour_type => :controller do > > > > My guess is that you're doing this in spec/models, but that's just a > > guess (please include complete error messages instead of just one line > > when you post questions like this). > > > > As for the approach: > > > > 1. I'd recommend only using before(:all) for expensive operations like > > initializing databases. In this example, there is no benefit to using > > before(:all). Not even a runtime benefit, because any instance vars > > that you set up get copied around which is no less expensive than > > simply re-creating them before(:each) example. Using before(:all) and > > before(:each) together just makes things confusing. > > > > 2. "it_should_populate_collections" speaks very nicely from a > > documentation standpoint, but from a failure isolation standpoint > > (i.e. understanding quickly why something fails when it does) I think > > it's a bit problematic. There's just no way to understand what's going > > on in the example without looking at the definition of > > it_should_populate_collections. It's very clever, but takes attention > > away from where it should be. The fact that it yields back to the > > current block makes it even more confusing. I'd stay away from that in > > specs. > > > > In general, I'd encourage you to use custom matchers rather than > > adding "it_blah" methods (i.e. @model.should populate_collections(:a, > > :b) ). I think that will make it much easier for other people to look > > at your specs and understand them from a documentation perspective, > > and a failure isolation perspective. > > > > 2 cents > > > > Cheers, > > David > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From blake.pettersson at hotmail.com Wed May 16 21:22:13 2007 From: blake.pettersson at hotmail.com (Blake Pettersson) Date: Thu, 17 May 2007 03:22:13 +0200 Subject: [rspec-users] Stubbing authentication across multiple controllers Message-ID: Hi, I'm new to RSpec, so I'm not too sure of the best practises in stubbing. I was thinking along the lines of including a helper method that would stub out a users id and posts to sessions/create. It works fine when speccing SessionsController, but of course it fails when it is included into other controllers specs, because of the post. I've tried posting to an absolute path ("http://test.host/sessions/create") and to a relative path ("/sessions/create"), but that doesn't seem to work either. Perhaps I'm going about this the wrong way, so if anyone has any suggestions it would be appreciated. #Helper method that is included in controller specs def login_as(username, password = "foo", id = "1") user = mock(username) user.stub!(:id).and_return(id) user.stub!(:to_param).and_return(id) User.should_receive(:authenticate).with(username, password).and_return(true) #Here it fails if included in a controller that isn't SessionController post(:create, :login => username, :password => password) puts response.inspect controller.send :current_user=, user end _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE From jerry.west at ntlworld.com Thu May 17 05:26:59 2007 From: jerry.west at ntlworld.com (Jerry West) Date: Thu, 17 May 2007 10:26:59 +0100 Subject: [rspec-users] Stubbing authentication across multiple controllers In-Reply-To: References: Message-ID: <464C1FE3.9080606@ntlworld.com> Blake, You might consider stubbing your controllers at a higher level. Presumably session/create sets up something in the session which your other controllers check to see if you are logged in. If you have your controllers call some method to make the check you can stub that; so far as they are concerned it will be as if your user had logged in, but you need not actually call SessionController. For example: controller.stub!(:logged_in?).and_return(true) controller.stub!(:authorized?).and_return(true) or even controller.stub!(:login_before_acting).and_return(true) # before_filter :login_before_acting though you can't use that to spec the authorization code in your controller ('cos it will skip the call to #authorized? which #login_before_acting would normally make). Leave your detailed spec as it is for SessionController, but abstract the functionality out - and stub it - for everyone else. It's your choice as to where you place the stubs; personally I make the controller call the before_filter but return immediately by stubbing #logged_in? and #authorized? as above. This means I can run specs to ensure my controllers do the right thing if the user is not logged in (the stub returns false) and/or is not authorized(*). You may also need to stub methods to return the current_user (etc) as required. Put them in helper methods as you are doing and use in setup/before blocks as required. YMMV. Best wishes, Jerry (*) There's a whole other discussion about this - surely if I've spec'd my authentication code all I need do is check my controller includes the module and calls the filter... but somehow I like to see the individual specs run for all my controllers...There is NO One True Way in rspec, all approaches are equal, but some are more equal than others. Now I'm rambling :-). From francois.beausoleil at gmail.com Thu May 17 10:44:41 2007 From: francois.beausoleil at gmail.com (=?UTF-8?Q?Fran=C3=A7ois_Beausoleil?=) Date: Thu, 17 May 2007 10:44:41 -0400 Subject: [rspec-users] How to mock helpers in view specs ? Message-ID: <41d5fadf0705170744r2bbee2fane65b97043787501e@mail.gmail.com> Hi all, I am mocking the following Rails view (inside a partial): <%= render :partial => "forums/forum", :collection => forum_category.forums.readable_by(current_user? ? current_user : nil) %> My spec fails with the following message: 1) ActionView::TemplateError in 'forum_categories/index (anonymous user) should only render forums accessible to anonymous users' undefined local variable or method `current_user' for #<#:0xb6204d54> On line #21 of app/views/forum_categories/index.rhtml But in before, I setup the correct stub: describe "forum_categories/index (anonymous user)" do before do @forum_category = mock("forum category") @forums_proxy = mock("forums proxy") @forum = mock("forum") @topics_proxy = mock("topics proxy") @forum_category.stub!(:forums).and_return(@forums_proxy) @forum.stub!(:topics).and_return(@topics_proxy) assigns[:forum_categories] = [@forum_category] @controller.stub!(:current_user?).and_return(false) @controller.stub!(:current_user).and_return(mock("mock user")) end it "should only render forums accessible to anonymous users" do @forums_proxy.should_receive(:readable_by).with(nil).and_return([]) do_render end def do_render render "forum_categories/index" end end What am I doing wrong ? This is on RSpec 0.9.4 and RSpec on Rails 0.9.4. Thanks ! -- Fran?ois Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ From ruyasan at gmail.com Thu May 17 12:26:08 2007 From: ruyasan at gmail.com (Ruy Asan) Date: Thu, 17 May 2007 09:26:08 -0700 Subject: [rspec-users] How to mock helpers in view specs ? In-Reply-To: <41d5fadf0705170744r2bbee2fane65b97043787501e@mail.gmail.com> References: <41d5fadf0705170744r2bbee2fane65b97043787501e@mail.gmail.com> Message-ID: <9285597E-6870-4D74-85F6-6FB26907F27D@gmail.com> AFAIK, you need to stub @controller.template instead On 17-May-07, at 7:44 AM, Fran?ois Beausoleil wrote: > Hi all, > > I am mocking the following Rails view (inside a partial): > <%= render :partial => "forums/forum", > :collection => forum_category.forums.readable_by(current_user? ? > current_user : nil) %> > > My spec fails with the following message: > 1) > ActionView::TemplateError in 'forum_categories/index (anonymous user) > should only render forums accessible to anonymous users' > undefined local variable or method `current_user' for > #<#:0xb6204d54> > On line #21 of app/views/forum_categories/index.rhtml > > But in before, I setup the correct stub: > > describe "forum_categories/index (anonymous user)" do > before do > @forum_category = mock("forum category") > @forums_proxy = mock("forums proxy") > @forum = mock("forum") > @topics_proxy = mock("topics proxy") > > @forum_category.stub!(:forums).and_return(@forums_proxy) > @forum.stub!(:topics).and_return(@topics_proxy) > > assigns[:forum_categories] = [@forum_category] > > @controller.stub!(:current_user?).and_return(false) > @controller.stub!(:current_user).and_return(mock("mock user")) > end > > it "should only render forums accessible to anonymous users" do > @forums_proxy.should_receive(:readable_by).with(nil).and_return > ([]) > do_render > end > > def do_render > render "forum_categories/index" > end > end > > What am I doing wrong ? > > This is on RSpec 0.9.4 and RSpec on Rails 0.9.4. > > Thanks ! > -- > Fran?ois Beausoleil > http://blog.teksol.info/ > http://piston.rubyforge.org/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From david.smalley.lists at googlemail.com Thu May 17 13:20:24 2007 From: david.smalley.lists at googlemail.com (David Smalley) Date: Thu, 17 May 2007 18:20:24 +0100 Subject: [rspec-users] strange results when using rcov with rspec Message-ID: <15181359-FF23-4463-9505-0E6430A19E3F@googlemail.com> I have some specs tucked away inside my vendor/plugins directory that I want to run when I run rake spec. I've got the rake task working just fine, but for some reason rcov seems to choke when I try to tweak the included/excluded files to ignore any files in app/ but to include files in vendor/plugins/ plugin/app/** The error I get is this: No file to analyze was found. All the files loaded by rcov matched one of the following expressions, and were thus ignored: [/\A\/usr\/ lib/, /\btc_[^.]*.rb/, /_test\.rb\z/, /\btest\//, /\bvendor\//, /\A\/ usr\/lib\/ruby\/gems\/1\.8\/gems\/rcov\-0\.8\.0\.2\/lib\/rcov\/report \.rb\z/, /lib\/spec/, /bin\/spec\//, /app/, /config/] You can solve this by doing one or more of the following: * rename the files not to be ignored so they don't match the above regexps * use --include-file to give a list of patterns for files not to be ignored * use -- exclude-only to give the new list of regexps to match against * structure your code as follows: test/test_*.rb for the test cases lib/ **/*.rb for the target source code whose coverage you want making sure that the test/test_*.rb files are loading from lib/, e.g. by using the -Ilib command-line argument, adding $:.unshift File.join (File.dirname(__FILE__), "..", "lib") to test/test_*.rb, or running rcov via a Rakefile (read the RDoc documentation or README.rake in the source distribution). ./vendor/plugins/sor_core/app/models/ collection.rb:1: uninitialized constant ActiveRecord (NameError) from /usr/lib/ruby/gems/1.8/gems/rcov-0.8.0.2/bin/rcov:516 from /usr/ bin/rcov:16 rake aborted! RSpec failures (See full trace by running task with --trace) A snippet of the rake task I am using looks like this: desc "Run the specs under vendor/plugins/**/spec/models" Spec::Rake::SpecTask.new(:models => "db:test:prepare") do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList["vendor/plugins/#{ENV['PLUGIN'] || "**"}/spec/models/*_spec.rb"] t.rcov = true t.rcov_dir = "spec/reports/model-coverage" t.rcov_opts = ['--include-file', "vendor\/plugins\/#{ENV ['PLUGIN'] || "**"}\/app\/models\/*", '--exclude', "lib\/spec,bin\/ spec/,app,config"] t.spec_opts = ["--format", "html"] t.out = "spec/reports/model-report/index.html" end If I just run a plain old rspec with this command: desc "Run the specs under spec/models" Spec::Rake::SpecTask.new(:models => "db:test:prepare") do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList["vendor/plugins/#{ENV['PLUGIN'] || "**"}/spec/models/*_spec.rb"] end Then all my tests run through just fine without any problems (but obviously produce no spec reports or rcov reports) Anyone got any ideas? Thanks, David From francois.beausoleil at gmail.com Thu May 17 15:46:33 2007 From: francois.beausoleil at gmail.com (=?UTF-8?Q?Fran=C3=A7ois_Beausoleil?=) Date: Thu, 17 May 2007 15:46:33 -0400 Subject: [rspec-users] How to mock helpers in view specs ? In-Reply-To: <9285597E-6870-4D74-85F6-6FB26907F27D@gmail.com> References: <41d5fadf0705170744r2bbee2fane65b97043787501e@mail.gmail.com> <9285597E-6870-4D74-85F6-6FB26907F27D@gmail.com> Message-ID: <41d5fadf0705171246m748f9d93xb538427e5e07a382@mail.gmail.com> Thanks Ruy ! 2007/5/17, Ruy Asan : > AFAIK, you need to stub @controller.template instead That's exactly what I needed. Thank you very much. There needs to be a mention of this on http://rspec.rubyforge.org/documentation/rails/writing/views.html Bye ! -- Fran?ois Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ From win at wincent.com Fri May 18 11:03:04 2007 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 18 May 2007 17:03:04 +0200 Subject: [rspec-users] Fixtures considered harmful? Message-ID: <45A7F626-DB11-4F49-9E65-80C0D01566F5@wincent.com> I'm trying to get really serious about doing true BDD for a new Rails project, and I note that at it says: "we really don?t recommend the use of rails fixtures" On the same page it also says (about Model specs): "these are the only specs that we feel should actually interact with the database" But looking, for example, at the examples at , almost all of them use fixtures. Can someone please clarify why use of fixtures are not recommended? Anyone care to recommend an active, open source Rails project that's using RSpec and which is an exemplar of "best practice"? I'd really like to get things right first time, if I can... Cheers, Wincent From john.paul.ashenfelter at gmail.com Fri May 18 11:16:34 2007 From: john.paul.ashenfelter at gmail.com (John Paul Ashenfelter) Date: Fri, 18 May 2007 08:16:34 -0700 Subject: [rspec-users] problems with textmate and rspec bundle Message-ID: <6553dba10705180816x1a3feb9ei1458b03f9b0a5d82@mail.gmail.com> Folks, I saw David's tutorial yesterday at RailsConf and started working on RSpec lastnight and am having a *ton* of trouble with the bundle for TextMate. I've made *some* progress, but thought I'd throw it to the list * I run ruby, including rb-rubygems using the MacPorts install (per JDD's Sandboxing Rails) * installed rspec 0.9.4 (also rcov 0.8.0.2 and ZenTest 3.5.2) * tried the game.rb /game_spec.rb demo * running $ spec game_spec.rb --format=specdoc works great * installed the RSpec 0.9.4 tmbundle by downloading it and clicking -- nothing fancy #game.rb class Game def hit(pins) end def score 0 end end # game_spec.rb require 'game' describe Game do before(:each) do @game = Game.new end it "should score 0 for gutter game" do 1.upto(20) { @game.hit(0) } @game.score.should == 0 end end Then I tried running from in TextMate (1.5.5) -- argh! My initial attempts resulting in the rubygems load error on line 1, which I solved by adding a .MacOSX/environment.plist with my $PATH contents to avoid the whole thing with the shebang line being a problem. PATH /opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/Users/johnpaul/bin And to make everything smooth, I also set TM_RUBY to /opt/local/bin/ruby But now I'm stuck here when I try to Cmd-R w/ RSpec, It could be user error -- I try to command in the game_spec.rb file and I get the following error /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- game (LoadError) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ./rspec/game_spec.rb:1 from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:85:in `load' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:85:in `load_specs' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:84:in `each' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:84:in `load_specs' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:22:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/command_line.rb:17:in `run' from /Users/johnpaul/Library/Application Support/TextMate/Pristine Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:47:in `run' from /Users/johnpaul/Library/Application Support/TextMate/Pristine Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:46:in `chdir' from /Users/johnpaul/Library/Application Support/TextMate/Pristine Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:46:in `run' from /Users/johnpaul/Library/Application Support/TextMate/Pristine Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:25:in `run_file' from /tmp/temp_textmate.ohalvM:4 So that's saying it can't find the game.rb file? > ls -l rspec total 16 -rwxr--r-- 1 johnpaul johnpaul 62 May 18 08:07 game.rb* -rwxr--r-- 1 johnpaul johnpaul 191 May 18 08:07 game_spec.rb* That seems ok. Just for kicks, I ran rspec on the game.rb file using cmd+r -- that gave me a green bar but said 0 examples, 0 failures so I don't think I'm using it properly. Any ideas/help? -- John Paul Ashenfelter CTO/Transitionpoint (blog) http://www.ashenfelter.com (email) ashenfelterj at transitionpoint.com From aslak.hellesoy at gmail.com Fri May 18 11:32:49 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 18 May 2007 08:32:49 -0700 Subject: [rspec-users] Fixtures considered harmful? In-Reply-To: <45A7F626-DB11-4F49-9E65-80C0D01566F5@wincent.com> References: <45A7F626-DB11-4F49-9E65-80C0D01566F5@wincent.com> Message-ID: <8d961d900705180832k249d7cc9p80898dadb413885e@mail.gmail.com> On 5/18/07, Wincent Colaiuta wrote: > I'm trying to get really serious about doing true BDD for a new Rails > project, and I note that at rails/index.html> it says: > > "we really don't recommend the use of rails fixtures" > > On the same page it also says (about Model specs): > > "these are the only specs that we feel should actually interact with > the database" > > But looking, for example, at the examples at rspec.rubyforge.org/documentation/rails/writing/models.html>, almost > all of them use fixtures. Can someone please clarify why use of > fixtures are not recommended? > We should get this up on the web page, but I'll provide some insight here. The reason why we don't recommend them is along the lines why we're not crazy about DRYing up specs. Let me repeat David's Agile Spec Manifesto (of which I am the second subscriber): We prefer clear spec over well factored specs. (Clarity is king). When everything is in your face you can picture it easier than when it's in several different locations (fixture files, helper files etc). > Anyone care to recommend an active, open source Rails project that's > using RSpec and which is an exemplar of "best practice"? I'd really > like to get things right first time, if I can... > I definitely gave up the term "Best Practice" after reading this blog: http://www.satisfice.com/blog/archives/27 All I can say is that in most situations I prefer to work without fixtures, but there are a few situations where they might be useful. Aslak > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Fri May 18 12:35:30 2007 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 18 May 2007 18:35:30 +0200 Subject: [rspec-users] Fixtures considered harmful? In-Reply-To: <8d961d900705180832k249d7cc9p80898dadb413885e@mail.gmail.com> References: <45A7F626-DB11-4F49-9E65-80C0D01566F5@wincent.com> <8d961d900705180832k249d7cc9p80898dadb413885e@mail.gmail.com> Message-ID: El 18/5/2007, a las 17:32, aslak hellesoy escribi?: >> But looking, for example, at the examples at > rspec.rubyforge.org/documentation/rails/writing/models.html>, almost >> all of them use fixtures. Can someone please clarify why use of >> fixtures are not recommended? >> > > We should get this up on the web page, but I'll provide some insight > here. The reason why we don't recommend them is along the lines why > we're not crazy about DRYing up specs. Let me repeat David's Agile > Spec Manifesto (of which I am the second subscriber): > > We prefer clear spec over well factored specs. (Clarity is king). > > When everything is in your face you can picture it easier than when > it's in several different locations (fixture files, helper files etc). Thanks for the explanation, Aslak. It's very clear. I think a sentence or two to that effect should definitely go up on the website. Cheers, Wincent From blake.pettersson at hotmail.com Fri May 18 13:24:17 2007 From: blake.pettersson at hotmail.com (Blake Pettersson) Date: Fri, 18 May 2007 19:24:17 +0200 Subject: [rspec-users] Stubbing authentication across multiple controllers Message-ID: > Leave your detailed spec as it is for SessionController, but abstract > the functionality out - and stub it - for everyone else. It's your > choice as to where you place the stubs; personally I make the controller > call the before_filter but return immediately by stubbing #logged_in? > and #authorized? as above. This means I can run specs to ensure my > controllers do the right thing if the user is not logged in (the stub > returns false) and/or is not authorized(*). You may also need to stub > methods to return the current_user (etc) as required. Put them in > helper methods as you are doing and use in setup/before blocks as > required. YMMV. > > Best wishes, > Jerry That does indeed sound like the best solution. Thanks! Regards, Blake _________________________________________________________________ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE From john.paul.ashenfelter at gmail.com Fri May 18 13:56:10 2007 From: john.paul.ashenfelter at gmail.com (John Paul Ashenfelter) Date: Fri, 18 May 2007 10:56:10 -0700 Subject: [rspec-users] problems with textmate and rspec bundle In-Reply-To: <6553dba10705180816x1a3feb9ei1458b03f9b0a5d82@mail.gmail.com> References: <6553dba10705180816x1a3feb9ei1458b03f9b0a5d82@mail.gmail.com> Message-ID: <6553dba10705181056m69d4fb2anc8eaa288e99fadb0@mail.gmail.com> Solved it myself -- I had not yet set TM_RSPEC_HOME in TextMate so I added /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/ and it's all good. RTMF, I know :) On 5/18/07, John Paul Ashenfelter wrote: > Folks, > > I saw David's tutorial yesterday at RailsConf and started working on > RSpec lastnight and am having a *ton* of trouble with the bundle for > TextMate. I've made *some* progress, but thought I'd throw it to the > list > > * I run ruby, including rb-rubygems using the MacPorts install (per > JDD's Sandboxing Rails) > * installed rspec 0.9.4 (also rcov 0.8.0.2 and ZenTest 3.5.2) > * tried the game.rb /game_spec.rb demo > * running $ spec game_spec.rb --format=specdoc works great > * installed the RSpec 0.9.4 tmbundle by downloading it and clicking -- > nothing fancy > > #game.rb > class Game > def hit(pins) > end > > def score > 0 > end > end > > # game_spec.rb > require 'game' > > describe Game do > before(:each) do > @game = Game.new > end > > it "should score 0 for gutter game" do > 1.upto(20) { @game.hit(0) } > @game.score.should == 0 > end > end > > Then I tried running from in TextMate (1.5.5) -- argh! > > My initial attempts resulting in the rubygems load error on line 1, > which I solved by adding a .MacOSX/environment.plist with my $PATH > contents to avoid the whole thing with the shebang line being a > problem. > > PATH /opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/Users/johnpaul/bin > > And to make everything smooth, I also set TM_RUBY to /opt/local/bin/ruby > > But now I'm stuck here when I try to Cmd-R w/ RSpec, It could be user > error -- I try to command in the game_spec.rb file and I get the > following error > > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- game (LoadError) from > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in > `require' from ./rspec/game_spec.rb:1 from > /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:85:in > `load' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:85:in > `load_specs' from > /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:84:in > `each' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:84:in > `load_specs' from > /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/behaviour_runner.rb:22:in > `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.9.4/lib/spec/runner/command_line.rb:17:in > `run' from /Users/johnpaul/Library/Application > Support/TextMate/Pristine > Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:47:in `run' from > /Users/johnpaul/Library/Application Support/TextMate/Pristine > Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:46:in `chdir' > from /Users/johnpaul/Library/Application Support/TextMate/Pristine > Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:46:in `run' from > /Users/johnpaul/Library/Application Support/TextMate/Pristine > Copy/Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:25:in `run_file' > from /tmp/temp_textmate.ohalvM:4 > > So that's saying it can't find the game.rb file? > > > ls -l rspec > total 16 > -rwxr--r-- 1 johnpaul johnpaul 62 May 18 08:07 game.rb* > -rwxr--r-- 1 johnpaul johnpaul 191 May 18 08:07 game_spec.rb* > > That seems ok. Just for kicks, I ran rspec on the game.rb file using > cmd+r -- that gave me a green bar but said 0 examples, 0 failures so I > don't think I'm using it properly. > > Any ideas/help? > -- > John Paul Ashenfelter > CTO/Transitionpoint > (blog) http://www.ashenfelter.com > (email) ashenfelterj at transitionpoint.com > -- John Paul Ashenfelter CTO/Transitionpoint (blog) http://www.ashenfelter.com (email) ashenfelterj at transitionpoint.com From mailing_lists at railsnewbie.com Fri May 18 13:59:17 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 18 May 2007 13:59:17 -0400 Subject: [rspec-users] Fixtures considered harmful? In-Reply-To: References: <45A7F626-DB11-4F49-9E65-80C0D01566F5@wincent.com> <8d961d900705180832k249d7cc9p80898dadb413885e@mail.gmail.com> Message-ID: <416C73F1-1B0E-406F-8C94-2E8461FA5FE0@railsnewbie.com> On May 18, 2007, at 12:35 PM, Wincent Colaiuta wrote: > El 18/5/2007, a las 17:32, aslak hellesoy escribi?: > >>> But looking, for example, at the examples at >> rspec.rubyforge.org/documentation/rails/writing/models.html>, almost >>> all of them use fixtures. Can someone please clarify why use of >>> fixtures are not recommended? >>> >> >> We should get this up on the web page, but I'll provide some insight >> here. The reason why we don't recommend them is along the lines why >> we're not crazy about DRYing up specs. Let me repeat David's Agile >> Spec Manifesto (of which I am the second subscriber): >> >> We prefer clear spec over well factored specs. (Clarity is king). >> >> When everything is in your face you can picture it easier than when >> it's in several different locations (fixture files, helper files >> etc). > > Thanks for the explanation, Aslak. It's very clear. I think a > sentence or two to that effect should definitely go up on the website. > I just wanted to add my $0.02. I've started using fixtures *only* for field validations. This quickly tells me that I have a good record, that I can unset a field, and that it is invalid. Fixtures really start to become a pain, though, if the fixture has a foreign key, and so largely I stay away from them. The issue of fixtures mainly seems to be a personal preference, and largely context dependent. I think David's advise on this one is good, though, and if you stick to that it's hard to go wrong. Scott > Cheers, > Wincent > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Fri May 18 22:15:55 2007 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 18 May 2007 23:15:55 -0300 Subject: [rspec-users] have_text matcher does not support should_not. Message-ID: <71166b3b0705181915r26e16d7bvea24cb3999cee2f7@mail.gmail.com> Hello Guys, Doing conversion of some test for some controllers, still with integrated views. Anyway, I have this: it "should not see Join This Group button on profile page as member" do get "show", :id => @group.id response.should be_success response.should_not have_text(/Join This Group/) end But running with spec (0.9.4), drop me the folling error: Matcher does not support should_not. See Spec::Matchers for more information about matchers. Which is contradictory, since RDoc state otherwise: http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000014 response.should have_text(expected) response.should_not have_text(expected) Just a bug? If so, I'm filling a a report at rubyforge. Thanks in advance -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Fri May 18 22:36:25 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 18 May 2007 19:36:25 -0700 Subject: [rspec-users] have_text matcher does not support should_not. In-Reply-To: <71166b3b0705181915r26e16d7bvea24cb3999cee2f7@mail.gmail.com> References: <71166b3b0705181915r26e16d7bvea24cb3999cee2f7@mail.gmail.com> Message-ID: <57c63afe0705181936n5f5079afpb998d989e092fe20@mail.gmail.com> On 5/18/07, Luis Lavena wrote: > Hello Guys, > > Doing conversion of some test for some controllers, still with integrated views. > > Anyway, I have this: > > it "should not see Join This Group button on profile page as member" do > get "show", :id => @group.id > response.should be_success > response.should_not have_text(/Join This Group/) > end > > But running with spec (0.9.4), drop me the folling error: > > Matcher does not support should_not. > See Spec::Matchers for more information > about matchers. > > Which is contradictory, since RDoc state otherwise: > > http://rspec.rubyforge.org/rdoc-rails/classes/Spec/Rails/Matchers.html#M000014 > > response.should have_text(expected) > response.should_not have_text(expected) > > Just a bug? If so, I'm filling a a report at rubyforge. Just a bug. Please file. > > Thanks in advance > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Fri May 18 22:53:27 2007 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 18 May 2007 23:53:27 -0300 Subject: [rspec-users] have_text matcher does not support should_not. In-Reply-To: <57c63afe0705181936n5f5079afpb998d989e092fe20@mail.gmail.com> References: <71166b3b0705181915r26e16d7bvea24cb3999cee2f7@mail.gmail.com> <57c63afe0705181936n5f5079afpb998d989e092fe20@mail.gmail.com> Message-ID: <71166b3b0705181953q2ea5e323q4e6ad4512419610a@mail.gmail.com> On 5/18/07, David Chelimsky wrote: > On 5/18/07, Luis Lavena wrote: [...] > > > > response.should have_text(expected) > > response.should_not have_text(expected) > > > > Just a bug? If so, I'm filling a a report at rubyforge. > > Just a bug. Please file. > Ok, until gets fixed: response.should_not !have_text(/Join This Group/) -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From win at wincent.com Sat May 19 07:08:29 2007 From: win at wincent.com (Wincent Colaiuta) Date: Sat, 19 May 2007 13:08:29 +0200 Subject: [rspec-users] RSpec 1.0.0 and a couple of other things Message-ID: <11C706E5-F20C-44E7-ACF5-1F5A0A85208F@wincent.com> First up, congratulations to the team on RSpec 1.0.0! RSpec is one of the most vibrant and professionally-run projects in the world of Ruby open source. Now that there is a commitment to a stable API I think we'll see RSpec really take off. Two quick things... In the absence of official Spec::UI docs, can Spec::UI be installed as a Rails plug-in? eg. script/plugin install svn://rubyforge.org/var/svn/rspec/tags/ REL_1_0_0/spec_ui Or is installing via RubyGems as per Aslak's post () the only "supported" way? And a quick bug report (can't login to RubyForge due to transparent proxy issues): The README.txt file that comes with Spec::UI 0.2.2 points to a non- existent page: Cheers, Wincent From aslak.hellesoy at gmail.com Sat May 19 13:04:06 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 19 May 2007 10:04:06 -0700 Subject: [rspec-users] RSpec 1.0.0 and a couple of other things In-Reply-To: <11C706E5-F20C-44E7-ACF5-1F5A0A85208F@wincent.com> References: <11C706E5-F20C-44E7-ACF5-1F5A0A85208F@wincent.com> Message-ID: <8d961d900705191004n3ab65ffif03493626144f10b@mail.gmail.com> On 5/19/07, Wincent Colaiuta wrote: > First up, congratulations to the team on RSpec 1.0.0! RSpec is one of > the most vibrant and professionally-run projects in the world of Ruby > open source. Now that there is a commitment to a stable API I think > we'll see RSpec really take off. > > Two quick things... > > In the absence of official Spec::UI docs, can Spec::UI be installed > as a Rails plug-in? eg. > > script/plugin install svn://rubyforge.org/var/svn/rspec/tags/ > REL_1_0_0/spec_ui > It would need some minor changes in order to work smoothly. I'll try to iron it out in the coming days/week. > Or is installing via RubyGems as per Aslak's post ( rubyforge.org/pipermail/rspec-users/2007-May/001541.html>) the only > "supported" way? > All it needs is an init.rb plus a rake task that works properly. > And a quick bug report (can't login to RubyForge due to transparent > proxy issues): > > The README.txt file that comes with Spec::UI 0.2.2 points to a non- > existent page: > > screenshots-from-watir> > Sorry about that - the links got messed up when I switched blogging system. It's out of date anyway. Aslak > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Sat May 19 14:00:48 2007 From: win at wincent.com (Wincent Colaiuta) Date: Sat, 19 May 2007 20:00:48 +0200 Subject: [rspec-users] Reflections on and questions about the describe/it syntax Message-ID: <55392EF5-1336-4C53-B098-3942E63FB752@wincent.com> I'm trying to wrap my head around the new describe/it syntax. First, a few of observations: - the "describe" word itself encourages you to think about contexts as things/nouns; this is reinforced by the way "script/generate rspec_model" and friends by default generate a template spec of the form "describe ClassName do ... end", because classes so often represent "things" (even if they are abstract things like relationships) - the ability to follow a bare class name with a qualifying string -- example: 'describe Stack, "(with one item)" do' -- further extends this pattern to encourage you to think of your contexts not only as "things", but as "things" with a certain state - finally, the "it" syntax used for the examples, almost always followed by the word "should", encourages you to think about specific behaviours within the context, which I guess is what the goals of RSpec are all about In many cases this works great and I have little trouble mapping the desired behaviours to the equivalent RSpec lingo. RSpec "steers" me towards writing specs along these lines: - User (without a login name) - should be invalid - User (with a non-unique login name) - should be invalid - User (with login name less than three characters long) - should be invalid But I start to feel uncomfortable with the repetition after a while, and I am not sure I am doing the right thing. What I really want to say is: - User - should have a valid login name - login name should be present - login name should be unique - login name should be three or more characters long - etc But if I start writing my specs like that I am getting further away from the one-spec-per-example ideal that some people argue for. Is this a bad thing? Which is clearer? "Clarity is king", after all. I also wonder about the difference between: - User (with a login name containing a space) - should be invalid And: - User - should be invalid if login name contains a space Should I be trying to keep my "it" examples totally free of conditional language? (eg. "should be something if something"). I personally think the conditional form reads more clearly. Basically, I am trying to go with the flow and work in the way that RSpec expects me to work. I figure if I do that then things will work out more easily for me. Words of wisdom, anyone? Best wishes, Wincent From dchelimsky at gmail.com Sat May 19 17:10:04 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 19 May 2007 14:10:04 -0700 Subject: [rspec-users] [ANN] RSpec 1.0 Message-ID: <57c63afe0705191410w4824da7fxd138998321eeafd5@mail.gmail.com> The RSpec Development Team is extraordinarily pleased to announce the release of RSpec-1.0.0. == RSpec RSpec provides a Domain Specific Language for describing and verifying the behaviour of Ruby code with executable examples. Some people like to call these examples "tests". In fact, they are. But we believe that tests have equally important value as documentation and as a design aid, and that the testing nomenclature and syntax in most unit testing frameworks keep too much focus on only the testing value, and hide the design and documentation value. This belief was a prime motivator for the emergence of Behaviour Driven Development, and RSpec is the original BDD tool in Ruby. == 1.0.0 This release represents a stake in the ground for the current API. While RSpec will certainly continue to grow as more people use it and provide valuable feedback, we are committed to the supporting the current API. Does this mean that we'll never break backwards compatibility again? We hope that it does. Of course, we can not predict all of the great ideas will come along. If we find ourselves in a situation in which such a change requires breaking backwards compatibility, we will only do so in a major release (i.e. 2.0.0), and will continue to support the previous major release for a reasonable amount of time. == Thanks We'd like to thank the 300+ members of the rspec-users and rspec-devel mailing lists who provide us with consistently invaluable feedback. We'd also like to thank the 40 contributors who have helped to fix nearly 200 bugs and 150 feature requests since Steve Baker registered RSpec in July of 2005. See http://rspec.rubyforge.org/community/index.html. == Numbers and facts * 16000 Downloads (ranked 31 on Rubyforge) * 40 contributors (bugfixes and patches) * 2000 svn commits * 890,000 Google hits for rspec+ruby * 100% coverage * 100% Self-describing == The RSpec Development Team is David Chelimsky Aslak Helles?y Brian Takita Dave Astels Steve Baker (the original author) From blake.pettersson at hotmail.com Sun May 20 11:55:39 2007 From: blake.pettersson at hotmail.com (Blake Pettersson) Date: Sun, 20 May 2007 17:55:39 +0200 Subject: [rspec-users] How to test for exceptions Message-ID: Hi folks, I'm in the process of converting a Test::Unit functional test to RSpec, but I've run into a slight problem. I tried looking through the documentation but I still don't know what I missed. Thanks in advance, Blake describe VenuesController, "on update" do before(:each) do @venue = mock("venue") @venue.stub!(:new_record?).and_return(false) @venue.stub!(:to_param).and_return('1') controller.class.send(:define_method, :rescue_action) { |e| raise e } end it "should raise an error if record is invalid" do stub_authorized_login Venue.should_receive(:find).and_return(@venue) @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) end end describe VenuesController, "on create" do before(:each) do @venue = mock("venue") @venue.stub!(:new_record?).and_return(true) @venue.stub!(:to_param).and_return('1') Venue.stub!(:new).and_return(@venue) controller.class.send(:define_method, :rescue_action) { |e| raise e } end it "should raise an error if record is invalid" do stub_authorized_login @venue.should_receive(:save!).and_return(false) lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) end end 1) 'VenuesController on update should raise an error if record is invalid' FAILED expected ActiveRecord::RecordInvalid, got # 2) 'VenuesController on create should raise an error if record is invalid' FAILED expected ActiveRecord::RecordInvalid but nothing was raised _________________________________________________________________ Connect to the next generation of MSN Messenger? http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline From aslak.hellesoy at gmail.com Sun May 20 12:04:59 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 20 May 2007 09:04:59 -0700 Subject: [rspec-users] How to test for exceptions In-Reply-To: References: Message-ID: <8d961d900705200904j6ab407cbi595ed0873fe85f54@mail.gmail.com> On 5/20/07, Blake Pettersson wrote: > > Hi folks, > > I'm in the process of converting a Test::Unit functional test to RSpec, but I've run into a slight problem. I tried looking through the documentation but I still don't know what I missed. > > Thanks in advance, > Blake > > describe VenuesController, "on update" do > before(:each) do > @venue = mock("venue") > @venue.stub!(:new_record?).and_return(false) > @venue.stub!(:to_param).and_return('1') > controller.class.send(:define_method, :rescue_action) { |e| raise e } > end > > it "should raise an error if record is invalid" do > stub_authorized_login > Venue.should_receive(:find).and_return(@venue) > @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) > lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) > end > end > > describe VenuesController, "on create" do > > before(:each) do > @venue = mock("venue") > @venue.stub!(:new_record?).and_return(true) > @venue.stub!(:to_param).and_return('1') > Venue.stub!(:new).and_return(@venue) > controller.class.send(:define_method, :rescue_action) { |e| raise e } > end > > it "should raise an error if record is invalid" do > stub_authorized_login > @venue.should_receive(:save!).and_return(false) > lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) > end > end > > 1) > 'VenuesController on update should raise an error if record is invalid' FAILED > expected ActiveRecord::RecordInvalid, got # > > 2) > 'VenuesController on create should raise an error if record is invalid' FAILED > expected ActiveRecord::RecordInvalid but nothing was raised > Is this shell output? Is there no backtrace? Aslak > > _________________________________________________________________ > Connect to the next generation of MSN Messenger > http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From blake.pettersson at hotmail.com Sun May 20 12:27:16 2007 From: blake.pettersson at hotmail.com (Blake Pettersson) Date: Sun, 20 May 2007 18:27:16 +0200 Subject: [rspec-users] How to test for exceptions Message-ID: ---------------------------------------- > Date: Sun, 20 May 2007 09:04:59 -0700 > From: aslak.hellesoy at gmail.com > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] How to test for exceptions > > On 5/20/07, Blake Pettersson wrote: > > > > Hi folks, > > > > I'm in the process of converting a Test::Unit functional test to RSpec, but I've run into a slight problem. I tried looking through the documentation but I still don't know what I missed. > > > > Thanks in advance, > > Blake > > > > describe VenuesController, "on update" do > > before(:each) do > > @venue = mock("venue") > > @venue.stub!(:new_record?).and_return(false) > > @venue.stub!(:to_param).and_return('1') > > controller.class.send(:define_method, :rescue_action) { |e| raise e } > > end > > > > it "should raise an error if record is invalid" do > > stub_authorized_login > > Venue.should_receive(:find).and_return(@venue) > > @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) > > lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) > > end > > end > > > > describe VenuesController, "on create" do > > > > before(:each) do > > @venue = mock("venue") > > @venue.stub!(:new_record?).and_return(true) > > @venue.stub!(:to_param).and_return('1') > > Venue.stub!(:new).and_return(@venue) > > controller.class.send(:define_method, :rescue_action) { |e| raise e } > > end > > > > it "should raise an error if record is invalid" do > > stub_authorized_login > > @venue.should_receive(:save!).and_return(false) > > lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) > > end > > end > > > > 1) > > 'VenuesController on update should raise an error if record is invalid' FAILED > > expected ActiveRecord::RecordInvalid, got # > > > > 2) > > 'VenuesController on create should raise an error if record is invalid' FAILED > > expected ActiveRecord::RecordInvalid but nothing was raised > > > > Is this shell output? Is there no backtrace? > > Aslak > > > > > _________________________________________________________________ > > Connect to the next generation of MSN Messenger > > http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline > > _______________________________________________ > > 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 Yes it is shell output. The full output follows: 3) 'VenuesController on create should raise an error if record is invalid' FAILED expected ActiveRecord::RecordInvalid but nothing was raised ./spec/controllers/venues_controller_spec.rb:60: script/spec:4: line 60: lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) I just realised that I posted to the wrong action on the update spec. The spec still doesn't pass though. The modified code: it "should raise an error if record is invalid" do stub_authorized_login Venue.should_receive(:find).and_return(@venue) @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) lambda {put :update, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) end The new error: 2) 'VenuesController on update should raise an error if record is invalid' FAILED expected ActiveRecord::RecordInvalid but nothing was raised ./spec/controllers/venues_controller_spec.rb:32: script/spec:4: line 32 is lambda {put :update, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) Regards, Blake _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us From aslak.hellesoy at gmail.com Sun May 20 12:40:08 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 20 May 2007 09:40:08 -0700 Subject: [rspec-users] How to test for exceptions In-Reply-To: References: Message-ID: <8d961d900705200940p3fe5b0c2y12b0fbaf62d32bbc@mail.gmail.com> Now I got confused. The error messages in your first post are not the same as in the second one: 'VenuesController on update should raise an error if record is invalid' FAILED expected ActiveRecord::RecordInvalid, got # versus 'VenuesController on update should raise an error if record is invalid' FAILED expected ActiveRecord::RecordInvalid but nothing was raised ./spec/controllers/venues_controller_spec.rb:32: script/spec:4: Plese post a whole new email with both code and error messages. Aslak On 5/20/07, Blake Pettersson wrote: > > ---------------------------------------- > > Date: Sun, 20 May 2007 09:04:59 -0700 > > From: aslak.hellesoy at gmail.com > > To: rspec-users at rubyforge.org > > Subject: Re: [rspec-users] How to test for exceptions > > > > On 5/20/07, Blake Pettersson wrote: > > > > > > Hi folks, > > > > > > I'm in the process of converting a Test::Unit functional test to RSpec, but I've run into a slight problem. I tried looking through the documentation but I still don't know what I missed. > > > > > > Thanks in advance, > > > Blake > > > > > > describe VenuesController, "on update" do > > > before(:each) do > > > @venue = mock("venue") > > > @venue.stub!(:new_record?).and_return(false) > > > @venue.stub!(:to_param).and_return('1') > > > controller.class.send(:define_method, :rescue_action) { |e| raise e } > > > end > > > > > > it "should raise an error if record is invalid" do > > > stub_authorized_login > > > Venue.should_receive(:find).and_return(@venue) > > > @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) > > > lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) > > > end > > > end > > > > > > describe VenuesController, "on create" do > > > > > > before(:each) do > > > @venue = mock("venue") > > > @venue.stub!(:new_record?).and_return(true) > > > @venue.stub!(:to_param).and_return('1') > > > Venue.stub!(:new).and_return(@venue) > > > controller.class.send(:define_method, :rescue_action) { |e| raise e } > > > end > > > > > > it "should raise an error if record is invalid" do > > > stub_authorized_login > > > @venue.should_receive(:save!).and_return(false) > > > lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) > > > end > > > end > > > > > > 1) > > > 'VenuesController on update should raise an error if record is invalid' FAILED > > > expected ActiveRecord::RecordInvalid, got # > > > > > > 2) > > > 'VenuesController on create should raise an error if record is invalid' FAILED > > > expected ActiveRecord::RecordInvalid but nothing was raised > > > > > > > Is this shell output? Is there no backtrace? > > > > Aslak > > > > > > > > _________________________________________________________________ > > > Connect to the next generation of MSN Messenger > > > http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline > > > _______________________________________________ > > > 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 > > Yes it is shell output. > > The full output follows: > > 3) > 'VenuesController on create should raise an error if record is invalid' FAILED > expected ActiveRecord::RecordInvalid but nothing was raised > ./spec/controllers/venues_controller_spec.rb:60: > script/spec:4: > > line 60: lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid) > > I just realised that I posted to the wrong action on the update spec. The spec still doesn't pass though. > > The modified code: > > it "should raise an error if record is invalid" do > stub_authorized_login > Venue.should_receive(:find).and_return(@venue) > @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) > lambda {put :update, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) > end > > The new error: > > 2) > 'VenuesController on update should raise an error if record is invalid' FAILED > expected ActiveRecord::RecordInvalid but nothing was raised > ./spec/controllers/venues_controller_spec.rb:32: > script/spec:4: > > line 32 is lambda {put :update, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) > > Regards, > Blake > > _________________________________________________________________ > Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From blake.pettersson at hotmail.com Sun May 20 12:50:02 2007 From: blake.pettersson at hotmail.com (Blake Pettersson) Date: Sun, 20 May 2007 18:50:02 +0200 Subject: [rspec-users] How to test for exceptions Message-ID: Sorry about that, I should've been more clear. After sending the first message, I realised that I had sent a post to the wrong method in my spec (I sent it to create instead of update, as I meant to). Since I altered the code to reflect my true intention, so did the error message. Here's the new (and hopefully correct) spec + error message: describe VenuesController, "on update" do before(:each) do @venue = mock("venue") @venue.stub!(:new_record?).and_return(false) @venue.stub!(:to_param).and_return('1') controller.class.send(:define_method, :rescue_action) { |e| raise e } end it "should raise an error if record is invalid" do stub_authorized_login Venue.should_receive(:find).and_return(@venue) @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) lambda {put :update, :id => @venue, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) end end 2) 'VenuesController on update should raise an error if record is invalid' FAILED expected ActiveRecord::RecordInvalid but nothing was raised ./spec/controllers/venues_controller_spec.rb:32: script/spec:4: Line 32 is in this case the last line in the spec (i.e the error assertion). Blake ---------------------------------------- > Date: Sun, 20 May 2007 09:40:08 -0700 > From: aslak.hellesoy at gmail.com > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] How to test for exceptions > > Now I got confused. The error messages in your first post are not the > same as in the second one: > > 'VenuesController on update should raise an error if record is invalid' FAILED > expected ActiveRecord::RecordInvalid, got # > > versus > > 'VenuesController on update should raise an error if record is invalid' FAILED > expected ActiveRecord::RecordInvalid but nothing was raised > ./spec/controllers/venues_controller_spec.rb:32: > script/spec:4: > > Plese post a whole new email with both code and error messages. > > Aslak > > > The new error: > > > > 2) > > 'VenuesController on update should raise an error if record is invalid' FAILED > > expected ActiveRecord::RecordInvalid but nothing was raised > > ./spec/controllers/venues_controller_spec.rb:32: > > script/spec:4: > > > > line 32 is lambda {put :update, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) > > > > Regards, > > Blake > > > > _________________________________________________________________ > > Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! > > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us > > _______________________________________________ > > 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 _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE From aslak.hellesoy at gmail.com Sun May 20 13:09:35 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 20 May 2007 10:09:35 -0700 Subject: [rspec-users] How to test for exceptions In-Reply-To: References: Message-ID: <8d961d900705201009j19444348m79c1c9d3866d083b@mail.gmail.com> On 5/20/07, Blake Pettersson wrote: > > Sorry about that, I should've been more clear. After sending the first message, I realised that I had sent a post to the wrong method in my spec (I sent it to create instead of update, as I meant to). Since I altered the code to reflect my true intention, so did the error message. Here's the new (and hopefully correct) spec + error message: > > describe VenuesController, "on update" do > > before(:each) do > @venue = mock("venue") > @venue.stub!(:new_record?).and_return(false) > @venue.stub!(:to_param).and_return('1') > controller.class.send(:define_method, :rescue_action) { |e| raise e } > end > > it "should raise an error if record is invalid" do > stub_authorized_login > Venue.should_receive(:find).and_return(@venue) > @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) > lambda {put :update, :id => @venue, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) > end > end > > 2) > 'VenuesController on update should raise an error if record is invalid' FAILED > expected ActiveRecord::RecordInvalid but nothing was raised > ./spec/controllers/venues_controller_spec.rb:32: > script/spec:4: > You generally don't want the controller to raise an error, as it will utterly confuse your users to see a Ruby backtrace. (Scaffold-generated controllers never raise exceptions). Instead you'd want to render a special page when the update fails. Here is what I would do: describe VenuesController, "on update" do before(:each) do @venue = mock_model(Venue) Venue.should_receive(:find).and_return(@venue) end it "should re-render edit after unsuccessful update" do stub_authorized_login @venue.should_receive(:update_attributes!).and_return(false) put :update response.should render_template('edit') end end Aslak > Line 32 is in this case the last line in the spec (i.e the error assertion). > > Blake > > > > ---------------------------------------- > > Date: Sun, 20 May 2007 09:40:08 -0700 > > From: aslak.hellesoy at gmail.com > > To: rspec-users at rubyforge.org > > Subject: Re: [rspec-users] How to test for exceptions > > > > Now I got confused. The error messages in your first post are not the > > same as in the second one: > > > > 'VenuesController on update should raise an error if record is invalid' FAILED > > expected ActiveRecord::RecordInvalid, got # > > > > versus > > > > 'VenuesController on update should raise an error if record is invalid' FAILED > > expected ActiveRecord::RecordInvalid but nothing was raised > > ./spec/controllers/venues_controller_spec.rb:32: > > script/spec:4: > > > > Plese post a whole new email with both code and error messages. > > > > Aslak > > > > > > The new error: > > > > > > 2) > > > 'VenuesController on update should raise an error if record is invalid' FAILED > > > expected ActiveRecord::RecordInvalid but nothing was raised > > > ./spec/controllers/venues_controller_spec.rb:32: > > > script/spec:4: > > > > > > line 32 is lambda {put :update, :venue => {"name" => "random text"}}.should raise_error(ActiveRecord::RecordInvalid) > > > > > > Regards, > > > Blake > > > > > > _________________________________________________________________ > > > Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! > > > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us > > > _______________________________________________ > > > 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 > > _________________________________________________________________ > Explore the seven wonders of the world > http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From blake.pettersson at hotmail.com Sun May 20 13:29:45 2007 From: blake.pettersson at hotmail.com (Blake Pettersson) Date: Sun, 20 May 2007 19:29:45 +0200 Subject: [rspec-users] How to test for exceptions Message-ID: > You generally don't want the controller to raise an error, as it will > utterly confuse your users to see a Ruby backtrace. > (Scaffold-generated controllers never raise exceptions). Instead you'd > want to render a special page when the update fails. Here is what I > would do: > > describe VenuesController, "on update" do > before(:each) do > @venue = mock_model(Venue) > Venue.should_receive(:find).and_return(@venue) > end > > it "should re-render edit after unsuccessful update" do > stub_authorized_login > @venue.should_receive(:update_attributes!).and_return(false) > put :update > response.should render_template('edit') > end > end > > Aslak > I do catch the exceptions. Using the exceptional plugin, I catch any ActiveRecord::RecordInvalid exceptions on create/update and render a new/edit template. Blake _________________________________________________________________ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE From dylanegan at gmail.com Sun May 20 16:53:11 2007 From: dylanegan at gmail.com (Dylan Egan) Date: Sun, 20 May 2007 13:53:11 -0700 Subject: [rspec-users] How to test for exceptions In-Reply-To: References: Message-ID: You want update_attributes! to raise the exception. Otherwise if you're returning false you'll want to be using update_attributes and if else statements. So something like it "should ..." do @venue.should_receive(:update_attributes!).with("name" => "random text").and_raise(ActiveRecord::RecordInvalid.new(mock_invalid_record)) do_update_call end it "should ..." do do_update_call response.should render_template(:edit) end This is the mock I create for invalid records. def mock_invalid_record(name = 'invalid_record') invalid_record, errors = mock(name), mock('errors') invalid_record.stub!(:errors).and_return(errors) errors.stub!(:full_messages).and_return(['errors']) invalid_record end From pergesu at gmail.com Mon May 21 02:31:31 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 21 May 2007 00:31:31 -0600 Subject: [rspec-users] Just upgraded to 1.0.0, should render_text isn't working for me Message-ID: <810a540e0705202331w3331ea4cu4242ab82f63ae4ba@mail.gmail.com> I finally got around to upgrading from 0.8.2 (!!). I had a spec which looked like specify "should render abc123" do controller.should_render :text => "abc123" get :key end With 1.0.0, the new spec is it "should render abc123" do get :key response.should render_text("abc123") end However it doesn't work, giving me the error: undefined method `render_text' for #<#:0x381a454> I installed the 1.0.0 rails plugin, and ran script/generate rspec again. Any ideas as to what's wrong? Pat From dchelimsky at gmail.com Mon May 21 04:31:28 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 21 May 2007 01:31:28 -0700 Subject: [rspec-users] Just upgraded to 1.0.0, should render_text isn't working for me In-Reply-To: <810a540e0705202331w3331ea4cu4242ab82f63ae4ba@mail.gmail.com> References: <810a540e0705202331w3331ea4cu4242ab82f63ae4ba@mail.gmail.com> Message-ID: <57c63afe0705210131j2ef76542yd7e618aae658ac60@mail.gmail.com> On 5/20/07, Pat Maddox wrote: > I finally got around to upgrading from 0.8.2 (!!). I had a spec which > looked like > > specify "should render abc123" do > controller.should_render :text => "abc123" > get :key > end > > With 1.0.0, the new spec is > > it "should render abc123" do > get :key > response.should render_text("abc123") > end > > However it doesn't work, giving me the error: > undefined method `render_text' for #<#:0x381a454> Try have_text instead of render_text. Cheers, David > > I installed the 1.0.0 rails plugin, and ran script/generate rspec > again. Any ideas as to what's wrong? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From blake.pettersson at hotmail.com Mon May 21 05:54:10 2007 From: blake.pettersson at hotmail.com (Blake Pettersson) Date: Mon, 21 May 2007 11:54:10 +0200 Subject: [rspec-users] How to test for exceptions Message-ID: This was just what I needed, thanks! ---------------------------------------- > Date: Sun, 20 May 2007 13:53:11 -0700 > From: dylanegan at gmail.com > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] How to test for exceptions > > You want update_attributes! to raise the exception. Otherwise if > you're returning false you'll want to be using update_attributes and > if else statements. > > So something like > > it "should ..." do > @venue.should_receive(:update_attributes!).with("name" => "random > text").and_raise(ActiveRecord::RecordInvalid.new(mock_invalid_record)) > do_update_call > end > > it "should ..." do > do_update_call > response.should render_template(:edit) > end > > This is the mock I create for invalid records. > > def mock_invalid_record(name = 'invalid_record') > invalid_record, errors = mock(name), mock('errors') > invalid_record.stub!(:errors).and_return(errors) > errors.stub!(:full_messages).and_return(['errors']) > invalid_record > end > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us From pocketsized at tiscali.co.uk Mon May 21 13:08:50 2007 From: pocketsized at tiscali.co.uk (David Green) Date: Mon, 21 May 2007 18:08:50 +0100 Subject: [rspec-users] slow execution times using spec_server Message-ID: <9612333e0705211008rd9a4740te04b0e0d1de5d85c@mail.gmail.com> hi all I'm seeing strange behaviour when running specs using spec_server. They take longer to execute, and it looks like none of examples are being run. here's the output for a simple spec file using just the spec command: ---------- foo at holly:~/rails/allison$ time ruby/script spec spec/models/listing_spec.rb ...... Finished in 0.060469 seconds 6 examples, 0 failures < --- real 0m1.850s user 0m1.500s sys 0m0.276s ---------- here's the same spec file run using the -X option (and spec_server running): ---------- foo at holly:~/rails/allison$ time ruby/script spec spec/models/listing_spec.rb -X Finished in 1.6e-05 seconds 0 examples, 0 failures < --- real 0m5.441s user 0m0.160s sys 0m0.016s ---------- I havn't got a clue what's going on here, does anyone have any suggestions? I'm using ubuntu 7.04, rspec 1.0.0 and rspec_on_rails 1.0.0 help! dave From pergesu at gmail.com Mon May 21 14:31:55 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 21 May 2007 12:31:55 -0600 Subject: [rspec-users] Just upgraded to 1.0.0, should render_text isn't working for me In-Reply-To: <57c63afe0705210131j2ef76542yd7e618aae658ac60@mail.gmail.com> References: <810a540e0705202331w3331ea4cu4242ab82f63ae4ba@mail.gmail.com> <57c63afe0705210131j2ef76542yd7e618aae658ac60@mail.gmail.com> Message-ID: <810a540e0705211131h410de395l55dd791094813633@mail.gmail.com> On 5/21/07, David Chelimsky wrote: > On 5/20/07, Pat Maddox wrote: > > I finally got around to upgrading from 0.8.2 (!!). I had a spec which > > looked like > > > > specify "should render abc123" do > > controller.should_render :text => "abc123" > > get :key > > end > > > > With 1.0.0, the new spec is > > > > it "should render abc123" do > > get :key > > response.should render_text("abc123") > > end > > > > However it doesn't work, giving me the error: > > undefined method `render_text' for #<#:0x381a454> > > Try have_text instead of render_text. Alright, that worked. The docs at http://rspec.rubyforge.org/documentation/rails/writing/controllers.html reference render_text. It seems like a lot of the docs may be out of date...I'm unable to convert my helper specs at this point. http://rspec.rubyforge.org/documentation/rails/writing/helpers.html shows one example using helper_name and one without it. Unfortunately if I don't use helper_name it says that my helper methods aren't defined, but if I use helper_name then it turns out helper_name itself isn't defined. If you could help me get these issues sorted out I'd be more than happy to update the docs accordingly. Pat From aslak.hellesoy at gmail.com Mon May 21 15:50:39 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 21 May 2007 12:50:39 -0700 Subject: [rspec-users] Just upgraded to 1.0.0, should render_text isn't working for me In-Reply-To: <810a540e0705211131h410de395l55dd791094813633@mail.gmail.com> References: <810a540e0705202331w3331ea4cu4242ab82f63ae4ba@mail.gmail.com> <57c63afe0705210131j2ef76542yd7e618aae658ac60@mail.gmail.com> <810a540e0705211131h410de395l55dd791094813633@mail.gmail.com> Message-ID: <8d961d900705211250x1d1fc654q1c374199e2a5ce4a@mail.gmail.com> On 5/21/07, Pat Maddox wrote: > On 5/21/07, David Chelimsky wrote: > > On 5/20/07, Pat Maddox wrote: > > > I finally got around to upgrading from 0.8.2 (!!). I had a spec which > > > looked like > > > > > > specify "should render abc123" do > > > controller.should_render :text => "abc123" > > > get :key > > > end > > > > > > With 1.0.0, the new spec is > > > > > > it "should render abc123" do > > > get :key > > > response.should render_text("abc123") > > > end > > > > > > However it doesn't work, giving me the error: > > > undefined method `render_text' for #<#:0x381a454> > > > > Try have_text instead of render_text. > > Alright, that worked. The docs at > http://rspec.rubyforge.org/documentation/rails/writing/controllers.html > reference render_text. > > It seems like a lot of the docs may be out of date...I'm unable to > convert my helper specs at this point. > http://rspec.rubyforge.org/documentation/rails/writing/helpers.html > shows one example using helper_name and one without it. Unfortunately > if I don't use helper_name it says that my helper methods aren't > defined, but if I use helper_name then it turns out helper_name itself > isn't defined. > Simply saying describe MyHelper should include the MyHelper module directly in the specs - provided you have put your specs under spec/helpers. Is this where you're keeping them? And what OS are you on? Aslak > If you could help me get these issues sorted out I'd be more than > happy to update the docs accordingly. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From carl.lerche at gmail.com Mon May 21 16:36:53 2007 From: carl.lerche at gmail.com (Carl Lerche) Date: Mon, 21 May 2007 13:36:53 -0700 Subject: [rspec-users] Rails' fixtures suck! But what about something like this? Message-ID: Sorry about the very long email, but this is a hairy topic that's been annoying me for some time and I decided to try to do something about. Also, if you got this twice, I apologize too, but it didn't seem to have successfully gone out the first time. Background: ---------- I've been dealing with Rails for about a year and a half now. I've been using Rails' built in testing framework, and it's fine... until I really have to start dealing with the fixtures. I am currently working on an application that really focuses on selecting data using complex logic. The only way to test the application in a meaningful way is by using a large number of fixtures. This has become a real nightmare to manage and I almost am spending more time keeping the fixtures up to date than I am coding or testing. So, I took a moment, stepped back, and took a good look at how I could I could improve fixtures to make my life a lot easier. I have gotten a quick and dirty prototype of my solution running, but before I really roll up my sleeves and start polishing it up, I thought I would try to get some suggestions from the community. Overview: --------- In my experience, the current fixture framework has three main problems: - There is no way to create different version of fixtures. What I mean by this is that you only can have one users.yml file even if your tests depend on different initial conditions. What this usually means is that you will just keep tagging on to the end of users.yml even though it is not the most efficient way to do it. - Managing relationships between tables is a really big pain. One must manually keep track of IDs. This can quickly become a major headache. - There is no clean way to quickly generate data. If I want 50 records that I could easily generate in a loop, I still gotta write them by hand (at least, I wasn't able to figure out how to add loops to my yaml files in a clean way). - There is a lot of repetition. No way to follow DRY. Solution: --------- + Versioned Fixtures First, to address the fixture "versions", I thought the easiest way to do this would be scenarios (I was inspired from fixture-scenarios). The way fixtures could be laid out is as follows: + specs |- fixtures |- global |- only_one_signed_up_user |- lots_of_posts_in_los_angeles |- ... All global fixtures (fixtures that should be loaded before every spec) go into global, then, for each different scenario, there is a directory created with the relevant fixtures in there. Then, in the specs, you could do the following ------------------------------- require File.dirname(__FILE__) + '/../spec_helper' describe User, :when => :only_one_signed_up_user do it "should be the only user" do User.count.should == 1 end end ------------------------------- The key part here would be the :when => :scenario_name option to the describe method. + Writing the fixtures Writing fixtures with YAML is quite ugly. I think a better way to do it would be using a DSL, but coming up with a good syntax is hard. This is where I am the most hesitant. I have two "options" and I was wondering if people could comment on them and give me some feedback and suggestions. - The first option is how I started out: http://pastie.caboo.se/63359 In this option, fixtures for multiple tables can be written in a single file. You would start out by using the _create_ method to tell the parser what table the fixtures are for and you could also specify :with, which would set default attributes for fixtures. You could also nest fixtures in order to easily scope them (see the last user fixture how I specified nested post fixtures). - The second option is what I currently prefer: http://pastie.caboo.se/63361 In this option, I keep the one table per file concept that is currently used. As such, we don't need to specify what table we want to use before hand. I make available a with_options method which lets you set default attributes for fixtures. It's also easy to create loops to automatically generate fixtures, as I show in the second half of the file. The f method is the actual method for creating a fixture. it takes a name as a string and a block in which the attributes of the fixtures are specified. However, the method_missing method is implemented to handle any missing methods and use that to create fixtures too as seen with fixture_name { ... } + Dealing with relationships I think what I hate the most about fixtures right now is having to deal with table relationships. Having to keep track of IDs myself is horrible. So, I thought that the easiest way to do this is making the table_name(:fixture_name) method available straight inside the fixtures. So, if I have a user model that has a location associated with it (let's say a zip code, longitude, and latitude), instead of having to copy / paste that data across fixtures, I can do the following: ------------------------------- local_guy { zip_id zips(:portland) longitude zips(:portland).longitude latitude zips(:portland).latitude } ------------------------------- This is much easier to deal with than the other way around. This also introduces dependencies between fixtures, I thought the easiest way to handle it would be adding a fixture_order configuration: ------------------------------- Spec::Runner.configure do |config| config.fixture_order = :zips, :categories, :users, :posts end ------------------------------- + What's not solved with this I haven't figured out a good way to handle counter_cache columns. Right now, this would still require you to manually count how many fixtures you have associated with a parent and add that to the counter_cache column. Any ideas of a better way to do this? Well, that's all I came up with. I'm going to keep hacking away at this and hopefully you all have some feedback to improve this concept. -- EPA Rating: 3000 Lines of Code / Gallon (of coffee) From pergesu at gmail.com Mon May 21 16:55:39 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 21 May 2007 14:55:39 -0600 Subject: [rspec-users] Just upgraded to 1.0.0, should render_text isn't working for me In-Reply-To: <8d961d900705211250x1d1fc654q1c374199e2a5ce4a@mail.gmail.com> References: <810a540e0705202331w3331ea4cu4242ab82f63ae4ba@mail.gmail.com> <57c63afe0705210131j2ef76542yd7e618aae658ac60@mail.gmail.com> <810a540e0705211131h410de395l55dd791094813633@mail.gmail.com> <8d961d900705211250x1d1fc654q1c374199e2a5ce4a@mail.gmail.com> Message-ID: <810a540e0705211355v2b9c9f74mf45e261c550f59b0@mail.gmail.com> On 5/21/07, aslak hellesoy wrote: > On 5/21/07, Pat Maddox wrote: > > On 5/21/07, David Chelimsky wrote: > > > On 5/20/07, Pat Maddox wrote: > > > > I finally got around to upgrading from 0.8.2 (!!). I had a spec which > > > > looked like > > > > > > > > specify "should render abc123" do > > > > controller.should_render :text => "abc123" > > > > get :key > > > > end > > > > > > > > With 1.0.0, the new spec is > > > > > > > > it "should render abc123" do > > > > get :key > > > > response.should render_text("abc123") > > > > end > > > > > > > > However it doesn't work, giving me the error: > > > > undefined method `render_text' for #<#:0x381a454> > > > > > > Try have_text instead of render_text. > > > > Alright, that worked. The docs at > > http://rspec.rubyforge.org/documentation/rails/writing/controllers.html > > reference render_text. > > > > It seems like a lot of the docs may be out of date...I'm unable to > > convert my helper specs at this point. > > http://rspec.rubyforge.org/documentation/rails/writing/helpers.html > > shows one example using helper_name and one without it. Unfortunately > > if I don't use helper_name it says that my helper methods aren't > > defined, but if I use helper_name then it turns out helper_name itself > > isn't defined. > > > > Simply saying describe MyHelper should include the MyHelper module > directly in the specs - provided you have put your specs under > spec/helpers. > > Is this where you're keeping them? And what OS are you on? > > Aslak > > > If you could help me get these issues sorted out I'd be more than > > happy to update the docs accordingly. > > > > Pat > > _______________________________________________ > > 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 > I was just running the specs with ruby... "ruby my_helper.rb", and it was having those problems. When I ran it with script/spec it ran fine. Pat From pergesu at gmail.com Mon May 21 17:09:57 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 21 May 2007 15:09:57 -0600 Subject: [rspec-users] Spec'ing redirect with arbitrary parameters Message-ID: <810a540e0705211409g764001c2t4990871640531f4e@mail.gmail.com> I've got the following expectation: response.should redirect_to(:action => "new", :video_id => "1", :process_id => "2", :origin_id => "3") that fails with this error message: expected redirect to {:video_id=>"1", :process_id=>"2", :origin_id=>"3", :action=>"new"}, got redirect to "http://test.host/videos/1/screenshot_selections/new?process_id=2&origin_id=3", which cannot be routed within this application (spec using the URL string if the redirection is to an external address) Seems like it doesn't like the process_id and origin_id parameters. Am I doing anything wrong or is it just a bug with the rails plugin? Pat From win at wincent.com Mon May 21 17:18:16 2007 From: win at wincent.com (Wincent Colaiuta) Date: Mon, 21 May 2007 23:18:16 +0200 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag Message-ID: <9DF09F73-6C27-4FFE-BA79-A0E2B5C296E7@wincent.com> When writing view specs is there any way to test not only for the presence of tags (have_tag) and nested tags (with_tag), but also test that they appear in a given order? For example, consider the following: it 'should display the login names, display names and email address in alternating rows' do response.should have_tag('div.odd>div') do with_tag('div', 'example login name 1') with_tag('div', 'example display name 1') with_tag('div', 'example email address 1') end response.should have_tag('div.even>div') do with_tag('div', 'example login name 2') with_tag('div', 'example display name 2') with_tag('div', 'example email address 2') end end I can change the order of the have_tag blocks and I can also change the order of the with_tag calls within each block without breaking the specs. Or to put it alternatively, my view can render the "odd" and "even" divs in a different order, or the nested divs inside each, without breaking the specs. In many cases, this might not matter. But what if I want to test for alternating divs (odd, even, odd even)? I can add multiple have_tag assertions but their order won't be considered, so I'm not really testing the alternation, only for existence. Cheers, Wincent From anibal at rojas.com.ve Mon May 21 19:00:04 2007 From: anibal at rojas.com.ve (=?ISO-8859-1?Q?An=EDbal_Rojas?=) Date: Mon, 21 May 2007 19:00:04 -0400 Subject: [rspec-users] logger anybody? Message-ID: Hello, When trying to use logger into any RSpec I get: logger anyboundefined local variable or method `logger' for #<#:0x253cdec> Not sure if this is the spected behaviour (haven't checked under the hood) It was just annoying not having a logger instance available as in Rails out of the tests. -- An?bal Rojas http://www.rubycorner.com http://www.hasmanydevelopers.com http://www.to2blogs.com http://anibal.rojas.com.ve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070521/8d88fe12/attachment.html From dchelimsky at gmail.com Mon May 21 20:01:23 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 21 May 2007 19:01:23 -0500 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <9DF09F73-6C27-4FFE-BA79-A0E2B5C296E7@wincent.com> References: <9DF09F73-6C27-4FFE-BA79-A0E2B5C296E7@wincent.com> Message-ID: <57c63afe0705211701j509f00cfh84eab720860cc17@mail.gmail.com> On 5/21/07, Wincent Colaiuta wrote: > When writing view specs is there any way to test not only for the > presence of tags (have_tag) and nested tags (with_tag), but also test > that they appear in a given order? > > For example, consider the following: > > it 'should display the login names, display names and email > address in alternating rows' do > response.should have_tag('div.odd>div') do > with_tag('div', 'example login name 1') > with_tag('div', 'example display name 1') > with_tag('div', 'example email address 1') > end > response.should have_tag('div.even>div') do > with_tag('div', 'example login name 2') > with_tag('div', 'example display name 2') > with_tag('div', 'example email address 2') > end > end > > I can change the order of the have_tag blocks and I can also change > the order of the with_tag calls within each block without breaking > the specs. Or to put it alternatively, my view can render the "odd" > and "even" divs in a different order, or the nested divs inside each, > without breaking the specs. > > In many cases, this might not matter. But what if I want to test for > alternating divs (odd, even, odd even)? I can add multiple have_tag > assertions but their order won't be considered, so I'm not really > testing the alternation, only for existence. Not to pass the buck ... but I'm going to pass the buck on this one. have_tag and with_tag wrap assert_select, which ships with Rails. I've actually submitted a couple of patches to assert_select to Rails myself because I'd like to see better error messages and more rjs coverage. I'd encourage you to make this request and/or submit a patch to Rails directly as well. David > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Mon May 21 20:16:13 2007 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 22 May 2007 02:16:13 +0200 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <57c63afe0705211701j509f00cfh84eab720860cc17@mail.gmail.com> References: <9DF09F73-6C27-4FFE-BA79-A0E2B5C296E7@wincent.com> <57c63afe0705211701j509f00cfh84eab720860cc17@mail.gmail.com> Message-ID: <01A103A1-8CA2-4F07-AE33-C29C7A2053D2@wincent.com> El 22/5/2007, a las 2:01, David Chelimsky escribi?: > Not to pass the buck ... but I'm going to pass the buck on this one. > have_tag and with_tag wrap assert_select, which ships with Rails. I've > actually submitted a couple of patches to assert_select to Rails > myself because I'd like to see better error messages and more rjs > coverage. I'd encourage you to make this request and/or submit a patch > to Rails directly as well. Ok, thanks for the advice, David. I've submitted a request ticket: http://dev.rubyonrails.org/ticket/8428 If you have any insight onto what such a patch might involve, please let me know. I don't know enough about Rails internals to work something up yet, but perhaps with some help I might be able to get at least a basic prototype working at some point. Cheers, Wincent From dchelimsky at gmail.com Mon May 21 20:27:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 21 May 2007 19:27:45 -0500 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <01A103A1-8CA2-4F07-AE33-C29C7A2053D2@wincent.com> References: <9DF09F73-6C27-4FFE-BA79-A0E2B5C296E7@wincent.com> <57c63afe0705211701j509f00cfh84eab720860cc17@mail.gmail.com> <01A103A1-8CA2-4F07-AE33-C29C7A2053D2@wincent.com> Message-ID: <57c63afe0705211727t7ab4389nf704329fc01fab8d@mail.gmail.com> On 5/21/07, Wincent Colaiuta wrote: > El 22/5/2007, a las 2:01, David Chelimsky escribi?: > > > Not to pass the buck ... but I'm going to pass the buck on this one. > > have_tag and with_tag wrap assert_select, which ships with Rails. I've > > actually submitted a couple of patches to assert_select to Rails > > myself because I'd like to see better error messages and more rjs > > coverage. I'd encourage you to make this request and/or submit a patch > > to Rails directly as well. > > Ok, thanks for the advice, David. I've submitted a request ticket: > > http://dev.rubyonrails.org/ticket/8428 > > If you have any insight onto what such a patch might involve, please > let me know. I don't know enough about Rails internals to work > something up yet, but perhaps with some help I might be able to get > at least a basic prototype working at some point. You don't have to know too much about Rails internals. assert_select is nicely decoupled from most of it. You will have to put on your regexp fu. Take a look at actionpack/test/controller/selector_assertions.rb and actionpack/lib/action_controller/assertions/selector_assertions.rb. Cheers, David > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bkeepers at gmail.com Mon May 21 23:42:23 2007 From: bkeepers at gmail.com (Brandon Keepers) Date: Mon, 21 May 2007 23:42:23 -0400 Subject: [rspec-users] Spec'ing redirect with arbitrary parameters In-Reply-To: <810a540e0705211409g764001c2t4990871640531f4e@mail.gmail.com> References: <810a540e0705211409g764001c2t4990871640531f4e@mail.gmail.com> Message-ID: <90EEA875-EAA2-47D4-B3B5-4124793A9CA8@gmail.com> On May 21, 2007, at 5:09 PM, Pat Maddox wrote: > I've got the following expectation: > > response.should redirect_to(:action => "new", :video_id => "1", > :process_id => "2", :origin_id => "3") > that fails with this error message: > > expected redirect to {:video_id=>"1", :process_id=>"2", > :origin_id=>"3", :action=>"new"}, got redirect to > "http://test.host/videos/1/screenshot_selections/new? > process_id=2&origin_id=3", > which cannot be routed within this application (spec using the URL > string if the redirection is to an external address) You may need the controller name in the params. It looks like you're using resources. If that's the case, use named routes: response.should redirect_to(resource_path(@video, @process, @origin)) > Seems like it doesn't like the process_id and origin_id parameters. > Am I doing anything wrong or is it just a bug with the rails plugin? My guess is that there is just some little nuance that is wrong. Does the url generate right in the browser? Brandon From joevandyk at gmail.com Tue May 22 03:38:05 2007 From: joevandyk at gmail.com (Joe Van Dyk) Date: Tue, 22 May 2007 00:38:05 -0700 Subject: [rspec-users] Comments wanted about spec'ing out a couple controller methods Message-ID: (oops, accidentally sent this to the rspec-devel list, sorry about that) Could someone help me spec out these Rails controller methods? I don't know where to get started, especially with the transaction stuff. Or, if anyone else could suggest ways I could improve the code, that would be great as well. Puzzle has_one Media. Both are AR model objects. class PuzzlesController < ApplicationController # a before_filter fills in @user def create @puzzle = Puzzle.new(params[:puzzle]) @puzzle.user = @user @media = Media.new(:uploaded_data => params[:media]) Puzzle.transaction do @puzzle.media = @media @puzzle.save! && @media.save! flash[:notice] = "Success!" redirect_to puzzle_path(@puzzle) end rescue ActiveRecord::RecordInvalid => e @media.valid? # force checking of errors even if @puzzle.save! failed flash[:error] = "Problem submitting the One Word Wonder..." render :partial => 'new', :layout => true end def update @puzzle = Puzzle.find params[:id] Puzzle.transaction do @puzzle.attributes = params[:puzzle] if params[:media] and params[:media].size > 0 @puzzle.media = Media.new :uploaded_data => params[:media] end @puzzle.save! && @puzzle.media.save! end rescue ActiveRecord::RecordInvalid => e @media.valid? flash[:error] = "Problem updating the One Word Wonder..." render :action => 'edit' end Thanks, Joe Van Dyk From joevandyk at gmail.com Tue May 22 03:41:30 2007 From: joevandyk at gmail.com (Joe Van Dyk) Date: Tue, 22 May 2007 00:41:30 -0700 Subject: [rspec-users] Running both autotest and rspec_autotest Message-ID: Hi, Is it possible to run both autotest and rspec_autotest at the same time while I convert my tests over to specs? autotest seems to either want to run one or the other. Also, rspec_autotest doesn't seem to red/green the error/successes. It should, right? Thanks, Joe From win at wincent.com Tue May 22 06:43:14 2007 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 22 May 2007 12:43:14 +0200 Subject: [rspec-users] BDD screenscast Message-ID: <86518FC6-19DF-42CA-8171-A888FA074EF9@wincent.com> I posted a quick screencast demonstrating some BDD with RSpec yesterday: http://wincent.com/a/about/wincent/weblog/archives/2007/05/ behaviourdriven.php I'm a C/Objective-C programmer who knows a bit of Ruby, almost nothing about Rails, and in BDD I can really only claim "new but interested" status. It's not scripted, it's totally improvised and unplanned, so there are plenty of mistakes, sub-optimal ideas and things which I mis- said... but hopefully people will get the idea. I think most of the people who read my weblog are fellow Objective-C programmers, but I wanted people to see the kind of workflow you can achieve with RSpec, especially when combined with addons like autotest and Growl. Cheers, Wincent From aslak.hellesoy at gmail.com Tue May 22 07:43:42 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 22 May 2007 04:43:42 -0700 Subject: [rspec-users] Comments wanted about spec'ing out a couple controller methods In-Reply-To: References: Message-ID: <8d961d900705220443l36cf9aa7p7a7a393a521c94d9@mail.gmail.com> On 5/22/07, Joe Van Dyk wrote: > (oops, accidentally sent this to the rspec-devel list, sorry about that) > > Could someone help me spec out these Rails controller methods? I > don't know where to get started, especially with the transaction > stuff. Or, if anyone else could suggest ways I could improve the > code, that would be great as well. > This is a very busy controller. I recommend you move as much logic as possible down to the model. Along the lines of http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model I am almost 100% sure that you wrote this controller before you wrote the spec - or that you don't have a spec. And that's how your controller got so fat ;-) I really recommend writing the spec first - starting with an empty controller (or freshly generated one). Then let the failing tests guide you in what you have to do in the controller - not the other way around. Aslak > Puzzle has_one Media. Both are AR model objects. > > class PuzzlesController < ApplicationController > > # a before_filter fills in @user > > def create > @puzzle = Puzzle.new(params[:puzzle]) > @puzzle.user = @user > > @media = Media.new(:uploaded_data => params[:media]) > > Puzzle.transaction do > @puzzle.media = @media > @puzzle.save! && @media.save! > flash[:notice] = "Success!" > redirect_to puzzle_path(@puzzle) > end > rescue ActiveRecord::RecordInvalid => e > @media.valid? # force checking of errors even if @puzzle.save! > failed > flash[:error] = "Problem submitting the One Word Wonder..." > render :partial => 'new', :layout => true > end > > def update > @puzzle = Puzzle.find params[:id] > Puzzle.transaction do > @puzzle.attributes = params[:puzzle] > if params[:media] and params[:media].size > 0 > @puzzle.media = Media.new :uploaded_data => params[:media] > end > @puzzle.save! && @puzzle.media.save! > end > rescue ActiveRecord::RecordInvalid => e > @media.valid? > flash[:error] = "Problem updating the One Word Wonder..." > render :action => 'edit' > end > > Thanks, > Joe Van Dyk > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Tue May 22 07:48:42 2007 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 22 May 2007 13:48:42 +0200 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <57c63afe0705211727t7ab4389nf704329fc01fab8d@mail.gmail.com> References: <9DF09F73-6C27-4FFE-BA79-A0E2B5C296E7@wincent.com> <57c63afe0705211701j509f00cfh84eab720860cc17@mail.gmail.com> <01A103A1-8CA2-4F07-AE33-C29C7A2053D2@wincent.com> <57c63afe0705211727t7ab4389nf704329fc01fab8d@mail.gmail.com> Message-ID: <942B9674-82A4-4522-A02A-DF7D301ACBED@wincent.com> El 22/5/2007, a las 2:27, David Chelimsky escribi?: > You don't have to know too much about Rails internals. assert_select > is nicely decoupled from most of it. You will have to put on your > regexp fu. > > Take a look at actionpack/test/controller/selector_assertions.rb and > actionpack/lib/action_controller/assertions/selector_assertions.rb. Ok, I've had a look at the both the Rails code in actionpack/lib/ action_controller/assertions/selector_assertions.rb and the RSpec implementations of have_tag and with_tag in lib/spec/rails/matchers/ assert_select.rb (actionpack/test/controller/selector_assertions.rb doesn't exist in either Rails 1.2.3 or trunk; did you mean actionpack/ test/controller/assert_select_test?). I don't necessarily have it fully grokked yet, but my observations of the RSpec side of things thus far are: 1. Each time you invoke "have_tag" you create a new AssertSelect instance under the covers 2. "with_tag" invokes "have_tag" behind the scenes, so that means a new AssertSelect instance gets created there two 3. I presume the method that ends up getting called when you do "should have_tag" is AssertSelect#matches? 4. If and only if the response text is a String, AssertSelect#matches? creates a new HTML::Document instance from it and prepends it to the arguments list 5. Finally, AssertSelect#matches? sends an "assert_select" message to the @spec_scope (which is really "self", ie. the matcher). So that's the way things are by the time Rails receives the message. Observations on the Rails side: 1. It appears that assert_select and friends are included into the object being tested via actionpack/lib/action_controller/assertions.rb. 2. assert_select uses an instance variable, @selected, to allow nesting of assert_select; so perhaps using instance variables may be the way to preserve state between assert_select calls and track the ordering of the elements. The only problem is, as I said I haven't fully grokked this yet so I am not sure what the lifetime of the objects in question are and how long the instance variables will stick around. It seems that a new AssertSelect instance is created for every assertion, every assertion has its own matcher, and the matcher receives the assert_select message, so I am not sure how to achieve the kind of inter-matcher or inter-assertion dependency which would allow ordering comparisons to be made. In other words, I don't know if this can be tackled purely from the Rails side of things. One thing which may prove useful is that assert_select returns an array of matches, and also passes that array into any block (if called with a block). The array contains HTML::Node instances, and these nodes have a position attribute (the position of the node within the byte stream); so making comparisons of order externally is possible and could be down already right now with no changes (although not transparently; you'd have to explicitly compare element positions in your specs). There are two more questions that grow out of this: 1. What would be the ideal "scope" for these order restrictions to take effect? Should multiple have_tag calls within the same example (the same "it" block) be expected to appear in order? Or should it apply to have_tags calls within the same context (the same "describe" block)? Should calling "render" again have the effect of "resetting" things? 2. If this can be implemented, should it apply as a default (might break existing specs), or should it be made optional (pass an additional parameter to indicate that ordering is important?); an alternative would be to add two additional methods, have_tags and with_tags, which would expect an array of selectors rather than a single selector, and would expect them to succeed in order (I almost think that this is the best solution). Any ideas? Cheers, Wincent From dchelimsky at gmail.com Tue May 22 09:48:26 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 22 May 2007 08:48:26 -0500 Subject: [rspec-users] BDD screenscast In-Reply-To: <86518FC6-19DF-42CA-8171-A888FA074EF9@wincent.com> References: <86518FC6-19DF-42CA-8171-A888FA074EF9@wincent.com> Message-ID: <57c63afe0705220648h18aa9ca7x19e90b517e0ed10f@mail.gmail.com> Cool. Thanks for doing this. I really need to get a screen cast or two up myself. FYI - you can get the examples to stop running continuously by removing the following from your spec.opts file: --format failing_examples:previous_failures.txt --example previous_failures.txt These lines configure rspec to limit the number of files that get run when there are failures, but autotest is doing the same thing so there is no need. Cheers, David On 5/22/07, Wincent Colaiuta wrote: > I posted a quick screencast demonstrating some BDD with RSpec yesterday: > > http://wincent.com/a/about/wincent/weblog/archives/2007/05/ > behaviourdriven.php > > I'm a C/Objective-C programmer who knows a bit of Ruby, almost > nothing about Rails, and in BDD I can really only claim "new but > interested" status. > > It's not scripted, it's totally improvised and unplanned, so there > are plenty of mistakes, sub-optimal ideas and things which I mis- > said... but hopefully people will get the idea. > > I think most of the people who read my weblog are fellow Objective-C > programmers, but I wanted people to see the kind of workflow you can > achieve with RSpec, especially when combined with addons like > autotest and Growl. > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From philodespotos at gmail.com Tue May 22 11:13:03 2007 From: philodespotos at gmail.com (Phil O Despotos) Date: Tue, 22 May 2007 10:13:03 -0500 Subject: [rspec-users] rspec_on_rails' spec:doc and dry runs Message-ID: <60f3810c0705220813t13ca3567vb360676abcc0f36a@mail.gmail.com> In rspec_on_rails, the spec:doc task uses --dry-run, which doesn't jive well with rspec's ability to write docs for you. For example, I use the rspec_expectation_matchers plugin from spicycode.com (scanned for a name, didn't find one =), and end up writing specs like: it { @ticket.should validate_presence_of(:name) } Which results in specdocs such as: Ticket - NO NAME (Because of --dry-run) - NO NAME (Because of --dry-run) - NO NAME (Because of --dry-run) The examples_specdoc task for rspec itself, however, doesn't use --dry-run. Using dry runs presumably speeds things up significantly, but results in "broken" docs when using one of rspec's handiest features. Should this be considered proper default behavior? Replacing the task is easy enough, so there's a good case for dry runs being the default behavior. I'm just curious. Kyle From chad at spicycode.com Tue May 22 11:18:23 2007 From: chad at spicycode.com (Chad Humphries) Date: Tue, 22 May 2007 11:18:23 -0400 Subject: [rspec-users] rspec_on_rails' spec:doc and dry runs In-Reply-To: <60f3810c0705220813t13ca3567vb360676abcc0f36a@mail.gmail.com> References: <60f3810c0705220813t13ca3567vb360676abcc0f36a@mail.gmail.com> Message-ID: <16f722280705220818p3951978fhc08f723052c9697c@mail.gmail.com> Phil, I wrote that bit o' code (the plugin at spicycode). I haven't actually used the dry-run mode before. I'll dig in and see what I can find about the issue. Chad On 5/22/07, Phil O Despotos wrote: > > In rspec_on_rails, the spec:doc task uses --dry-run, which doesn't > jive well with rspec's ability to write docs for you. > > For example, I use the rspec_expectation_matchers plugin from > spicycode.com (scanned for a name, didn't find one =), and end up > writing specs like: > > it { @ticket.should validate_presence_of(:name) } > > Which results in specdocs such as: > > Ticket > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > > The examples_specdoc task for rspec itself, however, doesn't use > --dry-run. > > Using dry runs presumably speeds things up significantly, but results > in "broken" docs when using one of rspec's handiest features. Should > this be considered proper default behavior? > > Replacing the task is easy enough, so there's a good case for dry runs > being the default behavior. I'm just curious. > > Kyle > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070522/e99b4da6/attachment.html From dchelimsky at gmail.com Tue May 22 11:40:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 22 May 2007 10:40:05 -0500 Subject: [rspec-users] rspec_on_rails' spec:doc and dry runs In-Reply-To: <60f3810c0705220813t13ca3567vb360676abcc0f36a@mail.gmail.com> References: <60f3810c0705220813t13ca3567vb360676abcc0f36a@mail.gmail.com> Message-ID: <57c63afe0705220840h39383f98r9be4878e1cee54cd@mail.gmail.com> On 5/22/07, Phil O Despotos wrote: > In rspec_on_rails, the spec:doc task uses --dry-run, which doesn't > jive well with rspec's ability to write docs for you. > > For example, I use the rspec_expectation_matchers plugin from > spicycode.com (scanned for a name, didn't find one =), and end up > writing specs like: > > it { @ticket.should validate_presence_of(:name) } > > Which results in specdocs such as: > > Ticket > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) > - NO NAME (Because of --dry-run) Self-generated example names were a feature request that got added much more recently than --dry-run, and the two can't really work together. Self-generated names rely on executing the examples and --dry-run does not actually execute examples. As far as I'm concerned, --dry-run has almost no value, so I'd actually like to see it abolished. 2 cents from the peanut gallery. Cheers, David > > The examples_specdoc task for rspec itself, however, doesn't use --dry-run. > > Using dry runs presumably speeds things up significantly, but results > in "broken" docs when using one of rspec's handiest features. Should > this be considered proper default behavior? > > Replacing the task is easy enough, so there's a good case for dry runs > being the default behavior. I'm just curious. > > Kyle > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From philodespotos at gmail.com Tue May 22 12:11:26 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Tue, 22 May 2007 11:11:26 -0500 Subject: [rspec-users] rspec_on_rails' spec:doc and dry runs In-Reply-To: <16f722280705220818p3951978fhc08f723052c9697c@mail.gmail.com> References: <60f3810c0705220813t13ca3567vb360676abcc0f36a@mail.gmail.com> <16f722280705220818p3951978fhc08f723052c9697c@mail.gmail.com> Message-ID: <60f3810c0705220911x6f776802w7f8088c6442b7c50@mail.gmail.com> On 5/22/07, Chad Humphries wrote: > Phil, > > I wrote that bit o' code (the plugin at spicycode). I haven't actually used > the dry-run mode before. I'll dig in and see what I can find about the > issue. The problem is on --dry-run's end, not yours. But while I'm here, I just ran into an issue with AssociationMatcher when using the belong_to matcher. The association uses singular names (Ticket belongs_to :status), which, when run through :singularize in the AssociationMatcher constructor, turns status into 'statu'. I can hack around it by specifying the class_name on both the model and the spec. I thought I'd be able to just use 'ticket.should belong_to(:statuses)', but that isn't working out. Don't know why, but I haven't had a chance to really look into it. Thanks for the awesome plugin. Kyle (Fixed my name to actually be my name...) From joevandyk at gmail.com Tue May 22 13:06:52 2007 From: joevandyk at gmail.com (Joe Van Dyk) Date: Tue, 22 May 2007 10:06:52 -0700 Subject: [rspec-users] Comments wanted about spec'ing out a couple controller methods In-Reply-To: <8d961d900705220443l36cf9aa7p7a7a393a521c94d9@mail.gmail.com> References: <8d961d900705220443l36cf9aa7p7a7a393a521c94d9@mail.gmail.com> Message-ID: On 5/22/07, aslak hellesoy wrote: > On 5/22/07, Joe Van Dyk wrote: > > (oops, accidentally sent this to the rspec-devel list, sorry about that) > > > > Could someone help me spec out these Rails controller methods? I > > don't know where to get started, especially with the transaction > > stuff. Or, if anyone else could suggest ways I could improve the > > code, that would be great as well. > > > > This is a very busy controller. I recommend you move as much logic as > possible down to the model. Along the lines of > http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model > > I am almost 100% sure that you wrote this controller before you wrote > the spec - or that you don't have a spec. And that's how your > controller got so fat ;-) > > I really recommend writing the spec first - starting with an empty > controller (or freshly generated one). Then let the failing tests > guide you in what you have to do in the controller - not the other way > around. > > Aslak That's obvious. :-) I just started with rspec after the railsconf. There's normal rails tests for these methods, but I'm trying to move towards more mocks. So, in this example, maybe I'd want to do something like this? def create @puzzle = Puzzle.new @puzzle.populate_and_save_with_user_and_puzzle_and_media_attributes @user, params[:puzzle], params[:media] if @puzzle.new_record # error stuff else # success stuff end end And then in Puzzle#populate_and_save_with_user_and_puzzle_and_media_attributes (once i find a better name) would have the transaction stuff in there? > > Puzzle has_one Media. Both are AR model objects. > > > > class PuzzlesController < ApplicationController > > > > # a before_filter fills in @user > > > > def create > > @puzzle = Puzzle.new(params[:puzzle]) > > @puzzle.user = @user > > > > @media = Media.new(:uploaded_data => params[:media]) > > > > Puzzle.transaction do > > @puzzle.media = @media > > @puzzle.save! && @media.save! > > flash[:notice] = "Success!" > > redirect_to puzzle_path(@puzzle) > > end > > rescue ActiveRecord::RecordInvalid => e > > @media.valid? # force checking of errors even if @puzzle.save! > > failed > > flash[:error] = "Problem submitting the One Word Wonder..." > > render :partial => 'new', :layout => true > > end > > > > def update > > @puzzle = Puzzle.find params[:id] > > Puzzle.transaction do > > @puzzle.attributes = params[:puzzle] > > if params[:media] and params[:media].size > 0 > > @puzzle.media = Media.new :uploaded_data => params[:media] > > end > > @puzzle.save! && @puzzle.media.save! > > end > > rescue ActiveRecord::RecordInvalid => e > > @media.valid? > > flash[:error] = "Problem updating the One Word Wonder..." > > render :action => 'edit' > > end > > > > Thanks, > > Joe Van Dyk > > _______________________________________________ > > 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 pergesu at gmail.com Tue May 22 13:55:28 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 22 May 2007 11:55:28 -0600 Subject: [rspec-users] Spec'ing redirect with arbitrary parameters In-Reply-To: <90EEA875-EAA2-47D4-B3B5-4124793A9CA8@gmail.com> References: <810a540e0705211409g764001c2t4990871640531f4e@mail.gmail.com> <90EEA875-EAA2-47D4-B3B5-4124793A9CA8@gmail.com> Message-ID: <810a540e0705221055x76ea5344wd0fcdaf6fc3526d1@mail.gmail.com> On 5/21/07, Brandon Keepers wrote: > > On May 21, 2007, at 5:09 PM, Pat Maddox wrote: > > > I've got the following expectation: > > > > response.should redirect_to(:action => "new", :video_id => "1", > > :process_id => "2", :origin_id => "3") > > > that fails with this error message: > > > > expected redirect to {:video_id=>"1", :process_id=>"2", > > :origin_id=>"3", :action=>"new"}, got redirect to > > "http://test.host/videos/1/screenshot_selections/new? > > process_id=2&origin_id=3", > > which cannot be routed within this application (spec using the URL > > string if the redirection is to an external address) > > You may need the controller name in the params. > > It looks like you're using resources. If that's the case, use named > routes: > > response.should redirect_to(resource_path(@video, @process, @origin)) Cool, I changed it to response.should redirect_to(new_screenshot_selection_path(:video_id => "1", :process_id => "2", :origin_id => "3")) and it works fine now. Thanks for the tip. Pat From jonathan at parkerhill.com Tue May 22 16:44:00 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 22 May 2007 16:44:00 -0400 Subject: [rspec-users] rails edge Message-ID: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> hi, first time trying rspec, and rails edge. Are there any known issues running rspec with rails edge? for one, apparently script/generate scaffold_resource has been renamed just "resource". Do I just search/replace "scaffold_resource" with "resource" in file rspec_resource_generator.rb ? Somethings still missing. before i get "Couldn't find 'scaffold_resource' generator" after the edit i get "No such file or directory - [myprojectpath]/vendor/rails/railties/ lib/rails_generator/generators/components/resource/templates/ view_index.rhtml From jonathan at parkerhill.com Tue May 22 16:56:23 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 22 May 2007 16:56:23 -0400 Subject: [rspec-users] rails edge In-Reply-To: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> References: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> Message-ID: i also tried search/replace "scaffold_resource" with "scaffold" in file vendor/plugins/rspec_on_rails/generators/rspec_resource/ rspec_resource_generator.rb) but similar error "No such file or directory - [myprojectpath]/vendor/rails/railties/ lib/rails_generator/generators/components/scaffold/templates/ view_index.rhtml I think the file its looking for would be view_index.html.erb a quick look it seems the script should be able to handle the new file extensions. ??? On May 22, 2007, at 4:44 PM, Jonathan Linowes wrote: > hi, > first time trying rspec, and rails edge. Are there any known issues > running rspec with rails edge? > > for one, apparently script/generate scaffold_resource has been > renamed just "resource". Do I just search/replace > "scaffold_resource" with "resource" in file > rspec_resource_generator.rb ? Somethings still missing. > > before i get "Couldn't find 'scaffold_resource' generator" > > after the edit i get > > "No such file or directory - [myprojectpath]/vendor/rails/railties/ > lib/rails_generator/generators/components/resource/templates/ > view_index.rhtml From jonathan at parkerhill.com Wed May 23 02:24:01 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 23 May 2007 02:24:01 -0400 Subject: [rspec-users] demo url Message-ID: hi, what was the url used during the demo at the Rspec BOF session at railsConf? From aslak.hellesoy at gmail.com Wed May 23 04:24:23 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 10:24:23 +0200 Subject: [rspec-users] demo url In-Reply-To: References: Message-ID: <8d961d900705230124y57eb113fscdc0060efbe3cff@mail.gmail.com> On 5/23/07, Jonathan Linowes wrote: > hi, what was the url used during the demo at the Rspec BOF session at > railsConf? > Here it is! http://aslakhellesoy.com/s5/rspec_bof_railsconf_2007.html > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed May 23 04:29:31 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 10:29:31 +0200 Subject: [rspec-users] Comments wanted about spec'ing out a couple controller methods In-Reply-To: References: <8d961d900705220443l36cf9aa7p7a7a393a521c94d9@mail.gmail.com> Message-ID: <8d961d900705230129y3a2fd86aqd03c609566266f72@mail.gmail.com> On 5/22/07, Joe Van Dyk wrote: > On 5/22/07, aslak hellesoy wrote: > > On 5/22/07, Joe Van Dyk wrote: > > > (oops, accidentally sent this to the rspec-devel list, sorry about that) > > > > > > Could someone help me spec out these Rails controller methods? I > > > don't know where to get started, especially with the transaction > > > stuff. Or, if anyone else could suggest ways I could improve the > > > code, that would be great as well. > > > > > > > This is a very busy controller. I recommend you move as much logic as > > possible down to the model. Along the lines of > > http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model > > > > I am almost 100% sure that you wrote this controller before you wrote > > the spec - or that you don't have a spec. And that's how your > > controller got so fat ;-) > > > > I really recommend writing the spec first - starting with an empty > > controller (or freshly generated one). Then let the failing tests > > guide you in what you have to do in the controller - not the other way > > around. > > > > Aslak > > That's obvious. :-) I just started with rspec after the railsconf. > There's normal rails tests for these methods, but I'm trying to move > towards more mocks. > > So, in this example, maybe I'd want to do something like this? > > def create > @puzzle = Puzzle.new > @puzzle.populate_and_save_with_user_and_puzzle_and_media_attributes > @user, params[:puzzle], params[:media] > if @puzzle.new_record > # error stuff > else > # success stuff > end > end > > And then in Puzzle#populate_and_save_with_user_and_puzzle_and_media_attributes > (once i find a better name) would have the transaction stuff in there? > Yes, that looks much, much better. More decoupled, more testable. When writing your specs for the controller you can now just mock the calls to #populate_and_save_with_user_and_puzzle_and_media_attributes and #new_record? so you can focus on how the controller behaves. Then I'd still recommend that the model specs go against a real database. Here you can use fixtures, or you can do like me - create all the associated objects in the example for more clarity. Cheers, Aslak > > > Puzzle has_one Media. Both are AR model objects. > > > > > > class PuzzlesController < ApplicationController > > > > > > # a before_filter fills in @user > > > > > > def create > > > @puzzle = Puzzle.new(params[:puzzle]) > > > @puzzle.user = @user > > > > > > @media = Media.new(:uploaded_data => params[:media]) > > > > > > Puzzle.transaction do > > > @puzzle.media = @media > > > @puzzle.save! && @media.save! > > > flash[:notice] = "Success!" > > > redirect_to puzzle_path(@puzzle) > > > end > > > rescue ActiveRecord::RecordInvalid => e > > > @media.valid? # force checking of errors even if @puzzle.save! > > > failed > > > flash[:error] = "Problem submitting the One Word Wonder..." > > > render :partial => 'new', :layout => true > > > end > > > > > > def update > > > @puzzle = Puzzle.find params[:id] > > > Puzzle.transaction do > > > @puzzle.attributes = params[:puzzle] > > > if params[:media] and params[:media].size > 0 > > > @puzzle.media = Media.new :uploaded_data => params[:media] > > > end > > > @puzzle.save! && @puzzle.media.save! > > > end > > > rescue ActiveRecord::RecordInvalid => e > > > @media.valid? > > > flash[:error] = "Problem updating the One Word Wonder..." > > > render :action => 'edit' > > > end > > > > > > Thanks, > > > Joe Van Dyk > > > _______________________________________________ > > > 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 aslak.hellesoy at gmail.com Wed May 23 04:46:36 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 10:46:36 +0200 Subject: [rspec-users] rails edge In-Reply-To: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> References: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> Message-ID: <8d961d900705230146u173d6c91j80799939b5fbf2de@mail.gmail.com> On 5/22/07, Jonathan Linowes wrote: > hi, > first time trying rspec, and rails edge. Are there any known issues > running rspec with rails edge? > It was fine a few days ago, but I just got new errors. > for one, apparently script/generate scaffold_resource has been > renamed just "resource". Do I just search/replace "scaffold_resource" > with "resource" in file rspec_resource_generator.rb ? Somethings > still missing. > Yes. I've just committed changes to rspec_generator on trunk so that it will look for the new path. There are still some issues that I'll try to fix quickly... Aslak > before i get "Couldn't find 'scaffold_resource' generator" > > after the edit i get > > "No such file or directory - [myprojectpath]/vendor/rails/railties/ > lib/rails_generator/generators/components/resource/templates/ > view_index.rhtml > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From martindemello at gmail.com Wed May 23 05:16:40 2007 From: martindemello at gmail.com (Martin DeMello) Date: Wed, 23 May 2007 14:46:40 +0530 Subject: [rspec-users] rspec wiki? Message-ID: Is there a wiki around anywhere? martin From aslak.hellesoy at gmail.com Wed May 23 05:38:49 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 11:38:49 +0200 Subject: [rspec-users] rspec wiki? In-Reply-To: References: Message-ID: <8d961d900705230238w4c3a606h857c00ca784c321@mail.gmail.com> On 5/23/07, Martin DeMello wrote: > Is there a wiki around anywhere? > No. It would be great to have one, but RubyForge doesn't have one that I like. We've been talking about getting Trac, which would mean moving the svn. So, it's going to take some time, but we'll try to get one. Aslak > martin > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed May 23 06:23:35 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 12:23:35 +0200 Subject: [rspec-users] rails edge In-Reply-To: <8d961d900705230146u173d6c91j80799939b5fbf2de@mail.gmail.com> References: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> <8d961d900705230146u173d6c91j80799939b5fbf2de@mail.gmail.com> Message-ID: <8d961d900705230323h4347dd24i2a23862a58ddfca9@mail.gmail.com> On 5/23/07, aslak hellesoy wrote: > On 5/22/07, Jonathan Linowes wrote: > > hi, > > first time trying rspec, and rails edge. Are there any known issues > > running rspec with rails edge? > > > > It was fine a few days ago, but I just got new errors. > > > for one, apparently script/generate scaffold_resource has been > > renamed just "resource". Do I just search/replace "scaffold_resource" > > with "resource" in file rspec_resource_generator.rb ? Somethings > > still missing. > > > > Yes. I've just committed changes to rspec_generator on trunk so that > it will look for the new path. > > There are still some issues that I'll try to fix quickly... > It looks like edge rails' resource generator is no longer generating controllers with the 7 CRUD methods. Now it's creating empty controllers. I'm not sure if this is intentional (are they baking in automatic REST?) or if it's an oversight due to their recent refactorings. So for now, Spec::Rails is broken on Edge Rails, and Edge Rails' Scaffold generator seems broken to me. But I might have missed something. Aslak > Aslak > > > before i get "Couldn't find 'scaffold_resource' generator" > > > > after the edit i get > > > > "No such file or directory - [myprojectpath]/vendor/rails/railties/ > > lib/rails_generator/generators/components/resource/templates/ > > view_index.rhtml > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From aslak.hellesoy at gmail.com Wed May 23 08:08:52 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 14:08:52 +0200 Subject: [rspec-users] rails edge In-Reply-To: <8d961d900705230323h4347dd24i2a23862a58ddfca9@mail.gmail.com> References: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> <8d961d900705230146u173d6c91j80799939b5fbf2de@mail.gmail.com> <8d961d900705230323h4347dd24i2a23862a58ddfca9@mail.gmail.com> Message-ID: <8d961d900705230508h4826b2b7i8c9d6891555fa392@mail.gmail.com> On 5/23/07, aslak hellesoy wrote: > On 5/23/07, aslak hellesoy wrote: > > On 5/22/07, Jonathan Linowes wrote: > > > hi, > > > first time trying rspec, and rails edge. Are there any known issues > > > running rspec with rails edge? > > > > > > > It was fine a few days ago, but I just got new errors. > > > > > for one, apparently script/generate scaffold_resource has been > > > renamed just "resource". Do I just search/replace "scaffold_resource" > > > with "resource" in file rspec_resource_generator.rb ? Somethings > > > still missing. > > > > > > > Yes. I've just committed changes to rspec_generator on trunk so that > > it will look for the new path. > > > > There are still some issues that I'll try to fix quickly... > > > > It looks like edge rails' resource generator is no longer generating > controllers with the 7 CRUD methods. Now it's creating empty > controllers. > > I'm not sure if this is intentional (are they baking in automatic > REST?) or if it's an oversight due to their recent refactorings. > > So for now, Spec::Rails is broken on Edge Rails, and Edge Rails' > Scaffold generator seems broken to me. But I might have missed > something. > Ok, the rspec_resource generator should be fixed now. We should probably rename it to rspec_scaffold to match the Rails name. One thing that isn't working with Spec::Rails on Rails edge is should redirect_to(url_options) I'm not sure why yet. Aslak > Aslak > > > Aslak > > > > > before i get "Couldn't find 'scaffold_resource' generator" > > > > > > after the edit i get > > > > > > "No such file or directory - [myprojectpath]/vendor/rails/railties/ > > > lib/rails_generator/generators/components/resource/templates/ > > > view_index.rhtml > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > From t.lucas at toolmantim.com Wed May 23 08:30:06 2007 From: t.lucas at toolmantim.com (Tim Lucas) Date: Wed, 23 May 2007 22:30:06 +1000 Subject: [rspec-users] rails edge In-Reply-To: <8d961d900705230508h4826b2b7i8c9d6891555fa392@mail.gmail.com> References: <6650EBC1-5F74-402F-B1AD-05E16DB2C490@parkerhill.com> <8d961d900705230146u173d6c91j80799939b5fbf2de@mail.gmail.com> <8d961d900705230323h4347dd24i2a23862a58ddfca9@mail.gmail.com> <8d961d900705230508h4826b2b7i8c9d6891555fa392@mail.gmail.com> Message-ID: <2D780CD4-A3E7-4D6E-8955-86EB3CDB6B85@toolmantim.com> On 23/05/2007, at 10:08 PM, aslak hellesoy wrote: > One thing that isn't working with Spec::Rails on Rails edge is should > redirect_to(url_options) > > I'm not sure why yet. Yeah I noticed that too. It's because of: http://dev.rubyonrails.org/changeset/6764 Now you can just use ActionController::Base.parse_formatted_request_parameters -- tim From jonathan at parkerhill.com Wed May 23 10:52:16 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 23 May 2007 10:52:16 -0400 Subject: [rspec-users] lines of code Message-ID: <1CB60439-7068-4864-9458-4A5F571C2D4D@parkerhill.com> I know this is probably a meaningless metric, but I'm new to TDD and would like to know what to expect in terms of lines of code of tests to lines of code in a "typical" rails app. It seems like it could be as much as 5:1 or more. Perhaps its more like number of test methods : lines of code is closer to 1:1 ? From philodespotos at gmail.com Wed May 23 11:00:24 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Wed, 23 May 2007 10:00:24 -0500 Subject: [rspec-users] content_for Message-ID: <60f3810c0705230800t68a92739j8c4d2ec9b993b5ed@mail.gmail.com> Any ideas how I would go about writing specs for views which make use of content_for? I'd like, for example, to be able to specify that ABC view places XYZ in the sidebar, which I do using content_for(:sidebar). Am I missing something obvious? Kyle From jeem at hughesorama.com Wed May 23 11:14:27 2007 From: jeem at hughesorama.com (Jim Hughes) Date: Wed, 23 May 2007 10:14:27 -0500 Subject: [rspec-users] lines of code In-Reply-To: <1CB60439-7068-4864-9458-4A5F571C2D4D@parkerhill.com> References: <1CB60439-7068-4864-9458-4A5F571C2D4D@parkerhill.com> Message-ID: <98872D1D-D3CE-4519-9710-46DF54017B4B@hughesorama.com> I think I run about 2:1 average, ranging from 8:1 for views to 1:4 for difficult business logic in the models. Jim On May 23, 2007, at 9:52 AM, Jonathan Linowes wrote: > I know this is probably a meaningless metric, but I'm new to TDD and > would like to know what to expect in terms of lines of code of tests > to lines of code in a "typical" rails app. It seems like it could be > as much as 5:1 or more. Perhaps its more like number of test > methods : lines of code is closer to 1:1 ? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From anthony at digitalphenom.com Wed May 23 11:03:47 2007 From: anthony at digitalphenom.com (Anthony Carlos) Date: Wed, 23 May 2007 11:03:47 -0400 Subject: [rspec-users] BDD screenscast In-Reply-To: <86518FC6-19DF-42CA-8171-A888FA074EF9@wincent.com> References: <86518FC6-19DF-42CA-8171-A888FA074EF9@wincent.com> Message-ID: <5012C7C0-A8E4-4EF8-8F36-D33ECD257B15@digitalphenom.com> Wincent: I enjoyed watching your screencast. Thank you! By the way, how did you configure autotest and growl to get the nice colored feedback? Thanks, -Anthony On May 22, 2007, at 6:43 AM, Wincent Colaiuta wrote: > I posted a quick screencast demonstrating some BDD with RSpec > yesterday: > > http://wincent.com/a/about/wincent/weblog/archives/2007/05/ > behaviourdriven.php > > I'm a C/Objective-C programmer who knows a bit of Ruby, almost > nothing about Rails, and in BDD I can really only claim "new but > interested" status. > > It's not scripted, it's totally improvised and unplanned, so there > are plenty of mistakes, sub-optimal ideas and things which I mis- > said... but hopefully people will get the idea. > > I think most of the people who read my weblog are fellow Objective-C > programmers, but I wanted people to see the kind of workflow you can > achieve with RSpec, especially when combined with addons like > autotest and Growl. > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From win at wincent.com Wed May 23 11:36:57 2007 From: win at wincent.com (Wincent Colaiuta) Date: Wed, 23 May 2007 17:36:57 +0200 Subject: [rspec-users] BDD screenscast In-Reply-To: <5012C7C0-A8E4-4EF8-8F36-D33ECD257B15@digitalphenom.com> References: <86518FC6-19DF-42CA-8171-A888FA074EF9@wincent.com> <5012C7C0-A8E4-4EF8-8F36-D33ECD257B15@digitalphenom.com> Message-ID: El 23/5/2007, a las 17:03, Anthony Carlos escribi?: > I enjoyed watching your screencast. Thank you! By the way, how did > you configure autotest and growl to get the nice colored feedback? I made notes on that on the wiki: And relatedly: Cheers, Wincent From aslak.hellesoy at gmail.com Wed May 23 11:53:32 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 17:53:32 +0200 Subject: [rspec-users] lines of code In-Reply-To: <1CB60439-7068-4864-9458-4A5F571C2D4D@parkerhill.com> References: <1CB60439-7068-4864-9458-4A5F571C2D4D@parkerhill.com> Message-ID: <8d961d900705230853w276bffcp99538126c25fb3ef@mail.gmail.com> On 5/23/07, Jonathan Linowes wrote: > I know this is probably a meaningless metric, but I'm new to TDD and > would like to know what to expect in terms of lines of code of tests > to lines of code in a "typical" rails app. It seems like it could be > as much as 5:1 or more. Perhaps its more like number of test > methods : lines of code is closer to 1:1 ? LOC ratios are meaningless. I'd rather strive for 90% code coverage (rake spec:rcov). This doesn't tell you that your specs are ok, but it tells you when they're not. Also, using --heckle with RSpec can help you assert spec goodness. Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeanpierre at gmail.com Wed May 23 13:51:43 2007 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Wed, 23 May 2007 10:51:43 -0700 Subject: [rspec-users] autotest and rspec for a non-rails project Message-ID: hi list - should it be possible to use autotest to continuously run specs for a non-rails project? when i execute autotest in the base directory of my project, it complains that it cannot load rspec_autotest, however looking at rspec_autotest[1] and rspec_rails_autotest.rb, it appears as though both are geared towards rails (perhaps even rspec on rails). cheers, jean-pierre [1] http://svn.caldersphere.net/svn/main/rspec_autotest/trunk/lib/rspec_autotest.rb -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070523/29edb16e/attachment.html From nicksieger at gmail.com Wed May 23 13:56:40 2007 From: nicksieger at gmail.com (Nick Sieger) Date: Wed, 23 May 2007 10:56:40 -0700 Subject: [rspec-users] autotest and rspec for a non-rails project In-Reply-To: References: Message-ID: On 5/23/07, jeanpierre at gmail.com wrote: > hi list - > > should it be possible to use autotest to continuously run specs for a > non-rails project? when i execute autotest in the base directory of my > project, it complains that it cannot load rspec_autotest, however looking at > rspec_autotest[1] and rspec_rails_autotest.rb, it appears as though both are > geared towards rails (perhaps even rspec on rails). > See [1]. I believe David and Ryan are working on integrating this patch in the next versions of RSpec and ZenTest. My code is around for posterity, but should be considered deprecated. Cheers, /Nick [1]: http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and-autotest-zentest-3-5-2 From dchelimsky at gmail.com Wed May 23 14:01:48 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 May 2007 13:01:48 -0500 Subject: [rspec-users] autotest and rspec for a non-rails project In-Reply-To: References: Message-ID: <57c63afe0705231101l50964483t7174e59e992e5d89@mail.gmail.com> On 5/23/07, Nick Sieger wrote: > On 5/23/07, jeanpierre at gmail.com wrote: > > hi list - > > > > should it be possible to use autotest to continuously run specs for a > > non-rails project? when i execute autotest in the base directory of my > > project, it complains that it cannot load rspec_autotest, however looking at > > rspec_autotest[1] and rspec_rails_autotest.rb, it appears as though both are > > geared towards rails (perhaps even rspec on rails). > > > > See [1]. I believe David and Ryan are working on integrating this > patch in the next versions of RSpec and ZenTest. We're actually working out a plugin model so that ZenTest won't know about RSpec, but RSpec wil be able to quietly plug itself in to autotest. That should be out within a week (hopefully within a day or two). In the mean time, your best bet is the latest rspec (1.0.0), the latest ZenTest (3.5.2) and the patch from my blog post. >My code is around > for posterity, but should be considered deprecated. > > Cheers, > /Nick > > [1]: http://blog.davidchelimsky.net/articles/2007/05/01/rspec-0-9-1-and-autotest-zentest-3-5-2 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Wed May 23 15:06:48 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 23 May 2007 15:06:48 -0400 Subject: [rspec-users] log file Message-ID: <85FF8F44-C80F-471D-BC3E-E46DE80856E5@parkerhill.com> hi, When running rails spec tests is there a log file generated? i'm looking for generated sql to help me debug like in development.log or is there a way to run the test against a webrick server so i can see logs? (i'm not running with spec_server at the moment, it doesnt seem to work well with autotest) thanks linoj From jeanpierre at gmail.com Wed May 23 15:16:54 2007 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Wed, 23 May 2007 12:16:54 -0700 Subject: [rspec-users] autotest and rspec for a non-rails project In-Reply-To: References: Message-ID: On 5/23/07, Nick Sieger wrote: > > On 5/23/07, jeanpierre at gmail.com wrote: > > hi list - > > > > should it be possible to use autotest to continuously run specs for a > > non-rails project? when i execute autotest in the base directory of my > > project, it complains that it cannot load rspec_autotest, however > looking at > > rspec_autotest[1] and rspec_rails_autotest.rb, it appears as though both > are > > geared towards rails (perhaps even rspec on rails). > > > > See [1]. I believe David and Ryan are working on integrating this > patch in the next versions of RSpec and ZenTest. My code is around > for posterity, but should be considered deprecated. excellent, i'll give the patch a go until a new version of zentest is released. thanks for the quick help! cheers, jean-pierre -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070523/a8dd2f66/attachment.html From dchelimsky at gmail.com Wed May 23 15:19:46 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 May 2007 14:19:46 -0500 Subject: [rspec-users] autotest and rspec for a non-rails project In-Reply-To: References: Message-ID: <57c63afe0705231219h1523b188idc8303bcb62e902@mail.gmail.com> On 5/23/07, jeanpierre at gmail.com wrote: > On 5/23/07, Nick Sieger wrote: > > On 5/23/07, jeanpierre at gmail.com wrote: > > > hi list - > > > > > > should it be possible to use autotest to continuously run specs for a > > > non-rails project? when i execute autotest in the base directory of my > > > project, it complains that it cannot load rspec_autotest, however > looking at > > > rspec_autotest[1] and rspec_rails_autotest.rb, it appears as though both > are > > > geared towards rails (perhaps even rspec on rails). > > > > > > > See [1]. I believe David and Ryan are working on integrating this > > patch in the next versions of RSpec and ZenTest. My code is around > > for posterity, but should be considered deprecated. > > excellent, i'll give the patch a go until a new version of zentest is > released. Cool - FYI - you'll need new versions of both RSpec and ZenTest when they are released because they are both playing a part in the new plugin structure. > > thanks for the quick help! > cheers, > jean-pierre > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at ekenosen.net Wed May 23 15:24:40 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Wed, 23 May 2007 15:24:40 -0400 Subject: [rspec-users] Spec'ing redirect with arbitrary parameters In-Reply-To: <810a540e0705221055x76ea5344wd0fcdaf6fc3526d1@mail.gmail.com> References: <810a540e0705211409g764001c2t4990871640531f4e@mail.gmail.com> <90EEA875-EAA2-47D4-B3B5-4124793A9CA8@gmail.com> <810a540e0705221055x76ea5344wd0fcdaf6fc3526d1@mail.gmail.com> Message-ID: <276ff9870705231224o32e26d93rd5e7171197348532@mail.gmail.com> On 5/22/07, Pat Maddox wrote: > On 5/21/07, Brandon Keepers wrote: > > On May 21, 2007, at 5:09 PM, Pat Maddox wrote: > > > I've got the following expectation: > > > > > > response.should redirect_to(:action => "new", :video_id => "1", > > > :process_id => "2", :origin_id => "3") > > > > > that fails with this error message: > > > > > > expected redirect to {:video_id=>"1", :process_id=>"2", > > > :origin_id=>"3", :action=>"new"}, got redirect to > > > "http://test.host/videos/1/screenshot_selections/new? > > > process_id=2&origin_id=3", > > > which cannot be routed within this application (spec using the URL > > > string if the redirection is to an external address) Interesting. I submitted the patch that changed around "should redirect_to()" behavior a bit, and I confess, I haven't had the opportunity to use it much with named resources much yet. That was to get around an intermittent bug when the URL contained parameters on the query string (but in a somewhat random order, so a simple string comparison would intermittently fail). The current behavior of the redirect_to matcher, when expecting a hash, is to convert that hash into a URL and then *back* into a hash (to pick up any magic dust that Rails might sprinkle in along the way). It also has to convert the response.redirect_url into a hash, in order to do the comparison (and pick up any routing magic). But Rails doesn't exactly make that easy for me. ;-) And it looks like my approach breaks with nested resources! It seems to work fine for the first level. I was rather surprised to find that the following will not work: ActionController::Routing::Routes.recognize_path "/videos/1/screenshot_selections/new" So, I don't have the time to look into it at the moment, but if someone else knows how to get the correct hash from that URL path, they could place that solution in line 48 of vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb. > > It looks like you're using resources. If that's the case, use named > > routes: > > > > response.should redirect_to(resource_path(@video, @process, @origin)) > > Cool, I changed it to > response.should redirect_to(new_screenshot_selection_path(:video_id => > "1", :process_id => "2", :origin_id => "3")) > > and it works fine now. Thanks for the tip. Yeah... if you are using resources, you should be using the named route anyway. ;-) But I wonder if the unordered hash issue will still cause occasional heartache... new_screenshot_selection_path(:video_id => "1", :process_id => "2", :origin_id => "3") could theoretically generate both of the following: "http://test.host/videos/1/screenshot_selections/new?process_id=2&origin_id=3" "http://test.host/videos/1/screenshot_selections/new?origin_id=3&process_id=2" Yuck! Maybe the right solution is to enforce a strictly alphabetical ordering within Rails itself? Or should any URL which is routable within the app be converted to a hash for comparison? -- Nick From nick at ekenosen.net Wed May 23 15:29:18 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Wed, 23 May 2007 15:29:18 -0400 Subject: [rspec-users] log file In-Reply-To: <85FF8F44-C80F-471D-BC3E-E46DE80856E5@parkerhill.com> References: <85FF8F44-C80F-471D-BC3E-E46DE80856E5@parkerhill.com> Message-ID: <276ff9870705231229x20ec5295l967085c7aada0544@mail.gmail.com> On 5/23/07, Jonathan Linowes wrote: > When running rails spec tests is there a log file generated? i'm > looking for generated sql to help me debug like in development.log Have you looked in log/test.log? I occasionally clear it out and then run all of the non-model specs, then grep through it for SQL, to enforce our "no DB access from non-model specs" rule. -- Nick From aslak.hellesoy at gmail.com Wed May 23 15:23:43 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 21:23:43 +0200 Subject: [rspec-users] log file In-Reply-To: <85FF8F44-C80F-471D-BC3E-E46DE80856E5@parkerhill.com> References: <85FF8F44-C80F-471D-BC3E-E46DE80856E5@parkerhill.com> Message-ID: <8d961d900705231223x7e2bf8i31a58ddc53f01ff8@mail.gmail.com> On 5/23/07, Jonathan Linowes wrote: > hi, > > When running rails spec tests is there a log file generated? i'm You can specify what kind of output you want on RSpec's command line. See spec --help for details. For example, you can do: spec --format specdoc:path/to/myfile.txt pat/to/my/specs I'm not sure how to tell autotest to give special command line options to the spec command though. Aslak > looking for generated sql to help me debug like in development.log > > or is there a way to run the test against a webrick server so i can > see logs? > > (i'm not running with spec_server at the moment, it doesnt seem to > work well with autotest) > > thanks > > linoj > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 23 15:36:25 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 May 2007 14:36:25 -0500 Subject: [rspec-users] log file In-Reply-To: <8d961d900705231223x7e2bf8i31a58ddc53f01ff8@mail.gmail.com> References: <85FF8F44-C80F-471D-BC3E-E46DE80856E5@parkerhill.com> <8d961d900705231223x7e2bf8i31a58ddc53f01ff8@mail.gmail.com> Message-ID: <57c63afe0705231236l524c5536mcae0121fd37ed21f@mail.gmail.com> On 5/23/07, aslak hellesoy wrote: > On 5/23/07, Jonathan Linowes wrote: > > hi, > > > > When running rails spec tests is there a log file generated? i'm > > You can specify what kind of output you want on RSpec's command line. > See spec --help for details. For example, you can do: > > spec --format specdoc:path/to/myfile.txt pat/to/my/specs > > I'm not sure how to tell autotest to give special command line options > to the spec command though. You'll have to read the ZenTest docs for details, but the high level is that you can add hooks in a .autotest file in the root of your rails project that tell autotest what command to use, what examples to run when certain files get changed, etc. > > Aslak > > > looking for generated sql to help me debug like in development.log > > > > or is there a way to run the test against a webrick server so i can > > see logs? > > > > (i'm not running with spec_server at the moment, it doesnt seem to > > work well with autotest) > > > > thanks > > > > linoj > > > > _______________________________________________ > > 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 bates.ryan at gmail.com Wed May 23 16:48:18 2007 From: bates.ryan at gmail.com (Ryan Bates) Date: Wed, 23 May 2007 13:48:18 -0700 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec Message-ID: Forgive me if this isn't the proper list. It's specific to the rSpec Rails plugin. The problem is, some controller actions are rendering the "diagnostics.rhtml" template when I'm expecting it to render something else in a controller spec. I'm assuming this is the template that displays the error message and a stack trace when an error is raised in the development environment. Is there anyway to see the error through rspec instead of the controller just rendering the diagnostics.rhtml template? I'm surprised this would even be rendered in the test environment. Thanks, Ryan From dchelimsky at gmail.com Wed May 23 17:08:02 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 May 2007 16:08:02 -0500 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: References: Message-ID: <57c63afe0705231408v58cb535va22338ec7d6a7f0a@mail.gmail.com> On 5/23/07, Ryan Bates wrote: > Forgive me if this isn't the proper list. It's specific to the rSpec > Rails plugin. This is the place. Welcome! > > The problem is, some controller actions are rendering the > "diagnostics.rhtml" template when I'm expecting it to render something > else in a controller spec. I'm assuming this is the template that > displays the error message and a stack trace when an error is raised > in the development environment. > > Is there anyway to see the error through rspec instead of the > controller just rendering the diagnostics.rhtml template? I'm > surprised this would even be rendered in the test environment. Try overriding rescue_action as is done in rails controller tests: # Re-raise errors caught by the controller. class MyController; def rescue_action(e) raise e end; end This used to be implicit, but we removed it because it overrode your own definition of rescue_action. If you want to do this for every controller, assuming you're on 1.0, you can do this in spec/spec_helper.rb Spec::Runner.configure do |config| config.before(:each) do controller.class.class_eval do define_method :rescue_action do |e| raise e end end end end Cheers, David From aslak.hellesoy at gmail.com Wed May 23 16:54:53 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 May 2007 22:54:53 +0200 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: References: Message-ID: <8d961d900705231354q629000a9tb9cc22cb9abbe571@mail.gmail.com> On 5/23/07, Ryan Bates wrote: > Forgive me if this isn't the proper list. It's specific to the rSpec > Rails plugin. > > The problem is, some controller actions are rendering the > "diagnostics.rhtml" template when I'm expecting it to render something > else in a controller spec. I'm assuming this is the template that > displays the error message and a stack trace when an error is raised > in the development environment. > class ActionController::Base def rescue_action(e) raise; end end > Is there anyway to see the error through rspec instead of the > controller just rendering the diagnostics.rhtml template? I'm > surprised this would even be rendered in the test environment. > Would it be a good idea to make this the default behaviour when running specs? Does vanilla Rails do that? Aslak > Thanks, > > Ryan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 23 17:36:28 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 May 2007 16:36:28 -0500 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: <8d961d900705231354q629000a9tb9cc22cb9abbe571@mail.gmail.com> References: <8d961d900705231354q629000a9tb9cc22cb9abbe571@mail.gmail.com> Message-ID: <57c63afe0705231436v1ac05af6u861cfc5b21df5c16@mail.gmail.com> On 5/23/07, aslak hellesoy wrote: > On 5/23/07, Ryan Bates wrote: > > Forgive me if this isn't the proper list. It's specific to the rSpec > > Rails plugin. > > > > The problem is, some controller actions are rendering the > > "diagnostics.rhtml" template when I'm expecting it to render something > > else in a controller spec. I'm assuming this is the template that > > displays the error message and a stack trace when an error is raised > > in the development environment. > > > > class ActionController::Base > def rescue_action(e) raise; end > end > > > Is there anyway to see the error through rspec instead of the > > controller just rendering the diagnostics.rhtml template? I'm > > surprised this would even be rendered in the test environment. > > > > Would it be a good idea to make this the default behaviour when running specs? No. We used to, but changed it in response to a bug report (http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9767&atid=3149) > > Does vanilla Rails do that? Not exactly. It puts it explicitly in generated controller specs. So by default, yes, but implicitly, no. > > Aslak > > > Thanks, > > > > Ryan > > _______________________________________________ > > 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 bates.ryan at gmail.com Wed May 23 18:03:00 2007 From: bates.ryan at gmail.com (Ryan Bates) Date: Wed, 23 May 2007 15:03:00 -0700 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: <57c63afe0705231408v58cb535va22338ec7d6a7f0a@mail.gmail.com> References: <57c63afe0705231408v58cb535va22338ec7d6a7f0a@mail.gmail.com> Message-ID: > Try overriding rescue_action as is done in rails controller tests: > > # Re-raise errors caught by the controller. > class MyController; def rescue_action(e) raise e end; end Thanks, that makes perfect sense. Strangely it's not working when I place it at the top of a controller spec: --- require File.dirname(__FILE__) + '/../spec_helper' class ArticlesController; def rescue_action(e) raise e end; end describe ArticlesController do #... end --- I get this error: --- You have to declare the controller name in controller specs. For example: describe "The ExampleController" do controller_name "example" #invokes the ExampleController end --- Placing it at the end of the spec file seems to work though. > If you want to do this for every controller, assuming you're on 1.0, > you can do this in spec/spec_helper.rb > > Spec::Runner.configure do |config| > config.before(:each) do > controller.class.class_eval do > define_method :rescue_action do |e| > raise e > end > end > end > end > This doesn't have any effect for me. It still renders the diagnostics.rhtml template with that in the spec_helper. I'm running 1.0. Ryan From mdeiters at msn.com Wed May 23 18:00:33 2007 From: mdeiters at msn.com (Matt Deiters) Date: Wed, 23 May 2007 17:00:33 -0500 Subject: [rspec-users] rspec mocha and controller specs without integrated_views In-Reply-To: Message-ID: The ability to choose a mocking framework is great as I prefer mocha, but I am have problems. On my controller specs, I am forced to 'integrate_views' as the following code below shows you, the mocking of views is rspec specific. See stub! versus mocha's stub unless block_given? unless integrate_views? @template.stub!(:file_exists?).and_return(true) @template.should_receive(:render_template).any_number_of_times.and_return(true) { |*args| @first_render ||= args[2] } @template.stub!(:find_template_extension_for).and_return("rhtml") @template.stub!(:read_template_file).and_return("this is fake content generated by rspec") end end I am getting the following error: undefined method `stub!' Any plans on fixing this? Matt From dchelimsky at gmail.com Wed May 23 18:17:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 May 2007 17:17:54 -0500 Subject: [rspec-users] rspec mocha and controller specs without integrated_views In-Reply-To: References: Message-ID: <57c63afe0705231517o78ab90abqf15b346e0be39b5@mail.gmail.com> On 5/23/07, Matt Deiters wrote: > The ability to choose a mocking framework is great as I prefer mocha, but I > am have problems. > > On my controller specs, I am forced to 'integrate_views' as the following > code below shows you, the mocking of views is rspec specific. See stub! > versus mocha's stub > > unless block_given? > unless integrate_views? > @template.stub!(:file_exists?).and_return(true) > > @template.should_receive(:render_template).any_number_of_times.and_return(true) > { |*args| > @first_render ||= args[2] > } > > @template.stub!(:find_template_extension_for).and_return("rhtml") > @template.stub!(:read_template_file).and_return("this is fake > content generated by rspec") > end > end > > I am getting the following error: undefined method `stub!' > Any plans on fixing this? Sure. Go ahead and raise an RFE in the tracker (http://rubyforge.org/tracker/?group_id=797). If you want to see it happen fast, submit a patch. Now that users can use any mock framework, we should probably not use any mock framework for anything internal, so the method should just override the methods that are being mocked. > > Matt > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed May 23 18:19:16 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 24 May 2007 00:19:16 +0200 Subject: [rspec-users] rspec mocha and controller specs without integrated_views In-Reply-To: References: Message-ID: <8d961d900705231519u30c72591pd05d6e7173162477@mail.gmail.com> On 5/24/07, Matt Deiters wrote: > The ability to choose a mocking framework is great as I prefer mocha, but I > am have problems. > > On my controller specs, I am forced to 'integrate_views' as the following > code below shows you, the mocking of views is rspec specific. See stub! > versus mocha's stub > > unless block_given? > unless integrate_views? > @template.stub!(:file_exists?).and_return(true) > > @template.should_receive(:render_template).any_number_of_times.and_return(true) > { |*args| > @first_render ||= args[2] > } > > @template.stub!(:find_template_extension_for).and_return("rhtml") > @template.stub!(:read_template_file).and_return("this is fake > content generated by rspec") > end > end > > I am getting the following error: undefined method `stub!' > Any plans on fixing this? > We didn't know about it before you told us. If you want it fixed fast, send a patch, if not, wait for us to do it. In any case, a ticket with a failing spec would be great. Aslak > Matt > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bates.ryan at gmail.com Wed May 23 18:21:20 2007 From: bates.ryan at gmail.com (Ryan Bates) Date: Wed, 23 May 2007 15:21:20 -0700 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: References: <57c63afe0705231408v58cb535va22338ec7d6a7f0a@mail.gmail.com> Message-ID: I got it working by placing this in the spec_helper.rb: --- Spec::Runner.configure do |config| config.before(:each) do unless @controller_class_name.blank? @controller_class_name.constantize.class_eval do define_method :rescue_action do |e| raise e end end end end end --- I'm sure accessing the @controller_class_name instance variable directly like that isn't a good thing, but it seems to work. If anyone knows of a better way please reply. :) Thanks again, Ryan From dchelimsky at gmail.com Wed May 23 18:26:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 23 May 2007 17:26:17 -0500 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: References: <57c63afe0705231408v58cb535va22338ec7d6a7f0a@mail.gmail.com> Message-ID: <57c63afe0705231526x375814fan29db821301e06a14@mail.gmail.com> On 5/23/07, Ryan Bates wrote: > I got it working by placing this in the spec_helper.rb: > > --- > Spec::Runner.configure do |config| > config.before(:each) do > unless @controller_class_name.blank? > @controller_class_name.constantize.class_eval do > define_method :rescue_action do |e| > raise e > end > end > end > end > end Nice job getting it working. We probably need something that would support this: Spec::Runner.configure do |config| config.define_controller_rescue_action {|e| raise e} end I'm not in love w/ exactly that - but something like that. Any suggestions? > --- > > I'm sure accessing the @controller_class_name instance variable > directly like that isn't a good thing, but it seems to work. If anyone > knows of a better way please reply. :) > > Thanks again, > > Ryan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bates.ryan at gmail.com Wed May 23 19:20:38 2007 From: bates.ryan at gmail.com (Ryan Bates) Date: Wed, 23 May 2007 16:20:38 -0700 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: <57c63afe0705231526x375814fan29db821301e06a14@mail.gmail.com> References: <57c63afe0705231408v58cb535va22338ec7d6a7f0a@mail.gmail.com> <57c63afe0705231526x375814fan29db821301e06a14@mail.gmail.com> Message-ID: > I'm not in love w/ exactly that - but something like that. Any suggestions? Maybe call it "override_controller_rescue_action!" and have it default to that block? -- Spec::Runner.configure do |config| config.override_controller_rescue_action! end -- A block could then be optionally passed to change its behavior if you don't want to simply raise the exception. You may also want to have it alias the old rescue_action method in case someone wants to call it? Hmm. Whatever the case, I do think there should be an easy way to do this and maybe mention something in the comments in the config file. I imagine the majority of Rails projects would want to set this? Ryan From daniel at danielfischer.com Thu May 24 02:18:22 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Wed, 23 May 2007 23:18:22 -0700 Subject: [rspec-users] Annoying problem, stack error Message-ID: <7e565b5c0705232318w2fcda837o7d7faf652042172a@mail.gmail.com> For some reason rake spec is totally crapping out on me. I don't know what I did to make it break, the only thing I tried new was install haml, but even after removing it there is still a stack trace. Here is what I am getting- sparta at phalanx ff $ rake spec (in /Users/sparta/Projects/work/idastudios/ff) ..................../usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:249:in `load_missing_constant': Expected /Users/sparta/Projects/work/idastudios/ff/config/../app/models/asset.rb to define Asset (LoadError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in `const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in `const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:260:in `load_missing_constant' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:468:in `const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1360:in `compute_type' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/reflection.rb:125:in `send' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/reflection.rb:125:in `klass' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_many_association.rb:194:in `construct_sql' ... 30 levels... from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in `parse' from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behaviour_runner' from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec:3 rake aborted! Command ruby -I"/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib" "/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec" "spec/controllers/comments_controller_spec.rb" "spec/controllers/posts_controller_spec.rb" "spec/controllers/users_controller_spec.rb" "spec/models/asset_spec.rb" "spec/models/category_spec.rb" "spec/models/comment_spec.rb" "spec/models/message_spec.rb" "spec/models/post_spec.rb" "spec/models/user_spec.rb" "spec/models/vote_spec.rb" --options "/Users/sparta/Projects/work/idastudios/ff/config/../spec/spec.opts" failed (See full trace by running task with --trace) Anyone have an idea what the heck is going on? Thanks, Daniel -- www.writersbeat.com www.danielfischer.com From win at wincent.com Thu May 24 02:56:35 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 24 May 2007 08:56:35 +0200 Subject: [rspec-users] Specs for code stored in rails_app/lib/ Message-ID: Where should the specs go for code in the "lib" directory of a Rails app? I made a folder, "spec/lib/", for storing such specs, and RSpec automatically picks them up when run using "rake spec". Before I go ahead and patch rspec_on_rails/lib/autotest/ rails_rspec.rb so that autotest can monitor these specs I'd like to ask whether this is the "standard" location for such specs or not. Cheers, Wincent From win at wincent.com Thu May 24 03:00:48 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 24 May 2007 09:00:48 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? Message-ID: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> The Rails ApplicationController (app/controllers/application.rb) serves as an abstract superclass for all other controllers in a Rails application and is a good place to put methods and filters which you want all of your controllers to use. In my case I'm using it to provide methods such as "current_user" and "logged_in?" etc. By default, RSpec doesn't produce a corresponding spec file for this controller. I've made a spec file (spec/controllers/application_spec.rb) so that I can test these methods, but I'm not sure if this is the right thing to do. Should I be testing only the non-abstract subclasses instead? Cheers, Wincent From t.lucas at toolmantim.com Thu May 24 03:18:23 2007 From: t.lucas at toolmantim.com (Tim Lucas) Date: Thu, 24 May 2007 17:18:23 +1000 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> Message-ID: On 24/05/2007, at 5:00 PM, Wincent Colaiuta wrote: > The Rails ApplicationController (app/controllers/application.rb) > serves as an abstract superclass for all other controllers in a Rails > application and is a good place to put methods and filters which you > want all of your controllers to use. In my case I'm using it to > provide methods such as "current_user" and "logged_in?" etc. > > By default, RSpec doesn't produce a corresponding spec file for this > controller. > > I've made a spec file (spec/controllers/application_spec.rb) so that > I can test these methods, but I'm not sure if this is the right thing > to do. Should I be testing only the non-abstract subclasses instead? I did it a slighty dodgy way (spec/controllers/ application_controller_spec.rb): http://pastie.caboo.se/64123 but nowadays you can probably use a shared spec, like so (require'd from your spec helper): describe "All controllers", :shared => true do it "should redirect to HQ if no subdomains specified" do ... end end and then: describe EventController do it_should_behave_like "All controllers" ... end Not sure how you'd deal with something like skip_before_filter though... -- tim From win at wincent.com Thu May 24 04:27:55 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 24 May 2007 10:27:55 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> Message-ID: <89327C27-8DD0-47D9-82DA-BCAF0D9EB1F2@wincent.com> El 24/5/2007, a las 9:18, Tim Lucas escribi?: > I did it a slighty dodgy way (spec/controllers/ > application_controller_spec.rb): > http://pastie.caboo.se/64123 First, thanks for the advice! Why do you say "dodgy"? > but nowadays you can probably use a shared spec, like so (require'd > from your spec helper): Probably not a bad idea. In that way you'd get confirmation that no subclass is overriding the behaviour of the superclass in unexpected ways. Cheers, Wincent From dchelimsky at gmail.com Thu May 24 04:35:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 03:35:10 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: References: Message-ID: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> On 5/24/07, Wincent Colaiuta wrote: > Where should the specs go for code in the "lib" directory of a Rails > app? > > I made a folder, "spec/lib/", for storing such specs, and RSpec > automatically picks them up when run using "rake spec". > > Before I go ahead and patch rspec_on_rails/lib/autotest/ > rails_rspec.rb so that autotest can monitor these specs I'd like to > ask whether this is the "standard" location for such specs or not. Seems reasonable. Can you get me that patch this AM? I want to do a 1.0.3 release today to fix a couple of bugs. FYI - how did you even find that file? We released it, but autotest is not using it yet. It will be after the next ZenTest release, but not yet. > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu May 24 05:25:42 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 24 May 2007 11:25:42 +0200 Subject: [rspec-users] Annoying problem, stack error In-Reply-To: <7e565b5c0705232318w2fcda837o7d7faf652042172a@mail.gmail.com> References: <7e565b5c0705232318w2fcda837o7d7faf652042172a@mail.gmail.com> Message-ID: <8d961d900705240225p49e90792wb3c4bb763baeed1b@mail.gmail.com> On 5/24/07, Fischer, Daniel wrote: > For some reason rake spec is totally crapping out on me. > Judging from the stack trace it doesn't look like it's from RSpec. In any case, we need more context to help you. A failing spec, detailed version info etc. Aslak > I don't know what I did to make it break, the only thing I tried new > was install haml, but even after removing it there is still a stack > trace. > > Here is what I am getting- > > sparta at phalanx ff $ rake spec > (in /Users/sparta/Projects/work/idastudios/ff) > ..................../usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:249:in > `load_missing_constant': Expected > /Users/sparta/Projects/work/idastudios/ff/config/../app/models/asset.rb > to define Asset (LoadError) > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in > `const_missing' > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in > `const_missing' > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:260:in > `load_missing_constant' > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:468:in > `const_missing' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1360:in > `compute_type' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/reflection.rb:125:in > `send' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/reflection.rb:125:in > `klass' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_many_association.rb:194:in > `construct_sql' > ... 30 levels... > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > `parse' > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > `create_behaviour_runner' > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > `run' > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec:3 > rake aborted! > Command ruby -I"/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib" > "/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec" > "spec/controllers/comments_controller_spec.rb" > "spec/controllers/posts_controller_spec.rb" > "spec/controllers/users_controller_spec.rb" > "spec/models/asset_spec.rb" "spec/models/category_spec.rb" > "spec/models/comment_spec.rb" "spec/models/message_spec.rb" > "spec/models/post_spec.rb" "spec/models/user_spec.rb" > "spec/models/vote_spec.rb" --options > "/Users/sparta/Projects/work/idastudios/ff/config/../spec/spec.opts" > failed > > (See full trace by running task with --trace) > > Anyone have an idea what the heck is going on? > > Thanks, > Daniel > > -- > www.writersbeat.com > www.danielfischer.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 24 05:35:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 04:35:03 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> Message-ID: <57c63afe0705240235t4194fe44y8f873e7ea1d9c165@mail.gmail.com> On 5/24/07, David Chelimsky wrote: > On 5/24/07, Wincent Colaiuta wrote: > > Where should the specs go for code in the "lib" directory of a Rails > > app? > > > > I made a folder, "spec/lib/", for storing such specs, and RSpec > > automatically picks them up when run using "rake spec". > > > > Before I go ahead and patch rspec_on_rails/lib/autotest/ > > rails_rspec.rb so that autotest can monitor these specs I'd like to > > ask whether this is the "standard" location for such specs or not. > > Seems reasonable. Can you get me that patch this AM? I want to do a > 1.0.3 release today to fix a couple of bugs. Actually - I've got this covered - no patch necessary. > > FYI - how did you even find that file? We released it, but autotest is > not using it yet. It will be after the next ZenTest release, but not > yet. > > > > > Cheers, > > Wincent > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From win at wincent.com Thu May 24 05:48:22 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 24 May 2007 11:48:22 +0200 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> Message-ID: El 24/5/2007, a las 10:35, David Chelimsky escribi?: > On 5/24/07, Wincent Colaiuta wrote: >> Where should the specs go for code in the "lib" directory of a Rails >> app? >> >> I made a folder, "spec/lib/", for storing such specs, and RSpec >> automatically picks them up when run using "rake spec". >> >> Before I go ahead and patch rspec_on_rails/lib/autotest/ >> rails_rspec.rb so that autotest can monitor these specs I'd like to >> ask whether this is the "standard" location for such specs or not. > > Seems reasonable. Can you get me that patch this AM? I want to do a > 1.0.3 release today to fix a couple of bugs. Will paste one possible diff below; based on the convention that for file: lib/my_module.rb There will be a corresponding spec at: spec/lib/my_module_spec.rb This may be too simplistic given the possibility of nesting subfolders in lib, but as a first cut it might be ok. > FYI - how did you even find that file? We released it, but autotest is > not using it yet. It will be after the next ZenTest release, but not > yet. Just happened to notice it; after "script/plugin install" I did an "svn st" and "svn diff" to see what was new... Cheers, Wincent Index: rails_rspec.rb =================================================================== --- rails_rspec.rb (revision 2014) +++ rails_rspec.rb (working copy) @@ -33,7 +33,7 @@ %r%^(test|spec)/fixtures/(.*).yml% => proc { |_, m| ["spec/models/#{m[2].singularize}_spec.rb"] + files_matching (%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%) }, - %r%^spec/(models|controllers|views|helpers)/.*rb$% => proc { | filename, _| + %r%^spec/(models|controllers|views|helpers|lib)/.*rb$% => proc { |filename, _| filename }, %r%^app/models/(.*)\.rb$% => proc { |_, m| @@ -61,6 +61,9 @@ %r%^app/controllers/(.*)\.rb$% => proc { |_, m| ["spec/controllers/#{m[1]}_spec.rb"] }, + %r%^lib/(.*)\.rb$% => proc { |_, m| + ["spec/lib/#{m[1]}_spec.rb"] + }, %r%^config/routes.rb$% => proc { # FIX: files_matching %r%^spec/(controllers|views|helpers)/.*_spec \.rb$% }, @@ -68,7 +71,7 @@ files_matching %r%^spec/models/.*_spec\.rb$% }, %r%^spec/spec_helper.rb|config/((boot|environment(s/ test)?).rb)% => proc { - files_matching %r%^spec/(models|controllers|views| helpers)/.*_spec\.rb$% + files_matching %r%^spec/(models|controllers|views|helpers| lib)/.*_spec\.rb$% }, } end From dchelimsky at gmail.com Thu May 24 05:53:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 04:53:55 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> Message-ID: <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> On 5/24/07, Wincent Colaiuta wrote: > El 24/5/2007, a las 10:35, David Chelimsky escribi?: > > > On 5/24/07, Wincent Colaiuta wrote: > >> Where should the specs go for code in the "lib" directory of a Rails > >> app? > >> > >> I made a folder, "spec/lib/", for storing such specs, and RSpec > >> automatically picks them up when run using "rake spec". > >> > >> Before I go ahead and patch rspec_on_rails/lib/autotest/ > >> rails_rspec.rb so that autotest can monitor these specs I'd like to > >> ask whether this is the "standard" location for such specs or not. > > > > Seems reasonable. Can you get me that patch this AM? I want to do a > > 1.0.3 release today to fix a couple of bugs. > > Will paste one possible diff below; based on the convention that for > file: > > lib/my_module.rb > > There will be a corresponding spec at: > > spec/lib/my_module_spec.rb > > This may be too simplistic given the possibility of nesting > subfolders in lib, but as a first cut it might be ok. > > > FYI - how did you even find that file? We released it, but autotest is > > not using it yet. It will be after the next ZenTest release, but not > > yet. > > Just happened to notice it; after "script/plugin install" I did an > "svn st" and "svn diff" to see what was new... > > Cheers, > Wincent > > > Index: rails_rspec.rb > =================================================================== > --- rails_rspec.rb (revision 2014) > +++ rails_rspec.rb (working copy) > @@ -33,7 +33,7 @@ > %r%^(test|spec)/fixtures/(.*).yml% => proc { |_, m| > ["spec/models/#{m[2].singularize}_spec.rb"] + files_matching > (%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%) > }, > - %r%^spec/(models|controllers|views|helpers)/.*rb$% => proc { | > filename, _| > + %r%^spec/(models|controllers|views|helpers|lib)/.*rb$% => proc > { |filename, _| > filename > }, > %r%^app/models/(.*)\.rb$% => proc { |_, m| > @@ -61,6 +61,9 @@ > %r%^app/controllers/(.*)\.rb$% => proc { |_, m| > ["spec/controllers/#{m[1]}_spec.rb"] > }, > + %r%^lib/(.*)\.rb$% => proc { |_, m| > + ["spec/lib/#{m[1]}_spec.rb"] > + }, > %r%^config/routes.rb$% => proc { # FIX: > files_matching %r%^spec/(controllers|views|helpers)/.*_spec > \.rb$% > }, > @@ -68,7 +71,7 @@ > files_matching %r%^spec/models/.*_spec\.rb$% > }, > %r%^spec/spec_helper.rb|config/((boot|environment(s/ > test)?).rb)% => proc { > - files_matching %r%^spec/(models|controllers|views| > helpers)/.*_spec\.rb$% > + files_matching %r%^spec/(models|controllers|views|helpers| > lib)/.*_spec\.rb$% > }, > } > end I don't think this is too simplistic - as long as the nested dirs align in lib and spec/lib, then the regexp matcher will include the '/'es, and all will be right with the world. In truth, I already implemented exactly what you have there (in a hurry to get a release out today), but if you file the above in the tracker I'll be more than happy to add you to the contributor page. Cheers, David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 24 06:22:31 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 05:22:31 -0500 Subject: [rspec-users] Spec'ing redirect with arbitrary parameters In-Reply-To: <276ff9870705231224o32e26d93rd5e7171197348532@mail.gmail.com> References: <810a540e0705211409g764001c2t4990871640531f4e@mail.gmail.com> <90EEA875-EAA2-47D4-B3B5-4124793A9CA8@gmail.com> <810a540e0705221055x76ea5344wd0fcdaf6fc3526d1@mail.gmail.com> <276ff9870705231224o32e26d93rd5e7171197348532@mail.gmail.com> Message-ID: <57c63afe0705240322w2692da87mb9ecf5cc4e4d7661@mail.gmail.com> On 5/23/07, nicholas a. evans wrote: > On 5/22/07, Pat Maddox wrote: > > On 5/21/07, Brandon Keepers wrote: > > > On May 21, 2007, at 5:09 PM, Pat Maddox wrote: > > > > I've got the following expectation: > > > > > > > > response.should redirect_to(:action => "new", :video_id => "1", > > > > :process_id => "2", :origin_id => "3") > > > > > > > that fails with this error message: > > > > > > > > expected redirect to {:video_id=>"1", :process_id=>"2", > > > > :origin_id=>"3", :action=>"new"}, got redirect to > > > > "http://test.host/videos/1/screenshot_selections/new? > > > > process_id=2&origin_id=3", > > > > which cannot be routed within this application (spec using the URL > > > > string if the redirection is to an external address) > > Interesting. I submitted the patch that changed around "should > redirect_to()" behavior a bit, and I confess, I haven't had the > opportunity to use it much with named resources much yet. That was to > get around an intermittent bug when the URL contained parameters on > the query string (but in a somewhat random order, so a simple string > comparison would intermittently fail). > > The current behavior of the redirect_to matcher, when expecting a > hash, is to convert that hash into a URL and then *back* into a hash > (to pick up any magic dust that Rails might sprinkle in along the > way). It also has to convert the response.redirect_url into a hash, > in order to do the comparison (and pick up any routing magic). But > Rails doesn't exactly make that easy for me. ;-) > > And it looks like my approach breaks with nested resources! It seems > to work fine for the first level. I was rather surprised to find that > the following will not work: > > ActionController::Routing::Routes.recognize_path > "/videos/1/screenshot_selections/new" > > So, I don't have the time to look into it at the moment, but if > someone else knows how to get the correct hash from that URL path, > they could place that solution in line 48 of > vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb. > > > > It looks like you're using resources. If that's the case, use named > > > routes: > > > > > > response.should redirect_to(resource_path(@video, @process, @origin)) > > > > Cool, I changed it to > > response.should redirect_to(new_screenshot_selection_path(:video_id => > > "1", :process_id => "2", :origin_id => "3")) > > > > and it works fine now. Thanks for the tip. > > Yeah... if you are using resources, you should be using the named > route anyway. ;-) But I wonder if the unordered hash issue will > still cause occasional heartache... > > new_screenshot_selection_path(:video_id => "1", :process_id => "2", > :origin_id => "3") > could theoretically generate both of the following: > "http://test.host/videos/1/screenshot_selections/new?process_id=2&origin_id=3" > "http://test.host/videos/1/screenshot_selections/new?origin_id=3&process_id=2" > > Yuck! Maybe the right solution is to enforce a strictly alphabetical > ordering within Rails itself? Or should any URL which is routable > within the app be converted to a hash for comparison? Turns out the problem was that edge has moved parse_query_parameters from CGIMethods to ActionController::AbstractRequest. This wasn't getting caught because the resulting error was being silently rescued. Should have the fix committed shortly. > > -- > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Thu May 24 06:24:14 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 24 May 2007 12:24:14 +0200 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> Message-ID: El 24/5/2007, a las 11:53, David Chelimsky escribi?: > In truth, I already implemented exactly what you have there (in a > hurry to get a release out today), but if you file the above in the > tracker I'll be more than happy to add you to the contributor page. Nah, I'm just happy to see RSpec constantly improving. If I come up with some more significant contributions in the future then I'll go through the proper channels... Cheers, Wincent From dchelimsky at gmail.com Thu May 24 06:45:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 05:45:17 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> Message-ID: <57c63afe0705240345o1a067a67p4a455ed7f703f7ef@mail.gmail.com> On 5/24/07, Wincent Colaiuta wrote: > El 24/5/2007, a las 11:53, David Chelimsky escribi?: > > > In truth, I already implemented exactly what you have there (in a > > hurry to get a release out today), but if you file the above in the > > tracker I'll be more than happy to add you to the contributor page. > > Nah, I'm just happy to see RSpec constantly improving. If I come up > with some more significant contributions in the future IF???????? Looking forward to it WHEN.... Cheers, David then I'll go > through the proper channels... > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Thu May 24 09:25:26 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 24 May 2007 15:25:26 +0200 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <942B9674-82A4-4522-A02A-DF7D301ACBED@wincent.com> References: <9DF09F73-6C27-4FFE-BA79-A0E2B5C296E7@wincent.com> <57c63afe0705211701j509f00cfh84eab720860cc17@mail.gmail.com> <01A103A1-8CA2-4F07-AE33-C29C7A2053D2@wincent.com> <57c63afe0705211727t7ab4389nf704329fc01fab8d@mail.gmail.com> <942B9674-82A4-4522-A02A-DF7D301ACBED@wincent.com> Message-ID: <36D873D8-1E7B-46FE-A5A3-6EC4A0EA0742@wincent.com> Ok, following up on my posts from a couple of days ago... The question: > When writing view specs is there any way to test not only for the > presence of tags (have_tag) and nested tags (with_tag), but also test > that they appear in a given order? The workaround: > One thing which may prove useful is that > assert_select returns an array of matches, and also passes that array > into any block (if called with a block). The array contains > HTML::Node instances, and these nodes have a position attribute (the > position of the node within the byte stream); so making comparisons > of order externally is possible and could be down already right now > with no changes (although not transparently; you'd have to explicitly > compare element positions in your specs). Here's an example spec showing one way this could be done. It's pretty ugly though (and I expect the list server will make it even uglier by hard-wrapping it) as it requires quite a bit of "book- keeping" to be done: describe '/users/index with 2 users' do before do users = (1..2).inject([]) do |list, index| user = mock("user #{index}") user.should_receive(:login_name).and_return("example login name #{index}") user.should_receive(:display_name).and_return("example display name #{index}") user.should_receive(:email_address).and_return("example email address #{index}") list << user end assigns[:users] = users render 'users/index' end it 'should display the login names, displays names and email address, in alternating odd and even rows' do odd = even = nil response.should have_tag('div.odd>div') do |match| odd = match[0] positions = [] with_tag('div.label', 'Login name:') { |match| positions << match[0].position } with_tag('div.info', 'example login name 1') { |match| positions << match[0].position } with_tag('div.label', 'Display name:') { |match| positions << match[0].position } with_tag('div.info', 'example display name 1') { |match| positions << match[0].position } with_tag('div.label', 'Email address:') { |match| positions << match[0].position } with_tag('div.info', 'example email address 1') { |match| positions << match[0].position } positions.should == positions.sort end response.should have_tag('div.even>div') do |match| even = match[0] positions = [] with_tag('div.label', 'Login name:') { |match| positions << match[0].position } with_tag('div.info', 'example login name 2') { |match| positions << match[0].position } with_tag('div.label', 'Display name:') { |match| positions << match[0].position } with_tag('div.info', 'example display name 2') { |match| positions << match[0].position } with_tag('div.label', 'Email address:') { |match| positions << match[0].position } with_tag('div.info', 'example email address 2') { |match| positions << match[0].position } positions.should == positions.sort end odd.position.should < even.position end end Compare this to the version without the book-keeping: describe '/users/index with 2 users' do before do users = (1..2).inject([]) do |list, index| user = mock("user #{index}") user.should_receive(:login_name).and_return("example login name #{index}") user.should_receive(:display_name).and_return("example display name #{index}") user.should_receive(:email_address).and_return("example email address #{index}") list << user end assigns[:users] = users render 'users/index' end it 'should display the login names, displays names and email address, in alternating odd and even rows' do response.should have_tag('div.odd>div') do with_tag('div.label', 'Login name:') with_tag('div.info', 'example login name 1') with_tag('div.label', 'Display name:') with_tag('div.info', 'example display name 1') with_tag('div.label', 'Email address:') with_tag('div.info', 'example email address 1') end response.should have_tag('div.even>div') do with_tag('div.label', 'Login name:') with_tag('div.info', 'example login name 2') with_tag('div.label', 'Display name:') with_tag('div.info', 'example display name 2') with_tag('div.label', 'Email address:') with_tag('div.info', 'example email address 2') end end end So, yes, the book-keeping-free version is much easier to look at, but it's also far too easy for the spec to pass with faulty input (jumble the divs around in any order you want and it will still pass). So improving have_tag, with_tag, or the underlying assert_select seems to be a very worthwhile project; I've got a very basic prototype implementation in place based on this small patch to actionpack/lib/ action_controller/assertions/selector_assertions.rb: === vendor/rails/actionpack/lib/action_controller/assertions/ selector_assertions.rb ================================================================== --- vendor/rails/actionpack/lib/action_controller/assertions/ selector_assertions.rb (revision 7191) +++ vendor/rails/actionpack/lib/action_controller/assertions/ selector_assertions.rb (local) @@ -286,6 +286,13 @@ "Expected at most #{equals[:maximum]} elements, found # {matches.size}." end + if !matches.empty? + if @previous_match and matches[0].position < @previous_match.position + raise "selector order mismatch ('#{matches[0].to_s}' at position #{matches[0].position} appears before '# {@previous_match.to_s}' at position #{@previous_match.position})" + end + @previous_match = matches[0] + end + # If a block is given call that block. Set @selected to allow # nested assert_select, which can be nested several levels deep. if block_given? && !matches.empty? Experimentation shows that the dynamic class created by RSpec for each "it" block receives the assert_select messages and hangs around for the duration of the block. So that means instance variables can be used to store positional information and an exception can be thrown if things don't happen in the expected order. This works, at least for the sample spec I've posted above. In the event of the ordering requirement failing the exception will include diagnostic information that looks like this: selector order mismatch ('
Display name:
' at position 109 appears before '
example login name 1' at position 150) Limitations, and doubts: - I don't know what type of exception to throw, so for now I'm just throwing a String (which becomes a RuntimeError) - no way to make it optional at this stage - this patch (or anything like it) is unlikely to get accepted in Rails because it will probably break lots of existing specs/tests which are written without caring about selector ordering Any further ideas? Cheers, Wincent From philodespotos at gmail.com Thu May 24 10:05:02 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Thu, 24 May 2007 09:05:02 -0500 Subject: [rspec-users] Annoying problem, stack error In-Reply-To: <7e565b5c0705232318w2fcda837o7d7faf652042172a@mail.gmail.com> References: <7e565b5c0705232318w2fcda837o7d7faf652042172a@mail.gmail.com> Message-ID: <60f3810c0705240705m31756b8bu7713b3bbb29eac19@mail.gmail.com> I have periodically been having this problem with edge, and I've seen others complaining about it happening before that, too. If you google it, you'll see this error ("Expected .../...rb to define ...") is fairly common. In my case, the issue was that I hadn't run db:migrate recently, and my has_many_polymorphs was somehow going a little crazy. "Expected .../tag.rb to define Tag". It's definitely not rspec, it's something that's not quite kosher on your end. Unfortunately, the error is painfully uninformative. Kyle On 5/24/07, Fischer, Daniel wrote: > For some reason rake spec is totally crapping out on me. > > I don't know what I did to make it break, the only thing I tried new > was install haml, but even after removing it there is still a stack > trace. > > Here is what I am getting- > > sparta at phalanx ff $ rake spec > (in /Users/sparta/Projects/work/idastudios/ff) > ..................../usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:249:in > `load_missing_constant': Expected > /Users/sparta/Projects/work/idastudios/ff/config/../app/models/asset.rb > to define Asset (LoadError) > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in > `const_missing' > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in > `const_missing' > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:260:in > `load_missing_constant' > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:468:in > `const_missing' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1360:in > `compute_type' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/reflection.rb:125:in > `send' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/reflection.rb:125:in > `klass' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_many_association.rb:194:in > `construct_sql' > ... 30 levels... > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > `parse' > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > `create_behaviour_runner' > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > `run' > from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec:3 > rake aborted! > Command ruby -I"/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib" > "/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec" > "spec/controllers/comments_controller_spec.rb" > "spec/controllers/posts_controller_spec.rb" > "spec/controllers/users_controller_spec.rb" > "spec/models/asset_spec.rb" "spec/models/category_spec.rb" > "spec/models/comment_spec.rb" "spec/models/message_spec.rb" > "spec/models/post_spec.rb" "spec/models/user_spec.rb" > "spec/models/vote_spec.rb" --options > "/Users/sparta/Projects/work/idastudios/ff/config/../spec/spec.opts" > failed > > (See full trace by running task with --trace) > > Anyone have an idea what the heck is going on? > > Thanks, > Daniel > > -- > www.writersbeat.com > www.danielfischer.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mdeiters at msn.com Thu May 24 10:24:17 2007 From: mdeiters at msn.com (Matt Deiters) Date: Thu, 24 May 2007 09:24:17 -0500 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <36D873D8-1E7B-46FE-A5A3-6EC4A0EA0742@wincent.com> Message-ID: Hey Wincent, A couple of questions/comments. Are you doing some sorting logic in the view? If so I can see why you would want to assert order, but perhaps it would be better to move that type of logic out of view and into your controller (or perhaps a presenter or helper). Then you would test the order of your collection in one of those (helper/controller) types of specs. Then your view would just iterate of the collection and if your view is just iterating over the collection, then when your testing order you would really be testing does 'ruby iterate right', which again is something we don't want to test in our views (or need test at all). Matt Deiters >From: Wincent Colaiuta >Reply-To: rspec-users >To: rspec-users >Subject: Re: [rspec-users] Ordering in view specs using have_tag and >with_tag >Date: Thu, 24 May 2007 15:25:26 +0200 > >Ok, following up on my posts from a couple of days ago... > >The question: > > > When writing view specs is there any way to test not only for the > > presence of tags (have_tag) and nested tags (with_tag), but also test > > that they appear in a given order? > >The workaround: > > > One thing which may prove useful is that > > assert_select returns an array of matches, and also passes that array > > into any block (if called with a block). The array contains > > HTML::Node instances, and these nodes have a position attribute (the > > position of the node within the byte stream); so making comparisons > > of order externally is possible and could be down already right now > > with no changes (although not transparently; you'd have to explicitly > > compare element positions in your specs). > >Here's an example spec showing one way this could be done. It's >pretty ugly though (and I expect the list server will make it even >uglier by hard-wrapping it) as it requires quite a bit of "book- >keeping" to be done: > >describe '/users/index with 2 users' do > before do > users = (1..2).inject([]) do |list, index| > user = mock("user #{index}") > user.should_receive(:login_name).and_return("example login >name #{index}") > user.should_receive(:display_name).and_return("example display >name #{index}") > user.should_receive(:email_address).and_return("example email >address #{index}") > list << user > end > assigns[:users] = users > render 'users/index' > end > > it 'should display the login names, displays names and email >address, in alternating odd and even rows' do > odd = even = nil > response.should have_tag('div.odd>div') do |match| > odd = match[0] > positions = [] > with_tag('div.label', 'Login name:') { |match| >positions << match[0].position } > with_tag('div.info', 'example login name 1') { |match| >positions << match[0].position } > with_tag('div.label', 'Display name:') { |match| >positions << match[0].position } > with_tag('div.info', 'example display name 1') { |match| >positions << match[0].position } > with_tag('div.label', 'Email address:') { |match| >positions << match[0].position } > with_tag('div.info', 'example email address 1') { |match| >positions << match[0].position } > positions.should == positions.sort > end > response.should have_tag('div.even>div') do |match| > even = match[0] > positions = [] > with_tag('div.label', 'Login name:') { |match| >positions << match[0].position } > with_tag('div.info', 'example login name 2') { |match| >positions << match[0].position } > with_tag('div.label', 'Display name:') { |match| >positions << match[0].position } > with_tag('div.info', 'example display name 2') { |match| >positions << match[0].position } > with_tag('div.label', 'Email address:') { |match| >positions << match[0].position } > with_tag('div.info', 'example email address 2') { |match| >positions << match[0].position } > positions.should == positions.sort > end > odd.position.should < even.position > end >end > >Compare this to the version without the book-keeping: > >describe '/users/index with 2 users' do > before do > users = (1..2).inject([]) do |list, index| > user = mock("user #{index}") > user.should_receive(:login_name).and_return("example login >name #{index}") > user.should_receive(:display_name).and_return("example display >name #{index}") > user.should_receive(:email_address).and_return("example email >address #{index}") > list << user > end > assigns[:users] = users > render 'users/index' > end > > it 'should display the login names, displays names and email >address, in alternating odd and even rows' do > response.should have_tag('div.odd>div') do > with_tag('div.label', 'Login name:') > with_tag('div.info', 'example login name 1') > with_tag('div.label', 'Display name:') > with_tag('div.info', 'example display name 1') > with_tag('div.label', 'Email address:') > with_tag('div.info', 'example email address 1') > end > response.should have_tag('div.even>div') do > with_tag('div.label', 'Login name:') > with_tag('div.info', 'example login name 2') > with_tag('div.label', 'Display name:') > with_tag('div.info', 'example display name 2') > with_tag('div.label', 'Email address:') > with_tag('div.info', 'example email address 2') > end > end >end > >So, yes, the book-keeping-free version is much easier to look at, but >it's also far too easy for the spec to pass with faulty input (jumble >the divs around in any order you want and it will still pass). So >improving have_tag, with_tag, or the underlying assert_select seems >to be a very worthwhile project; I've got a very basic prototype >implementation in place based on this small patch to actionpack/lib/ >action_controller/assertions/selector_assertions.rb: > >=== vendor/rails/actionpack/lib/action_controller/assertions/ >selector_assertions.rb >================================================================== >--- vendor/rails/actionpack/lib/action_controller/assertions/ >selector_assertions.rb (revision 7191) >+++ vendor/rails/actionpack/lib/action_controller/assertions/ >selector_assertions.rb (local) >@@ -286,6 +286,13 @@ > "Expected at most #{equals[:maximum]} elements, found # >{matches.size}." > end > >+ if !matches.empty? >+ if @previous_match and matches[0].position < >@previous_match.position >+ raise "selector order mismatch ('#{matches[0].to_s}' at >position #{matches[0].position} appears before '# >{@previous_match.to_s}' at position #{@previous_match.position})" >+ end >+ @previous_match = matches[0] >+ end >+ > # If a block is given call that block. Set @selected to allow > # nested assert_select, which can be nested several levels >deep. > if block_given? && !matches.empty? > >Experimentation shows that the dynamic class created by RSpec for >each "it" block receives the assert_select messages and hangs around >for the duration of the block. So that means instance variables can >be used to store positional information and an exception can be >thrown if things don't happen in the expected order. > >This works, at least for the sample spec I've posted above. In the >event of the ordering requirement failing the exception will include >diagnostic information that looks like this: > >selector order mismatch ('
Display name:
' at >position 109 appears before '
example login name 1div>' at position 150) > >Limitations, and doubts: > >- I don't know what type of exception to throw, so for now I'm just >throwing a String (which becomes a RuntimeError) > >- no way to make it optional at this stage > >- this patch (or anything like it) is unlikely to get accepted in >Rails because it will probably break lots of existing specs/tests >which are written without caring about selector ordering > >Any further ideas? > >Cheers, >Wincent > >_______________________________________________ >rspec-users mailing list >rspec-users at rubyforge.org >http://rubyforge.org/mailman/listinfo/rspec-users From joevandyk at gmail.com Thu May 24 10:31:21 2007 From: joevandyk at gmail.com (Joe Van Dyk) Date: Thu, 24 May 2007 07:31:21 -0700 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <89327C27-8DD0-47D9-82DA-BCAF0D9EB1F2@wincent.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <89327C27-8DD0-47D9-82DA-BCAF0D9EB1F2@wincent.com> Message-ID: On 5/24/07, Wincent Colaiuta wrote: > El 24/5/2007, a las 9:18, Tim Lucas escribi?: > > > I did it a slighty dodgy way (spec/controllers/ > > application_controller_spec.rb): > > http://pastie.caboo.se/64123 > > First, thanks for the advice! > > Why do you say "dodgy"? > > > but nowadays you can probably use a shared spec, like so (require'd > > from your spec helper): > > Probably not a bad idea. In that way you'd get confirmation that no > subclass is overriding the behaviour of the superclass in unexpected > ways. I'd vote for shared spec (i.e. CaresAboutLoggingIn) and have that spec test that the controller does the right things. Joe From win at wincent.com Thu May 24 10:56:16 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 24 May 2007 16:56:16 +0200 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: References: Message-ID: <487D1990-941E-42D4-9079-51245BBEE68B@wincent.com> El 24/5/2007, a las 16:24, Matt Deiters escribi?: > A couple of questions/comments. Are you doing some sorting logic in > the view? If so I can see why you would want to assert order, but > perhaps it would be better to move that type of logic out of view > and into your controller (or perhaps a presenter or helper). Then > you would test the order of your collection in one of those (helper/ > controller) types of specs. Then your view would just iterate of > the collection and if your view is just iterating over the > collection, then when your testing order you would really be > testing does 'ruby iterate right', which again is something we > don't want to test in our views (or need test at all). No, the view has no sorting logic: <% for user in @users %>
Login name:
<%=h user.login_name %>
Display name:
<%=h user.display_name %>
Email address:
<%=h user.email_address %>
<% end %> But I do want to be sure of some things, and these stemmed out of behaviour-driving the development of the view. I basically imagined what I wanted the view to look like in my mind and started coming up with specifications: - users should be listed in rows - rows should have alternate classes (odd, even, odd, even) so they can be visually styled - there should be three fields for each user - the fields should appear in order: login name, display name, email address - each field should be preceded by the correct, corresponding label - users should appear in the view in the order that they were passed to it - etc So when I wrote the view based on the specs. I was dismayed to find that if I ignored the question of ordering then I could radically change the view and the specs would still pass, even though I the view no longer resembled what I wanted it to look like in my mind... Basically, I want to be able to assert that "rows should be odd, even" and only "odd, even" should pass, not "even, odd". Likewise, I want to be able to assert "header, content, footer" and not accept results like "footer, header, content" etc. In the case where order doesn't matter at all and you only want to test for the presence of something on the page, you can easily do that with a single "have_tag" inside an example "it" block of its own. Cheers, Wincent From daniel at danielfischer.com Thu May 24 13:25:47 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Thu, 24 May 2007 10:25:47 -0700 Subject: [rspec-users] Annoying problem, stack error In-Reply-To: <8d961d900705240225p49e90792wb3c4bb763baeed1b@mail.gmail.com> References: <7e565b5c0705232318w2fcda837o7d7faf652042172a@mail.gmail.com> <8d961d900705240225p49e90792wb3c4bb763baeed1b@mail.gmail.com> Message-ID: <7e565b5c0705241025ld52ce20qd7bfe56b33ff320a@mail.gmail.com> Aslak, Great meeting you at the Rspec BoF! Anyway, I figured it out. Apparently I installed a new plugin, but that installed it as "trunk", when there was already a trunk plugin respository from file_column. I never noticed that it defaulted to trunk instead of the plugin's name. Weird. How I figured this out, I have no clue. So, after reinstalling my plugins and renaming them to what they are truly called, everything worked. :) On 5/24/07, aslak hellesoy wrote: > > On 5/24/07, Fischer, Daniel wrote: > > For some reason rake spec is totally crapping out on me. > > > > Judging from the stack trace it doesn't look like it's from RSpec. In > any case, we need more context to help you. A failing spec, detailed > version info etc. > > Aslak > > > I don't know what I did to make it break, the only thing I tried new > > was install haml, but even after removing it there is still a stack > > trace. > > > > Here is what I am getting- > > > > sparta at phalanx ff $ rake spec > > (in /Users/sparta/Projects/work/idastudios/ff) > > ..................../usr/local/lib/ruby/gems/1.8/gems/activesupport- > 1.4.2/lib/active_support/dependencies.rb:249:in > > `load_missing_constant': Expected > > /Users/sparta/Projects/work/idastudios/ff/config/../app/models/asset.rb > > to define Asset (LoadError) > > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:452:in > > `const_missing' > > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:464:in > > `const_missing' > > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:260:in > > `load_missing_constant' > > from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:468:in > > `const_missing' > > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3 > /lib/active_record/base.rb:1360:in > > `compute_type' > > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3 > /lib/active_record/reflection.rb:125:in > > `send' > > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3 > /lib/active_record/reflection.rb:125:in > > `klass' > > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3 > /lib/active_record/associations/has_many_association.rb:194:in > > `construct_sql' > > ... 30 levels... > > from > /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > > `parse' > > from > /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > > `create_behaviour_runner' > > from > /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > > `run' > > from > /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec:3 > > rake aborted! > > Command ruby > -I"/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib" > > > "/Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/bin/spec" > > "spec/controllers/comments_controller_spec.rb" > > "spec/controllers/posts_controller_spec.rb" > > "spec/controllers/users_controller_spec.rb" > > "spec/models/asset_spec.rb" "spec/models/category_spec.rb" > > "spec/models/comment_spec.rb" "spec/models/message_spec.rb" > > "spec/models/post_spec.rb" "spec/models/user_spec.rb" > > "spec/models/vote_spec.rb" --options > > "/Users/sparta/Projects/work/idastudios/ff/config/../spec/spec.opts" > > failed > > > > (See full trace by running task with --trace) > > > > Anyone have an idea what the heck is going on? > > > > Thanks, > > Daniel > > > > -- > > www.writersbeat.com > > www.danielfischer.com > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > -- www.writersbeat.com www.danielfischer.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070524/73e86aa9/attachment-0001.html From hughes.james at gmail.com Thu May 24 14:34:34 2007 From: hughes.james at gmail.com (James Hughes) Date: Thu, 24 May 2007 11:34:34 -0700 Subject: [rspec-users] Missing RspecScaffoldGenerator Message-ID: <765a2c230705241134j43524a32l929458b79fccca96@mail.gmail.com> Just a quick note that I had to make the following change after installing 1.0.2 as rails plugins to get the resource generator working: Index: rspec_scaffold_generator.rb =================================================================== --- rspec_scaffold_generator.rb (revision 2022) +++ rspec_scaffold_generator.rb (working copy) @@ -1,4 +1,4 @@ -class RspecResourceGenerator < Rails::Generator::NamedBase +class RspecScaffoldGenerator < Rails::Generator::NamedBase default_options :skip_migration => false attr_reader :controller_name, From joevandyk at gmail.com Thu May 24 14:36:05 2007 From: joevandyk at gmail.com (Joe Van Dyk) Date: Thu, 24 May 2007 11:36:05 -0700 Subject: [rspec-users] mocking out helper method in a view spec Message-ID: Hi, How can I mock or stub out a helper method that's being called in a view that's described by a view spec? Joe From tristil at gmail.com Thu May 24 14:37:07 2007 From: tristil at gmail.com (Joseph Method) Date: Thu, 24 May 2007 14:37:07 -0400 Subject: [rspec-users] Missing RspecScaffoldGenerator In-Reply-To: <765a2c230705241134j43524a32l929458b79fccca96@mail.gmail.com> References: <765a2c230705241134j43524a32l929458b79fccca96@mail.gmail.com> Message-ID: <167b6aa00705241137p67eff08fv45e6b48c653e2457@mail.gmail.com> So did I. On 5/24/07, James Hughes wrote: > Just a quick note that I had to make the following change after > installing 1.0.2 as rails plugins to get the resource generator > working: > > Index: rspec_scaffold_generator.rb > =================================================================== > --- rspec_scaffold_generator.rb (revision 2022) > +++ rspec_scaffold_generator.rb (working copy) > @@ -1,4 +1,4 @@ > -class RspecResourceGenerator < Rails::Generator::NamedBase > +class RspecScaffoldGenerator < Rails::Generator::NamedBase > default_options :skip_migration => false > > attr_reader :controller_name, > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- -J. Method From dchelimsky at gmail.com Thu May 24 14:37:36 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 13:37:36 -0500 Subject: [rspec-users] Missing RspecScaffoldGenerator In-Reply-To: <167b6aa00705241137p67eff08fv45e6b48c653e2457@mail.gmail.com> References: <765a2c230705241134j43524a32l929458b79fccca96@mail.gmail.com> <167b6aa00705241137p67eff08fv45e6b48c653e2457@mail.gmail.com> Message-ID: <57c63afe0705241137n20b0e877m11cade810741c5cd@mail.gmail.com> This is already fixed in trunk and will be released w/ 1.0.3 later today. On 5/24/07, Joseph Method wrote: > So did I. > > On 5/24/07, James Hughes wrote: > > Just a quick note that I had to make the following change after > > installing 1.0.2 as rails plugins to get the resource generator > > working: > > > > Index: rspec_scaffold_generator.rb > > =================================================================== > > --- rspec_scaffold_generator.rb (revision 2022) > > +++ rspec_scaffold_generator.rb (working copy) > > @@ -1,4 +1,4 @@ > > -class RspecResourceGenerator < Rails::Generator::NamedBase > > +class RspecScaffoldGenerator < Rails::Generator::NamedBase > > default_options :skip_migration => false > > > > attr_reader :controller_name, > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > -J. Method > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From philodespotos at gmail.com Thu May 24 15:13:51 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Thu, 24 May 2007 14:13:51 -0500 Subject: [rspec-users] mocking out helper method in a view spec In-Reply-To: References: Message-ID: <60f3810c0705241213q271150d5j37a5f008a954bd33@mail.gmail.com> You can stub/mock methods on @controller.template. Kyle On 5/24/07, Joe Van Dyk wrote: > Hi, > > How can I mock or stub out a helper method that's being called in a > view that's described by a view spec? > > Joe > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 24 15:15:48 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 14:15:48 -0500 Subject: [rspec-users] mocking out helper method in a view spec In-Reply-To: <60f3810c0705241213q271150d5j37a5f008a954bd33@mail.gmail.com> References: <60f3810c0705241213q271150d5j37a5f008a954bd33@mail.gmail.com> Message-ID: <57c63afe0705241215x276ea969k59dad6b8ec4622bb@mail.gmail.com> On 5/24/07, Kyle Hargraves wrote: > You can stub/mock methods on @controller.template. Actually - you can access that directly if you're on 1.0.2 through the #template method (which returns @controller.template) > > Kyle > > On 5/24/07, Joe Van Dyk wrote: > > Hi, > > > > How can I mock or stub out a helper method that's being called in a > > view that's described by a view spec? > > > > Joe > > _______________________________________________ > > 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 anthony at digitalphenom.com Thu May 24 15:16:41 2007 From: anthony at digitalphenom.com (Anthony Carlos) Date: Thu, 24 May 2007 15:16:41 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> Message-ID: <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> Tim: I'm sorry, but I'm a newbie and I don't fully understand. Could you please give me more details? 1. Is the slightly dodgy way completely separate from using a shared spec? 2. What is the appropriate file path and name for your first example regarding a shared spec? Is it RAILS_ROOT/spec/controllers/ all_controllers_spec.rb? 3. Does the event controller spec belong in RAILS_ROOT/spec/ controllers/event_controller_spec.rb? 4. How do you actually fire off the test? Do I have to call get or post inside a do-end block that is attached to it_should_behave_like "All controllers"? e.g., describe EventController do it_should_behave_like "All controllers" do get 'event1' # just an example action end end 5. Is there any further documentation on it_should_behave_like other than the RDoc? It doesn't really say too much. Thanks for your help! -Anthony On May 24, 2007, at 3:18 AM, Tim Lucas wrote: > On 24/05/2007, at 5:00 PM, Wincent Colaiuta wrote: > >> The Rails ApplicationController (app/controllers/application.rb) >> serves as an abstract superclass for all other controllers in a Rails >> application and is a good place to put methods and filters which you >> want all of your controllers to use. In my case I'm using it to >> provide methods such as "current_user" and "logged_in?" etc. >> >> By default, RSpec doesn't produce a corresponding spec file for this >> controller. >> >> I've made a spec file (spec/controllers/application_spec.rb) so that >> I can test these methods, but I'm not sure if this is the right thing >> to do. Should I be testing only the non-abstract subclasses instead? > > I did it a slighty dodgy way (spec/controllers/ > application_controller_spec.rb): > http://pastie.caboo.se/64123 > > but nowadays you can probably use a shared spec, like so (require'd > from your spec helper): > > describe "All controllers", :shared => true do > it "should redirect to HQ if no subdomains specified" do > ... > end > end > > and then: > > describe EventController do > it_should_behave_like "All controllers" > ... > end > > Not sure how you'd deal with something like skip_before_filter > though... > > -- tim > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From coda.hale at gmail.com Thu May 24 17:15:10 2007 From: coda.hale at gmail.com (Coda Hale) Date: Thu, 24 May 2007 14:15:10 -0700 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> Message-ID: On 5/24/07, David Chelimsky wrote: > I don't think this is too simplistic - as long as the nested dirs > align in lib and spec/lib, then the regexp matcher will include the > '/'es, and all will be right with the world. > > In truth, I already implemented exactly what you have there (in a > hurry to get a release out today), but if you file the above in the > tracker I'll be more than happy to add you to the contributor page. A related question -- where do spec support files go? For example, I've got more than a few one-off matchers and such, and having a 500-line spec_helper.rb doesn't seem workable. I ended up putting mine in /spec/lib, and the specs for /lib files in /libraries. Any ideas? -- Coda Hale http://blog.codahale.com From dchelimsky at gmail.com Thu May 24 17:17:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 16:17:29 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> Message-ID: <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> On 5/24/07, Coda Hale wrote: > On 5/24/07, David Chelimsky wrote: > > I don't think this is too simplistic - as long as the nested dirs > > align in lib and spec/lib, then the regexp matcher will include the > > '/'es, and all will be right with the world. > > > > In truth, I already implemented exactly what you have there (in a > > hurry to get a release out today), but if you file the above in the > > tracker I'll be more than happy to add you to the contributor page. > > A related question -- where do spec support files go? For example, > I've got more than a few one-off matchers and such, and having a > 500-line spec_helper.rb doesn't seem workable. > > I ended up putting mine in /spec/lib, and the specs for /lib files in > /libraries. I'd definitely have the specs for lib in spec/lib. As for your helpers, how about spec/helpers???? > > Any ideas? > > -- > Coda Hale > http://blog.codahale.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From coda.hale at gmail.com Thu May 24 17:22:36 2007 From: coda.hale at gmail.com (Coda Hale) Date: Thu, 24 May 2007 14:22:36 -0700 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> Message-ID: On 5/24/07, David Chelimsky wrote: > On 5/24/07, Coda Hale wrote: > > A related question -- where do spec support files go? For example, > > I've got more than a few one-off matchers and such, and having a > > 500-line spec_helper.rb doesn't seem workable. > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > /libraries. > > I'd definitely have the specs for lib in spec/lib. As for your > helpers, how about spec/helpers???? Thanks for the quick reply! I'm not sure if I was clear -- I'm not looking for a place to put the specs for my helpers. That's obviously /sepc/helpers. I'm looking for a place to put the support classes for the specs -- custom matchers, etc. If I stuff them all in spec_helper.rb, it'll grow to be unmanageably large. -- Coda Hale http://blog.codahale.com From dchelimsky at gmail.com Thu May 24 17:28:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 16:28:30 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> Message-ID: <57c63afe0705241428n52eb8588w71e5e9235284f8c6@mail.gmail.com> On 5/24/07, Coda Hale wrote: > On 5/24/07, David Chelimsky wrote: > > On 5/24/07, Coda Hale wrote: > > > A related question -- where do spec support files go? For example, > > > I've got more than a few one-off matchers and such, and having a > > > 500-line spec_helper.rb doesn't seem workable. > > > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > > /libraries. > > > > I'd definitely have the specs for lib in spec/lib. As for your > > helpers, how about spec/helpers???? > > Thanks for the quick reply! > > I'm not sure if I was clear -- I'm not looking for a place to put the > specs for my helpers. That's obviously /sepc/helpers. I'm looking for > a place to put the support classes for the specs -- custom matchers, > etc. If I stuff them all in spec_helper.rb, it'll grow to be > unmanageably large. Right - I understood the question. I spaced for a second that we already have spec/helpers - sorry. Pick any name you like other than lib, models, views, controllers, helpers, etc. But definitely in a subdirectory there. How about support, or common, or inc, or something like that? > > -- > Coda Hale > http://blog.codahale.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Thu May 24 17:29:55 2007 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 24 May 2007 18:29:55 -0300 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> Message-ID: <71166b3b0705241429n57c8148h780abb047b8933fb@mail.gmail.com> On 5/24/07, Coda Hale wrote: > On 5/24/07, David Chelimsky wrote: > > On 5/24/07, Coda Hale wrote: > > > A related question -- where do spec support files go? For example, > > > I've got more than a few one-off matchers and such, and having a > > > 500-line spec_helper.rb doesn't seem workable. > > > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > > /libraries. > > > > I'd definitely have the specs for lib in spec/lib. As for your > > helpers, how about spec/helpers???? > > Thanks for the quick reply! > > I'm not sure if I was clear -- I'm not looking for a place to put the > specs for my helpers. That's obviously /sepc/helpers. I'm looking for > a place to put the support classes for the specs -- custom matchers, > etc. If I stuff them all in spec_helper.rb, it'll grow to be > unmanageably large. > I'm using spec/lib for that, and spec/libraries for exampling code at RAILS_ROOT/lib -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From dchelimsky at gmail.com Thu May 24 17:31:09 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 16:31:09 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <71166b3b0705241429n57c8148h780abb047b8933fb@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> <71166b3b0705241429n57c8148h780abb047b8933fb@mail.gmail.com> Message-ID: <57c63afe0705241431me4c9f67tecc95683e0b40382@mail.gmail.com> On 5/24/07, Luis Lavena wrote: > On 5/24/07, Coda Hale wrote: > > On 5/24/07, David Chelimsky wrote: > > > On 5/24/07, Coda Hale wrote: > > > > A related question -- where do spec support files go? For example, > > > > I've got more than a few one-off matchers and such, and having a > > > > 500-line spec_helper.rb doesn't seem workable. > > > > > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > > > /libraries. > > > > > > I'd definitely have the specs for lib in spec/lib. As for your > > > helpers, how about spec/helpers???? > > > > Thanks for the quick reply! > > > > I'm not sure if I was clear -- I'm not looking for a place to put the > > specs for my helpers. That's obviously /sepc/helpers. I'm looking for > > a place to put the support classes for the specs -- custom matchers, > > etc. If I stuff them all in spec_helper.rb, it'll grow to be > > unmanageably large. > > > > I'm using spec/lib for that, and spec/libraries for exampling code at > RAILS_ROOT/lib That's two for two, but it won't work if you want to use autotest. > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Thu May 24 17:35:37 2007 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 24 May 2007 18:35:37 -0300 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <57c63afe0705241431me4c9f67tecc95683e0b40382@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> <71166b3b0705241429n57c8148h780abb047b8933fb@mail.gmail.com> <57c63afe0705241431me4c9f67tecc95683e0b40382@mail.gmail.com> Message-ID: <71166b3b0705241435w351acfabje5c41385c1af93ea@mail.gmail.com> On 5/24/07, David Chelimsky wrote: [...] > > I'm using spec/lib for that, and spec/libraries for exampling code at > > RAILS_ROOT/lib > > That's two for two, but it won't work if you want to use autotest. > Er, not a fan of autotest/zentest :-P -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From ruyasan at gmail.com Thu May 24 17:35:49 2007 From: ruyasan at gmail.com (Ruy Asan) Date: Thu, 24 May 2007 14:35:49 -0700 Subject: [rspec-users] Mocking, changing method interfaces and integration tests Message-ID: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> Suppose we have a method 'foo' which internally uses another method 'bar'. Being good BDDers we mock out the 'bar' method. After all, we only want to spec the 'foo' method - actually running the 'bar' method means slower, less maintainable and brittler specs. That's why we <3 mocking, right? We rely on the fact that 'bar' is being adequately tested somewhere else, by whomever wrote it. They can change their implementation of 'bar' and we can change our implementation of 'foo' and as long as the existing tests keep passing everyone is happy. But what happens if 'bar' needs to be refactored in a way that changes the interface? rSpec does succeed in informing bar's author that he is breaking someone's expectations about the 'bar' function - however, he really has no idea whose expectations he is breaking. (i.e. rSpec doesn't give us any clues about what exactly has to follow our change in interface- it just tells us something may be broken). Changing the interface of bar means going over the code the hard way, getting in touch with everyone that uses the 'bar' function and making sure everything still works. Not very agile! It makes changing interfaces a very very expensive process. Of course, such changes are never really cheap - but because of mocks it becomes really REALLY expensive. So what are our options? 1) Don't use mocks. Not using mocks would of course catch any such problems right away. Yes mocks have benefits, but if we plan on refactoring often, the above scenario may just be too high a price to pay. 2) Don't change interfaces (too often) - i.e. specs should be treated as immutable. If it's such an expensive process just make sure it doesn't have to happen that often ;) I think if you have an all-vet, all-star team of programmers this could work out just fine - but even then, having change be expensive just isn't a good thing. Sometimes the app grows in a certain way and changing an interface is simply The Right Thing To Do? - but it will probably break the app in a hard to fix way so Let's Just Stick With What Works? takes over :p 3) Rely on integration testing to catch these sort of bugs. This too can work - although it seems to shift a significant burden on integration testing. Doesn't it sort of imply we need 100% (or close to that) integration test coverage? Doesn't that mean A LOT of integration testing, and aren't integration tests horribly brittle, time consuming to write in large numbers and a PITA to maintain? I'm actually kind of confused about how integration tests fit in with the rSpec+Mocks way of doing things. I really don't hear of teams doing regular integration testing in a true "let's test all our coupling"-sense. (and speaking from experience, it really is a pain in the ass to do a lot of it - SO BRITTLE!) At the same, it also seems kind-of necessary. In addition to the above refactoring problem, there's the question of reliable your external libraries really are (which you are going out of your way not to test by using mocks). They are often buggy, often famously so. Having 100:1 rSpec to code ratio won't save you from IE6 bugs :p Having a javascript- heavy rails app with lots of IE6 users (not exactly an edge case with rspec users...) means these bugs are rather important. You can't rely on rSpec to catch problems before pushing out a new version of your app. Doesn't this take away one of the main benefits of automated testing? Just aside from this whole business - I'm wondering how others are dealing with this problem? JS unit testing can help, no doubt, but there are lot and lots of things that can wrong outside such tests, and like I said, comprehensive unit tests are phenomenally hard to write and maintain. So basically all 3 of the above options are pretty crappy. One idea I had is to automatically translate MyObj#should_receive (:method).and_return("value") into a seprate spec for MyObj but... that actually just defeats the whole purpose of mock objects in a very round-about way :p Another idea is to have a spec runner option which ignores all mocks and stubs - using the real options instead. This run mode would ONLY be triggered when someone changes an existing spec, specifically to to answer the question of "whose code did i just break". However - I think this would radically change the way specs have to be designed to really work. :/ I'm curious to hear how I should deal with these problems. Since i've been kinda rambly, I'll restate my complaints: (Note: when I say rSpec, I actually mean rSpec with heavy use of mocking, which seems to be the recommended way to go. I am aware that rspec != mocking, and that most of these complaints are actually more particular to mocking then rspec, but nevertheless, rspec and mocks do go hand in hand more often then not:) 1) If you change the interface of a function - all rSpec tells you is that something may have broken (because your existing specs for the function in question will fail initially). You don't actually know for a fact anything broke, and you definitely don't know what broke. It's also very easy for someone new to rSpec to not realize that changing an existing spec may lead to un-detected failure somewhere else. 2) Mocking external libraries and/or access to external applications assumes these always work as expected, which as we all know, is a dirty lie :p (handy as it may be). rSpec does not protect you against bugs in the libraries you're using in any way. 3) rSpec + Rails leaves a very size-able javascript and browser blind spot. No way of dealing with this exists other then integration testing (a-la selenium), and there is no accepted way of doing integration testing that is both feasible (i.e. doesn't take for ever) and reliable (i.e. actually covers a good part of your code). Finally, I really should mention that I'm actually quite happy with rSpec overall, and yes, I'm aware I'm asking a lot of rSpec here :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070524/abd12560/attachment.html From dchelimsky at gmail.com Thu May 24 17:38:23 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 24 May 2007 16:38:23 -0500 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: <71166b3b0705241435w351acfabje5c41385c1af93ea@mail.gmail.com> References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> <57c63afe0705241417n3a450fbfj8d18c8871d8a5327@mail.gmail.com> <71166b3b0705241429n57c8148h780abb047b8933fb@mail.gmail.com> <57c63afe0705241431me4c9f67tecc95683e0b40382@mail.gmail.com> <71166b3b0705241435w351acfabje5c41385c1af93ea@mail.gmail.com> Message-ID: <57c63afe0705241438i5c5fb86ej96c34d9781af3423@mail.gmail.com> On 5/24/07, Luis Lavena wrote: > On 5/24/07, David Chelimsky wrote: > [...] > > > I'm using spec/lib for that, and spec/libraries for exampling code at > > > RAILS_ROOT/lib > > > > That's two for two, but it won't work if you want to use autotest. > > > > Er, not a fan of autotest/zentest :-P What don't you like about autotest? > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel at danielfischer.com Fri May 25 05:05:11 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Fri, 25 May 2007 02:05:11 -0700 Subject: [rspec-users] RCov? Message-ID: <7e565b5c0705250205i18daf9ben37e7a67ca36918c8@mail.gmail.com> Sorry to be a newb about this, but I'm trying to integrate rcov into my tests. I tried to follow the example located here: http://rspec.rubyforge.org/tools/rcov.html But to my dismay, I just don't understand what to do. I tried to run that task in the rspec plugins directory, but it threw an error about pre_commit. Regardless though, I want to be able to rcov all of "my" code, so where would I put this, in the regular Rakefile in the app directory? That doesn't make much sense though, does it? (Questioning because the syntax id different). Anyway, I'm confused, and I could use help, thanks! -- www.writersbeat.com www.danielfischer.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070525/40733570/attachment-0001.html From aslak.hellesoy at gmail.com Fri May 25 05:15:38 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 25 May 2007 11:15:38 +0200 Subject: [rspec-users] RCov? In-Reply-To: <7e565b5c0705250205i18daf9ben37e7a67ca36918c8@mail.gmail.com> References: <7e565b5c0705250205i18daf9ben37e7a67ca36918c8@mail.gmail.com> Message-ID: <8d961d900705250215p74f286d9j45ac4685fa163f43@mail.gmail.com> On 5/25/07, Fischer, Daniel wrote: > Sorry to be a newb about this, but I'm trying to integrate rcov into my > tests. I tried to follow the example located here: You don't have to apologise for being a newb - we're nice here :-) > http://rspec.rubyforge.org/tools/rcov.html > The correct page is actually here: http://rspec.rubyforge.org/documentation/tools/rcov.html (We've had some trouble deleting old pages) > But to my dismay, I just don't understand what to do. I tried to run that > task in the rspec plugins directory, but it threw an error about pre_commit. Are you trying to run RSpec's own specs or *your* own specs? What command did you type, in what directory and what console output did you get? What are your versions of everything relevant? (ruby, rspec, rails if you use that, rcov, rake, OS etc etc) > Regardless though, I want to be able to rcov all of "my" code, so where > would I put this, in the regular Rakefile in the app directory? I assume you're using Rails then (RSpec is not only for Rails). You should have a spec:rcov task ready for you! If you have grep, just do the following to see all spec related tasks: rake -T | grep spec HTH, Aslak > That doesn't > make much sense though, does it? (Questioning because the syntax id > different). > > Anyway, I'm confused, and I could use help, thanks! > > -- > www.writersbeat.com > www.danielfischer.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pocketsized at tiscali.co.uk Fri May 25 05:40:03 2007 From: pocketsized at tiscali.co.uk (David Green) Date: Fri, 25 May 2007 10:40:03 +0100 Subject: [rspec-users] still seeing strange behaviour with spec_server Message-ID: <9612333e0705250240te95bc60r6e0efc40d398402b@mail.gmail.com> hi all a few days ago i reported spec_server didn't appear to be running specs and the command itself was running slowly. I've since tried it on a new system with a clean install of ubuntu 7.04, rails 1.2.3 and rspec 1.0.2 and I'm seeing the same behavior. *** without spec_server *** x at holly:~/rails/test$ time ruby script/spec spec/models/user_spec.rb . Finished in 0.08807 seconds 1 example, 0 failures real 0m2.042s user 0m1.544s sys 0m0.260s *** with spec_server running and the --drb option *** x at holly:~/rails/test$ time ruby script/spec spec/models/user_spec.rb --drb Finished in 1.5e-05 seconds 0 examples, 0 failures real 0m5.582s user 0m0.176s sys 0m0.012s the spec's are just the ones created by the rspec model generator. the rails app is completely new except for an empty User model could someone else please try to replicate this? thanks dave From court3nay at gmail.com Fri May 25 06:18:03 2007 From: court3nay at gmail.com (Courtenay) Date: Fri, 25 May 2007 03:18:03 -0700 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> Message-ID: <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> Wow, you did a great job of writing up that irc discussion we had. I just had a thought; what about if there was a way of "running" your mock against the real thing to see if they (still) match up? Courtenay On 5/24/07, Ruy Asan wrote: > Suppose we have a method 'foo' which internally uses another method 'bar'. > > Being good BDDers we mock out the 'bar' method. After all, we only want to > spec the 'foo' method - actually running the 'bar' method means slower, less > maintainable and brittler specs. That's why we <3 mocking, right? > > We rely on the fact that 'bar' is being adequately tested somewhere else, by > whomever wrote it. They can change their implementation of 'bar' and we can > change our implementation of 'foo' and as long as the existing tests keep > passing everyone is happy. > > But what happens if 'bar' needs to be refactored in a way that changes the > interface? rSpec does succeed in informing bar's author that he is breaking > someone's expectations about the 'bar' function - however, he really has no > idea whose expectations he is breaking. (i.e. rSpec doesn't give us any > clues about what exactly has to follow our change in interface- it just > tells us something may be broken). > > Changing the interface of bar means going over the code the hard way, > getting in touch with everyone that uses the 'bar' function and making sure > everything still works. Not very agile! It makes changing interfaces a very > very expensive process. Of course, such changes are never really cheap - but > because of mocks it becomes really REALLY expensive. > > So what are our options? > > 1) Don't use mocks. Not using mocks would of course catch any such problems > right away. Yes mocks have benefits, but if we plan on refactoring often, > the above scenario may just be too high a price to pay. > > 2) Don't change interfaces (too often) - i.e. specs should be treated as > immutable. If it's such an expensive process just make sure it doesn't have > to happen that often ;) I think if you have an all-vet, all-star team of > programmers this could work out just fine - but even then, having change be > expensive just isn't a good thing. Sometimes the app grows in a certain way > and changing an interface is simply The Right Thing To Do? - but it will > probably break the app in a hard to fix way so Let's Just Stick With What > Works? takes over :p > > 3) Rely on integration testing to catch these sort of bugs. This too can > work - although it seems to shift a significant burden on integration > testing. Doesn't it sort of imply we need 100% (or close to that) > integration test coverage? Doesn't that mean A LOT of integration testing, > and aren't integration tests horribly brittle, time consuming to write in > large numbers and a PITA to maintain? > > I'm actually kind of confused about how integration tests fit in with the > rSpec+Mocks way of doing things. I really don't hear of teams doing regular > integration testing in a true "let's test all our coupling"-sense. (and > speaking from experience, it really is a pain in the ass to do a lot of it - > SO BRITTLE!) At the same, it also seems kind-of necessary. In addition to > the above refactoring problem, there's the question of reliable your > external libraries really are (which you are going out of your way not to > test by using mocks). They are often buggy, often famously so. Having 100:1 > rSpec to code ratio won't save you from IE6 bugs :p Having a > javascript-heavy rails app with lots of IE6 users (not exactly an edge case > with rspec users...) means these bugs are rather important. You can't rely > on rSpec to catch problems before pushing out a new version of your app. > Doesn't this take away one of the main benefits of automated testing? > > Just aside from this whole business - I'm wondering how others are dealing > with this problem? JS unit testing can help, no doubt, but there are lot and > lots of things that can wrong outside such tests, and like I > said, comprehensive unit tests are phenomenally hard to write and maintain. > > So basically all 3 of the above options are pretty crappy. > > One idea I had is to automatically translate > MyObj#should_receive(:method).and_return("value") into a > seprate spec for MyObj but... that actually just defeats the whole purpose > of mock objects in a very round-about way :p > > Another idea is to have a spec runner option which ignores all mocks and > stubs - using the real options instead. This run mode would ONLY be > triggered when someone changes an existing spec, specifically to to answer > the question of "whose code did i just break". However - I think this would > radically change the way specs have to be designed to really work. :/ > > I'm curious to hear how I should deal with these problems. Since i've been > kinda rambly, I'll restate my complaints: > > (Note: when I say rSpec, I actually mean rSpec with heavy use of > mocking, which seems to be the recommended way to go. I am aware that rspec > != mocking, and that most of these complaints are actually more particular > to mocking then rspec, but nevertheless, rspec and mocks do go hand in hand > more often then not:) > > 1) If you change the interface of a function - all rSpec tells you is that > something may have broken (because your existing specs for the function in > question will fail initially). You don't actually know for a fact anything > broke, and you definitely don't know what broke. It's also very easy for > someone new to rSpec to not realize that changing an existing spec may lead > to un-detected failure somewhere else. > > 2) Mocking external libraries and/or access to external applications assumes > these always work as expected, which as we all know, is a dirty lie :p > (handy as it may be). rSpec does not protect you against bugs in the > libraries you're using in any way. > > 3) rSpec + Rails leaves a very size-able javascript and browser blind spot. > No way of dealing with this exists other then integration testing (a-la > selenium), and there is no accepted way of doing integration testing that is > both feasible (i.e. doesn't take for ever) and reliable (i.e. actually > covers a good part of your code). > > > Finally, I really should mention that I'm actually quite happy with rSpec > overall, and yes, I'm aware I'm asking a lot of rSpec here :) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri May 25 08:44:27 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 May 2007 07:44:27 -0500 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> Message-ID: <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> On 5/25/07, Courtenay wrote: > Wow, you did a great job of writing up that irc discussion we had. > > I just had a thought; what about if there was a way of "running" your > mock against the real thing to see if they (still) match up? Aslak had a similar idea a while back: http://rubyforge.org/tracker/?func=detail&group_id=797&aid=5064&atid=3152 I'd like to see something like this - but controllable from the command line. So you can run things as you normally do now, or you can do something like: $ spec spec --mock_mismatch Thing#instance_method (not implemented) - spec/a_spec.rb:37 - spec/b_spec.rb:42 Thing.class_method - spec/c_spec.rb:13 - (argument mismatch: 2 for 1) etc. The goal would be to point you to the right places to look to learn about what needs to change, not to try to decipher the problem in detail beyond the high level. I think this could help assuage some of Ruy's concerns, but not all. Ruy: you stated that concerns are really about mocking, not about RSpec. I'd expand that to say they are about testing in general. You may want to float them on some other lists like testdrivendevelopment at yahoogroups.com and extremeprogramming at yahoogroups.com. The mocking questions could also go to user at jmock.codehaus.org and mocha-developer at rubyforge.org. Advanced apology if this sounds patronizing - but it sounds like you're looking for some sort of silver bullet or "best practice". In my experience, this is a road to disaster for two reasons. One, the "best practice" gets in the way of actually thinking about problems. Two, the acceptance of something as a "best practice" leads to a false sense of security. "If I do this, then all will be right with the world". What's worked for me has been a balance of programmer tests, customer acceptance tests and exploratory testing. RSpec does a good job of facilitating programmer tests, but can also help with acceptance tests when coupled with other tools like selenium or watir (assuming you're doing webapps). Keep in mind that TDD evolved on teams that had employed customer acceptance tests as well as programmer tests. If you're ONLY doing programmer tests, you should probably mock a bit less, or divide your tests up into class-level and integration tests. RSpec's own tests are a good example of this. We don't have a clean separation of these, but if you look through RSpec's examples you'll see some that feel like unit tests, some that feel like integration tests and some that feel like story tests (i.e. customer tests). Hope that helps. Cheers, David > > > Courtenay > > > On 5/24/07, Ruy Asan wrote: > > Suppose we have a method 'foo' which internally uses another method 'bar'. > > > > Being good BDDers we mock out the 'bar' method. After all, we only want to > > spec the 'foo' method - actually running the 'bar' method means slower, less > > maintainable and brittler specs. That's why we <3 mocking, right? > > > > We rely on the fact that 'bar' is being adequately tested somewhere else, by > > whomever wrote it. They can change their implementation of 'bar' and we can > > change our implementation of 'foo' and as long as the existing tests keep > > passing everyone is happy. > > > > But what happens if 'bar' needs to be refactored in a way that changes the > > interface? rSpec does succeed in informing bar's author that he is breaking > > someone's expectations about the 'bar' function - however, he really has no > > idea whose expectations he is breaking. (i.e. rSpec doesn't give us any > > clues about what exactly has to follow our change in interface- it just > > tells us something may be broken). > > > > Changing the interface of bar means going over the code the hard way, > > getting in touch with everyone that uses the 'bar' function and making sure > > everything still works. Not very agile! It makes changing interfaces a very > > very expensive process. Of course, such changes are never really cheap - but > > because of mocks it becomes really REALLY expensive. > > > > So what are our options? > > > > 1) Don't use mocks. Not using mocks would of course catch any such problems > > right away. Yes mocks have benefits, but if we plan on refactoring often, > > the above scenario may just be too high a price to pay. > > > > 2) Don't change interfaces (too often) - i.e. specs should be treated as > > immutable. If it's such an expensive process just make sure it doesn't have > > to happen that often ;) I think if you have an all-vet, all-star team of > > programmers this could work out just fine - but even then, having change be > > expensive just isn't a good thing. Sometimes the app grows in a certain way > > and changing an interface is simply The Right Thing To Do? - but it will > > probably break the app in a hard to fix way so Let's Just Stick With What > > Works? takes over :p > > > > 3) Rely on integration testing to catch these sort of bugs. This too can > > work - although it seems to shift a significant burden on integration > > testing. Doesn't it sort of imply we need 100% (or close to that) > > integration test coverage? Doesn't that mean A LOT of integration testing, > > and aren't integration tests horribly brittle, time consuming to write in > > large numbers and a PITA to maintain? > > > > I'm actually kind of confused about how integration tests fit in with the > > rSpec+Mocks way of doing things. I really don't hear of teams doing regular > > integration testing in a true "let's test all our coupling"-sense. (and > > speaking from experience, it really is a pain in the ass to do a lot of it - > > SO BRITTLE!) At the same, it also seems kind-of necessary. In addition to > > the above refactoring problem, there's the question of reliable your > > external libraries really are (which you are going out of your way not to > > test by using mocks). They are often buggy, often famously so. Having 100:1 > > rSpec to code ratio won't save you from IE6 bugs :p Having a > > javascript-heavy rails app with lots of IE6 users (not exactly an edge case > > with rspec users...) means these bugs are rather important. You can't rely > > on rSpec to catch problems before pushing out a new version of your app. > > Doesn't this take away one of the main benefits of automated testing? > > > > Just aside from this whole business - I'm wondering how others are dealing > > with this problem? JS unit testing can help, no doubt, but there are lot and > > lots of things that can wrong outside such tests, and like I > > said, comprehensive unit tests are phenomenally hard to write and maintain. > > > > So basically all 3 of the above options are pretty crappy. > > > > One idea I had is to automatically translate > > MyObj#should_receive(:method).and_return("value") into a > > seprate spec for MyObj but... that actually just defeats the whole purpose > > of mock objects in a very round-about way :p > > > > Another idea is to have a spec runner option which ignores all mocks and > > stubs - using the real options instead. This run mode would ONLY be > > triggered when someone changes an existing spec, specifically to to answer > > the question of "whose code did i just break". However - I think this would > > radically change the way specs have to be designed to really work. :/ > > > > I'm curious to hear how I should deal with these problems. Since i've been > > kinda rambly, I'll restate my complaints: > > > > (Note: when I say rSpec, I actually mean rSpec with heavy use of > > mocking, which seems to be the recommended way to go. I am aware that rspec > > != mocking, and that most of these complaints are actually more particular > > to mocking then rspec, but nevertheless, rspec and mocks do go hand in hand > > more often then not:) > > > > 1) If you change the interface of a function - all rSpec tells you is that > > something may have broken (because your existing specs for the function in > > question will fail initially). You don't actually know for a fact anything > > broke, and you definitely don't know what broke. It's also very easy for > > someone new to rSpec to not realize that changing an existing spec may lead > > to un-detected failure somewhere else. > > > > 2) Mocking external libraries and/or access to external applications assumes > > these always work as expected, which as we all know, is a dirty lie :p > > (handy as it may be). rSpec does not protect you against bugs in the > > libraries you're using in any way. > > > > 3) rSpec + Rails leaves a very size-able javascript and browser blind spot. > > No way of dealing with this exists other then integration testing (a-la > > selenium), and there is no accepted way of doing integration testing that is > > both feasible (i.e. doesn't take for ever) and reliable (i.e. actually > > covers a good part of your code). > > > > > > Finally, I really should mention that I'm actually quite happy with rSpec > > overall, and yes, I'm aware I'm asking a lot of rSpec here :) > > _______________________________________________ > > 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 May 25 11:07:04 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 May 2007 10:07:04 -0500 Subject: [rspec-users] How to mock helpers in view specs ? In-Reply-To: <41d5fadf0705171246m748f9d93xb538427e5e07a382@mail.gmail.com> References: <41d5fadf0705170744r2bbee2fane65b97043787501e@mail.gmail.com> <9285597E-6870-4D74-85F6-6FB26907F27D@gmail.com> <41d5fadf0705171246m748f9d93xb538427e5e07a382@mail.gmail.com> Message-ID: <57c63afe0705250807u54b64d46id46f87648a23d20e@mail.gmail.com> On 5/17/07, Fran?ois Beausoleil wrote: > Thanks Ruy ! > > 2007/5/17, Ruy Asan : > > AFAIK, you need to stub @controller.template instead > > That's exactly what I needed. Thank you very much. > > There needs to be a mention of this on > http://rspec.rubyforge.org/documentation/rails/writing/views.html There is. Scroll down. > > Bye ! > -- > Fran?ois Beausoleil > http://blog.teksol.info/ > http://piston.rubyforge.org/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jonathan at parkerhill.com Fri May 25 11:21:06 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 25 May 2007 11:21:06 -0400 Subject: [rspec-users] rspec on rails update question Message-ID: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> I'm sure this is OT but I'd appreciate the help I'm using rspec_on_rails I prefer to use stable release rather than live dangerously (at least until I can tell the difference between what I might be doing wrong vs problems in rspec). However, I would like to try the RspecScaffoldGenerator fix. I installed (per the docs) last week with the following commands $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ tags/REL_1_0_0/rspec $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ tags/REL_1_0_0/rspec_on_rails $ script/generate rspec Should I have said REL_1_0_2 instead? Will svn up find the latest tags? When I run $ svn up vendor/plugins/rspec At revision 2032. $ svn up vendor/plugins/rspec_on_rails At revision 2032. How can i tell which version is actually installed on my system now? perhaps I don't know svn well enough to identify the tags I would like 1.0.3, its listed under http://rspec.rubyforge.org/ changes.html but tags/REL_1_0_3 doesn't seem to exist yet, right? It tried $ ruby script/plugin install -x --force svn://rubyforge.org/var/ svn/rspec/tags/REL_1_0_3/rspec svn: URL 'svn://rubyforge.org/var/svn/rspec/tags/REL_1_0_3/rspec' doesn't exist Is that the way to upgrade? thanks linoj From jonathan at parkerhill.com Fri May 25 11:28:19 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 25 May 2007 11:28:19 -0400 Subject: [rspec-users] rspec on rails update question In-Reply-To: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> References: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> Message-ID: i also tried $ script/plugin update rspec Updating plugin: rspec $ script/plugin update rspec_on_rails Updating plugin: rspec_on_rails but neither seemed to download anything On May 25, 2007, at 11:21 AM, Jonathan Linowes wrote: > I'm sure this is OT but I'd appreciate the help > > I'm using rspec_on_rails > > I prefer to use stable release rather than live dangerously (at least > until I can tell the difference between what I might be doing wrong > vs problems in rspec). However, I would like to try the > RspecScaffoldGenerator fix. > > I installed (per the docs) last week with the following commands > > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > tags/REL_1_0_0/rspec > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > tags/REL_1_0_0/rspec_on_rails > $ script/generate rspec > > Should I have said REL_1_0_2 instead? Will svn up find the latest > tags? > > When I run > $ svn up vendor/plugins/rspec > At revision 2032. > $ svn up vendor/plugins/rspec_on_rails > At revision 2032. > > How can i tell which version is actually installed on my system now? > perhaps I don't know svn well enough to identify the tags > > I would like 1.0.3, its listed under http://rspec.rubyforge.org/ > changes.html but tags/REL_1_0_3 doesn't seem to exist yet, right? It > tried > > $ ruby script/plugin install -x --force svn://rubyforge.org/var/ > svn/rspec/tags/REL_1_0_3/rspec > svn: URL 'svn://rubyforge.org/var/svn/rspec/tags/REL_1_0_3/rspec' > doesn't exist > > Is that the way to upgrade? > > thanks > linoj > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri May 25 11:32:15 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 May 2007 10:32:15 -0500 Subject: [rspec-users] rspec on rails update question In-Reply-To: References: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> Message-ID: <57c63afe0705250832u55a1c7f3k7e3fcd1f8a73fd7e@mail.gmail.com> On 5/25/07, Jonathan Linowes wrote: > i also tried > $ script/plugin update rspec > Updating plugin: rspec > $ script/plugin update rspec_on_rails > Updating plugin: rspec_on_rails > > but neither seemed to download anything Not if you installed from a tag. Ideally, you should NEVER see any updates under a tag. Tags are permanent snapshots. > > > On May 25, 2007, at 11:21 AM, Jonathan Linowes wrote: > > > I'm sure this is OT but I'd appreciate the help > > > > I'm using rspec_on_rails > > > > I prefer to use stable release rather than live dangerously (at least > > until I can tell the difference between what I might be doing wrong > > vs problems in rspec). However, I would like to try the > > RspecScaffoldGenerator fix. > > > > I installed (per the docs) last week with the following commands > > > > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > > tags/REL_1_0_0/rspec > > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > > tags/REL_1_0_0/rspec_on_rails > > $ script/generate rspec > > > > Should I have said REL_1_0_2 instead? Will svn up find the latest > > tags? > > > > When I run > > $ svn up vendor/plugins/rspec > > At revision 2032. > > $ svn up vendor/plugins/rspec_on_rails > > At revision 2032. > > > > How can i tell which version is actually installed on my system now? > > perhaps I don't know svn well enough to identify the tags > > > > I would like 1.0.3, its listed under http://rspec.rubyforge.org/ > > changes.html but tags/REL_1_0_3 doesn't seem to exist yet, right? It > > tried > > > > $ ruby script/plugin install -x --force svn://rubyforge.org/var/ > > svn/rspec/tags/REL_1_0_3/rspec > > svn: URL 'svn://rubyforge.org/var/svn/rspec/tags/REL_1_0_3/rspec' > > doesn't exist > > > > Is that the way to upgrade? > > > > thanks > > linoj > > > > > > _______________________________________________ > > 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 May 25 11:27:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 May 2007 10:27:17 -0500 Subject: [rspec-users] rspec on rails update question In-Reply-To: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> References: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> Message-ID: <57c63afe0705250827o4cadbad6lf631a26c242245f1@mail.gmail.com> On 5/25/07, Jonathan Linowes wrote: > I'm sure this is OT but I'd appreciate the help Very ON Topic - no worries. > > I'm using rspec_on_rails > > I prefer to use stable release rather than live dangerously (at least > until I can tell the difference between what I might be doing wrong > vs problems in rspec). However, I would like to try the > RspecScaffoldGenerator fix. > > I installed (per the docs) last week with the following commands > > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > tags/REL_1_0_0/rspec > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > tags/REL_1_0_0/rspec_on_rails > $ script/generate rspec > > Should I have said REL_1_0_2 instead? Will svn up find the latest tags? We just added tags/CURRENT, so from now on you can grab that and use svn up to update releases. > > When I run > $ svn up vendor/plugins/rspec > At revision 2032. > $ svn up vendor/plugins/rspec_on_rails > At revision 2032. > > How can i tell which version is actually installed on my system now? > perhaps I don't know svn well enough to identify the tags Look in vendor/plugins/rspec/lib/spec/version.rb > > I would like 1.0.3, its listed under http://rspec.rubyforge.org/ > changes.html but tags/REL_1_0_3 doesn't seem to exist yet, right? It > tried That was a mistake, but 1.0.3 will be out shortly (maybe even today). > > $ ruby script/plugin install -x --force svn://rubyforge.org/var/ > svn/rspec/tags/REL_1_0_3/rspec > svn: URL 'svn://rubyforge.org/var/svn/rspec/tags/REL_1_0_3/rspec' > doesn't exist ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails Cheers, David > > Is that the way to upgrade? > > thanks > linoj > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri May 25 11:35:11 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 25 May 2007 17:35:11 +0200 Subject: [rspec-users] rspec on rails update question In-Reply-To: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> References: <71FE6BC4-19EB-45DD-A6A5-F0AB9927D5E3@parkerhill.com> Message-ID: <8d961d900705250835w12661965gf9195aeca17eb133@mail.gmail.com> On 5/25/07, Jonathan Linowes wrote: > I'm sure this is OT but I'd appreciate the help > > I'm using rspec_on_rails > > I prefer to use stable release rather than live dangerously (at least > until I can tell the difference between what I might be doing wrong > vs problems in rspec). However, I would like to try the > RspecScaffoldGenerator fix. > > I installed (per the docs) last week with the following commands > > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > tags/REL_1_0_0/rspec > $ ruby script/plugin install -x svn://rubyforge.org/var/svn/rspec/ > tags/REL_1_0_0/rspec_on_rails > $ script/generate rspec > > Should I have said REL_1_0_2 instead? Will svn up find the latest tags? > REL_* tags will never move. However, you can get the CURRENT tag (new as of today), which will always give you the latest release. Sort of like trunk, but you won't get the unstable bits between each release. > When I run > $ svn up vendor/plugins/rspec > At revision 2032. > $ svn up vendor/plugins/rspec_on_rails > At revision 2032. > > How can i tell which version is actually installed on my system now? After you do an svn up, you must rebootstrap rspec: script/generate rspec Now: ruby script/spec -v ..will tell you the current RSpec version - as well as the svn revision. > perhaps I don't know svn well enough to identify the tags > stand in the plugin and do svn info. you should get the same revision info as script/spec -v > I would like 1.0.3, its listed under http://rspec.rubyforge.org/ > changes.html but tags/REL_1_0_3 doesn't seem to exist yet, right? 1.0.3 is not released yet. The changes file has info on what's coming because we sometimes upload the web site between releases. > It > tried > > $ ruby script/plugin install -x --force svn://rubyforge.org/var/ > svn/rspec/tags/REL_1_0_3/rspec > svn: URL 'svn://rubyforge.org/var/svn/rspec/tags/REL_1_0_3/rspec' > doesn't exist > > Is that the way to upgrade? > I think so. Aslak > thanks > linoj > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From anthony at digitalphenom.com Fri May 25 11:54:03 2007 From: anthony at digitalphenom.com (Anthony Carlos) Date: Fri, 25 May 2007 11:54:03 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> Message-ID: <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> Hey everyone: I found more information about its_should_behave_like on the documentation index page (duh!). The example shows how a behavior is factored out and put into its own describe block. However, that behavior is still within the same file. I think my problems stem from the fact that I'm using Rails and the ApplicationController is its own separate file. I want to figure out where specs for ApplicationController are supposed to live, and how to call them. Here's what I've tried: Created /spec/controllers/application_controller_spec.rb: require File.dirname(__FILE__) + '/../spec_helper' describe "All controllers", :shared => true do it "should respond to authenticate" do controller.should respond_to(:authenticate) end it "should respond to current_user" do controller.should respond_to(:current_user) end end Created /spec/controllers/concrete_controller_spec.rb: require File.dirname(__FILE__) + '/../spec_helper' describe ConcreteController do it_should_behave_like "All controllers" end Then, I ran rake spec:autotest, and got the following output: ConcreteController - should respond to current_user - should respond to authenticate But, if I update and save concrete_controller_spec.rb, autotest tries to run that spec on its own and I get "Shared Behaviour 'All controllers' can not be found (RuntimeError)". So, I added a conditional require statement at the top of concrete_controller_spec.rb: require File.dirname(__FILE__) + '/application_controller_spec' unless Spec::DSL::Behaviour.find_shared_behaviour("All controllers") That got rid of the Shared Behaviour can not be found error. Is this a suitable workaround, or is it too dodgy? So, things are peachy except that I'm only checking that all controllers respond to certain methods. I want to test the logic of these methods, so I added the following example to my All Controllers behavior: it "should flash notice when session[:current_user_id] does not exist" do session[:current_user_id] = nil controller.authenticate flash[:notice].should == 'Please login.' end My problem now, is that I get a nil object error. Specifically, in application.rb, I'm trying to call request.parameters and request is nil. It seems that request is not part of the context anymore since I moved the behavior out to a separate file. How do I regain access to request, response, assigns, flash, and session? Thanks for your help! -Anthony On May 24, 2007, at 3:16 PM, Anthony Carlos wrote: > Tim: > > I'm sorry, but I'm a newbie and I don't fully understand. Could you > please give me more details? > > 1. Is the slightly dodgy way completely separate from using a shared > spec? > 2. What is the appropriate file path and name for your first example > regarding a shared spec? Is it RAILS_ROOT/spec/controllers/ > all_controllers_spec.rb? > 3. Does the event controller spec belong in RAILS_ROOT/spec/ > controllers/event_controller_spec.rb? > 4. How do you actually fire off the test? Do I have to call get or > post inside a do-end block that is attached to it_should_behave_like > "All controllers"? > > e.g., > > describe EventController do > it_should_behave_like "All controllers" do > get 'event1' # just an example action > end > end > > 5. Is there any further documentation on it_should_behave_like other > than the RDoc? It doesn't really say too much. > > Thanks for your help! > > -Anthony > > On May 24, 2007, at 3:18 AM, Tim Lucas wrote: > >> On 24/05/2007, at 5:00 PM, Wincent Colaiuta wrote: >> >>> The Rails ApplicationController (app/controllers/application.rb) >>> serves as an abstract superclass for all other controllers in a >>> Rails >>> application and is a good place to put methods and filters which you >>> want all of your controllers to use. In my case I'm using it to >>> provide methods such as "current_user" and "logged_in?" etc. >>> >>> By default, RSpec doesn't produce a corresponding spec file for this >>> controller. >>> >>> I've made a spec file (spec/controllers/application_spec.rb) so that >>> I can test these methods, but I'm not sure if this is the right >>> thing >>> to do. Should I be testing only the non-abstract subclasses instead? >> >> I did it a slighty dodgy way (spec/controllers/ >> application_controller_spec.rb): >> http://pastie.caboo.se/64123 >> >> but nowadays you can probably use a shared spec, like so (require'd >> from your spec helper): >> >> describe "All controllers", :shared => true do >> it "should redirect to HQ if no subdomains specified" do >> ... >> end >> end >> >> and then: >> >> describe EventController do >> it_should_behave_like "All controllers" >> ... >> end >> >> Not sure how you'd deal with something like skip_before_filter >> though... >> >> -- tim >> >> _______________________________________________ >> 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 May 25 16:49:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 May 2007 15:49:13 -0500 Subject: [rspec-users] [ANN] RSpec-1.0.3 Message-ID: <57c63afe0705251349l6f83b574sa5cc43fd0abba4f6@mail.gmail.com> The RSpec Development Team is pleased to announce the release of RSpec-1.0.3. == Changes This is the compatibility release! * Compatible with autotest!!!! (As of ZenTest 3.6.0 - see below) * Compatible with edge rails (as of r6825). * Compatible with jruby (since release 1.0.1) See http://rspec.rubyforge.org/changes.html for more detail. == About RSpec RSpec is a framework which provides programmers with a Domain Specific Language to describe the behaviour of Ruby code with readable, executable examples that guide you in the design process and serve well as both documentation and tests. == Autotest compatibility ZenTest-3.6.0 boasts a new autodiscovery and plugin model that other frameworks can register with and plug into. RSpec-1.0.3 ships with the necessary plugin code, so all you need to do is download and go: For Rails apps: gem install ZenTest --version '>= 3.6.0' rails myproject cd myproject ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails script/generate rspec autotest ... and off you go For a non-rails app, you'll need to follow the convention of parallel lib and spec directories. For example: gem install ZenTest --version '>= 3.6.0' gem install rspec --version '>= 1.0.3' mkdir stuff cd stuff mkdir lib mkdir spec autotest Enjoy! From pergesu at gmail.com Fri May 25 17:31:26 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 25 May 2007 15:31:26 -0600 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> Message-ID: <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> This is something I've kind of struggled with over the past few months [1]. And just yesterday I made the decision to move away from mocks in most cases. That decision resulted from me changing a db column name from 'user' to 'username', but one of my tests mocked a #find_by_user method, so the test passed even though my code was broken. Just to note, I've got ~7k lines of Rails spec code that uses mocks, and tens of thousands that don't. So I've used both approaches extensively in multiple projects, and have formed the following ideas. I think David has a really good point about mock usage being related to customer/programmer test coverage. At this point, we don't have any customer tests. I also don't like the idea of relying on heavyweight browser-based tests. I want to be able to run rake and know that my code works. Over the past week, I've converted a number of my controller tests to use the real implementations instead of using mocks. It was obvious when I realized that in my controllers I'm concerned with state a lot more than interaction - a request is made, some state changes, a response is given. I want my tests to prove that those state changes are actually being made. In this way, my controller specs act as integration tests. I do a *tiny* bit of mocking in controller specs, in cases where I can't verify state such as making some notification request to another machine in the system. I'm still using mocks quite a bit in my model specs, and I'm not quite sure if I'll be cutting back or not. Just going to take it a day at a time and try to remove any pain. You've all surely read Martin Fowler's discussion about interaction-based vs state-based testing. One of the points Dave Astels always hammers on about BDD and interaction-based testing is that it's not testing, it's a design tool. I've found that with mocks I tend to arrive at a better design earlier on than I do without mocks. I've also found that I can't change the design very easily. Mocks are coupled to the design of the code, not the behavior. Aslak says that state-based testing ain't BDD [3], but I disagree. If I can't refactor - changing the design of the code without changing the behavior - that doesn't seem very behavior-driven to me. Mocks are nice as a design tool, but I've come to accept the fact that creating a moderately good design early isn't as useful as having the freedom to change my design later on. I'm just not good enough to come up with the perfect design the first time around. My tests need to give me the confidence to refactor. And I need to be able to run those tests quickly from the command line rather than having to start up a browser, even if it's automated. In that regard, mocks just aren't for me, at least on my current project. Sorry for the length. pat.should be_less_verbose Pat [1] http://evang.eli.st/blog/2007/4/9/i-think-i-might-not-get-mocks [2] http://www.martinfowler.com/articles/mocksArentStubs.html [3] http://blog.aslakhellesoy.com/2006/12/11/the-bdd-cargo-cult (for some reason it doesn't feel right to link to my blog and MF's bliki together :) From dchelimsky at gmail.com Fri May 25 18:08:24 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 25 May 2007 17:08:24 -0500 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> Message-ID: <57c63afe0705251508s46395026hd24731650c051541@mail.gmail.com> On 5/25/07, Pat Maddox wrote: > This is something I've kind of struggled with over the past few months > [1]. And just yesterday I made the decision to move away from mocks > in most cases. That decision resulted from me changing a db column > name from 'user' to 'username', but one of my tests mocked a > #find_by_user method, so the test passed even though my code was > broken. > > Just to note, I've got ~7k lines of Rails spec code that uses mocks, > and tens of thousands that don't. So I've used both approaches > extensively in multiple projects, and have formed the following ideas. > > I think David has a really good point about mock usage being related > to customer/programmer test coverage. At this point, we don't have > any customer tests. I also don't like the idea of relying on > heavyweight browser-based tests. I want to be able to run rake and > know that my code works. > > Over the past week, I've converted a number of my controller tests to > use the real implementations instead of using mocks. It was obvious > when I realized that in my controllers I'm concerned with state a lot > more than interaction - a request is made, some state changes, a > response is given. I want my tests to prove that those state changes > are actually being made. In this way, my controller specs act as > integration tests. I do a *tiny* bit of mocking in controller specs, > in cases where I can't verify state such as making some notification > request to another machine in the system. > > I'm still using mocks quite a bit in my model specs, and I'm not quite > sure if I'll be cutting back or not. Just going to take it a day at a > time and try to remove any pain. > > You've all surely read Martin Fowler's discussion about > interaction-based vs state-based testing. One of the points Dave > Astels always hammers on about BDD and interaction-based testing is > that it's not testing, it's a design tool. I've found that with mocks > I tend to arrive at a better design earlier on than I do without > mocks. I've also found that I can't change the design very easily. > Mocks are coupled to the design of the code, not the behavior. Aslak > says that state-based testing ain't BDD [3], but I disagree. If I > can't refactor - changing the design of the code without changing the > behavior - that doesn't seem very behavior-driven to me. > > Mocks are nice as a design tool, but I've come to accept the fact that > creating a moderately good design early isn't as useful as having the > freedom to change my design later on. I'm just not good enough to > come up with the perfect design the first time around. My tests need > to give me the confidence to refactor. And I need to be able to run > those tests quickly from the command line rather than having to start > up a browser, even if it's automated. In that regard, mocks just > aren't for me, at least on my current project. One thing about TDD and the notion of a "design tool" - it's an ongoing process. If you want to end up w/ real models in your specs, you can still use mocks to figure out what they should do, then replace them w/ the real deal later. This is not nearly as expensive as it sounds, and lets you focus on one thing at a time. As for integration testing, what I've found w/ Rails is that if you do a couple of happy paths with rails built-in integration tests, you'll expose the refactoring problems that are raising such concern in this thread. For me, that's a win because you don't have to do the expensive in-browser stuff, everything's in Ruby, you still can use mocks to keep the isolation level stuff quick, and you run the slow integration tests before you commit. As for mocks tying you to implementation - I see a strong relationship to how well you follow "Tell, Don't Ask" and the value you get out of mocking. If you're doing a lot telling instead of asking, you have an implicitly more loosely coupled design. But if you want to make sure that the object being described does the telling, there's no better way to do that then with a mock in my view. 2 more cents. David > > Sorry for the length. pat.should be_less_verbose > > Pat > > [1] http://evang.eli.st/blog/2007/4/9/i-think-i-might-not-get-mocks > [2] http://www.martinfowler.com/articles/mocksArentStubs.html > [3] http://blog.aslakhellesoy.com/2006/12/11/the-bdd-cargo-cult > > (for some reason it doesn't feel right to link to my blog and MF's > bliki together :) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From court3nay at gmail.com Fri May 25 18:14:40 2007 From: court3nay at gmail.com (Courtenay) Date: Fri, 25 May 2007 15:14:40 -0700 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> Message-ID: <4b430c8f0705251514y4c9724a6p3ee5af6b71510be@mail.gmail.com> Pat, I use rails' integration tests to test my whole app. Usually I get lazy, and just dump my production data into the test DB and tell my SpiderTest to just spider every single page and tell me what broke. Also, I try to hide my database code behind methods, so 'find_by_user' would forever remain as a method and whatever DB code will always be hidden there. To the controller, the actual fields I'm using are irrelevant. When starting a new project I'll try hard to define a nice uncoupled interface between models and controllers. It's like, when you assume that the model's public methods will never change, you name them a bit differently. I'm not much of a theorist, though, and much prefer to let others kick it out and wait for the dust to settle. On 5/25/07, Pat Maddox wrote: > This is something I've kind of struggled with over the past few months > [1]. And just yesterday I made the decision to move away from mocks > in most cases. That decision resulted from me changing a db column > name from 'user' to 'username', but one of my tests mocked a > #find_by_user method, so the test passed even though my code was > broken. > > Just to note, I've got ~7k lines of Rails spec code that uses mocks, > and tens of thousands that don't. So I've used both approaches > extensively in multiple projects, and have formed the following ideas. > > I think David has a really good point about mock usage being related > to customer/programmer test coverage. At this point, we don't have > any customer tests. I also don't like the idea of relying on > heavyweight browser-based tests. I want to be able to run rake and > know that my code works. > > Over the past week, I've converted a number of my controller tests to > use the real implementations instead of using mocks. It was obvious > when I realized that in my controllers I'm concerned with state a lot > more than interaction - a request is made, some state changes, a > response is given. I want my tests to prove that those state changes > are actually being made. In this way, my controller specs act as > integration tests. I do a *tiny* bit of mocking in controller specs, > in cases where I can't verify state such as making some notification > request to another machine in the system. > > I'm still using mocks quite a bit in my model specs, and I'm not quite > sure if I'll be cutting back or not. Just going to take it a day at a > time and try to remove any pain. > > You've all surely read Martin Fowler's discussion about > interaction-based vs state-based testing. One of the points Dave > Astels always hammers on about BDD and interaction-based testing is > that it's not testing, it's a design tool. I've found that with mocks > I tend to arrive at a better design earlier on than I do without > mocks. I've also found that I can't change the design very easily. > Mocks are coupled to the design of the code, not the behavior. Aslak > says that state-based testing ain't BDD [3], but I disagree. If I > can't refactor - changing the design of the code without changing the > behavior - that doesn't seem very behavior-driven to me. > > Mocks are nice as a design tool, but I've come to accept the fact that > creating a moderately good design early isn't as useful as having the > freedom to change my design later on. I'm just not good enough to > come up with the perfect design the first time around. My tests need > to give me the confidence to refactor. And I need to be able to run > those tests quickly from the command line rather than having to start > up a browser, even if it's automated. In that regard, mocks just > aren't for me, at least on my current project. > > Sorry for the length. pat.should be_less_verbose > > Pat > > [1] http://evang.eli.st/blog/2007/4/9/i-think-i-might-not-get-mocks > [2] http://www.martinfowler.com/articles/mocksArentStubs.html > [3] http://blog.aslakhellesoy.com/2006/12/11/the-bdd-cargo-cult > > (for some reason it doesn't feel right to link to my blog and MF's > bliki together :) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From court3nay at gmail.com Fri May 25 18:23:46 2007 From: court3nay at gmail.com (Courtenay) Date: Fri, 25 May 2007 15:23:46 -0700 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <57c63afe0705251508s46395026hd24731650c051541@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> <57c63afe0705251508s46395026hd24731650c051541@mail.gmail.com> Message-ID: <4b430c8f0705251523m4538a90akf234b9f9dd4091af@mail.gmail.com> On 5/25/07, David Chelimsky wrote: > > As for mocks tying you to implementation - I see a strong relationship > to how well you follow "Tell, Don't Ask" and the value you get out of > mocking. If you're doing a lot telling instead of asking, you have an > implicitly more loosely coupled design. But if you want to make sure > that the object being described does the telling, there's no better > way to do that then with a mock in my view. > David, Pat, Ruy: I think this is a failure of Rails for letting us talk to the DB from our controllers. For example def show @user = User.find(:first, :conditions => { :id => params[:id] }, :include => :images) end This kind of thinking then pervades throughout the entire 'rails way' of doing things. This makes it hard to refactor, and just horrible to mock. I can never think up a catchy name for this, (i'll use find_inclusive for now) but ... def show @user = User.find_inclusive( params[:id] ) end This works on the idea that, "What if 'find' were a private method?" Now we can mock User.find_inclusive in the controller spec; we can refactor the entire user model, change the database implementation (:include something else) and, in an extreme case, you only give an external coder access to particular models knowing that other code wouldn't be touched (yes, I've done this in the past. Yuk.) Now, on a large or distributed team, hell.. any size team.. if someone goes and changes find_inclusive, and the user-model spec breaks, they are responsible for ensuring that the failing spec is NOT altered; rather, that their code respects the old API and the spec passes, in addition to their fixes. Finally, higher-level tests (whether selenium or rails' integrations) will help you test the whole stack; I still don't believe that controllers should_hit the db :) courtenay From pergesu at gmail.com Fri May 25 18:33:30 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 25 May 2007 16:33:30 -0600 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <57c63afe0705251508s46395026hd24731650c051541@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> <57c63afe0705251508s46395026hd24731650c051541@mail.gmail.com> Message-ID: <810a540e0705251533v1ecb41eco894ef823389a6b3c@mail.gmail.com> On 5/25/07, David Chelimsky wrote: > On 5/25/07, Pat Maddox wrote: > > This is something I've kind of struggled with over the past few months > > [1]. And just yesterday I made the decision to move away from mocks > > in most cases. That decision resulted from me changing a db column > > name from 'user' to 'username', but one of my tests mocked a > > #find_by_user method, so the test passed even though my code was > > broken. > > > > Just to note, I've got ~7k lines of Rails spec code that uses mocks, > > and tens of thousands that don't. So I've used both approaches > > extensively in multiple projects, and have formed the following ideas. > > > > I think David has a really good point about mock usage being related > > to customer/programmer test coverage. At this point, we don't have > > any customer tests. I also don't like the idea of relying on > > heavyweight browser-based tests. I want to be able to run rake and > > know that my code works. > > > > Over the past week, I've converted a number of my controller tests to > > use the real implementations instead of using mocks. It was obvious > > when I realized that in my controllers I'm concerned with state a lot > > more than interaction - a request is made, some state changes, a > > response is given. I want my tests to prove that those state changes > > are actually being made. In this way, my controller specs act as > > integration tests. I do a *tiny* bit of mocking in controller specs, > > in cases where I can't verify state such as making some notification > > request to another machine in the system. > > > > I'm still using mocks quite a bit in my model specs, and I'm not quite > > sure if I'll be cutting back or not. Just going to take it a day at a > > time and try to remove any pain. > > > > You've all surely read Martin Fowler's discussion about > > interaction-based vs state-based testing. One of the points Dave > > Astels always hammers on about BDD and interaction-based testing is > > that it's not testing, it's a design tool. I've found that with mocks > > I tend to arrive at a better design earlier on than I do without > > mocks. I've also found that I can't change the design very easily. > > Mocks are coupled to the design of the code, not the behavior. Aslak > > says that state-based testing ain't BDD [3], but I disagree. If I > > can't refactor - changing the design of the code without changing the > > behavior - that doesn't seem very behavior-driven to me. > > > > Mocks are nice as a design tool, but I've come to accept the fact that > > creating a moderately good design early isn't as useful as having the > > freedom to change my design later on. I'm just not good enough to > > come up with the perfect design the first time around. My tests need > > to give me the confidence to refactor. And I need to be able to run > > those tests quickly from the command line rather than having to start > > up a browser, even if it's automated. In that regard, mocks just > > aren't for me, at least on my current project. > > One thing about TDD and the notion of a "design tool" - it's an > ongoing process. If you want to end up w/ real models in your specs, > you can still use mocks to figure out what they should do, then > replace them w/ the real deal later. This is not nearly as expensive > as it sounds, and lets you focus on one thing at a time. I've considered that as well, and it's an attractive approach that I plan to try soon. > As for integration testing, what I've found w/ Rails is that if you do > a couple of happy paths with rails built-in integration tests, you'll > expose the refactoring problems that are raising such concern in this > thread. For me, that's a win because you don't have to do the > expensive in-browser stuff, everything's in Ruby, you still can use > mocks to keep the isolation level stuff quick, and you run the slow > integration tests before you commit. I've yet to get major benefits from the integration tests. I realize that it's nice to codify user stories, but so far it hasn't been nice enough that I care very much. I'm okay with the "user adds an item to car, user checks out" being split into separate controller tests. If they both pass, I'm satisfied that my code works. I don't think that integration tests are inherently bad, just that they don't provide enough value (to me) over standard controller tests, given the real downside of slowness. > As for mocks tying you to implementation - I see a strong relationship > to how well you follow "Tell, Don't Ask" and the value you get out of > mocking. If you're doing a lot telling instead of asking, you have an > implicitly more loosely coupled design. But if you want to make sure > that the object being described does the telling, there's no better > way to do that then with a mock in my view. I absolutely agree. I didn't really get into this, but my model specs use mocks quite a bit. And that's good, because if I use mocks then it means I'm far more likely to write better OO code. After all, if I'm doing a good job of "tell, don't ask" then there shouldn't be too much state to verify. So I guess I can summarize my first post as saying that I prefer to use controller specs as very lightweight integration tests. In that regard, I should be using real implementations where possible and verifying the modified state of the system. Pat > 2 more cents. > > David > > > > > Sorry for the length. pat.should be_less_verbose > > > > Pat > > > > [1] http://evang.eli.st/blog/2007/4/9/i-think-i-might-not-get-mocks > > [2] http://www.martinfowler.com/articles/mocksArentStubs.html > > [3] http://blog.aslakhellesoy.com/2006/12/11/the-bdd-cargo-cult > > > > (for some reason it doesn't feel right to link to my blog and MF's > > bliki together :) > > _______________________________________________ > > 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 pergesu at gmail.com Fri May 25 18:38:02 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 25 May 2007 16:38:02 -0600 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <4b430c8f0705251514y4c9724a6p3ee5af6b71510be@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> <4b430c8f0705251514y4c9724a6p3ee5af6b71510be@mail.gmail.com> Message-ID: <810a540e0705251538v35f63a22n3fe28b545067bd7f@mail.gmail.com> On 5/25/07, Courtenay wrote: > Pat, I use rails' integration tests to test my whole app. Usually I > get lazy, and just dump my production data into the test DB and tell > my SpiderTest to just spider every single page and tell me what broke. That's cool. I discussed what I think of the integration tests in my response to David. I'd be really interested to know if I'm missing key benefits though. > Also, I try to hide my database code behind methods, so 'find_by_user' > would forever remain as a method and whatever DB code will always be > hidden there. To the controller, the actual fields I'm using are > irrelevant. When starting a new project I'll try hard to define a > nice uncoupled interface between models and controllers. It's like, > when you assume that the model's public methods will never change, you > name them a bit differently. Totally. I did end up just writing a find_by_user method that delegated to find_by_username, so I didn't have to change any of my application code. My concern though was that I didn't know it broke in the first place because I was using mocks. But you're right, had I just written and tested find_by_user method instead of using the dynamic finder, I wouldn't have run into that issue. I'll be sure to keep that in mind. It goes along with "don't mock APIs you don't own," and I certainly don't own the dynamic finders. Pat > > I'm not much of a theorist, though, and much prefer to let others kick > it out and wait for the dust to settle. > > > > On 5/25/07, Pat Maddox wrote: > > This is something I've kind of struggled with over the past few months > > [1]. And just yesterday I made the decision to move away from mocks > > in most cases. That decision resulted from me changing a db column > > name from 'user' to 'username', but one of my tests mocked a > > #find_by_user method, so the test passed even though my code was > > broken. > > > > Just to note, I've got ~7k lines of Rails spec code that uses mocks, > > and tens of thousands that don't. So I've used both approaches > > extensively in multiple projects, and have formed the following ideas. > > > > I think David has a really good point about mock usage being related > > to customer/programmer test coverage. At this point, we don't have > > any customer tests. I also don't like the idea of relying on > > heavyweight browser-based tests. I want to be able to run rake and > > know that my code works. > > > > Over the past week, I've converted a number of my controller tests to > > use the real implementations instead of using mocks. It was obvious > > when I realized that in my controllers I'm concerned with state a lot > > more than interaction - a request is made, some state changes, a > > response is given. I want my tests to prove that those state changes > > are actually being made. In this way, my controller specs act as > > integration tests. I do a *tiny* bit of mocking in controller specs, > > in cases where I can't verify state such as making some notification > > request to another machine in the system. > > > > I'm still using mocks quite a bit in my model specs, and I'm not quite > > sure if I'll be cutting back or not. Just going to take it a day at a > > time and try to remove any pain. > > > > You've all surely read Martin Fowler's discussion about > > interaction-based vs state-based testing. One of the points Dave > > Astels always hammers on about BDD and interaction-based testing is > > that it's not testing, it's a design tool. I've found that with mocks > > I tend to arrive at a better design earlier on than I do without > > mocks. I've also found that I can't change the design very easily. > > Mocks are coupled to the design of the code, not the behavior. Aslak > > says that state-based testing ain't BDD [3], but I disagree. If I > > can't refactor - changing the design of the code without changing the > > behavior - that doesn't seem very behavior-driven to me. > > > > Mocks are nice as a design tool, but I've come to accept the fact that > > creating a moderately good design early isn't as useful as having the > > freedom to change my design later on. I'm just not good enough to > > come up with the perfect design the first time around. My tests need > > to give me the confidence to refactor. And I need to be able to run > > those tests quickly from the command line rather than having to start > > up a browser, even if it's automated. In that regard, mocks just > > aren't for me, at least on my current project. > > > > Sorry for the length. pat.should be_less_verbose > > > > Pat > > > > [1] http://evang.eli.st/blog/2007/4/9/i-think-i-might-not-get-mocks > > [2] http://www.martinfowler.com/articles/mocksArentStubs.html > > [3] http://blog.aslakhellesoy.com/2006/12/11/the-bdd-cargo-cult > > > > (for some reason it doesn't feel right to link to my blog and MF's > > bliki together :) > > _______________________________________________ > > 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 pergesu at gmail.com Fri May 25 18:49:22 2007 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 25 May 2007 16:49:22 -0600 Subject: [rspec-users] Mocking, changing method interfaces and integration tests In-Reply-To: <4b430c8f0705251523m4538a90akf234b9f9dd4091af@mail.gmail.com> References: <980C6C4F-0B83-443D-B41D-C55D82D24B2A@gmail.com> <4b430c8f0705250318k35d9500cr7cd72c369c8b556d@mail.gmail.com> <57c63afe0705250544l3146d6abpfce111072ece246b@mail.gmail.com> <810a540e0705251431y3bb8e554kfa1658420102842@mail.gmail.com> <57c63afe0705251508s46395026hd24731650c051541@mail.gmail.com> <4b430c8f0705251523m4538a90akf234b9f9dd4091af@mail.gmail.com> Message-ID: <810a540e0705251549h71ef084ayee4e9df1cf04f78d@mail.gmail.com> On 5/25/07, Courtenay wrote: > On 5/25/07, David Chelimsky wrote: > > > > As for mocks tying you to implementation - I see a strong relationship > > to how well you follow "Tell, Don't Ask" and the value you get out of > > mocking. If you're doing a lot telling instead of asking, you have an > > implicitly more loosely coupled design. But if you want to make sure > > that the object being described does the telling, there's no better > > way to do that then with a mock in my view. > > > > David, Pat, Ruy: > > I think this is a failure of Rails for letting us talk to the DB from > our controllers. For example > > def show > @user = User.find(:first, :conditions => { :id => params[:id] }, > :include => :images) > end > > This kind of thinking then pervades throughout the entire 'rails way' > of doing things. > > This makes it hard to refactor, and just horrible to mock. Yeah, I think that sucks. I think I made a post about it a while back regarding how to spec it. it "should find the user, including associated images" do User.should receive(:find).with(:conditions => { :id => params[:id] }, :include => :images).and_return @mock_user do_get end Ummm..............no > I can > never think up a catchy name for this, (i'll use find_inclusive for > now) but ... > > def show > @user = User.find_inclusive( params[:id] ) > end What about User.find_with_images or User.find_and_include_images > This works on the idea that, "What if 'find' were a private method?" > > Now we can mock User.find_inclusive in the controller spec; we can > refactor the entire user model, change the database implementation > (:include something else) and, in an extreme case, you only give an > external coder access to particular models knowing that other code > wouldn't be touched (yes, I've done this in the past. Yuk.) > > Now, on a large or distributed team, hell.. any size team.. if someone > goes and changes find_inclusive, and the user-model spec breaks, they > are responsible for ensuring that the failing spec is NOT altered; > rather, that their code respects the old API and the spec passes, in > addition to their fixes. > > Finally, higher-level tests (whether selenium or rails' integrations) > will help you test the whole stack; I still don't believe that > controllers should_hit the db :) The situation that really burned me, and led to me hitting the db from controller tests, is one in which I was creating several related objects. I'd create a company, and that company had a before_create method that created a site for it. A Site would need to create its own settings. In the model specs, each level worked fine (I only tested creating an object and the child object, not all the way down). But in production, foreign keys in the child objects just weren't being set. My code didn't work even though my specs said it did. Of course that's because my specs just weren't good enough, but if I had integration tests (even if they're done in my controller spec), I would have known that. Pat From joevandyk at gmail.com Sat May 26 00:48:44 2007 From: joevandyk at gmail.com (Joe Van Dyk) Date: Fri, 25 May 2007 21:48:44 -0700 Subject: [rspec-users] [ANN] RSpec-1.0.3 In-Reply-To: <57c63afe0705251349l6f83b574sa5cc43fd0abba4f6@mail.gmail.com> References: <57c63afe0705251349l6f83b574sa5cc43fd0abba4f6@mail.gmail.com> Message-ID: I have a sorta large project that used Test::Rails to do rails tests (i.e. model tests, controller tests, view tests, and integration tests). I'm converting the tests slowly over to specs, but it's going to take me a long time to do. Is there a way to have autotest work with both specs and the tests in the tests/ directory? Or, can I have two autotests running, one for specs and one for tests? On 5/25/07, David Chelimsky wrote: > The RSpec Development Team is pleased to announce the release of RSpec-1.0.3. > > == Changes > > This is the compatibility release! > > * Compatible with autotest!!!! (As of ZenTest 3.6.0 - see below) > * Compatible with edge rails (as of r6825). > * Compatible with jruby (since release 1.0.1) > > See http://rspec.rubyforge.org/changes.html for more detail. > > == About RSpec > > RSpec is a framework which provides programmers with a Domain Specific > Language to describe the behaviour of Ruby code with readable, > executable examples that guide you in the design process and serve > well as both documentation and tests. > > == Autotest compatibility > > ZenTest-3.6.0 boasts a new autodiscovery and plugin model that other > frameworks can register with and plug into. RSpec-1.0.3 ships with the > necessary plugin code, so all you need to do is download and go: > > For Rails apps: > > gem install ZenTest --version '>= 3.6.0' > rails myproject > cd myproject > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec > ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails > script/generate rspec > autotest > > ... and off you go > > For a non-rails app, you'll need to follow the convention of parallel > lib and spec directories. For example: > > gem install ZenTest --version '>= 3.6.0' > gem install rspec --version '>= 1.0.3' > mkdir stuff > cd stuff > mkdir lib > mkdir spec > autotest > > Enjoy! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat May 26 01:18:44 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 26 May 2007 00:18:44 -0500 Subject: [rspec-users] [ANN] RSpec-1.0.3 In-Reply-To: References: <57c63afe0705251349l6f83b574sa5cc43fd0abba4f6@mail.gmail.com> Message-ID: <57c63afe0705252218t536abedfm440b03ce2815948c@mail.gmail.com> On 5/25/07, Joe Van Dyk wrote: > I have a sorta large project that used Test::Rails to do rails tests > (i.e. model tests, controller tests, view tests, and integration > tests). > > I'm converting the tests slowly over to specs, but it's going to take > me a long time to do. Is there a way to have autotest work with both > specs and the tests in the tests/ directory? Or, can I have two > autotests running, one for specs and one for tests? It's really designed to run one or the other, however, you could, in theory, play with vendor/plugins/rspec_on_rails/lib/autotest/rspec_rails.rb. If you change @spec_command to "ruby ", remove spec/spec.opts, and modify @test_mappings to associate all of the test directories to the app directories like the spec directories are already mapped, you MIGHT get what you want. I haven't tried this - but give it a shot and let us know how it went. Good luck. Cheers, David > > On 5/25/07, David Chelimsky wrote: > > The RSpec Development Team is pleased to announce the release of RSpec-1.0.3. > > > > == Changes > > > > This is the compatibility release! > > > > * Compatible with autotest!!!! (As of ZenTest 3.6.0 - see below) > > * Compatible with edge rails (as of r6825). > > * Compatible with jruby (since release 1.0.1) > > > > See http://rspec.rubyforge.org/changes.html for more detail. > > > > == About RSpec > > > > RSpec is a framework which provides programmers with a Domain Specific > > Language to describe the behaviour of Ruby code with readable, > > executable examples that guide you in the design process and serve > > well as both documentation and tests. > > > > == Autotest compatibility > > > > ZenTest-3.6.0 boasts a new autodiscovery and plugin model that other > > frameworks can register with and plug into. RSpec-1.0.3 ships with the > > necessary plugin code, so all you need to do is download and go: > > > > For Rails apps: > > > > gem install ZenTest --version '>= 3.6.0' > > rails myproject > > cd myproject > > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec > > ruby script/plugin install > > svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails > > script/generate rspec > > autotest > > > > ... and off you go > > > > For a non-rails app, you'll need to follow the convention of parallel > > lib and spec directories. For example: > > > > gem install ZenTest --version '>= 3.6.0' > > gem install rspec --version '>= 1.0.3' > > mkdir stuff > > cd stuff > > mkdir lib > > mkdir spec > > autotest > > > > Enjoy! > > _______________________________________________ > > 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 omen.king at gmail.com Sat May 26 01:33:15 2007 From: omen.king at gmail.com (Omen King) Date: Sat, 26 May 2007 01:33:15 -0400 Subject: [rspec-users] RSpec Message-ID: Hi RSpec Mailing list, I'm new to RSpec and I am trying to get it running with the caboo.se sample rails app. I installed the current version of rspec with rspec_on_rails I tried to run rake spec but received: 330-07:~/desktop/restful_auth_rspec/vendor multimedia$ rake spec (in /Users/multimedia/Desktop/restful_auth_rspec) /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in `load_missing_constant': uninitialized constant ActiveRecordMatchers (NameError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in `const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in `const_missing' from ./spec/models/authenticated_base_spec.rb:4 from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in `class_eval' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in `eval_behaviour' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:30:in `initialize' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in `new' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in `create' ... 21 levels... from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in `parse' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behaviour_runner' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 rake aborted! Command ruby -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" "spec/controllers/session_controller_spec.rb" "spec/controllers/user_assets_controller_spec.rb" "spec/controllers/users_controller_spec.rb" "spec/helpers/user_assets_helper_spec.rb" "spec/helpers/user_assets_url_helpers_spec.rb" "spec/models/asset_spec.rb" "spec/models/authenticated_base_spec.rb" "spec/models/user_spec.rb" "spec/views/assets/edit_rhtml_spec.rb" "spec/views/assets/index_rhtml_spec.rb" "spec/views/assets/new_rhtml_spec.rb" "spec/views/assets/show_rhtml_spec.rb" "spec/views/users/edit_rhtml_spec.rb" "spec/views/users/index_rhtml_spec.rb" "spec/views/users/new_rhtml_spec.rb" "spec/views/users/show_rhtml_spec.rb" --options "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" failed (See full trace by running task with --trace) So I thought installing the trunk version of rails would resolve it but I got: 330-07:~/desktop/restful_auth_rspec multimedia$ rake spec (in /Users/multimedia/Desktop/restful_auth_rspec) /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/railties/lib/dispatcher.rb:90: undefined method `attr_accessor_with_default' for # (NoMethodError) from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require' from /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/actionpack/lib/action_controller/integration.rb:1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' ... 29 levels... from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in `parse' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behaviour_runner' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in `run' from /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 rake aborted! Command ruby -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" "spec/controllers/session_controller_spec.rb" "spec/controllers/user_assets_controller_spec.rb" "spec/controllers/users_controller_spec.rb" "spec/helpers/user_assets_helper_spec.rb" "spec/helpers/user_assets_url_helpers_spec.rb" "spec/models/asset_spec.rb" "spec/models/authenticated_base_spec.rb" "spec/models/user_spec.rb" "spec/views/assets/edit_rhtml_spec.rb" "spec/views/assets/index_rhtml_spec.rb" "spec/views/assets/new_rhtml_spec.rb" "spec/views/assets/show_rhtml_spec.rb" "spec/views/users/edit_rhtml_spec.rb" "spec/views/users/index_rhtml_spec.rb" "spec/views/users/new_rhtml_spec.rb" "spec/views/users/show_rhtml_spec.rb" --options "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" failed Any idea how to resolve this? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070526/a4f0149d/attachment.html From aslak.hellesoy at gmail.com Sat May 26 06:04:44 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 26 May 2007 12:04:44 +0200 Subject: [rspec-users] RSpec In-Reply-To: References: Message-ID: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> On 5/26/07, Omen King wrote: > Hi RSpec Mailing list, > > I'm new to RSpec and I am trying to get it running with the caboo.se sample > rails app. > I installed the current version of rspec with rspec_on_rails > > I tried to run rake spec but received: > > 330-07:~/desktop/restful_auth_rspec/vendor multimedia$ rake > spec > (in /Users/multimedia/Desktop/restful_auth_rspec) > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in > `load_missing_constant': uninitialized constant ActiveRecordMatchers This is Ruby telling you it can't find the class or module ActiveRecordMatchers. IIRC this is something that lives in a third party plugin. Google for ActiveRecordMatchers and install it. (It *should* be automatically installed as an svn:external though) It also looks like the Caboose app was last updated in april, so it might not be uptodate with RSpec 1.0 - I'm assuming you're using this: http://sample.caboo.se/empty_rails_app/ HTH, Aslak > (NameError) > from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in > `const_missing' > from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in > `const_missing' > from ./spec/models/authenticated_base_spec.rb:4 > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > `class_eval' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > `eval_behaviour' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:30:in > `initialize' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > `new' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > `create' > ... 21 levels... > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > `parse' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > `create_behaviour_runner' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > `run' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > rake aborted! > Command ruby > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > "spec/controllers/session_controller_spec.rb" > "spec/controllers/user_assets_controller_spec.rb" > "spec/controllers/users_controller_spec.rb" > "spec/helpers/user_assets_helper_spec.rb" > "spec/helpers/user_assets_url_helpers_spec.rb" > "spec/models/asset_spec.rb" > "spec/models/authenticated_base_spec.rb" > "spec/models/user_spec.rb" > "spec/views/assets/edit_rhtml_spec.rb" > "spec/views/assets/index_rhtml_spec.rb" > "spec/views/assets/new_rhtml_spec.rb" > "spec/views/assets/show_rhtml_spec.rb" > "spec/views/users/edit_rhtml_spec.rb" > "spec/views/users/index_rhtml_spec.rb" > "spec/views/users/new_rhtml_spec.rb" > "spec/views/users/show_rhtml_spec.rb" --options > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > failed > > (See full trace by running task with --trace) > > So I thought installing the trunk version of rails would resolve it but I > got: > > 330-07:~/desktop/restful_auth_rspec multimedia$ rake spec > (in /Users/multimedia/Desktop/restful_auth_rspec) > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/railties/lib/dispatcher.rb:90: > undefined method `attr_accessor_with_default' for # > (NoMethodError) > from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require' > from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in > `require' > from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in > `new_constants_in' > from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in > `require' > from > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/actionpack/lib/action_controller/integration.rb:1 > from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require' > from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > ... 29 levels... > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > `parse' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > `create_behaviour_runner' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > `run' > from > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > rake aborted! > Command ruby > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > "spec/controllers/session_controller_spec.rb" > "spec/controllers/user_assets_controller_spec.rb" > "spec/controllers/users_controller_spec.rb" > "spec/helpers/user_assets_helper_spec.rb" > "spec/helpers/user_assets_url_helpers_spec.rb" > "spec/models/asset_spec.rb" > "spec/models/authenticated_base_spec.rb" > "spec/models/user_spec.rb" > "spec/views/assets/edit_rhtml_spec.rb" > "spec/views/assets/index_rhtml_spec.rb" > "spec/views/assets/new_rhtml_spec.rb" > "spec/views/assets/show_rhtml_spec.rb" > "spec/views/users/edit_rhtml_spec.rb" > "spec/views/users/index_rhtml_spec.rb" > "spec/views/users/new_rhtml_spec.rb" > "spec/views/users/show_rhtml_spec.rb" --options > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > failed > > Any idea how to resolve this? > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From omen.king at gmail.com Sat May 26 11:43:10 2007 From: omen.king at gmail.com (Omen King) Date: Sat, 26 May 2007 11:43:10 -0400 Subject: [rspec-users] RSpec In-Reply-To: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> References: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> Message-ID: ActiveRecordMatchers does exist as a file called rpspec_extensions in my lib. I want to update this sample app to Respec 1.0 I original error still persist. I have rspec installed as a plugin. On 5/26/07, aslak hellesoy wrote: > > On 5/26/07, Omen King wrote: > > Hi RSpec Mailing list, > > > > I'm new to RSpec and I am trying to get it running with the caboo.sesample > > rails app. > > I installed the current version of rspec with rspec_on_rails > > > > I tried to run rake spec but received: > > > > 330-07:~/desktop/restful_auth_rspec/vendor multimedia$ rake > > spec > > (in /Users/multimedia/Desktop/restful_auth_rspec) > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:266:in > > `load_missing_constant': uninitialized constant ActiveRecordMatchers > > This is Ruby telling you it can't find the class or module > ActiveRecordMatchers. > > IIRC this is something that lives in a third party plugin. Google for > ActiveRecordMatchers and install it. (It *should* be automatically > installed as an svn:external though) > > It also looks like the Caboose app was last updated in april, so it > might not be uptodate with RSpec 1.0 - I'm assuming you're using this: > http://sample.caboo.se/empty_rails_app/ > > HTH, > Aslak > > > (NameError) > > from > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:452:in > > `const_missing' > > from > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:464:in > > `const_missing' > > from ./spec/models/authenticated_base_spec.rb:4 > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > > `class_eval' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > > `eval_behaviour' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:30:in > > `initialize' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > > `new' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > > `create' > > ... 21 levels... > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > > `parse' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > > `create_behaviour_runner' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > > `run' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > > rake aborted! > > Command ruby > > > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > > > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > > "spec/controllers/session_controller_spec.rb" > > "spec/controllers/user_assets_controller_spec.rb" > > "spec/controllers/users_controller_spec.rb" > > "spec/helpers/user_assets_helper_spec.rb" > > "spec/helpers/user_assets_url_helpers_spec.rb" > > "spec/models/asset_spec.rb" > > "spec/models/authenticated_base_spec.rb" > > "spec/models/user_spec.rb" > > "spec/views/assets/edit_rhtml_spec.rb" > > "spec/views/assets/index_rhtml_spec.rb" > > "spec/views/assets/new_rhtml_spec.rb" > > "spec/views/assets/show_rhtml_spec.rb" > > "spec/views/users/edit_rhtml_spec.rb" > > "spec/views/users/index_rhtml_spec.rb" > > "spec/views/users/new_rhtml_spec.rb" > > "spec/views/users/show_rhtml_spec.rb" --options > > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > > failed > > > > (See full trace by running task with --trace) > > > > So I thought installing the trunk version of rails would resolve it but > I > > got: > > > > 330-07:~/desktop/restful_auth_rspec multimedia$ rake spec > > (in /Users/multimedia/Desktop/restful_auth_rspec) > > > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/railties/lib/dispatcher.rb:90: > > undefined method `attr_accessor_with_default' for # > > (NoMethodError) > > from > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_require' > > from > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `require' > > from > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:495:in > > `require' > > from > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:342:in > > `new_constants_in' > > from > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:495:in > > `require' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/actionpack/lib/action_controller/integration.rb:1 > > from > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_require' > > from > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `require' > > ... 29 levels... > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > > `parse' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > > `create_behaviour_runner' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > > `run' > > from > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > > rake aborted! > > Command ruby > > > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > > > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > > "spec/controllers/session_controller_spec.rb" > > "spec/controllers/user_assets_controller_spec.rb" > > "spec/controllers/users_controller_spec.rb" > > "spec/helpers/user_assets_helper_spec.rb" > > "spec/helpers/user_assets_url_helpers_spec.rb" > > "spec/models/asset_spec.rb" > > "spec/models/authenticated_base_spec.rb" > > "spec/models/user_spec.rb" > > "spec/views/assets/edit_rhtml_spec.rb" > > "spec/views/assets/index_rhtml_spec.rb" > > "spec/views/assets/new_rhtml_spec.rb" > > "spec/views/assets/show_rhtml_spec.rb" > > "spec/views/users/edit_rhtml_spec.rb" > > "spec/views/users/index_rhtml_spec.rb" > > "spec/views/users/new_rhtml_spec.rb" > > "spec/views/users/show_rhtml_spec.rb" --options > > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > > failed > > > > Any idea how to resolve this? > > > > > > _______________________________________________ > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070526/e807900b/attachment.html From aslak.hellesoy at gmail.com Sat May 26 12:01:15 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 26 May 2007 18:01:15 +0200 Subject: [rspec-users] RSpec In-Reply-To: References: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> Message-ID: <8d961d900705260901h3e86b4cauacba95be7c0ebc11@mail.gmail.com> On 5/26/07, Omen King wrote: > ActiveRecordMatchers does exist as a file called rpspec_extensions in my > lib. > I want to update this sample app to Respec 1.0 > > I original error still persist. I have rspec installed as a plugin. > Please provide detailed info about how we can reproduce the error. Aslak > > > > On 5/26/07, aslak hellesoy wrote: > > On 5/26/07, Omen King wrote: > > > Hi RSpec Mailing list, > > > > > > I'm new to RSpec and I am trying to get it running with the caboo.se > sample > > > rails app. > > > I installed the current version of rspec with rspec_on_rails > > > > > > I tried to run rake spec but received: > > > > > > 330-07:~/desktop/restful_auth_rspec/vendor multimedia$ > rake > > > spec > > > (in /Users/multimedia/Desktop/restful_auth_rspec) > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in > > > `load_missing_constant': uninitialized constant ActiveRecordMatchers > > > > This is Ruby telling you it can't find the class or module > ActiveRecordMatchers. > > > > IIRC this is something that lives in a third party plugin. Google for > > ActiveRecordMatchers and install it. (It *should* be automatically > > installed as an svn:external though) > > > > It also looks like the Caboose app was last updated in april, so it > > might not be uptodate with RSpec 1.0 - I'm assuming you're using this: > > http://sample.caboo.se/empty_rails_app/ > > > > HTH, > > Aslak > > > > > (NameError) > > > from > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in > > > `const_missing' > > > from > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in > > > `const_missing' > > > from ./spec/models/authenticated_base_spec.rb:4 > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > > > `class_eval' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > > > `eval_behaviour' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:30:in > > > `initialize' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > > > `new' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > > > `create' > > > ... 21 levels... > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > > > `parse' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > > > `create_behaviour_runner' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > > > `run' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > > > rake aborted! > > > Command ruby > > > > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > > > > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > > > "spec/controllers/session_controller_spec.rb" > > > "spec/controllers/user_assets_controller_spec.rb" > > > "spec/controllers/users_controller_spec.rb" > > > "spec/helpers/user_assets_helper_spec.rb" > > > "spec/helpers/user_assets_url_helpers_spec.rb" > > > "spec/models/asset_spec.rb" > > > "spec/models/authenticated_base_spec.rb" > > > "spec/models/user_spec.rb" > > > "spec/views/assets/edit_rhtml_spec.rb" > > > "spec/views/assets/index_rhtml_spec.rb" > > > "spec/views/assets/new_rhtml_spec.rb" > > > "spec/views/assets/show_rhtml_spec.rb" > > > "spec/views/users/edit_rhtml_spec.rb" > > > "spec/views/users/index_rhtml_spec.rb" > > > "spec/views/users/new_rhtml_spec.rb" > > > "spec/views/users/show_rhtml_spec.rb" --options > > > > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > > > failed > > > > > > (See full trace by running task with --trace) > > > > > > So I thought installing the trunk version of rails would resolve it but > I > > > got: > > > > > > 330-07:~/desktop/restful_auth_rspec multimedia$ rake > spec > > > (in /Users/multimedia/Desktop/restful_auth_rspec) > > > > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/railties/lib/dispatcher.rb:90: > > > undefined method `attr_accessor_with_default' for # > > > (NoMethodError) > > > from > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > `gem_original_require' > > > from > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > `require' > > > from > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in > > > `require' > > > from > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport- > 1.4.2/lib/active_support/dependencies.rb:342:in > > > `new_constants_in' > > > from > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in > > > `require' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/actionpack/lib/action_controller/integration.rb:1 > > > from > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > `gem_original_require' > > > from > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > `require' > > > ... 29 levels... > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > > > `parse' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > > > `create_behaviour_runner' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > > > `run' > > > from > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > > > rake aborted! > > > Command ruby > > > > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > > > > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > > > "spec/controllers/session_controller_spec.rb" > > > "spec/controllers/user_assets_controller_spec.rb" > > > "spec/controllers/users_controller_spec.rb" > > > "spec/helpers/user_assets_helper_spec.rb" > > > "spec/helpers/user_assets_url_helpers_spec.rb" > > > "spec/models/asset_spec.rb" > > > "spec/models/authenticated_base_spec.rb" > > > "spec/models/user_spec.rb" > > > "spec/views/assets/edit_rhtml_spec.rb" > > > "spec/views/assets/index_rhtml_spec.rb" > > > "spec/views/assets/new_rhtml_spec.rb" > > > "spec/views/assets/show_rhtml_spec.rb" > > > "spec/views/users/edit_rhtml_spec.rb" > > > "spec/views/users/index_rhtml_spec.rb" > > > "spec/views/users/new_rhtml_spec.rb" > > > "spec/views/users/show_rhtml_spec.rb" --options > > > > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > > > failed > > > > > > Any idea how to resolve this? > > > > > > > > > _______________________________________________ > > > 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 omen.king at gmail.com Sat May 26 12:05:34 2007 From: omen.king at gmail.com (Omen King) Date: Sat, 26 May 2007 12:05:34 -0400 Subject: [rspec-users] RSpec In-Reply-To: <8d961d900705260901h3e86b4cauacba95be7c0ebc11@mail.gmail.com> References: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> <8d961d900705260901h3e86b4cauacba95be7c0ebc11@mail.gmail.com> Message-ID: I downloaded the web-app again, I installed the RSpec Gem and then loaded in the the rspec and respec_on_rails and everything works now. On 5/26/07, aslak hellesoy wrote: > > On 5/26/07, Omen King wrote: > > ActiveRecordMatchers does exist as a file called rpspec_extensions in my > > lib. > > I want to update this sample app to Respec 1.0 > > > > I original error still persist. I have rspec installed as a plugin. > > > > Please provide detailed info about how we can reproduce the error. > > Aslak > > > > > > > > > On 5/26/07, aslak hellesoy wrote: > > > On 5/26/07, Omen King wrote: > > > > Hi RSpec Mailing list, > > > > > > > > I'm new to RSpec and I am trying to get it running with the caboo.se > > sample > > > > rails app. > > > > I installed the current version of rspec with rspec_on_rails > > > > > > > > I tried to run rake spec but received: > > > > > > > > 330-07:~/desktop/restful_auth_rspec/vendor multimedia$ > > rake > > > > spec > > > > (in /Users/multimedia/Desktop/restful_auth_rspec) > > > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:266:in > > > > `load_missing_constant': uninitialized constant ActiveRecordMatchers > > > > > > This is Ruby telling you it can't find the class or module > > ActiveRecordMatchers. > > > > > > IIRC this is something that lives in a third party plugin. Google for > > > ActiveRecordMatchers and install it. (It *should* be automatically > > > installed as an svn:external though) > > > > > > It also looks like the Caboose app was last updated in april, so it > > > might not be uptodate with RSpec 1.0 - I'm assuming you're using this: > > > http://sample.caboo.se/empty_rails_app/ > > > > > > HTH, > > > Aslak > > > > > > > (NameError) > > > > from > > > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:452:in > > > > `const_missing' > > > > from > > > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:464:in > > > > `const_missing' > > > > from ./spec/models/authenticated_base_spec.rb:4 > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > > > > `class_eval' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:49:in > > > > `eval_behaviour' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:30:in > > > > `initialize' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > > > > `new' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb:36:in > > > > `create' > > > > ... 21 levels... > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > > > > `parse' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > > > > `create_behaviour_runner' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > > > > `run' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > > > > rake aborted! > > > > Command ruby > > > > > > > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > > > > > > > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > > > > "spec/controllers/session_controller_spec.rb" > > > > "spec/controllers/user_assets_controller_spec.rb" > > > > "spec/controllers/users_controller_spec.rb" > > > > "spec/helpers/user_assets_helper_spec.rb" > > > > "spec/helpers/user_assets_url_helpers_spec.rb" > > > > "spec/models/asset_spec.rb" > > > > "spec/models/authenticated_base_spec.rb" > > > > "spec/models/user_spec.rb" > > > > "spec/views/assets/edit_rhtml_spec.rb" > > > > "spec/views/assets/index_rhtml_spec.rb" > > > > "spec/views/assets/new_rhtml_spec.rb" > > > > "spec/views/assets/show_rhtml_spec.rb" > > > > "spec/views/users/edit_rhtml_spec.rb" > > > > "spec/views/users/index_rhtml_spec.rb" > > > > "spec/views/users/new_rhtml_spec.rb" > > > > "spec/views/users/show_rhtml_spec.rb" --options > > > > > > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > > > > failed > > > > > > > > (See full trace by running task with --trace) > > > > > > > > So I thought installing the trunk version of rails would resolve it > but > > I > > > > got: > > > > > > > > 330-07:~/desktop/restful_auth_rspec multimedia$ rake > > spec > > > > (in /Users/multimedia/Desktop/restful_auth_rspec) > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/railties/lib/dispatcher.rb:90: > > > > undefined method `attr_accessor_with_default' for > # > > > > (NoMethodError) > > > > from > > > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > > `gem_original_require' > > > > from > > > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > > `require' > > > > from > > > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:495:in > > > > `require' > > > > from > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport- > > 1.4.2/lib/active_support/dependencies.rb:342:in > > > > `new_constants_in' > > > > from > > > > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2 > /lib/active_support/dependencies.rb:495:in > > > > `require' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/config/../vendor/plugins/trunk/actionpack/lib/action_controller/integration.rb:1 > > > > from > > > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > > `gem_original_require' > > > > from > > > > > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > > `require' > > > > ... 29 levels... > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in > > > > `parse' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in > > > > `create_behaviour_runner' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14:in > > > > `run' > > > > from > > > > > > > /Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec:3 > > > > rake aborted! > > > > Command ruby > > > > > > > -I"/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/lib" > > > > > > > "/Users/multimedia/Desktop/restful_auth_rspec/vendor/plugins/rspec/bin/spec" > > > > "spec/controllers/session_controller_spec.rb" > > > > "spec/controllers/user_assets_controller_spec.rb" > > > > "spec/controllers/users_controller_spec.rb" > > > > "spec/helpers/user_assets_helper_spec.rb" > > > > "spec/helpers/user_assets_url_helpers_spec.rb" > > > > "spec/models/asset_spec.rb" > > > > "spec/models/authenticated_base_spec.rb" > > > > "spec/models/user_spec.rb" > > > > "spec/views/assets/edit_rhtml_spec.rb" > > > > "spec/views/assets/index_rhtml_spec.rb" > > > > "spec/views/assets/new_rhtml_spec.rb" > > > > "spec/views/assets/show_rhtml_spec.rb" > > > > "spec/views/users/edit_rhtml_spec.rb" > > > > "spec/views/users/index_rhtml_spec.rb" > > > > "spec/views/users/new_rhtml_spec.rb" > > > > "spec/views/users/show_rhtml_spec.rb" --options > > > > > > "/Users/multimedia/Desktop/restful_auth_rspec/config/../spec/spec.opts" > > > > failed > > > > > > > > Any idea how to resolve this? > > > > > > > > > > > > _______________________________________________ > > > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070526/00968a02/attachment-0001.html From omen.king at gmail.com Sat May 26 12:12:15 2007 From: omen.king at gmail.com (Omen King) Date: Sat, 26 May 2007 12:12:15 -0400 Subject: [rspec-users] RSpec In-Reply-To: References: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> <8d961d900705260901h3e86b4cauacba95be7c0ebc11@mail.gmail.com> Message-ID: So I can run rake spec. I've gotten errors and I not too sure what I'm looking at. Lets take a look at error 1: =================================================== specify "should render new" do controller.should_render :new get :new end 1) NoMethodError in '/session/new GET should render new' undefined method `should_render' for # ./spec/controllers/session_controller_spec.rb:7: =================================================== Is it trying to called a method called 'should_render' for session_controller of session_controller_spec? 2) NameError in '/session POST without remember me should authenticate user' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:15: 3) NameError in '/session POST without remember me should login user' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:15: 4) NameError in '/session POST without remember me should not remember me' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:15: 5) NameError in '/session POST without remember me should redirect to root' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:15: 6) NameError in '/session POST with remember me should remember me' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:44: 7) NameError in '/session POST with remember me should create cookie' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:44: 8) NameError in '/session POST when invalid should authenticate user' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:72: 9) NameError in '/session POST when invalid should login user' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:72: 10) NameError in '/session POST when invalid should not remember me' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:72: 11) NameError in '/session POST when invalid should render new' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:72: 12) NameError in '/session DELETE should get current user' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:102: 13) NameError in '/session DELETE should forget current user' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:102: 14) NameError in '/session DELETE should delete token on logout' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:102: 15) NameError in '/session DELETE should reset session' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:102: 16) NameError in '/session DELETE should redirect to root' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/controllers/session_controller_spec.rb:102: 17) NoMethodError in 'Requesting /assets using GET should render index.rhtml' undefined method `should_render' for # ./spec/controllers/user_assets_controller_spec.rb:25: 18) NoMethodError in 'Requesting /assets/1 using GET should render show.rhtml' undefined method `should_render' for # ./spec/controllers/user_assets_controller_spec.rb:93: 19) NoMethodError in 'Requesting /assets/new using GET should render new.rhtml' undefined method `should_render' for # ./spec/controllers/user_assets_controller_spec.rb:159: 20) NoMethodError in 'Requesting /assets/1;edit using GET should render edit.rhtml' undefined method `should_render' for # ./spec/controllers/user_assets_controller_spec.rb:201: 21) NoMethodError in 'Requesting /users using GET should render index.rhtml' undefined method `should_render' for # ./spec/controllers/users_controller_spec.rb:49: 22) NoMethodError in 'Requesting /users/1 using GET should render show.rhtml' undefined method `should_render' for # ./spec/controllers/users_controller_spec.rb:112: 23) NoMethodError in 'Requesting /users/new using GET should render new.rhtml' undefined method `should_render' for # ./spec/controllers/users_controller_spec.rb:175: 24) ActiveRecord::StatementInvalid in 'Requesting /users/1;edit using GET should fail if current user doesn't match' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/controllers/users_controller_spec.rb:209:in `new' ./spec/controllers/users_controller_spec.rb:209: 25) NoMethodError in 'Requesting /users/1;edit using GET should render edit.rhtml' undefined method `should_render' for # ./spec/controllers/users_controller_spec.rb:221: 26) NoMethodError in 'the UserAssetsHelper should return user login name' undefined method `should_eql' for "JoeLogin":String ./spec/helpers/user_assets_helper_spec.rb:11: 27) NameError in 'the generated url helpers for UserAssetsController should return assets path given no arguments' undefined local variable or method `controller' for [Dynamically generated class for RSpec example]:# (eval):2:in `assets_path' ./spec/helpers/user_assets_url_helpers_spec.rb:24: 28) NameError in 'the generated url helpers for UserAssetsController should return assets path given explicit argument' undefined local variable or method `controller' for [Dynamically generated class for RSpec example]:# (eval):2:in `assets_path' ./spec/helpers/user_assets_url_helpers_spec.rb:28: 29) NameError in 'the generated url helpers for UserAssetsController should return asset path' undefined local variable or method `controller' for [Dynamically generated class for RSpec example]:# (eval):2:in `asset_path' ./spec/helpers/user_assets_url_helpers_spec.rb:32: 30) NameError in 'the generated url helpers for UserAssetsController should return edit_asset path' undefined local variable or method `controller' for [Dynamically generated class for RSpec example]:# (eval):2:in `edit_asset_path' ./spec/helpers/user_assets_url_helpers_spec.rb:36: 31) NameError in 'the generated url helpers for UserAssetsController should return new_asset path' undefined local variable or method `controller' for [Dynamically generated class for RSpec example]:# (eval):2:in `new_asset_path' ./spec/helpers/user_assets_url_helpers_spec.rb:40: 32) NameError in 'the generated url helpers for UserAssetsController should return asset_attachable path' undefined local variable or method `controller' for [Dynamically generated class for RSpec example]:# (eval):2:in `asset_attachable_path' ./spec/helpers/user_assets_url_helpers_spec.rb:44: 33) ActiveRecord::StatementInvalid in 'Given a generated asset_spec.rb with fixtures loaded fixtures should load two Assets' ActiveRecord::StatementInvalid: Mysql::Error: #42S02Table 'sample_test.assets' doesn't exist: DELETE FROM assets: DELETE FROM assets /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' /Users/multimedia/Desktop/rest_org/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/model.rb:12:in `before_eval' 34) ActiveRecord::StatementInvalid in 'A User abstract class should have valid associations' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/authenticated_base_spec.rb:7:in `new' ./spec/models/authenticated_base_spec.rb:7: 35) ActiveRecord::StatementInvalid in 'An existing user should authenticate with new or reset password' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/authenticated_base_spec.rb:14: 36) ActiveRecord::StatementInvalid in 'An existing user should not rehash password on login change' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/authenticated_base_spec.rb:14: 37) ActiveRecord::StatementInvalid in 'An existing user should remember token' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/authenticated_base_spec.rb:14: 38) ActiveRecord::StatementInvalid in 'An existing user should increment hit counter' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/authenticated_base_spec.rb:14: 39) ActiveRecord::StatementInvalid in 'An existing user should forget token' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/authenticated_base_spec.rb:14: 40) ActiveRecord::StatementInvalid in 'An existing user should be remembered for a period' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/authenticated_base_spec.rb:14: 41) NoMethodError in 'A new user should create' undefined method `should_change' for # ./spec/models/authenticated_base_spec.rb:59: 42) NoMethodError in 'A new user should require login' undefined method `should_not_change' for # ./spec/models/authenticated_base_spec.rb:63: 43) NoMethodError in 'A new user should require password' undefined method `should_not_change' for # ./spec/models/authenticated_base_spec.rb:68: 44) NoMethodError in 'A new user should require password confirmation' undefined method `should_not_change' for # ./spec/models/authenticated_base_spec.rb:73: 45) NoMethodError in 'A new user should require email' undefined method `should_not_change' for # ./spec/models/authenticated_base_spec.rb:78: 46) ActiveRecord::StatementInvalid in 'A User should have valid associations' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/user_spec.rb:7:in `new' ./spec/models/user_spec.rb:7: 47) ActiveRecord::StatementInvalid in 'A User should protect against updates to secure attributes' Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS FROM users /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in `log' ./spec/models/user_spec.rb:7:in `new' ./spec/models/user_spec.rb:7: 48) NoMethodError in '/assets/edit.rhtml should render edit form' undefined method `should_have_tag' for # ./spec/views/assets/edit_rhtml_spec.rb:36: 49) NoMethodError in '/assets/index.rhtml should render list of assets' undefined method `should_have_tag' for # ./spec/views/assets/index_rhtml_spec.rb:49: 50) NoMethodError in '/assets/new.rhtml should render new form' undefined method `should_have_tag' for # ./spec/views/assets/new_rhtml_spec.rb:39: 51) NoMethodError in '/users/edit.rhtml should render edit form' undefined method `should_have_tag' for # ./spec/views/users/edit_rhtml_spec.rb:21: 52) NameError in '/users/new.rhtml should render new form' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/views/users/new_rhtml_spec.rb:10: 53) NameError in '/users/show.rhtml should render attributes in

' undefined local variable or method `mock_user' for [Dynamically generated class for RSpec example]:# ./spec/views/users/show_rhtml_spec.rb:7: Finished in 2.492637 seconds 117 examples, 53 failures -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070526/8cf85a35/attachment-0001.html From aslak.hellesoy at gmail.com Sat May 26 12:38:46 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 26 May 2007 18:38:46 +0200 Subject: [rspec-users] RSpec In-Reply-To: References: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> <8d961d900705260901h3e86b4cauacba95be7c0ebc11@mail.gmail.com> Message-ID: <8d961d900705260938n539dba57k4de53a995b76f68f@mail.gmail.com> The app you downloaded is not compatible with rspec 1.0. Please contact the app authors or upgrade it yourself. See upgrading on the rspec website. On 5/26/07, Omen King wrote: > So I can run rake spec. I've gotten errors and I not too sure what I'm > looking at. > > Lets take a look at error 1: > =================================================== > specify "should render new" do > controller.should_render :new > get :new > end > > 1) > NoMethodError in '/session/new GET should render new' > undefined method `should_render' for # > ./spec/controllers/session_controller_spec.rb:7: > =================================================== > Is it trying to called a method called 'should_render' for > session_controller of session_controller_spec? > > 2) > NameError in '/session POST without remember me should authenticate user' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:15: > > 3) > NameError in '/session POST without remember me should login user' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:15: > > 4) > NameError in '/session POST without remember me should not remember me' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:15: > > 5) > NameError in '/session POST without remember me should redirect to root' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:15: > > 6) > NameError in '/session POST with remember me should remember me' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:44: > > 7) > NameError in '/session POST with remember me should create cookie' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:44: > > 8) > NameError in '/session POST when invalid should authenticate user' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:72: > > 9) > NameError in '/session POST when invalid should login user' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:72: > > 10) > NameError in '/session POST when invalid should not remember me' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:72: > > 11) > NameError in '/session POST when invalid should render new' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:72: > > 12) > NameError in '/session DELETE should get current user' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:102: > > 13) > NameError in '/session DELETE should forget current user' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:102: > > 14) > NameError in '/session DELETE should delete token on logout' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:102: > > 15) > NameError in '/session DELETE should reset session' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:102: > > 16) > NameError in '/session DELETE should redirect to root' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/controllers/session_controller_spec.rb:102: > > 17) > NoMethodError in 'Requesting /assets using GET should render index.rhtml' > undefined method `should_render' for # > ./spec/controllers/user_assets_controller_spec.rb:25: > > 18) > NoMethodError in 'Requesting /assets/1 using GET should render show.rhtml' > undefined method `should_render' for # > ./spec/controllers/user_assets_controller_spec.rb:93: > > 19) > NoMethodError in 'Requesting /assets/new using GET should render new.rhtml' > undefined method `should_render' for # > ./spec/controllers/user_assets_controller_spec.rb:159: > > 20) > NoMethodError in 'Requesting /assets/1;edit using GET should render > edit.rhtml' > undefined method `should_render' for # > ./spec/controllers/user_assets_controller_spec.rb:201: > > 21) > NoMethodError in 'Requesting /users using GET should render index.rhtml' > undefined method `should_render' for # > ./spec/controllers/users_controller_spec.rb:49: > > 22) > NoMethodError in 'Requesting /users/1 using GET should render show.rhtml' > undefined method `should_render' for # > ./spec/controllers/users_controller_spec.rb:112: > > 23) > NoMethodError in 'Requesting /users/new using GET should render new.rhtml' > undefined method `should_render' for # > ./spec/controllers/users_controller_spec.rb:175: > > 24) > ActiveRecord::StatementInvalid in 'Requesting /users/1;edit using GET should > fail if current user doesn't match' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/controllers/users_controller_spec.rb:209:in `new' > ./spec/controllers/users_controller_spec.rb:209: > > 25) > NoMethodError in 'Requesting /users/1;edit using GET should render > edit.rhtml' > undefined method `should_render' for # > ./spec/controllers/users_controller_spec.rb:221: > > 26) > NoMethodError in 'the UserAssetsHelper should return user login name' > undefined method `should_eql' for "JoeLogin":String > ./spec/helpers/user_assets_helper_spec.rb:11: > > 27) > NameError in 'the generated url helpers for UserAssetsController should > return assets path given no arguments' > undefined local variable or method `controller' for [Dynamically generated > class for RSpec example]:# > (eval):2:in `assets_path' > ./spec/helpers/user_assets_url_helpers_spec.rb:24: > > 28) > NameError in 'the generated url helpers for UserAssetsController should > return assets path given explicit argument' > undefined local variable or method `controller' for [Dynamically generated > class for RSpec example]:# > (eval):2:in `assets_path' > ./spec/helpers/user_assets_url_helpers_spec.rb:28: > > 29) > NameError in 'the generated url helpers for UserAssetsController should > return asset path' > undefined local variable or method `controller' for [Dynamically generated > class for RSpec example]:# > (eval):2:in `asset_path' > ./spec/helpers/user_assets_url_helpers_spec.rb:32: > > 30) > NameError in 'the generated url helpers for UserAssetsController should > return edit_asset path' > undefined local variable or method `controller' for [Dynamically generated > class for RSpec example]:# > (eval):2:in `edit_asset_path' > ./spec/helpers/user_assets_url_helpers_spec.rb:36: > > 31) > NameError in 'the generated url helpers for UserAssetsController should > return new_asset path' > undefined local variable or method `controller' for [Dynamically generated > class for RSpec example]:# > (eval):2:in `new_asset_path' > ./spec/helpers/user_assets_url_helpers_spec.rb:40: > > 32) > NameError in 'the generated url helpers for UserAssetsController should > return asset_attachable path' > undefined local variable or method `controller' for [Dynamically generated > class for RSpec example]:# > (eval):2:in `asset_attachable_path' > ./spec/helpers/user_assets_url_helpers_spec.rb:44: > > 33) > ActiveRecord::StatementInvalid in 'Given a generated asset_spec.rb with > fixtures loaded fixtures should load two Assets' > ActiveRecord::StatementInvalid: Mysql::Error: #42S02Table > 'sample_test.assets' doesn't exist: DELETE FROM assets: DELETE FROM assets > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > /Users/multimedia/Desktop/rest_org/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/model.rb:12:in > `before_eval' > > 34) > ActiveRecord::StatementInvalid in 'A User abstract class should have valid > associations' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/authenticated_base_spec.rb:7:in `new' > ./spec/models/authenticated_base_spec.rb:7: > > 35) > ActiveRecord::StatementInvalid in 'An existing user should authenticate with > new or reset password' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/authenticated_base_spec.rb:14: > > 36) > ActiveRecord::StatementInvalid in 'An existing user should not rehash > password on login change' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/authenticated_base_spec.rb:14: > > 37) > ActiveRecord::StatementInvalid in 'An existing user should remember token' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/authenticated_base_spec.rb:14: > > 38) > ActiveRecord::StatementInvalid in 'An existing user should increment hit > counter' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/authenticated_base_spec.rb:14: > > 39) > ActiveRecord::StatementInvalid in 'An existing user should forget token' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/authenticated_base_spec.rb:14: > > 40) > ActiveRecord::StatementInvalid in 'An existing user should be remembered for > a period' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/authenticated_base_spec.rb:14: > > 41) > NoMethodError in 'A new user should create' > undefined method `should_change' for > # > ./spec/models/authenticated_base_spec.rb:59: > > 42) > NoMethodError in 'A new user should require login' > undefined method `should_not_change' for > # > ./spec/models/authenticated_base_spec.rb:63: > > 43) > NoMethodError in 'A new user should require password' > undefined method `should_not_change' for > # > ./spec/models/authenticated_base_spec.rb:68: > > 44) > NoMethodError in 'A new user should require password confirmation' > undefined method `should_not_change' for > # > ./spec/models/authenticated_base_spec.rb:73: > > 45) > NoMethodError in 'A new user should require email' > undefined method `should_not_change' for > # > ./spec/models/authenticated_base_spec.rb:78: > > 46) > ActiveRecord::StatementInvalid in 'A User should have valid associations' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/user_spec.rb:7:in `new' > ./spec/models/user_spec.rb:7: > > 47) > ActiveRecord::StatementInvalid in 'A User should protect against updates to > secure attributes' > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > FROM users > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > `log' > ./spec/models/user_spec.rb:7:in `new' > ./spec/models/user_spec.rb:7: > > 48) > NoMethodError in '/assets/edit.rhtml should render edit form' > undefined method `should_have_tag' for > # > ./spec/views/assets/edit_rhtml_spec.rb:36: > > 49) > NoMethodError in '/assets/index.rhtml should render list of assets' > undefined method `should_have_tag' for > # > ./spec/views/assets/index_rhtml_spec.rb:49: > > 50) > NoMethodError in '/assets/new.rhtml should render new form' > undefined method `should_have_tag' for > # > ./spec/views/assets/new_rhtml_spec.rb:39: > > 51) > NoMethodError in '/users/edit.rhtml should render edit form' > undefined method `should_have_tag' for > # > ./spec/views/users/edit_rhtml_spec.rb:21: > > 52) > NameError in '/users/new.rhtml should render new form' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/views/users/new_rhtml_spec.rb:10: > > 53) > NameError in '/users/show.rhtml should render attributes in

' > undefined local variable or method `mock_user' for [Dynamically generated > class for RSpec example]:# > ./spec/views/users/show_rhtml_spec.rb:7: > > Finished in 2.492637 seconds > > 117 examples, 53 failures > From court3nay at gmail.com Sat May 26 17:28:44 2007 From: court3nay at gmail.com (Courtenay) Date: Sat, 26 May 2007 14:28:44 -0700 Subject: [rspec-users] RSpec In-Reply-To: <8d961d900705260938n539dba57k4de53a995b76f68f@mail.gmail.com> References: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> <8d961d900705260901h3e86b4cauacba95be7c0ebc11@mail.gmail.com> <8d961d900705260938n539dba57k4de53a995b76f68f@mail.gmail.com> Message-ID: <4b430c8f0705261428w17b88a2bwb2d2e8b7fab4b451@mail.gmail.com> Heh. The author is lazy and hasn't upgraded his sample apps to latest rspec. Also, you didn't load the database schema; rake db:migrate Patches are, of course, always welcome. Courtenay (the lazy author) http://blog.caboo.se On 5/26/07, aslak hellesoy wrote: > The app you downloaded is not compatible with rspec 1.0. Please > contact the app authors or upgrade it yourself. See upgrading on the > rspec website. > > On 5/26/07, Omen King wrote: > > So I can run rake spec. I've gotten errors and I not too sure what I'm > > looking at. > > > > Lets take a look at error 1: > > =================================================== > > specify "should render new" do > > controller.should_render :new > > get :new > > end > > > > 1) > > NoMethodError in '/session/new GET should render new' > > undefined method `should_render' for # > > ./spec/controllers/session_controller_spec.rb:7: > > =================================================== > > Is it trying to called a method called 'should_render' for > > session_controller of session_controller_spec? > > > > 2) > > NameError in '/session POST without remember me should authenticate user' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:15: > > > > 3) > > NameError in '/session POST without remember me should login user' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:15: > > > > 4) > > NameError in '/session POST without remember me should not remember me' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:15: > > > > 5) > > NameError in '/session POST without remember me should redirect to root' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:15: > > > > 6) > > NameError in '/session POST with remember me should remember me' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:44: > > > > 7) > > NameError in '/session POST with remember me should create cookie' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:44: > > > > 8) > > NameError in '/session POST when invalid should authenticate user' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:72: > > > > 9) > > NameError in '/session POST when invalid should login user' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:72: > > > > 10) > > NameError in '/session POST when invalid should not remember me' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:72: > > > > 11) > > NameError in '/session POST when invalid should render new' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:72: > > > > 12) > > NameError in '/session DELETE should get current user' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:102: > > > > 13) > > NameError in '/session DELETE should forget current user' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:102: > > > > 14) > > NameError in '/session DELETE should delete token on logout' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:102: > > > > 15) > > NameError in '/session DELETE should reset session' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:102: > > > > 16) > > NameError in '/session DELETE should redirect to root' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/controllers/session_controller_spec.rb:102: > > > > 17) > > NoMethodError in 'Requesting /assets using GET should render index.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/user_assets_controller_spec.rb:25: > > > > 18) > > NoMethodError in 'Requesting /assets/1 using GET should render show.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/user_assets_controller_spec.rb:93: > > > > 19) > > NoMethodError in 'Requesting /assets/new using GET should render new.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/user_assets_controller_spec.rb:159: > > > > 20) > > NoMethodError in 'Requesting /assets/1;edit using GET should render > > edit.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/user_assets_controller_spec.rb:201: > > > > 21) > > NoMethodError in 'Requesting /users using GET should render index.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/users_controller_spec.rb:49: > > > > 22) > > NoMethodError in 'Requesting /users/1 using GET should render show.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/users_controller_spec.rb:112: > > > > 23) > > NoMethodError in 'Requesting /users/new using GET should render new.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/users_controller_spec.rb:175: > > > > 24) > > ActiveRecord::StatementInvalid in 'Requesting /users/1;edit using GET should > > fail if current user doesn't match' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/controllers/users_controller_spec.rb:209:in `new' > > ./spec/controllers/users_controller_spec.rb:209: > > > > 25) > > NoMethodError in 'Requesting /users/1;edit using GET should render > > edit.rhtml' > > undefined method `should_render' for # > > ./spec/controllers/users_controller_spec.rb:221: > > > > 26) > > NoMethodError in 'the UserAssetsHelper should return user login name' > > undefined method `should_eql' for "JoeLogin":String > > ./spec/helpers/user_assets_helper_spec.rb:11: > > > > 27) > > NameError in 'the generated url helpers for UserAssetsController should > > return assets path given no arguments' > > undefined local variable or method `controller' for [Dynamically generated > > class for RSpec example]:# > > (eval):2:in `assets_path' > > ./spec/helpers/user_assets_url_helpers_spec.rb:24: > > > > 28) > > NameError in 'the generated url helpers for UserAssetsController should > > return assets path given explicit argument' > > undefined local variable or method `controller' for [Dynamically generated > > class for RSpec example]:# > > (eval):2:in `assets_path' > > ./spec/helpers/user_assets_url_helpers_spec.rb:28: > > > > 29) > > NameError in 'the generated url helpers for UserAssetsController should > > return asset path' > > undefined local variable or method `controller' for [Dynamically generated > > class for RSpec example]:# > > (eval):2:in `asset_path' > > ./spec/helpers/user_assets_url_helpers_spec.rb:32: > > > > 30) > > NameError in 'the generated url helpers for UserAssetsController should > > return edit_asset path' > > undefined local variable or method `controller' for [Dynamically generated > > class for RSpec example]:# > > (eval):2:in `edit_asset_path' > > ./spec/helpers/user_assets_url_helpers_spec.rb:36: > > > > 31) > > NameError in 'the generated url helpers for UserAssetsController should > > return new_asset path' > > undefined local variable or method `controller' for [Dynamically generated > > class for RSpec example]:# > > (eval):2:in `new_asset_path' > > ./spec/helpers/user_assets_url_helpers_spec.rb:40: > > > > 32) > > NameError in 'the generated url helpers for UserAssetsController should > > return asset_attachable path' > > undefined local variable or method `controller' for [Dynamically generated > > class for RSpec example]:# > > (eval):2:in `asset_attachable_path' > > ./spec/helpers/user_assets_url_helpers_spec.rb:44: > > > > 33) > > ActiveRecord::StatementInvalid in 'Given a generated asset_spec.rb with > > fixtures loaded fixtures should load two Assets' > > ActiveRecord::StatementInvalid: Mysql::Error: #42S02Table > > 'sample_test.assets' doesn't exist: DELETE FROM assets: DELETE FROM assets > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > /Users/multimedia/Desktop/rest_org/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/model.rb:12:in > > `before_eval' > > > > 34) > > ActiveRecord::StatementInvalid in 'A User abstract class should have valid > > associations' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/authenticated_base_spec.rb:7:in `new' > > ./spec/models/authenticated_base_spec.rb:7: > > > > 35) > > ActiveRecord::StatementInvalid in 'An existing user should authenticate with > > new or reset password' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/authenticated_base_spec.rb:14: > > > > 36) > > ActiveRecord::StatementInvalid in 'An existing user should not rehash > > password on login change' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/authenticated_base_spec.rb:14: > > > > 37) > > ActiveRecord::StatementInvalid in 'An existing user should remember token' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/authenticated_base_spec.rb:14: > > > > 38) > > ActiveRecord::StatementInvalid in 'An existing user should increment hit > > counter' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/authenticated_base_spec.rb:14: > > > > 39) > > ActiveRecord::StatementInvalid in 'An existing user should forget token' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/authenticated_base_spec.rb:14: > > > > 40) > > ActiveRecord::StatementInvalid in 'An existing user should be remembered for > > a period' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/authenticated_base_spec.rb:14: > > > > 41) > > NoMethodError in 'A new user should create' > > undefined method `should_change' for > > # > > ./spec/models/authenticated_base_spec.rb:59: > > > > 42) > > NoMethodError in 'A new user should require login' > > undefined method `should_not_change' for > > # > > ./spec/models/authenticated_base_spec.rb:63: > > > > 43) > > NoMethodError in 'A new user should require password' > > undefined method `should_not_change' for > > # > > ./spec/models/authenticated_base_spec.rb:68: > > > > 44) > > NoMethodError in 'A new user should require password confirmation' > > undefined method `should_not_change' for > > # > > ./spec/models/authenticated_base_spec.rb:73: > > > > 45) > > NoMethodError in 'A new user should require email' > > undefined method `should_not_change' for > > # > > ./spec/models/authenticated_base_spec.rb:78: > > > > 46) > > ActiveRecord::StatementInvalid in 'A User should have valid associations' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/user_spec.rb:7:in `new' > > ./spec/models/user_spec.rb:7: > > > > 47) > > ActiveRecord::StatementInvalid in 'A User should protect against updates to > > secure attributes' > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW FIELDS > > FROM users > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > `log' > > ./spec/models/user_spec.rb:7:in `new' > > ./spec/models/user_spec.rb:7: > > > > 48) > > NoMethodError in '/assets/edit.rhtml should render edit form' > > undefined method `should_have_tag' for > > # > > ./spec/views/assets/edit_rhtml_spec.rb:36: > > > > 49) > > NoMethodError in '/assets/index.rhtml should render list of assets' > > undefined method `should_have_tag' for > > # > > ./spec/views/assets/index_rhtml_spec.rb:49: > > > > 50) > > NoMethodError in '/assets/new.rhtml should render new form' > > undefined method `should_have_tag' for > > # > > ./spec/views/assets/new_rhtml_spec.rb:39: > > > > 51) > > NoMethodError in '/users/edit.rhtml should render edit form' > > undefined method `should_have_tag' for > > # > > ./spec/views/users/edit_rhtml_spec.rb:21: > > > > 52) > > NameError in '/users/new.rhtml should render new form' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/views/users/new_rhtml_spec.rb:10: > > > > 53) > > NameError in '/users/show.rhtml should render attributes in

' > > undefined local variable or method `mock_user' for [Dynamically generated > > class for RSpec example]:# > > ./spec/views/users/show_rhtml_spec.rb:7: > > > > Finished in 2.492637 seconds > > > > 117 examples, 53 failures > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From omen.king at gmail.com Sat May 26 17:54:40 2007 From: omen.king at gmail.com (Omen King) Date: Sat, 26 May 2007 17:54:40 -0400 Subject: [rspec-users] RSpec In-Reply-To: <4b430c8f0705261428w17b88a2bwb2d2e8b7fab4b451@mail.gmail.com> References: <8d961d900705260304n5fe70858mf39aef06d648328@mail.gmail.com> <8d961d900705260901h3e86b4cauacba95be7c0ebc11@mail.gmail.com> <8d961d900705260938n539dba57k4de53a995b76f68f@mail.gmail.com> <4b430c8f0705261428w17b88a2bwb2d2e8b7fab4b451@mail.gmail.com> Message-ID: He's really lazy, I've updated the spec_helper.rb and translated the spec. I'm getting different errors now such as: 1) NoMethodError in 'Requesting /assets/1;edit using GET should render edit.rhtml' undefined method `render?' for # ./spec/controllers/user_assets_controller_spec.rb:201: and 5) NoMethodError in '/users/edit.rhtml should render edit form' undefined method `matches?' for # ./spec/views/users/edit_rhtml_spec.rb:21: I'm not too certain why it isn't seeing matches but I'll have to do more digging. I love caboo.se! On 5/26/07, Courtenay wrote: > > Heh. The author is lazy and hasn't upgraded his sample apps to latest > rspec. > Also, you didn't load the database schema; > > rake db:migrate > > Patches are, of course, always welcome. > > Courtenay (the lazy author) > http://blog.caboo.se > > > On 5/26/07, aslak hellesoy wrote: > > The app you downloaded is not compatible with rspec 1.0. Please > > contact the app authors or upgrade it yourself. See upgrading on the > > rspec website. > > > > On 5/26/07, Omen King wrote: > > > So I can run rake spec. I've gotten errors and I not too sure what I'm > > > looking at. > > > > > > Lets take a look at error 1: > > > =================================================== > > > specify "should render new" do > > > controller.should_render :new > > > get :new > > > end > > > > > > 1) > > > NoMethodError in '/session/new GET should render new' > > > undefined method `should_render' for # > > > ./spec/controllers/session_controller_spec.rb:7: > > > =================================================== > > > Is it trying to called a method called 'should_render' for > > > session_controller of session_controller_spec? > > > > > > 2) > > > NameError in '/session POST without remember me should authenticate > user' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:15: > > > > > > 3) > > > NameError in '/session POST without remember me should login user' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:15: > > > > > > 4) > > > NameError in '/session POST without remember me should not remember > me' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:15: > > > > > > 5) > > > NameError in '/session POST without remember me should redirect to > root' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:15: > > > > > > 6) > > > NameError in '/session POST with remember me should remember me' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:44: > > > > > > 7) > > > NameError in '/session POST with remember me should create cookie' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:44: > > > > > > 8) > > > NameError in '/session POST when invalid should authenticate user' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:72: > > > > > > 9) > > > NameError in '/session POST when invalid should login user' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:72: > > > > > > 10) > > > NameError in '/session POST when invalid should not remember me' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:72: > > > > > > 11) > > > NameError in '/session POST when invalid should render new' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:72: > > > > > > 12) > > > NameError in '/session DELETE should get current user' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:102: > > > > > > 13) > > > NameError in '/session DELETE should forget current user' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:102: > > > > > > 14) > > > NameError in '/session DELETE should delete token on logout' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:102: > > > > > > 15) > > > NameError in '/session DELETE should reset session' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:102: > > > > > > 16) > > > NameError in '/session DELETE should redirect to root' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/controllers/session_controller_spec.rb:102: > > > > > > 17) > > > NoMethodError in 'Requesting /assets using GET should render > index.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/user_assets_controller_spec.rb:25: > > > > > > 18) > > > NoMethodError in 'Requesting /assets/1 using GET should render > show.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/user_assets_controller_spec.rb:93: > > > > > > 19) > > > NoMethodError in 'Requesting /assets/new using GET should render > new.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/user_assets_controller_spec.rb:159: > > > > > > 20) > > > NoMethodError in 'Requesting /assets/1;edit using GET should render > > > edit.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/user_assets_controller_spec.rb:201: > > > > > > 21) > > > NoMethodError in 'Requesting /users using GET should render > index.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/users_controller_spec.rb:49: > > > > > > 22) > > > NoMethodError in 'Requesting /users/1 using GET should render > show.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/users_controller_spec.rb:112: > > > > > > 23) > > > NoMethodError in 'Requesting /users/new using GET should render > new.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/users_controller_spec.rb:175: > > > > > > 24) > > > ActiveRecord::StatementInvalid in 'Requesting /users/1;edit using GET > should > > > fail if current user doesn't match' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/controllers/users_controller_spec.rb:209:in `new' > > > ./spec/controllers/users_controller_spec.rb:209: > > > > > > 25) > > > NoMethodError in 'Requesting /users/1;edit using GET should render > > > edit.rhtml' > > > undefined method `should_render' for # > > > ./spec/controllers/users_controller_spec.rb:221: > > > > > > 26) > > > NoMethodError in 'the UserAssetsHelper should return user login name' > > > undefined method `should_eql' for "JoeLogin":String > > > ./spec/helpers/user_assets_helper_spec.rb:11: > > > > > > 27) > > > NameError in 'the generated url helpers for UserAssetsController > should > > > return assets path given no arguments' > > > undefined local variable or method `controller' for [Dynamically > generated > > > class for RSpec example]:# > > > (eval):2:in `assets_path' > > > ./spec/helpers/user_assets_url_helpers_spec.rb:24: > > > > > > 28) > > > NameError in 'the generated url helpers for UserAssetsController > should > > > return assets path given explicit argument' > > > undefined local variable or method `controller' for [Dynamically > generated > > > class for RSpec example]:# > > > (eval):2:in `assets_path' > > > ./spec/helpers/user_assets_url_helpers_spec.rb:28: > > > > > > 29) > > > NameError in 'the generated url helpers for UserAssetsController > should > > > return asset path' > > > undefined local variable or method `controller' for [Dynamically > generated > > > class for RSpec example]:# > > > (eval):2:in `asset_path' > > > ./spec/helpers/user_assets_url_helpers_spec.rb:32: > > > > > > 30) > > > NameError in 'the generated url helpers for UserAssetsController > should > > > return edit_asset path' > > > undefined local variable or method `controller' for [Dynamically > generated > > > class for RSpec example]:# > > > (eval):2:in `edit_asset_path' > > > ./spec/helpers/user_assets_url_helpers_spec.rb:36: > > > > > > 31) > > > NameError in 'the generated url helpers for UserAssetsController > should > > > return new_asset path' > > > undefined local variable or method `controller' for [Dynamically > generated > > > class for RSpec example]:# > > > (eval):2:in `new_asset_path' > > > ./spec/helpers/user_assets_url_helpers_spec.rb:40: > > > > > > 32) > > > NameError in 'the generated url helpers for UserAssetsController > should > > > return asset_attachable path' > > > undefined local variable or method `controller' for [Dynamically > generated > > > class for RSpec example]:# > > > (eval):2:in `asset_attachable_path' > > > ./spec/helpers/user_assets_url_helpers_spec.rb:44: > > > > > > 33) > > > ActiveRecord::StatementInvalid in 'Given a generated asset_spec.rb > with > > > fixtures loaded fixtures should load two Assets' > > > ActiveRecord::StatementInvalid: Mysql::Error: #42S02Table > > > 'sample_test.assets' doesn't exist: DELETE FROM assets: DELETE FROM > assets > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > > /Users/multimedia/Desktop/rest_org/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/model.rb:12:in > > > `before_eval' > > > > > > 34) > > > ActiveRecord::StatementInvalid in 'A User abstract class should have > valid > > > associations' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/authenticated_base_spec.rb:7:in `new' > > > ./spec/models/authenticated_base_spec.rb:7: > > > > > > 35) > > > ActiveRecord::StatementInvalid in 'An existing user should > authenticate with > > > new or reset password' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/authenticated_base_spec.rb:14: > > > > > > 36) > > > ActiveRecord::StatementInvalid in 'An existing user should not rehash > > > password on login change' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/authenticated_base_spec.rb:14: > > > > > > 37) > > > ActiveRecord::StatementInvalid in 'An existing user should remember > token' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/authenticated_base_spec.rb:14: > > > > > > 38) > > > ActiveRecord::StatementInvalid in 'An existing user should increment > hit > > > counter' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/authenticated_base_spec.rb:14: > > > > > > 39) > > > ActiveRecord::StatementInvalid in 'An existing user should forget > token' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/authenticated_base_spec.rb:14: > > > > > > 40) > > > ActiveRecord::StatementInvalid in 'An existing user should be > remembered for > > > a period' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/authenticated_base_spec.rb:14: > > > > > > 41) > > > NoMethodError in 'A new user should create' > > > undefined method `should_change' for > > > # > > > ./spec/models/authenticated_base_spec.rb:59: > > > > > > 42) > > > NoMethodError in 'A new user should require login' > > > undefined method `should_not_change' for > > > # > > > ./spec/models/authenticated_base_spec.rb:63: > > > > > > 43) > > > NoMethodError in 'A new user should require password' > > > undefined method `should_not_change' for > > > # > > > ./spec/models/authenticated_base_spec.rb:68: > > > > > > 44) > > > NoMethodError in 'A new user should require password confirmation' > > > undefined method `should_not_change' for > > > # > > > ./spec/models/authenticated_base_spec.rb:73: > > > > > > 45) > > > NoMethodError in 'A new user should require email' > > > undefined method `should_not_change' for > > > # > > > ./spec/models/authenticated_base_spec.rb:78: > > > > > > 46) > > > ActiveRecord::StatementInvalid in 'A User should have valid > associations' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/user_spec.rb:7:in `new' > > > ./spec/models/user_spec.rb:7: > > > > > > 47) > > > ActiveRecord::StatementInvalid in 'A User should protect against > updates to > > > secure attributes' > > > Mysql::Error: #42S02Table 'sample_test.users' doesn't exist: SHOW > FIELDS > > > FROM users > > > > /Users/multimedia/Desktop/rest_org/config/../lib/ar_extensions.rb:27:in > > > `log' > > > ./spec/models/user_spec.rb:7:in `new' > > > ./spec/models/user_spec.rb:7: > > > > > > 48) > > > NoMethodError in '/assets/edit.rhtml should render edit form' > > > undefined method `should_have_tag' for > > > # > > > ./spec/views/assets/edit_rhtml_spec.rb:36: > > > > > > 49) > > > NoMethodError in '/assets/index.rhtml should render list of assets' > > > undefined method `should_have_tag' for > > > # > > > ./spec/views/assets/index_rhtml_spec.rb:49: > > > > > > 50) > > > NoMethodError in '/assets/new.rhtml should render new form' > > > undefined method `should_have_tag' for > > > # > > > ./spec/views/assets/new_rhtml_spec.rb:39: > > > > > > 51) > > > NoMethodError in '/users/edit.rhtml should render edit form' > > > undefined method `should_have_tag' for > > > # > > > ./spec/views/users/edit_rhtml_spec.rb:21: > > > > > > 52) > > > NameError in '/users/new.rhtml should render new form' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/views/users/new_rhtml_spec.rb:10: > > > > > > 53) > > > NameError in '/users/show.rhtml should render attributes in

' > > > undefined local variable or method `mock_user' for [Dynamically > generated > > > class for RSpec example]:# > > > ./spec/views/users/show_rhtml_spec.rb:7: > > > > > > Finished in 2.492637 seconds > > > > > > 117 examples, 53 failures > > > > > _______________________________________________ > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070526/ff1b3d10/attachment-0001.html From francois.beausoleil at gmail.com Sun May 27 08:00:19 2007 From: francois.beausoleil at gmail.com (=?UTF-8?Q?Fran=C3=A7ois_Beausoleil?=) Date: Sun, 27 May 2007 08:00:19 -0400 Subject: [rspec-users] How to mock helpers in view specs ? In-Reply-To: <57c63afe0705250807u54b64d46id46f87648a23d20e@mail.gmail.com> References: <41d5fadf0705170744r2bbee2fane65b97043787501e@mail.gmail.com> <9285597E-6870-4D74-85F6-6FB26907F27D@gmail.com> <41d5fadf0705171246m748f9d93xb538427e5e07a382@mail.gmail.com> <57c63afe0705250807u54b64d46id46f87648a23d20e@mail.gmail.com> Message-ID: <41d5fadf0705270500s5b6d20eag15aff635467858c7@mail.gmail.com> 2007/5/25, David Chelimsky : > On 5/17/07, Fran?ois Beausoleil wrote: > > http://rspec.rubyforge.org/documentation/rails/writing/views.html > > There is. Scroll down. Well, I'm sorry about that. Thanks for pointing my error :) Bye ! -- Fran?ois Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ From anibal at rojas.com.ve Sun May 27 10:45:53 2007 From: anibal at rojas.com.ve (=?ISO-8859-1?Q?An=EDbal_Rojas?=) Date: Sun, 27 May 2007 10:45:53 -0400 Subject: [rspec-users] annotate_models plugin to annotate RSpec specs and fixture Message-ID: I have found useful to have the table information associated to models disp?ayed in the models and fixtures files of my rails applications. If you want to add this information to the spec_fixtures and specs add the following patch to your plugin. Index: vendor/plugins/annotate_models/lib/annotate_models.rb =================================================================== --- vendor/plugins/annotate_models/lib/annotate_models.rb (revision 45) +++ vendor/plugins/annotate_models/lib/annotate_models.rb (working copy) @@ -1,7 +1,8 @@ require "config/environment" MODEL_DIR = File.join(RAILS_ROOT, "app/models") -FIXTURE_DIR = File.join(RAILS_ROOT, "test/fixtures") +SPEC_DIR = File.join(RAILS_ROOT, "spec/models") +FIXTURE_DIR = File.join(RAILS_ROOT, "spec/fixtures") module AnnotateModels @@ -75,6 +76,9 @@ model_file_name = File.join(MODEL_DIR, klass.name.underscore + ".rb") annotate_one_file(model_file_name, info) + spec_file_name = File.join(SPEC_DIR, klass.name.underscore + "_spec.rb") + annotate_one_file(spec_file_name, info) + fixture_file_name = File.join(FIXTURE_DIR, klass.table_name + ".yml") annotate_one_file(fixture_file_name, info) end -- An?bal Rojas http://www.rubycorner.com http://www.hasmanydevelopers.com From omen.king at gmail.com Sun May 27 11:11:59 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 27 May 2007 11:11:59 -0400 Subject: [rspec-users] annotate_models plugin to annotate RSpec specs and fixture In-Reply-To: References: Message-ID: Good timing, I was just thinking that annotate would be more useful in my models and fixtures. On 5/27/07, An?bal Rojas wrote: > > I have found useful to have the table information associated to models > disp?ayed in the models and fixtures files of my rails applications. > If you want to add this information to the spec_fixtures and specs add > the following patch to your plugin. > > Index: vendor/plugins/annotate_models/lib/annotate_models.rb > =================================================================== > --- vendor/plugins/annotate_models/lib/annotate_models.rb (revision > 45) > +++ vendor/plugins/annotate_models/lib/annotate_models.rb (working > copy) > @@ -1,7 +1,8 @@ > require "config/environment" > > MODEL_DIR = File.join(RAILS_ROOT, "app/models") > -FIXTURE_DIR = File.join(RAILS_ROOT, "test/fixtures") > +SPEC_DIR = File.join(RAILS_ROOT, "spec/models") > +FIXTURE_DIR = File.join(RAILS_ROOT, "spec/fixtures") > > module AnnotateModels > > @@ -75,6 +76,9 @@ > model_file_name = File.join(MODEL_DIR, klass.name.underscore + ".rb") > annotate_one_file(model_file_name, info) > > + spec_file_name = File.join(SPEC_DIR, klass.name.underscore + > "_spec.rb") > + annotate_one_file(spec_file_name, info) > + > fixture_file_name = File.join(FIXTURE_DIR, klass.table_name + ".yml") > annotate_one_file(fixture_file_name, info) > end > > -- > An?bal Rojas > http://www.rubycorner.com > http://www.hasmanydevelopers.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: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/d0e3b58a/attachment.html From omen.king at gmail.com Sun May 27 11:15:42 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 27 May 2007 11:15:42 -0400 Subject: [rspec-users] [NoMethodError] simple problem Message-ID: I think this test should pass but it doesn't 1) NoMethodError in 'Person should return full name' undefined method `full_name?' for # ./spec/models/person_spec.rb:43: describe Person do it "should return full name" do person = Person.new person.should be_full_name end end class Person < ActiveRecord::Base def full_name true end end -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/18efd0c1/attachment.html From dchelimsky at gmail.com Sun May 27 11:39:31 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 May 2007 10:39:31 -0500 Subject: [rspec-users] [NoMethodError] simple problem In-Reply-To: References: Message-ID: <57c63afe0705270839lb61b005qa0aea511191384d2@mail.gmail.com> On 5/27/07, Andrew WC Brown wrote: > I think this test should pass but it doesn't > > 1) > NoMethodError in 'Person should return full name' > undefined method `full_name?' for # > ./spec/models/person_spec.rb:43: > > describe Person do > it "should return full name" do > person = Person.new > person.should be_full_name > end > end > > class Person < ActiveRecord::Base > def full_name > true > end > end The error message says that what is missing is full_name?, not full_name. Try this: class Person < ActiveRecord::Base def full_name? true end end From omen.king at gmail.com Sun May 27 11:49:54 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 27 May 2007 11:49:54 -0400 Subject: [rspec-users] [NoMethodError] simple problem In-Reply-To: <57c63afe0705270839lb61b005qa0aea511191384d2@mail.gmail.com> References: <57c63afe0705270839lb61b005qa0aea511191384d2@mail.gmail.com> Message-ID: Oh it all just clicked. What I wanted to do was: def full_name [first_name, last_name].join(' ') end it "should return full name" do person = Person.create(:first_name => "Andrew",:last_name => "Brown") person.full_name.should eql("Andrew Brown") end Still getting use to RSpec but I'm loving it. On 5/27/07, David Chelimsky wrote: > > On 5/27/07, Andrew WC Brown wrote: > > I think this test should pass but it doesn't > > > > 1) > > NoMethodError in 'Person should return full name' > > undefined method `full_name?' for # > > ./spec/models/person_spec.rb:43: > > > > describe Person do > > it "should return full name" do > > person = Person.new > > person.should be_full_name > > end > > end > > > > class Person < ActiveRecord::Base > > def full_name > > true > > end > > end > > The error message says that what is missing is full_name?, not > full_name. Try this: > > class Person < ActiveRecord::Base > def full_name? > true > end > end > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/e5496ad3/attachment.html From dchelimsky at gmail.com Sun May 27 11:52:43 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 May 2007 10:52:43 -0500 Subject: [rspec-users] [NoMethodError] simple problem In-Reply-To: References: <57c63afe0705270839lb61b005qa0aea511191384d2@mail.gmail.com> Message-ID: <57c63afe0705270852q55880578q24afb7b0346d28a4@mail.gmail.com> On 5/27/07, Andrew WC Brown wrote: > Oh it all just clicked. > What I wanted to do was: > > def full_name > [first_name, last_name].join(' ') > end > > it "should return full name" do > person = Person.create(:first_name => "Andrew",:last_name => "Brown") > person.full_name.should eql("Andrew Brown") > end FYI - this will run faster if you use Person.new, which doesn't save the database record. May seem trivial on one spec, but as they multiply, this sort of thing can make a big difference. > > Still getting use to RSpec but I'm loving it. > > > On 5/27/07, David Chelimsky wrote: > > > > On 5/27/07, Andrew WC Brown < omen.king at gmail.com> wrote: > > > I think this test should pass but it doesn't > > > > > > 1) > > > NoMethodError in 'Person should return full name' > > > undefined method `full_name?' for # > > > ./spec/models/person_spec.rb:43: > > > > > > describe Person do > > > it "should return full name" do > > > person = Person.new > > > person.should be_full_name > > > end > > > end > > > > > > class Person < ActiveRecord::Base > > > def full_name > > > true > > > end > > > end > > > > The error message says that what is missing is full_name?, not > > full_name. Try this: > > > > class Person < ActiveRecord::Base > > def full_name? > > true > > end > > end > > _______________________________________________ > > 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 omen.king at gmail.com Sun May 27 14:58:17 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 27 May 2007 14:58:17 -0400 Subject: [rspec-users] Checking for Range Message-ID: how would you check for a range using rspec? person.password.range.should == Range.new(5..40) <- this doesn't work -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/4d8cb007/attachment-0001.html From dchelimsky at gmail.com Sun May 27 15:03:40 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 May 2007 14:03:40 -0500 Subject: [rspec-users] Checking for Range In-Reply-To: References: Message-ID: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> On 5/27/07, Andrew WC Brown wrote: > how would you check for a range using rspec? > > person.password.range.should == Range.new(5..40) <- this doesn't work The correct ruby syntax is Range.new(5, 40). So this should work: person.password.range.should == Range.new(5, 40) Cheers, David From dchelimsky at gmail.com Sun May 27 15:06:01 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 May 2007 14:06:01 -0500 Subject: [rspec-users] Checking for Range In-Reply-To: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> Message-ID: <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> On 5/27/07, David Chelimsky wrote: > On 5/27/07, Andrew WC Brown wrote: > > how would you check for a range using rspec? > > > > person.password.range.should == Range.new(5..40) <- this doesn't work > > The correct ruby syntax is Range.new(5, 40). So this should work: > > person.password.range.should == Range.new(5, 40) OR .... person.password.range.should == (5..40) #shortcut for Range.new(5, 40) > > Cheers, > David > From omen.king at gmail.com Sun May 27 15:31:45 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 27 May 2007 15:31:45 -0400 Subject: [rspec-users] Checking for Range In-Reply-To: <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> Message-ID: Well I get error as such: 1) NoMethodError in 'Person should require a password within the range of 5..40 characters' undefined method `range' for "ruby_tuesday":String ./spec/models/person_spec.rb:43: and I have a feeling that they're right when they say string doesn't have a range method. I thought this would work: person.password.length.should == (5..40) but doesn't look so 1) ArgumentError in 'Person should require a password within the range of 5..40 characters' wrong number of arguments (1 for 2) ./spec/models/person_spec.rb:43:in `initialize' ./spec/models/person_spec.rb:43:in `new' ./spec/models/person_spec.rb:43: On 5/27/07, David Chelimsky wrote: > > On 5/27/07, David Chelimsky wrote: > > On 5/27/07, Andrew WC Brown wrote: > > > how would you check for a range using rspec? > > > > > > person.password.range.should == Range.new(5..40) <- this doesn't work > > > > The correct ruby syntax is Range.new(5, 40). So this should work: > > > > person.password.range.should == Range.new(5, 40) > > OR .... > > person.password.range.should == (5..40) #shortcut for Range.new(5, 40) > > > > > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/6e148572/attachment.html From dchelimsky at gmail.com Sun May 27 15:39:39 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 May 2007 14:39:39 -0500 Subject: [rspec-users] Checking for Range In-Reply-To: References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> Message-ID: <57c63afe0705271239i5be0c90ai512bddb6cfa21f4a@mail.gmail.com> On 5/27/07, Andrew WC Brown wrote: > Well I get error as such: > > 1) > NoMethodError in 'Person should require a password within the range of 5..40 > characters' > undefined method `range' for "ruby_tuesday":String > ./spec/models/person_spec.rb:43: > > and I have a feeling that they're right when they say string doesn't have a > range method. > > I thought this would work: > person.password.length.should == (5..40) > > but doesn't look so > > 1) > ArgumentError in 'Person should require a password within the range of 5..40 > characters' > wrong number of arguments (1 for 2) > ./spec/models/person_spec.rb:43:in `initialize' > ./spec/models/person_spec.rb:43:in `new' > ./spec/models/person_spec.rb:43: OK. I should have asked for the backtrace first. It's generally a good idea to include backtraces rather than just saying "it doesn't work". "Person should require a password within the range of 5..40" suggests to me that you should have several examples: Person should require password length between 5 and 40 - should not accept a password of length 4 - should accept a password of length 5 - should accept a password of length 40 - should not accept a password of length 41 Make sense? > > > > > On 5/27/07, David Chelimsky wrote: > > > > On 5/27/07, David Chelimsky wrote: > > > On 5/27/07, Andrew WC Brown wrote: > > > > how would you check for a range using rspec? > > > > > > > > person.password.range.should == Range.new(5..40) <- this doesn't work > > > > > > The correct ruby syntax is Range.new(5, 40). So this should work: > > > > > > person.password.range.should == Range.new(5, 40) > > > > OR .... > > > > person.password.range.should == (5..40) #shortcut for Range.new(5, 40) > > > > > > > > > > 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 > From sam.maillists at googlemail.com Sun May 27 15:41:33 2007 From: sam.maillists at googlemail.com (Sam Aaron) Date: Sun, 27 May 2007 20:41:33 +0100 Subject: [rspec-users] Checking for Range In-Reply-To: References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> Message-ID: On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote: > > I thought this would work: > person.password.length.should == (5..40) > I think that in this case, you want to use the === operator when comparing a number with a range. Instead of trying to see if both of the objects (the number and the range) are the same, the === operator checks to see if the number is within the range. Also, make sure you surround your range with parenthesis (which you are already doing), and put the range on the left hand side of the === operator for it to work. Have a look at this quick irb session for an example of what I mean: >> (10..50) == 15 => false >> (10..50) === 15 => true >> 10..50 === 15 ArgumentError: bad value for range from (irb):6 >> 15 === 10..50 ArgumentError: bad value for range from (irb):7 >> 15 === (10..50) => false >> Hope this helps, Sam --- http://sam.aaron.name From omen.king at gmail.com Sun May 27 16:17:35 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 27 May 2007 16:17:35 -0400 Subject: [rspec-users] Checking for Range In-Reply-To: References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> Message-ID: it "should require a password within the range of 5..40 characters" do person = create(:last_name => "ruby_tuesday") person.password.should_not be_nil (5..40) === person.password.length.should end Its true, it really works, tell all your friends! On 5/27/07, Sam Aaron wrote: > > > On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote: > > > > I thought this would work: > > person.password.length.should == (5..40) > > > > I think that in this case, you want to use the === operator when > comparing a number with a range. Instead of trying to see if both of > the objects (the number and the range) are the same, the === operator > checks to see if the number is within the range. > > Also, make sure you surround your range with parenthesis (which you > are already doing), and put the range on the left hand side of the > === operator for it to work. Have a look at this quick irb session > for an example of what I mean: > > >> (10..50) == 15 > => false > >> (10..50) === 15 > => true > >> 10..50 === 15 > ArgumentError: bad value for range > from (irb):6 > >> 15 === 10..50 > ArgumentError: bad value for range > from (irb):7 > >> 15 === (10..50) > => false > >> > > Hope this helps, > > Sam > > --- > http://sam.aaron.name > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/188c97e6/attachment.html From dchelimsky at gmail.com Sun May 27 16:25:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 27 May 2007 15:25:10 -0500 Subject: [rspec-users] Checking for Range In-Reply-To: References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> Message-ID: <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> On 5/27/07, Andrew WC Brown wrote: > it "should require a password within the range of 5..40 characters" do > person = create(:last_name => "ruby_tuesday") > person.password.should_not be_nil > (5..40) === person.password.length.should > end > > Its true, it really works, tell all your friends! How does that verify that a person will reject a password length of 4 or 41? > > > On 5/27/07, Sam Aaron wrote: > > > > On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote: > > > > > > I thought this would work: > > > person.password.length.should == (5..40) > > > > > > > I think that in this case, you want to use the === operator when > > comparing a number with a range. Instead of trying to see if both of > > the objects (the number and the range) are the same, the === operator > > checks to see if the number is within the range. > > > > Also, make sure you surround your range with parenthesis (which you > > are already doing), and put the range on the left hand side of the > > === operator for it to work. Have a look at this quick irb session > > for an example of what I mean: > > > > >> (10..50) == 15 > > => false > > >> (10..50) === 15 > > => true > > >> 10..50 === 15 > > ArgumentError: bad value for range > > from (irb):6 > > >> 15 === 10..50 > > ArgumentError: bad value for range > > from (irb):7 > > >> 15 === (10..50) > > => false > > >> > > > > Hope this helps, > > > > Sam > > > > --- > > http://sam.aaron.name > > > > > > _______________________________________________ > > 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 joshknowles at gmail.com Sun May 27 17:40:21 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Sun, 27 May 2007 14:40:21 -0700 Subject: [rspec-users] Checking for Range In-Reply-To: <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> Message-ID: On 5/27/07, David Chelimsky wrote: > > > > How does that verify that a person will reject a password length of 4 or > 41? I have compiled a collection of rspec matchers to be used when testing rails validations: http://svn.integrumtech.com/public/plugins/rspec_on_rails_matchers If you use this library then you would spec out the password length as follows: it do @user.should validate_length_of(:password, 5..40) end Behind the scenes this matcher attempts to set the password to a value outside of the range and then calls valid? I obviously need to finish this plugin, and get it properly documented, but in the mean time comments/suggestions welcome/ Josh -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/085c9e16/attachment-0001.html From nick at ekenosen.net Sun May 27 17:58:58 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Sun, 27 May 2007 17:58:58 -0400 Subject: [rspec-users] Specs for code stored in rails_app/lib/ In-Reply-To: References: <57c63afe0705240135x1dc27fd1g95d93f11e960d608@mail.gmail.com> <57c63afe0705240253t7e305d3eh7577ad90af28a566@mail.gmail.com> Message-ID: <276ff9870705271458p286aa90ke66d6cde3d1cc968@mail.gmail.com> I've been putting mine directly in the RAILS_ROOT/spec directory: e.g. spec/user_spec_helper.rb, spec/patient_spec_helper.rb. I usually put the require statements into spec/spec_helper.rb. I suppose a case could be made for that being a little bit messy. Perhaps spec/support would be my first choice. -- Nick On 5/24/07, Coda Hale wrote: > On 5/24/07, David Chelimsky wrote: > > I don't think this is too simplistic - as long as the nested dirs > > align in lib and spec/lib, then the regexp matcher will include the > > '/'es, and all will be right with the world. > > > > In truth, I already implemented exactly what you have there (in a > > hurry to get a release out today), but if you file the above in the > > tracker I'll be more than happy to add you to the contributor page. > > A related question -- where do spec support files go? For example, > I've got more than a few one-off matchers and such, and having a > 500-line spec_helper.rb doesn't seem workable. > > I ended up putting mine in /spec/lib, and the specs for /lib files in > /libraries. > > Any ideas? From omen.king at gmail.com Sun May 27 18:34:23 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 27 May 2007 18:34:23 -0400 Subject: [rspec-users] Checking for Range In-Reply-To: <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> Message-ID: I'm testing the validation validates_length_of :password, :within => 5..40 In this case I should be receiving a failure but I'm not :( it "should require a password within the range of 5..40 characters" do person = create(:password => 'a') person.password.should_not be_nil person.should validate_length_of(:password, 5..40) end I'm an amature tester, would you tell me how I should verify? I haven't fully grasped setting testing goals On 5/27/07, David Chelimsky wrote: > > On 5/27/07, Andrew WC Brown wrote: > > it "should require a password within the range of 5..40 characters" do > > person = create(:last_name => "ruby_tuesday") > > person.password.should_not be_nil > > (5..40) === person.password.length.should > > end > > > > Its true, it really works, tell all your friends! > > How does that verify that a person will reject a password length of 4 or > 41? > > > > > > > On 5/27/07, Sam Aaron wrote: > > > > > > On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote: > > > > > > > > I thought this would work: > > > > person.password.length.should == (5..40) > > > > > > > > > > I think that in this case, you want to use the === operator when > > > comparing a number with a range. Instead of trying to see if both of > > > the objects (the number and the range) are the same, the === operator > > > checks to see if the number is within the range. > > > > > > Also, make sure you surround your range with parenthesis (which you > > > are already doing), and put the range on the left hand side of the > > > === operator for it to work. Have a look at this quick irb session > > > for an example of what I mean: > > > > > > >> (10..50) == 15 > > > => false > > > >> (10..50) === 15 > > > => true > > > >> 10..50 === 15 > > > ArgumentError: bad value for range > > > from (irb):6 > > > >> 15 === 10..50 > > > ArgumentError: bad value for range > > > from (irb):7 > > > >> 15 === (10..50) > > > => false > > > >> > > > > > > Hope this helps, > > > > > > Sam > > > > > > --- > > > http://sam.aaron.name > > > > > > > > > _______________________________________________ > > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/ed416647/attachment.html From luislavena at gmail.com Mon May 28 06:55:25 2007 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 28 May 2007 07:55:25 -0300 Subject: [rspec-users] Rails, respond_to? over anonymous module (extend has_many). Message-ID: <71166b3b0705280355p6892b6eex78da6af3801ffe05@mail.gmail.com> Hello List, I'm trying to generate examples for some list-helpers I have coded which use in my projects. Basically, the Playlist class uses one anonymous module in has_many that acts as helper between acts_as_list and my desired API: class Playlist < ActiveRecord::Base # associations go here has_many :playlist_items, :order => :position, :dependent => :destroy has_many :assets, :through => :playlist_items, :order => :position do def << (*assets) assets.flatten.each do |asset| item = proxy_owner.playlist_items.build(:asset => asset) item.save unless proxy_owner.new_record? proxy_owner.duration += asset.duration end proxy_owner.save unless proxy_owner.new_record? end def delete_at (position) pli = proxy_owner.playlist_items.find_by_position(position) rescue nil unless pli.nil? duration = pli.asset.duration proxy_owner.playlist_items.delete(pli) proxy_owner.update_attributes( :duration => (proxy_owner.duration - duration) ) end end def order return [] if proxy_owner.new_record? proxy_owner.playlist_item_ids end def reorder (ids) return [] if proxy_owner.new_record? ids.each_with_index do |id, position| PlaylistItem.update(id, :position => position + 1) end proxy_owner.playlist_items(true) end end # validations goes here validates_presence_of :title validates_uniqueness_of :title # code after this point end == Now, running a simple spec like this: describe Playlist do fixtures :playlists before(:each) do @list = Playlist.new end it { @list.assets.should respond_to(:<<) } it { @list.assets.should respond_to(:delete_at) } it { @list.assets.should respond_to(:order) } it { @list.assets.should respond_to(:reorder) } end == Only #order and #reorder report errors: 1) 'Playlist should respond to #order' FAILED expected target to respond to :order ./spec\models\playlist_spec.rb:16: 2) 'Playlist should respond to #reorder' FAILED expected target to respond to :reorder ./spec\models\playlist_spec.rb:17: Attached is the backtrace (--backtrace) when running with spec command. Any hint? Command works and do what its expected, but respond_to from RSpec don't see them (from console they work). Ruby: 1.8.5 mswin32 OS: Windows XP SP2 (English) RSpec: 0.9.4 (upgrade to 1.0.3 fails with "NoMethodError" 'fixtures'). Rails: 6703 (Edge, pistoned) Thanks in advance guys! -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: backtrace.txt Url: http://rubyforge.org/pipermail/rspec-users/attachments/20070528/3c983f56/attachment.txt From daniel.sandbecker at gmail.com Mon May 28 08:31:55 2007 From: daniel.sandbecker at gmail.com (Daniel Sandbecker) Date: Mon, 28 May 2007 14:31:55 +0200 Subject: [rspec-users] Rails matcher render_template is wrong when using GetText, looking for flexible solution Message-ID: <6541533c0705280531h71908aa0l466b56bae9b75a43@mail.gmail.com> I have a problem with a mismatch between RSpec Rails and the actual behavior when using GetText, and would be glad for suggestions how to best solve this. When using GetText a failure is reported for the following simplified specification: describe SamplesController, "when requesting /samples" do it "should render index " do get 'index' response.should render_template("index") end end The result is: SamplesController when requesting /samples - should render index (FAILED - 1) 1) 'SamplesController when requesting /samples should render index' FAILED expected "index", got "index_en" When I run the application, the template index.rhtml do get rendered (I don't have any "index_en.rhtml"). The source of this mismatch is that GetText overrides ActionView::Base.render_file, testing each possible localized template path and passes the first existing path to the original render_file method : return render_file_without_locale(localized_path, use_full_path, local_assigns) if file_exists? localized_path This line always evaluates to true in RSpec context, but to false in the application. After a lot of digging I found out that RspecOnRails overrides file_exists? with a stub when integrate_views is not set (lib/spec/rails/dsl/behaviour/controller.rb:57): @template.stub!(:file_exists?).and_return(true) Now I'm not sure what would be the best solution. Since I know about this, I could simply add the same extension as GetText does to the expected rendered view path: response.should render_template("index" + "_" + GetText.locale.to_general) But adding this to every check would be ugly and not very DRY. I've tried to override the render_template matcher in my SpecHelper with a method doing the addition before passing it on to the matcher. module Spec::Rails::Matchers alias render_template_without_gettext_fix render_template def render_template(path) path += "_" + GetText.locale.to_general render_template_without_gettext_fix(path) end end But that breaks any spec that calls integrate_views. And I can't see how I can check the status of integrate_views in this override, since it doesn't have access to a controller instance. (My Ruby skills are not very advanced. And the code I've read hunting this problem down has made me dizzy.) What I (think I) would like to achieve is some kind of check on each Controller instance before the specs are run, and overriding render_template if necessary. Is this possible/reasonable? Maybe I'm just stupid. Should I care about this error, or simply not use "render_template" in isolated controller tests? I'm thankful for any advice! /Daniel RSpec 1.0.2 Spec::Rails 1.0.2 Rails 1.2.2 Ruby-GetText 1.9.0 (MsWin) From aslak.hellesoy at gmail.com Mon May 28 09:11:27 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 28 May 2007 15:11:27 +0200 Subject: [rspec-users] Rails, respond_to? over anonymous module (extend has_many). In-Reply-To: <71166b3b0705280355p6892b6eex78da6af3801ffe05@mail.gmail.com> References: <71166b3b0705280355p6892b6eex78da6af3801ffe05@mail.gmail.com> Message-ID: <8d961d900705280611t4ded8cc1w852a363b191dd0f5@mail.gmail.com> On 5/28/07, Luis Lavena wrote: > Hello List, > > I'm trying to generate examples for some list-helpers I have coded > which use in my projects. > > Basically, the Playlist class uses one anonymous module in has_many > that acts as helper between acts_as_list and my desired API: > > class Playlist < ActiveRecord::Base > # associations go here > has_many :playlist_items, :order => :position, :dependent => :destroy > has_many :assets, :through => :playlist_items, :order => :position do > def << (*assets) > assets.flatten.each do |asset| > item = proxy_owner.playlist_items.build(:asset => asset) > item.save unless proxy_owner.new_record? > proxy_owner.duration += asset.duration > end > proxy_owner.save unless proxy_owner.new_record? > end > > def delete_at (position) > pli = proxy_owner.playlist_items.find_by_position(position) rescue nil > unless pli.nil? > duration = pli.asset.duration > proxy_owner.playlist_items.delete(pli) > proxy_owner.update_attributes( :duration => > (proxy_owner.duration - duration) ) > end > end > > def order > return [] if proxy_owner.new_record? > proxy_owner.playlist_item_ids > end > > def reorder (ids) > return [] if proxy_owner.new_record? > ids.each_with_index do |id, position| > PlaylistItem.update(id, :position => position + 1) > end > proxy_owner.playlist_items(true) > end > end > > # validations goes here > validates_presence_of :title > validates_uniqueness_of :title > > # code after this point > end > > == > > Now, running a simple spec like this: > > describe Playlist do > fixtures :playlists > > before(:each) do > @list = Playlist.new > end > > it { @list.assets.should respond_to(:<<) } > it { @list.assets.should respond_to(:delete_at) } > it { @list.assets.should respond_to(:order) } > it { @list.assets.should respond_to(:reorder) } > end > > == > > Only #order and #reorder report errors: > > 1) > 'Playlist should respond to #order' FAILED > expected target to respond to :order > ./spec\models\playlist_spec.rb:16: > > 2) > 'Playlist should respond to #reorder' FAILED > expected target to respond to :reorder > ./spec\models\playlist_spec.rb:17: > > Attached is the backtrace (--backtrace) when running with spec command. > > Any hint? > Command works and do what its expected, but respond_to from RSpec > don't see them (from console they work). > O don't have an answer to what's wrong, but I'm wondering what you're trying to achieve by expecting certain objects to respond to certain methods. Why aren't you just invoking these methods instead? > Ruby: 1.8.5 mswin32 > OS: Windows XP SP2 (English) > RSpec: 0.9.4 (upgrade to 1.0.3 fails with "NoMethodError" 'fixtures'). What command fails with NoMethodError and what's the full backtrace? And how can we reproduce it? I'd rather help people upgrade to 1.0 than supporting older versions. Aslak > Rails: 6703 (Edge, pistoned) > > Thanks in advance guys! > > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From dchelimsky at gmail.com Mon May 28 09:27:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 May 2007 08:27:33 -0500 Subject: [rspec-users] Checking for Range In-Reply-To: References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> Message-ID: <57c63afe0705280627g3476e15ene83c07c099d055d5@mail.gmail.com> On 5/27/07, Andrew WC Brown wrote: > I'm testing the validation > validates_length_of :password, :within => 5..40 > > In this case I should be receiving a failure but I'm not :( > > it "should require a password within the range of 5..40 characters" do > person = create(:password => 'a') > person.password.should_not be_nil > person.should validate_length_of(:password, 5..40) > end > > I'm an amature tester, would you tell me how I should verify? > I haven't fully grasped setting testing goals The behaviour you're trying to describe is that the User should require that passwords bear certain qualities - in this case a length between 5 and 40. So you need to ask yourself how the User should behave when this requirement is violated, and then specify that it behaves that way. Here's how I might handle this: describe User do it "should reject a password of length 4" do User.create(:password => "1234").should have(1).error_on(:password) end it "should accept a password of length 5" do User.create(:password => "12345").should have(0).errors_on(:password) end it "should accept a password of length 40" do User.create( :password => "1234567890123456789012345678901234567890" ).should have(0).errors_on(:password) end it "should reject a password of length 41" do User.create( :password => "12345678901234567890123456789012345678901" ).should have(1).error_on(:password) end end And possibly add something about the specific error message in one of the cases. That make sense? > > On 5/27/07, David Chelimsky wrote: > > > > On 5/27/07, Andrew WC Brown wrote: > > > it "should require a password within the range of 5..40 characters" do > > > person = create(:last_name => "ruby_tuesday") > > > person.password.should_not be_nil > > > (5..40) === person.password.length.should > > > end > > > > > > Its true, it really works, tell all your friends! > > > > How does that verify that a person will reject a password length of 4 or > 41? > > > > > > > > > > > On 5/27/07, Sam Aaron wrote: > > > > > > > > On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote: > > > > > > > > > > I thought this would work: > > > > > person.password.length.should == (5..40) > > > > > > > > > > > > > I think that in this case, you want to use the === operator when > > > > comparing a number with a range. Instead of trying to see if both of > > > > the objects (the number and the range) are the same, the === operator > > > > checks to see if the number is within the range. > > > > > > > > Also, make sure you surround your range with parenthesis (which you > > > > are already doing), and put the range on the left hand side of the > > > > === operator for it to work. Have a look at this quick irb session > > > > for an example of what I mean: > > > > > > > > >> (10..50) == 15 > > > > => false > > > > >> (10..50) === 15 > > > > => true > > > > >> 10..50 === 15 > > > > ArgumentError: bad value for range > > > > from (irb):6 > > > > >> 15 === 10..50 > > > > ArgumentError: bad value for range > > > > from (irb):7 > > > > >> 15 === (10..50) > > > > => false > > > > >> > > > > > > > > Hope this helps, > > > > > > > > Sam > > > > > > > > --- > > > > http://sam.aaron.name > > > > > > > > > > > > _______________________________________________ > > > > 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 Mon May 28 09:41:06 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 May 2007 08:41:06 -0500 Subject: [rspec-users] Rails matcher render_template is wrong when using GetText, looking for flexible solution In-Reply-To: <6541533c0705280531h71908aa0l466b56bae9b75a43@mail.gmail.com> References: <6541533c0705280531h71908aa0l466b56bae9b75a43@mail.gmail.com> Message-ID: <57c63afe0705280641g6a51c8b4l6cf59cd9fbd7222e@mail.gmail.com> On 5/28/07, Daniel Sandbecker wrote: > I have a problem with a mismatch between RSpec Rails and the actual > behavior when using GetText, and would be glad for suggestions how to > best solve this. > > When using GetText a failure is reported for the following simplified > specification: > > describe SamplesController, "when requesting /samples" do > it "should render index " do > get 'index' > response.should render_template("index") > end > end > > The result is: > > SamplesController when requesting /samples > - should render index (FAILED - 1) > > 1) > 'SamplesController when requesting /samples should render index' FAILED > expected "index", got "index_en" > > When I run the application, the template index.rhtml do get rendered > (I don't have any "index_en.rhtml"). > > The source of this mismatch is that GetText overrides > ActionView::Base.render_file, testing each possible localized template > path and passes the first existing path to the original render_file > method : > > return render_file_without_locale(localized_path, use_full_path, > local_assigns) if file_exists? localized_path > > This line always evaluates to true in RSpec context, but to false in > the application. > > After a lot of digging I found out that RspecOnRails overrides > file_exists? with a stub when integrate_views is not set > (lib/spec/rails/dsl/behaviour/controller.rb:57): > > @template.stub!(:file_exists?).and_return(true) > > > > Now I'm not sure what would be the best solution. > > Since I know about this, I could simply add the same extension as > GetText does to the expected rendered view path: > > response.should render_template("index" + "_" + GetText.locale.to_general) > > But adding this to every check would be ugly and not very DRY. > > I've tried to override the render_template matcher in my SpecHelper > with a method doing the addition before passing it on to the matcher. > > module Spec::Rails::Matchers > alias render_template_without_gettext_fix render_template > def render_template(path) > path += "_" + GetText.locale.to_general > render_template_without_gettext_fix(path) > end > end > > But that breaks any spec that calls integrate_views. And I can't see > how I can check the status of integrate_views in this override, since > it doesn't have access to a controller instance. (My Ruby skills are > not very advanced. And the code I've read hunting this problem down > has made me dizzy.) > > What I (think I) would like to achieve is some kind of check on each > Controller instance before the specs are run, and overriding > render_template if necessary. Is this possible/reasonable? Not sure if this is the best solution, but you should be able to do this with the current trunk (doesn't work before that due to a bug) like this: #in spec_helper.rb Spec::Runner.configure do |config| config.before(:each) do if @using_gettext #redefine render_template end end end # in samples_controller_spec.rb describe SamplesController, "when requesting /samples" do prepend_before(:each) do @using_gettext = true end it "should render index " do get 'index' response.should render_template("index") end end > > Maybe I'm just stupid. Should I care about this error, or simply not > use "render_template" in isolated controller tests? I would care about it. This specifies what template should be rendered, which is something you want. > > I'm thankful for any advice! > > /Daniel > > RSpec 1.0.2 > Spec::Rails 1.0.2 > Rails 1.2.2 > Ruby-GetText 1.9.0 (MsWin) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Mon May 28 12:30:26 2007 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 28 May 2007 13:30:26 -0300 Subject: [rspec-users] Rails, respond_to? over anonymous module (extend has_many). In-Reply-To: <8d961d900705280611t4ded8cc1w852a363b191dd0f5@mail.gmail.com> References: <71166b3b0705280355p6892b6eex78da6af3801ffe05@mail.gmail.com> <8d961d900705280611t4ded8cc1w852a363b191dd0f5@mail.gmail.com> Message-ID: <71166b3b0705280930q13847c81j394379aef49d71f4@mail.gmail.com> On 5/28/07, aslak hellesoy wrote: [...] > > Command works and do what its expected, but respond_to from RSpec > > don't see them (from console they work). > > > > O don't have an answer to what's wrong, but I'm wondering what you're > trying to achieve by expecting certain objects to respond to certain > methods. Why aren't you just invoking these methods instead? > Good point, old habit :-P > > Ruby: 1.8.5 mswin32 > > OS: Windows XP SP2 (English) > > RSpec: 0.9.4 (upgrade to 1.0.3 fails with "NoMethodError" 'fixtures'). > > What command fails with NoMethodError and what's the full backtrace? > And how can we reproduce it? I'd rather help people upgrade to 1.0 > than supporting older versions. > Will get you the backtrace later, when return to the office, but is related to fixtures: describe User do fixtures :users ... end When running, it report that DSL / Rails / EvalContext don't have any method defined "fixtures" (from top of my head, will get you specific data later today). Thanks for your time. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From omen.king at gmail.com Mon May 28 13:59:40 2007 From: omen.king at gmail.com (Andrew WC Brown) Date: Mon, 28 May 2007 13:59:40 -0400 Subject: [rspec-users] Checking for Range In-Reply-To: <57c63afe0705280627g3476e15ene83c07c099d055d5@mail.gmail.com> References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> <57c63afe0705280627g3476e15ene83c07c099d055d5@mail.gmail.com> Message-ID: That actaully makes alot of sense now. Does this have to do with something State vs Behaviour verfication? I've been reading alot about stubs and mocks. It took a long which to comprehend. On 5/28/07, David Chelimsky wrote: > > On 5/27/07, Andrew WC Brown wrote: > > I'm testing the validation > > validates_length_of :password, :within => 5..40 > > > > In this case I should be receiving a failure but I'm not :( > > > > it "should require a password within the range of 5..40 characters" do > > person = create(:password => 'a') > > person.password.should_not be_nil > > person.should validate_length_of(:password, 5..40) > > end > > > > I'm an amature tester, would you tell me how I should verify? > > I haven't fully grasped setting testing goals > > The behaviour you're trying to describe is that the User should > require that passwords bear certain qualities - in this case a length > between 5 and 40. So you need to ask yourself how the User should > behave when this requirement is violated, and then specify that it > behaves that way. > > Here's how I might handle this: > > describe User do > it "should reject a password of length 4" do > User.create(:password => "1234").should have(1).error_on(:password) > end > it "should accept a password of length 5" do > User.create(:password => "12345").should have(0).errors_on(:password) > end > it "should accept a password of length 40" do > User.create( > :password => "1234567890123456789012345678901234567890" > ).should have(0).errors_on(:password) > end > it "should reject a password of length 41" do > User.create( > :password => "12345678901234567890123456789012345678901" > ).should have(1).error_on(:password) > end > end > > And possibly add something about the specific error message in one of the > cases. > > That make sense? > > > > > On 5/27/07, David Chelimsky wrote: > > > > > > On 5/27/07, Andrew WC Brown wrote: > > > > it "should require a password within the range of 5..40 > characters" do > > > > person = create(:last_name => "ruby_tuesday") > > > > person.password.should_not be_nil > > > > (5..40) === person.password.length.should > > > > end > > > > > > > > Its true, it really works, tell all your friends! > > > > > > How does that verify that a person will reject a password length of 4 > or > > 41? > > > > > > > > > > > > > > > On 5/27/07, Sam Aaron wrote: > > > > > > > > > > On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote: > > > > > > > > > > > > I thought this would work: > > > > > > person.password.length.should == (5..40) > > > > > > > > > > > > > > > > I think that in this case, you want to use the === operator when > > > > > comparing a number with a range. Instead of trying to see if both > of > > > > > the objects (the number and the range) are the same, the === > operator > > > > > checks to see if the number is within the range. > > > > > > > > > > Also, make sure you surround your range with parenthesis (which > you > > > > > are already doing), and put the range on the left hand side of the > > > > > === operator for it to work. Have a look at this quick irb session > > > > > for an example of what I mean: > > > > > > > > > > >> (10..50) == 15 > > > > > => false > > > > > >> (10..50) === 15 > > > > > => true > > > > > >> 10..50 === 15 > > > > > ArgumentError: bad value for range > > > > > from (irb):6 > > > > > >> 15 === 10..50 > > > > > ArgumentError: bad value for range > > > > > from (irb):7 > > > > > >> 15 === (10..50) > > > > > => false > > > > > >> > > > > > > > > > > Hope this helps, > > > > > > > > > > Sam > > > > > > > > > > --- > > > > > http://sam.aaron.name > > > > > > > > > > > > > > > _______________________________________________ > > > > > 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: http://rubyforge.org/pipermail/rspec-users/attachments/20070528/62a81812/attachment.html From dchelimsky at gmail.com Mon May 28 16:01:22 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 May 2007 15:01:22 -0500 Subject: [rspec-users] Checking for Range In-Reply-To: References: <57c63afe0705271203x461a1ca8m7bb86329f0ff0fb4@mail.gmail.com> <57c63afe0705271206y760aabd9s11961c2c8f364129@mail.gmail.com> <57c63afe0705271325s13cd34bdw2e0beaf5b844e9b@mail.gmail.com> <57c63afe0705280627g3476e15ene83c07c099d055d5@mail.gmail.com> Message-ID: <57c63afe0705281301l5ad2370fq18558b48de346262@mail.gmail.com> On 5/28/07, Andrew WC Brown wrote: > That actaully makes alot of sense now. > Does this have to do with something State vs Behaviour verfication? Not really - the 4 examples are more about boundary testing - testing at, above and below any boundaries to ensure that your conditional logic works as expected. In fact, I failed to do "all 3 sides" of the boundaries, so you might want to add examples for 6 and 39 to round things out. > I've been reading alot about stubs and mocks. > It took a long which to comprehend. > > > On 5/28/07, David Chelimsky wrote: > > On 5/27/07, Andrew WC Brown wrote: > > > I'm testing the validation > > > validates_length_of :password, :within => 5..40 > > > > > > In this case I should be receiving a failure but I'm not :( > > > > > > it "should require a password within the range of 5..40 characters" do > > > person = create(:password => 'a') > > > person.password.should_not be_nil > > > person.should validate_length_of(:password, 5..40) > > > end > > > > > > I'm an amature tester, would you tell me how I should verify? > > > I haven't fully grasped setting testing goals > > > > The behaviour you're trying to describe is that the User should > > require that passwords bear certain qualities - in this case a length > > between 5 and 40. So you need to ask yourself how the User should > > behave when this requirement is violated, and then specify that it > > behaves that way. > > > > Here's how I might handle this: > > > > describe User do > > it "should reject a password of length 4" do > > User.create(:password => "1234").should have(1).error_on(:password) > > end > > it "should accept a password of length 5" do > > User.create(:password => "12345").should have(0).errors_on(:password) > > end > > it "should accept a password of length 40" do > > User.create( > > :password => > "1234567890123456789012345678901234567890" > > ).should have(0).errors_on(:password) > > end > > it "should reject a password of length 41" do > > User.create ( > > :password => > "12345678901234567890123456789012345678901" > > ).should have(1).error_on(:password) > > end > > end > > > > And possibly add something about the specific error message in one of the > cases. > > > > That make sense? > > > > > > > > On 5/27/07, David Chelimsky wrote: > > > > > > > > On 5/27/07, Andrew WC Brown < omen.king at gmail.com > wrote: > > > > > it "should require a password within the range of 5..40 > characters" do > > > > > person = create(:last_name => "ruby_tuesday") > > > > > person.password.should_not be_nil > > > > > (5..40) === person.password.length.should > > > > > end > > > > > > > > > > Its true, it really works, tell all your friends! > > > > > > > > How does that verify that a person will reject a password length of 4 > or > > > 41? > > > > > > > > > > > > > > > > > > > On 5/27/07, Sam Aaron < sam.maillists at googlemail.com > wrote: > > > > > > > > > > > > On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote: > > > > > > > > > > > > > > I thought this would work: > > > > > > > person.password.length.should == (5..40) > > > > > > > > > > > > > > > > > > > I think that in this case, you want to use the === operator when > > > > > > comparing a number with a range. Instead of trying to see if both > of > > > > > > the objects (the number and the range) are the same, the === > operator > > > > > > checks to see if the number is within the range. > > > > > > > > > > > > Also, make sure you surround your range with parenthesis (which > you > > > > > > are already doing), and put the range on the left hand side of the > > > > > > === operator for it to work. Have a look at this quick irb session > > > > > > for an example of what I mean: > > > > > > > > > > > > >> (10..50) == 15 > > > > > > => false > > > > > > >> (10..50) === 15 > > > > > > => true > > > > > > >> 10..50 === 15 > > > > > > ArgumentError: bad value for range > > > > > > from (irb):6 > > > > > > >> 15 === 10..50 > > > > > > ArgumentError: bad value for range > > > > > > from (irb):7 > > > > > > >> 15 === (10..50) > > > > > > => false > > > > > > >> > > > > > > > > > > > > Hope this helps, > > > > > > > > > > > > Sam > > > > > > > > > > > > --- > > > > > > http://sam.aaron.name > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > 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 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon May 28 16:06:01 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 May 2007 15:06:01 -0500 Subject: [rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec In-Reply-To: References: <57c63afe0705231408v58cb535va22338ec7d6a7f0a@mail.gmail.com> <57c63afe0705231526x375814fan29db821301e06a14@mail.gmail.com> Message-ID: <57c63afe0705281306s731569b5n417e88794f2a2dea@mail.gmail.com> On 5/23/07, Ryan Bates wrote: > > I'm not in love w/ exactly that - but something like that. Any suggestions? > > Maybe call it "override_controller_rescue_action!" and have it default > to that block? For better or worse, I ended up calling it raise_controller_errors, and didn't provide a re-definition hook. I think this makes things more friendly. You can say this for one behaviour: describe SomeController do raise_controller_errors ... end or this for all: #in spec_helper.rb Spec::Runner.configure do |config| config.before(:each, :behaviour_type => :controller) do raise_controller_errors end end This config gets set up for you by default when you say "script/generate rspec". Cheers, David > > -- > Spec::Runner.configure do |config| > config.override_controller_rescue_action! > end > -- > > A block could then be optionally passed to change its behavior if you > don't want to simply raise the exception. You may also want to have it > alias the old rescue_action method in case someone wants to call it? > Hmm. > > Whatever the case, I do think there should be an easy way to do this > and maybe mention something in the comments in the config file. I > imagine the majority of Rails projects would want to set this? > > Ryan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon May 28 16:15:51 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 May 2007 15:15:51 -0500 Subject: [rspec-users] Running both autotest and rspec_autotest In-Reply-To: References: Message-ID: <57c63afe0705281315s3bf9bb1cm93ce3356e31a2d1a@mail.gmail.com> On 5/22/07, Joe Van Dyk wrote: > Hi, > > Is it possible to run both autotest and rspec_autotest at the same > time while I convert my tests over to specs? autotest seems to either > want to run one or the other. It does. And since you need two different commands, I'm not quite sure how you could get autotest to fire them both off. > > Also, rspec_autotest doesn't seem to red/green the error/successes. > It should, right? If you get the latest versions of ZenTest and RSpec you should see colors. Cheers, David > > Thanks, > Joe > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon May 28 22:00:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 May 2007 22:00:34 -0400 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <487D1990-941E-42D4-9079-51245BBEE68B@wincent.com> References: <487D1990-941E-42D4-9079-51245BBEE68B@wincent.com> Message-ID: <57c63afe0705281900j5ffb4495o4a4b05890a4a0b7@mail.gmail.com> On 5/24/07, Wincent Colaiuta wrote: > El 24/5/2007, a las 16:24, Matt Deiters escribi?: > > > A couple of questions/comments. Are you doing some sorting logic in > > the view? If so I can see why you would want to assert order, but > > perhaps it would be better to move that type of logic out of view > > and into your controller (or perhaps a presenter or helper). Then > > you would test the order of your collection in one of those (helper/ > > controller) types of specs. Then your view would just iterate of > > the collection and if your view is just iterating over the > > collection, then when your testing order you would really be > > testing does 'ruby iterate right', which again is something we > > don't want to test in our views (or need test at all). > > No, the view has no sorting logic: > > <% for user in @users %> >

>
>
Login name:
>
<%=h user.login_name %>
>
Display name:
>
<%=h user.display_name %>
>
Email address:
>
<%=h user.email_address %>
>
>
> <% end %> > > But I do want to be sure of some things, and these stemmed out of > behaviour-driving the development of the view. I basically imagined > what I wanted the view to look like in my mind and started coming up > with specifications: > > - users should be listed in rows > - rows should have alternate classes (odd, even, odd, even) so they > can be visually styled > - there should be three fields for each user > - the fields should appear in order: login name, display name, email > address > - each field should be preceded by the correct, corresponding label > - users should appear in the view in the order that they were passed > to it > - etc > > So when I wrote the view based on the specs. I was dismayed to find > that if I ignored the question of ordering then I could radically > change the view and the specs would still pass, even though I the > view no longer resembled what I wanted it to look like in my mind... > Basically, I want to be able to assert that "rows should be odd, > even" and only "odd, even" should pass, not "even, odd". Likewise, I > want to be able to assert "header, content, footer" and not accept > results like "footer, header, content" etc. > > In the case where order doesn't matter at all and you only want to > test for the presence of something on the page, you can easily do > that with a single "have_tag" inside an example "it" block of its own. Actually - looking at assert_select (which have_tag and with_tag wrap), you should be able to get what you're looking for using the nth-child selectors. Check it out: http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/cheat/assert_select.html Let us know if it works. > > Cheers, > Wincent > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon May 28 22:02:59 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 May 2007 22:02:59 -0400 Subject: [rspec-users] logger anybody? In-Reply-To: References: Message-ID: <57c63afe0705281902u13fd8528pb89d269e70ca26bb@mail.gmail.com> On 5/21/07, An?bal Rojas wrote: > Hello, > > When trying to use logger into any RSpec I get: > > logger anyboundefined local variable or method `logger' for > #<#:0x253cdec> > > Not sure if this is the spected behaviour (haven't checked under the > hood) It was just annoying not having a logger instance available as in > Rails out of the tests. If you're looking to get this addressed, please submit an RFE or, even better, a patch. http://rspec.rubyforge.org/community/contribute.html Cheers, David > > -- > An?bal Rojas > http://www.rubycorner.com > http://www.hasmanydevelopers.com > http://www.to2blogs.com > http://anibal.rojas.com.ve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Tue May 29 04:54:52 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 04:54:52 -0400 Subject: [rspec-users] questions rspec on rails Message-ID: Hi, rather than flooding this list with separate emails, I've been queueing up questions using rspec with rails. (an irc channel would be nice too :) Here ya go... - Is there a way to test named routes? - Could I get an example how to test an ajax request (link_to_remote)? would that go in view? and/or in controller spec? - Can you assert which layout template is rendered in a controller spec? - How to test application_helper.rb helpers? (creating a file spec/helpers/application_helper_spec.rb like other helper_spec files gives an error no such file to load -- ./spec/helpers/../application_helper (LoadError) - How to write a test (uh, i mean spec) for helpers that take blocks? for example: def link_block_to_remote( options = {}, html_options = {}, &block) concat(link_to_remote(capture(&block), options, html_options), block.binding) end - How can i test ActionMailer? eg ensure it renders the correct template. - Is there an equivalent to script/generate mailer ,eg rspec_mailer that generates specs? and/or do you have examples of mailer specs? - Do you have recommendations for using authentication? should i load a users.yml fixture or setup users some other way? (my controllers and views may check for current_user, logged_in?, etc) (I use restful_authentication) - this may not be rspec at all, I'm calling assert_difference (defined in /lib/authenticated_test_helper.rb) with 3 args but get an error that it expects 2. Is there another version of this method somewhere? I cant find it. If i rename the one i know and call that (eg assert_difference3) its ok. - do any of you also use topfunky_power_tools (ref peepcode testing video) But I dont know how to get my specs to find the topfunky test_helper.rb file. (btw, that file also has a assert_difference but it also takes 3 args... ) - peepcode also suggests vic_tests for integration testing. Have you used that, what do you think? - Running autotest, when a spec errors, autotest sometimes tries re- running the test 2, 3, sometimes many more times repeatedly although I dont touche the file again. Is this a known bug? That's it for now :) thanks linoj From win at wincent.com Tue May 29 05:36:28 2007 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 29 May 2007 11:36:28 +0200 Subject: [rspec-users] Ordering in view specs using have_tag and with_tag In-Reply-To: <57c63afe0705281900j5ffb4495o4a4b05890a4a0b7@mail.gmail.com> References: <487D1990-941E-42D4-9079-51245BBEE68B@wincent.com> <57c63afe0705281900j5ffb4495o4a4b05890a4a0b7@mail.gmail.com> Message-ID: <2E4A7C42-3313-4C55-A28C-0B8502F88303@wincent.com> El 29/5/2007, a las 4:00, David Chelimsky escribi?: > Actually - looking at assert_select (which have_tag and with_tag > wrap), you should be able to get what you're looking for using the > nth-child selectors. Check it out: > > http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/ > cheat/assert_select.html Great cheat sheet, that one! Thanks for sharing the link. There's also a PDF if anyone wants to print it out: http://labnotes.org/svn/public/ruby/rails_plugins/assert_select/cheat/ assert_select.pdf Yes, I think that would definitely work. If we add that to the list of possible techniques we now have three levels of specificity; working from least to most specific we have: 1. No ordering requirements, when you only care about the presence of tags on the page. 2. Strict ordering requirement, as implemented by the assert_select patch that I posted, where you expect tags to appear in the order that you assert them in your specs. 3. Ultra-strict positioning, using the nth-child selectors as you suggest, where you not only care about the order of the tags but specify their numeric position within the list. Obviously as you move through the list from less to more specific your specs become more tightly bound to the structural details of the view, it becomes harder to change the view without breaking the specs, which in turn means you'll tend to pick up mistakes in the view more quickly, but you'll also have a lot more duplication between view and spec. So I guess it's a matter of choosing the right tool for each case. Cheers, Wincent From dchelimsky at gmail.com Tue May 29 07:17:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 May 2007 07:17:34 -0400 Subject: [rspec-users] questions rspec on rails In-Reply-To: References: Message-ID: <57c63afe0705290417n16fe3bf9ked7f8c18d0ff6303@mail.gmail.com> On 5/29/07, Jonathan Linowes wrote: > Hi, rather than flooding this list with separate emails, I've been > queueing up questions using rspec with rails. (an irc channel would > be nice too :) Here ya go... Actually, we prefer separate email. There's too much here for any one person to answer quickly and since this will all be part of one thread it becomes difficult to find the great answer you got from so and so in a month. I'll answer one. > - Running autotest, when a spec errors, autotest sometimes tries re- > running the test 2, 3, sometimes many more times repeatedly although > I dont touche the file again. Is this a known bug? It's more of a conflict than a bug. Easily resolved: http://rubyforge.org/tracker/?func=detail&group_id=797&aid=11147&atid=3149 http://blog.davidchelimsky.net/articles/2007/05/29/rspec-and-autotest From anibal at rojas.com.ve Tue May 29 07:46:01 2007 From: anibal at rojas.com.ve (=?ISO-8859-1?Q?An=EDbal_Rojas?=) Date: Tue, 29 May 2007 07:46:01 -0400 Subject: [rspec-users] Specify methods (GET, POST) allowed for an action in Rails Message-ID: Hello, I have been trying without sucess to specify that a specific action should only be reached when the appropiated method is used. I think I am missing something obvious... :-) (and yes, the context of this problem is the restful routes) -- An?bal Rojas http://www.rubycorner.com http://www.hasmanydevelopers.com From mailing_lists at railsnewbie.com Tue May 29 07:52:02 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 29 May 2007 07:52:02 -0400 Subject: [rspec-users] questions rspec on rails In-Reply-To: References: Message-ID: <70EE6770-3ABB-46F4-9195-AE566AD21A12@railsnewbie.com> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote: > Hi, rather than flooding this list with separate emails, I've been > queueing up questions using rspec with rails. (an irc channel would > be nice too :) Here ya go... > > > - Is there a way to test named routes? I don't think there is a very clean & direct way (hopefully the others on the list can correct me). The rspec rest generator generates some code to check the routes, so you could use something like that. Scott From anthony at digitalphenom.com Tue May 29 08:36:57 2007 From: anthony at digitalphenom.com (Anthony Carlos) Date: Tue, 29 May 2007 08:36:57 -0400 Subject: [rspec-users] questions rspec on rails In-Reply-To: References: Message-ID: <992B878E-9A9A-4A48-A34A-E3A1C5D76769@digitalphenom.com> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote: > Hi, rather than flooding this list with separate emails, I've been > queueing up questions using rspec with rails. (an irc channel would > be nice too :) Here ya go... > > - Can you assert which layout template is rendered in a controller > spec? > I'll answer this one: response.should render_template() Don't forget to include either a GET or POST, and if you're using stubs or mocks, watch test.log for errors. I've noticed that when I stub out a model object, for example, if I don't stub out all the methods that get called before the action gets to my render, then the spec fails but without a lot of related info. test.log will usually give me a hint with a stack trace. It's documented here: http://rspec.rubyforge.org/documentation/rails/ writing/controllers.html > > That's it for now :) thanks > linoj > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From marcus at ahnve.com Tue May 29 09:42:44 2007 From: marcus at ahnve.com (Marcus Ahnve) Date: Tue, 29 May 2007 15:42:44 +0200 Subject: [rspec-users] Selenium, Spec:Ui and ... forks? Message-ID: <4d4e79cc0705290642n3da90bf3lfdc9a5c8283e741e@mail.gmail.com> I am using Spec:UI to run my Selenium tests, and I want to start Selenium only once, for many descriptions. I've come quite far solving it by declaring a main ui spec like the following: require 'pathname' require File.dirname(__FILE__) + '/selenium' $base_url="http://localhost:3000" $browser = Selenium::SeleniumDriver.new("localhost", 4444, "*firefox", "http://localhost:3000", 10000) $browser.start Dir.glob(Pathname.new(__FILE__).parent.join("iteration*").join("*.rb")).each do |file| require file end $browser.kill! rescue nil The problem is that the browser is killed before the specs are run. Anyone has an idea why this is happening? On a related sidenote, a listener interface in RSpec would be quite nice, could the Spec::Runnner::Reporter be used for that? /Marcus Cheers /Marcus -- http://marcus.ahnve.net From anibalrojas at gmail.com Tue May 29 09:51:09 2007 From: anibalrojas at gmail.com (=?ISO-8859-1?Q?An=EDbal_Rojas?=) Date: Tue, 29 May 2007 09:51:09 -0400 Subject: [rspec-users] logger anybody? In-Reply-To: <57c63afe0705281902u13fd8528pb89d269e70ca26bb@mail.gmail.com> References: <57c63afe0705281902u13fd8528pb89d269e70ca26bb@mail.gmail.com> Message-ID: David, Ok, I tough it was my fault. Let me digg a little to see if I can find the problem. -- An?bal On 5/28/07, David Chelimsky wrote: > On 5/21/07, An?bal Rojas wrote: > > Hello, > > > > When trying to use logger into any RSpec I get: > > > > logger anyboundefined local variable or method `logger' for > > #<#:0x253cdec> > > > > Not sure if this is the spected behaviour (haven't checked under the > > hood) It was just annoying not having a logger instance available as in > > Rails out of the tests. > > If you're looking to get this addressed, please submit an RFE or, even > better, a patch. > > http://rspec.rubyforge.org/community/contribute.html > > Cheers, > David > > > > > -- > > An?bal Rojas > > http://www.rubycorner.com > > http://www.hasmanydevelopers.com > > http://www.to2blogs.com > > http://anibal.rojas.com.ve > > > > _______________________________________________ > > 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 win at wincent.com Tue May 29 10:50:59 2007 From: win at wincent.com (Wincent Colaiuta) Date: Tue, 29 May 2007 16:50:59 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> Message-ID: El 25/5/2007, a las 17:54, Anthony Carlos escribi?: > I found more information about its_should_behave_like on the > documentation index page (duh!). The example shows how a behavior is > factored out and put into its own describe block. However, that > behavior is still within the same file. I think my problems stem from > the fact that I'm using Rails and the ApplicationController is its > own separate file. > > But, if I update and save concrete_controller_spec.rb, autotest tries > to run that spec on its own and I get "Shared Behaviour 'All > controllers' can not be found (RuntimeError)". So, I added a > conditional require statement at the top of > concrete_controller_spec.rb: > > require File.dirname(__FILE__) + '/application_controller_spec' > unless Spec::DSL::Behaviour.find_shared_behaviour("All controllers") > > That got rid of the Shared Behaviour can not be found error. Is this > a suitable workaround, or is it too dodgy? I faced a similar issue with shared behaviours. If you stick your shared behaviour at the top of a file and only use it within that same file then there are no problems, but if you want to put a shared behaviour in your spec_helper.rb or some other shared file so that it can be used from other files, then you run into the problem that you describe. As a temporary workaround I'm bracketing the shared behaviour to make sure that it only gets evaluated once, similar to how you've done, but it does indeed feel dodgy (reminds me of conditionally including C header files). What do you think about the following as possible solutions? 1. Change spec/dsl/behaviour.rb to simply skip duplicate definitions rather than raising an exception. Obviously, the risk here is that someone would accidentally name two shared behaviours the same way without realizing it, and only the first encountered one would be evaluated. 2. Add a ":global" option for shared behaviours which are intended to be included globally; only these behaviours would be skipped when evaluated multiple times, and normal shared behaviours would continue to exhibit the existing behaviour: describe 'All controllers', :global => true do .. end 3. A variation on the previous suggestion: instead of using ":global" and ":shared" as alternatives, continue to use ":shared" in all cases, but allow ":global" to be passed as an additional option: describe 'All controllers', :shared => true, :global => true do .. end Of these solutions, I think I like the second one the best. Any other suggestions? Cheers, Wincent From aslak.hellesoy at gmail.com Tue May 29 11:32:57 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 29 May 2007 17:32:57 +0200 Subject: [rspec-users] Selenium, Spec:Ui and ... forks? In-Reply-To: <4d4e79cc0705290642n3da90bf3lfdc9a5c8283e741e@mail.gmail.com> References: <4d4e79cc0705290642n3da90bf3lfdc9a5c8283e741e@mail.gmail.com> Message-ID: <8d961d900705290832h4aa931d2v6eaa160e706f4e92@mail.gmail.com> On 5/29/07, Marcus Ahnve wrote: > I am using Spec:UI to run my Selenium tests, and I want to start > Selenium only once, for many descriptions. > > I've come quite far solving it by declaring a main ui spec like the following: > > require 'pathname' > require File.dirname(__FILE__) + '/selenium' > > $base_url="http://localhost:3000" > $browser = Selenium::SeleniumDriver.new("localhost", 4444, "*firefox", > "http://localhost:3000", 10000) > $browser.start > > Dir.glob(Pathname.new(__FILE__).parent.join("iteration*").join("*.rb")).each > do |file| > require file > end > > $browser.kill! rescue nil > > The problem is that the browser is killed before the specs are run. > Anyone has an idea why this is happening? > Yes, because requiring a spec file doesn't automatically run it - it just queues it up for running. Try killing your $browser in an at_exit{} block instead Aslak > On a related sidenote, a listener interface in RSpec would be quite > nice, could the Spec::Runnner::Reporter be used for that? > > /Marcus > > Cheers /Marcus > -- > http://marcus.ahnve.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Tue May 29 11:47:50 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 11:47:50 -0400 Subject: [rspec-users] questions rspec on rails In-Reply-To: <57c63afe0705290417n16fe3bf9ked7f8c18d0ff6303@mail.gmail.com> References: <57c63afe0705290417n16fe3bf9ked7f8c18d0ff6303@mail.gmail.com> Message-ID: Hi, I should have mentioned I already did that. Here's my spec.opts file --colour --format progress --loadby mtime On May 29, 2007, at 7:17 AM, David Chelimsky wrote: > On 5/29/07, Jonathan Linowes wrote: >> Hi, rather than flooding this list with separate emails, I've been >> queueing up questions using rspec with rails. (an irc channel would >> be nice too :) Here ya go... > > Actually, we prefer separate email. There's too much here for any one > person to answer quickly and since this will all be part of one thread > it becomes difficult to find the great answer you got from so and so > in a month. > > I'll answer one. > >> - Running autotest, when a spec errors, autotest sometimes tries re- >> running the test 2, 3, sometimes many more times repeatedly although >> I dont touche the file again. Is this a known bug? > > It's more of a conflict than a bug. Easily resolved: > > http://rubyforge.org/tracker/? > func=detail&group_id=797&aid=11147&atid=3149 > http://blog.davidchelimsky.net/articles/2007/05/29/rspec-and-autotest > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jonathan at parkerhill.com Tue May 29 11:57:29 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 11:57:29 -0400 Subject: [rspec-users] questions rspec on rails In-Reply-To: <992B878E-9A9A-4A48-A34A-E3A1C5D76769@digitalphenom.com> References: <992B878E-9A9A-4A48-A34A-E3A1C5D76769@digitalphenom.com> Message-ID: <7E0C3942-53C3-4A35-9292-0C4C31227FC3@parkerhill.com> Hi, yes I realize I can assert the view template. I'm trying to assert the layout one. I've tried response.should render_template("pages") and response.should render_template("layouts/pages") and response.should render_template("/layouts/pages") and response.should render_template('/app/views/layouts/site_pages') On May 29, 2007, at 8:36 AM, Anthony Carlos wrote: > > On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote: > >> Hi, rather than flooding this list with separate emails, I've been >> queueing up questions using rspec with rails. (an irc channel would >> be nice too :) Here ya go... >> >> - Can you assert which layout template is rendered in a controller >> spec? >> > > I'll answer this one: > > response.should render_template() > > Don't forget to include either a GET or POST, and if you're using > stubs or mocks, watch test.log for errors. I've noticed that when I > stub out a model object, for example, if I don't stub out all the > methods that get called before the action gets to my render, then the > spec fails but without a lot of related info. test.log will usually > give me a hint with a stack trace. > > It's documented here: http://rspec.rubyforge.org/documentation/rails/ > writing/controllers.html > >> >> That's it for now :) thanks >> linoj >> >> >> _______________________________________________ >> 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 jonathan at parkerhill.com Tue May 29 12:11:24 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 12:11:24 -0400 Subject: [rspec-users] questions rspec on rails In-Reply-To: <57c63afe0705290417n16fe3bf9ked7f8c18d0ff6303@mail.gmail.com> References: <57c63afe0705290417n16fe3bf9ked7f8c18d0ff6303@mail.gmail.com> Message-ID: <4570D767-E983-4508-A61C-DEB33960AC8D@parkerhill.com> >Actually, we prefer separate email. ok, I'll dole them out incrementally, with some more detail From anibalrojas at gmail.com Tue May 29 13:42:04 2007 From: anibalrojas at gmail.com (=?ISO-8859-1?Q?An=EDbal_Rojas?=) Date: Tue, 29 May 2007 13:42:04 -0400 Subject: [rspec-users] Trouble defining a stub method for a controller Message-ID: Hello, Not sure if I am doing something really wrong (let's not say stupid for now), but I haven't been able to stub a controller method like: controller.stub!(:logged_in?).and_return(true) Please help, this is driving me nuts ;-) -- An?bal Rojas http://www.rubycorner.com http://www.hasmanydevelopers.com From jonathan at parkerhill.com Tue May 29 14:52:44 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 14:52:44 -0400 Subject: [rspec-users] specs for ActionMailer Message-ID: <01896995-1237-4814-8893-98262D33CC08@parkerhill.com> Hi, Email notifications are an important part of my app and I would like to spec them. Here's what I have going so far. It seems to work. I'd appreciate comments/suggestions. Rails script/generate mailer produces tests for the email contents etc. I've started by manually converting the generated unit tests to rspec, and then changing/adding examples as I implement the emails. In this scenario, an AdminNotify message is sent when a create action of PagesController class completes. ----------------- app/models/admin_notify.rb : class AdminNotify < ActionMailer::Base def itemcreated(item, sent_at = Time.now) @subject = 'MySite: itemcreated' @body = { :item => item } @recipients = 'admin at gmail.com' @from = 'mysite at gmail.com' @sent_on = sent_at @sent_on = sent_at @headers = {} end ----------------- app/views/admin_notify/itemcreated.text.html.erb :

AdminNotify#itemcreated

A new item was created

Class: <%= @item.class %>
Name: <%= @item.name %>

----------------- spec/fixtures/admin_notify/itemcreated :

AdminNotify#itemcreated

A new item was created

Class: SitePage
Name: asdfasdf

----------------- spec/models/admin_notify_spec.rb : require File.dirname(__FILE__) + '/../spec_helper' FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures' CHARSET = "utf-8" include ActionMailer::Quoting describe AdminNotify do before(:each) do ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] @item = SitePage.new( :name => 'asdfasdf') @item.save! @expected = TMail::Mail.new @expected.set_content_type "text", "plain", { "charset" => CHARSET } #@expected.set_content_type "multipart", "alternative", { "charset" => CHARSET } @expected.mime_version = '1.0' @expected.from = 'jonathan at linowes.com' @expected.to = 'linojon at gmail.com' end it "should generate correct 'create notify' message" do @expected.subject = 'ReviewRamp: itemcreated' @expected.body = read_fixture('itemcreated') @expected.date = Time.now # (asserting mimeparts is too hard ) #@expected.encoded.should == AdminNotify.create_itemcreated (@item, at expected.date).encoded # just check contents part of message response = AdminNotify.create_itemcreated(@item, at expected.date) do_check_email_response(@expected, response) end end def read_fixture(action) IO.readlines("#{FIXTURES_PATH}/admin_notify/#{action}") end def encode(subject) quoted_printable(subject, CHARSET) end def do_check_email_response(expected, response) response.date.should == expected.date response.from.should == expected.from response.to.should == expected.to response.subject.should == @expected.subject response.body.should == @expected.body end #end of admin_notify_spec.rb From gramos at rectorado.unl.edu.ar Tue May 29 14:37:18 2007 From: gramos at rectorado.unl.edu.ar (Gaston Ramos) Date: Tue, 29 May 2007 15:37:18 -0300 Subject: [rspec-users] Trouble defining a stub method for a controller In-Reply-To: References: Message-ID: <20070529183718.GA2271@marlasina> El mar, 29 de may de 2007, a las 01:42:04 -0400, An?bal Rojas dijo: > Hello, > > Not sure if I am doing something really wrong (let's not say > stupid for now), but I haven't been able to stub a controller method > like: > > controller.stub!(:logged_in?).and_return(true) > > Please help, this is driving me nuts ;-) I have this, and works ok! try it: describe PersonController do before(:each) do @person = mock("person") @person.stub!(:new_record?).and_return(false) Person.stub!(:new).and_return(@person) controller.stub!(:logged_in?).and_return(true) end it "create should be redirect list at finish" do get 'create' response.should redirect_to(:action => 'list') end end > > -- > An?bal Rojas > http://www.rubycorner.com > http://www.hasmanydevelopers.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Gast?n Ramos "I always thought Smalltalk would beat Java, I just didn't know it would be called 'Ruby' when it did." -- Kent Beck From gramos at rectorado.unl.edu.ar Tue May 29 14:42:22 2007 From: gramos at rectorado.unl.edu.ar (Gaston Ramos) Date: Tue, 29 May 2007 15:42:22 -0300 Subject: [rspec-users] Trouble defining a stub method for a controller In-Reply-To: References: Message-ID: <20070529184222.GA3164@marlasina> El mar, 29 de may de 2007, a las 01:42:04 -0400, An?bal Rojas dijo: > Hello, > > Not sure if I am doing something really wrong (let's not say > stupid for now), but I haven't been able to stub a controller method > like: > > controller.stub!(:logged_in?).and_return(true) > > Please help, this is driving me nuts ;-) I have this, and works ok! try it: describe PersonController do before(:each) do @person = mock("person") @person.stub!(:new_record?).and_return(false) Person.stub!(:new).and_return(@person) controller.stub!(:logged_in?).and_return(true) end it "create should be redirect list at finish" do get 'create' response.should redirect_to(:action => 'list') end end > > -- > An?bal Rojas > http://www.rubycorner.com > http://www.hasmanydevelopers.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Gast?n Ramos "I always thought Smalltalk would beat Java, I just didn't know it would be called 'Ruby' when it did." -- Kent Beck From anibalrojas at gmail.com Tue May 29 16:12:19 2007 From: anibalrojas at gmail.com (=?ISO-8859-1?Q?An=EDbal_Rojas?=) Date: Tue, 29 May 2007 16:12:19 -0400 Subject: [rspec-users] Trouble defining a stub method for a controller In-Reply-To: <20070529183718.GA2271@marlasina> References: <20070529183718.GA2271@marlasina> Message-ID: Gast?n, thanks for your response, but that is my same code and it is not workig. I started a new scaffold application, to discard any other problem, and it just doesn't work in any of the dev boxes in our offices. -- An?bal On 5/29/07, Gaston Ramos wrote: > El mar, 29 de may de 2007, a las 01:42:04 -0400, An?bal Rojas dijo: > > Hello, > > > > Not sure if I am doing something really wrong (let's not say > > stupid for now), but I haven't been able to stub a controller method > > like: > > > > controller.stub!(:logged_in?).and_return(true) > > > > Please help, this is driving me nuts ;-) > > I have this, and works ok! try it: > > describe PersonController do > > before(:each) do > @person = mock("person") > > @person.stub!(:new_record?).and_return(false) > Person.stub!(:new).and_return(@person) > controller.stub!(:logged_in?).and_return(true) > end > > it "create should be redirect list at finish" do > get 'create' > response.should redirect_to(:action => 'list') > end > > end > > > > > > -- > > An?bal Rojas > > http://www.rubycorner.com > > http://www.hasmanydevelopers.com > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Gast?n Ramos > > "I always thought Smalltalk would beat Java, I just didn't know it would be > called 'Ruby' when it did." > -- Kent Beck > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Tue May 29 16:20:13 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 16:20:13 -0400 Subject: [rspec-users] TDD stats on a project Message-ID: Just a thought, it would be interesting to track and graph the number of examples (and number implemented) on a daily basis as a way of tracking a project progress. From gramos at rectorado.unl.edu.ar Tue May 29 16:57:31 2007 From: gramos at rectorado.unl.edu.ar (Gastón Ramos) Date: Tue, 29 May 2007 17:57:31 -0300 Subject: [rspec-users] Trouble defining a stub method for a controller In-Reply-To: References: <20070529183718.GA2271@marlasina> Message-ID: <20070529205731.GA6233@marlasina> El mar, 29 de may de 2007, a las 04:12:19 -0400, An?bal Rojas dijo: > Gast?n, thanks for your response, but that is my same code and it is not workig. > > I started a new scaffold application, to discard any other problem, > and it just doesn't work in any of the dev boxes in our offices. > > -- > An?bal wich is the exact error? are you watching the test.log file? > > On 5/29/07, Gaston Ramos wrote: > > El mar, 29 de may de 2007, a las 01:42:04 -0400, An?bal Rojas dijo: > > > Hello, > > > > > > Not sure if I am doing something really wrong (let's not say > > > stupid for now), but I haven't been able to stub a controller method > > > like: > > > > > > controller.stub!(:logged_in?).and_return(true) > > > > > > Please help, this is driving me nuts ;-) > > > > I have this, and works ok! try it: > > > > describe PersonController do > > > > before(:each) do > > @person = mock("person") > > > > @person.stub!(:new_record?).and_return(false) > > Person.stub!(:new).and_return(@person) > > controller.stub!(:logged_in?).and_return(true) > > end > > > > it "create should be redirect list at finish" do > > get 'create' > > response.should redirect_to(:action => 'list') > > end > > > > end > > > > > > > > > > -- > > > An?bal Rojas > > > http://www.rubycorner.com > > > http://www.hasmanydevelopers.com > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > -- > > Gast?n Ramos > > > > "I always thought Smalltalk would beat Java, I just didn't know it would be > > called 'Ruby' when it did." > > -- Kent Beck > > _______________________________________________ > > 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 > -- Gast?n Ramos "I always thought Smalltalk would beat Java, I just didn't know it would be called 'Ruby' when it did." -- Kent Beck From dchelimsky at gmail.com Tue May 29 17:51:36 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 May 2007 17:51:36 -0400 Subject: [rspec-users] rspec and autotest (was: questions rspec on rails) Message-ID: <57c63afe0705291451w35bf31f5qf9cc1bd3602c1110@mail.gmail.com> Do have the latest versions? RSpec-1.0.3 ZenTest-3.6.0 ---------- Forwarded message ---------- From: Jonathan Linowes Date: May 29, 2007 11:47 AM Subject: Re: [rspec-users] questions rspec on rails To: rspec-users Hi, I should have mentioned I already did that. Here's my spec.opts file --colour --format progress --loadby mtime On May 29, 2007, at 7:17 AM, David Chelimsky wrote: > On 5/29/07, Jonathan Linowes wrote: >> Hi, rather than flooding this list with separate emails, I've been >> queueing up questions using rspec with rails. (an irc channel would >> be nice too :) Here ya go... > > Actually, we prefer separate email. There's too much here for any one > person to answer quickly and since this will all be part of one thread > it becomes difficult to find the great answer you got from so and so > in a month. > > I'll answer one. > >> - Running autotest, when a spec errors, autotest sometimes tries re- >> running the test 2, 3, sometimes many more times repeatedly although >> I dont touche the file again. Is this a known bug? > > It's more of a conflict than a bug. Easily resolved: > > http://rubyforge.org/tracker/? > func=detail&group_id=797&aid=11147&atid=3149 > http://blog.davidchelimsky.net/articles/2007/05/29/rspec-and-autotest > _______________________________________________ > 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 jonathan at parkerhill.com Tue May 29 17:56:54 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 17:56:54 -0400 Subject: [rspec-users] layout template In-Reply-To: <7E0C3942-53C3-4A35-9292-0C4C31227FC3@parkerhill.com> References: <992B878E-9A9A-4A48-A34A-E3A1C5D76769@digitalphenom.com> <7E0C3942-53C3-4A35-9292-0C4C31227FC3@parkerhill.com> Message-ID: <5E3EE9E2-BBCE-465C-BF4F-AC563983ECDE@parkerhill.com> to answer my own question here, @layout is a variable so response.layout.should == 'layouts/pages' On May 29, 2007, at 11:57 AM, Jonathan Linowes wrote: > Hi, > > yes I realize I can assert the view template. I'm trying to assert > the layout one. > > I've tried > response.should render_template("pages") > and > response.should render_template("layouts/pages") > and > response.should render_template("/layouts/pages") > and > response.should render_template('/app/views/layouts/site_pages') > > > On May 29, 2007, at 8:36 AM, Anthony Carlos wrote: > >> >> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote: >> >>> Hi, rather than flooding this list with separate emails, I've been >>> queueing up questions using rspec with rails. (an irc channel would >>> be nice too :) Here ya go... >>> >>> - Can you assert which layout template is rendered in a controller >>> spec? >>> >> >> I'll answer this one: >> >> response.should render_template() >> >> Don't forget to include either a GET or POST, and if you're using >> stubs or mocks, watch test.log for errors. I've noticed that when I >> stub out a model object, for example, if I don't stub out all the >> methods that get called before the action gets to my render, then the >> spec fails but without a lot of related info. test.log will usually >> give me a hint with a stack trace. >> >> It's documented here: http://rspec.rubyforge.org/documentation/rails/ >> writing/controllers.html >> >>> >>> That's it for now :) thanks >>> linoj >>> >>> >>> _______________________________________________ >>> 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 Tue May 29 18:19:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 May 2007 18:19:17 -0400 Subject: [rspec-users] layout template In-Reply-To: <5E3EE9E2-BBCE-465C-BF4F-AC563983ECDE@parkerhill.com> References: <992B878E-9A9A-4A48-A34A-E3A1C5D76769@digitalphenom.com> <7E0C3942-53C3-4A35-9292-0C4C31227FC3@parkerhill.com> <5E3EE9E2-BBCE-465C-BF4F-AC563983ECDE@parkerhill.com> Message-ID: <57c63afe0705291519o106b9222n56a9d75964db0d6b@mail.gmail.com> On 5/29/07, Jonathan Linowes wrote: > to answer my own question here, @layout is a variable so > > response.layout.should == 'layouts/pages' This is a great case for a custom matcher, if you're interested. Something like: response.should use_layout('pages') Check out http://blog.davidchelimsky.net/articles/2007/02/18/custom-expectation-matchers for info on how-to. > > > > On May 29, 2007, at 11:57 AM, Jonathan Linowes wrote: > > > Hi, > > > > yes I realize I can assert the view template. I'm trying to assert > > the layout one. > > > > I've tried > > response.should render_template("pages") > > and > > response.should render_template("layouts/pages") > > and > > response.should render_template("/layouts/pages") > > and > > response.should render_template('/app/views/layouts/site_pages') > > > > > > On May 29, 2007, at 8:36 AM, Anthony Carlos wrote: > > > >> > >> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote: > >> > >>> Hi, rather than flooding this list with separate emails, I've been > >>> queueing up questions using rspec with rails. (an irc channel would > >>> be nice too :) Here ya go... > >>> > >>> - Can you assert which layout template is rendered in a controller > >>> spec? > >>> > >> > >> I'll answer this one: > >> > >> response.should render_template() > >> > >> Don't forget to include either a GET or POST, and if you're using > >> stubs or mocks, watch test.log for errors. I've noticed that when I > >> stub out a model object, for example, if I don't stub out all the > >> methods that get called before the action gets to my render, then the > >> spec fails but without a lot of related info. test.log will usually > >> give me a hint with a stack trace. > >> > >> It's documented here: http://rspec.rubyforge.org/documentation/rails/ > >> writing/controllers.html > >> > >>> > >>> That's it for now :) thanks > >>> linoj > >>> > >>> > >>> _______________________________________________ > >>> 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 jonathan at parkerhill.com Tue May 29 18:46:26 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 18:46:26 -0400 Subject: [rspec-users] rspec and autotest (was: questions rspec on rails) In-Reply-To: <57c63afe0705291451w35bf31f5qf9cc1bd3602c1110@mail.gmail.com> References: <57c63afe0705291451w35bf31f5qf9cc1bd3602c1110@mail.gmail.com> Message-ID: <1A596517-C71D-45DA-B7F4-6826E2C6D056@parkerhill.com> yes, latest of both it happens when i have a syntax error in the file being tested (i think) On May 29, 2007, at 5:51 PM, David Chelimsky wrote: > Do have the latest versions? > > RSpec-1.0.3 > ZenTest-3.6.0 > > ---------- Forwarded message ---------- > From: Jonathan Linowes > Date: May 29, 2007 11:47 AM > Subject: Re: [rspec-users] questions rspec on rails > To: rspec-users > > > Hi, I should have mentioned I already did that. Here's my spec.opts > file > > --colour > --format > progress > --loadby > mtime > > > > On May 29, 2007, at 7:17 AM, David Chelimsky wrote: > >> On 5/29/07, Jonathan Linowes wrote: >>> Hi, rather than flooding this list with separate emails, I've been >>> queueing up questions using rspec with rails. (an irc channel would >>> be nice too :) Here ya go... >> >> Actually, we prefer separate email. There's too much here for any one >> person to answer quickly and since this will all be part of one >> thread >> it becomes difficult to find the great answer you got from so and so >> in a month. >> >> I'll answer one. >> >>> - Running autotest, when a spec errors, autotest sometimes tries re- >>> running the test 2, 3, sometimes many more times repeatedly although >>> I dont touche the file again. Is this a known bug? >> >> It's more of a conflict than a bug. Easily resolved: >> >> http://rubyforge.org/tracker/? >> func=detail&group_id=797&aid=11147&atid=3149 >> http://blog.davidchelimsky.net/articles/2007/05/29/rspec-and-autotest >> _______________________________________________ >> 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 t.lucas at toolmantim.com Tue May 29 19:13:42 2007 From: t.lucas at toolmantim.com (Tim Lucas) Date: Wed, 30 May 2007 09:13:42 +1000 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> Message-ID: <5FB005A0-4592-4FD3-A8BD-115994C42B5F@toolmantim.com> On 25/05/2007, at 5:16 AM, Anthony Carlos wrote: > I'm sorry, but I'm a newbie and I don't fully understand. Could you > please give me more details? > > 1. Is the slightly dodgy way completely separate from using a shared > spec? Yeah, it's completely separate. The pastie[1] is the complete spec. This only tests your ApplicationController though. > 2. What is the appropriate file path and name for your first example > regarding a shared spec? Is it RAILS_ROOT/spec/controllers/ > all_controllers_spec.rb? > 3. Does the event controller spec belong in RAILS_ROOT/spec/ > controllers/event_controller_spec.rb? > 4. How do you actually fire off the test? Do I have to call get or > post inside a do-end block that is attached to it_should_behave_like > "All controllers"? > > e.g., > > describe EventController do > it_should_behave_like "All controllers" do > get 'event1' # just an example action > end > end > > 5. Is there any further documentation on it_should_behave_like other > than the RDoc? It doesn't really say too much. I haven't actually used shared specs... so if you figure out please do share! -- tim [1] http://pastie.caboo.se/64123 From jonathan at parkerhill.com Tue May 29 19:13:41 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 19:13:41 -0400 Subject: [rspec-users] layout template In-Reply-To: <57c63afe0705291519o106b9222n56a9d75964db0d6b@mail.gmail.com> References: <992B878E-9A9A-4A48-A34A-E3A1C5D76769@digitalphenom.com> <7E0C3942-53C3-4A35-9292-0C4C31227FC3@parkerhill.com> <5E3EE9E2-BBCE-465C-BF4F-AC563983ECDE@parkerhill.com> <57c63afe0705291519o106b9222n56a9d75964db0d6b@mail.gmail.com> Message-ID: cool! it works!! I put it all in spec_helper.rb Is there a better place to put it? your post implies the class and the method should be in separate files? (I dont know what is meant by "#included in specify blocks") http://blog.davidchelimsky.net/articles/2007/02/18/expectation-matchers # in spec_helper.rb class UseLayout def initialize(expected) @expected = 'layouts/' + expected end def matches?(controller) @actual = controller.layout #@actual.equal?(@expected) @actual == @expected end def failure_message return "use_layout expected #{@expected.inspect}, got # {@actual.inspect}", @expected, @actual end def negeative_failure_message return "use_layout expected #{@expected.inspect} not to equal # {@actual.inspect}", @expected, @actual end end def use_layout(expected) UseLayout.new(expected) end # in controller spec response.should use_layout("application") On May 29, 2007, at 6:19 PM, David Chelimsky wrote: > On 5/29/07, Jonathan Linowes wrote: >> to answer my own question here, @layout is a variable so >> >> response.layout.should == 'layouts/pages' > > This is a great case for a custom matcher, if you're interested. > Something like: > > response.should use_layout('pages') > > Check out http://blog.davidchelimsky.net/articles/2007/02/18/custom- > expectation-matchers > for info on how-to. > >> >> >> >> On May 29, 2007, at 11:57 AM, Jonathan Linowes wrote: >> >>> Hi, >>> >>> yes I realize I can assert the view template. I'm trying to assert >>> the layout one. >>> >>> I've tried >>> response.should render_template("pages") >>> and >>> response.should render_template("layouts/pages") >>> and >>> response.should render_template("/layouts/pages") >>> and >>> response.should render_template('/app/views/layouts/site_pages') >>> >>> >>> On May 29, 2007, at 8:36 AM, Anthony Carlos wrote: >>> >>>> >>>> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote: >>>> >>>>> Hi, rather than flooding this list with separate emails, I've been >>>>> queueing up questions using rspec with rails. (an irc channel >>>>> would >>>>> be nice too :) Here ya go... >>>>> >>>>> - Can you assert which layout template is rendered in a controller >>>>> spec? >>>>> >>>> >>>> I'll answer this one: >>>> >>>> response.should render_template() >>>> >>>> Don't forget to include either a GET or POST, and if you're using >>>> stubs or mocks, watch test.log for errors. I've noticed that when I >>>> stub out a model object, for example, if I don't stub out all the >>>> methods that get called before the action gets to my render, >>>> then the >>>> spec fails but without a lot of related info. test.log will usually >>>> give me a hint with a stack trace. >>>> >>>> It's documented here: http://rspec.rubyforge.org/documentation/ >>>> rails/ >>>> writing/controllers.html >>>> >>>>> >>>>> That's it for now :) thanks >>>>> linoj >>>>> >>>>> >>>>> _______________________________________________ >>>>> 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 From dchelimsky at gmail.com Tue May 29 19:17:01 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 May 2007 19:17:01 -0400 Subject: [rspec-users] rspec and autotest (was: questions rspec on rails) In-Reply-To: <1A596517-C71D-45DA-B7F4-6826E2C6D056@parkerhill.com> References: <57c63afe0705291451w35bf31f5qf9cc1bd3602c1110@mail.gmail.com> <1A596517-C71D-45DA-B7F4-6826E2C6D056@parkerhill.com> Message-ID: <57c63afe0705291617l53fd39e5pd1392126ba9519d3@mail.gmail.com> On 5/29/07, Jonathan Linowes wrote: > yes, latest of both > > it happens when i have a syntax error in the file being tested (i think) I haven't experienced that with the latest versions. Please do let us know what you discover. Cheers, David > > > On May 29, 2007, at 5:51 PM, David Chelimsky wrote: > > > Do have the latest versions? > > > > RSpec-1.0.3 > > ZenTest-3.6.0 > > > > ---------- Forwarded message ---------- > > From: Jonathan Linowes > > Date: May 29, 2007 11:47 AM > > Subject: Re: [rspec-users] questions rspec on rails > > To: rspec-users > > > > > > Hi, I should have mentioned I already did that. Here's my spec.opts > > file > > > > --colour > > --format > > progress > > --loadby > > mtime > > > > > > > > On May 29, 2007, at 7:17 AM, David Chelimsky wrote: > > > >> On 5/29/07, Jonathan Linowes wrote: > >>> Hi, rather than flooding this list with separate emails, I've been > >>> queueing up questions using rspec with rails. (an irc channel would > >>> be nice too :) Here ya go... > >> > >> Actually, we prefer separate email. There's too much here for any one > >> person to answer quickly and since this will all be part of one > >> thread > >> it becomes difficult to find the great answer you got from so and so > >> in a month. > >> > >> I'll answer one. > >> > >>> - Running autotest, when a spec errors, autotest sometimes tries re- > >>> running the test 2, 3, sometimes many more times repeatedly although > >>> I dont touche the file again. Is this a known bug? > >> > >> It's more of a conflict than a bug. Easily resolved: > >> > >> http://rubyforge.org/tracker/? > >> func=detail&group_id=797&aid=11147&atid=3149 > >> http://blog.davidchelimsky.net/articles/2007/05/29/rspec-and-autotest > >> _______________________________________________ > >> 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 Tue May 29 19:31:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 May 2007 19:31:18 -0400 Subject: [rspec-users] layout template In-Reply-To: References: <992B878E-9A9A-4A48-A34A-E3A1C5D76769@digitalphenom.com> <7E0C3942-53C3-4A35-9292-0C4C31227FC3@parkerhill.com> <5E3EE9E2-BBCE-465C-BF4F-AC563983ECDE@parkerhill.com> <57c63afe0705291519o106b9222n56a9d75964db0d6b@mail.gmail.com> Message-ID: <57c63afe0705291631r62872e07h3e4b11dcda0c0efe@mail.gmail.com> On 5/29/07, Jonathan Linowes wrote: > cool! it works!! Right on! > I put it all in spec_helper.rb > Is there a better place to put it? your post implies the class and > the method should be in separate files? (I dont know what is meant by > "#included in specify blocks") The Matchers module gets included in the object in which the examples get run, giving you access to matchers in that module in the examples. Both the Equal class and the equal method are defined in a single file. As for where to keep them, I do keep them in spec_helper, but you can certainly put them in a spec/matchers directory - or even a new plugin if you want to share them with your other apps. > http://blog.davidchelimsky.net/articles/2007/02/18/expectation-matchers > > # in spec_helper.rb > > class UseLayout > def initialize(expected) > @expected = 'layouts/' + expected > end > def matches?(controller) > @actual = controller.layout > #@actual.equal?(@expected) > @actual == @expected > end > def failure_message > return "use_layout expected #{@expected.inspect}, got # > {@actual.inspect}", @expected, @actual > end > def negeative_failure_message > return "use_layout expected #{@expected.inspect} not to equal # > {@actual.inspect}", @expected, @actual > end > end > > > def use_layout(expected) > UseLayout.new(expected) > end > > # in controller spec > response.should use_layout("application") > > > On May 29, 2007, at 6:19 PM, David Chelimsky wrote: > > > On 5/29/07, Jonathan Linowes wrote: > >> to answer my own question here, @layout is a variable so > >> > >> response.layout.should == 'layouts/pages' > > > > This is a great case for a custom matcher, if you're interested. > > Something like: > > > > response.should use_layout('pages') > > > > Check out http://blog.davidchelimsky.net/articles/2007/02/18/custom- > > expectation-matchers > > for info on how-to. > > > >> > >> > >> > >> On May 29, 2007, at 11:57 AM, Jonathan Linowes wrote: > >> > >>> Hi, > >>> > >>> yes I realize I can assert the view template. I'm trying to assert > >>> the layout one. > >>> > >>> I've tried > >>> response.should render_template("pages") > >>> and > >>> response.should render_template("layouts/pages") > >>> and > >>> response.should render_template("/layouts/pages") > >>> and > >>> response.should render_template('/app/views/layouts/site_pages') > >>> > >>> > >>> On May 29, 2007, at 8:36 AM, Anthony Carlos wrote: > >>> > >>>> > >>>> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote: > >>>> > >>>>> Hi, rather than flooding this list with separate emails, I've been > >>>>> queueing up questions using rspec with rails. (an irc channel > >>>>> would > >>>>> be nice too :) Here ya go... > >>>>> > >>>>> - Can you assert which layout template is rendered in a controller > >>>>> spec? > >>>>> > >>>> > >>>> I'll answer this one: > >>>> > >>>> response.should render_template() > >>>> > >>>> Don't forget to include either a GET or POST, and if you're using > >>>> stubs or mocks, watch test.log for errors. I've noticed that when I > >>>> stub out a model object, for example, if I don't stub out all the > >>>> methods that get called before the action gets to my render, > >>>> then the > >>>> spec fails but without a lot of related info. test.log will usually > >>>> give me a hint with a stack trace. > >>>> > >>>> It's documented here: http://rspec.rubyforge.org/documentation/ > >>>> rails/ > >>>> writing/controllers.html > >>>> > >>>>> > >>>>> That's it for now :) thanks > >>>>> linoj > >>>>> > >>>>> > >>>>> _______________________________________________ > >>>>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Tue May 29 19:37:59 2007 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 29 May 2007 20:37:59 -0300 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> Message-ID: <71166b3b0705291637u64c99a15sfa7bc4e8152d1d9e@mail.gmail.com> On 5/29/07, Wincent Colaiuta wrote: [...] > > 2. Add a ":global" option for shared behaviours which are intended to > be included globally; only these behaviours would be skipped when > evaluated multiple times, and normal shared behaviours would continue > to exhibit the existing behaviour: > > describe 'All controllers', :global => true do .. end > > 3. A variation on the previous suggestion: instead of using ":global" > and ":shared" as alternatives, continue to use ":shared" in all > cases, but allow ":global" to be passed as an additional option: > > describe 'All controllers', :shared => true, :global => true do .. end > > Of these solutions, I think I like the second one the best. Any other > suggestions? > describe 'All controllers', :shared => :global do ... end Since that will be shared anyway, what change is "context" (no pun intended). -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From anibalrojas at gmail.com Tue May 29 19:47:01 2007 From: anibalrojas at gmail.com (=?ISO-8859-1?Q?An=EDbal_Rojas?=) Date: Tue, 29 May 2007 19:47:01 -0400 Subject: [rspec-users] Trouble defining a stub method for a controller In-Reply-To: <20070529205731.GA6233@marlasina> References: <20070529183718.GA2271@marlasina> <20070529205731.GA6233@marlasina> Message-ID: Gaston, right now I am far away from mi dev box, I will check tomorow. Thanks for your help. -- An?bal On 5/29/07, Gast?n Ramos wrote: > El mar, 29 de may de 2007, a las 04:12:19 -0400, An?bal Rojas dijo: > > Gast?n, thanks for your response, but that is my same code and it is not workig. > > > > I started a new scaffold application, to discard any other problem, > > and it just doesn't work in any of the dev boxes in our offices. > > > > -- > > An?bal > > wich is the exact error? > are you watching the test.log file? > > > > > On 5/29/07, Gaston Ramos wrote: > > > El mar, 29 de may de 2007, a las 01:42:04 -0400, An?bal Rojas dijo: > > > > Hello, > > > > > > > > Not sure if I am doing something really wrong (let's not say > > > > stupid for now), but I haven't been able to stub a controller method > > > > like: > > > > > > > > controller.stub!(:logged_in?).and_return(true) > > > > > > > > Please help, this is driving me nuts ;-) > > > > > > I have this, and works ok! try it: > > > > > > describe PersonController do > > > > > > before(:each) do > > > @person = mock("person") > > > > > > @person.stub!(:new_record?).and_return(false) > > > Person.stub!(:new).and_return(@person) > > > controller.stub!(:logged_in?).and_return(true) > > > end > > > > > > it "create should be redirect list at finish" do > > > get 'create' > > > response.should redirect_to(:action => 'list') > > > end > > > > > > end > > > > > > > > > > > > > > -- > > > > An?bal Rojas > > > > http://www.rubycorner.com > > > > http://www.hasmanydevelopers.com > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > -- > > > Gast?n Ramos > > > > > > "I always thought Smalltalk would beat Java, I just didn't know it would be > > > called 'Ruby' when it did." > > > -- Kent Beck > > > _______________________________________________ > > > 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 > > > > -- > Gast?n Ramos > > "I always thought Smalltalk would beat Java, I just didn't know it would be > called 'Ruby' when it did." > -- Kent Beck > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue May 29 19:52:21 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 May 2007 19:52:21 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> Message-ID: <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> On 5/25/07, Anthony Carlos wrote: > Hey everyone: > > I found more information about its_should_behave_like on the > documentation index page (duh!). The example shows how a behavior is > factored out and put into its own describe block. However, that > behavior is still within the same file. I think my problems stem from > the fact that I'm using Rails and the ApplicationController is its > own separate file. > > I want to figure out where specs for ApplicationController are > supposed to live, and how to call them. > > Here's what I've tried: > > Created /spec/controllers/application_controller_spec.rb: > > require File.dirname(__FILE__) + '/../spec_helper' > describe "All controllers", :shared => true do > it "should respond to authenticate" do > controller.should respond_to(:authenticate) > end > it "should respond to current_user" do > controller.should respond_to(:current_user) > end > end > > Created /spec/controllers/concrete_controller_spec.rb: > > require File.dirname(__FILE__) + '/../spec_helper' > describe ConcreteController do > it_should_behave_like "All controllers" > end > > Then, I ran rake spec:autotest, and got the following output: > ConcreteController > - should respond to current_user > - should respond to authenticate > > But, if I update and save concrete_controller_spec.rb, autotest tries > to run that spec on its own and I get "Shared Behaviour 'All > controllers' can not be found (RuntimeError)". So, I added a > conditional require statement at the top of concrete_controller_spec.rb: > > require File.dirname(__FILE__) + '/application_controller_spec' > unless Spec::DSL::Behaviour.find_shared_behaviour("All controllers") > > That got rid of the Shared Behaviour can not be found error. Is this > a suitable workaround, or is it too dodgy? I don't view that as a workaround at all. You should always be able to run any example file by itself. If such a file relies on other files, then it should require them. Another thing you could do is to put shared behaviours in spec/shared/ and require everything in spec/shared from spec/spec_helper. > > So, things are peachy except that I'm only checking that all > controllers respond to certain methods. I want to test the logic of > these methods, so I added the following example to my All Controllers > behavior: > > it "should flash notice when session[:current_user_id] does not > exist" do > session[:current_user_id] = nil > controller.authenticate > flash[:notice].should == 'Please login.' > end > > My problem now, is that I get a nil object error. Specifically, in > application.rb, I'm trying to call request.parameters and request is > nil. It seems that request is not part of the context anymore since I > moved the behavior out to a separate file. How do I regain access to > request, response, assigns, flash, and session? The fact that the shared examples are in another file should have no bearing on whether they have runtime access to whatever is in the behaviours that include them. This all sounds odd to me. Can you post a backtrace please? > > Thanks for your help! > > -Anthony > > > On May 24, 2007, at 3:16 PM, Anthony Carlos wrote: > > > Tim: > > > > I'm sorry, but I'm a newbie and I don't fully understand. Could you > > please give me more details? > > > > 1. Is the slightly dodgy way completely separate from using a shared > > spec? > > 2. What is the appropriate file path and name for your first example > > regarding a shared spec? Is it RAILS_ROOT/spec/controllers/ > > all_controllers_spec.rb? > > 3. Does the event controller spec belong in RAILS_ROOT/spec/ > > controllers/event_controller_spec.rb? > > 4. How do you actually fire off the test? Do I have to call get or > > post inside a do-end block that is attached to it_should_behave_like > > "All controllers"? > > > > e.g., > > > > describe EventController do > > it_should_behave_like "All controllers" do > > get 'event1' # just an example action > > end > > end > > > > 5. Is there any further documentation on it_should_behave_like other > > than the RDoc? It doesn't really say too much. > > > > Thanks for your help! > > > > -Anthony > > > > On May 24, 2007, at 3:18 AM, Tim Lucas wrote: > > > >> On 24/05/2007, at 5:00 PM, Wincent Colaiuta wrote: > >> > >>> The Rails ApplicationController (app/controllers/application.rb) > >>> serves as an abstract superclass for all other controllers in a > >>> Rails > >>> application and is a good place to put methods and filters which you > >>> want all of your controllers to use. In my case I'm using it to > >>> provide methods such as "current_user" and "logged_in?" etc. > >>> > >>> By default, RSpec doesn't produce a corresponding spec file for this > >>> controller. > >>> > >>> I've made a spec file (spec/controllers/application_spec.rb) so that > >>> I can test these methods, but I'm not sure if this is the right > >>> thing > >>> to do. Should I be testing only the non-abstract subclasses instead? > >> > >> I did it a slighty dodgy way (spec/controllers/ > >> application_controller_spec.rb): > >> http://pastie.caboo.se/64123 > >> > >> but nowadays you can probably use a shared spec, like so (require'd > >> from your spec helper): > >> > >> describe "All controllers", :shared => true do > >> it "should redirect to HQ if no subdomains specified" do > >> ... > >> end > >> end > >> > >> and then: > >> > >> describe EventController do > >> it_should_behave_like "All controllers" > >> ... > >> end > >> > >> Not sure how you'd deal with something like skip_before_filter > >> though... > >> > >> -- tim > >> > >> _______________________________________________ > >> 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 joshknowles at gmail.com Tue May 29 20:17:23 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Tue, 29 May 2007 17:17:23 -0700 Subject: [rspec-users] TDD stats on a project In-Reply-To: References: Message-ID: On 5/29/07, Jonathan Linowes wrote: > > Just a thought, it would be interesting to track and graph the number > of examples (and number implemented) on a daily basis as a way of > tracking a project progress. Simplistic solution: rake stats Advanced solution: Look into RCov. -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070529/2ddf03d6/attachment.html From jonathan at parkerhill.com Tue May 29 20:22:27 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 20:22:27 -0400 Subject: [rspec-users] should_eql etc? Message-ID: <096E089E-7451-42AC-9625-943D9F72FCA7@parkerhill.com> Hi, I'm trying the specs for restful_authentication I found here http://jonathan.tron.name/articles/2007/01/02/rspec-on-rails-restful- authentication It seems to use custom .should methods: should_eql, should_be_an_instance_of, should_redirect_to, should_be_success, should_not_be_nil, should_be_nil, should_not_be_nil, should_be_empty, should_be_success, should_not_change, and should_not_be_activated Is this using an old version of rspec, and/or do i need to define these methods and how? thanks linoj From dchelimsky at gmail.com Tue May 29 21:03:41 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 29 May 2007 21:03:41 -0400 Subject: [rspec-users] should_eql etc? In-Reply-To: <096E089E-7451-42AC-9625-943D9F72FCA7@parkerhill.com> References: <096E089E-7451-42AC-9625-943D9F72FCA7@parkerhill.com> Message-ID: <57c63afe0705291803u5026faefudb4307eec55c335b@mail.gmail.com> On 5/29/07, Jonathan Linowes wrote: > Hi, I'm trying the specs for restful_authentication I found here > > http://jonathan.tron.name/articles/2007/01/02/rspec-on-rails-restful- > authentication > > It seems to use custom .should methods: should_eql, > should_be_an_instance_of, should_redirect_to, should_be_success, > should_not_be_nil, should_be_nil, should_not_be_nil, should_be_empty, > should_be_success, should_not_change, and should_not_be_activated > > Is this using an old version of rspec, and/or do i need to define > these methods and how? Old version. Just replace "should_not_" with "should_not " and then "should_" with "should ". > > thanks > > linoj > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Tue May 29 22:49:09 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 29 May 2007 22:49:09 -0400 Subject: [rspec-users] should_eql etc? In-Reply-To: <57c63afe0705291803u5026faefudb4307eec55c335b@mail.gmail.com> References: <096E089E-7451-42AC-9625-943D9F72FCA7@parkerhill.com> <57c63afe0705291803u5026faefudb4307eec55c335b@mail.gmail.com> Message-ID: <731D5A86-0C63-4C46-8CF1-2C6D0A1C7267@parkerhill.com> thanks fyi, I've posted the updated files http://www.vaporbase.com/postings/Rspec_1.0_and_Restful_Authentication On May 29, 2007, at 9:03 PM, David Chelimsky wrote: > On 5/29/07, Jonathan Linowes wrote: >> Hi, I'm trying the specs for restful_authentication I found here >> >> http://jonathan.tron.name/articles/2007/01/02/rspec-on-rails-restful- >> authentication >> >> It seems to use custom .should methods: should_eql, >> should_be_an_instance_of, should_redirect_to, should_be_success, >> should_not_be_nil, should_be_nil, should_not_be_nil, should_be_empty, >> should_be_success, should_not_change, and should_not_be_activated >> >> Is this using an old version of rspec, and/or do i need to define >> these methods and how? > > Old version. Just replace "should_not_" with "should_not " and then > "should_" with "should ". > >> >> thanks >> >> linoj >> >> _______________________________________________ >> 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 jonathan at parkerhill.com Wed May 30 01:38:02 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 30 May 2007 01:38:02 -0400 Subject: [rspec-users] rspec and autotest (was: questions rspec on rails) In-Reply-To: <57c63afe0705291617l53fd39e5pd1392126ba9519d3@mail.gmail.com> References: <57c63afe0705291451w35bf31f5qf9cc1bd3602c1110@mail.gmail.com> <1A596517-C71D-45DA-B7F4-6826E2C6D056@parkerhill.com> <57c63afe0705291617l53fd39e5pd1392126ba9519d3@mail.gmail.com> Message-ID: i havent done a scientific analysis but here's an example of whats on my autotest console when it decides to repeat itself # Waiting at 2007-05-30 01:33:19 script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb; script/spec -O spec/spec.opts spec/models/user_notifier_spec.rb ...........FFFF On May 29, 2007, at 7:17 PM, David Chelimsky wrote: > On 5/29/07, Jonathan Linowes wrote: >> yes, latest of both >> >> it happens when i have a syntax error in the file being tested (i >> think) > > I haven't experienced that with the latest versions. Please do let us > know what you discover. > > Cheers, > David > >> >> >> On May 29, 2007, at 5:51 PM, David Chelimsky wrote: >> >>> Do have the latest versions? >>> >>> RSpec-1.0.3 >>> ZenTest-3.6.0 >>> >>> ---------- Forwarded message ---------- >>> From: Jonathan Linowes >>> Date: May 29, 2007 11:47 AM >>> Subject: Re: [rspec-users] questions rspec on rails >>> To: rspec-users >>> >>> >>> Hi, I should have mentioned I already did that. Here's my spec.opts >>> file >>> >>> --colour >>> --format >>> progress >>> --loadby >>> mtime >>> >>> >>> >>> On May 29, 2007, at 7:17 AM, David Chelimsky wrote: >>> >>>> On 5/29/07, Jonathan Linowes wrote: >>>>> Hi, rather than flooding this list with separate emails, I've been >>>>> queueing up questions using rspec with rails. (an irc channel >>>>> would >>>>> be nice too :) Here ya go... >>>> >>>> Actually, we prefer separate email. There's too much here for >>>> any one >>>> person to answer quickly and since this will all be part of one >>>> thread >>>> it becomes difficult to find the great answer you got from so >>>> and so >>>> in a month. >>>> >>>> I'll answer one. >>>> >>>>> - Running autotest, when a spec errors, autotest sometimes >>>>> tries re- >>>>> running the test 2, 3, sometimes many more times repeatedly >>>>> although >>>>> I dont touche the file again. Is this a known bug? >>>> >>>> It's more of a conflict than a bug. Easily resolved: >>>> >>>> http://rubyforge.org/tracker/? >>>> func=detail&group_id=797&aid=11147&atid=3149 >>>> http://blog.davidchelimsky.net/articles/2007/05/29/rspec-and- >>>> autotest >>>> _______________________________________________ >>>> 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 From jonathan at parkerhill.com Wed May 30 05:05:24 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 30 May 2007 05:05:24 -0400 Subject: [rspec-users] authentication mocks Message-ID: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> hi I'm using restful_authentication and have controller specs working using users fixtures (and login_as) however i've been trying for hours without success to do it without fixtures, using mocks and stubs instead. anyone here done this? got code? :) thanks From jerry.west at ntlworld.com Wed May 30 09:22:07 2007 From: jerry.west at ntlworld.com (Jerry West) Date: Wed, 30 May 2007 14:22:07 +0100 Subject: [rspec-users] authentication mocks In-Reply-To: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> References: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> Message-ID: <465D7A7F.6080708@ntlworld.com> Hi Jonathan, You should be able to stub the routines a controller uses to check if a user is logged in, which will allow your controllers to function without actually requiring you to post login details. Something like 'controller.stub!(:logged_in?).and_return(true)' should suffice. Or you could stub the before_filter method itself. Check to see what your code calls behind the scenes. You may find you need to stub routines in the authentication module depending on what you want to spec (e.g. action on failing login, action on incorrect authorization, logging in via cookie, etc). Rgds, Jerry Jonathan Linowes wrote: > hi > I'm using restful_authentication > and have controller specs working using users fixtures (and login_as) > > however i've been trying for hours without success to do it without > fixtures, using mocks and stubs instead. > > anyone here done this? got code? > :) > > thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Wed May 30 11:33:21 2007 From: cwdinfo at gmail.com (s.ross) Date: Wed, 30 May 2007 08:33:21 -0700 Subject: [rspec-users] authentication mocks In-Reply-To: <465D7A7F.6080708@ntlworld.com> References: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> <465D7A7F.6080708@ntlworld.com> Message-ID: <21537DD8-D770-4539-B60C-9795A7C023A4@gmail.com> My observation is that mocking or stubbing as high in the API as possible is best. So, if you have to dive into someone else's code, your spec could break if their code breaks (e.g., restful_authentication). That's why Jerry's suggestion that you stub your own filter is great. Steve On May 30, 2007, at 6:22 AM, Jerry West wrote: > Hi Jonathan, > > You should be able to stub the routines a controller uses to check > if a > user is logged in, which will allow your controllers to function > without > actually requiring you to post login details. Something like > 'controller.stub!(:logged_in?).and_return(true)' should suffice. > Or you > could stub the before_filter method itself. Check to see what your > code calls behind the scenes. You may find you need to stub > routines in > the authentication module depending on what you want to spec (e.g. > action on failing login, action on incorrect authorization, logging in > via cookie, etc). > > Rgds, > Jerry > > > > Jonathan Linowes wrote: >> hi >> I'm using restful_authentication >> and have controller specs working using users fixtures (and login_as) >> >> however i've been trying for hours without success to do it without >> fixtures, using mocks and stubs instead. >> >> anyone here done this? got code? >> :) >> >> thanks >> _______________________________________________ >> 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 Steve Ross sross at calicowebdev.com http://www.calicowebdev.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070530/b8f8c22b/attachment-0001.html From marcus at ahnve.com Wed May 30 12:45:23 2007 From: marcus at ahnve.com (Marcus Ahnve) Date: Wed, 30 May 2007 18:45:23 +0200 Subject: [rspec-users] Selenium, Spec:Ui and ... forks? In-Reply-To: <8d961d900705290832h4aa931d2v6eaa160e706f4e92@mail.gmail.com> References: <4d4e79cc0705290642n3da90bf3lfdc9a5c8283e741e@mail.gmail.com> <8d961d900705290832h4aa931d2v6eaa160e706f4e92@mail.gmail.com> Message-ID: <4d4e79cc0705300945g576f451m77ea7a9e8f908b37@mail.gmail.com> On 5/29/07, aslak hellesoy wrote: > On 5/29/07, Marcus Ahnve wrote: > > I am using Spec:UI to run my Selenium tests, and I want to start > > Selenium only once, for many descriptions. > > The problem is that the browser is killed before the specs are run. > > Anyone has an idea why this is happening? > > > > Yes, because requiring a spec file doesn't automatically run it - it > just queues it up for running. Try killing your $browser in an > at_exit{} block instead Brilliant. Thanks. Cheers /Marcus -- http://marcus.ahnve.net From win at wincent.com Wed May 30 14:36:50 2007 From: win at wincent.com (Wincent Colaiuta) Date: Wed, 30 May 2007 20:36:50 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> Message-ID: <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> El 30/5/2007, a las 1:52, David Chelimsky escribi?: > I don't view that as a workaround at all. You should always be able to > run any example file by itself. If such a file relies on other files, > then it should require them. > > Another thing you could do is to put shared behaviours in spec/shared/ > and require everything in spec/shared from spec/spec_helper. > > The fact that the shared examples are in another file should have no > bearing on whether they have runtime access to whatever is in the > behaviours that include them. This all sounds odd to me. Can you post > a backtrace please? I've been looking at the code for this and was a bit puzzled by the following in lib/spec/dsl/behaviour.rb def add_shared_behaviour(behaviour) return if behaviour.equal?(found_behaviour = find_shared_behaviour(behaviour.description)) ... The intent is evidently to skip over previously instantiated shared behaviours, but I can't think of too many real-world cases where the object identity test (equal?) will succeed. About the only place it will succeed is in the spec (spec/spec/dsl/shared_behaviour_spec.rb): it "should NOT complain when adding a the same shared behaviour again (i.e. file gets reloaded)" do behaviour = behaviour_class.new("shared behaviour") {} behaviour_class.add_shared_behaviour(behaviour) behaviour_class.add_shared_behaviour(behaviour) end Here the exact same instance is being added and it is naturally skipped. But try adding something like the following to your spec_helper.rb file and watch the exceptions being raised when you do a "rake spec": describe "foobar", :shared => true do end Here every spec which includes the spec_helper.rb file will trigger an ArgumentError because the same shared behaviour gets re-evaluated over and over again and "found_behaviour" is set each time: def add_shared_behaviour(behaviour) return if behaviour.equal?(found_behaviour = find_shared_behaviour(behaviour.description)) raise ArgumentError.new("Shared Behaviour '# {behaviour.description}' already exists") if found_behaviour I think the solution here is to relax the equality comparison, use "==" instead of "equal?": Index: rspec/lib/spec/dsl/behaviour.rb =================================================================== --- rspec/lib/spec/dsl/behaviour.rb (revision 2060) +++ rspec/lib/spec/dsl/behaviour.rb (working copy) @@ -6,7 +6,7 @@ class << self def add_shared_behaviour(behaviour) - return if behaviour.equal?(found_behaviour = find_shared_behaviour(behaviour.description)) + return if behaviour == (found_behaviour = find_shared_behaviour(behaviour.description)) raise ArgumentError.new("Shared Behaviour '# {behaviour.description}' already exists") if found_behaviour shared_behaviours << behaviour end I've made this change against the RSpec trunk and "rake pre_commit" passes all specs. But I actually think that there might be some mistakes in the specs themselves: it "should NOT complain when adding a the same shared behaviour again (i.e. file gets reloaded)" do behaviour = behaviour_class.new("shared behaviour") {} behaviour_class.add_shared_behaviour(behaviour) behaviour_class.add_shared_behaviour(behaviour) end The two problems I see here are: - behaviour isn't actually a shared behaviour; you'd need to use "make_shared_behaviour" for that - adding the exact same instance as in the spec is not the same as what happens when the file gets reloaded, because when you reload a file, the "describe" block is actually going to instantiate a new (different) Behaviour instance very time I could change this spec to make it correct but then the following spec will no longer pass: it "should complain when adding a second shared behaviour with the same description" do make_shared_behaviour("shared behaviour") {} lambda { make_shared_behaviour("shared behaviour") {} }.should raise_error(ArgumentError) end It seems to me that to get the correct behaviour this spec will have to be jettisoned... It's not possible to have shared behaviours in reloaded files without relaxing the requirement above... Thoughts? Cheers, Wincent From anthony at digitalphenom.com Wed May 30 16:15:48 2007 From: anthony at digitalphenom.com (Anthony Carlos) Date: Wed, 30 May 2007 16:15:48 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> Message-ID: On May 29, 2007, at 7:52 PM, David Chelimsky wrote: > I don't view that as a workaround at all. You should always be able to > run any example file by itself. If such a file relies on other files, > then it should require them. > > Another thing you could do is to put shared behaviours in spec/shared/ > and require everything in spec/shared from spec/spec_helper. Thanks for the but of wisdom. It really helps to understand your intent! > The fact that the shared examples are in another file should have no > bearing on whether they have runtime access to whatever is in the > behaviours that include them. This all sounds odd to me. Can you post > a backtrace please? I'll see if I can reconstruct the situation and post something tonight or tomorrow. Thanks! -Anthony From tom at experthuman.com Wed May 30 16:33:44 2007 From: tom at experthuman.com (Tom Stuart) Date: Wed, 30 May 2007 21:33:44 +0100 Subject: [rspec-users] autotest and rspec_on_rails not happy Message-ID: Hi, I've been using the rspec and rspec_on_rails plugins quite happily on my Rails project for a while now. Today I noticed the autotest support in RSpec-1.0.3 and decided to give that a spin. Oh tragedy! $ autotest loading autotest/rails_rspec ./vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb:33:in `initialize': undefined method `singularize' for "organizations":String (NoMethodError) from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:395:in `call' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:395:in `tests_for_file' from ./vendor/plugins/rspec/lib/autotest/rspec.rb:19:in `tests_for_file' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:319:in `find_files_to_test' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:318:in `each' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:318:in `find_files_to_test' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:373:in `reset' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:164:in `run' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ autotest.rb:123:in `run' from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/bin/ autotest:48 from /usr/local/bin/autotest:18:in `load' from /usr/local/bin/autotest:18 Hey, that's not good. RSpec is totally happy when I run it by itself, and RSpec + autotest is totally happy when I run it in a fresh Rails project (as per the 1.0.3 announcement). It's just freaking out on my current project and I can't get it to un-freak out no matter how many files I knock out. Maybe this is a ZenTest problem instead. Maybe I've just done something incredibly stupid in my Rails project to break everything (but everything else works fine!). I don't know. I'm desperate. I really, really want autotest to work. Can anyone help? Cheers, -Tom From dchelimsky at gmail.com Wed May 30 16:52:48 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 16:52:48 -0400 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: References: Message-ID: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> On 5/30/07, Tom Stuart wrote: > Hi, > > I've been using the rspec and rspec_on_rails plugins quite happily on > my Rails project for a while now. Today I noticed the autotest > support in RSpec-1.0.3 and decided to give that a spin. > > Oh tragedy! > > $ autotest > loading autotest/rails_rspec > ./vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb:33:in > `initialize': undefined method `singularize' for > "organizations":String (NoMethodError) > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:395:in `call' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:395:in `tests_for_file' > from ./vendor/plugins/rspec/lib/autotest/rspec.rb:19:in > `tests_for_file' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:319:in `find_files_to_test' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:318:in `each' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:318:in `find_files_to_test' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:373:in `reset' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:164:in `run' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/ > autotest.rb:123:in `run' > from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/bin/ > autotest:48 > from /usr/local/bin/autotest:18:in `load' > from /usr/local/bin/autotest:18 > > Hey, that's not good. > > RSpec is totally happy when I run it by itself, and RSpec + autotest > is totally happy when I run it in a fresh Rails project (as per the > 1.0.3 announcement). It's just freaking out on my current project and > I can't get it to un-freak out no matter how many files I knock out. > > Maybe this is a ZenTest problem instead. Maybe I've just done > something incredibly stupid in my Rails project to break everything > (but everything else works fine!). I don't know. I'm desperate. I > really, really want autotest to work. Can anyone help? Check out this bug report: http://rubyforge.org/tracker/?func=detail&atid=3151&aid=11221&group_id=797 A change is in the works. Cheers, David > > Cheers, > -Tom > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tom at experthuman.com Wed May 30 17:10:21 2007 From: tom at experthuman.com (Tom Stuart) Date: Wed, 30 May 2007 22:10:21 +0100 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> Message-ID: On 30 May 2007, at 21:52, David Chelimsky wrote: > Check out this bug report: > http://rubyforge.org/tracker/? > func=detail&atid=3151&aid=11221&group_id=797 > A change is in the works. Oh, that's awesome. Easily fixed. Thank you so much. Cheers, -Tom From dchelimsky at gmail.com Wed May 30 17:11:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 17:11:34 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> Message-ID: <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> On 5/30/07, Wincent Colaiuta wrote: > El 30/5/2007, a las 1:52, David Chelimsky escribi?: > > > I don't view that as a workaround at all. You should always be able to > > run any example file by itself. If such a file relies on other files, > > then it should require them. > > > > Another thing you could do is to put shared behaviours in spec/shared/ > > and require everything in spec/shared from spec/spec_helper. > > > > The fact that the shared examples are in another file should have no > > bearing on whether they have runtime access to whatever is in the > > behaviours that include them. This all sounds odd to me. Can you post > > a backtrace please? > > I've been looking at the code for this and was a bit puzzled by the > following in lib/spec/dsl/behaviour.rb > > def add_shared_behaviour(behaviour) > return if behaviour.equal?(found_behaviour = > find_shared_behaviour(behaviour.description)) > ... > > The intent is evidently to skip over previously instantiated shared > behaviours, but I can't think of too many real-world cases where the > object identity test (equal?) will succeed. About the only place it > will succeed is in the spec (spec/spec/dsl/shared_behaviour_spec.rb): > > it "should NOT complain when adding a the same shared > behaviour again (i.e. file gets reloaded)" do > behaviour = behaviour_class.new("shared behaviour") {} > behaviour_class.add_shared_behaviour(behaviour) > behaviour_class.add_shared_behaviour(behaviour) > end > > Here the exact same instance is being added and it is naturally > skipped. But try adding something like the following to your > spec_helper.rb file and watch the exceptions being raised when you do > a "rake spec": > > describe "foobar", :shared => true do > end > > Here every spec which includes the spec_helper.rb file will trigger > an ArgumentError because the same shared behaviour gets re-evaluated > over and over again and "found_behaviour" is set each time: > > def add_shared_behaviour(behaviour) > return if behaviour.equal?(found_behaviour = > find_shared_behaviour(behaviour.description)) > raise ArgumentError.new("Shared Behaviour '# > {behaviour.description}' already exists") if found_behaviour > > I think the solution here is to relax the equality comparison, use > "==" instead of "equal?": > > Index: rspec/lib/spec/dsl/behaviour.rb > =================================================================== > --- rspec/lib/spec/dsl/behaviour.rb (revision 2060) > +++ rspec/lib/spec/dsl/behaviour.rb (working copy) > @@ -6,7 +6,7 @@ > class << self > def add_shared_behaviour(behaviour) > - return if behaviour.equal?(found_behaviour = > find_shared_behaviour(behaviour.description)) > + return if behaviour == (found_behaviour = > find_shared_behaviour(behaviour.description)) > raise ArgumentError.new("Shared Behaviour '# > {behaviour.description}' already exists") if found_behaviour > shared_behaviours << behaviour > end > > I've made this change against the RSpec trunk and "rake pre_commit" > passes all specs. But I actually think that there might be some > mistakes in the specs themselves: > > it "should NOT complain when adding a the same shared > behaviour again (i.e. file gets reloaded)" do > behaviour = behaviour_class.new("shared behaviour") {} > behaviour_class.add_shared_behaviour(behaviour) > behaviour_class.add_shared_behaviour(behaviour) > end > > The two problems I see here are: > > - behaviour isn't actually a shared behaviour; you'd need to use > "make_shared_behaviour" for that > > - adding the exact same instance as in the spec is not the same as > what happens when the file gets reloaded, because when you reload a > file, the "describe" block is actually going to instantiate a new > (different) Behaviour instance very time > > I could change this spec to make it correct but then the following > spec will no longer pass: > > it "should complain when adding a second shared behaviour with > the same description" do > make_shared_behaviour("shared behaviour") {} > lambda { make_shared_behaviour("shared behaviour") > {} }.should raise_error(ArgumentError) > end > > It seems to me that to get the correct behaviour this spec will have > to be jettisoned... It's not possible to have shared behaviours in > reloaded files without relaxing the requirement above... > > Thoughts? I think you're spot on about all of this. I'm thinking that a simple solution would be that each time a shared behaviour is registered, the location of its definition can be registered as well. Then we can ignore the ones defined in the same place when a file gets reloaded, but still complain when another one is defined with the same name from a different location. WDYT? > > Cheers, > Wincent > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 30 17:13:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 17:13:30 -0400 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> Message-ID: <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> On 5/30/07, Tom Stuart wrote: > On 30 May 2007, at 21:52, David Chelimsky wrote: > > Check out this bug report: > > http://rubyforge.org/tracker/? > > func=detail&atid=3151&aid=11221&group_id=797 > > A change is in the works. > > Oh, that's awesome. Easily fixed. Thank you so much. So did you apply Josh's 2nd patch and watch the problem disappear? > > Cheers, > -Tom > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tom at experthuman.com Wed May 30 17:17:05 2007 From: tom at experthuman.com (Tom Stuart) Date: Wed, 30 May 2007 22:17:05 +0100 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> Message-ID: <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> On 30 May 2007, at 22:13, David Chelimsky wrote: >> Easily fixed. > So did you apply Josh's 2nd patch and watch the problem disappear? Yep! Everything's happy again now, especially me. From dchelimsky at gmail.com Wed May 30 17:18:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 17:18:12 -0400 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> Message-ID: <57c63afe0705301418p45b45230xd2de8a0c2f994d9a@mail.gmail.com> On 5/30/07, Tom Stuart wrote: > On 30 May 2007, at 22:13, David Chelimsky wrote: > >> Easily fixed. > > So did you apply Josh's 2nd patch and watch the problem disappear? > > Yep! Everything's happy again now, especially me. :) Thanks. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joshknowles at gmail.com Wed May 30 17:31:37 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Wed, 30 May 2007 14:31:37 -0700 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> Message-ID: On 5/30/07, Tom Stuart wrote: > > > Yep! Everything's happy again now, especially me. Good to hear. Sorry I broke it the first time! Josh -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070530/7c9d426e/attachment.html From dchelimsky at gmail.com Wed May 30 17:34:07 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 17:34:07 -0400 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> Message-ID: <57c63afe0705301434j39ab7870g11c386b10044213b@mail.gmail.com> On 5/30/07, Josh Knowles wrote: > > > On 5/30/07, Tom Stuart wrote: > > > > Yep! Everything's happy again now, especially me. > > > Good to hear. Sorry I broke it the first time! Thanks for fixing it so fast. David > > Josh > > > > > -- > Josh Knowles > joshknowles at gmail.com > http://joshknowles.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joshknowles at gmail.com Wed May 30 18:13:59 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Wed, 30 May 2007 15:13:59 -0700 Subject: [rspec-users] Error when accessing flash through helper specs Message-ID: Running edge rspec/rails I'm having a heck of a time testing helpers which are accessing the flash(1) since changeset 2044. Is anyone else seeing this problem? Has anyone found a workaround and or proper fix? Josh 1: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=11223&group_id=797 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070530/d8e4450f/attachment.html From win at wincent.com Wed May 30 18:35:49 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 31 May 2007 00:35:49 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> Message-ID: <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> El 30/5/2007, a las 23:11, David Chelimsky escribi?: > I think you're spot on about all of this. I'm thinking that a simple > solution would be that each time a shared behaviour is registered, the > location of its definition can be registered as well. Then we can > ignore the ones defined in the same place when a file gets reloaded, > but still complain when another one is defined with the same name from > a different location. > > WDYT? Would be great -- it would basically capture the intent of your current implementation -- but how would you get the location of its definition? Cheers, Wincent From dchelimsky at gmail.com Wed May 30 18:51:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 18:51:00 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> Message-ID: <57c63afe0705301551i6415432cyf55def0e205c8954@mail.gmail.com> On 5/30/07, Wincent Colaiuta wrote: > El 30/5/2007, a las 23:11, David Chelimsky escribi?: > > > I think you're spot on about all of this. I'm thinking that a simple > > solution would be that each time a shared behaviour is registered, the > > location of its definition can be registered as well. Then we can > > ignore the ones defined in the same place when a file gets reloaded, > > but still complain when another one is defined with the same name from > > a different location. > > > > WDYT? > > Would be great -- it would basically capture the intent of your > current implementation -- but how would you get the location of its > definition? By inspecting caller. We do this already in building up the backtrace. I'll pursue this soon. Cheers, David > > Cheers, > Wincent > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jed.hurt at gmail.com Wed May 30 19:11:26 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Wed, 30 May 2007 17:11:26 -0600 Subject: [rspec-users] Specify attr_protected Message-ID: This is kind of a two part question. Question One: I want to be sure that an Order model is protecting sensitive attributes from mass assignment. The example looks like this: describe Order do it "should protect total attribute from mass assignment" do @order = Order.new(:total => 0.05) @order.total.should_not == 0.05 end end And the code to implement it: class Order < ActiveRecord::Base attr_protected :total end It seems to work, but is there a better way? Not saying that this way is bad, just that I'm very green :) Question Two: I actually have a bunch of attributes that need to be protected. Rather than hand-writing a call to the 'it' method for each attribute, could I just loop over an array of attributes that need to be checked and programatically define the 'it' calls? Pseudo-code: describe Order do [:total, :id, :customer_ip, :status, :error_message, :updated_at, :created_at, :finalize, :tax, :shipping].each do |attribute| it "should protect #{attribute} attributes from mass assignment" do @order = Order.new(attribute => 'hax0rz') @order.attribute.should_not == 'hax0rz' end end end What would the actual implementation look like? From barjunk at attglobal.net Wed May 30 18:11:54 2007 From: barjunk at attglobal.net (barsalou) Date: Wed, 30 May 2007 14:11:54 -0800 Subject: [rspec-users] Using mocks Message-ID: <20070530141154.24wxj1miwww8k0c4@lcgalaska.com> I've just started doing TDD/BDD and like the idea of mocks. So I set out to use them. The doc pages seem great, I setup the mock and then it just works. Here is what I am trying to do: Myuser is a non-rails model of user attributes. We are going to be mocking the connection to the ldap server. The user class has a login method that connects to the ldap server and if successful, returns the user object. For now though, I'd be happy for it to return the true value. I'm writing this message cause it doesn't work for me, but I'm sure it is because I am not doing something right...but unsure what exactly that is. describe Myuser do before(:each) do my_mock = mock(:some_name) my_mock.should_receive(:login).with("user","pass").and_return(true) end it "should be logged in" do my_mock.login("user","pass") end end I get this: NameError in 'Myuser should be logged in' undefined local variable or method `my_mock' for [Dynamically generated class for RSpec example]:# I figure I'm using the mock wrong in the test, but couldn't find an example that made sense to my newby mind. Thanks for any direction. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From dchelimsky at gmail.com Wed May 30 19:43:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 19:43:29 -0400 Subject: [rspec-users] Specify attr_protected In-Reply-To: References: Message-ID: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> On 5/30/07, Jed Hurt wrote: > This is kind of a two part question. > > Question One: I want to be sure that an Order model is protecting > sensitive attributes from mass assignment. > > The example looks like this: > > describe Order do > it "should protect total attribute from mass assignment" do > @order = Order.new(:total => 0.05) > @order.total.should_not == 0.05 > end > end > > And the code to implement it: > > class Order < ActiveRecord::Base > attr_protected :total > end > > > It seems to work, but is there a better way? Not saying that this way > is bad, just that I'm very green :) This seems pretty good to me. You're not cluttering up the example with what the value of total IS - just what it is not, which is the thing you're interested in. > > > Question Two: I actually have a bunch of attributes that need to be > protected. Rather than hand-writing a call to the 'it' method for each > attribute, could I just loop over an array of attributes that need to > be checked and programatically define the 'it' calls? > > Pseudo-code: > > describe Order do > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > :created_at, :finalize, :tax, :shipping].each do |attribute| > it "should protect #{attribute} attributes from mass assignment" do > @order = Order.new(attribute => 'hax0rz') > @order.attribute.should_not == 'hax0rz' > end > end > end > > What would the actual implementation look like? I think it would look exactly like what you wrote. Have you tried it? From dchelimsky at gmail.com Wed May 30 19:45:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 19:45:58 -0400 Subject: [rspec-users] Using mocks In-Reply-To: <20070530141154.24wxj1miwww8k0c4@lcgalaska.com> References: <20070530141154.24wxj1miwww8k0c4@lcgalaska.com> Message-ID: <57c63afe0705301645y15868ecqb8e65803529a3a5e@mail.gmail.com> On 5/30/07, barsalou wrote: > I've just started doing TDD/BDD and like the idea of mocks. So I set > out to use them. The doc pages seem great, I setup the mock and then > it just works. Here is what I am trying to do: > > Myuser is a non-rails model of user attributes. We are going to be > mocking the connection to the ldap server. The user class has a login > method that connects to the ldap server and if successful, returns the > user object. For now though, I'd be happy for it to return the true > value. > > I'm writing this message cause it doesn't work for me, but I'm sure it > is because I am not doing something right...but unsure what exactly > that is. > > describe Myuser do > before(:each) do > my_mock = mock(:some_name) > my_mock.should_receive(:login).with("user","pass").and_return(true) > end These need to be instance variables: describe Myuser do before(:each) do @my_mock = mock(:some_name) @my_mock.should_receive(:login).with("user","pass").and_return(true) end it "should be logged in" do @my_mock.login("user","pass") end end See if that works. David > > > it "should be logged in" do > my_mock.login("user","pass") > end > > end > > I get this: > > NameError in 'Myuser should be logged in' > undefined local variable or method `my_mock' for [Dynamically generated > class for RSpec example]:# > > I figure I'm using the mock wrong in the test, but couldn't find an > example that made sense to my newby mind. > > Thanks for any direction. > > Mike B. > > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From barjunk at attglobal.net Wed May 30 18:11:54 2007 From: barjunk at attglobal.net (barsalou) Date: Wed, 30 May 2007 14:11:54 -0800 Subject: [rspec-users] Using mocks Message-ID: <20070530141154.24wxj1miwww8k0c4@lcgalaska.com> I've just started doing TDD/BDD and like the idea of mocks. So I set out to use them. The doc pages seem great, I setup the mock and then it just works. Here is what I am trying to do: Myuser is a non-rails model of user attributes. We are going to be mocking the connection to the ldap server. The user class has a login method that connects to the ldap server and if successful, returns the user object. For now though, I'd be happy for it to return the true value. I'm writing this message cause it doesn't work for me, but I'm sure it is because I am not doing something right...but unsure what exactly that is. describe Myuser do before(:each) do my_mock = mock(:some_name) my_mock.should_receive(:login).with("user","pass").and_return(true) end it "should be logged in" do my_mock.login("user","pass") end end I get this: NameError in 'Myuser should be logged in' undefined local variable or method `my_mock' for [Dynamically generated class for RSpec example]:# I figure I'm using the mock wrong in the test, but couldn't find an example that made sense to my newby mind. Thanks for any direction. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From daniel at danielfischer.com Wed May 30 20:03:01 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Wed, 30 May 2007 17:03:01 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? Message-ID: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> My problem has been listed here: http://railsforum.com/viewtopic.php?pid=25439#p25439 Don't think it would be required to completely re-type it here :) Thanks! -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community From luislavena at gmail.com Wed May 30 20:04:08 2007 From: luislavena at gmail.com (Luis Lavena) Date: Wed, 30 May 2007 21:04:08 -0300 Subject: [rspec-users] Specify attr_protected In-Reply-To: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> Message-ID: <71166b3b0705301704p953a57bt161fe1bdab95a23c@mail.gmail.com> On 5/30/07, David Chelimsky wrote: > On 5/30/07, Jed Hurt wrote: [...] > > Question Two: I actually have a bunch of attributes that need to be > > protected. Rather than hand-writing a call to the 'it' method for each > > attribute, could I just loop over an array of attributes that need to > > be checked and programatically define the 'it' calls? > > > > Pseudo-code: > > > > describe Order do > > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > > :created_at, :finalize, :tax, :shipping].each do |attribute| > > it "should protect #{attribute} attributes from mass assignment" do > > @order = Order.new(attribute => 'hax0rz') > > @order.attribute.should_not == 'hax0rz' > > end > > end > > end > > > > What would the actual implementation look like? > > I think it would look exactly like what you wrote. Have you tried it? I do exactly the same: [:title, :content_type, :basename].each do |attr| it { @asset.should have_present(attr) } end [:title, :basename].each do |attr| it { @asset.should have_unique(attr) } end In this case, I use the self description provided by matchers, but works also with #{} for double quoted strings. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From jchris at mfdz.com Wed May 30 20:08:37 2007 From: jchris at mfdz.com (Chris Anderson) Date: Wed, 30 May 2007 17:08:37 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> Message-ID: Daniel, Usually the route specs have nothing to do with the controller's code. Your controller may not be issuing the proper find, but your route setup has no effect on the do_get method in your second spec. More helpful would be to see your controller code. Chris On 5/30/07, Fischer, Daniel wrote: > My problem has been listed here: > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > Don't think it would be required to completely re-type it here :) > > Thanks! > > -- > -Daniel Fischer > > http://danielfischer.com - Geek Blog > http://abigfisch.com - Portfolio > http://writersbeat.com - Writing Community > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Chris Anderson http://jchris.mfdz.com From daniel at danielfischer.com Wed May 30 20:15:18 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Wed, 30 May 2007 17:15:18 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> Message-ID: <7e565b5c0705301715i3ffb9576g711fa5c638435848@mail.gmail.com> Chris, class PostsController < ApplicationController before_filter(:get_user) before_filter :login_required def index @posts = @user.posts.find(:all) respond_to do |format| format.html # index.rhtml format.xml { render :xml => @posts.to_xml } end end def show respond_to do |format| format.html # show.rhtml format.xml { render :xml => @post.to_xml } end end def new @post = Post.new end def edit end def create @post = Post.new(params[:post]) @post.user_id = @user.id respond_to do |format| if @post.save flash[:notice] = 'Post was successfully created.' format.html { redirect_to post_url(@user, @post) } format.xml { head :created, :location => post_url(@user, @post) } else format.html { render :action => "new" } format.xml { render :xml => @post.errors.to_xml } end end end def update respond_to do |format| if @post.update_attributes(params[:post]) flash[:notice] = 'Post was successfully updated.' format.html { redirect_to post_url(@user, @post) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @post.errors.to_xml } end end end def destroy @post.destroy respond_to do |format| format.html { redirect_to posts_url } format.xml { head :ok } end end private def get_user @user = User.find(params[:user_id]) @post = @user.posts.find(params[:id]) if params[:id] end end Hope that clears it up :) On 5/30/07, Chris Anderson wrote: > Daniel, > Usually the route specs have nothing to do with the controller's code. > Your controller may not be issuing the proper find, but your route > setup has no effect on the do_get method in your second spec. > > More helpful would be to see your controller code. > > Chris > > On 5/30/07, Fischer, Daniel wrote: > > My problem has been listed here: > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > Don't think it would be required to completely re-type it here :) > > > > Thanks! > > > > -- > > -Daniel Fischer > > > > http://danielfischer.com - Geek Blog > > http://abigfisch.com - Portfolio > > http://writersbeat.com - Writing Community > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > Chris Anderson > http://jchris.mfdz.com > -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community From barjunk at attglobal.net Wed May 30 20:44:25 2007 From: barjunk at attglobal.net (barsalou) Date: Wed, 30 May 2007 16:44:25 -0800 Subject: [rspec-users] Using mocks In-Reply-To: References: Message-ID: <20070530164425.ga54pqeca8o8w0kc@lcgalaska.com> > Message: 11 > Date: Wed, 30 May 2007 19:45:58 -0400 > From: "David Chelimsky" > Subject: Re: [rspec-users] Using mocks > To: rspec-users > Message-ID: > <57c63afe0705301645y15868ecqb8e65803529a3a5e at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 5/30/07, barsalou wrote: >> I've just started doing TDD/BDD and like the idea of mocks. So I set >> out to use them. The doc pages seem great, I setup the mock and then >> it just works. Here is what I am trying to do: >> >> Myuser is a non-rails model of user attributes. We are going to be >> mocking the connection to the ldap server. The user class has a login >> method that connects to the ldap server and if successful, returns the >> user object. For now though, I'd be happy for it to return the true >> value. >> >> I'm writing this message cause it doesn't work for me, but I'm sure it >> is because I am not doing something right...but unsure what exactly >> that is. >> >> describe Myuser do >> before(:each) do >> my_mock = mock(:some_name) >> my_mock.should_receive(:login).with("user","pass").and_return(true) >> end > > These need to be instance variables: > > describe Myuser do > before(:each) do > @my_mock = mock(:some_name) > @my_mock.should_receive(:login).with("user","pass").and_return(true) > end > it "should be logged in" do > @my_mock.login("user","pass") > end > end > > See if that works. > > David >> That worked for me just fine. What do I need to do to change the examples page to include an example of the usage of the created mock as well as mention that those mocks should be instance variables? I'm assuming they have to be instance variables because they go out of scope at the end of before_each? Thanks for the help. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From dchelimsky at gmail.com Wed May 30 20:49:06 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 20:49:06 -0400 Subject: [rspec-users] Using mocks In-Reply-To: <20070530164425.ga54pqeca8o8w0kc@lcgalaska.com> References: <20070530164425.ga54pqeca8o8w0kc@lcgalaska.com> Message-ID: <57c63afe0705301749n68d88ed5j93f33620f8ee8836@mail.gmail.com> On 5/30/07, barsalou wrote: > > > Message: 11 > > Date: Wed, 30 May 2007 19:45:58 -0400 > > From: "David Chelimsky" > > Subject: Re: [rspec-users] Using mocks > > To: rspec-users > > Message-ID: > > <57c63afe0705301645y15868ecqb8e65803529a3a5e at mail.gmail.com> > > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > > > On 5/30/07, barsalou wrote: > >> I've just started doing TDD/BDD and like the idea of mocks. So I set > >> out to use them. The doc pages seem great, I setup the mock and then > >> it just works. Here is what I am trying to do: > >> > >> Myuser is a non-rails model of user attributes. We are going to be > >> mocking the connection to the ldap server. The user class has a login > >> method that connects to the ldap server and if successful, returns the > >> user object. For now though, I'd be happy for it to return the true > >> value. > >> > >> I'm writing this message cause it doesn't work for me, but I'm sure it > >> is because I am not doing something right...but unsure what exactly > >> that is. > >> > >> describe Myuser do > >> before(:each) do > >> my_mock = mock(:some_name) > >> my_mock.should_receive(:login).with("user","pass").and_return(true) > >> end > > > > These need to be instance variables: > > > > describe Myuser do > > before(:each) do > > @my_mock = mock(:some_name) > > @my_mock.should_receive(:login).with("user","pass").and_return(true) > > end > > it "should be logged in" do > > @my_mock.login("user","pass") > > end > > end > > > > See if that works. > > > > David > >> > > That worked for me just fine. What do I need to do to change the > examples page to include an example of the usage of the created mock as > well as mention that those mocks should be instance variables? Submit a feature request in the tracker: http://rubyforge.org/tracker/?group_id=797 I tried to set up a docs tracker, but screwed it up and haven't gotten the rubyforge folks to fix it for me yet ;) > > I'm assuming they have to be instance variables because they go out of > scope at the end of before_each? > > Thanks for the help. > > Mike B. > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jonathan at parkerhill.com Wed May 30 20:50:17 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 30 May 2007 20:50:17 -0400 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> Message-ID: <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> Don't you need to stub the User model :find too? (needed in your private get_user call) private def get_user @user = User.find(params[:user_id]) @post = @user.posts.find(params[:id]) if params[:id] end On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > My problem has been listed here: > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > Don't think it would be required to completely re-type it here :) > > Thanks! > > -- > -Daniel Fischer > > http://danielfischer.com - Geek Blog > http://abigfisch.com - Portfolio > http://writersbeat.com - Writing Community > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From daniel at danielfischer.com Wed May 30 21:07:18 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Wed, 30 May 2007 18:07:18 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> Message-ID: <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> Jonathan, Yeah something like that. I have no idea how to put it together properly. I'm beyond confused at this point, that's why I could really use some help. I figured out my "response" error, but now Im trying to "find all posts" Right now I got something like: User.should_receive(:posts).with(:all).and_return([@posts]) But I know it should be User.posts.find(:all) - i'm not sure how to make this a proper behavior check. How do I setup my mocks to correspond with this? Thanks. On 5/30/07, Jonathan Linowes wrote: > Don't you need to stub the User model :find too? (needed in your > private get_user call) > > private > def get_user > @user = User.find(params[:user_id]) > @post = @user.posts.find(params[:id]) if params[:id] > end > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > My problem has been listed here: > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > Don't think it would be required to completely re-type it here :) > > > > Thanks! > > > > -- > > -Daniel Fischer > > > > http://danielfischer.com - Geek Blog > > http://abigfisch.com - Portfolio > > http://writersbeat.com - Writing Community > > _______________________________________________ > > 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 > -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community From cwdinfo at gmail.com Wed May 30 21:07:33 2007 From: cwdinfo at gmail.com (s.ross) Date: Wed, 30 May 2007 18:07:33 -0700 Subject: [rspec-users] Using mocks In-Reply-To: <20070530141154.24wxj1miwww8k0c4@lcgalaska.com> References: <20070530141154.24wxj1miwww8k0c4@lcgalaska.com> Message-ID: <872E949B-15FF-4F6D-87C9-ADD5F2EDC0A4@gmail.com> Make my_mock an instance variable: @my_mock = mock('some_name') And reference it as @my_mock in your examples. See if that fixes it. --steve On May 30, 2007, at 3:11 PM, barsalou wrote: > I've just started doing TDD/BDD and like the idea of mocks. So I set > out to use them. The doc pages seem great, I setup the mock and then > it just works. Here is what I am trying to do: > > Myuser is a non-rails model of user attributes. We are going to be > mocking the connection to the ldap server. The user class has a login > method that connects to the ldap server and if successful, returns the > user object. For now though, I'd be happy for it to return the true > value. > > I'm writing this message cause it doesn't work for me, but I'm sure it > is because I am not doing something right...but unsure what exactly > that is. > > describe Myuser do > before(:each) do > my_mock = mock(:some_name) > my_mock.should_receive(:login).with("user","pass").and_return > (true) > end > > > it "should be logged in" do > my_mock.login("user","pass") > end > > end > > I get this: > > NameError in 'Myuser should be logged in' > undefined local variable or method `my_mock' for [Dynamically > generated > class for RSpec example]:# > > I figure I'm using the mock wrong in the test, but couldn't find an > example that made sense to my newby mind. > > Thanks for any direction. > > Mike B. > > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Steve Ross sross at calicowebdev.com http://www.calicowebdev.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070530/0873f6b4/attachment.html From jonathan at parkerhill.com Wed May 30 23:09:29 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 30 May 2007 23:09:29 -0400 Subject: [rspec-users] stubbing controller methods, I'm stumped In-Reply-To: <21537DD8-D770-4539-B60C-9795A7C023A4@gmail.com> References: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> <465D7A7F.6080708@ntlworld.com> <21537DD8-D770-4539-B60C-9795A7C023A4@gmail.com> Message-ID: <016DE1CA-30AB-4AD0-A7C6-E036F8D48132@parkerhill.com> I must be dense because I keep having trouble stubbing anything in a controller. I can stub models but not controller methods, whether directly defined in the controller file or in a module Here's a small example: # sandbox_controller.rb class SandboxController < ApplicationController def someaction @value = somemethod end def somemethod return 10 end end # sandbox_controller_spec.rb require File.dirname(__FILE__) + '/../spec_helper' describe SandboxController, " handling someaction" do before do SandboxController.stub!(:somemethod).and_return(99) end it "should get 99" do get :someaction assigns[:value].should equal(99) end end # console $ script/spec spec/controllers/sandbox_controller_spec.rb --color -- format specdoc SandboxController handling someaction - should get 99 (FAILED - 1) 1) 'SandboxController handling someaction should get 99' FAILED expected 99, got 10 (using .equal?) ./spec/controllers/sandbox_controller_spec.rb:10: script/spec:4: Finished in 0.13381 seconds 1 example, 1 failure In real life I want to stub out the authentication methods in module / lib/authenticated_system.rb , or the before_filter method as suggested to me earlier so I can move forward with my spec'ing controllers that have authorization built in. This is getting painful. linoj From jonathan at parkerhill.com Wed May 30 23:12:18 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 30 May 2007 23:12:18 -0400 Subject: [rspec-users] stubbing controller methods, I'm stumped In-Reply-To: <016DE1CA-30AB-4AD0-A7C6-E036F8D48132@parkerhill.com> References: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> <465D7A7F.6080708@ntlworld.com> <21537DD8-D770-4539-B60C-9795A7C023A4@gmail.com> <016DE1CA-30AB-4AD0-A7C6-E036F8D48132@parkerhill.com> Message-ID: btw, if you're so inclined, I'm on irc as "linoj" :) On May 30, 2007, at 11:09 PM, Jonathan Linowes wrote: > I must be dense because I keep having trouble stubbing anything in > a controller. I can stub models but not controller methods, whether > directly defined in the controller file or in a module > > Here's a small example: > > # sandbox_controller.rb > > class SandboxController < ApplicationController > def someaction > @value = somemethod > end > > def somemethod > return 10 > end > end > > # sandbox_controller_spec.rb > > require File.dirname(__FILE__) + '/../spec_helper' > > describe SandboxController, " handling someaction" do > before do > SandboxController.stub!(:somemethod).and_return(99) > end > > it "should get 99" do > get :someaction > assigns[:value].should equal(99) > end > end > > # console > > $ script/spec spec/controllers/sandbox_controller_spec.rb --color -- > format specdoc > > SandboxController handling someaction > - should get 99 (FAILED - 1) > > 1) > 'SandboxController handling someaction should get 99' FAILED > expected 99, got 10 (using .equal?) > ./spec/controllers/sandbox_controller_spec.rb:10: > script/spec:4: > > Finished in 0.13381 seconds > > 1 example, 1 failure > > > In real life I want to stub out the authentication methods in > module /lib/authenticated_system.rb , or the before_filter method > as suggested to me earlier so I can move forward with my spec'ing > controllers that have authorization built in. This is getting painful. > > linoj > > > From dchelimsky at gmail.com Wed May 30 23:19:41 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 30 May 2007 23:19:41 -0400 Subject: [rspec-users] stubbing controller methods, I'm stumped In-Reply-To: <016DE1CA-30AB-4AD0-A7C6-E036F8D48132@parkerhill.com> References: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> <465D7A7F.6080708@ntlworld.com> <21537DD8-D770-4539-B60C-9795A7C023A4@gmail.com> <016DE1CA-30AB-4AD0-A7C6-E036F8D48132@parkerhill.com> Message-ID: <57c63afe0705302019i7082b2eag60119fa45012a8b@mail.gmail.com> On 5/30/07, Jonathan Linowes wrote: > I must be dense because I keep having trouble stubbing anything in a > controller. I can stub models but not controller methods, whether > directly defined in the controller file or in a module > > Here's a small example: > > # sandbox_controller.rb > > class SandboxController < ApplicationController > def someaction > @value = somemethod > end > > def somemethod > return 10 > end This is an instance method. > end > > # sandbox_controller_spec.rb > > require File.dirname(__FILE__) + '/../spec_helper' > > describe SandboxController, " handling someaction" do > before do > SandboxController.stub!(:somemethod).and_return(99) This is stubbing a class method, which doesn't exists. Try this: controller.stub!(:somemethod).and_return(99) Cheers, David > end > > it "should get 99" do > get :someaction > assigns[:value].should equal(99) > end > end > > # console > > $ script/spec spec/controllers/sandbox_controller_spec.rb --color -- > format specdoc > > SandboxController handling someaction > - should get 99 (FAILED - 1) > > 1) > 'SandboxController handling someaction should get 99' FAILED > expected 99, got 10 (using .equal?) > ./spec/controllers/sandbox_controller_spec.rb:10: > script/spec:4: > > Finished in 0.13381 seconds > > 1 example, 1 failure > > > In real life I want to stub out the authentication methods in module / > lib/authenticated_system.rb , or the before_filter method as > suggested to me earlier so I can move forward with my spec'ing > controllers that have authorization built in. This is getting painful. > > linoj > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jed.hurt at gmail.com Wed May 30 23:23:07 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Wed, 30 May 2007 21:23:07 -0600 Subject: [rspec-users] Specify attr_protected In-Reply-To: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> Message-ID: Wow. It does work. I didn't even bother to try it because I figured that calling 'it' inside of the 'each' block would not be the same as calling 'it' directly inside of the 'describe' block. I've never actually written a method that yields to a block. I'm still trying to fit into my Rubyist pants. So Ruby actually yields down into the 'each' block from the parent 'describe' block? On 5/30/07, David Chelimsky wrote: > On 5/30/07, Jed Hurt wrote: > > This is kind of a two part question. > > > > Question One: I want to be sure that an Order model is protecting > > sensitive attributes from mass assignment. > > > > The example looks like this: > > > > describe Order do > > it "should protect total attribute from mass assignment" do > > @order = Order.new(:total => 0.05) > > @order.total.should_not == 0.05 > > end > > end > > > > And the code to implement it: > > > > class Order < ActiveRecord::Base > > attr_protected :total > > end > > > > > > It seems to work, but is there a better way? Not saying that this way > > is bad, just that I'm very green :) > > This seems pretty good to me. You're not cluttering up the example > with what the value of total IS - just what it is not, which is the > thing you're interested in. > > > > > > > Question Two: I actually have a bunch of attributes that need to be > > protected. Rather than hand-writing a call to the 'it' method for each > > attribute, could I just loop over an array of attributes that need to > > be checked and programatically define the 'it' calls? > > > > Pseudo-code: > > > > describe Order do > > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > > :created_at, :finalize, :tax, :shipping].each do |attribute| > > it "should protect #{attribute} attributes from mass assignment" do > > @order = Order.new(attribute => 'hax0rz') > > @order.attribute.should_not == 'hax0rz' > > end > > end > > end > > > > What would the actual implementation look like? > > I think it would look exactly like what you wrote. Have you tried it? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jed.hurt at gmail.com Wed May 30 23:45:21 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Wed, 30 May 2007 21:45:21 -0600 Subject: [rspec-users] Specify attr_protected In-Reply-To: References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> Message-ID: Hmmm.... scratch that. I actually had a typo in my code. After correcting the typo, It looks like the code is trying to literally call @order.attribute rather than @order.id, @order.total, etc... Is eval the best option? eval("@order.#{attribute}.should_not == 'hax0rz'") On 5/30/07, Jed Hurt wrote: > Wow. It does work. I didn't even bother to try it because I figured > that calling 'it' inside of the 'each' block would not be the same as > calling 'it' directly inside of the 'describe' block. I've never > actually written a method that yields to a block. I'm still trying to > fit into my Rubyist pants. > > So Ruby actually yields down into the 'each' block from the parent > 'describe' block? > > On 5/30/07, David Chelimsky wrote: > > On 5/30/07, Jed Hurt wrote: > > > This is kind of a two part question. > > > > > > Question One: I want to be sure that an Order model is protecting > > > sensitive attributes from mass assignment. > > > > > > The example looks like this: > > > > > > describe Order do > > > it "should protect total attribute from mass assignment" do > > > @order = Order.new(:total => 0.05) > > > @order.total.should_not == 0.05 > > > end > > > end > > > > > > And the code to implement it: > > > > > > class Order < ActiveRecord::Base > > > attr_protected :total > > > end > > > > > > > > > It seems to work, but is there a better way? Not saying that this way > > > is bad, just that I'm very green :) > > > > This seems pretty good to me. You're not cluttering up the example > > with what the value of total IS - just what it is not, which is the > > thing you're interested in. > > > > > > > > > > > Question Two: I actually have a bunch of attributes that need to be > > > protected. Rather than hand-writing a call to the 'it' method for each > > > attribute, could I just loop over an array of attributes that need to > > > be checked and programatically define the 'it' calls? > > > > > > Pseudo-code: > > > > > > describe Order do > > > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > > > :created_at, :finalize, :tax, :shipping].each do |attribute| > > > it "should protect #{attribute} attributes from mass assignment" do > > > @order = Order.new(attribute => 'hax0rz') > > > @order.attribute.should_not == 'hax0rz' > > > end > > > end > > > end > > > > > > What would the actual implementation look like? > > > > I think it would look exactly like what you wrote. Have you tried it? > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From dchelimsky at gmail.com Thu May 31 00:00:59 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 00:00:59 -0400 Subject: [rspec-users] Specify attr_protected In-Reply-To: References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> Message-ID: <57c63afe0705302100q43883e4r4381301eaa35b917@mail.gmail.com> On 5/30/07, Jed Hurt wrote: > Hmmm.... scratch that. I actually had a typo in my code. After > correcting the typo, It looks like the code is trying to literally > call @order.attribute rather than @order.id, @order.total, etc... > > Is eval the best option? > > eval("@order.#{attribute}.should_not == 'hax0rz'") That, or (I think): (@order.send attribute).should)_not == hax0rz' > > On 5/30/07, Jed Hurt wrote: > > Wow. It does work. I didn't even bother to try it because I figured > > that calling 'it' inside of the 'each' block would not be the same as > > calling 'it' directly inside of the 'describe' block. I've never > > actually written a method that yields to a block. I'm still trying to > > fit into my Rubyist pants. > > > > So Ruby actually yields down into the 'each' block from the parent > > 'describe' block? > > > > On 5/30/07, David Chelimsky wrote: > > > On 5/30/07, Jed Hurt wrote: > > > > This is kind of a two part question. > > > > > > > > Question One: I want to be sure that an Order model is protecting > > > > sensitive attributes from mass assignment. > > > > > > > > The example looks like this: > > > > > > > > describe Order do > > > > it "should protect total attribute from mass assignment" do > > > > @order = Order.new(:total => 0.05) > > > > @order.total.should_not == 0.05 > > > > end > > > > end > > > > > > > > And the code to implement it: > > > > > > > > class Order < ActiveRecord::Base > > > > attr_protected :total > > > > end > > > > > > > > > > > > It seems to work, but is there a better way? Not saying that this way > > > > is bad, just that I'm very green :) > > > > > > This seems pretty good to me. You're not cluttering up the example > > > with what the value of total IS - just what it is not, which is the > > > thing you're interested in. > > > > > > > > > > > > > > > Question Two: I actually have a bunch of attributes that need to be > > > > protected. Rather than hand-writing a call to the 'it' method for each > > > > attribute, could I just loop over an array of attributes that need to > > > > be checked and programatically define the 'it' calls? > > > > > > > > Pseudo-code: > > > > > > > > describe Order do > > > > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > > > > :created_at, :finalize, :tax, :shipping].each do |attribute| > > > > it "should protect #{attribute} attributes from mass assignment" do > > > > @order = Order.new(attribute => 'hax0rz') > > > > @order.attribute.should_not == 'hax0rz' > > > > end > > > > end > > > > end > > > > > > > > What would the actual implementation look like? > > > > > > I think it would look exactly like what you wrote. Have you tried it? > > > _______________________________________________ > > > 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 Thu May 31 00:01:28 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 00:01:28 -0400 Subject: [rspec-users] Specify attr_protected In-Reply-To: <57c63afe0705302100q43883e4r4381301eaa35b917@mail.gmail.com> References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> <57c63afe0705302100q43883e4r4381301eaa35b917@mail.gmail.com> Message-ID: <57c63afe0705302101s2a163158s1e88b1ce738b45c3@mail.gmail.com> On 5/31/07, David Chelimsky wrote: > On 5/30/07, Jed Hurt wrote: > > Hmmm.... scratch that. I actually had a typo in my code. After > > correcting the typo, It looks like the code is trying to literally > > call @order.attribute rather than @order.id, @order.total, etc... > > > > Is eval the best option? > > > > eval("@order.#{attribute}.should_not == 'hax0rz'") > > That, or (I think): > > (@order.send attribute).should)_not == hax0rz' > Sorry - typo - this: (@order.send attribute).should_not == hax0rz' > > > > > On 5/30/07, Jed Hurt wrote: > > > Wow. It does work. I didn't even bother to try it because I figured > > > that calling 'it' inside of the 'each' block would not be the same as > > > calling 'it' directly inside of the 'describe' block. I've never > > > actually written a method that yields to a block. I'm still trying to > > > fit into my Rubyist pants. > > > > > > So Ruby actually yields down into the 'each' block from the parent > > > 'describe' block? > > > > > > On 5/30/07, David Chelimsky wrote: > > > > On 5/30/07, Jed Hurt wrote: > > > > > This is kind of a two part question. > > > > > > > > > > Question One: I want to be sure that an Order model is protecting > > > > > sensitive attributes from mass assignment. > > > > > > > > > > The example looks like this: > > > > > > > > > > describe Order do > > > > > it "should protect total attribute from mass assignment" do > > > > > @order = Order.new(:total => 0.05) > > > > > @order.total.should_not == 0.05 > > > > > end > > > > > end > > > > > > > > > > And the code to implement it: > > > > > > > > > > class Order < ActiveRecord::Base > > > > > attr_protected :total > > > > > end > > > > > > > > > > > > > > > It seems to work, but is there a better way? Not saying that this way > > > > > is bad, just that I'm very green :) > > > > > > > > This seems pretty good to me. You're not cluttering up the example > > > > with what the value of total IS - just what it is not, which is the > > > > thing you're interested in. > > > > > > > > > > > > > > > > > > > Question Two: I actually have a bunch of attributes that need to be > > > > > protected. Rather than hand-writing a call to the 'it' method for each > > > > > attribute, could I just loop over an array of attributes that need to > > > > > be checked and programatically define the 'it' calls? > > > > > > > > > > Pseudo-code: > > > > > > > > > > describe Order do > > > > > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > > > > > :created_at, :finalize, :tax, :shipping].each do |attribute| > > > > > it "should protect #{attribute} attributes from mass assignment" do > > > > > @order = Order.new(attribute => 'hax0rz') > > > > > @order.attribute.should_not == 'hax0rz' > > > > > end > > > > > end > > > > > end > > > > > > > > > > What would the actual implementation look like? > > > > > > > > I think it would look exactly like what you wrote. Have you tried it? > > > > _______________________________________________ > > > > 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 Thu May 31 00:02:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 00:02:13 -0400 Subject: [rspec-users] Specify attr_protected In-Reply-To: <57c63afe0705302101s2a163158s1e88b1ce738b45c3@mail.gmail.com> References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> <57c63afe0705302100q43883e4r4381301eaa35b917@mail.gmail.com> <57c63afe0705302101s2a163158s1e88b1ce738b45c3@mail.gmail.com> Message-ID: <57c63afe0705302102y1900b806v355676da6d31c4e4@mail.gmail.com> On 5/31/07, David Chelimsky wrote: > On 5/31/07, David Chelimsky wrote: > > On 5/30/07, Jed Hurt wrote: > > > Hmmm.... scratch that. I actually had a typo in my code. After > > > correcting the typo, It looks like the code is trying to literally > > > call @order.attribute rather than @order.id, @order.total, etc... > > > > > > Is eval the best option? > > > > > > eval("@order.#{attribute}.should_not == 'hax0rz'") > > > > That, or (I think): > > > > (@order.send attribute).should)_not == hax0rz' > > > > Sorry - typo - this: > > (@order.send attribute).should_not == hax0rz' UGH - one more time: (@order.send attribute).should_not == 'hax0rz' > > > > > > > > > On 5/30/07, Jed Hurt wrote: > > > > Wow. It does work. I didn't even bother to try it because I figured > > > > that calling 'it' inside of the 'each' block would not be the same as > > > > calling 'it' directly inside of the 'describe' block. I've never > > > > actually written a method that yields to a block. I'm still trying to > > > > fit into my Rubyist pants. > > > > > > > > So Ruby actually yields down into the 'each' block from the parent > > > > 'describe' block? > > > > > > > > On 5/30/07, David Chelimsky wrote: > > > > > On 5/30/07, Jed Hurt wrote: > > > > > > This is kind of a two part question. > > > > > > > > > > > > Question One: I want to be sure that an Order model is protecting > > > > > > sensitive attributes from mass assignment. > > > > > > > > > > > > The example looks like this: > > > > > > > > > > > > describe Order do > > > > > > it "should protect total attribute from mass assignment" do > > > > > > @order = Order.new(:total => 0.05) > > > > > > @order.total.should_not == 0.05 > > > > > > end > > > > > > end > > > > > > > > > > > > And the code to implement it: > > > > > > > > > > > > class Order < ActiveRecord::Base > > > > > > attr_protected :total > > > > > > end > > > > > > > > > > > > > > > > > > It seems to work, but is there a better way? Not saying that this way > > > > > > is bad, just that I'm very green :) > > > > > > > > > > This seems pretty good to me. You're not cluttering up the example > > > > > with what the value of total IS - just what it is not, which is the > > > > > thing you're interested in. > > > > > > > > > > > > > > > > > > > > > > > Question Two: I actually have a bunch of attributes that need to be > > > > > > protected. Rather than hand-writing a call to the 'it' method for each > > > > > > attribute, could I just loop over an array of attributes that need to > > > > > > be checked and programatically define the 'it' calls? > > > > > > > > > > > > Pseudo-code: > > > > > > > > > > > > describe Order do > > > > > > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > > > > > > :created_at, :finalize, :tax, :shipping].each do |attribute| > > > > > > it "should protect #{attribute} attributes from mass assignment" do > > > > > > @order = Order.new(attribute => 'hax0rz') > > > > > > @order.attribute.should_not == 'hax0rz' > > > > > > end > > > > > > end > > > > > > end > > > > > > > > > > > > What would the actual implementation look like? > > > > > > > > > > I think it would look exactly like what you wrote. Have you tried it? > > > > > _______________________________________________ > > > > > 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 jchris at mfdz.com Thu May 31 01:01:19 2007 From: jchris at mfdz.com (Chris Anderson) Date: Wed, 30 May 2007 22:01:19 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> Message-ID: I usually do something like this in my before(:each) section: User.stub!(:find).and_return(@u = mock_model(User, :posts => @pc = mock('posts collection'))) @pc.stub(:find).and_return([@p = mock_model(Post)]) with the corresponding should_receives in my various examples... the trick is to mock the user's posts collection as its own object. On 5/30/07, Fischer, Daniel wrote: > Jonathan, > > Yeah something like that. I have no idea how to put it together > properly. I'm beyond confused at this point, that's why I could really > use some help. > > I figured out my "response" error, but now Im trying to "find all posts" > > Right now I got something like: > > User.should_receive(:posts).with(:all).and_return([@posts]) > > But I know it should be User.posts.find(:all) - i'm not sure how to > make this a proper behavior check. > > How do I setup my mocks to correspond with this? > > Thanks. > > On 5/30/07, Jonathan Linowes wrote: > > Don't you need to stub the User model :find too? (needed in your > > private get_user call) > > > > private > > def get_user > > @user = User.find(params[:user_id]) > > @post = @user.posts.find(params[:id]) if params[:id] > > end > > > > > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > > > My problem has been listed here: > > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > > > Don't think it would be required to completely re-type it here :) > > > > > > Thanks! > > > > > > -- > > > -Daniel Fischer > > > > > > http://danielfischer.com - Geek Blog > > > http://abigfisch.com - Portfolio > > > http://writersbeat.com - Writing Community > > > _______________________________________________ > > > 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 > > > > > -- > -Daniel Fischer > > http://danielfischer.com - Geek Blog > http://abigfisch.com - Portfolio > http://writersbeat.com - Writing Community > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Chris Anderson http://jchris.mfdz.com From win at wincent.com Thu May 31 01:27:27 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 31 May 2007 07:27:27 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <57c63afe0705301551i6415432cyf55def0e205c8954@mail.gmail.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> <57c63afe0705301551i6415432cyf55def0e205c8954@mail.gmail.com> Message-ID: <3D2A121C-E28D-4BD7-8028-F3E951464816@wincent.com> El 31/5/2007, a las 0:51, David Chelimsky escribi?: > On 5/30/07, Wincent Colaiuta wrote: >> El 30/5/2007, a las 23:11, David Chelimsky escribi?: >> >>> I think you're spot on about all of this. I'm thinking that a simple >>> solution would be that each time a shared behaviour is >>> registered, the >>> location of its definition can be registered as well. Then we can >>> ignore the ones defined in the same place when a file gets reloaded, >>> but still complain when another one is defined with the same name >>> from >>> a different location. >>> >>> WDYT? >> >> Would be great -- it would basically capture the intent of your >> current implementation -- but how would you get the location of its >> definition? > > By inspecting caller. We do this already in building up the backtrace. > I'll pursue this soon. Ah, of course... I didn't even realize that Kernel#caller was in the Ruby core... That will definitely work then. Cheers, Wincent From jonathan at parkerhill.com Thu May 31 01:53:35 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Thu, 31 May 2007 01:53:35 -0400 Subject: [rspec-users] stubbing controller methods (unstumped) In-Reply-To: <57c63afe0705302019i7082b2eag60119fa45012a8b@mail.gmail.com> References: <9D3DE5DF-0EE9-485A-868C-D0E40E2DEFA9@parkerhill.com> <465D7A7F.6080708@ntlworld.com> <21537DD8-D770-4539-B60C-9795A7C023A4@gmail.com> <016DE1CA-30AB-4AD0-A7C6-E036F8D48132@parkerhill.com> <57c63afe0705302019i7082b2eag60119fa45012a8b@mail.gmail.com> Message-ID: thanks!! My confusion was aggravated by a bug in my controller so I thought the stub wasn't working when it was. Other problems included things like forgetting a "?" on methods like "logged_in?" ... Writing the test examples like below really helped me sort it out. I've blogged it at http://www.vaporbase.com/postings/ Using_Rspec_on_Controllers linoj On May 30, 2007, at 11:19 PM, David Chelimsky wrote: > On 5/30/07, Jonathan Linowes wrote: >> I must be dense because I keep having trouble stubbing anything in a >> controller. I can stub models but not controller methods, whether >> directly defined in the controller file or in a module >> >> Here's a small example: >> >> # sandbox_controller.rb >> >> class SandboxController < ApplicationController >> def someaction >> @value = somemethod >> end >> >> def somemethod >> return 10 >> end > > This is an instance method. > >> end >> >> # sandbox_controller_spec.rb >> >> require File.dirname(__FILE__) + '/../spec_helper' >> >> describe SandboxController, " handling someaction" do >> before do >> SandboxController.stub!(:somemethod).and_return(99) > > This is stubbing a class method, which doesn't exists. Try this: > > controller.stub!(:somemethod).and_return(99) > > Cheers, > David > >> end >> >> it "should get 99" do >> get :someaction >> assigns[:value].should equal(99) >> end >> end >> >> # console >> >> $ script/spec spec/controllers/sandbox_controller_spec.rb --color -- >> format specdoc >> >> SandboxController handling someaction >> - should get 99 (FAILED - 1) >> >> 1) >> 'SandboxController handling someaction should get 99' FAILED >> expected 99, got 10 (using .equal?) >> ./spec/controllers/sandbox_controller_spec.rb:10: >> script/spec:4: >> >> Finished in 0.13381 seconds >> >> 1 example, 1 failure >> >> >> In real life I want to stub out the authentication methods in >> module / >> lib/authenticated_system.rb , or the before_filter method as >> suggested to me earlier so I can move forward with my spec'ing >> controllers that have authorization built in. This is getting >> painful. >> >> linoj >> >> >> >> _______________________________________________ >> 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 daniel at danielfischer.com Thu May 31 02:17:39 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Wed, 30 May 2007 23:17:39 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> Message-ID: <7e565b5c0705302317s6a4ae3b7raa72f362a7f063d9@mail.gmail.com> Okay that failed. I could really use a full blown example with this, just mocking isn't going to "give me insight" anymore I don't think. If anyone can post a basic crud behavior check, w/ nested routes - I'd really appreciate it. Thanks, Daniel On 5/30/07, Chris Anderson wrote: > > I usually do something like this in my before(:each) section: > > User.stub!(:find).and_return(@u = mock_model(User, :posts => @pc = > mock('posts collection'))) > @pc.stub(:find).and_return([@p = mock_model(Post)]) > > with the corresponding should_receives in my various examples... the > trick is to mock the user's posts collection as its own object. > > On 5/30/07, Fischer, Daniel wrote: > > Jonathan, > > > > Yeah something like that. I have no idea how to put it together > > properly. I'm beyond confused at this point, that's why I could really > > use some help. > > > > I figured out my "response" error, but now Im trying to "find all posts" > > > > Right now I got something like: > > > > User.should_receive(:posts).with(:all).and_return([@posts]) > > > > But I know it should be User.posts.find(:all) - i'm not sure how to > > make this a proper behavior check. > > > > How do I setup my mocks to correspond with this? > > > > Thanks. > > > > On 5/30/07, Jonathan Linowes wrote: > > > Don't you need to stub the User model :find too? (needed in your > > > private get_user call) > > > > > > private > > > def get_user > > > @user = User.find(params[:user_id]) > > > @post = @user.posts.find(params[:id]) if params[:id] > > > end > > > > > > > > > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > > > > > My problem has been listed here: > > > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > > > > > Don't think it would be required to completely re-type it here :) > > > > > > > > Thanks! > > > > > > > > -- > > > > -Daniel Fischer > > > > > > > > http://danielfischer.com - Geek Blog > > > > http://abigfisch.com - Portfolio > > > > http://writersbeat.com - Writing Community > > > > _______________________________________________ > > > > 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 > > > > > > > > > -- > > -Daniel Fischer > > > > http://danielfischer.com - Geek Blog > > http://abigfisch.com - Portfolio > > http://writersbeat.com - Writing Community > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > Chris Anderson > http://jchris.mfdz.com > -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070530/c00a411b/attachment-0001.html From win at wincent.com Thu May 31 03:25:49 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 31 May 2007 09:25:49 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <3D2A121C-E28D-4BD7-8028-F3E951464816@wincent.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> <57c63afe0705301551i6415432cyf55def0e205c8954@mail.gmail.com> <3D2A121C-E28D-4BD7-8028-F3E951464816@wincent.com> Message-ID: El 31/5/2007, a las 7:27, Wincent Colaiuta escribi?: > El 31/5/2007, a las 0:51, David Chelimsky escribi?: > >> On 5/30/07, Wincent Colaiuta wrote: >>> El 30/5/2007, a las 23:11, David Chelimsky escribi?: >>> >>>> I think you're spot on about all of this. I'm thinking that a >>>> simple >>>> solution would be that each time a shared behaviour is >>>> registered, the >>>> location of its definition can be registered as well. Then we can >>>> ignore the ones defined in the same place when a file gets >>>> reloaded, >>>> but still complain when another one is defined with the same name >>>> from >>>> a different location. >>>> >>>> WDYT? >>> >>> Would be great -- it would basically capture the intent of your >>> current implementation -- but how would you get the location of its >>> definition? >> >> By inspecting caller. We do this already in building up the >> backtrace. >> I'll pursue this soon. > > Ah, of course... I didn't even realize that Kernel#caller was in the > Ruby core... That will definitely work then. The following seems to work. Some things to note: - the code in the trunk (as at r2061) allows "found_behaviour" to be nil and adds it to the shared_behaviours array, which seems wrong; this patch fixes that - the patch uses the already-present :spec_path info (extracted using Kernel#caller in the "describe" method) as this seems the cleanest way of geting location info - I've added some specs to confirm that things work... note that because the :spec_path info gets put in place only when using "describe" a couple of the specs have to directly use the "describe" method rather than the "make_shared_behaviour" helper method - fixed a typo in one of the examples ("when adding a the same") Is this something like what you had in mind? Cheers, Wincent Index: rspec/lib/spec/dsl/behaviour.rb =================================================================== --- rspec/lib/spec/dsl/behaviour.rb (revision 2061) +++ rspec/lib/spec/dsl/behaviour.rb (working copy) @@ -7,6 +7,7 @@ class << self def add_shared_behaviour(behaviour) return if behaviour.equal?(found_behaviour = find_shared_behaviour(behaviour.description)) + return if found_behaviour and behaviour.description [:spec_path] == found_behaviour.description[:spec_path] raise ArgumentError.new("Shared Behaviour '# {behaviour.description}' already exists") if found_behaviour shared_behaviours << behaviour end Index: rspec/spec/spec/dsl/shared_behaviour_spec.rb =================================================================== --- rspec/spec/spec/dsl/shared_behaviour_spec.rb (revision 2061) +++ rspec/spec/spec/dsl/shared_behaviour_spec.rb (working copy) @@ -74,16 +74,23 @@ end it "should complain when adding a second shared behaviour with the same description" do - make_shared_behaviour("shared behaviour") {} - lambda { make_shared_behaviour("shared behaviour") {} }.should raise_error(ArgumentError) + describe "shared behaviour", :shared => true do + end + lambda { describe "shared behaviour", :shared => true do + end }.should raise_error(ArgumentError) end - it "should NOT complain when adding a the same shared behaviour again (i.e. file gets reloaded)" do - behaviour = behaviour_class.new("shared behaviour") {} - behaviour_class.add_shared_behaviour(behaviour) - behaviour_class.add_shared_behaviour(behaviour) + it "should NOT complain when adding the same shared behaviour instance again" do + shared_behaviour = make_shared_behaviour("shared behaviour") {} + behaviour_class.add_shared_behaviour(shared_behaviour) + behaviour_class.add_shared_behaviour(shared_behaviour) end + it "should NOT complain when adding the same shared behaviour again (i.e. file gets reloaded)" do + lambda { 2.times { describe "shared behaviour", :shared => true do + end } }.should_not raise_error(ArgumentError) + end + it "should add examples to current behaviour when calling it_should_behave_like" do shared_behaviour = make_shared_behaviour("shared behaviour") {} shared_behaviour.it("shared example") {} From win at wincent.com Thu May 31 03:35:21 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 31 May 2007 09:35:21 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> <57c63afe0705301551i6415432cyf55def0e205c8954@mail.gmail.com> <3D2A121C-E28D-4BD7-8028-F3E951464816@wincent.com> Message-ID: El 31/5/2007, a las 9:25, Wincent Colaiuta escribi?: > - the code in the trunk (as at r2061) allows "found_behaviour" to be > nil and adds it to the shared_behaviours array, which seems wrong; > this patch fixes that Forget I said that! I was thinking about something else. W From daniel at danielfischer.com Thu May 31 04:31:47 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Thu, 31 May 2007 01:31:47 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <7e565b5c0705302317s6a4ae3b7raa72f362a7f063d9@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> <7e565b5c0705302317s6a4ae3b7raa72f362a7f063d9@mail.gmail.com> Message-ID: <7e565b5c0705310131l441129dfif4441e2759d26afb@mail.gmail.com> Oh my... I don't know what happened... but my entire posts_controller_spec completely exploded and i'm having 31 failures, before I was having like 8. I'm not sure what is going on, I could REALLY use the help. http://pastie.caboo.se/66440 for a list of everything that is going on, and the code. I really appreciate the help guys, once I get over the mountain I'm sure I'll understand it :) On 5/30/07, Fischer, Daniel wrote: > Okay that failed. > > I could really use a full blown example with this, just mocking isn't going > to "give me insight" anymore I don't think. If anyone can post a basic crud > behavior check, w/ nested routes - I'd really appreciate it. > > Thanks, > Daniel > > On 5/30/07, Chris Anderson wrote: > > I usually do something like this in my before(:each) section: > > > > User.stub!(:find).and_return(@u = mock_model(User, :posts => @pc = > > mock('posts collection'))) > > @pc.stub(:find).and_return([@p = mock_model(Post)]) > > > > with the corresponding should_receives in my various examples... the > > trick is to mock the user's posts collection as its own object. > > > > On 5/30/07, Fischer, Daniel < daniel at danielfischer.com> wrote: > > > Jonathan, > > > > > > Yeah something like that. I have no idea how to put it together > > > properly. I'm beyond confused at this point, that's why I could really > > > use some help. > > > > > > I figured out my "response" error, but now Im trying to "find all posts" > > > > > > Right now I got something like: > > > > > > > User.should_receive(:posts).with(:all).and_return([@posts]) > > > > > > But I know it should be User.posts.find(:all) - i'm not sure how to > > > make this a proper behavior check. > > > > > > How do I setup my mocks to correspond with this? > > > > > > Thanks. > > > > > > On 5/30/07, Jonathan Linowes wrote: > > > > Don't you need to stub the User model :find too? (needed in your > > > > private get_user call) > > > > > > > > private > > > > def get_user > > > > @user = User.find(params[:user_id]) > > > > @post = @user.posts.find(params[:id]) if params[:id] > > > > end > > > > > > > > > > > > > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > > > > > > > My problem has been listed here: > > > > > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > > > > > > > Don't think it would be required to completely re-type it here :) > > > > > > > > > > Thanks! > > > > > > > > > > -- > > > > > -Daniel Fischer > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > http://abigfisch.com - Portfolio > > > > > http://writersbeat.com - Writing Community > > > > > _______________________________________________ > > > > > 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 > > > > > > > > > > > > > -- > > > -Daniel Fischer > > > > > > http://danielfischer.com - Geek Blog > > > http://abigfisch.com - Portfolio > > > http://writersbeat.com - Writing Community > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > -- > > Chris Anderson > > http://jchris.mfdz.com > > > > > > -- > > -Daniel Fischer > > http://danielfischer.com - Geek Blog > http://abigfisch.com - Portfolio > http://writersbeat.com - Writing Community -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community From win at wincent.com Thu May 31 04:59:21 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 31 May 2007 10:59:21 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> Message-ID: El 30/5/2007, a las 1:52, David Chelimsky escribi?: > Another thing you could do is to put shared behaviours in spec/shared/ > and require everything in spec/shared from spec/spec_helper. Do you think it's worth updating the test mappings in rspec_on_rails/ lib/autotest/rails_rspec.rb to reflect this convention (ie. run all specs whenever anything in spec/shared gets touched)? I also wonder if this is enough of a convention, perhaps rspec/lib/ autotest/rspec.rb should be updated as well. Speaking of which, I see that currently it only has one-to-one test mappings set up but it should probably run all the specs whenever spec_helper.rb is updated. Let me know if you want a patch for that. Cheers, Wincent From dchelimsky at gmail.com Thu May 31 06:42:41 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 06:42:41 -0400 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <7e565b5c0705310131l441129dfif4441e2759d26afb@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> <7e565b5c0705302317s6a4ae3b7raa72f362a7f063d9@mail.gmail.com> <7e565b5c0705310131l441129dfif4441e2759d26afb@mail.gmail.com> Message-ID: <57c63afe0705310342h42ab6f51x77c3576c9f77f69c@mail.gmail.com> On 5/31/07, Fischer, Daniel wrote: > Oh my... > > I don't know what happened... but my entire posts_controller_spec > completely exploded and i'm having 31 failures, before I was having > like 8. I'm not sure what is going on, I could REALLY use the help. > > http://pastie.caboo.se/66440 for a list of everything that is going > on, and the code. Try running the one file with the -b switch to get a full backtrace. script/spec spec/controllers/posts_controller_spec.rb -b > > I really appreciate the help guys, once I get over the mountain I'm > sure I'll understand it :) > > On 5/30/07, Fischer, Daniel wrote: > > Okay that failed. > > > > I could really use a full blown example with this, just mocking isn't going > > to "give me insight" anymore I don't think. If anyone can post a basic crud > > behavior check, w/ nested routes - I'd really appreciate it. > > > > Thanks, > > Daniel > > > > On 5/30/07, Chris Anderson wrote: > > > I usually do something like this in my before(:each) section: > > > > > > User.stub!(:find).and_return(@u = mock_model(User, :posts => @pc = > > > mock('posts collection'))) > > > @pc.stub(:find).and_return([@p = mock_model(Post)]) > > > > > > with the corresponding should_receives in my various examples... the > > > trick is to mock the user's posts collection as its own object. > > > > > > On 5/30/07, Fischer, Daniel < daniel at danielfischer.com> wrote: > > > > Jonathan, > > > > > > > > Yeah something like that. I have no idea how to put it together > > > > properly. I'm beyond confused at this point, that's why I could really > > > > use some help. > > > > > > > > I figured out my "response" error, but now Im trying to "find all posts" > > > > > > > > Right now I got something like: > > > > > > > > > > User.should_receive(:posts).with(:all).and_return([@posts]) > > > > > > > > But I know it should be User.posts.find(:all) - i'm not sure how to > > > > make this a proper behavior check. > > > > > > > > How do I setup my mocks to correspond with this? > > > > > > > > Thanks. > > > > > > > > On 5/30/07, Jonathan Linowes wrote: > > > > > Don't you need to stub the User model :find too? (needed in your > > > > > private get_user call) > > > > > > > > > > private > > > > > def get_user > > > > > @user = User.find(params[:user_id]) > > > > > @post = @user.posts.find(params[:id]) if params[:id] > > > > > end > > > > > > > > > > > > > > > > > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > > > > > > > > > My problem has been listed here: > > > > > > > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > > > > > > > > > Don't think it would be required to completely re-type it here :) > > > > > > > > > > > > Thanks! > > > > > > > > > > > > -- > > > > > > -Daniel Fischer > > > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > > http://abigfisch.com - Portfolio > > > > > > http://writersbeat.com - Writing Community > > > > > > _______________________________________________ > > > > > > 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 > > > > > > > > > > > > > > > > > -- > > > > -Daniel Fischer > > > > > > > > http://danielfischer.com - Geek Blog > > > > http://abigfisch.com - Portfolio > > > > http://writersbeat.com - Writing Community > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > -- > > > Chris Anderson > > > http://jchris.mfdz.com > > > > > > > > > > > -- > > > > -Daniel Fischer > > > > http://danielfischer.com - Geek Blog > > http://abigfisch.com - Portfolio > > http://writersbeat.com - Writing Community > > > -- > -Daniel Fischer > > http://danielfischer.com - Geek Blog > http://abigfisch.com - Portfolio > http://writersbeat.com - Writing Community > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 31 06:46:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 06:46:33 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> <57c63afe0705301551i6415432cyf55def0e205c8954@mail.gmail.com> <3D2A121C-E28D-4BD7-8028-F3E951464816@wincent.com> Message-ID: <57c63afe0705310346h6ef3f267xa4bbce217d485c63@mail.gmail.com> On 5/31/07, Wincent Colaiuta wrote: > El 31/5/2007, a las 7:27, Wincent Colaiuta escribi?: > > > El 31/5/2007, a las 0:51, David Chelimsky escribi?: > > > >> On 5/30/07, Wincent Colaiuta wrote: > >>> El 30/5/2007, a las 23:11, David Chelimsky escribi?: > >>> > >>>> I think you're spot on about all of this. I'm thinking that a > >>>> simple > >>>> solution would be that each time a shared behaviour is > >>>> registered, the > >>>> location of its definition can be registered as well. Then we can > >>>> ignore the ones defined in the same place when a file gets > >>>> reloaded, > >>>> but still complain when another one is defined with the same name > >>>> from > >>>> a different location. > >>>> > >>>> WDYT? > >>> > >>> Would be great -- it would basically capture the intent of your > >>> current implementation -- but how would you get the location of its > >>> definition? > >> > >> By inspecting caller. We do this already in building up the > >> backtrace. > >> I'll pursue this soon. > > > > Ah, of course... I didn't even realize that Kernel#caller was in the > > Ruby core... That will definitely work then. > > The following seems to work. Some things to note: > > - the code in the trunk (as at r2061) allows "found_behaviour" to be > nil and adds it to the shared_behaviours array, which seems wrong; > this patch fixes that > > - the patch uses the already-present :spec_path info (extracted using > Kernel#caller in the "describe" method) as this seems the cleanest > way of geting location info > > - I've added some specs to confirm that things work... note that > because the :spec_path info gets put in place only when using > "describe" a couple of the specs have to directly use the "describe" > method rather than the "make_shared_behaviour" helper method > > - fixed a typo in one of the examples ("when adding a the same") > > Is this something like what you had in mind? > > Cheers, > Wincent > > Index: rspec/lib/spec/dsl/behaviour.rb > =================================================================== > --- rspec/lib/spec/dsl/behaviour.rb (revision 2061) > +++ rspec/lib/spec/dsl/behaviour.rb (working copy) > @@ -7,6 +7,7 @@ > class << self > def add_shared_behaviour(behaviour) > return if behaviour.equal?(found_behaviour = > find_shared_behaviour(behaviour.description)) > + return if found_behaviour and behaviour.description > [:spec_path] == found_behaviour.description[:spec_path] > raise ArgumentError.new("Shared Behaviour '# > {behaviour.description}' already exists") if found_behaviour > shared_behaviours << behaviour > end > Index: rspec/spec/spec/dsl/shared_behaviour_spec.rb > =================================================================== > --- rspec/spec/spec/dsl/shared_behaviour_spec.rb (revision 2061) > +++ rspec/spec/spec/dsl/shared_behaviour_spec.rb (working copy) > @@ -74,16 +74,23 @@ > end > it "should complain when adding a second shared behaviour > with the same description" do > - make_shared_behaviour("shared behaviour") {} > - lambda { make_shared_behaviour("shared behaviour") > {} }.should raise_error(ArgumentError) > + describe "shared behaviour", :shared => true do > + end > + lambda { describe "shared behaviour", :shared => true do > + end }.should raise_error(ArgumentError) > end > - it "should NOT complain when adding a the same shared > behaviour again (i.e. file gets reloaded)" do > - behaviour = behaviour_class.new("shared behaviour") {} > - behaviour_class.add_shared_behaviour(behaviour) > - behaviour_class.add_shared_behaviour(behaviour) > + it "should NOT complain when adding the same shared behaviour > instance again" do > + shared_behaviour = make_shared_behaviour("shared behaviour") {} > + behaviour_class.add_shared_behaviour(shared_behaviour) > + behaviour_class.add_shared_behaviour(shared_behaviour) > end > + it "should NOT complain when adding the same shared behaviour > again (i.e. file gets reloaded)" do > + lambda { 2.times { describe "shared behaviour", :shared => > true do > + end } }.should_not raise_error(ArgumentError) > + end > + > it "should add examples to current behaviour when calling > it_should_behave_like" do > shared_behaviour = make_shared_behaviour("shared > behaviour") {} > shared_behaviour.it("shared example") {} Please post this in the tracker: http://rubyforge.org/tracker/?atid=3151&group_id=797&func=browse. > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 31 06:47:14 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 06:47:14 -0400 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> Message-ID: <57c63afe0705310347j532acff2n99feb4d66f29f0f1@mail.gmail.com> On 5/31/07, Wincent Colaiuta wrote: > El 30/5/2007, a las 1:52, David Chelimsky escribi?: > > > Another thing you could do is to put shared behaviours in spec/shared/ > > and require everything in spec/shared from spec/spec_helper. > > Do you think it's worth updating the test mappings in rspec_on_rails/ > lib/autotest/rails_rspec.rb to reflect this convention (ie. run all > specs whenever anything in spec/shared gets touched)? > > I also wonder if this is enough of a convention, perhaps rspec/lib/ > autotest/rspec.rb should be updated as well. Speaking of which, I see > that currently it only has one-to-one test mappings set up but it > should probably run all the specs whenever spec_helper.rb is updated. > Let me know if you want a patch for that. Sounds like a good idea - please post to the tracker: http://rubyforge.org/tracker/?atid=3151&group_id=797&func=browse > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel at danielfischer.com Thu May 31 07:17:12 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Thu, 31 May 2007 04:17:12 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <57c63afe0705310342h42ab6f51x77c3576c9f77f69c@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> <7e565b5c0705302317s6a4ae3b7raa72f362a7f063d9@mail.gmail.com> <7e565b5c0705310131l441129dfif4441e2759d26afb@mail.gmail.com> <57c63afe0705310342h42ab6f51x77c3576c9f77f69c@mail.gmail.com> Message-ID: <7e565b5c0705310417u1d1fef0fv8a152b938c672966@mail.gmail.com> 1) 'PostsController handling GET /users/1/posts should be successful' FAILED expected success? to return true, got false /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/expectations.rb:52:in `fail_with' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/expectations/handler.rb:16:in `handle_matcher' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/expectations/extensions/object.rb:32:in `should' ./spec/controllers/posts_controller_spec.rb:46: /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:73:in `instance_eval' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:73:in `run_example' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:23:in `run' /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:21:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/behaviour.rb:72:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/behaviour.rb:69:in `each' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/behaviour.rb:69:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:45:in `run_behaviours' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:44:in `each' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:44:in `run_behaviours' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:27:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/command_line.rb:17:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/bin/spec:3: /usr/local/bin/spec:18:in `load' /usr/local/bin/spec:18: Doesn't really tell me anything, how about you? On 5/31/07, David Chelimsky wrote: > > On 5/31/07, Fischer, Daniel wrote: > > Oh my... > > > > I don't know what happened... but my entire posts_controller_spec > > completely exploded and i'm having 31 failures, before I was having > > like 8. I'm not sure what is going on, I could REALLY use the help. > > > > http://pastie.caboo.se/66440 for a list of everything that is going > > on, and the code. > > Try running the one file with the -b switch to get a full backtrace. > > script/spec spec/controllers/posts_controller_spec.rb -b > > > > > I really appreciate the help guys, once I get over the mountain I'm > > sure I'll understand it :) > > > > On 5/30/07, Fischer, Daniel wrote: > > > Okay that failed. > > > > > > I could really use a full blown example with this, just mocking isn't > going > > > to "give me insight" anymore I don't think. If anyone can post a basic > crud > > > behavior check, w/ nested routes - I'd really appreciate it. > > > > > > Thanks, > > > Daniel > > > > > > On 5/30/07, Chris Anderson wrote: > > > > I usually do something like this in my before(:each) section: > > > > > > > > User.stub!(:find).and_return(@u = mock_model(User, :posts => @pc = > > > > mock('posts collection'))) > > > > @pc.stub(:find).and_return([@p = mock_model(Post)]) > > > > > > > > with the corresponding should_receives in my various examples... the > > > > trick is to mock the user's posts collection as its own object. > > > > > > > > On 5/30/07, Fischer, Daniel < daniel at danielfischer.com> wrote: > > > > > Jonathan, > > > > > > > > > > Yeah something like that. I have no idea how to put it together > > > > > properly. I'm beyond confused at this point, that's why I could > really > > > > > use some help. > > > > > > > > > > I figured out my "response" error, but now Im trying to "find all > posts" > > > > > > > > > > Right now I got something like: > > > > > > > > > > > > > User.should_receive(:posts).with(:all).and_return([@posts]) > > > > > > > > > > But I know it should be User.posts.find(:all) - i'm not sure how > to > > > > > make this a proper behavior check. > > > > > > > > > > How do I setup my mocks to correspond with this? > > > > > > > > > > Thanks. > > > > > > > > > > On 5/30/07, Jonathan Linowes wrote: > > > > > > Don't you need to stub the User model :find too? (needed in your > > > > > > private get_user call) > > > > > > > > > > > > private > > > > > > def get_user > > > > > > @user = User.find(params[:user_id]) > > > > > > @post = @user.posts.find(params[:id]) if params[:id] > > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > > > > > > > > > > > My problem has been listed here: > > > > > > > > > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > > > > > > > > > > > Don't think it would be required to completely re-type it here > :) > > > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > -- > > > > > > > -Daniel Fischer > > > > > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > > > http://abigfisch.com - Portfolio > > > > > > > http://writersbeat.com - Writing Community > > > > > > > _______________________________________________ > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > -- > > > > > -Daniel Fischer > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > http://abigfisch.com - Portfolio > > > > > http://writersbeat.com - Writing Community > > > > > _______________________________________________ > > > > > rspec-users mailing list > > > > > rspec-users at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > > -- > > > > Chris Anderson > > > > http://jchris.mfdz.com > > > > > > > > > > > > > > > > -- > > > > > > -Daniel Fischer > > > > > > http://danielfischer.com - Geek Blog > > > http://abigfisch.com - Portfolio > > > http://writersbeat.com - Writing Community > > > > > > -- > > -Daniel Fischer > > > > http://danielfischer.com - Geek Blog > > http://abigfisch.com - Portfolio > > http://writersbeat.com - Writing Community > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070531/139670e8/attachment.html From tom at experthuman.com Thu May 31 07:19:31 2007 From: tom at experthuman.com (Tom Stuart) Date: Thu, 31 May 2007 12:19:31 +0100 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> Message-ID: <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> On 30 May 2007, at 22:17, Tom Stuart wrote: > Everything's happy again now, especially me. I've stopped being happy again, although this time for a different reason! I've got (let's say) one spec, with (let's say) 10 examples in it. autotest + rspec work like a charm as long all the examples pass, but if I change my code so that (let's say) 4 of the examples fail, things start to get out of control. autotest runs automatically after I make the broken change, which is fine: > script/spec -O spec/spec.opts spec/models/matcher_spec.rb > FFFF...... But then if I just touch a file so that it runs again, it does this: > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > spec.opts spec/models/matcher_spec.rb > FFFF...... > FFFF...... > FFFF...... > FFFF...... And if I touch again, I get: > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > spec.opts spec/models/matcher_spec.rb; [...16 times...] > FFFF...... > FFFF...... > FFFF...... > FFFF...... > FFFF...... > FFFF...... > [...16 times...] As you can imagine, as time goes by, this isn't doing much for my productivity. If I actually fix the breakage so that all the examples pass again, and wait for the 4^n invocations of script/spec to finish, I'm back in a healthy sitaution again, but once more examples start failing it starts spiraling off again... This is all a great incentive to never break my code but I need something a little gentler for now. Before I spend too much time investigating it, does anyone have any intuition about whether this is a zentest or an rspec_on_rails issue? Cheers, -Tom From dchelimsky at gmail.com Thu May 31 07:28:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 07:28:18 -0400 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <7e565b5c0705310417u1d1fef0fv8a152b938c672966@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> <7e565b5c0705302317s6a4ae3b7raa72f362a7f063d9@mail.gmail.com> <7e565b5c0705310131l441129dfif4441e2759d26afb@mail.gmail.com> <57c63afe0705310342h42ab6f51x77c3576c9f77f69c@mail.gmail.com> <7e565b5c0705310417u1d1fef0fv8a152b938c672966@mail.gmail.com> Message-ID: <57c63afe0705310428x57847426gaef8bc3d2733cfc1@mail.gmail.com> On 5/31/07, Fischer, Daniel wrote: > 1) > 'PostsController handling GET /users/1/posts should be successful' FAILED > expected success? to return true, got false > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/expectations.rb:52:in > `fail_with' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/expectations/handler.rb:16:in > `handle_matcher' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/expectations/extensions/object.rb:32:in > `should' > ./spec/controllers/posts_controller_spec.rb:46: > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:73:in > `instance_eval' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:73:in > `run_example' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:23:in > `run' > /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/example.rb:21:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/behaviour.rb:72:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/dsl/behaviour.rb:69:in > `each' > /usr/local/lib/ruby/gems/1.8/gems/rspec- > 1.0.2/lib/spec/dsl/behaviour.rb:69:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:45:in > `run_behaviours' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:44:in > `each' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:44:in > `run_behaviours' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/lib/spec/runner/behaviour_runner.rb:27:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec- > 1.0.2/lib/spec/runner/command_line.rb:17:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/bin/spec:3: > /usr/local/bin/spec:18:in `load' > /usr/local/bin/spec:18: > > Doesn't really tell me anything, how about you? Nope. Thanks for playing ;) One thing - controller examples used to implicitly re-raise controller errors. We removed this in response to a bug report, which had the insidious side-effect of hiding errors without you knowing. If you upgrade to 1.0.4, you'll see a call in spec_helper.rb to raise_controller_errors. This is a new method that lets you do so explicitly, and is included in spec_helper.rb by default. I'm thinking this might help expose the problem. > > > On 5/31/07, David Chelimsky wrote: > > On 5/31/07, Fischer, Daniel wrote: > > > Oh my... > > > > > > I don't know what happened... but my entire posts_controller_spec > > > completely exploded and i'm having 31 failures, before I was having > > > like 8. I'm not sure what is going on, I could REALLY use the help. > > > > > > http://pastie.caboo.se/66440 for a list of everything that is going > > > on, and the code. > > > > Try running the one file with the -b switch to get a full backtrace. > > > > script/spec spec/controllers/posts_controller_spec.rb -b > > > > > > > > I really appreciate the help guys, once I get over the mountain I'm > > > sure I'll understand it :) > > > > > > On 5/30/07, Fischer, Daniel wrote: > > > > Okay that failed. > > > > > > > > I could really use a full blown example with this, just mocking isn't > going > > > > to "give me insight" anymore I don't think. If anyone can post a basic > crud > > > > behavior check, w/ nested routes - I'd really appreciate it. > > > > > > > > Thanks, > > > > Daniel > > > > > > > > On 5/30/07, Chris Anderson wrote: > > > > > I usually do something like this in my before(:each) section: > > > > > > > > > > User.stub!(:find).and_return(@u = mock_model(User, :posts => @pc = > > > > > mock('posts collection'))) > > > > > @pc.stub(:find).and_return([@p = mock_model(Post)]) > > > > > > > > > > with the corresponding should_receives in my various examples... the > > > > > trick is to mock the user's posts collection as its own object. > > > > > > > > > > On 5/30/07, Fischer, Daniel < daniel at danielfischer.com> wrote: > > > > > > Jonathan, > > > > > > > > > > > > Yeah something like that. I have no idea how to put it together > > > > > > properly. I'm beyond confused at this point, that's why I could > really > > > > > > use some help. > > > > > > > > > > > > I figured out my "response" error, but now Im trying to "find all > posts" > > > > > > > > > > > > Right now I got something like: > > > > > > > > > > > > > > > > > User.should_receive(:posts).with(:all).and_return([@posts]) > > > > > > > > > > > > But I know it should be User.posts.find(:all) - i'm not sure how > to > > > > > > make this a proper behavior check. > > > > > > > > > > > > How do I setup my mocks to correspond with this? > > > > > > > > > > > > Thanks. > > > > > > > > > > > > On 5/30/07, Jonathan Linowes wrote: > > > > > > > Don't you need to stub the User model :find too? (needed in your > > > > > > > private get_user call) > > > > > > > > > > > > > > private > > > > > > > def get_user > > > > > > > @user = User.find(params[:user_id]) > > > > > > > @post = @user.posts.find(params[:id]) if params[:id] > > > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > > > > > > > > > > > > > My problem has been listed here: > > > > > > > > > > > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > > > > > > > > > > > > > Don't think it would be required to completely re-type it here > :) > > > > > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > -- > > > > > > > > -Daniel Fischer > > > > > > > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > > > > http://abigfisch.com - Portfolio > > > > > > > > http://writersbeat.com - Writing Community > > > > > > > > > _______________________________________________ > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > -Daniel Fischer > > > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > > http://abigfisch.com - Portfolio > > > > > > http://writersbeat.com - Writing Community > > > > > > _______________________________________________ > > > > > > rspec-users mailing list > > > > > > rspec-users at rubyforge.org > > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > > > > > > -- > > > > > Chris Anderson > > > > > http://jchris.mfdz.com > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > -Daniel Fischer > > > > > > > > http://danielfischer.com - Geek Blog > > > > http://abigfisch.com - Portfolio > > > > http://writersbeat.com - Writing Community > > > > > > > > > -- > > > -Daniel Fischer > > > > > > http://danielfischer.com - Geek Blog > > > http://abigfisch.com - Portfolio > > > http://writersbeat.com - Writing Community > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > -- > > -Daniel Fischer > > http://danielfischer.com - Geek Blog > http://abigfisch.com - Portfolio > http://writersbeat.com - Writing Community From dchelimsky at gmail.com Thu May 31 07:41:01 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 07:41:01 -0400 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> Message-ID: <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> On 5/31/07, Tom Stuart wrote: > On 30 May 2007, at 22:17, Tom Stuart wrote: > > Everything's happy again now, especially me. > > I've stopped being happy again, although this time for a different > reason! > > I've got (let's say) one spec, with (let's say) 10 examples in it. > autotest + rspec work like a charm as long all the examples pass, but > if I change my code so that (let's say) 4 of the examples fail, > things start to get out of control. > > autotest runs automatically after I make the broken change, which is > fine: > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb > > FFFF...... > > But then if I just touch a file so that it runs again, it does this: > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > spec.opts spec/models/matcher_spec.rb > > FFFF...... > > FFFF...... > > FFFF...... > > FFFF...... > > And if I touch again, I get: > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > spec.opts spec/models/matcher_spec.rb; [...16 times...] > > FFFF...... > > FFFF...... > > FFFF...... > > FFFF...... > > FFFF...... > > FFFF...... > > [...16 times...] > > As you can imagine, as time goes by, this isn't doing much for my > productivity. If I actually fix the breakage so that all the examples > pass again, and wait for the 4^n invocations of script/spec to > finish, I'm back in a healthy sitaution again, but once more examples > start failing it starts spiraling off again... > > This is all a great incentive to never break my code but I need > something a little gentler for now. Before I spend too much time > investigating it, does anyone have any intuition about whether this > is a zentest or an rspec_on_rails issue? I've not heard of this before and can't reproduce it. Which file are you touching to get this to happen? > > Cheers, > -Tom > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel at danielfischer.com Thu May 31 08:03:03 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Thu, 31 May 2007 05:03:03 -0700 Subject: [rspec-users] Could anyone please help with rspec/nested resource behavior checking? In-Reply-To: <57c63afe0705310428x57847426gaef8bc3d2733cfc1@mail.gmail.com> References: <7e565b5c0705301703w334c3e2dg3f05d734ed76cd5a@mail.gmail.com> <1D95C70C-B551-43D3-AE07-5E7FFD9C5B74@parkerhill.com> <7e565b5c0705301807o42711e51w555ace5e8c037c84@mail.gmail.com> <7e565b5c0705302317s6a4ae3b7raa72f362a7f063d9@mail.gmail.com> <7e565b5c0705310131l441129dfif4441e2759d26afb@mail.gmail.com> <57c63afe0705310342h42ab6f51x77c3576c9f77f69c@mail.gmail.com> <7e565b5c0705310417u1d1fef0fv8a152b938c672966@mail.gmail.com> <57c63afe0705310428x57847426gaef8bc3d2733cfc1@mail.gmail.com> Message-ID: <7e565b5c0705310503l6af1f834n5d0363633787b59a@mail.gmail.com> David, Awesome - well at least it's telling me something isn't working "that well" anymore. Instead of the previous "expected success? to return true, got false" It's now "Couldn't find User with ID=1" But I swore that same code worked before, it looks proper in my pastie doesn't it? *scratches head* - it certainly works when it's "live". On 5/31/07, David Chelimsky wrote: > > On 5/31/07, Fischer, Daniel wrote: > > 1) > > 'PostsController handling GET /users/1/posts should be successful' > FAILED > > expected success? to return true, got false > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/expectations.rb:52:in > > `fail_with' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/expectations/handler.rb:16:in > > `handle_matcher' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/expectations/extensions/object.rb:32:in > > `should' > > ./spec/controllers/posts_controller_spec.rb:46: > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/dsl/example.rb:73:in > > `instance_eval' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/dsl/example.rb:73:in > > `run_example' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/dsl/example.rb:23:in > > `run' > > /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/dsl/example.rb:21:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/dsl/behaviour.rb:72:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/dsl/behaviour.rb:69:in > > `each' > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > 1.0.2/lib/spec/dsl/behaviour.rb:69:in `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/runner/behaviour_runner.rb:45:in > > `run_behaviours' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/runner/behaviour_runner.rb:44:in > > `each' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/runner/behaviour_runner.rb:44:in > > `run_behaviours' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2 > /lib/spec/runner/behaviour_runner.rb:27:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > 1.0.2/lib/spec/runner/command_line.rb:17:in `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.2/bin/spec:3: > > /usr/local/bin/spec:18:in `load' > > /usr/local/bin/spec:18: > > > > Doesn't really tell me anything, how about you? > > Nope. Thanks for playing ;) > > One thing - controller examples used to implicitly re-raise controller > errors. We removed this in response to a bug report, which had the > insidious side-effect of hiding errors without you knowing. If you > upgrade to 1.0.4, you'll see a call in spec_helper.rb to > raise_controller_errors. This is a new method that lets you do so > explicitly, and is included in spec_helper.rb by default. > > I'm thinking this might help expose the problem. > > > > > > > On 5/31/07, David Chelimsky wrote: > > > On 5/31/07, Fischer, Daniel wrote: > > > > Oh my... > > > > > > > > I don't know what happened... but my entire posts_controller_spec > > > > completely exploded and i'm having 31 failures, before I was having > > > > like 8. I'm not sure what is going on, I could REALLY use the help. > > > > > > > > http://pastie.caboo.se/66440 for a list of everything that is going > > > > on, and the code. > > > > > > Try running the one file with the -b switch to get a full backtrace. > > > > > > script/spec spec/controllers/posts_controller_spec.rb -b > > > > > > > > > > > I really appreciate the help guys, once I get over the mountain I'm > > > > sure I'll understand it :) > > > > > > > > On 5/30/07, Fischer, Daniel wrote: > > > > > Okay that failed. > > > > > > > > > > I could really use a full blown example with this, just mocking > isn't > > going > > > > > to "give me insight" anymore I don't think. If anyone can post a > basic > > crud > > > > > behavior check, w/ nested routes - I'd really appreciate it. > > > > > > > > > > Thanks, > > > > > Daniel > > > > > > > > > > On 5/30/07, Chris Anderson wrote: > > > > > > I usually do something like this in my before(:each) section: > > > > > > > > > > > > User.stub!(:find).and_return(@u = mock_model(User, :posts => @pc > = > > > > > > mock('posts collection'))) > > > > > > @pc.stub(:find).and_return([@p = mock_model(Post)]) > > > > > > > > > > > > with the corresponding should_receives in my various examples... > the > > > > > > trick is to mock the user's posts collection as its own object. > > > > > > > > > > > > On 5/30/07, Fischer, Daniel < daniel at danielfischer.com> wrote: > > > > > > > Jonathan, > > > > > > > > > > > > > > Yeah something like that. I have no idea how to put it > together > > > > > > > properly. I'm beyond confused at this point, that's why I > could > > really > > > > > > > use some help. > > > > > > > > > > > > > > I figured out my "response" error, but now Im trying to "find > all > > posts" > > > > > > > > > > > > > > Right now I got something like: > > > > > > > > > > > > > > > > > > > > > User.should_receive(:posts).with(:all).and_return([@posts]) > > > > > > > > > > > > > > But I know it should be User.posts.find(:all) - i'm not sure > how > > to > > > > > > > make this a proper behavior check. > > > > > > > > > > > > > > How do I setup my mocks to correspond with this? > > > > > > > > > > > > > > Thanks. > > > > > > > > > > > > > > On 5/30/07, Jonathan Linowes wrote: > > > > > > > > Don't you need to stub the User model :find too? (needed in > your > > > > > > > > private get_user call) > > > > > > > > > > > > > > > > private > > > > > > > > def get_user > > > > > > > > @user = User.find(params[:user_id]) > > > > > > > > @post = @user.posts.find(params[:id]) if params[:id] > > > > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On May 30, 2007, at 8:03 PM, Fischer, Daniel wrote: > > > > > > > > > > > > > > > > > My problem has been listed here: > > > > > > > > > > > > > > http://railsforum.com/viewtopic.php?pid=25439#p25439 > > > > > > > > > > > > > > > > > > Don't think it would be required to completely re-type it > here > > :) > > > > > > > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > -- > > > > > > > > > -Daniel Fischer > > > > > > > > > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > > > > > http://abigfisch.com - Portfolio > > > > > > > > > http://writersbeat.com - Writing Community > > > > > > > > > > > _______________________________________________ > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > -Daniel Fischer > > > > > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > > > http://abigfisch.com - Portfolio > > > > > > > http://writersbeat.com - Writing Community > > > > > > > _______________________________________________ > > > > > > > rspec-users mailing list > > > > > > > rspec-users at rubyforge.org > > > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Chris Anderson > > > > > > http://jchris.mfdz.com > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > -Daniel Fischer > > > > > > > > > > http://danielfischer.com - Geek Blog > > > > > http://abigfisch.com - Portfolio > > > > > http://writersbeat.com - Writing Community > > > > > > > > > > > > -- > > > > -Daniel Fischer > > > > > > > > http://danielfischer.com - Geek Blog > > > > http://abigfisch.com - Portfolio > > > > http://writersbeat.com - Writing Community > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > -- > > > > -Daniel Fischer > > > > http://danielfischer.com - Geek Blog > > http://abigfisch.com - Portfolio > > http://writersbeat.com - Writing Community > -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070531/f8b813b4/attachment.html From win at wincent.com Thu May 31 10:42:06 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 31 May 2007 16:42:06 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <57c63afe0705310346h6ef3f267xa4bbce217d485c63@mail.gmail.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <8D003563-F706-4D0C-B7D9-032F26EE9420@wincent.com> <57c63afe0705301411p6e467cf6l5e3ea8e60dd955f7@mail.gmail.com> <9756B68F-9448-4FB3-A42F-C4EDFA6DFF84@wincent.com> <57c63afe0705301551i6415432cyf55def0e205c8954@mail.gmail.com> <3D2A121C-E28D-4BD7-8028-F3E951464816@wincent.com> <57c63afe0705310346h6ef3f267xa4bbce217d485c63@mail.gmail.com> Message-ID: <8F331437-9076-4FC2-B7F3-2CBA4BC35F0B@wincent.com> El 31/5/2007, a las 12:46, David Chelimsky escribi?: >> Index: rspec/lib/spec/dsl/behaviour.rb >> =================================================================== >> --- rspec/lib/spec/dsl/behaviour.rb (revision 2061) >> +++ rspec/lib/spec/dsl/behaviour.rb (working copy) >> @@ -7,6 +7,7 @@ >> class << self >> def add_shared_behaviour(behaviour) >> return if behaviour.equal?(found_behaviour = >> find_shared_behaviour(behaviour.description)) >> + return if found_behaviour and behaviour.description >> [:spec_path] == found_behaviour.description[:spec_path] >> raise ArgumentError.new("Shared Behaviour '# >> {behaviour.description}' already exists") if found_behaviour >> shared_behaviours << behaviour >> end >> Index: rspec/spec/spec/dsl/shared_behaviour_spec.rb >> =================================================================== >> --- rspec/spec/spec/dsl/shared_behaviour_spec.rb (revision >> 2061) >> +++ rspec/spec/spec/dsl/shared_behaviour_spec.rb (working >> copy) >> @@ -74,16 +74,23 @@ >> end >> it "should complain when adding a second shared behaviour >> with the same description" do >> - make_shared_behaviour("shared behaviour") {} >> - lambda { make_shared_behaviour("shared behaviour") >> {} }.should raise_error(ArgumentError) >> + describe "shared behaviour", :shared => true do >> + end >> + lambda { describe "shared behaviour", :shared => true do >> + end }.should raise_error(ArgumentError) >> end >> - it "should NOT complain when adding a the same shared >> behaviour again (i.e. file gets reloaded)" do >> - behaviour = behaviour_class.new("shared behaviour") {} >> - behaviour_class.add_shared_behaviour(behaviour) >> - behaviour_class.add_shared_behaviour(behaviour) >> + it "should NOT complain when adding the same shared behaviour >> instance again" do >> + shared_behaviour = make_shared_behaviour("shared >> behaviour") {} >> + behaviour_class.add_shared_behaviour(shared_behaviour) >> + behaviour_class.add_shared_behaviour(shared_behaviour) >> end >> + it "should NOT complain when adding the same shared behaviour >> again (i.e. file gets reloaded)" do >> + lambda { 2.times { describe "shared behaviour", :shared => >> true do >> + end } }.should_not raise_error(ArgumentError) >> + end >> + >> it "should add examples to current behaviour when calling >> it_should_behave_like" do >> shared_behaviour = make_shared_behaviour("shared >> behaviour") {} >> shared_behaviour.it("shared example") {} > > Please post this in the tracker: > http://rubyforge.org/tracker/?atid=3151&group_id=797&func=browse. Ok, done: http://rubyforge.org/tracker/index.php? func=detail&aid=11252&group_id=797&atid=3151 Cheers, Wincent From win at wincent.com Thu May 31 10:42:09 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 31 May 2007 16:42:09 +0200 Subject: [rspec-users] Specs for ApplicationController, where to put them? In-Reply-To: <57c63afe0705310347j532acff2n99feb4d66f29f0f1@mail.gmail.com> References: <2D69A175-3C2A-4E38-A006-68695DF3E359@wincent.com> <050EF0F7-7EE3-4995-AFE3-0FD735F98167@digitalphenom.com> <583D179D-743C-49BB-9CFA-B31AF11C71E2@digitalphenom.com> <57c63afe0705291652r2bb1ea05o29ed4b4ec96e29ed@mail.gmail.com> <57c63afe0705310347j532acff2n99feb4d66f29f0f1@mail.gmail.com> Message-ID: <30054AFD-E518-4D5A-BF17-73E5BC7790D6@wincent.com> El 31/5/2007, a las 12:47, David Chelimsky escribi?: > On 5/31/07, Wincent Colaiuta wrote: >> El 30/5/2007, a las 1:52, David Chelimsky escribi?: >> >>> Another thing you could do is to put shared behaviours in spec/ >>> shared/ >>> and require everything in spec/shared from spec/spec_helper. >> >> Do you think it's worth updating the test mappings in rspec_on_rails/ >> lib/autotest/rails_rspec.rb to reflect this convention (ie. run all >> specs whenever anything in spec/shared gets touched)? >> >> I also wonder if this is enough of a convention, perhaps rspec/lib/ >> autotest/rspec.rb should be updated as well. Speaking of which, I see >> that currently it only has one-to-one test mappings set up but it >> should probably run all the specs whenever spec_helper.rb is updated. >> Let me know if you want a patch for that. > > Sounds like a good idea - please post to the tracker: > http://rubyforge.org/tracker/?atid=3151&group_id=797&func=browse Ok, done: http://rubyforge.org/tracker/index.php? func=detail&aid=11253&group_id=797&atid=3151 Cheers, Wincent From tom at experthuman.com Thu May 31 10:11:42 2007 From: tom at experthuman.com (Tom Stuart) Date: Thu, 31 May 2007 15:11:42 +0100 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> Message-ID: On 31 May 2007, at 12:41, David Chelimsky wrote: > I've not heard of this before and can't reproduce it. Below is how I can reproduce on a fresh Rails project. Does this work for you too, or is it something weird about my environment? (Note that, once autotest is running, I've simply inserted its subsequent output below each command that prompted it, for lack of any better way of showing the activity in two concurrent windows.) Cheers, -Tom -- ~$ uname -a Linux 2.6.20-16-server #2 SMP Wed May 23 01:53:06 UTC 2007 i686 GNU/ Linux ~$ ruby -v ruby 1.8.5 (2006-08-25) [i486-linux] ~$ rails -v Rails 1.2.3 ~$ zentest -v zentest v3.6.0 ~$ rails myproject ~$ mysqladmin -u root create myproject_development ~$ cd myproject/ ~/myproject$ ./script/plugin install svn://rubyforge.org/var/svn/ rspec/trunk/rspec ~/myproject$ ./script/plugin install svn://rubyforge.org/var/svn/ rspec/trunk/rspec_on_rails ~/myproject$ ./script/generate rspec ~/myproject$ ./script/generate rspec_scaffold Post title:string body:text ~/myproject$ rake db:migrate ~/myproject$ autotest script/spec -O spec/spec.opts spec/views/posts/new.rhtml_spec.rb spec/ views/posts/index.rhtml_spec.rb spec/views/posts/show.rhtml_spec.rb spec/controllers/posts_controller_spec.rb spec/views/posts/ edit.rhtml_spec.rb spec/helpers/posts_helper_spec.rb spec/models/ post_spec.rb ........................................... 43 examples, 0 failures ~/myproject$ sed -ie '5,10s/^/#/' app/controllers/posts_controller.rb script/spec -O spec/spec.opts spec/controllers/posts_controller_spec.rb .........................FF.FF........ 38 examples, 4 failures ~/myproject$ touch app/controllers/posts_controller.rb script/spec -O spec/spec.opts spec/controllers/ posts_controller_spec.rb; script/spec -O spec/spec.opts spec/ controllers/posts_controller_spec.rb .........................FF.FF........ 38 examples, 4 failures .........................FF.FF........ 38 examples, 4 failures ~/myproject$ touch app/controllers/posts_controller.rb script/spec -O spec/spec.opts spec/controllers/ posts_controller_spec.rb; script/spec -O spec/spec.opts spec/ controllers/posts_controller_spec.rb; script/spec -O spec/spec.opts spec/controllers/posts_controller_spec.rb; script/spec -O spec/ spec.opts spec/controllers/posts_controller_spec.rb .........................FF.FF........ 38 examples, 4 failures .........................FF.FF........ 38 examples, 4 failures .........................FF.FF........ 38 examples, 4 failures .........................FF.FF........ 38 examples, 4 failures ~/myproject$ sed -ie '5,10s/^#//' app/controllers/posts_controller.rb script/spec -O spec/spec.opts spec/controllers/ posts_controller_spec.rb; script/spec -O spec/spec.opts spec/ controllers/posts_controller_spec.rb; script/spec -O spec/spec.opts spec/controllers/posts_controller_spec.rb; script/spec -O spec/ spec.opts spec/controllers/posts_controller_spec.rb; script/spec -O spec/spec.opts spec/controllers/posts_controller_spec.rb; script/ spec -O spec/spec.opts spec/controllers/posts_controller_spec.rb; script/spec -O spec/spec.opts spec/controllers/ posts_controller_spec.rb; script/spec -O spec/spec.opts spec/ controllers/posts_controller_spec.rb ...................................... 38 examples, 0 failures ...................................... 38 examples, 0 failures ...................................... 38 examples, 0 failures ...................................... 38 examples, 0 failures ...................................... 38 examples, 0 failures ...................................... 38 examples, 0 failures ...................................... 38 examples, 0 failures ...................................... 38 examples, 0 failures script/spec -O spec/spec.opts spec/views/posts/new.rhtml_spec.rb spec/ views/posts/index.rhtml_spec.rb spec/views/posts/show.rhtml_spec.rb spec/controllers/posts_controller_spec.rb spec/views/posts/ edit.rhtml_spec.rb spec/helpers/posts_helper_spec.rb spec/models/ post_spec.rb ........................................... 43 examples, 0 failures ~/myproject$ touch app/controllers/posts_controller.rb script/spec -O spec/spec.opts spec/controllers/posts_controller_spec.rb ...................................... 38 examples, 0 failures From philodespotos at gmail.com Thu May 31 08:28:04 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Thu, 31 May 2007 07:28:04 -0500 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> Message-ID: <60f3810c0705310528w36ef86f8wdc7c9dd2e1ad798b@mail.gmail.com> On 5/31/07, David Chelimsky wrote: > On 5/31/07, Tom Stuart wrote: > > I've stopped being happy again, although this time for a different > > reason! > > > > I've got (let's say) one spec, with (let's say) 10 examples in it. > > autotest + rspec work like a charm as long all the examples pass, but > > if I change my code so that (let's say) 4 of the examples fail, > > things start to get out of control. > > > > autotest runs automatically after I make the broken change, which is > > fine: > > > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb > > > FFFF...... > > > > But then if I just touch a file so that it runs again, it does this: > > > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > > > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > > > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > spec.opts spec/models/matcher_spec.rb > > > FFFF...... > > > FFFF...... > > > FFFF...... > > > FFFF...... > > > > And if I touch again, I get: > > > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > > > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > > > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > spec.opts spec/models/matcher_spec.rb; [...16 times...] > > > FFFF...... > > > FFFF...... > > > FFFF...... > > > FFFF...... > > > FFFF...... > > > FFFF...... > > > [...16 times...] > > > > As you can imagine, as time goes by, this isn't doing much for my > > productivity. If I actually fix the breakage so that all the examples > > pass again, and wait for the 4^n invocations of script/spec to > > finish, I'm back in a healthy sitaution again, but once more examples > > start failing it starts spiraling off again... > > > > This is all a great incentive to never break my code but I need > > something a little gentler for now. Before I spend too much time > > investigating it, does anyone have any intuition about whether this > > is a zentest or an rspec_on_rails issue? > > I've not heard of this before and can't reproduce it. Which file are > you touching to get this to happen? I have the same issue. I typically only notice when working on a controller, since my controller specs are often larger than my model or view specs, so 16+ runs can take quite a while, but it happens with everything AFAICT. As an example to recap: Turn on autotest, get my green. Comment out the Model.find(:all) from my index action, save, and get 2 failures. Save again without changing anything, get the same 2 failures, but autotest runs a second time. Save once more, autotest runs four times. Again, 8. And so on. I'm currently running Rails r6868, rspec+rspec_on_rails r2049, and ZenTest 3.6.0 on OS X 10.4.9. Also using growlnotify with a .autotest I found at http://blog.internautdesign.com/2006/11/12/autotest-growl-goodness. Any other information that could help? Kyle From jed.hurt at gmail.com Thu May 31 11:45:45 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Thu, 31 May 2007 09:45:45 -0600 Subject: [rspec-users] Specify attr_protected In-Reply-To: <57c63afe0705302102y1900b806v355676da6d31c4e4@mail.gmail.com> References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> <57c63afe0705302100q43883e4r4381301eaa35b917@mail.gmail.com> <57c63afe0705302101s2a163158s1e88b1ce738b45c3@mail.gmail.com> <57c63afe0705302102y1900b806v355676da6d31c4e4@mail.gmail.com> Message-ID: Great. I like the 'send' syntax; its much cleaner than eval. Here's the final example for those following along at home: describe Order do [:id, :customer_ip, :status, :error_message, :updated_at, :created_at, :finalize, :tax, :shipping].each do |attribute| it "should protect '#{attribute}' attribute from mass assignment" do @order = Order.new(attribute => 'hax0rz') @order.send(attribute).should_not == 'hax0rz' end end end And the implementation: class Order < ActiveRecord::Base attr_protected :id, :customer_ip, :status, :error_message, :updated_at, :created_at, :finalize, :tax, :shipping end On 5/30/07, David Chelimsky wrote: > On 5/31/07, David Chelimsky wrote: > > On 5/31/07, David Chelimsky wrote: > > > On 5/30/07, Jed Hurt wrote: > > > > Hmmm.... scratch that. I actually had a typo in my code. After > > > > correcting the typo, It looks like the code is trying to literally > > > > call @order.attribute rather than @order.id, @order.total, etc... > > > > > > > > Is eval the best option? > > > > > > > > eval("@order.#{attribute}.should_not == 'hax0rz'") > > > > > > That, or (I think): > > > > > > (@order.send attribute).should)_not == hax0rz' > > > > > > > Sorry - typo - this: > > > > (@order.send attribute).should_not == hax0rz' > > UGH - one more time: > > (@order.send attribute).should_not == 'hax0rz' > > > > > > > > > > > > > > > On 5/30/07, Jed Hurt wrote: > > > > > Wow. It does work. I didn't even bother to try it because I figured > > > > > that calling 'it' inside of the 'each' block would not be the same as > > > > > calling 'it' directly inside of the 'describe' block. I've never > > > > > actually written a method that yields to a block. I'm still trying to > > > > > fit into my Rubyist pants. > > > > > > > > > > So Ruby actually yields down into the 'each' block from the parent > > > > > 'describe' block? > > > > > > > > > > On 5/30/07, David Chelimsky wrote: > > > > > > On 5/30/07, Jed Hurt wrote: > > > > > > > This is kind of a two part question. > > > > > > > > > > > > > > Question One: I want to be sure that an Order model is protecting > > > > > > > sensitive attributes from mass assignment. > > > > > > > > > > > > > > The example looks like this: > > > > > > > > > > > > > > describe Order do > > > > > > > it "should protect total attribute from mass assignment" do > > > > > > > @order = Order.new(:total => 0.05) > > > > > > > @order.total.should_not == 0.05 > > > > > > > end > > > > > > > end > > > > > > > > > > > > > > And the code to implement it: > > > > > > > > > > > > > > class Order < ActiveRecord::Base > > > > > > > attr_protected :total > > > > > > > end > > > > > > > > > > > > > > > > > > > > > It seems to work, but is there a better way? Not saying that this way > > > > > > > is bad, just that I'm very green :) > > > > > > > > > > > > This seems pretty good to me. You're not cluttering up the example > > > > > > with what the value of total IS - just what it is not, which is the > > > > > > thing you're interested in. > > > > > > > > > > > > > > > > > > > > > > > > > > > Question Two: I actually have a bunch of attributes that need to be > > > > > > > protected. Rather than hand-writing a call to the 'it' method for each > > > > > > > attribute, could I just loop over an array of attributes that need to > > > > > > > be checked and programatically define the 'it' calls? > > > > > > > > > > > > > > Pseudo-code: > > > > > > > > > > > > > > describe Order do > > > > > > > [:total, :id, :customer_ip, :status, :error_message, :updated_at, > > > > > > > :created_at, :finalize, :tax, :shipping].each do |attribute| > > > > > > > it "should protect #{attribute} attributes from mass assignment" do > > > > > > > @order = Order.new(attribute => 'hax0rz') > > > > > > > @order.attribute.should_not == 'hax0rz' > > > > > > > end > > > > > > > end > > > > > > > end > > > > > > > > > > > > > > What would the actual implementation look like? > > > > > > > > > > > > I think it would look exactly like what you wrote. Have you tried it? > > > > > > _______________________________________________ > > > > > > 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 Thu May 31 11:50:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 11:50:58 -0400 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <60f3810c0705310528w36ef86f8wdc7c9dd2e1ad798b@mail.gmail.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> <60f3810c0705310528w36ef86f8wdc7c9dd2e1ad798b@mail.gmail.com> Message-ID: <57c63afe0705310850w62d94b4ei32b1d29d5fee85c@mail.gmail.com> On 5/31/07, Kyle Hargraves wrote: > On 5/31/07, David Chelimsky wrote: > > On 5/31/07, Tom Stuart wrote: > > > I've stopped being happy again, although this time for a different > > > reason! > > > > > > I've got (let's say) one spec, with (let's say) 10 examples in it. > > > autotest + rspec work like a charm as long all the examples pass, but > > > if I change my code so that (let's say) 4 of the examples fail, > > > things start to get out of control. > > > > > > autotest runs automatically after I make the broken change, which is > > > fine: > > > > > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb > > > > FFFF...... > > > > > > But then if I just touch a file so that it runs again, it does this: > > > > > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > > > > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > > > > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > > spec.opts spec/models/matcher_spec.rb > > > > FFFF...... > > > > FFFF...... > > > > FFFF...... > > > > FFFF...... > > > > > > And if I touch again, I get: > > > > > > > script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ > > > > spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O > > > > spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > > spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ > > > > spec.opts spec/models/matcher_spec.rb; [...16 times...] > > > > FFFF...... > > > > FFFF...... > > > > FFFF...... > > > > FFFF...... > > > > FFFF...... > > > > FFFF...... > > > > [...16 times...] > > > > > > As you can imagine, as time goes by, this isn't doing much for my > > > productivity. If I actually fix the breakage so that all the examples > > > pass again, and wait for the 4^n invocations of script/spec to > > > finish, I'm back in a healthy sitaution again, but once more examples > > > start failing it starts spiraling off again... > > > > > > This is all a great incentive to never break my code but I need > > > something a little gentler for now. Before I spend too much time > > > investigating it, does anyone have any intuition about whether this > > > is a zentest or an rspec_on_rails issue? > > > > I've not heard of this before and can't reproduce it. Which file are > > you touching to get this to happen? > > I have the same issue. I typically only notice when working on a > controller, since my controller specs are often larger than my model > or view specs, so 16+ runs can take quite a while, but it happens with > everything AFAICT. > > As an example to recap: Turn on autotest, get my green. Comment out > the Model.find(:all) from my index action, save, and get 2 failures. > Save again without changing anything, get the same 2 failures, but > autotest runs a second time. Save once more, autotest runs four times. > Again, 8. And so on. > > I'm currently running Rails r6868, rspec+rspec_on_rails r2049, and > ZenTest 3.6.0 on OS X 10.4.9. > Also using growlnotify with a .autotest I found at > http://blog.internautdesign.com/2006/11/12/autotest-growl-goodness. I added the growl file described and get the following error: ./.autotest:7:in `slice': can't convert Regexp into Integer (TypeError) Did you run into this problem? > > Any other information that could help? > > Kyle > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tom at experthuman.com Thu May 31 11:55:03 2007 From: tom at experthuman.com (Tom Stuart) Date: Thu, 31 May 2007 16:55:03 +0100 Subject: [rspec-users] Specify attr_protected In-Reply-To: References: <57c63afe0705301643v308fe4aap1a3f78514d6d0fd2@mail.gmail.com> <57c63afe0705302100q43883e4r4381301eaa35b917@mail.gmail.com> <57c63afe0705302101s2a163158s1e88b1ce738b45c3@mail.gmail.com> <57c63afe0705302102y1900b806v355676da6d31c4e4@mail.gmail.com> Message-ID: <779D6565-6985-417D-84CA-E53868A5EE7F@experthuman.com> On 31 May 2007, at 16:45, Jed Hurt wrote: > Great. I like the 'send' syntax; its much cleaner than eval. > @order.send(attribute).should_not == 'hax0rz' Not to be pedantic, but I'd prefer @order[attribute].should_not == 'hax0rz' which of course does the same thing, but is a little bit more... semantically pleasing? Cheers, -Tom From jonathan at parkerhill.com Thu May 31 12:33:06 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Thu, 31 May 2007 12:33:06 -0400 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> Message-ID: This is exactly what happens to me too On May 31, 2007, at 7:41 AM, David Chelimsky wrote: > On 5/31/07, Tom Stuart wrote: >> On 30 May 2007, at 22:17, Tom Stuart wrote: >>> Everything's happy again now, especially me. >> >> I've stopped being happy again, although this time for a different >> reason! >> >> I've got (let's say) one spec, with (let's say) 10 examples in it. >> autotest + rspec work like a charm as long all the examples pass, but >> if I change my code so that (let's say) 4 of the examples fail, >> things start to get out of control. >> >> autotest runs automatically after I make the broken change, which is >> fine: >> >>> script/spec -O spec/spec.opts spec/models/matcher_spec.rb >>> FFFF...... >> >> But then if I just touch a file so that it runs again, it does this: >> >>> script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ >>> spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O >>> spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ >>> spec.opts spec/models/matcher_spec.rb >>> FFFF...... >>> FFFF...... >>> FFFF...... >>> FFFF...... >> >> And if I touch again, I get: >> >>> script/spec -O spec/spec.opts spec/models/matcher_spec.rb; script/ >>> spec -O spec/spec.opts spec/models/matcher_spec.rb; script/spec -O >>> spec/spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ >>> spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ >>> spec.opts spec/models/matcher_spec.rb; script/spec -O spec/ >>> spec.opts spec/models/matcher_spec.rb; [...16 times...] >>> FFFF...... >>> FFFF...... >>> FFFF...... >>> FFFF...... >>> FFFF...... >>> FFFF...... >>> [...16 times...] >> >> As you can imagine, as time goes by, this isn't doing much for my >> productivity. If I actually fix the breakage so that all the examples >> pass again, and wait for the 4^n invocations of script/spec to >> finish, I'm back in a healthy sitaution again, but once more examples >> start failing it starts spiraling off again... >> >> This is all a great incentive to never break my code but I need >> something a little gentler for now. Before I spend too much time >> investigating it, does anyone have any intuition about whether this >> is a zentest or an rspec_on_rails issue? > > I've not heard of this before and can't reproduce it. Which file are > you touching to get this to happen? > >> >> Cheers, >> -Tom >> _______________________________________________ >> 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 jonathan at parkerhill.com Thu May 31 12:35:43 2007 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Thu, 31 May 2007 12:35:43 -0400 Subject: [rspec-users] rspec and autotest In-Reply-To: References: <57c63afe0705291451w35bf31f5qf9cc1bd3602c1110@mail.gmail.com> <1A596517-C71D-45DA-B7F4-6826E2C6D056@parkerhill.com> <57c63afe0705291617l53fd39e5pd1392126ba9519d3@mail.gmail.com> Message-ID: <08BD2AA5-8D34-4F36-9090-D4491AD361A7@parkerhill.com> I dont know if this is related but test.log contains these lines at the start of each time rspec runs ===== Wednesday, May 30, 2007 10:11:37 PM US/Eastern ===== Spec::Rails::DSL::HelperEvalContextController: missing default helper path spec/rails/dsl/helper_eval_context_helper Spec::Rails::DSL::ViewExampleController: missing default helper path spec/rails/dsl/view_example_helper SQL (0.000177) SET SQL_AUTO_IS_NULL=0 SQL (0.000072) BEGIN From philodespotos at gmail.com Thu May 31 14:01:38 2007 From: philodespotos at gmail.com (Kyle Hargraves) Date: Thu, 31 May 2007 13:01:38 -0500 Subject: [rspec-users] autotest and rspec_on_rails not happy In-Reply-To: <57c63afe0705310850w62d94b4ei32b1d29d5fee85c@mail.gmail.com> References: <57c63afe0705301352i10c9ed5dk9a262c69d8220343@mail.gmail.com> <57c63afe0705301413s68004f9bjd4e5dc8a896beadb@mail.gmail.com> <00E3CF8B-89D5-4311-9D78-4ADB0491AD02@experthuman.com> <294AEDEF-6323-4EA3-8C4B-43CC33A84CCE@experthuman.com> <57c63afe0705310441g730e2b27q5c1600e46c2081f6@mail.gmail.com> <60f3810c0705310528w36ef86f8wdc7c9dd2e1ad798b@mail.gmail.com> <57c63afe0705310850w62d94b4ei32b1d29d5fee85c@mail.gmail.com> Message-ID: <60f3810c0705311101x16676c50kc2c6b0add4c98381@mail.gmail.com> On 5/31/07, David Chelimsky wrote: > I added the growl file described and get the following error: > > ./.autotest:7:in `slice': can't convert Regexp into Integer (TypeError) > > Did you run into this problem? My mistake, I just provided the first link that looked similar on Google. That one's for an older version of ZenTest that provided the results differently. The actual one I'm using is slightly different and I can't find the blog I got it from, but this is my actual file: http://pastie.caboo.se/66587. Either way it looks to be irrelevant, as if I move the file out of the way and try it, the error still occurs. Kyle From nick at ekenosen.net Thu May 31 16:34:47 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Thu, 31 May 2007 16:34:47 -0400 Subject: [rspec-users] Another attempt for a succinct model validation DSL Message-ID: <276ff9870705311334t7dd388c8mf79fc6e7fa5aa695@mail.gmail.com> On 5/28/07, David Chelimsky wrote: > The behaviour you're trying to describe is that the User should > require that passwords bear certain qualities - in this case a length > between 5 and 40. So you need to ask yourself how the User should > behave when this requirement is violated, and then specify that it > behaves that way. > > Here's how I might handle this: > > describe User do > it "should reject a password of length 4" do > User.create(:password => "1234").should have(1).error_on(:password) > end > it "should accept a password of length 5" do > User.create(:password => "12345").should have(0).errors_on(:password) > end ... That's pretty much exactly the pattern that I've been doing for specing my model validations... I like it; I think it is the simplest, most useful way of going about validations. But it can get a bit wordy, and the code duplication starts to become painful. I flooded the lists a few weeks back with some ideas for a nicer DSL for model validations, but I never actually followed up with a working implementation, because they all still felt a bit clunky to me... plus I haven't had any free weekends, nor have I been doing much with model validations at work recently. For some reason, looking at your example here made me want to try for a better DSL again. I like your use of the words "accept" and "reject" (versus "valid"/"invalid"), because they get right to the core of what actually happens, i.e. what the behavior is. And I like the emphasis on the examples (especially since I often think of TDD/BDD as EDD, Example Driven Design). So here's my latest thought-experiment: http://pastie.caboo.se/66478 And also, a simpler multi-field version: http://pastie.caboo.se/66510 Notice how checking all three sides of each boundary is so simple and succinct that there is almost no excuse not to do so. Also, after noticing how similar the multi-field validation is to a fit-table or some of Brian Marick and zenspider's recent blog entries, I decided that further simplification was necessary/desirable. :-) Consider this my request for comments on the syntax. Hopefully I'll have time to put my code where my mouth is and create a rspec extension to do this in the near future. :-) -- Nick From dchelimsky at gmail.com Thu May 31 17:56:58 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 May 2007 17:56:58 -0400 Subject: [rspec-users] Another attempt for a succinct model validation DSL In-Reply-To: <276ff9870705311334t7dd388c8mf79fc6e7fa5aa695@mail.gmail.com> References: <276ff9870705311334t7dd388c8mf79fc6e7fa5aa695@mail.gmail.com> Message-ID: <57c63afe0705311456p716f9c8mf564f3cd4cbfd40b@mail.gmail.com> On 5/31/07, nicholas a. evans wrote: > On 5/28/07, David Chelimsky wrote: > > The behaviour you're trying to describe is that the User should > > require that passwords bear certain qualities - in this case a length > > between 5 and 40. So you need to ask yourself how the User should > > behave when this requirement is violated, and then specify that it > > behaves that way. > > > > Here's how I might handle this: > > > > describe User do > > it "should reject a password of length 4" do > > User.create(:password => "1234").should have(1).error_on(:password) > > end > > it "should accept a password of length 5" do > > User.create(:password => "12345").should have(0).errors_on(:password) > > end > ... > > That's pretty much exactly the pattern that I've been doing for > specing my model validations... I like it; I think it is the > simplest, most useful way of going about validations. But it can get > a bit wordy, and the code duplication starts to become painful. > > I flooded the lists a few weeks back with some ideas for a nicer DSL > for model validations, but I never actually followed up with a working > implementation, because they all still felt a bit clunky to me... plus > I haven't had any free weekends, nor have I been doing much with model > validations at work recently. > > For some reason, looking at your example here made me want to try for > a better DSL again. I like your use of the words "accept" and > "reject" (versus "valid"/"invalid"), because they get right to the > core of what actually happens, i.e. what the behavior is. And I like > the emphasis on the examples (especially since I often think of > TDD/BDD as EDD, Example Driven Design). > > So here's my latest thought-experiment: http://pastie.caboo.se/66478 > And also, a simpler multi-field version: http://pastie.caboo.se/66510 > > Notice how checking all three sides of each boundary is so simple and > succinct that there is almost no excuse not to do so. Also, after > noticing how similar the multi-field validation is to a fit-table or > some of Brian Marick and zenspider's recent blog entries, I decided > that further simplification was necessary/desirable. :-) > > Consider this my request for comments on the syntax. Hopefully I'll > have time to put my code where my mouth is and create a rspec > extension to do this in the near future. :-) Really interesting stuff. Thanks! I took at a shot at something that feels more like the rest of RSpec. It's admittedly more verbose than your examples, but I also think it speaks well and aligns with everything else in rspec. WDYT? http://pastie.caboo.se/66679 David > > -- > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel at danielfischer.com Thu May 31 22:06:32 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Thu, 31 May 2007 19:06:32 -0700 Subject: [rspec-users] Okay, new question - dealing w/ logging in restrictions (controller?) Message-ID: <7e565b5c0705311906x46d95a1ap85dd50825625ce9d@mail.gmail.com> Hey all, so if you read my previous thing about nested routes - I'm just not going to do with them anymore. Anyway, so my controller has a before_filter on the edit action; which checks to see if the current post's user, is the same as the currently logged in user, if true then they can edit, otherwise not. def check_user if current_user.login != @post.user.login redirect_to post_url(@post) end end Now I can easily test this functionality by seeing if I get redirected if I hit that page, but what if I actually want to be logged in, so I can test to see if the edit action is working? Any input on this? Thanks. -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community From daniel at danielfischer.com Thu May 31 22:10:46 2007 From: daniel at danielfischer.com (Fischer, Daniel) Date: Thu, 31 May 2007 19:10:46 -0700 Subject: [rspec-users] Another attempt for a succinct model validation DSL In-Reply-To: <57c63afe0705311456p716f9c8mf564f3cd4cbfd40b@mail.gmail.com> References: <276ff9870705311334t7dd388c8mf79fc6e7fa5aa695@mail.gmail.com> <57c63afe0705311456p716f9c8mf564f3cd4cbfd40b@mail.gmail.com> Message-ID: <7e565b5c0705311910o5a3f9734v23aa2508ffd33161@mail.gmail.com> I really like the second one! On 5/31/07, David Chelimsky wrote: > On 5/31/07, nicholas a. evans wrote: > > On 5/28/07, David Chelimsky wrote: > > > The behaviour you're trying to describe is that the User should > > > require that passwords bear certain qualities - in this case a length > > > between 5 and 40. So you need to ask yourself how the User should > > > behave when this requirement is violated, and then specify that it > > > behaves that way. > > > > > > Here's how I might handle this: > > > > > > describe User do > > > it "should reject a password of length 4" do > > > User.create(:password => "1234").should have(1).error_on(:password) > > > end > > > it "should accept a password of length 5" do > > > User.create(:password => "12345").should have(0).errors_on(:password) > > > end > > ... > > > > That's pretty much exactly the pattern that I've been doing for > > specing my model validations... I like it; I think it is the > > simplest, most useful way of going about validations. But it can get > > a bit wordy, and the code duplication starts to become painful. > > > > I flooded the lists a few weeks back with some ideas for a nicer DSL > > for model validations, but I never actually followed up with a working > > implementation, because they all still felt a bit clunky to me... plus > > I haven't had any free weekends, nor have I been doing much with model > > validations at work recently. > > > > For some reason, looking at your example here made me want to try for > > a better DSL again. I like your use of the words "accept" and > > "reject" (versus "valid"/"invalid"), because they get right to the > > core of what actually happens, i.e. what the behavior is. And I like > > the emphasis on the examples (especially since I often think of > > TDD/BDD as EDD, Example Driven Design). > > > > So here's my latest thought-experiment: http://pastie.caboo.se/66478 > > And also, a simpler multi-field version: http://pastie.caboo.se/66510 > > > > Notice how checking all three sides of each boundary is so simple and > > succinct that there is almost no excuse not to do so. Also, after > > noticing how similar the multi-field validation is to a fit-table or > > some of Brian Marick and zenspider's recent blog entries, I decided > > that further simplification was necessary/desirable. :-) > > > > Consider this my request for comments on the syntax. Hopefully I'll > > have time to put my code where my mouth is and create a rspec > > extension to do this in the near future. :-) > > Really interesting stuff. Thanks! > > I took at a shot at something that feels more like the rest of RSpec. > It's admittedly more verbose than your examples, but I also think it > speaks well and aligns with everything else in rspec. WDYT? > > http://pastie.caboo.se/66679 > > David > > > > > > > -- > > Nick > > _______________________________________________ > > 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 > -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community