From mailing_lists at railsnewbie.com Sun Apr 1 10:50:12 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 1 Apr 2007 10:50:12 -0400 Subject: [rspec-users] --color doesn't work with --drb w/rspec_autotest Message-ID: If I got this to work, do you think we could/should check in rspec_autotest into rspec? I've updated rspec_autotest abit, so let me know if you'd like the modified code. Scott From dchelimsky at gmail.com Sun Apr 1 11:03:46 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 1 Apr 2007 10:03:46 -0500 Subject: [rspec-users] --color doesn't work with --drb w/rspec_autotest In-Reply-To: References: Message-ID: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> On 4/1/07, Scott Taylor wrote: > > If I got this to work, do you think we could/should check in > rspec_autotest into rspec? > > I've updated rspec_autotest abit, so let me know if you'd like the > modified code. > > Scott This is an interesting idea but I want to coordinate w/ rspec_autotest's author first. I'll get back to the list after I hear back from him. David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Sun Apr 1 11:16:15 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 1 Apr 2007 11:16:15 -0400 Subject: [rspec-users] --color doesn't work with --drb w/rspec_autotest In-Reply-To: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> Message-ID: On Apr 1, 2007, at 11:03 AM, David Chelimsky wrote: > On 4/1/07, Scott Taylor wrote: >> >> If I got this to work, do you think we could/should check in >> rspec_autotest into rspec? >> >> I've updated rspec_autotest abit, so let me know if you'd like the >> modified code. >> >> Scott > > This is an interesting idea but I want to coordinate w/ > rspec_autotest's author first. I'll get back to the list after I hear > back from him. > > David Yeah - I believe I tried to email him and the email on his blog was broken. I know that he was trying to integrate this with autotest. Last I checked (a few days ago), Autotest has a bug in its tracker relating to rspec_autotest. So maybe this piece of software belongs in autotest. If "getting the names right" is as a big of a deal as you guys claim it is, then the tool should properly be labeled "autospec". Or maybe just "ln -s" it. As for the red/green issue - someone else on the mailing list claimed that they could use drb w/ color - so it would be interesting to hear exactly what their configuration is (what rspec/rspec_on_rails setup they have). Out of my own curiosity (and also for fixing the autospec bug), how is the red/green color generated in rspec? Or rather, can you point me to the code that does so? I've only been able to find the opts(-- color) line in the runner. And finally a third thing: I'm almost done over-hauling the doc system to use webgen 0.4.2. I'll post the code to the tracker when I'm done with that. Scott From dchelimsky at gmail.com Sun Apr 1 11:22:38 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 1 Apr 2007 10:22:38 -0500 Subject: [rspec-users] --color doesn't work with --drb w/rspec_autotest In-Reply-To: References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> Message-ID: <57c63afe0704010822o5504823ta4f251177a0ceabe@mail.gmail.com> On 4/1/07, Scott Taylor wrote: > > On Apr 1, 2007, at 11:03 AM, David Chelimsky wrote: > > > On 4/1/07, Scott Taylor wrote: > >> > >> If I got this to work, do you think we could/should check in > >> rspec_autotest into rspec? > >> > >> I've updated rspec_autotest abit, so let me know if you'd like the > >> modified code. > >> > >> Scott > > > > This is an interesting idea but I want to coordinate w/ > > rspec_autotest's author first. I'll get back to the list after I hear > > back from him. > > > > David > > Yeah - I believe I tried to email him and the email on his blog was > broken. > > I know that he was trying to integrate this with autotest. Last I > checked (a few days ago), Autotest has a bug in its tracker relating > to rspec_autotest. So maybe this piece of software belongs in autotest. If that's true then I'll try to coordinate w/ Ryan and Eric. > > If "getting the names right" is as a big of a deal as you guys claim > it is, then the tool should properly be labeled "autospec". Or maybe > just "ln -s" it. Sure - that's just a name in a rake task. So most likely it would end up being something like spec:auto > > As for the red/green issue - someone else on the mailing list claimed > that they could use drb w/ color - so it would be interesting to hear > exactly what their configuration is (what rspec/rspec_on_rails setup > they have). > > Out of my own curiosity (and also for fixing the autospec bug), how > is the red/green color generated in rspec? Or rather, can you point > me to the code that does so? I've only been able to find the opts(-- > color) line in the runner. Look at base_text_formatter.rb > > And finally a third thing: I'm almost done over-hauling the doc > system to use webgen 0.4.2. I'll post the code to the tracker when > I'm done with that. Great. I look forward to it. Thanks Scott, David > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Sun Apr 1 12:57:54 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 1 Apr 2007 12:57:54 -0400 Subject: [rspec-users] rake w/rspec Message-ID: <09DCBFCD-8AE0-41A1-9005-88FFA11BF5A9@railsnewbie.com> How can I spec out a rake task? How can I use rake in my spec's? I want to fix this rake spec:autotest bug with --drb and --color. How can I get rake output? How would I get out of autotest? My initial thought is just to run the command in the spec. Scott From dchelimsky at gmail.com Sun Apr 1 15:21:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 1 Apr 2007 14:21:33 -0500 Subject: [rspec-users] rake w/rspec In-Reply-To: <09DCBFCD-8AE0-41A1-9005-88FFA11BF5A9@railsnewbie.com> References: <09DCBFCD-8AE0-41A1-9005-88FFA11BF5A9@railsnewbie.com> Message-ID: <57c63afe0704011221p5e3138acr6e19a124707f5ce9@mail.gmail.com> Grab the ZenTest gem and look at its tests for autotest. That should give you some direction I think. On 4/1/07, Scott Taylor wrote: > > How can I spec out a rake task? > > How can I use rake in my spec's? I want to fix this rake > spec:autotest bug with --drb and --color. How can I get rake output? > > How would I get out of autotest? My initial thought is just to run > the command in the spec. > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Sun Apr 1 15:23:41 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 1 Apr 2007 21:23:41 +0200 Subject: [rspec-users] rake w/rspec In-Reply-To: <09DCBFCD-8AE0-41A1-9005-88FFA11BF5A9@railsnewbie.com> References: <09DCBFCD-8AE0-41A1-9005-88FFA11BF5A9@railsnewbie.com> Message-ID: <8d961d900704011223u4742e61tf254164c6308b86@mail.gmail.com> On 4/1/07, Scott Taylor wrote: > > How can I spec out a rake task? > I haven't tried it myself, but I would look at Rake's own unit tests to see how they do it. > How can I use rake in my spec's? Do you mean invoking a Rake task? Either by spawing a child rake process (not recommended since it's slow) or by instantiating a task object directly and invoking it via Rake's API. > I want to fix this rake > spec:autotest bug with --drb and --color. How can I get rake output? > I think you'd get better Rake questions on the Rake mailing list. > How would I get out of autotest? My initial thought is just to run > the command in the spec. > I don't understand the question. Get out of? Aslak > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Sun Apr 1 15:49:50 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 1 Apr 2007 15:49:50 -0400 Subject: [rspec-users] rake w/rspec In-Reply-To: <8d961d900704011223u4742e61tf254164c6308b86@mail.gmail.com> References: <09DCBFCD-8AE0-41A1-9005-88FFA11BF5A9@railsnewbie.com> <8d961d900704011223u4742e61tf254164c6308b86@mail.gmail.com> Message-ID: <5D96C891-AB85-450B-8A1F-7B25304958A4@railsnewbie.com> On Apr 1, 2007, at 3:23 PM, aslak hellesoy wrote: > On 4/1/07, Scott Taylor wrote: >> >> How can I spec out a rake task? >> > > I haven't tried it myself, but I would look at Rake's own unit tests > to see how they do it. > >> How can I use rake in my spec's? > > Do you mean invoking a Rake task? Either by spawing a child rake > process (not recommended since it's slow) or by instantiating a task > object directly and invoking it via Rake's API. > >> I want to fix this rake >> spec:autotest bug with --drb and --color. How can I get rake output? >> > > I think you'd get better Rake questions on the Rake mailing list. > >> How would I get out of autotest? My initial thought is just to run >> the command in the spec. >> > I don't understand the question. Get out of? Escape out of autotest. Usually with autotest you hit CTRL-C to run all of the tests (again). Hitting Control-C twice gets you back to the command line. This is actually a bug w/ rspec_autotest, because CTRL-C also shuts down rake. rspec_autotest is run through rake, so to re-run all of your specs (not just the failing ones), you will have to exit the application and run it again (even though autotest claims otherwise). Aslak, Thanks for the input on rake. From mailing_lists at railsnewbie.com Sun Apr 1 15:51:15 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 1 Apr 2007 15:51:15 -0400 Subject: [rspec-users] rake w/rspec In-Reply-To: <57c63afe0704011221p5e3138acr6e19a124707f5ce9@mail.gmail.com> References: <09DCBFCD-8AE0-41A1-9005-88FFA11BF5A9@railsnewbie.com> <57c63afe0704011221p5e3138acr6e19a124707f5ce9@mail.gmail.com> Message-ID: <5E0CC5DA-E1F6-4FA7-93BF-4242758B63E1@railsnewbie.com> I've started, but didn't see anything too striking. Couldn't figure out how the test's were actually running through autotest, although I only looked at it briefly. I'll have another go of it in a few days, and post back if I find anything interesting or fix the bug. Scott On Apr 1, 2007, at 3:21 PM, David Chelimsky wrote: > Grab the ZenTest gem and look at its tests for autotest. That should > give you some direction I think. > > On 4/1/07, Scott Taylor wrote: >> >> How can I spec out a rake task? >> >> How can I use rake in my spec's? I want to fix this rake >> spec:autotest bug with --drb and --color. How can I get rake output? >> >> How would I get out of autotest? My initial thought is just to run >> the command in the spec. >> >> 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 joshknowles at gmail.com Sun Apr 1 19:42:23 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Sun, 1 Apr 2007 16:42:23 -0700 Subject: [rspec-users] a better "should have valid associations" In-Reply-To: <57c63afe0703311344h5298c7c2wef0c71aa2a6daeda@mail.gmail.com> References: <4b430c8f0703290118t49bf8c45vc8fcab2670108f97@mail.gmail.com> <57c63afe0703290805n44d830arb49b93215cf572ee@mail.gmail.com> <57c63afe0703290844m20421d03q8e54ef0a4810c5e3@mail.gmail.com> <8d961d900703290902n5ef951b5k2045564a92e41d90@mail.gmail.com> <6079631A-7C8D-4BC6-AA80-973F22E684EC@daveastels.com> <8d961d900703311109j1a05dc09w34e4b35e33ab6633@mail.gmail.com> <57c63afe0703311344h5298c7c2wef0c71aa2a6daeda@mail.gmail.com> Message-ID: On 3/31/07, David Chelimsky wrote: > My instinct is that I wouldn't want the dependency from Spec::Rails to > another plugin. If that's the goal we should either ship the > rspec_resource generator as a separate plugin or move Josh's plugin > into RSpec (w/ his permission, of course). > > Thoughts on that (especially from Josh)? I'm all for moving this into rspec_on_rails. The only reason I released this originally as a plugin was honestly because the barrier to entry of getting the rspec dev environment up and running was to much. Dealing with old versions of webgen and not being able to use sqlite was to much frustration for an afternoon hack project. If there is enough interest I will gladly add the additional association matchers and submit everything as a patch. 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/20070401/55df0688/attachment.html From dchelimsky at gmail.com Tue Apr 3 09:03:44 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Apr 2007 08:03:44 -0500 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> Message-ID: <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> On 4/1/07, Scott Taylor wrote: > And finally a third thing: I'm almost done over-hauling the doc > system to use webgen 0.4.2. I'll post the code to the tracker when > I'm done with that. > > Scott How close are you on this? I'm trying to do some planning. Thx, David From mailing_lists at railsnewbie.com Tue Apr 3 15:56:09 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 3 Apr 2007 15:56:09 -0400 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> Message-ID: <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> Right now I just have the main style sheet to change a bit, as one or two of the CSS classes have changed. I'd also like to write a small shell script to diff the results of the output directories (unless I can do this with svn?) just to make sure nothing (significant) has changed. By the looks of it everything looks about ready to go. Otherwise the content parser (for textile + ruby html tags) has totally been rewritten. All of the meta.info files (containing the directory hiarchies) has been consolidated into one file at the root of doc. I'm not sure if you consider this a feature or not, although it seems to be required by webgen 0.4.2. I've posted to their mailing list to see if I can go back to the old system (of having meta.info files in each subdir which has a menu). I haven't gotten a response yet. So, pretty close. I should be done with it by tomorrow, if everything goes well, or by the end of the week if one employs a conservative measure. Best, Scott On Apr 3, 2007, at 9:03 AM, David Chelimsky wrote: > On 4/1/07, Scott Taylor wrote: > >> And finally a third thing: I'm almost done over-hauling the doc >> system to use webgen 0.4.2. I'll post the code to the tracker when >> I'm done with that. >> >> Scott > > How close are you on this? I'm trying to do some planning. > > Thx, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Tue Apr 3 16:05:28 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 3 Apr 2007 22:05:28 +0200 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> Message-ID: <8d961d900704031305m7f846a9dnc2d8b3b430d24541@mail.gmail.com> On 4/3/07, Scott Taylor wrote: > > Right now I just have the main style sheet to change a bit, as one or > two of the CSS classes have changed. > > I'd also like to write a small shell script to diff the results of > the output directories (unless I can do this with svn?) just to make > sure nothing (significant) has changed. By the looks of it > everything looks about ready to go. > > Otherwise the content parser (for textile + ruby html tags) has > totally been rewritten. > > All of the meta.info files (containing the directory hiarchies) has > been consolidated into one file at the root of doc. I'm not sure if > you consider this a feature or not, although it seems to be required > by webgen 0.4.2. I've posted to their mailing list to see if I can > go back to the old system (of having meta.info files in each subdir > which has a menu). I haven't gotten a response yet. > Actually, having one single meta.info file at the top would be great! I'm planning to add a Javascript-backed menu to the site to make it more navigable, and this would be a great starting point. Aslak > So, pretty close. I should be done with it by tomorrow, if > everything goes well, or by the end of the week if one employs a > conservative measure. > > Best, > > Scott > > > > On Apr 3, 2007, at 9:03 AM, David Chelimsky wrote: > > > On 4/1/07, Scott Taylor wrote: > > > >> And finally a third thing: I'm almost done over-hauling the doc > >> system to use webgen 0.4.2. I'll post the code to the tracker when > >> I'm done with that. > >> > >> Scott > > > > How close are you on this? I'm trying to do some planning. > > > > Thx, > > 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 mailing_lists at railsnewbie.com Tue Apr 3 19:40:41 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 3 Apr 2007 19:40:41 -0400 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: <8d961d900704031305m7f846a9dnc2d8b3b430d24541@mail.gmail.com> References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> <8d961d900704031305m7f846a9dnc2d8b3b430d24541@mail.gmail.com> Message-ID: > > Actually, having one single meta.info file at the top would be great! > I'm planning to add a Javascript-backed menu to the site to make it > more navigable, and this would be a great starting point. > > Aslak > >> So, pretty close. I should be done with it by tomorrow, if >> everything goes well, or by the end of the week if one employs a >> conservative measure. Actually the file is now called metainfo.yaml, just for your information. Is there any other non-textile content in any of the src files for webgen? All I've seen so far is , , and ....Anything else that isn't textile? Scott From pergesu at gmail.com Wed Apr 4 00:07:29 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 3 Apr 2007 22:07:29 -0600 Subject: [rspec-users] rspec_plugin generator Message-ID: <810a540e0704032107xde04f47uc2b0eb6bd1bfb445@mail.gmail.com> I've created a couple plugins lately, and have been using RSpec instead of Test::Unit for them, so I wrote up this little generator. Also does some isolated database testing if you want as an added bonus. Basic info: Rails gives us a generator to create plugins with ./script/generate plugin. It creates all the stub files, including some tests for you. What if you want to use RSpec instead of Test::Unit though? ./script/generate rspec_plugin Yep, it's super basic, it just does all the same stuff as the regular plugin generator does, except it creates RSpec stubs for you. There is one added bonus though, and that's that you can set up an individual database for your plugin. ./script/generate rspec_plugin my_plugin --with-database This will create a schema.rb file where you can create the schema for your plugin specs, a database.yml file to configure the database connection, and set up some helpful stuff in spec_helper.rb Nice for quickly getting a plugin going with tests isolated against its own database. The database stuff is based on code from Chapter 8 of Rails Plugins: Extending Rails Beyond the Core by James Adam. If you're writing a plugin, check it out, you'll definitely learn a few tricks. ./script/plugin install svn://evang.eli.st/public/plugins/rspec_plugin From aslak.hellesoy at gmail.com Wed Apr 4 03:44:05 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 4 Apr 2007 09:44:05 +0200 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> <8d961d900704031305m7f846a9dnc2d8b3b430d24541@mail.gmail.com> Message-ID: <8d961d900704040044t53daddfrab2ce0d772e96f2b@mail.gmail.com> On 4/4/07, Scott Taylor wrote: > > > > Actually, having one single meta.info file at the top would be great! > > I'm planning to add a Javascript-backed menu to the site to make it > > more navigable, and this would be a great starting point. > > > > Aslak > > > >> So, pretty close. I should be done with it by tomorrow, if > >> everything goes well, or by the end of the week if one employs a > >> conservative measure. > > > Actually the file is now called metainfo.yaml, just for your > information. > > Is there any other non-textile content in any of the src files for > webgen? All I've seen so far is , , and > > > ....Anything else that isn't textile? > Not that I know of. > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From esad at esse.at Wed Apr 4 11:43:18 2007 From: esad at esse.at (Esad Hajdarevic) Date: Wed, 04 Apr 2007 17:43:18 +0200 Subject: [rspec-users] pontential bug in rspec_on_rails and ActiveRecord transactions Message-ID: <4613C796.5090900@esse.at> Hello rspec-users, I've encountered a strange bug in rspec, but it may be me who is wrong. I'm running latest version from the trunk (r1678) of both rspec and rspec_on_rails. Please consider the following model: class Url < ActiveRecord::Base def after_save Contact.create!(:primary_email => 'user at example.com') raise ActiveRecord::RecordInvalid.new(self) end end Basically what it does is that in after_save it will insert a new contact into database but after the exception has been raised, the Rails will make a rollback on transaction. Running in console: Url.create!(:url => 'http://example.com') Will yield following SQL (taken from the log) BEGIN INSERT INTO urls (`icon_url`, `domain`, `url`, `cached_version`, `description`, `created_at`) VALUES(NULL, NULL, 'http://www.example.com/', 0, NULL, '2007-04-04 15:36:08') INSERT INTO contacts (`internal_id`, `name`, `updated_at`, `primary_email`, `notes`, `user_id`, `created_at`) VALUES(NULL, NULL, '2007-04-04 15:36:08', 'user at example.com', NULL, NULL, '2007-04-04 15:36:08') ROLLBACK However, when I wrote the specification that looked something like this: context "Url" do setup do Contact.delete_all Url.delete_all end specify do lambda { Url.create(:url => 'http://www.example.com/') }.should raise_error Url.count.should == 0 Contact.count.should == 0 end end It failed! The log output was: BEGIN DELETE FROM contacts DELETE FROM urls INSERT INTO urls (`icon_url`, `domain`, `url`, `cached_version`, `description`, `created_at`) VALUES(NULL, NULL, 'http://www.example.com/', 0, NULL, '2007-04-04 15:35:46') INSERT INTO contacts (`internal_id`, `name`, `updated_at`, `primary_email`, `notes`, `user_id`, `created_at`) VALUES(NULL, NULL, '2007-04-04 15:35:46', 'user at example.com', NULL, NULL, '2007-04-04 15:35:46') SELECT count(*) AS count_all FROM urls ROLLBACK How did count statement got into transaction? Is rspec doing some magic with ActiveRecord that is causing this to happen? Thanks for your help, Esad From aslak.hellesoy at gmail.com Wed Apr 4 12:33:01 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 4 Apr 2007 18:33:01 +0200 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. Message-ID: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> We'd like to get some feedback on RSpec 0.9 before we start pushing out releases via Rubyforge's gem server and update the website. We have therefore made the first beta of 0.9 available - both prepackaged and tagged in subversion (see below). RSpec 0.9 introduces a new API for expectations, which essentially means that your underscores go away (there has been other discussions on the lists about this). In addition to this, you can say describe/it instead of context/specify. We believe this will lead to even more readable - and well-written specs. (context/specify will still be supported for a while). == Translator == In order to ease the transition from 0.8 to 0.9, we have included a tool to translate your 0.8 style specs to 0.9 style. After installing the 0.9 gem, you should run: spec_translator path_to_my_spec_dir path_to_my_translated_spec_dir (or alternatively, if you have your code under version control and can do a revert if things go wrong:) spec_translator path_to_my_spec_dir path_to_my_spec_dir (This will translate your specs in-place) == Where to get it == RSpec core is available here: * http://rspec.rubyforge.org/rspec-0.9.0.gem * http://rspec.rubyforge.org/rspec-0.9.0.tgz * http://rspec.rubyforge.org/rspec-0.9.0.zip * http://rspec.rubyforge.org/RSpec-0.9.0.tmbundle.tgz == Rails users == For those of you who want to install 0.9 beta as plugins, the svn URLs are: * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec_on_rails (Don't forget to do do a "script generate rspec" to update your local files) Cheers, Aslak From mtrier at eminentconsultinggroup.com Wed Apr 4 12:53:47 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Wed, 4 Apr 2007 12:53:47 -0400 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: <9F9AF820-B756-4E1B-B5C1-44EEC828918F@eminentconsultinggroup.com> Thanks Aslak, David, and the rest of the team. Nice work. Michael On Apr 4, 2007, at 12:33 PM, aslak hellesoy wrote: > We'd like to get some feedback on RSpec 0.9 before we start pushing > out releases via Rubyforge's gem server and update the website. We > have therefore made the first beta of 0.9 available - both prepackaged > and tagged in subversion (see below). > > RSpec 0.9 introduces a new API for expectations, which essentially > means that your underscores go away (there has been other discussions > on the lists about this). In addition to this, you can say describe/it > instead of context/specify. We believe this will lead to even more > readable - and well-written specs. (context/specify will still be > supported for a while). > > == Translator == > In order to ease the transition from 0.8 to 0.9, we have included a > tool to translate your 0.8 style specs to 0.9 style. After installing > the 0.9 gem, you should run: > > spec_translator path_to_my_spec_dir path_to_my_translated_spec_dir > > (or alternatively, if you have your code under version control and can > do a revert if things go wrong:) > > spec_translator path_to_my_spec_dir path_to_my_spec_dir > > (This will translate your specs in-place) > > == Where to get it == > > RSpec core is available here: > > * http://rspec.rubyforge.org/rspec-0.9.0.gem > * http://rspec.rubyforge.org/rspec-0.9.0.tgz > * http://rspec.rubyforge.org/rspec-0.9.0.zip > * http://rspec.rubyforge.org/RSpec-0.9.0.tmbundle.tgz > > == Rails users == > For those of you who want to install 0.9 beta as plugins, the svn > URLs are: > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/ > rspec_on_rails > > (Don't forget to do do a "script generate rspec" to update your > local files) > > Cheers, > Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tils-rspec at tils.net Wed Apr 4 14:03:46 2007 From: tils-rspec at tils.net (Tilmann Singer) Date: Wed, 4 Apr 2007 20:03:46 +0200 Subject: [rspec-users] pontential bug in rspec_on_rails and ActiveRecord transactions In-Reply-To: <4613C796.5090900@esse.at> References: <4613C796.5090900@esse.at> Message-ID: <20070404180346.GN7625@tils.net> * Esad Hajdarevic [20070404 18:57]: > The log output was: > > BEGIN > DELETE FROM contacts > DELETE FROM urls > INSERT INTO urls (`icon_url`, `domain`, `url`, `cached_version`, > `description`, `created_at`) VALUES(NULL, NULL, > 'http://www.example.com/', 0, NULL, '2007-04-04 15:35:46') > INSERT INTO contacts (`internal_id`, `name`, `updated_at`, > `primary_email`, `notes`, `user_id`, `created_at`) VALUES(NULL, NULL, > '2007-04-04 15:35:46', 'user at example.com', NULL, NULL, '2007-04-04 > 15:35:46') > SELECT count(*) AS count_all FROM urls > ROLLBACK > > How did count statement got into transaction? Is rspec doing some > magic with ActiveRecord that is causing this to happen? RSpec does the same as the Test::Unit framework, it will wrap each test run in a transaction and roll it back at the end, if the configuration use_transactional_fixtures = true is set (in spec_helper.rb). If you want to test behaviour that is depending on db transactions then I think it is necessary to set this to false. Til From dchelimsky at gmail.com Wed Apr 4 14:16:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Apr 2007 13:16:50 -0500 Subject: [rspec-users] [rspec-devel] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: <57c63afe0704041116g37b8a562n70a8b1977e3de6dc@mail.gmail.com> On 4/4/07, aslak hellesoy wrote: > We'd like to get some feedback on RSpec 0.9 before we start pushing > out releases via Rubyforge's gem server and update the website. We > have therefore made the first beta of 0.9 available - both prepackaged > and tagged in subversion (see below). > > RSpec 0.9 introduces a new API for expectations, which essentially > means that your underscores go away (there has been other discussions > on the lists about this). In addition to this, you can say describe/it > instead of context/specify. We believe this will lead to even more > readable - and well-written specs. (context/specify will still be > supported for a while). > > == Translator == > In order to ease the transition from 0.8 to 0.9, we have included a > tool to translate your 0.8 style specs to 0.9 style. After installing > the 0.9 gem, you should run: > > spec_translator path_to_my_spec_dir path_to_my_translated_spec_dir > > (or alternatively, if you have your code under version control and can > do a revert if things go wrong:) > > spec_translator path_to_my_spec_dir path_to_my_spec_dir > > (This will translate your specs in-place) > > == Where to get it == > > RSpec core is available here: > > * http://rspec.rubyforge.org/rspec-0.9.0.gem > * http://rspec.rubyforge.org/rspec-0.9.0.tgz > * http://rspec.rubyforge.org/rspec-0.9.0.zip > * http://rspec.rubyforge.org/RSpec-0.9.0.tmbundle.tgz > > == Rails users == > For those of you who want to install 0.9 beta as plugins, the svn URLs are: > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec_on_rails > > (Don't forget to do do a "script generate rspec" to update your local files) Since we haven't updated the website yet you can't see the change log w/o downloading it - here's some of what it has to say: * Sugar FREE! * Fixed [#6523] Run rspec on rails without a db * Fixed [#9295] rake spec should run anything in the spec directory (not just rspec's standard dirs) * Added [#9786] infer controller and helper names from the described type * Fixed [#7795] form_tag renders action='/view_spec' in view specs * Fixed [#9767] rspec_on_rails should not define rescue_action on controllers * Fixed [#9421] --line doesn't work with behaviours that use class names * Fixed [#9760] rspec generators incompatible with changes to edge rails * Added [#9786] infer controller and helper names from the described type * Applied a simplified version of [#9282] Change to allow running specs from textmate with rspec installed as a rails plugin (and no rspec gem installed) * Applied [#9700] Make Spec::DSL::Example#name public / Add a --timeout switch. A great way to prevent specs from getting slow. * In Rails, script/generate rspec will generate a spec.opts file that optimises faster/more efficient running of specs. * Added [#9522] support using rspec's expectations with test/unit * Moved rspec_on_rails up to the project root, simplifying the download url * Fixed [#8103] RSpec not installing spec script correctly. * The --spec option is replaced by the --example option. * The --loadby option no longer supports a file argument. Use --example file_name instead. * The --example option can now take a file name as an argument. The file should contain example names. * New --failures option which will write out a file that can later be used with --example. * Internal classes are named Behaviour/Example (rather than Context/Specification). * You can now use mocha by saying config.mock_with :mocha in a spec_helper * before_context_eval is replaced by before_eval. * Applied [#9509] allow spaced options in spec.opts * Applied [#9510] Added File for Ruby 1.8.6 * Applied [#9511] Clarification to README file in spec/ * Moved all of the Spec::Rails specs down to the plugins directory - now you can run the specs after you install. * Updated RSpec.tmbundle to the 0.9 syntax and replaced context/specify with describe/it. * Applied [#9232] ActionController::Base#render is sometimes protected (patch from Dan Manges) * Added --reverse option, allowing contexts/specs to be run in reverse order. * Added --loadby option, allowing better control over load order for spec files. mtime and file.txt supported. * Implemented [#8696] --order option (see --reverse and --loadby) * Added describe/it as aliases for context/specify - suggestion from Dan North. * Applied [#7637] [PATCH] add skip-migration option to rspec_resource generator * Added [#9167] string.should have_tag * Changed script/rails_spec_server to script/spec_server and added script/spec (w/ path to vendor/plugins/rspec) * Fixed [#8897] Error when mixing controller spec with/without integrated views and using template system other than rhtml * Updated sample app specs to 0.9 syntax * Updated generated specs to 0.9 syntax * Applied [#8994] trunk: generated names for be_ specs (Multiple patches from Yurii Rashkovskii) I've been blogging about some of the new features, and will continue to do so. Aslak and Dave also blog about rspec features from time to time so check their blogs out as well: http://blog.davidchelimsky.net/ http://blog.aslakhellesoy.com/ http://blog.daveastels.com/ Cheers, David > > Cheers, > Aslak > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > From dchelimsky at gmail.com Wed Apr 4 14:34:32 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Apr 2007 13:34:32 -0500 Subject: [rspec-users] moving 0.9 to trunk Message-ID: <57c63afe0704041134j4ab00784ne58a838fcf00efe3@mail.gmail.com> Heads up for those of you who have been using trunk or branches/0.9-dev: I'm going to be moving them around in the next day or so. What is now in trunk will move to branches/0.8-maintenance, and what is now in branches/0.9-dev will move to trunk. I'll email shortly before and after this happens, but I figured I'd give you some advanced warning. David From mailing_lists at railsnewbie.com Wed Apr 4 22:35:44 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 4 Apr 2007 22:35:44 -0400 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: <8d961d900704040044t53daddfrab2ce0d772e96f2b@mail.gmail.com> References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> <8d961d900704031305m7f846a9dnc2d8b3b430d24541@mail.gmail.com> <8d961d900704040044t53daddfrab2ce0d772e96f2b@mail.gmail.com> Message-ID: <00366452-521F-49AF-BBF5-CD4CD53F3947@railsnewbie.com> Actually there were are a few span tags in there. I've reworked the system so that this is no longer a problem. The only thing left to do is figure out why the links to static pages in metainfo.yaml aren't working. Here are their definitions: documentation/report.html: title: RSpec Report url: ../report.html inMenu: true orderInfo: 55 documentation/rdoc.html: title: RDoc url: ../rdoc/index.html inMenu: true orderInfo: 60 documentation/rcov.html: title: RCov url: ../coverage/index.html inMenu: true orderInfo: 70 documentation/rails/rdoc.html: title: RDoc url: ../../rdoc-rails/index.html inMenu: true orderInfo: 130 Any ideas? Are these created by a rake task? Scott On Apr 4, 2007, at 3:44 AM, aslak hellesoy wrote: > On 4/4/07, Scott Taylor wrote: >>> >>> Actually, having one single meta.info file at the top would be >>> great! >>> I'm planning to add a Javascript-backed menu to the site to make it >>> more navigable, and this would be a great starting point. >>> >>> Aslak >>> >>>> So, pretty close. I should be done with it by tomorrow, if >>>> everything goes well, or by the end of the week if one employs a >>>> conservative measure. >> >> >> Actually the file is now called metainfo.yaml, just for your >> information. >> >> Is there any other non-textile content in any of the src files for >> webgen? All I've seen so far is , , and >> >> >> ....Anything else that isn't textile? >> > > Not that I know of. > >> 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 dchelimsky at gmail.com Wed Apr 4 22:46:53 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Apr 2007 21:46:53 -0500 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: <00366452-521F-49AF-BBF5-CD4CD53F3947@railsnewbie.com> References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> <8d961d900704031305m7f846a9dnc2d8b3b430d24541@mail.gmail.com> <8d961d900704040044t53daddfrab2ce0d772e96f2b@mail.gmail.com> <00366452-521F-49AF-BBF5-CD4CD53F3947@railsnewbie.com> Message-ID: <57c63afe0704041946x2718f3b0r2fe12babea7b3d8@mail.gmail.com> On 4/4/07, Scott Taylor wrote: > > Actually there were are a few span tags in there. I've reworked the > system so that this is no longer a problem. > > The only thing left to do is figure out why the links to static pages > in metainfo.yaml aren't working. Here are their definitions: > > documentation/report.html: > title: RSpec Report > url: ../report.html > inMenu: true > orderInfo: 55 > > documentation/rdoc.html: > title: RDoc > url: ../rdoc/index.html > inMenu: true > orderInfo: 60 > > documentation/rcov.html: > title: RCov > url: ../coverage/index.html > inMenu: true > orderInfo: 70 > > documentation/rails/rdoc.html: > title: RDoc > url: ../../rdoc-rails/index.html > inMenu: true > orderInfo: 130 > > > Any ideas? Are these created by a rake task? Yes. If that's all that's left go ahead and submit the patch and I'll resolve any links that aren't working. Thanks. > > Scott > > > > > On Apr 4, 2007, at 3:44 AM, aslak hellesoy wrote: > > > On 4/4/07, Scott Taylor wrote: > >>> > >>> Actually, having one single meta.info file at the top would be > >>> great! > >>> I'm planning to add a Javascript-backed menu to the site to make it > >>> more navigable, and this would be a great starting point. > >>> > >>> Aslak > >>> > >>>> So, pretty close. I should be done with it by tomorrow, if > >>>> everything goes well, or by the end of the week if one employs a > >>>> conservative measure. > >> > >> > >> Actually the file is now called metainfo.yaml, just for your > >> information. > >> > >> Is there any other non-textile content in any of the src files for > >> webgen? All I've seen so far is , , and > >> > >> > >> ....Anything else that isn't textile? > >> > > > > Not that I know of. > > > >> 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 mailing_lists at railsnewbie.com Wed Apr 4 23:45:32 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 4 Apr 2007 23:45:32 -0400 Subject: [rspec-users] Fwd: --color doesn't work with --drb w/rspec_autotest In-Reply-To: <57c63afe0704041946x2718f3b0r2fe12babea7b3d8@mail.gmail.com> References: <57c63afe0704010803g3e3e5ce3i5e89fcd06fc4653c@mail.gmail.com> <57c63afe0704030603w22e405e5n443e676cf8d833a4@mail.gmail.com> <446D6DE0-0AA3-446D-93B7-2BFC020DF457@railsnewbie.com> <8d961d900704031305m7f846a9dnc2d8b3b430d24541@mail.gmail.com> <8d961d900704040044t53daddfrab2ce0d772e96f2b@mail.gmail.com> <00366452-521F-49AF-BBF5-CD4CD53F3947@railsnewbie.com> <57c63afe0704041946x2718f3b0r2fe12babea7b3d8@mail.gmail.com> Message-ID: <8EA0099C-AF25-4272-887A-E1700156AB24@railsnewbie.com> I've patched against the 0.8 trunk and am going to submit it through the tracker. Scott On Apr 4, 2007, at 10:46 PM, David Chelimsky wrote: > On 4/4/07, Scott Taylor wrote: >> >> Actually there were are a few span tags in there. I've reworked the >> system so that this is no longer a problem. >> >> The only thing left to do is figure out why the links to static pages >> in metainfo.yaml aren't working. Here are their definitions: >> >> documentation/report.html: >> title: RSpec Report >> url: ../report.html >> inMenu: true >> orderInfo: 55 >> >> documentation/rdoc.html: >> title: RDoc >> url: ../rdoc/index.html >> inMenu: true >> orderInfo: 60 >> >> documentation/rcov.html: >> title: RCov >> url: ../coverage/index.html >> inMenu: true >> orderInfo: 70 >> >> documentation/rails/rdoc.html: >> title: RDoc >> url: ../../rdoc-rails/index.html >> inMenu: true >> orderInfo: 130 >> >> >> Any ideas? Are these created by a rake task? > > Yes. If that's all that's left go ahead and submit the patch and I'll > resolve any links that aren't working. > > Thanks. > >> >> Scott >> >> >> >> >> On Apr 4, 2007, at 3:44 AM, aslak hellesoy wrote: >> >>> On 4/4/07, Scott Taylor wrote: >>>>> >>>>> Actually, having one single meta.info file at the top would be >>>>> great! >>>>> I'm planning to add a Javascript-backed menu to the site to >>>>> make it >>>>> more navigable, and this would be a great starting point. >>>>> >>>>> Aslak >>>>> >>>>>> So, pretty close. I should be done with it by tomorrow, if >>>>>> everything goes well, or by the end of the week if one employs a >>>>>> conservative measure. >>>> >>>> >>>> Actually the file is now called metainfo.yaml, just for your >>>> information. >>>> >>>> Is there any other non-textile content in any of the src files for >>>> webgen? All I've seen so far is , >>> >, and >>>> >>>> >>>> ....Anything else that isn't textile? >>>> >>> >>> Not that I know of. >>> >>>> 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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From bosshoff at gmail.com Thu Apr 5 08:55:53 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Thu, 5 Apr 2007 08:55:53 -0400 Subject: [rspec-users] Extending assigns in controller specs? Message-ID: <359ebde50704050555h7b719d05jc8569bfe2e1027e8@mail.gmail.com> Hello, I am interested in enhancing assigns in controller specs to do things like the following assigns[:key1, :key2, :key3] #=> vals for keys Is there away to "break open" this construction to overload the :[] operator? Thanks. -Chris From win at wincent.com Thu Apr 5 11:34:13 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 5 Apr 2007 17:34:13 +0200 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: El 4/4/2007, a las 18:33, aslak hellesoy escribi?: > RSpec 0.9 introduces a new API for expectations, which essentially > means that your underscores go away Can you please give an example of what this looks like? I've looked at the various "dot vs underscore" discussions on the lists so I'm interested to see what the new style is. Cheers, Wincent From roberto at techmobil.com.br Thu Apr 5 12:56:37 2007 From: roberto at techmobil.com.br (Roberto Soares) Date: Thu, 5 Apr 2007 13:56:37 -0300 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: from: rspec/examples/stack_spec.rb require File.dirname(__FILE__) + '/spec_helper' require File.dirname(__FILE__) + "/stack" describe Stack do setup do @stack = Stack.new ["a","b","c"].each { |x| @stack.push x } end it "should add to the top when sent #push" do @stack.push "d" @stack.peek.should == "d" end it "should return the top item when sent #peek" do @stack.peek.should == "c" end it "should NOT remove the top item when sent #peek" do @stack.peek.should == "c" @stack.peek.should == "c" end it "should return the top item when sent #pop" do @stack.pop.should == "c" end it "should remove the top item when sent #pop" do @stack.pop.should == "c" @stack.pop.should == "b" end end describe Stack, " (empty)" do setup do @stack = Stack.new end # NOTE that this one auto-generates the description "should be empty" specify { @stack.should be_empty } it "should no longer be empty after #push" do @stack.push "anything" @stack.should_not be_empty end it "should complain when sent #peek" do lambda { @stack.peek }.should raise_error(StackUnderflowError) end it "should complain when sent #pop" do lambda { @stack.pop }.should raise_error(StackUnderflowError) end end describe Stack, " (with one item)" do setup do @stack = Stack.new @stack.push 3 end # NOTE that this one auto-generates the description "should not be empty" specify { @stack.should_not be_empty } it "should remain not empty after #peek" do @stack.peek @stack.should_not be_empty end it "should become empty after #pop" do @stack.pop @stack.should be_empty end end describe Stack, " (with one item less than capacity)" do setup do @stack = Stack.new (1..9).each { |i| @stack.push i } end # NOTE that this one auto-generates the description "should not be full" specify { @stack.should_not be_full } it "should become full after #push" do @stack.push Object.new @stack.should be_full end end describe Stack, " (full)" do setup do @stack = Stack.new (1..10).each { |i| @stack.push i } end # NOTE that this one auto-generates the description "should be full" it { @stack.should be_full } it "should remain full after #peek" do @stack.peek @stack.should be_full end it "should no longer be full after #pop" do @stack.pop @stack.should_not be_full end it "should complain on #push" do lambda { @stack.push Object.new }.should raise_error(StackOverflowError) end end On 4/5/07, Wincent Colaiuta wrote: > > El 4/4/2007, a las 18:33, aslak hellesoy escribi?: > > > RSpec 0.9 introduces a new API for expectations, which essentially > > means that your underscores go away > > Can you please give an example of what this looks like? I've looked > at the various "dot vs underscore" discussions on the lists so I'm > interested to see what the new style is. > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Roberto Soares Diretor de P&D da Techmobil http://roberto.techmobil.com.br 73 8105-4337 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070405/e7eb20c5/attachment-0001.html From dchelimsky at gmail.com Thu Apr 5 13:01:11 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Apr 2007 17:01:11 +0000 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: <57c63afe0704051001p1637cf76n2b42c08b5b87b61b@mail.gmail.com> On 4/5/07, Wincent Colaiuta wrote: > El 4/4/2007, a las 18:33, aslak hellesoy escribi?: > > > RSpec 0.9 introduces a new API for expectations, which essentially > > means that your underscores go away > > Can you please give an example of what this looks like? I've looked > at the various "dot vs underscore" discussions on the lists so I'm > interested to see what the new style is. Instead of this: actual.should_equal(expected) team.should_have(3).players 5.should_be < 7 you say this: actual.should equal(expected) team.should have(3).players 5.should be < 7 > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Thu Apr 5 14:09:16 2007 From: win at wincent.com (Wincent Colaiuta) Date: Thu, 5 Apr 2007 20:09:16 +0200 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: <131A95F6-4146-4BEE-962A-0B4C2DB1737A@wincent.com> El 4/4/2007, a las 18:33, aslak hellesoy escribi?: > In order to ease the transition from 0.8 to 0.9, we have included a > tool to translate your 0.8 style specs to 0.9 style. The included translator did a pretty good job on a fairly large project ("svn diff" on the working copy after the translation yielded over 3,000 lines of diffs) with only a few minor issues for which I'll paste in samples. (Tried to post this to the RubyForge issue tracker but I can't stay logged in long enough to open the ticket because of an invisible anonymous proxy in place thanks to my ISP...) Whitespace between specs and comments eaten: - lambda { @instance.foo = foo }.should_raise NoMethodError # no writer defined + lambda { @instance.foo = foo }.should raise_error (NoMethodError)# no writer defined Incorrect parentheses around method invocations with parameters: - AndPredicate.new('foo').should_eql AndPredicate.new('foo') + AndPredicate.new('foo').should eql(AndPredicate.new)('foo') Unnecessary parens: - Node.subclass('FooNode').should_not_be_nil + Node.subclass('FooNode').should_not be_nil() Missing parentheses, yields "parenthesize argument(s) for future version" warnings when running specs: - lambda { sequence.parse ('bar') }.should_throw :ZeroWidthParseSuccess + lambda { sequence.parse('bar') }.should throw_symbol :ZeroWidthParseSuccess Another example: - @parslet.should_eql @parslet.clone + @parslet.should eql @parslet.clone Another case of misplaced parens: - @parslet.should_not_eql lambda { nil }.to_parseable + @parslet.should_not eql(lambda){ nil }.to_parseable Another: - results.should_be_kind_of SimpleASTLanguage::Identifier + results.should be_kind_of(SimpleASTLanguage)::Identifier Apart from that, no major issues. All specs continued to pass after 0.90, and the updated TextMate bundle works brilliantly. Cheers, Wincent From dchelimsky at gmail.com Thu Apr 5 14:45:06 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Apr 2007 18:45:06 +0000 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <131A95F6-4146-4BEE-962A-0B4C2DB1737A@wincent.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> <131A95F6-4146-4BEE-962A-0B4C2DB1737A@wincent.com> Message-ID: <57c63afe0704051145o57e692e3pc6759fc09ba0480d@mail.gmail.com> On 4/5/07, Wincent Colaiuta wrote: > El 4/4/2007, a las 18:33, aslak hellesoy escribi?: > > > In order to ease the transition from 0.8 to 0.9, we have included a > > tool to translate your 0.8 style specs to 0.9 style. > > The included translator did a pretty good job on a fairly large > project ("svn diff" on the working copy after the translation yielded > over 3,000 lines of diffs) with only a few minor issues for which > I'll paste in samples. (Tried to post this to the RubyForge issue > tracker but I can't stay logged in long enough to open the ticket > because of an invisible anonymous proxy in place thanks to my ISP...) > > > Whitespace between specs and comments eaten: > > - lambda { @instance.foo = foo }.should_raise NoMethodError # no > writer defined > + lambda { @instance.foo = foo }.should raise_error > (NoMethodError)# no writer defined > > > Incorrect parentheses around method invocations with parameters: > > - AndPredicate.new('foo').should_eql AndPredicate.new('foo') > + AndPredicate.new('foo').should eql(AndPredicate.new)('foo') > > > Unnecessary parens: > > - Node.subclass('FooNode').should_not_be_nil > + Node.subclass('FooNode').should_not be_nil() > > > Missing parentheses, yields "parenthesize argument(s) for future > version" warnings when running specs: > > - lambda { sequence.parse > ('bar') }.should_throw :ZeroWidthParseSuccess > + lambda { sequence.parse('bar') }.should > throw_symbol :ZeroWidthParseSuccess > > > Another example: > > - @parslet.should_eql @parslet.clone > + @parslet.should eql @parslet.clone > > > Another case of misplaced parens: > > - @parslet.should_not_eql lambda { nil }.to_parseable > + @parslet.should_not eql(lambda){ nil }.to_parseable > > > Another: > > - results.should_be_kind_of SimpleASTLanguage::Identifier > + results.should be_kind_of(SimpleASTLanguage)::Identifier > > > Apart from that, no major issues. All specs continued to pass after > 0.90, and the updated TextMate bundle works brilliantly. > > Cheers, > Wincent Great feedback - thank you Wincent. I've added this to the tracker: http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149 Cheers, David > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Thu Apr 5 15:10:57 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 5 Apr 2007 15:10:57 -0400 Subject: [rspec-users] Extending assigns in controller specs? In-Reply-To: <359ebde50704050555h7b719d05jc8569bfe2e1027e8@mail.gmail.com> References: <359ebde50704050555h7b719d05jc8569bfe2e1027e8@mail.gmail.com> Message-ID: One method would be to: 1. figure out the class 2. reopen the class, 3. alias the method, 4. use your method if multiple keys are given, use the old aliased method if not. Don't know if assigns might have some metaclass trickery, though. Post what you find. I'd be interested. As for spec'ing it out, first: require File.dirname(__FILE__) + "/..." class MyController < ActionController def single_var @var = "var" end def multi_var @var1 = 1 @var2 = 2 end end describe "MyController's single_var" do controller_name :my_controller setup do get :single_var end it "should assign one variable" do assign[:var].should == "var" end end describe "MyController's multi_var" do ... it "should assign multi variables" do assign[:var1, :var2].should == [1, 2] end end Obviously you can use more descriptive names than I have here. But I hope you can see where I'm going with this. Scott On Apr 5, 2007, at 8:55 AM, Chris Hoffman wrote: > Hello, > I am interested in enhancing assigns in controller specs to do > things like the following > > assigns[:key1, :key2, :key3] #=> vals for keys > > Is there away to "break open" this construction to overload the :[] > operator? > > Thanks. > > -Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Apr 5 15:41:21 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Apr 2007 19:41:21 +0000 Subject: [rspec-users] Extending assigns in controller specs? In-Reply-To: References: <359ebde50704050555h7b719d05jc8569bfe2e1027e8@mail.gmail.com> Message-ID: <57c63afe0704051241l558e4f86q30c80580ed6d9273@mail.gmail.com> On 4/5/07, Scott Taylor wrote: > > One method would be to: > > 1. figure out the class > 2. reopen the class, > 3. alias the method, > 4. use your method if multiple keys are given, use the old aliased > method if not. > > Don't know if assigns might have some metaclass trickery, though. > Post what you find. I'd be interested. > > As for spec'ing it out, first: > > require File.dirname(__FILE__) + "/..." > > class MyController < ActionController > def single_var > @var = "var" > end > > def multi_var > @var1 = 1 > @var2 = 2 > end > end > > describe "MyController's single_var" do > controller_name :my_controller > > setup do > get :single_var > end > > it "should assign one variable" do > assign[:var].should == "var" > end > end > > describe "MyController's multi_var" do > > ... > > it "should assign multi variables" do > assign[:var1, :var2].should == [1, 2] > end > end assigns is available before and after the action so you don't really need an action to spec this: it "should assign a single var" do assigns[:a] = 'b' assigns[:a].should == 'b' end it "should assign multiple vars" do assigns[:a, :b] = 'c', 'd' assigns[:a].should == 'c' assigns[:b].should == 'd' end The class is IvarProxy, which is actually left over from ZenTest, which an earlier version of Spec::Rails wrapped. Cheers, David > > > Obviously you can use more descriptive names than I have here. But I > hope you can see where I'm going with this. > > Scott > > > On Apr 5, 2007, at 8:55 AM, Chris Hoffman wrote: > > > Hello, > > I am interested in enhancing assigns in controller specs to do > > things like the following > > > > assigns[:key1, :key2, :key3] #=> vals for keys > > > > Is there away to "break open" this construction to overload the :[] > > operator? > > > > 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 Thu Apr 5 20:40:44 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Apr 2007 19:40:44 -0500 Subject: [rspec-users] moving 0.9 to trunk Message-ID: <57c63afe0704051740o46ae174bib303be3851db698a@mail.gmail.com> Trunksters: I'm in the process of moving 0.9 to trunk so things might be a bit weird for a few minutes if you're updating. I'll email when I'm done. David From dchelimsky at gmail.com Thu Apr 5 21:17:44 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Apr 2007 20:17:44 -0500 Subject: [rspec-users] trunk is now ... trunk Message-ID: <57c63afe0704051817w2f1f61eco5888527a9b371536@mail.gmail.com> All, If you're following 0.9 development, it has been moved to the trunk. What was in the trunk was 0.8 maintenance, which has been moved to branches/0.8-maintenance. We had originally planned an 0.8.3 release, but have decided to just press forward with 0.9, hence the beta release yesterday. Cheers, David From mtrier at eminentconsultinggroup.com Thu Apr 5 21:30:06 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Thu, 5 Apr 2007 21:30:06 -0400 Subject: [rspec-users] Mocking Authentication Message-ID: Is anyone using Restful Authentication? If so, how are you mocking the login for your controllers? I'm having trouble with it and would love an example of someone's login. I'm sure I'm missing something simple. Michael railsconsulting.com From graeme.nelson at gmail.com Thu Apr 5 23:07:05 2007 From: graeme.nelson at gmail.com (Graeme Nelson) Date: Thu, 5 Apr 2007 20:07:05 -0700 Subject: [rspec-users] Mocking Authentication In-Reply-To: References: Message-ID: <616887F6-97F2-49E6-ABB5-844EBA126236@gmail.com> Hi Michael - I tried to reply from my work email and it bounced. oops. This is what I am doing on a current project: def mock_user_authentication(allow_user_to_pass=true) controller.stub!(:login_required).and_return(allow_user_to_pass) end You get the controller object with your controller specs. I am sure there are other ways of doing this, but I found this to be pretty clean. Thanks Graeme Nelson On Apr 5, 2007, at 6:30 PM, Michael Trier wrote: > Is anyone using Restful Authentication? If so, how are you mocking > the login for your controllers? I'm having trouble with it and would > love an example of someone's login. I'm sure I'm missing something > simple. > > Michael > railsconsulting.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mtrier at eminentconsultinggroup.com Thu Apr 5 23:26:18 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Thu, 5 Apr 2007 23:26:18 -0400 Subject: [rspec-users] Mocking Authentication In-Reply-To: <616887F6-97F2-49E6-ABB5-844EBA126236@gmail.com> References: <616887F6-97F2-49E6-ABB5-844EBA126236@gmail.com> Message-ID: Thanks so much. Funny that you responded because I saw your post about testing controllers and your mention of mock_user_authentication, but no implementation for it when I did a search. I tried to contact you but couldn't find a contact address. Anyway, thanks so much. I'll give that a shot. Michael On Apr 5, 2007, at 11:07 PM, Graeme Nelson wrote: > Hi Michael - > > I tried to reply from my work email and it bounced. oops. > > This is what I am doing on a current project: > > def mock_user_authentication(allow_user_to_pass=true) > controller.stub!(:login_required).and_return(allow_user_to_pass) > end > > You get the controller object with your controller specs. > > I am sure there are other ways of doing this, but I found this to be > pretty clean. > > Thanks > Graeme Nelson > > On Apr 5, 2007, at 6:30 PM, Michael Trier wrote: > >> Is anyone using Restful Authentication? If so, how are you mocking >> the login for your controllers? I'm having trouble with it and would >> love an example of someone's login. I'm sure I'm missing something >> simple. >> >> Michael >> railsconsulting.com >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From bosshoff at gmail.com Fri Apr 6 08:21:17 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Fri, 6 Apr 2007 08:21:17 -0400 Subject: [rspec-users] Extending assigns in controller specs? In-Reply-To: <57c63afe0704051241l558e4f86q30c80580ed6d9273@mail.gmail.com> References: <359ebde50704050555h7b719d05jc8569bfe2e1027e8@mail.gmail.com> <57c63afe0704051241l558e4f86q30c80580ed6d9273@mail.gmail.com> Message-ID: <359ebde50704060521s5655a9dfmc046210380ce3028@mail.gmail.com> That's just the information for which I was looking. Thanks to both of you. On 4/5/07, David Chelimsky wrote: > On 4/5/07, Scott Taylor wrote: > > > > One method would be to: > > > > 1. figure out the class > > 2. reopen the class, > > 3. alias the method, > > 4. use your method if multiple keys are given, use the old aliased > > method if not. > > > > Don't know if assigns might have some metaclass trickery, though. > > Post what you find. I'd be interested. > > > > As for spec'ing it out, first: > > > > require File.dirname(__FILE__) + "/..." > > > > class MyController < ActionController > > def single_var > > @var = "var" > > end > > > > def multi_var > > @var1 = 1 > > @var2 = 2 > > end > > end > > > > describe "MyController's single_var" do > > controller_name :my_controller > > > > setup do > > get :single_var > > end > > > > it "should assign one variable" do > > assign[:var].should == "var" > > end > > end > > > > describe "MyController's multi_var" do > > > > ... > > > > it "should assign multi variables" do > > assign[:var1, :var2].should == [1, 2] > > end > > end > > assigns is available before and after the action so you don't really > need an action to spec this: > > it "should assign a single var" do > assigns[:a] = 'b' > assigns[:a].should == 'b' > end > > it "should assign multiple vars" do > assigns[:a, :b] = 'c', 'd' > assigns[:a].should == 'c' > assigns[:b].should == 'd' > end > > The class is IvarProxy, which is actually left over from ZenTest, > which an earlier version of Spec::Rails wrapped. > > Cheers, > David > > > > > > > Obviously you can use more descriptive names than I have here. But I > > hope you can see where I'm going with this. > > > > Scott > > > > > > On Apr 5, 2007, at 8:55 AM, Chris Hoffman wrote: > > > > > Hello, > > > I am interested in enhancing assigns in controller specs to do > > > things like the following > > > > > > assigns[:key1, :key2, :key3] #=> vals for keys > > > > > > Is there away to "break open" this construction to overload the :[] > > > operator? > > > > > > 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 cwdinfo at gmail.com Fri Apr 6 16:04:10 2007 From: cwdinfo at gmail.com (s.ross) Date: Fri, 6 Apr 2007 13:04:10 -0700 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: spec_translator does a good job with recent specs, but ones written in the more sugary days still require a bit more editing. E.g., foo.should.be.valid Not translated as: foo.should be_valid and foo.should.not.be.valid Not translated as: foo.should_not be_valid Also, changes to semantics of "be" make: foo.should be(true) fail, where: foo.should ==(true) succeeds. Some of this may be bad practice on my part. WDYT? On Apr 4, 2007, at 9:33 AM, aslak hellesoy wrote: > We'd like to get some feedback on RSpec 0.9 before we start pushing > out releases via Rubyforge's gem server and update the website. We > have therefore made the first beta of 0.9 available - both prepackaged > and tagged in subversion (see below). > > RSpec 0.9 introduces a new API for expectations, which essentially > means that your underscores go away (there has been other discussions > on the lists about this). In addition to this, you can say describe/it > instead of context/specify. We believe this will lead to even more > readable - and well-written specs. (context/specify will still be > supported for a while). > > == Translator == > In order to ease the transition from 0.8 to 0.9, we have included a > tool to translate your 0.8 style specs to 0.9 style. After installing > the 0.9 gem, you should run: > > spec_translator path_to_my_spec_dir path_to_my_translated_spec_dir > > (or alternatively, if you have your code under version control and can > do a revert if things go wrong:) > > spec_translator path_to_my_spec_dir path_to_my_spec_dir > > (This will translate your specs in-place) > > == Where to get it == > > RSpec core is available here: > > * http://rspec.rubyforge.org/rspec-0.9.0.gem > * http://rspec.rubyforge.org/rspec-0.9.0.tgz > * http://rspec.rubyforge.org/rspec-0.9.0.zip > * http://rspec.rubyforge.org/RSpec-0.9.0.tmbundle.tgz > > == Rails users == > For those of you who want to install 0.9 beta as plugins, the svn > URLs are: > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/ > rspec_on_rails > > (Don't forget to do do a "script generate rspec" to update your > local files) > > Cheers, > Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Thu Apr 5 17:31:26 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 5 Apr 2007 17:31:26 -0400 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: <6EAADF38-E6FC-49C3-A74F-74FE84A3EBC3@railsnewbie.com> When are you going to convert trunk to 0.9? Do you more-or-less have a time frame? (I understand these things are set in stone). In the mean time, should I be patching against trunk, or is there a convenient way to patch against 0.9 right now? Best, Scott On Apr 4, 2007, at 12:33 PM, aslak hellesoy wrote: > We'd like to get some feedback on RSpec 0.9 before we start pushing > out releases via Rubyforge's gem server and update the website. We > have therefore made the first beta of 0.9 available - both prepackaged > and tagged in subversion (see below). > > RSpec 0.9 introduces a new API for expectations, which essentially > means that your underscores go away (there has been other discussions > on the lists about this). In addition to this, you can say describe/it > instead of context/specify. We believe this will lead to even more > readable - and well-written specs. (context/specify will still be > supported for a while). > > == Translator == > In order to ease the transition from 0.8 to 0.9, we have included a > tool to translate your 0.8 style specs to 0.9 style. After installing > the 0.9 gem, you should run: > > spec_translator path_to_my_spec_dir path_to_my_translated_spec_dir > > (or alternatively, if you have your code under version control and can > do a revert if things go wrong:) > > spec_translator path_to_my_spec_dir path_to_my_spec_dir > > (This will translate your specs in-place) > > == Where to get it == > > RSpec core is available here: > > * http://rspec.rubyforge.org/rspec-0.9.0.gem > * http://rspec.rubyforge.org/rspec-0.9.0.tgz > * http://rspec.rubyforge.org/rspec-0.9.0.zip > * http://rspec.rubyforge.org/RSpec-0.9.0.tmbundle.tgz > > == Rails users == > For those of you who want to install 0.9 beta as plugins, the svn > URLs are: > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/ > rspec_on_rails > > (Don't forget to do do a "script generate rspec" to update your > local files) > > Cheers, > Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Apr 6 17:56:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 6 Apr 2007 16:56:00 -0500 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: <6EAADF38-E6FC-49C3-A74F-74FE84A3EBC3@railsnewbie.com> References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> <6EAADF38-E6FC-49C3-A74F-74FE84A3EBC3@railsnewbie.com> Message-ID: <57c63afe0704061456i4f79a7c8l22b800883f8bcbcc@mail.gmail.com> On 4/5/07, Scott Taylor wrote: > > When are you going to convert trunk to 0.9? Do you more-or-less have > a time frame? (I understand these things are set in stone). > > In the mean time, should I be patching against trunk, or is there a > convenient way to patch against 0.9 right now? > > Best, > > Scott I emailed about this a couple of times yesterday. The trunk is NOW 0.9, so you should be patching the trunk. Thanks, David > > > > On Apr 4, 2007, at 12:33 PM, aslak hellesoy wrote: > > > We'd like to get some feedback on RSpec 0.9 before we start pushing > > out releases via Rubyforge's gem server and update the website. We > > have therefore made the first beta of 0.9 available - both prepackaged > > and tagged in subversion (see below). > > > > RSpec 0.9 introduces a new API for expectations, which essentially > > means that your underscores go away (there has been other discussions > > on the lists about this). In addition to this, you can say describe/it > > instead of context/specify. We believe this will lead to even more > > readable - and well-written specs. (context/specify will still be > > supported for a while). > > > > == Translator == > > In order to ease the transition from 0.8 to 0.9, we have included a > > tool to translate your 0.8 style specs to 0.9 style. After installing > > the 0.9 gem, you should run: > > > > spec_translator path_to_my_spec_dir path_to_my_translated_spec_dir > > > > (or alternatively, if you have your code under version control and can > > do a revert if things go wrong:) > > > > spec_translator path_to_my_spec_dir path_to_my_spec_dir > > > > (This will translate your specs in-place) > > > > == Where to get it == > > > > RSpec core is available here: > > > > * http://rspec.rubyforge.org/rspec-0.9.0.gem > > * http://rspec.rubyforge.org/rspec-0.9.0.tgz > > * http://rspec.rubyforge.org/rspec-0.9.0.zip > > * http://rspec.rubyforge.org/RSpec-0.9.0.tmbundle.tgz > > > > == Rails users == > > For those of you who want to install 0.9 beta as plugins, the svn > > URLs are: > > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/rspec > > * svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_1/ > > rspec_on_rails > > > > (Don't forget to do do a "script generate rspec" to update your > > local files) > > > > Cheers, > > 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 Fri Apr 6 18:07:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 6 Apr 2007 17:07:55 -0500 Subject: [rspec-users] ANN: RSpec 0.9.0 beta-1 available for download. In-Reply-To: References: <8d961d900704040933i6917b8dey25be2d1f4372a42b@mail.gmail.com> Message-ID: <57c63afe0704061507yc6f81f4o12bf83b9aa872400@mail.gmail.com> On 4/6/07, s.ross wrote: > spec_translator does a good job with recent specs, but ones written > in the more sugary days still require a bit more editing. E.g., > > foo.should.be.valid > > Not translated as: > > foo.should be_valid > > and > > foo.should.not.be.valid > > Not translated as: > > foo.should_not be_valid Sugar == underscores instead of dots, so that's actually pre-sugar. We officially ended support for dots way back on 8/9/2006 when we released RSpec 0.6.0. If that syntax is still working with 0.8 it is not intentional. There is no plan to support this w/ the translator. > > Also, changes to semantics of "be" make: > > foo.should be(true) > > fail, where: > > foo.should ==(true) > > succeeds. The translator should convert this: foo.should be(true) to this: foo.should equal(true) If it's not doing that it's definitely a bug, in which case please report it to the tracker. FYI - In 0.9 you can write either equal(true) or be_true, but the translator uses the former. Thanks, David From jed.hurt at gmail.com Fri Apr 6 22:27:43 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Fri, 6 Apr 2007 20:27:43 -0600 Subject: [rspec-users] Integration Specs On Rails Message-ID: Now that RSpec is nearing 1 dot oh, are there any plans to implement an integration testing equivalent in RSpec On Rails? From dchelimsky at gmail.com Sat Apr 7 00:34:31 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 6 Apr 2007 23:34:31 -0500 Subject: [rspec-users] Integration Specs On Rails In-Reply-To: References: Message-ID: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> On 4/6/07, Jed Hurt wrote: > Now that RSpec is nearing 1 dot oh It is? >, are there any plans to implement > an integration testing equivalent in RSpec On Rails? There's an open RFE for this http://rubyforge.org/tracker/index.php?func=detail&aid=9381&group_id=797&atid=3152. Just a matter of priority. If somebody wants to take a stab at a patch, that might move it up. David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bryan at brynary.com Sun Apr 8 01:35:29 2007 From: bryan at brynary.com (Bryan Helmkamp) Date: Sun, 8 Apr 2007 01:35:29 -0400 Subject: [rspec-users] Integration Specs On Rails In-Reply-To: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> References: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> Message-ID: On 4/7/07, David Chelimsky wrote: > There's an open RFE for this > http://rubyforge.org/tracker/index.php?func=detail&aid=9381&group_id=797&atid=3152. > Just a matter of priority. If somebody wants to take a stab at a > patch, that might move it up. I guess it's worth asking if what we are talking about should be termed "integration" specs or "acceptance" specs. In my current RSpec project, we use a spec/integration directory for specs that cover specific clusters of objects, often with DB access, but still not at a high level the customer could understand. We reserve spec/models, spec/controllers, and spec/views for specifying behavior for those pieces in isolation, with as few DB hits as possible. A significant issue I see is that Rails' integration specs are not at as high of a level as I think they should be. I'd like to write something like: visit PageA should click_link("Next page") should be_on(PageB) I'm (very slowly) working on a library to support this kind of syntax in Rails integration specs, but it would be even better to do this with RSpec. -- Bryan Helmkmap http://brynary.com -- My blog From brynarylists at gmail.com Sun Apr 8 01:27:06 2007 From: brynarylists at gmail.com (Bryan Helmkamp) Date: Sun, 8 Apr 2007 01:27:06 -0400 Subject: [rspec-users] Integration Specs On Rails In-Reply-To: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> References: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> Message-ID: On 4/7/07, David Chelimsky wrote: > On 4/6/07, Jed Hurt wrote: > > Now that RSpec is nearing 1 dot oh > > It is? Only if there's no possiblity of 0.10, 0.11, etc. -- Bryan Helmkmap http://brynary.com -- My blog From graeme.nelson at planetargon.com Thu Apr 5 22:07:01 2007 From: graeme.nelson at planetargon.com (Graeme Nelson) Date: Thu, 5 Apr 2007 19:07:01 -0700 Subject: [rspec-users] Mocking Authentication In-Reply-To: References: Message-ID: <9A0C67F9-D9F1-49D4-A89F-B32ED38AFFAE@planetargon.com> Hi Michael - Here is how I am doing it on a current project. def mock_user_authentication(allow_user_to_pass=true) controller.stub!(:login_required).and_return(allow_user_to_pass) end The controller is available in your controller specs. Thanks Graeme Nelson On Apr 5, 2007, at 6:30 PM, Michael Trier wrote: > Is anyone using Restful Authentication? If so, how are you mocking > the login for your controllers? I'm having trouble with it and would > love an example of someone's login. I'm sure I'm missing something > simple. > > Michael > railsconsulting.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Graeme Nelson Developer PLANET ARGON, LLC Ruby on Rails Development, Consulting & Hosting www.planetargon.com +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax] -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070405/3dc5c751/attachment-0001.html From dchelimsky at gmail.com Sun Apr 8 14:55:22 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Apr 2007 13:55:22 -0500 Subject: [rspec-users] Integration Specs On Rails In-Reply-To: References: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> Message-ID: <57c63afe0704081155o2a069b27g35bdfa61d609aa37@mail.gmail.com> On 4/8/07, Bryan Helmkamp wrote: > On 4/7/07, David Chelimsky wrote: > > On 4/6/07, Jed Hurt wrote: > > > Now that RSpec is nearing 1 dot oh > > > > It is? > > Only if there's no possiblity of 0.10, 0.11, etc. There is very definitely the possibility of 0.10, 0.11, etc. We'd like to get to 1.0, but not prematurely. While I don't anticipate any backwards-compatibility breaking changes (like going from underscores to spaces), there are still some DSL ideas floating around that need to be explored and proven out before we commit to a 1.0. "describe/it" for example, which I like better, and some others do as well, does not prevent us from supporting "context/specify". > > -- > Bryan Helmkmap > http://brynary.com -- My blog > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From julien.palmas at gmail.com Sun Apr 8 18:28:02 2007 From: julien.palmas at gmail.com (Julien Palmas) Date: Mon, 9 Apr 2007 00:28:02 +0200 Subject: [rspec-users] typos in a tutorial page Message-ID: This page has some typos in the forth grey box http://rspec.rubyforge.org/tutorials/stack_04.html "should_equal" should be "should ==" and "should_not_be_empty" should be "should_not be_empty" this causes some spec to fail By the way, this is my first mail to the list, so Hi everybody !! From mailing_lists at railsnewbie.com Sun Apr 8 18:49:57 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 8 Apr 2007 18:49:57 -0400 Subject: [rspec-users] rcov with rspec & rails Message-ID: Is there an easy way to use rcov to show my code coverage with RSpec in a rails project? Scott From mailing_lists at railsnewbie.com Sun Apr 8 18:59:16 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 8 Apr 2007 18:59:16 -0400 Subject: [rspec-users] typos in a tutorial page In-Reply-To: References: Message-ID: <4CBA614B-BB89-4285-A749-83D28ABCF5FC@railsnewbie.com> Hi Julien. Thanks for the info. I believe that some of this comes from the syntax changes in 0.8. David, Aslak, or one of the other members would know better than I. Scott On Apr 8, 2007, at 6:28 PM, Julien Palmas wrote: > This page has some typos in the forth grey box > http://rspec.rubyforge.org/tutorials/stack_04.html > > "should_equal" should be "should ==" > and > "should_not_be_empty" should be "should_not be_empty" > > this causes some spec to fail > > By the way, this is my first mail to the list, so Hi everybody !! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cwdinfo at gmail.com Sun Apr 8 19:10:51 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 8 Apr 2007 16:10:51 -0700 Subject: [rspec-users] rcov with rspec & rails In-Reply-To: References: Message-ID: <92B0A47F-4B0F-48B1-9B44-70FE1E3EA635@gmail.com> I just do: rcov spec/models/*.rb spec/controllers/*.rb spec/views/*.rb spec/ helpers/*.rb Seems to work ok. On Apr 8, 2007, at 3:49 PM, Scott Taylor wrote: > > Is there an easy way to use rcov to show my code coverage with RSpec > in a rails project? > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Apr 8 22:19:21 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Apr 2007 21:19:21 -0500 Subject: [rspec-users] typos in a tutorial page In-Reply-To: <4CBA614B-BB89-4285-A749-83D28ABCF5FC@railsnewbie.com> References: <4CBA614B-BB89-4285-A749-83D28ABCF5FC@railsnewbie.com> Message-ID: <57c63afe0704081919u3267dd8dx382d5769ad153efc@mail.gmail.com> On 4/8/07, Scott Taylor wrote: > > Hi Julien. > > Thanks for the info. > > I believe that some of this comes from the syntax changes in 0.8. > David, Aslak, or one of the other members would know better than I. Actually, the tutorial needs a complete overhaul so I've removed it from the 0.9 docs. I'll restore soon, but I don't want that to hold up the 0.9.0 release. David > > Scott > > > On Apr 8, 2007, at 6:28 PM, Julien Palmas wrote: > > > This page has some typos in the forth grey box > > http://rspec.rubyforge.org/tutorials/stack_04.html > > > > "should_equal" should be "should ==" > > and > > "should_not_be_empty" should be "should_not be_empty" > > > > this causes some spec to fail > > > > By the way, this is my first mail to the list, so Hi everybody !! > > _______________________________________________ > > 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 jed.hurt at gmail.com Sun Apr 8 23:54:52 2007 From: jed.hurt at gmail.com (Jed Hurt) Date: Sun, 8 Apr 2007 21:54:52 -0600 Subject: [rspec-users] Integration Specs On Rails In-Reply-To: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> References: <57c63afe0704062134g6f30fb31s2ff2a80cf14d4519@mail.gmail.com> Message-ID: My bad. I made the silly blunder of thinking that the next point after 0.9 would be 1.0. Obviously having version numbers higher than .9 is quite common ;) On 4/6/07, David Chelimsky wrote: > On 4/6/07, Jed Hurt wrote: > > Now that RSpec is nearing 1 dot oh > > It is? > > >, are there any plans to implement > > an integration testing equivalent in RSpec On Rails? > > There's an open RFE for this > http://rubyforge.org/tracker/index.php?func=detail&aid=9381&group_id=797&atid=3152. > Just a matter of priority. If somebody wants to take a stab at a > patch, that might move it up. > > 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 pergesu at gmail.com Mon Apr 9 01:37:55 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 8 Apr 2007 23:37:55 -0600 Subject: [rspec-users] RCov results seem to include the spec files Message-ID: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> I saw the RCov page at http://rspec.rubyforge.org/tools/rcov.html and decided to add it to my project. My rakefile looks like this: require "rake" require "spec/rake/spectask" desc "Run all specs with RCov" Spec::Rake::SpecTask.new("spec:rcov") do |t| t.spec_files = FileList["spec/**/*_spec.rb"] t.rcov = true end When I run rake spec:rcov, it runs the specs using RCov and generates the reports, but it's including all my spec files as well. At the very bottom I'll see stuff like spec/models/user_spec.rb 89 73 100.0% it even includes spec_helper.rb! I don't really care to know that my specs are covered :) Here's the command that's being run as a result of the rake task: /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" -S rcov --exclude lib\/spec,bin\/spec,config\/boot.rb -o "coverage" "/usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" -- "spec/controllers/books_controller_spec.rb" "spec/controllers/feedback_controller_spec.rb" "spec/controllers/stack_controller_spec.rb" "spec/controllers/users_controller_spec.rb" "spec/helpers/books_helper_spec.rb" "spec/models/book_spec.rb" "spec/models/user_spec.rb" rspec 0.8.2, rcov 0.8.0.2 I noticed that the example output at http://rspec.rubyforge.org/coverage/index.html doesn't seem to share this. So how can I make rcov ignore the spec files themselves? Pat From mailing_lists at railsnewbie.com Mon Apr 9 03:29:16 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 9 Apr 2007 03:29:16 -0400 Subject: [rspec-users] RCov results seem to include the spec files In-Reply-To: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> References: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> Message-ID: I'm getting a ton of errors when using that... Here is one of my specs: describe "GET /users/1/terms" do controller_name :terms def do_get get :index, :user_id => 1 end it "should be successful" do do_get response.should be_success end ... end and the response from rcov: 1) NoMethodError in 'GET /users/1/terms should render index' undefined method `should_render' for # ./spec/controllers/terms_controller_spec.rb:43: Any ideas? Scott On Apr 9, 2007, at 1:37 AM, Pat Maddox wrote: > > require "rake" > require "spec/rake/spectask" > > desc "Run all specs with RCov" > Spec::Rake::SpecTask.new("spec:rcov") do |t| > t.spec_files = FileList["spec/**/*_spec.rb"] > t.rcov = true > end From mailing_lists at railsnewbie.com Mon Apr 9 03:34:18 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 9 Apr 2007 03:34:18 -0400 Subject: [rspec-users] RCov results seem to include the spec files In-Reply-To: References: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> Message-ID: <8753D9CA-2365-4A3D-AF92-52E92B7A3C24@railsnewbie.com> oops. wrong spec included. it should be: it "should render index" do controller.should_render(:index) do_get end On Apr 9, 2007, at 3:29 AM, Scott Taylor wrote: > > I'm getting a ton of errors when using that... > > Here is one of my specs: > > describe "GET /users/1/terms" do > > controller_name :terms > > def do_get > get :index, :user_id => 1 > end > > it "should be successful" do > do_get > response.should be_success > end > > ... > end > > and the response from rcov: > > 1) > NoMethodError in 'GET /users/1/terms should render index' > undefined method `should_render' for # > ./spec/controllers/terms_controller_spec.rb:43: > > Any ideas? > > Scott > > > > On Apr 9, 2007, at 1:37 AM, Pat Maddox wrote: > >> >> require "rake" >> require "spec/rake/spectask" >> >> desc "Run all specs with RCov" >> Spec::Rake::SpecTask.new("spec:rcov") do |t| >> t.spec_files = FileList["spec/**/*_spec.rb"] >> t.rcov = true >> end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Apr 9 07:14:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Apr 2007 06:14:10 -0500 Subject: [rspec-users] RCov results seem to include the spec files In-Reply-To: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> References: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> Message-ID: <57c63afe0704090414i437bf75fn58856e0915c18ba5@mail.gmail.com> On 4/9/07, Pat Maddox wrote: > I saw the RCov page at http://rspec.rubyforge.org/tools/rcov.html and > decided to add it to my project. My rakefile looks like this: > > require "rake" > require "spec/rake/spectask" > > desc "Run all specs with RCov" > Spec::Rake::SpecTask.new("spec:rcov") do |t| > t.spec_files = FileList["spec/**/*_spec.rb"] > t.rcov = true > end Try this: Spec::Rake::SpecTask.new("spec:rcov") do |t| t.spec_files = FileList["spec/**/*_spec.rb"] t.rcov = true t.rcov_opts = ['--exclude', "spec"] end David > When I run rake spec:rcov, it runs the specs using RCov and generates > the reports, but it's including all my spec files as well. > > At the very bottom I'll see stuff like > spec/models/user_spec.rb 89 73 100.0% > > it even includes spec_helper.rb! > > I don't really care to know that my specs are covered :) > > Here's the command that's being run as a result of the rake task: > /usr/local/bin/ruby > -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib" -S rcov > --exclude lib\/spec,bin\/spec,config\/boot.rb -o "coverage" > "/usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec" -- > "spec/controllers/books_controller_spec.rb" > "spec/controllers/feedback_controller_spec.rb" > "spec/controllers/stack_controller_spec.rb" > "spec/controllers/users_controller_spec.rb" > "spec/helpers/books_helper_spec.rb" "spec/models/book_spec.rb" > "spec/models/user_spec.rb" > > rspec 0.8.2, rcov 0.8.0.2 > > I noticed that the example output at > http://rspec.rubyforge.org/coverage/index.html doesn't seem to share > this. So how can I make rcov ignore the spec files themselves? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Apr 9 07:29:09 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Apr 2007 06:29:09 -0500 Subject: [rspec-users] RCov results seem to include the spec files In-Reply-To: <57c63afe0704090414i437bf75fn58856e0915c18ba5@mail.gmail.com> References: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> <57c63afe0704090414i437bf75fn58856e0915c18ba5@mail.gmail.com> Message-ID: <57c63afe0704090429y63150645s92ed6ea60bdd051@mail.gmail.com> On 4/9/07, David Chelimsky wrote: > On 4/9/07, Pat Maddox wrote: > > I saw the RCov page at http://rspec.rubyforge.org/tools/rcov.html and > > decided to add it to my project. My rakefile looks like this: > > > > require "rake" > > require "spec/rake/spectask" > > > > desc "Run all specs with RCov" > > Spec::Rake::SpecTask.new("spec:rcov") do |t| > > t.spec_files = FileList["spec/**/*_spec.rb"] > > t.rcov = true > > end > > Try this: > > Spec::Rake::SpecTask.new("spec:rcov") do |t| > t.spec_files = FileList["spec/**/*_spec.rb"] > t.rcov = true > t.rcov_opts = ['--exclude', "spec"] > end > > David FYI - I added this to docs for 0.9. From pergesu at gmail.com Mon Apr 9 13:14:29 2007 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 9 Apr 2007 11:14:29 -0600 Subject: [rspec-users] RCov results seem to include the spec files In-Reply-To: <57c63afe0704090429y63150645s92ed6ea60bdd051@mail.gmail.com> References: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> <57c63afe0704090414i437bf75fn58856e0915c18ba5@mail.gmail.com> <57c63afe0704090429y63150645s92ed6ea60bdd051@mail.gmail.com> Message-ID: <810a540e0704091014r372052f5w3e904b36cca6ee28@mail.gmail.com> On 4/9/07, David Chelimsky wrote: > On 4/9/07, David Chelimsky wrote: > > On 4/9/07, Pat Maddox wrote: > > > I saw the RCov page at http://rspec.rubyforge.org/tools/rcov.html and > > > decided to add it to my project. My rakefile looks like this: > > > > > > require "rake" > > > require "spec/rake/spectask" > > > > > > desc "Run all specs with RCov" > > > Spec::Rake::SpecTask.new("spec:rcov") do |t| > > > t.spec_files = FileList["spec/**/*_spec.rb"] > > > t.rcov = true > > > end > > > > Try this: > > > > Spec::Rake::SpecTask.new("spec:rcov") do |t| > > t.spec_files = FileList["spec/**/*_spec.rb"] > > t.rcov = true > > t.rcov_opts = ['--exclude', "spec"] > > end > > > > David > > FYI - I added this to docs for 0.9. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hey David, Thanks for the info. For Rails apps, I use t.rcov_opts = ['--exclude', "spec", "--exclude", "config"] because it doesn't make much sense to include the config files either. Thanks again, Pat From mtrier at eminentconsultinggroup.com Mon Apr 9 13:55:17 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Mon, 9 Apr 2007 13:55:17 -0400 Subject: [rspec-users] RCov results seem to include the spec files In-Reply-To: <810a540e0704091014r372052f5w3e904b36cca6ee28@mail.gmail.com> References: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> <57c63afe0704090414i437bf75fn58856e0915c18ba5@mail.gmail.com> <57c63afe0704090429y63150645s92ed6ea60bdd051@mail.gmail.com> <810a540e0704091014r372052f5w3e904b36cca6ee28@mail.gmail.com> Message-ID: What about the test directory as well for those of us that are still migrating things over. Michael railsconsulting.com On Apr 9, 2007, at 1:14 PM, Pat Maddox wrote: > On 4/9/07, David Chelimsky wrote: >> On 4/9/07, David Chelimsky wrote: >>> On 4/9/07, Pat Maddox wrote: >>>> I saw the RCov page at http://rspec.rubyforge.org/tools/ >>>> rcov.html and >>>> decided to add it to my project. My rakefile looks like this: >>>> >>>> require "rake" >>>> require "spec/rake/spectask" >>>> >>>> desc "Run all specs with RCov" >>>> Spec::Rake::SpecTask.new("spec:rcov") do |t| >>>> t.spec_files = FileList["spec/**/*_spec.rb"] >>>> t.rcov = true >>>> end >>> >>> Try this: >>> >>> Spec::Rake::SpecTask.new("spec:rcov") do |t| >>> t.spec_files = FileList["spec/**/*_spec.rb"] >>> t.rcov = true >>> t.rcov_opts = ['--exclude', "spec"] >>> end >>> >>> David >> >> FYI - I added this to docs for 0.9. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Hey David, > > Thanks for the info. > > For Rails apps, I use > t.rcov_opts = ['--exclude', "spec", "--exclude", "config"] > > because it doesn't make much sense to include the config files either. > > Thanks again, > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Apr 9 14:01:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Apr 2007 13:01:18 -0500 Subject: [rspec-users] RCov results seem to include the spec files In-Reply-To: <810a540e0704091014r372052f5w3e904b36cca6ee28@mail.gmail.com> References: <810a540e0704082237yb32a148ndb0538be4dbc5bdb@mail.gmail.com> <57c63afe0704090414i437bf75fn58856e0915c18ba5@mail.gmail.com> <57c63afe0704090429y63150645s92ed6ea60bdd051@mail.gmail.com> <810a540e0704091014r372052f5w3e904b36cca6ee28@mail.gmail.com> Message-ID: <57c63afe0704091101x5c45ce99hc09d9b5a14686bd8@mail.gmail.com> On 4/9/07, Pat Maddox wrote: > On 4/9/07, David Chelimsky wrote: > > On 4/9/07, David Chelimsky wrote: > > > On 4/9/07, Pat Maddox wrote: > > > > I saw the RCov page at http://rspec.rubyforge.org/tools/rcov.html and > > > > decided to add it to my project. My rakefile looks like this: > > > > > > > > require "rake" > > > > require "spec/rake/spectask" > > > > > > > > desc "Run all specs with RCov" > > > > Spec::Rake::SpecTask.new("spec:rcov") do |t| > > > > t.spec_files = FileList["spec/**/*_spec.rb"] > > > > t.rcov = true > > > > end > > > > > > Try this: > > > > > > Spec::Rake::SpecTask.new("spec:rcov") do |t| > > > t.spec_files = FileList["spec/**/*_spec.rb"] > > > t.rcov = true > > > t.rcov_opts = ['--exclude', "spec"] > > > end > > > > > > David > > > > FYI - I added this to docs for 0.9. > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > Hey David, > > Thanks for the info. > > For Rails apps, I use > t.rcov_opts = ['--exclude', "spec", "--exclude", "config"] You can also do it w/ a single --exclude and a list of comma separated vals: t.rcov_opts = ['--exclude', "spec, config"] > > because it doesn't make much sense to include the config files either. > > Thanks again, > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Mon Apr 9 16:07:10 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 9 Apr 2007 16:07:10 -0400 Subject: [rspec-users] changes in 0.8 and greater - should_ Message-ID: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> Has the should_... syntax changed? I'm getting errors when running the following: should_render(:index) should_be_valid should_not_be_valid should_respond_to should_be should_render I thought the syntax changed to something like the following: obj.should render(:index) but this doesn't seem to work. Scott From mailing_lists at railsnewbie.com Mon Apr 9 16:26:11 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 9 Apr 2007 16:26:11 -0400 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> Message-ID: If I have rspec & rspec on rails checked out from trunk in my rails project, should I copy the spec & spec_server utilities into the script/ directory of my rails project (and run the generator) every time I run svn update? Scott On Apr 9, 2007, at 4:07 PM, Scott Taylor wrote: > > Has the should_... syntax changed? I'm getting errors when running > the following: > > should_render(:index) > should_be_valid > should_not_be_valid > should_respond_to > should_be > should_render > > I thought the syntax changed to something like the following: > > obj.should render(:index) > > but this doesn't seem to work. > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Mon Apr 9 16:43:24 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 9 Apr 2007 22:43:24 +0200 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> Message-ID: <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> On 4/9/07, Scott Taylor wrote: > > Has the should_... syntax changed? I'm getting errors when running > the following: > > should_render(:index) > should_be_valid > should_not_be_valid > should_respond_to > should_be > should_render > Object now only gets monkeypatched with two methods: should and should_not. should_anything_else will no longer work. > I thought the syntax changed to something like the following: > > obj.should render(:index) > Syntactically, yes. But the API has changed too, so now you must say: response.should render_template(:index) See doc/output/rdoc-rails/index.html (rspec_on_rails/lib/spec/rails/matchers.rb RDoc) and example_rails_app/spec/controllers/people_controller_spec.rb for details. Aslak > but this doesn't seem to work. > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Apr 9 16:46:16 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 9 Apr 2007 22:46:16 +0200 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> Message-ID: <8d961d900704091346k5ff37ca8v28645b482f378808@mail.gmail.com> On 4/9/07, Scott Taylor wrote: > > If I have rspec & rspec on rails checked out from trunk in my rails > project, should I copy the spec & spec_server utilities into the > script/ directory of my rails project (and run the generator) every > time I run svn update? > To be safe, you should run "ruby script/generate rspec" after every svn update. However, you'll be fine without running it unless there are changes to the rspec generator. Aslak > Scott > > > > On Apr 9, 2007, at 4:07 PM, Scott Taylor wrote: > > > > > Has the should_... syntax changed? I'm getting errors when running > > the following: > > > > should_render(:index) > > should_be_valid > > should_not_be_valid > > should_respond_to > > should_be > > should_render > > > > I thought the syntax changed to something like the following: > > > > obj.should render(:index) > > > > but this doesn't seem to work. > > > > 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 mailing_lists at railsnewbie.com Mon Apr 9 17:36:49 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 9 Apr 2007 17:36:49 -0400 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> Message-ID: <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> Thanks for the info, Aslak. What is the appropriate form of render in the view specs to use? Doing something like this: render "users/1/terms" gives me: /users/1/terms/index.html.erb I'm using restful-routes and markaby. I know there was a bug in the tracker about markaby templates. I'll follow up on that if this is the case here. Scott On Apr 9, 2007, at 4:43 PM, aslak hellesoy wrote: > On 4/9/07, Scott Taylor wrote: >> >> Has the should_... syntax changed? I'm getting errors when running >> the following: >> >> should_render(:index) >> should_be_valid >> should_not_be_valid >> should_respond_to >> should_be >> should_render >> > > Object now only gets monkeypatched with two methods: should and > should_not. > should_anything_else will no longer work. > >> I thought the syntax changed to something like the following: >> >> obj.should render(:index) >> > > Syntactically, yes. But the API has changed too, so now you must say: > response.should render_template(:index) > > See doc/output/rdoc-rails/index.html > (rspec_on_rails/lib/spec/rails/matchers.rb RDoc) and > example_rails_app/spec/controllers/people_controller_spec.rb for > details. > > Aslak > >> but this doesn't seem to work. >> >> 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 aslak.hellesoy at gmail.com Mon Apr 9 17:45:29 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 9 Apr 2007 23:45:29 +0200 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> Message-ID: <8d961d900704091445k5ddd6b5cnde20607c39eb76ec@mail.gmail.com> On 4/9/07, Scott Taylor wrote: > > Thanks for the info, Aslak. > > What is the appropriate form of render in the view specs to use? > RSpec doesn't have code without specs, so if you don't find it in the docs, the best place to look is the specs > Doing something like this: > > render "users/1/terms" > That's the right form. > gives me: > What do you mean by "gives me"? > /users/1/terms/index.html.erb > Seems to be a recent change in edge rails: http://dev.rubyonrails.org/changeset/6507 > I'm using restful-routes and markaby. > > I know there was a bug in the tracker about markaby templates. I'll > follow up on that if this is the case here. > > Scott > > > > On Apr 9, 2007, at 4:43 PM, aslak hellesoy wrote: > > > On 4/9/07, Scott Taylor wrote: > >> > >> Has the should_... syntax changed? I'm getting errors when running > >> the following: > >> > >> should_render(:index) > >> should_be_valid > >> should_not_be_valid > >> should_respond_to > >> should_be > >> should_render > >> > > > > Object now only gets monkeypatched with two methods: should and > > should_not. > > should_anything_else will no longer work. > > > >> I thought the syntax changed to something like the following: > >> > >> obj.should render(:index) > >> > > > > Syntactically, yes. But the API has changed too, so now you must say: > > response.should render_template(:index) > > > > See doc/output/rdoc-rails/index.html > > (rspec_on_rails/lib/spec/rails/matchers.rb RDoc) and > > example_rails_app/spec/controllers/people_controller_spec.rb for > > details. > > > > Aslak > > > >> but this doesn't seem to work. > >> > >> 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 mailing_lists at railsnewbie.com Mon Apr 9 17:46:24 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 9 Apr 2007 17:46:24 -0400 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> Message-ID: <17ED89BC-6242-4A76-8778-48595042EDD0@railsnewbie.com> Forget this email. I figured it out. It works fine with markaby. As for nested routes, this works fine: render "/terms/index" Scott On Apr 9, 2007, at 5:36 PM, Scott Taylor wrote: > > Thanks for the info, Aslak. > > What is the appropriate form of render in the view specs to use? > > Doing something like this: > > render "users/1/terms" > > gives me: > > /users/1/terms/index.html.erb > > I'm using restful-routes and markaby. > > I know there was a bug in the tracker about markaby templates. I'll > follow up on that if this is the case here. > > Scott > > > > On Apr 9, 2007, at 4:43 PM, aslak hellesoy wrote: > >> On 4/9/07, Scott Taylor wrote: >>> >>> Has the should_... syntax changed? I'm getting errors when running >>> the following: >>> >>> should_render(:index) >>> should_be_valid >>> should_not_be_valid >>> should_respond_to >>> should_be >>> should_render >>> >> >> Object now only gets monkeypatched with two methods: should and >> should_not. >> should_anything_else will no longer work. >> >>> I thought the syntax changed to something like the following: >>> >>> obj.should render(:index) >>> >> >> Syntactically, yes. But the API has changed too, so now you must say: >> response.should render_template(:index) >> >> See doc/output/rdoc-rails/index.html >> (rspec_on_rails/lib/spec/rails/matchers.rb RDoc) and >> example_rails_app/spec/controllers/people_controller_spec.rb for >> details. >> >> Aslak >> >>> but this doesn't seem to work. >>> >>> 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 dchelimsky at gmail.com Mon Apr 9 17:48:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Apr 2007 16:48:10 -0500 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <8d961d900704091445k5ddd6b5cnde20607c39eb76ec@mail.gmail.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> <8d961d900704091445k5ddd6b5cnde20607c39eb76ec@mail.gmail.com> Message-ID: <57c63afe0704091448p6612ab2co63a34ccaa34c369e@mail.gmail.com> On 4/9/07, aslak hellesoy wrote: > On 4/9/07, Scott Taylor wrote: > > > > Thanks for the info, Aslak. > > > > What is the appropriate form of render in the view specs to use? > > > > RSpec doesn't have code without specs, so if you don't find it in the > docs, the best place to look is the specs > > > Doing something like this: > > > > render "users/1/terms" Actually it's not the right form. In view specs you want to specify the filesystem path to the template from the app/views directory. So if you want to describe app/views/users/index.erb, you would say: render 'users/index.erb' We haven't set out to support markaby specifically, so please report any related bugs in the tracker. > > > > That's the right form. > > > gives me: > > > > What do you mean by "gives me"? > > > /users/1/terms/index.html.erb > > > > Seems to be a recent change in edge rails: > http://dev.rubyonrails.org/changeset/6507 > > > I'm using restful-routes and markaby. > > > > I know there was a bug in the tracker about markaby templates. I'll > > follow up on that if this is the case here. > > > > Scott > > > > > > > > On Apr 9, 2007, at 4:43 PM, aslak hellesoy wrote: > > > > > On 4/9/07, Scott Taylor wrote: > > >> > > >> Has the should_... syntax changed? I'm getting errors when running > > >> the following: > > >> > > >> should_render(:index) > > >> should_be_valid > > >> should_not_be_valid > > >> should_respond_to > > >> should_be > > >> should_render > > >> > > > > > > Object now only gets monkeypatched with two methods: should and > > > should_not. > > > should_anything_else will no longer work. > > > > > >> I thought the syntax changed to something like the following: > > >> > > >> obj.should render(:index) > > >> > > > > > > Syntactically, yes. But the API has changed too, so now you must say: > > > response.should render_template(:index) > > > > > > See doc/output/rdoc-rails/index.html > > > (rspec_on_rails/lib/spec/rails/matchers.rb RDoc) and > > > example_rails_app/spec/controllers/people_controller_spec.rb for > > > details. > > > > > > Aslak > > > > > >> but this doesn't seem to work. > > >> > > >> 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Apr 9 17:49:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Apr 2007 16:49:03 -0500 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <17ED89BC-6242-4A76-8778-48595042EDD0@railsnewbie.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> <17ED89BC-6242-4A76-8778-48595042EDD0@railsnewbie.com> Message-ID: <57c63afe0704091449u69fc2450x5f02213a6917a807@mail.gmail.com> On 4/9/07, Scott Taylor wrote: > > Forget this email. I figured it out. It works fine with markaby. > As for nested routes, this works fine: > > render "/terms/index" Glad you figured it out. I'm assuming that the template is app/views/terms/index.erb, right? > > Scott > > > On Apr 9, 2007, at 5:36 PM, Scott Taylor wrote: > > > > > Thanks for the info, Aslak. > > > > What is the appropriate form of render in the view specs to use? > > > > Doing something like this: > > > > render "users/1/terms" > > > > gives me: > > > > /users/1/terms/index.html.erb > > > > I'm using restful-routes and markaby. > > > > I know there was a bug in the tracker about markaby templates. I'll > > follow up on that if this is the case here. > > > > Scott > > > > > > > > On Apr 9, 2007, at 4:43 PM, aslak hellesoy wrote: > > > >> On 4/9/07, Scott Taylor wrote: > >>> > >>> Has the should_... syntax changed? I'm getting errors when running > >>> the following: > >>> > >>> should_render(:index) > >>> should_be_valid > >>> should_not_be_valid > >>> should_respond_to > >>> should_be > >>> should_render > >>> > >> > >> Object now only gets monkeypatched with two methods: should and > >> should_not. > >> should_anything_else will no longer work. > >> > >>> I thought the syntax changed to something like the following: > >>> > >>> obj.should render(:index) > >>> > >> > >> Syntactically, yes. But the API has changed too, so now you must say: > >> response.should render_template(:index) > >> > >> See doc/output/rdoc-rails/index.html > >> (rspec_on_rails/lib/spec/rails/matchers.rb RDoc) and > >> example_rails_app/spec/controllers/people_controller_spec.rb for > >> details. > >> > >> Aslak > >> > >>> but this doesn't seem to work. > >>> > >>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Mon Apr 9 17:51:23 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 9 Apr 2007 17:51:23 -0400 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <57c63afe0704091449u69fc2450x5f02213a6917a807@mail.gmail.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> <17ED89BC-6242-4A76-8778-48595042EDD0@railsnewbie.com> <57c63afe0704091449u69fc2450x5f02213a6917a807@mail.gmail.com> Message-ID: <5DE6E01A-4BFC-4D76-A967-6004A2FFF405@railsnewbie.com> On Apr 9, 2007, at 5:49 PM, David Chelimsky wrote: > On 4/9/07, Scott Taylor wrote: >> >> Forget this email. I figured it out. It works fine with markaby. >> As for nested routes, this works fine: >> >> render "/terms/index" > > Glad you figured it out. I'm assuming that the template is > app/views/terms/index.erb, right? .mab, since it's markaby. Scott From dchelimsky at gmail.com Mon Apr 9 18:04:57 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 9 Apr 2007 17:04:57 -0500 Subject: [rspec-users] changes in 0.8 and greater - should_ In-Reply-To: <5DE6E01A-4BFC-4D76-A967-6004A2FFF405@railsnewbie.com> References: <89664B96-CF93-4BAE-B004-F5D7947128FD@railsnewbie.com> <8d961d900704091343t2d6072eci8da40f7a821b5418@mail.gmail.com> <8FAADE52-C7B3-4328-992F-A164DCF54CE0@railsnewbie.com> <17ED89BC-6242-4A76-8778-48595042EDD0@railsnewbie.com> <57c63afe0704091449u69fc2450x5f02213a6917a807@mail.gmail.com> <5DE6E01A-4BFC-4D76-A967-6004A2FFF405@railsnewbie.com> Message-ID: <57c63afe0704091504n6a63ab6ctd1d23263835638db@mail.gmail.com> On 4/9/07, Scott Taylor wrote: > > On Apr 9, 2007, at 5:49 PM, David Chelimsky wrote: > > > On 4/9/07, Scott Taylor wrote: > >> > >> Forget this email. I figured it out. It works fine with markaby. > >> As for nested routes, this works fine: > >> > >> render "/terms/index" > > > > Glad you figured it out. I'm assuming that the template is > > app/views/terms/index.erb, right? > > .mab, since it's markaby. Thanks! > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bienhd at gmail.com Mon Apr 9 21:55:26 2007 From: bienhd at gmail.com (Hugh Bien) Date: Mon, 9 Apr 2007 18:55:26 -0700 Subject: [rspec-users] Having some trouble with rspec on rails. Message-ID: Hi guys, I'm having some trouble with RSpec on Rails. Specifically, whenever I run the specs separately they're fine: spec spec/controllers/*.rb spec spec/models/*.rb Or if I run them with TextMate..., but whenever I use the RCov Rake task from the RSpec page (or if I run all the specs together) I get failures: rake rcov spec spec/*/*.rb spec spec/models/*.rb spec/controllers/*.rb The failures seem to be happening due to NoMethodErrors like render_template doesn't exist, or everything coming back from assigns[:symbol] is nil. But that only happens when I run ALL the specs in one command. Oddly enough, running just the controller specs or just the model specs produces no failures/errors. Has anyone had issue or knows how to fix it? I'm running on RSpec 0.8.2 and the same plugin version. Cheers, Hugh From mailing_lists at railsnewbie.com Tue Apr 10 08:15:09 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 10 Apr 2007 08:15:09 -0400 Subject: [rspec-users] getting output of STDOUT in spec Message-ID: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> Consider the following method: def name_to_terminal puts "Scott Taylor" end How would I spec this out? Scott From aslak.hellesoy at gmail.com Tue Apr 10 08:21:06 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 10 Apr 2007 14:21:06 +0200 Subject: [rspec-users] getting output of STDOUT in spec In-Reply-To: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> References: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> Message-ID: <8d961d900704100521u40129577l54cf0efc86dcccf2@mail.gmail.com> On 4/10/07, Scott Taylor wrote: > > Consider the following method: > > def name_to_terminal > puts "Scott Taylor" > end > > How would I spec this out? > def name_to_terminal(io=STDOUT) io.puts "Scott Taylor" end then call it from a spec passing in a mock for io with the appropriate expectation > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Apr 10 08:21:11 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Apr 2007 07:21:11 -0500 Subject: [rspec-users] getting output of STDOUT in spec In-Reply-To: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> References: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> Message-ID: <57c63afe0704100521x3b464f7dvf0ba45c7059eaf84@mail.gmail.com> On 4/10/07, Scott Taylor wrote: > > Consider the following method: > > def name_to_terminal > puts "Scott Taylor" > end > > How would I spec this out? RSpec prints to STDOUT, but the examples and implementation use an instance of IO (mocked for the examples). So you'd have something like: describe Interactor do setup { @interactor = Interactor.new(@io = mock("IO")) } it "should print name to IO" do @io.should_receive(:<<).with("Scott Taylor") @interactor.print "Scott Taylor" end end > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Tue Apr 10 11:23:36 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Tue, 10 Apr 2007 16:23:36 +0100 Subject: [rspec-users] getting output of STDOUT in spec In-Reply-To: <8d961d900704100521u40129577l54cf0efc86dcccf2@mail.gmail.com> References: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> <8d961d900704100521u40129577l54cf0efc86dcccf2@mail.gmail.com> Message-ID: On 10 Apr 2007, at 13:21, aslak hellesoy wrote: > def name_to_terminal(io=STDOUT) > io.puts "Scott Taylor" > end > > then call it from a spec passing in a mock for io with the appropriate > expectation Aha - this gives me an idea about the dreaded "current-time" problem def do_something(time_factory=Time) time = time_factory.new # ... end Actually I suppose it works for any class. Why didn't I think of that before? It's so simple! From aslak.hellesoy at gmail.com Tue Apr 10 12:04:36 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 10 Apr 2007 18:04:36 +0200 Subject: [rspec-users] getting output of STDOUT in spec In-Reply-To: References: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> <8d961d900704100521u40129577l54cf0efc86dcccf2@mail.gmail.com> Message-ID: <8d961d900704100904n4855f831g97a3650ecec7509f@mail.gmail.com> This is a variant of the dependency injection principle. It goes hand in hand with mocking. I recommend martin fowler's DI article for more info. On 4/10/07, Ashley Moran wrote: > > On 10 Apr 2007, at 13:21, aslak hellesoy wrote: > > > def name_to_terminal(io=STDOUT) > > io.puts "Scott Taylor" > > end > > > > then call it from a spec passing in a mock for io with the appropriate > > expectation > > Aha - this gives me an idea about the dreaded "current-time" problem > > def do_something(time_factory=Time) > time = time_factory.new > # ... > end > > Actually I suppose it works for any class. Why didn't I think of > that before? It's so simple! > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Apr 10 12:18:02 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Apr 2007 11:18:02 -0500 Subject: [rspec-users] getting output of STDOUT in spec In-Reply-To: <8d961d900704100904n4855f831g97a3650ecec7509f@mail.gmail.com> References: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> <8d961d900704100521u40129577l54cf0efc86dcccf2@mail.gmail.com> <8d961d900704100904n4855f831g97a3650ecec7509f@mail.gmail.com> Message-ID: <57c63afe0704100918i6e90a607v334bf679c636658e@mail.gmail.com> There is one potential pitfall w/ this approach. I still use it in spite of the pitfall, but it's something you should be aware of. It's entirely possible to default to the wrong this: class NotTime class << self def now return 'or later' end end end class Thing do def do_something(time_factory=NotTime) time = time_factory.now ... end end If your examples always use mocks, and never challenge the assumption that the default is Time, you can get into trouble. In truth, I can't recall when this has bitten me. But it does seem like a hole you can fall in. On 4/10/07, aslak hellesoy wrote: > This is a variant of the dependency injection principle. It goes hand > in hand with mocking. I recommend martin fowler's DI article for more > info. > > On 4/10/07, Ashley Moran wrote: > > > > On 10 Apr 2007, at 13:21, aslak hellesoy wrote: > > > > > def name_to_terminal(io=STDOUT) > > > io.puts "Scott Taylor" > > > end > > > > > > then call it from a spec passing in a mock for io with the appropriate > > > expectation > > > > Aha - this gives me an idea about the dreaded "current-time" problem > > > > def do_something(time_factory=Time) > > time = time_factory.new > > # ... > > end > > > > Actually I suppose it works for any class. Why didn't I think of > > that before? It's so simple! > > > > _______________________________________________ > > 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 Apr 10 16:56:17 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 10 Apr 2007 16:56:17 -0400 Subject: [rspec-users] using YAML for --failures and --examples Message-ID: <98B1EBAE-6E9C-4D55-940C-4F9000C2BB2E@railsnewbie.com> As it is currently, in trunk, --failures and --examples except a text file, each line containing the name of a spec. I'm wondering: Would a a patch to use YAML (instead or as well as) plain text be welcomed? I'm thinking of a yaml file like the following: spec_file_1: file: spec/person_spec.rb specs: - should have first name - should provide email address spec_file_2: file: spec/client_spec.rb specs: - should have meeting on monday - should drink on friday Any thoughts? Scott From dchelimsky at gmail.com Tue Apr 10 17:12:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Apr 2007 16:12:50 -0500 Subject: [rspec-users] using YAML for --failures and --examples In-Reply-To: <98B1EBAE-6E9C-4D55-940C-4F9000C2BB2E@railsnewbie.com> References: <98B1EBAE-6E9C-4D55-940C-4F9000C2BB2E@railsnewbie.com> Message-ID: <57c63afe0704101412h5c30e6ffwd47d1cca5658c3b1@mail.gmail.com> On 4/10/07, Scott Taylor wrote: > > As it is currently, in trunk, --failures and --examples except a text > file, each line containing the name of a spec. > > I'm wondering: Would a a patch to use YAML (instead or as well as) > plain text be welcomed? I'm thinking of a yaml file like the following: > > spec_file_1: > file: spec/person_spec.rb > specs: > - should have first name > - should provide email address > > spec_file_2: > file: spec/client_spec.rb > specs: > - should have meeting on monday > - should drink on friday > > > Any thoughts? What benefit would this provide? > > Scott > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From t.lucas at toolmantim.com Tue Apr 10 19:25:02 2007 From: t.lucas at toolmantim.com (Tim Lucas) Date: Wed, 11 Apr 2007 09:25:02 +1000 Subject: [rspec-users] getting output of STDOUT in spec In-Reply-To: References: <045A2147-F9AE-42B4-933E-320CEBD30E2B@railsnewbie.com> <8d961d900704100521u40129577l54cf0efc86dcccf2@mail.gmail.com> Message-ID: <1F27DC6A-02CA-4935-913B-8FCA750FF872@toolmantim.com> On 11/04/2007, at 1:23 AM, Ashley Moran wrote: > Aha - this gives me an idea about the dreaded "current-time" problem > > def do_something(time_factory=Time) > time = time_factory.new > # ... > end > > Actually I suppose it works for any class. Why didn't I think of > that before? It's so simple! Usually I just have "today" or "now" as a parameter: def do_something(now=Time.now) # ... end def do_something(today=Date.today) # ... end Though there's no reason you couldn't mock those two method calls... -- tim From marcus at ahnve.com Wed Apr 11 07:57:52 2007 From: marcus at ahnve.com (Marcus Ahnve) Date: Wed, 11 Apr 2007 13:57:52 +0200 Subject: [rspec-users] Default exclude pattern in 0.9.0 Message-ID: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> The "rspec" rake task collects all _spec files in the spec directory, and excludes the "watir" directory. Is this indicating a preference for using Watir over Selenium? I would like it better to standardize on something more neutral, 'ui' perhaps? /Marcus -- Marcus Ahnve http://marcus.ahnve.net From mahnve at gmail.com Wed Apr 11 08:01:09 2007 From: mahnve at gmail.com (Marcus Ahnve) Date: Wed, 11 Apr 2007 14:01:09 +0200 Subject: [rspec-users] Default exclude pattern in 0.9.0 In-Reply-To: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> References: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> Message-ID: <58f8dc7a0704110501g119645e1h584088d2d895655c@mail.gmail.com> I also noticed that there is a Rake task named Watir. /Marcus On 4/11/07, Marcus Ahnve wrote: > The "rspec" rake task collects all _spec files in the spec directory, > and excludes the "watir" directory. > > Is this indicating a preference for using Watir over Selenium? I would > like it better to standardize on something more neutral, 'ui' perhaps? > > /Marcus > > -- > Marcus Ahnve > http://marcus.ahnve.net > From aslak.hellesoy at gmail.com Wed Apr 11 08:09:42 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Apr 2007 14:09:42 +0200 Subject: [rspec-users] Default exclude pattern in 0.9.0 In-Reply-To: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> References: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> Message-ID: <8d961d900704110509k6274572bj20b19acf1dab6712@mail.gmail.com> On 4/11/07, Marcus Ahnve wrote: > The "rspec" rake task collects all _spec files in the spec directory, > and excludes the "watir" directory. > > Is this indicating a preference for using Watir over Selenium? I'm not sure why you think that's the case. If you look in subversion, there is a spec_ui project with some experimental support for both Watir and Selenium. > I would > like it better to standardize on something more neutral, 'ui' perhaps? > > /Marcus > > -- > Marcus Ahnve > http://marcus.ahnve.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Apr 11 08:13:19 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Apr 2007 14:13:19 +0200 Subject: [rspec-users] Default exclude pattern in 0.9.0 In-Reply-To: <58f8dc7a0704110501g119645e1h584088d2d895655c@mail.gmail.com> References: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> <58f8dc7a0704110501g119645e1h584088d2d895655c@mail.gmail.com> Message-ID: <8d961d900704110513l348b36b9m31b7ba62f0c52576@mail.gmail.com> On 4/11/07, Marcus Ahnve wrote: > I also noticed that there is a Rake task named Watir. > Which one are you referring to? Where did you find this task? > /Marcus > > On 4/11/07, Marcus Ahnve wrote: > > The "rspec" rake task collects all _spec files in the spec directory, > > and excludes the "watir" directory. > > > > Is this indicating a preference for using Watir over Selenium? I would > > like it better to standardize on something more neutral, 'ui' perhaps? > > > > /Marcus > > > > -- > > Marcus Ahnve > > http://marcus.ahnve.net > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mahnve at gmail.com Wed Apr 11 08:41:21 2007 From: mahnve at gmail.com (Marcus Ahnve) Date: Wed, 11 Apr 2007 14:41:21 +0200 Subject: [rspec-users] Default exclude pattern in 0.9.0 In-Reply-To: <8d961d900704110509k6274572bj20b19acf1dab6712@mail.gmail.com> References: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> <8d961d900704110509k6274572bj20b19acf1dab6712@mail.gmail.com> Message-ID: <58f8dc7a0704110541x3b948bafia34c53a9b954ecc9@mail.gmail.com> On 4/11/07, aslak hellesoy wrote: > On 4/11/07, Marcus Ahnve wrote: > > The "rspec" rake task collects all _spec files in the spec directory, > > and excludes the "watir" directory. > > > > Is this indicating a preference for using Watir over Selenium? > > I'm not sure why you think that's the case. If you look in subversion, > there is a spec_ui project with some experimental support for both > Watir and Selenium. Yes, I am actually using spec_ui. My thought was based on the dir excluded being named "watir". But still, wouldn't it be better to use a more generic name for ui tests? /Marcus From nick at ekenosen.net Wed Apr 11 10:07:12 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Wed, 11 Apr 2007 10:07:12 -0400 Subject: [rspec-users] DRYer controller specs Message-ID: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> So, I've been following the recommendations for controller specs here: http://blog.davidchelimsky.net/articles/2006/11/09/tutorial-rspec-stubs-and-mocks Most notably: a single expectation per specify block; the setup block contains only stubs; mock expectations each get their own specify block. (I'm still using 0.8, so I haven't gotten the describe/it goodness yet.) I don't really mind the stub/mock duplication (between setup and the specifications). What's annoying me is the action duplication. "get 'create'" is called in each specify block, sometimes before the actual specification, sometimes afterward, depending on whether it's a mock expectation or a state expectation. So I played around with creating the following module and then extending my context with it. module MockSpecHelpers def expect_that_it(msg) specify msg do yield action end end def then_it(msg) specify msg do action yield end end end in the context block, I would then "def action do get 'create' end". And I would replace the following specify blocks specify "should create a new person on GET to create" do Person.should_receive(:new).and_return(@person) get 'create' end specify "should assign new person to template on GET to create" do get 'create' assigns[:person].should_be @person end with expect_that_it "should create a new person on GET to create" do Person.should_receive(:new).and_return(@person) end then_it "should assign new person to template on GET to create" do assigns[:person].should_be @person end The problem is that my weak Ruby metaprogramming fu has completely failed me. :-) I can't figure out how to get the block to be evaluated in a context that has access to the appropriate context methods (assigns, response, session, etc). I get errors like the following: NameError in 'GET /controller/action/1234 should render the foobar template' undefined local variable or method `response' for # (Usually the "expect_that_it" blocks work fine, because they aren't dependent on anything that is specific to their EvalContext.) Does someone know how I could get this working? I also thought about making an alias for setup called "given" and instead of "action" it could be "when_action" to more closely follow the "given/expect/when/then" pattern and naming conventions. Does this even look like a good idea, or is there a better way? Would it make more sense to open the EvalContext rather than trying to extend a module? -- Nick From aslak.hellesoy at gmail.com Wed Apr 11 10:24:41 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Apr 2007 16:24:41 +0200 Subject: [rspec-users] Default exclude pattern in 0.9.0 In-Reply-To: <58f8dc7a0704110541x3b948bafia34c53a9b954ecc9@mail.gmail.com> References: <58f8dc7a0704110457pc218f18v3c27b45aef3cf225@mail.gmail.com> <8d961d900704110509k6274572bj20b19acf1dab6712@mail.gmail.com> <58f8dc7a0704110541x3b948bafia34c53a9b954ecc9@mail.gmail.com> Message-ID: <8d961d900704110724y3df5f552mc07caaac65076de7@mail.gmail.com> On 4/11/07, Marcus Ahnve wrote: > On 4/11/07, aslak hellesoy wrote: > > On 4/11/07, Marcus Ahnve wrote: > > > The "rspec" rake task collects all _spec files in the spec directory, > > > and excludes the "watir" directory. > > > > > > Is this indicating a preference for using Watir over Selenium? > > > > I'm not sure why you think that's the case. If you look in subversion, > > there is a spec_ui project with some experimental support for both > > Watir and Selenium. > > Yes, I am actually using spec_ui. My thought was based on the dir > excluded being named "watir". > Fixed! Nothing magic (watir) is excluded anymore. (I admit it was a temporary hack to avoid running example_rails_app's watir specs, which are still a little quirky to set up). Aslak > But still, wouldn't it be better to use a more generic name for ui tests? > > /Marcus > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Wed Apr 11 10:38:20 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 11 Apr 2007 10:38:20 -0400 Subject: [rspec-users] using YAML for --failures and --examples In-Reply-To: <57c63afe0704101412h5c30e6ffwd47d1cca5658c3b1@mail.gmail.com> References: <98B1EBAE-6E9C-4D55-940C-4F9000C2BB2E@railsnewbie.com> <57c63afe0704101412h5c30e6ffwd47d1cca5658c3b1@mail.gmail.com> Message-ID: On Apr 10, 2007, at 5:12 PM, David Chelimsky wrote: > On 4/10/07, Scott Taylor wrote: >> >> As it is currently, in trunk, --failures and --examples except a text >> file, each line containing the name of a spec. >> >> I'm wondering: Would a a patch to use YAML (instead or as well as) >> plain text be welcomed? I'm thinking of a yaml file like the >> following: >> >> spec_file_1: >> file: spec/person_spec.rb >> specs: >> - should have first name >> - should provide email address >> >> spec_file_2: >> file: spec/client_spec.rb >> specs: >> - should have meeting on monday >> - should drink on friday >> >> >> Any thoughts? > > What benefit would this provide? It would only provide a benefit in a large spec suite, and as long as each spec file contains more than one describe/context block. Scott From aslak.hellesoy at gmail.com Wed Apr 11 11:16:56 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Apr 2007 17:16:56 +0200 Subject: [rspec-users] using YAML for --failures and --examples In-Reply-To: References: <98B1EBAE-6E9C-4D55-940C-4F9000C2BB2E@railsnewbie.com> <57c63afe0704101412h5c30e6ffwd47d1cca5658c3b1@mail.gmail.com> Message-ID: <8d961d900704110816m7086983ai8366498064c65578@mail.gmail.com> On 4/11/07, Scott Taylor wrote: > > On Apr 10, 2007, at 5:12 PM, David Chelimsky wrote: > > > On 4/10/07, Scott Taylor wrote: > >> > >> As it is currently, in trunk, --failures and --examples except a text > >> file, each line containing the name of a spec. > >> > >> I'm wondering: Would a a patch to use YAML (instead or as well as) > >> plain text be welcomed? I'm thinking of a yaml file like the > >> following: > >> > >> spec_file_1: > >> file: spec/person_spec.rb > >> specs: > >> - should have first name > >> - should provide email address > >> > >> spec_file_2: > >> file: spec/client_spec.rb > >> specs: > >> - should have meeting on monday > >> - should drink on friday > >> > >> > >> Any thoughts? > > > > What benefit would this provide? > > It would only provide a benefit in a large spec suite, and as long as > each spec file contains more than one describe/context block. > What would we achieve with YAML that we can't do with plain text? > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Wed Apr 11 11:25:47 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 11 Apr 2007 11:25:47 -0400 Subject: [rspec-users] using YAML for --failures and --examples In-Reply-To: <8d961d900704110816m7086983ai8366498064c65578@mail.gmail.com> References: <98B1EBAE-6E9C-4D55-940C-4F9000C2BB2E@railsnewbie.com> <57c63afe0704101412h5c30e6ffwd47d1cca5658c3b1@mail.gmail.com> <8d961d900704110816m7086983ai8366498064c65578@mail.gmail.com> Message-ID: On Apr 11, 2007, at 11:16 AM, aslak hellesoy wrote: > On 4/11/07, Scott Taylor wrote: >> >> On Apr 10, 2007, at 5:12 PM, David Chelimsky wrote: >> >>> On 4/10/07, Scott Taylor wrote: >>>> >>>> As it is currently, in trunk, --failures and --examples except a >>>> text >>>> file, each line containing the name of a spec. >>>> >>>> I'm wondering: Would a a patch to use YAML (instead or as well as) >>>> plain text be welcomed? I'm thinking of a yaml file like the >>>> following: >>>> >>>> spec_file_1: >>>> file: spec/person_spec.rb >>>> specs: >>>> - should have first name >>>> - should provide email address >>>> >>>> spec_file_2: >>>> file: spec/client_spec.rb >>>> specs: >>>> - should have meeting on monday >>>> - should drink on friday >>>> >>>> >>>> Any thoughts? >>> >>> What benefit would this provide? >> >> It would only provide a benefit in a large spec suite, and as long as >> each spec file contains more than one describe/context block. >> > > What would we achieve with YAML that we can't do with plain text? It could also be in plain text. YAML is just generally more readable. Scott From aslak.hellesoy at gmail.com Wed Apr 11 11:40:04 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Apr 2007 17:40:04 +0200 Subject: [rspec-users] using YAML for --failures and --examples In-Reply-To: References: <98B1EBAE-6E9C-4D55-940C-4F9000C2BB2E@railsnewbie.com> <57c63afe0704101412h5c30e6ffwd47d1cca5658c3b1@mail.gmail.com> <8d961d900704110816m7086983ai8366498064c65578@mail.gmail.com> Message-ID: <8d961d900704110840n76bce805w76634fc88d044a1d@mail.gmail.com> On 4/11/07, Scott Taylor wrote: > > On Apr 11, 2007, at 11:16 AM, aslak hellesoy wrote: > > > On 4/11/07, Scott Taylor wrote: > >> > >> On Apr 10, 2007, at 5:12 PM, David Chelimsky wrote: > >> > >>> On 4/10/07, Scott Taylor wrote: > >>>> > >>>> As it is currently, in trunk, --failures and --examples except a > >>>> text > >>>> file, each line containing the name of a spec. > >>>> > >>>> I'm wondering: Would a a patch to use YAML (instead or as well as) > >>>> plain text be welcomed? I'm thinking of a yaml file like the > >>>> following: > >>>> > >>>> spec_file_1: > >>>> file: spec/person_spec.rb > >>>> specs: > >>>> - should have first name > >>>> - should provide email address > >>>> > >>>> spec_file_2: > >>>> file: spec/client_spec.rb > >>>> specs: > >>>> - should have meeting on monday > >>>> - should drink on friday > >>>> > >>>> > >>>> Any thoughts? > >>> > >>> What benefit would this provide? > >> > >> It would only provide a benefit in a large spec suite, and as long as > >> each spec file contains more than one describe/context block. > >> > > > > What would we achieve with YAML that we can't do with plain text? > > It could also be in plain text. YAML is just generally more readable. > The file is not meant to be read by humans, but by RSpec. And if you decide to read it, I would argue that plain text is *much* easier to read than YAML. Aslak > > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From julien.palmas at gmail.com Wed Apr 11 11:58:03 2007 From: julien.palmas at gmail.com (Julien Palmas) Date: Wed, 11 Apr 2007 17:58:03 +0200 Subject: [rspec-users] RSpec plugin for RadRails Message-ID: Hi, Is there already a plugin for RadRails that would support RSpec ? Thx Julien -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070411/1c9aca29/attachment.html From aslak.hellesoy at gmail.com Wed Apr 11 12:06:12 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Apr 2007 18:06:12 +0200 Subject: [rspec-users] RSpec plugin for RadRails In-Reply-To: References: Message-ID: <8d961d900704110906h60cb939cs8ca320f60c85dd71@mail.gmail.com> On 4/11/07, Julien Palmas wrote: > Hi, > > Is there already a plugin for RadRails that would support RSpec ? > Not to my knowledge, but I have outlined what needs to be done here: http://rspec.rubyforge.org/tools/extensions/editors/ Aslak > Thx > Julien > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bosshoff at gmail.com Wed Apr 11 12:30:56 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Wed, 11 Apr 2007 12:30:56 -0400 Subject: [rspec-users] Suggestion: put svn url under "Contribute" section of site Message-ID: <359ebde50704110930q11c8f685o2b604908e3817bd9@mail.gmail.com> Hello, I have been looking to submit a patch to RSpec, and I wanted to go about it the right way, so I loaded up http://rspec.rubyforge.org/contribute.html. The author of this page suggests that one should download from trunk to make any patches. It would be great if this section also included a url to the trunk. -Chris From aslak.hellesoy at gmail.com Wed Apr 11 12:43:37 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 11 Apr 2007 18:43:37 +0200 Subject: [rspec-users] Suggestion: put svn url under "Contribute" section of site In-Reply-To: <359ebde50704110930q11c8f685o2b604908e3817bd9@mail.gmail.com> References: <359ebde50704110930q11c8f685o2b604908e3817bd9@mail.gmail.com> Message-ID: <8d961d900704110943g4a421f9cn1d54a1c989a2aeb7@mail.gmail.com> On 4/11/07, Chris Hoffman wrote: > Hello, > I have been looking to submit a patch to RSpec, and I wanted to go > about it the right way, so I loaded up > http://rspec.rubyforge.org/contribute.html. The author of this page > suggests that one should download from trunk to make any patches. It > would be great if this section also included a url to the trunk. > The website of the next release will have it (svn://rubyforge.org/var/svn/rspec/trunk) Thanks! Aslak > -Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mlangenberg at gmail.com Wed Apr 11 15:03:28 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Wed, 11 Apr 2007 21:03:28 +0200 Subject: [rspec-users] redirection doesn't get detected well? Message-ID: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> I'm doing a redirect in one of my controller actions and somehow I can't spec it, see this pastie: http://pastie.caboo.se/53120. When following the link from a browser I'm being redirected to the right page. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070411/e6786c86/attachment.html From dchelimsky at gmail.com Wed Apr 11 15:29:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Apr 2007 14:29:30 -0500 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> Message-ID: <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> On 4/11/07, Matthijs Langenberg wrote: > I'm doing a redirect in one of my controller actions and somehow I can't > spec it, see this pastie: http://pastie.caboo.se/53120. > When following the link from a browser I'm being redirected to the right > page. First of all - nice example! Secondly, this looks like it should work. What's actually in the response? ... it "should destroy order_product with order_id==3 and product_id==6 and redirect to /orders/3." do @order_product.should_receive(:destroy) delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 puts response.inspect response.should be_redirect end ... > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mlangenberg at gmail.com Wed Apr 11 17:58:29 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Wed, 11 Apr 2007 23:58:29 +0200 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> Message-ID: <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> Thanks for the hint David, when I looked at response.body I saw the following HTML passing by:
OrderProduct expected :find with (:first, {:conditions=>
{:order_id=>3, :product_id=>6}}) but received it with (:first,
{:conditions=>{:order_id=>"3", :product_id=>"6"}})
Which makes totally sense since params["order_id"] and params["product_id"] indeed are String objects instead of Fixnum objects, however, shouldn't this expectation error raise earlier and make that expectation fail instead of the response.should be_redirect expectation? On 4/11/07, David Chelimsky wrote: > On 4/11/07, Matthijs Langenberg wrote: > > I'm doing a redirect in one of my controller actions and somehow I can't > > spec it, see this pastie: http://pastie.caboo.se/53120. > > When following the link from a browser I'm being redirected to the right > > page. > > First of all - nice example! > > Secondly, this looks like it should work. What's actually in the response? > > ... > it "should destroy order_product with order_id==3 and product_id==6 > and redirect to /orders/3." do > @order_product.should_receive(:destroy) > delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 > puts response.inspect > response.should be_redirect > 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 mtrier at eminentconsultinggroup.com Wed Apr 11 18:10:58 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Wed, 11 Apr 2007 18:10:58 -0400 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> Message-ID: <64419915-46B0-4729-939F-64B3771B0A75@eminentconsultinggroup.com> I ran into a similar issue due to the same issue and blogged about it here: http://blog.railsconsulting.com/2007/3/27/mocking-restful-routes I was going to originally respond to you and suggest that but since the first test didn't fail it threw me once again. Michael On Apr 11, 2007, at 5:58 PM, Matthijs Langenberg wrote: > Thanks for the hint David, when I looked at response.body I saw the > following HTML passing by: > >
OrderProduct expected :find with (:first, {:conditions=>
> {:order_id=>3, :product_id=>6}}) but received it with (:first,
> {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> > Which makes totally sense since params["order_id"] and > params["product_id"] indeed are String objects instead of Fixnum > objects, however, shouldn't this expectation error raise earlier and > make that expectation fail instead of the response.should be_redirect > expectation? > > On 4/11/07, David Chelimsky wrote: >> On 4/11/07, Matthijs Langenberg wrote: >>> I'm doing a redirect in one of my controller actions and somehow >>> I can't >>> spec it, see this pastie: http://pastie.caboo.se/53120. >>> When following the link from a browser I'm being redirected to >>> the right >>> page. >> >> First of all - nice example! >> >> Secondly, this looks like it should work. What's actually in the >> response? >> >> ... >> it "should destroy order_product with order_id==3 and product_id==6 >> and redirect to /orders/3." do >> @order_product.should_receive(:destroy) >> delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 >> puts response.inspect >> response.should be_redirect >> 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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Apr 11 18:16:09 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 00:16:09 +0200 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> Message-ID: <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> On 4/11/07, Matthijs Langenberg wrote: > Thanks for the hint David, when I looked at response.body I saw the > following HTML passing by: > >
OrderProduct expected :find with (:first, {:conditions=>
> {:order_id=>3, :product_id=>6}}) but received it with (:first,
> {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> > Which makes totally sense since params["order_id"] and > params["product_id"] indeed are String objects instead of Fixnum > objects, however, shouldn't this expectation error raise earlier and > make that expectation fail instead of the response.should be_redirect > expectation? RSpec doesn't invoke actions directly - it invokes them via Rails. Rails catches any exceptions that happen in a controller action and prints the backtrace to the response. Would it make sense if we found a way to at least let mock errors ripple through and back to RSpec? Aslak > > On 4/11/07, David Chelimsky wrote: > > On 4/11/07, Matthijs Langenberg wrote: > > > I'm doing a redirect in one of my controller actions and somehow I can't > > > spec it, see this pastie: http://pastie.caboo.se/53120. > > > When following the link from a browser I'm being redirected to the right > > > page. > > > > First of all - nice example! > > > > Secondly, this looks like it should work. What's actually in the response? > > > > ... > > it "should destroy order_product with order_id==3 and product_id==6 > > and redirect to /orders/3." do > > @order_product.should_receive(:destroy) > > delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 > > puts response.inspect > > response.should be_redirect > > 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Apr 11 18:19:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Apr 2007 17:19:13 -0500 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> Message-ID: <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> On 4/11/07, aslak hellesoy wrote: > On 4/11/07, Matthijs Langenberg wrote: > > Thanks for the hint David, when I looked at response.body I saw the > > following HTML passing by: > > > >
OrderProduct expected :find with (:first, {:conditions=>
> > {:order_id=>3, :product_id=>6}}) but received it with (:first,
> > {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> > > > Which makes totally sense since params["order_id"] and > > params["product_id"] indeed are String objects instead of Fixnum > > objects, however, shouldn't this expectation error raise earlier and > > make that expectation fail instead of the response.should be_redirect > > expectation? > > RSpec doesn't invoke actions directly - it invokes them via Rails. > Rails catches any exceptions that happen in a controller action and > prints the backtrace to the response. > > Would it make sense if we found a way to at least let mock errors > ripple through and back to RSpec? You mean monkey patch Rails to not catch mock failures? That sounds scary. > > Aslak > > > > > On 4/11/07, David Chelimsky wrote: > > > On 4/11/07, Matthijs Langenberg wrote: > > > > I'm doing a redirect in one of my controller actions and somehow I can't > > > > spec it, see this pastie: http://pastie.caboo.se/53120. > > > > When following the link from a browser I'm being redirected to the right > > > > page. > > > > > > First of all - nice example! > > > > > > Secondly, this looks like it should work. What's actually in the response? > > > > > > ... > > > it "should destroy order_product with order_id==3 and product_id==6 > > > and redirect to /orders/3." do > > > @order_product.should_receive(:destroy) > > > delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 > > > puts response.inspect > > > response.should be_redirect > > > 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 > > > > > _______________________________________________ > > 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 Wed Apr 11 18:26:39 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Thu, 12 Apr 2007 00:26:39 +0200 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> Message-ID: <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> I think that's the only way and it is quit simple: OrderProductsController.class_eval do def rescue_action(e) raise e end; end 1) Spec::Mocks::MockExpectationError in 'DELETE on /order_products?order_id=3&product_id=6 should destroy order_product with order_id==3 and product_id==6 and redirect to /orders/3.' OrderProduct expected :find with (:first, {:conditions=>{:order_id=>3, :product_id=>"6"}}) but received it with (:first, {:conditions=>{:order_id=>"3", :product_id=>"6"}}) /Users/mlangenberg/Documents/rails/pos/config/../app/controllers/order_products_controller.rb:3:in `destroy' ./spec/controllers/order_products_controller_spec.rb:17: Finished in 0.055156 seconds 1 example, 1 failure Now I wouldn't mind if the controller_name method does this type of monkeypatching, it saves me a lot of debugging. On 4/12/07, David Chelimsky wrote: > On 4/11/07, aslak hellesoy wrote: > > On 4/11/07, Matthijs Langenberg wrote: > > > Thanks for the hint David, when I looked at response.body I saw the > > > following HTML passing by: > > > > > >
OrderProduct expected :find with (:first, {:conditions=>
> > > {:order_id=>3, :product_id=>6}}) but received it with (:first,
> > > {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> > > > > > Which makes totally sense since params["order_id"] and > > > params["product_id"] indeed are String objects instead of Fixnum > > > objects, however, shouldn't this expectation error raise earlier and > > > make that expectation fail instead of the response.should be_redirect > > > expectation? > > > > RSpec doesn't invoke actions directly - it invokes them via Rails. > > Rails catches any exceptions that happen in a controller action and > > prints the backtrace to the response. > > > > Would it make sense if we found a way to at least let mock errors > > ripple through and back to RSpec? > > You mean monkey patch Rails to not catch mock failures? That sounds scary. > > > > > Aslak > > > > > > > > On 4/11/07, David Chelimsky wrote: > > > > On 4/11/07, Matthijs Langenberg wrote: > > > > > I'm doing a redirect in one of my controller actions and somehow I can't > > > > > spec it, see this pastie: http://pastie.caboo.se/53120. > > > > > When following the link from a browser I'm being redirected to the right > > > > > page. > > > > > > > > First of all - nice example! > > > > > > > > Secondly, this looks like it should work. What's actually in the response? > > > > > > > > ... > > > > it "should destroy order_product with order_id==3 and product_id==6 > > > > and redirect to /orders/3." do > > > > @order_product.should_receive(:destroy) > > > > delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 > > > > puts response.inspect > > > > response.should be_redirect > > > > 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 > > > > > > > _______________________________________________ > > > 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 Wed Apr 11 18:34:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Apr 2007 17:34:16 -0500 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> Message-ID: <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> On 4/11/07, Matthijs Langenberg wrote: > I think that's the only way and it is quit simple: > > OrderProductsController.class_eval do > def rescue_action(e) raise e end; > end > > 1) > Spec::Mocks::MockExpectationError in 'DELETE on > /order_products?order_id=3&product_id=6 should destroy order_product > with order_id==3 and product_id==6 and redirect to /orders/3.' > OrderProduct expected :find with (:first, {:conditions=>{:order_id=>3, > :product_id=>"6"}}) but received it with (:first, > {:conditions=>{:order_id=>"3", :product_id=>"6"}}) > /Users/mlangenberg/Documents/rails/pos/config/../app/controllers/order_products_controller.rb:3:in > `destroy' > ./spec/controllers/order_products_controller_spec.rb:17: > > Finished in 0.055156 seconds > > 1 example, 1 failure > > Now I wouldn't mind if the controller_name method does this type of > monkeypatching, it saves me a lot of debugging. Interestingly enough, we had that in there and it was recently removed: http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9767&atid=3149 We could make that configurable, but I certainly don't want to simply add it back in. WDYT? > > On 4/12/07, David Chelimsky wrote: > > On 4/11/07, aslak hellesoy wrote: > > > On 4/11/07, Matthijs Langenberg wrote: > > > > Thanks for the hint David, when I looked at response.body I saw the > > > > following HTML passing by: > > > > > > > >
OrderProduct expected :find with (:first, {:conditions=>
> > > > {:order_id=>3, :product_id=>6}}) but received it with (:first,
> > > > {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> > > > > > > > Which makes totally sense since params["order_id"] and > > > > params["product_id"] indeed are String objects instead of Fixnum > > > > objects, however, shouldn't this expectation error raise earlier and > > > > make that expectation fail instead of the response.should be_redirect > > > > expectation? > > > > > > RSpec doesn't invoke actions directly - it invokes them via Rails. > > > Rails catches any exceptions that happen in a controller action and > > > prints the backtrace to the response. > > > > > > Would it make sense if we found a way to at least let mock errors > > > ripple through and back to RSpec? > > > > You mean monkey patch Rails to not catch mock failures? That sounds scary. > > > > > > > > Aslak > > > > > > > > > > > On 4/11/07, David Chelimsky wrote: > > > > > On 4/11/07, Matthijs Langenberg wrote: > > > > > > I'm doing a redirect in one of my controller actions and somehow I can't > > > > > > spec it, see this pastie: http://pastie.caboo.se/53120. > > > > > > When following the link from a browser I'm being redirected to the right > > > > > > page. > > > > > > > > > > First of all - nice example! > > > > > > > > > > Secondly, this looks like it should work. What's actually in the response? > > > > > > > > > > ... > > > > > it "should destroy order_product with order_id==3 and product_id==6 > > > > > and redirect to /orders/3." do > > > > > @order_product.should_receive(:destroy) > > > > > delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 > > > > > puts response.inspect > > > > > response.should be_redirect > > > > > 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 > > > > > > > > > _______________________________________________ > > > > 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 mtrier at eminentconsultinggroup.com Wed Apr 11 18:52:13 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Wed, 11 Apr 2007 18:52:13 -0400 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> Message-ID: Isn't that how Test::Unit handles a similar situation? I think if we just know to add it if needed that should be enough. Or at least make it configurable. I agree that we probably don't want that magic happening without being aware of it. Michael On Apr 11, 2007, at 6:34 PM, David Chelimsky wrote: > On 4/11/07, Matthijs Langenberg wrote: >> I think that's the only way and it is quit simple: >> >> OrderProductsController.class_eval do >> def rescue_action(e) raise e end; >> end >> >> 1) >> Spec::Mocks::MockExpectationError in 'DELETE on >> /order_products?order_id=3&product_id=6 should destroy order_product >> with order_id==3 and product_id==6 and redirect to /orders/3.' >> OrderProduct expected :find with (:first, {:conditions=> >> {:order_id=>3, >> :product_id=>"6"}}) but received it with (:first, >> {:conditions=>{:order_id=>"3", :product_id=>"6"}}) >> /Users/mlangenberg/Documents/rails/pos/config/../app/controllers/ >> order_products_controller.rb:3:in >> `destroy' >> ./spec/controllers/order_products_controller_spec.rb:17: >> >> Finished in 0.055156 seconds >> >> 1 example, 1 failure >> >> Now I wouldn't mind if the controller_name method does this type of >> monkeypatching, it saves me a lot of debugging. > > Interestingly enough, we had that in there and it was recently > removed: > > http://rubyforge.org/tracker/? > func=detail&group_id=797&aid=9767&atid=3149 > > We could make that configurable, but I certainly don't want to simply > add it back in. WDYT? > >> >> On 4/12/07, David Chelimsky wrote: >>> On 4/11/07, aslak hellesoy wrote: >>>> On 4/11/07, Matthijs Langenberg wrote: >>>>> Thanks for the hint David, when I looked at response.body I saw >>>>> the >>>>> following HTML passing by: >>>>> >>>>>
OrderProduct expected :find with (:first, {:conditions=>
>>>>> {:order_id=>3, :product_id=>6}}) but received it with (:first,
>>>>> {:conditions=>{:order_id=>"3", :product_id=>"6"}})
>>>>> >>>>> Which makes totally sense since params["order_id"] and >>>>> params["product_id"] indeed are String objects instead of Fixnum >>>>> objects, however, shouldn't this expectation error raise >>>>> earlier and >>>>> make that expectation fail instead of the response.should >>>>> be_redirect >>>>> expectation? >>>> >>>> RSpec doesn't invoke actions directly - it invokes them via Rails. >>>> Rails catches any exceptions that happen in a controller action and >>>> prints the backtrace to the response. >>>> >>>> Would it make sense if we found a way to at least let mock errors >>>> ripple through and back to RSpec? >>> >>> You mean monkey patch Rails to not catch mock failures? That >>> sounds scary. >>> >>>> >>>> Aslak >>>> >>>>> >>>>> On 4/11/07, David Chelimsky wrote: >>>>>> On 4/11/07, Matthijs Langenberg wrote: >>>>>>> I'm doing a redirect in one of my controller actions and >>>>>>> somehow I can't >>>>>>> spec it, see this pastie: http://pastie.caboo.se/53120. >>>>>>> When following the link from a browser I'm being redirected >>>>>>> to the right >>>>>>> page. >>>>>> >>>>>> First of all - nice example! >>>>>> >>>>>> Secondly, this looks like it should work. What's actually in >>>>>> the response? >>>>>> >>>>>> ... >>>>>> it "should destroy order_product with order_id==3 and >>>>>> product_id==6 >>>>>> and redirect to /orders/3." do >>>>>> @order_product.should_receive(:destroy) >>>>>> delete 'destroy', :id => 'nil', :order_id => >>>>>> 3, :product_id => 6 >>>>>> puts response.inspect >>>>>> response.should be_redirect >>>>>> 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 >>>>>> >>>>> _______________________________________________ >>>>> 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 mlangenberg at gmail.com Wed Apr 11 19:13:48 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Thu, 12 Apr 2007 01:13:48 +0200 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> Message-ID: <27c0ac6d0704111613u30d1a954md9abbc96916f37c3@mail.gmail.com> That's indeed just how Test::Unit is handeling this situation. I think that there are two options for this problem, the first is to enhance the rspec_controller generator to add the class eval code in the controller_spec.rb file, just like rails with Test::Unit does. While writing your specs, you see that the method is being monkey patched and if it gets in your way, you remove it yourself and know that rails errors do not raise. The second one requires some more work, but can be a smarter solution: we check if the method is already defined in the controller, if it isn't we can "safely" monkeypatch it. When it is already defined, we don't monkeypatch the controller, but do print a warning about not being able to catch exceptions raised by the action. On 4/12/07, Michael Trier wrote: > Isn't that how Test::Unit handles a similar situation? I think if we > just know to add it if needed that should be enough. Or at least > make it configurable. I agree that we probably don't want that magic > happening without being aware of it. > > Michael > > On Apr 11, 2007, at 6:34 PM, David Chelimsky wrote: > > > On 4/11/07, Matthijs Langenberg wrote: > >> I think that's the only way and it is quit simple: > >> > >> OrderProductsController.class_eval do > >> def rescue_action(e) raise e end; > >> end > >> > >> 1) > >> Spec::Mocks::MockExpectationError in 'DELETE on > >> /order_products?order_id=3&product_id=6 should destroy order_product > >> with order_id==3 and product_id==6 and redirect to /orders/3.' > >> OrderProduct expected :find with (:first, {:conditions=> > >> {:order_id=>3, > >> :product_id=>"6"}}) but received it with (:first, > >> {:conditions=>{:order_id=>"3", :product_id=>"6"}}) > >> /Users/mlangenberg/Documents/rails/pos/config/../app/controllers/ > >> order_products_controller.rb:3:in > >> `destroy' > >> ./spec/controllers/order_products_controller_spec.rb:17: > >> > >> Finished in 0.055156 seconds > >> > >> 1 example, 1 failure > >> > >> Now I wouldn't mind if the controller_name method does this type of > >> monkeypatching, it saves me a lot of debugging. > > > > Interestingly enough, we had that in there and it was recently > > removed: > > > > http://rubyforge.org/tracker/? > > func=detail&group_id=797&aid=9767&atid=3149 > > > > We could make that configurable, but I certainly don't want to simply > > add it back in. WDYT? > > > >> > >> On 4/12/07, David Chelimsky wrote: > >>> On 4/11/07, aslak hellesoy wrote: > >>>> On 4/11/07, Matthijs Langenberg wrote: > >>>>> Thanks for the hint David, when I looked at response.body I saw > >>>>> the > >>>>> following HTML passing by: > >>>>> > >>>>>
OrderProduct expected :find with (:first, {:conditions=>
> >>>>> {:order_id=>3, :product_id=>6}}) but received it with (:first,
> >>>>> {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> >>>>> > >>>>> Which makes totally sense since params["order_id"] and > >>>>> params["product_id"] indeed are String objects instead of Fixnum > >>>>> objects, however, shouldn't this expectation error raise > >>>>> earlier and > >>>>> make that expectation fail instead of the response.should > >>>>> be_redirect > >>>>> expectation? > >>>> > >>>> RSpec doesn't invoke actions directly - it invokes them via Rails. > >>>> Rails catches any exceptions that happen in a controller action and > >>>> prints the backtrace to the response. > >>>> > >>>> Would it make sense if we found a way to at least let mock errors > >>>> ripple through and back to RSpec? > >>> > >>> You mean monkey patch Rails to not catch mock failures? That > >>> sounds scary. > >>> > >>>> > >>>> Aslak > >>>> > >>>>> > >>>>> On 4/11/07, David Chelimsky wrote: > >>>>>> On 4/11/07, Matthijs Langenberg wrote: > >>>>>>> I'm doing a redirect in one of my controller actions and > >>>>>>> somehow I can't > >>>>>>> spec it, see this pastie: http://pastie.caboo.se/53120. > >>>>>>> When following the link from a browser I'm being redirected > >>>>>>> to the right > >>>>>>> page. > >>>>>> > >>>>>> First of all - nice example! > >>>>>> > >>>>>> Secondly, this looks like it should work. What's actually in > >>>>>> the response? > >>>>>> > >>>>>> ... > >>>>>> it "should destroy order_product with order_id==3 and > >>>>>> product_id==6 > >>>>>> and redirect to /orders/3." do > >>>>>> @order_product.should_receive(:destroy) > >>>>>> delete 'destroy', :id => 'nil', :order_id => > >>>>>> 3, :product_id => 6 > >>>>>> puts response.inspect > >>>>>> response.should be_redirect > >>>>>> 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 > >>>>>> > >>>>> _______________________________________________ > >>>>> 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 aslak.hellesoy at gmail.com Wed Apr 11 19:44:44 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 01:44:44 +0200 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> Message-ID: <8d961d900704111644s1b4de6c2rae6745609c621d8d@mail.gmail.com> On 4/12/07, David Chelimsky wrote: > On 4/11/07, Matthijs Langenberg wrote: > > I think that's the only way and it is quit simple: > > > > OrderProductsController.class_eval do > > def rescue_action(e) raise e end; > > end > > > > 1) > > Spec::Mocks::MockExpectationError in 'DELETE on > > /order_products?order_id=3&product_id=6 should destroy order_product > > with order_id==3 and product_id==6 and redirect to /orders/3.' > > OrderProduct expected :find with (:first, {:conditions=>{:order_id=>3, > > :product_id=>"6"}}) but received it with (:first, > > {:conditions=>{:order_id=>"3", :product_id=>"6"}}) > > /Users/mlangenberg/Documents/rails/pos/config/../app/controllers/order_products_controller.rb:3:in > > `destroy' > > ./spec/controllers/order_products_controller_spec.rb:17: > > > > Finished in 0.055156 seconds > > > > 1 example, 1 failure > > > > Now I wouldn't mind if the controller_name method does this type of > > monkeypatching, it saves me a lot of debugging. > > Interestingly enough, we had that in there and it was recently removed: > > http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9767&atid=3149 > > We could make that configurable, but I certainly don't want to simply > add it back in. WDYT? > I'm working on adding it back in - this time a little smarter. It will only reraise the exception if it is a mock exception, otherwise it will be handled by Rails. Makes sense? Aslak > > > > On 4/12/07, David Chelimsky wrote: > > > On 4/11/07, aslak hellesoy wrote: > > > > On 4/11/07, Matthijs Langenberg wrote: > > > > > Thanks for the hint David, when I looked at response.body I saw the > > > > > following HTML passing by: > > > > > > > > > >
OrderProduct expected :find with (:first, {:conditions=>
> > > > > {:order_id=>3, :product_id=>6}}) but received it with (:first,
> > > > > {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> > > > > > > > > > Which makes totally sense since params["order_id"] and > > > > > params["product_id"] indeed are String objects instead of Fixnum > > > > > objects, however, shouldn't this expectation error raise earlier and > > > > > make that expectation fail instead of the response.should be_redirect > > > > > expectation? > > > > > > > > RSpec doesn't invoke actions directly - it invokes them via Rails. > > > > Rails catches any exceptions that happen in a controller action and > > > > prints the backtrace to the response. > > > > > > > > Would it make sense if we found a way to at least let mock errors > > > > ripple through and back to RSpec? > > > > > > You mean monkey patch Rails to not catch mock failures? That sounds scary. > > > > > > > > > > > Aslak > > > > > > > > > > > > > > On 4/11/07, David Chelimsky wrote: > > > > > > On 4/11/07, Matthijs Langenberg wrote: > > > > > > > I'm doing a redirect in one of my controller actions and somehow I can't > > > > > > > spec it, see this pastie: http://pastie.caboo.se/53120. > > > > > > > When following the link from a browser I'm being redirected to the right > > > > > > > page. > > > > > > > > > > > > First of all - nice example! > > > > > > > > > > > > Secondly, this looks like it should work. What's actually in the response? > > > > > > > > > > > > ... > > > > > > it "should destroy order_product with order_id==3 and product_id==6 > > > > > > and redirect to /orders/3." do > > > > > > @order_product.should_receive(:destroy) > > > > > > delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6 > > > > > > puts response.inspect > > > > > > response.should be_redirect > > > > > > 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 > > > > > > > > > > > _______________________________________________ > > > > > 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 mtrier at eminentconsultinggroup.com Wed Apr 11 19:46:44 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Wed, 11 Apr 2007 19:46:44 -0400 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <8d961d900704111644s1b4de6c2rae6745609c621d8d@mail.gmail.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> <8d961d900704111644s1b4de6c2rae6745609c621d8d@mail.gmail.com> Message-ID: <251B8073-F345-4C2A-8DEA-2E7E35F4FABA@eminentconsultinggroup.com> On Apr 11, 2007, at 7:44 PM, aslak hellesoy wrote: > On 4/12/07, David Chelimsky wrote: >> On 4/11/07, Matthijs Langenberg wrote: >>> I think that's the only way and it is quit simple: >>> >>> OrderProductsController.class_eval do >>> def rescue_action(e) raise e end; >>> end >>> >>> 1) >>> Spec::Mocks::MockExpectationError in 'DELETE on >>> /order_products?order_id=3&product_id=6 should destroy order_product >>> with order_id==3 and product_id==6 and redirect to /orders/3.' >>> OrderProduct expected :find with (:first, {:conditions=> >>> {:order_id=>3, >>> :product_id=>"6"}}) but received it with (:first, >>> {:conditions=>{:order_id=>"3", :product_id=>"6"}}) >>> /Users/mlangenberg/Documents/rails/pos/config/../app/controllers/ >>> order_products_controller.rb:3:in >>> `destroy' >>> ./spec/controllers/order_products_controller_spec.rb:17: >>> >>> Finished in 0.055156 seconds >>> >>> 1 example, 1 failure >>> >>> Now I wouldn't mind if the controller_name method does this type of >>> monkeypatching, it saves me a lot of debugging. >> >> Interestingly enough, we had that in there and it was recently >> removed: >> >> http://rubyforge.org/tracker/? >> func=detail&group_id=797&aid=9767&atid=3149 >> >> We could make that configurable, but I certainly don't want to simply >> add it back in. WDYT? >> > > I'm working on adding it back in - this time a little smarter. It will > only reraise the exception if it is a mock exception, otherwise it > will be handled by Rails. > > Makes sense? Sounds good. Thanks aslak. This will help out a lot. Michael >>> >>> On 4/12/07, David Chelimsky wrote: >>>> On 4/11/07, aslak hellesoy wrote: >>>>> On 4/11/07, Matthijs Langenberg wrote: >>>>>> Thanks for the hint David, when I looked at response.body I >>>>>> saw the >>>>>> following HTML passing by: >>>>>> >>>>>>
OrderProduct expected :find with (:first, {:conditions=>
>>>>>> {:order_id=>3, :product_id=>6}}) but received it with (:first,
>>>>>> {:conditions=>{:order_id=>"3", :product_id=>"6"}})
>>>>>> >>>>>> Which makes totally sense since params["order_id"] and >>>>>> params["product_id"] indeed are String objects instead of Fixnum >>>>>> objects, however, shouldn't this expectation error raise >>>>>> earlier and >>>>>> make that expectation fail instead of the response.should >>>>>> be_redirect >>>>>> expectation? >>>>> >>>>> RSpec doesn't invoke actions directly - it invokes them via Rails. >>>>> Rails catches any exceptions that happen in a controller action >>>>> and >>>>> prints the backtrace to the response. >>>>> >>>>> Would it make sense if we found a way to at least let mock errors >>>>> ripple through and back to RSpec? >>>> >>>> You mean monkey patch Rails to not catch mock failures? That >>>> sounds scary. >>>> >>>>> >>>>> Aslak >>>>> >>>>>> >>>>>> On 4/11/07, David Chelimsky wrote: >>>>>>> On 4/11/07, Matthijs Langenberg wrote: >>>>>>>> I'm doing a redirect in one of my controller actions and >>>>>>>> somehow I can't >>>>>>>> spec it, see this pastie: http://pastie.caboo.se/53120. >>>>>>>> When following the link from a browser I'm being redirected >>>>>>>> to the right >>>>>>>> page. >>>>>>> >>>>>>> First of all - nice example! >>>>>>> >>>>>>> Secondly, this looks like it should work. What's actually in >>>>>>> the response? >>>>>>> >>>>>>> ... >>>>>>> it "should destroy order_product with order_id==3 and >>>>>>> product_id==6 >>>>>>> and redirect to /orders/3." do >>>>>>> @order_product.should_receive(:destroy) >>>>>>> delete 'destroy', :id => 'nil', :order_id => >>>>>>> 3, :product_id => 6 >>>>>>> puts response.inspect >>>>>>> response.should be_redirect >>>>>>> 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 >>>>>>> >>>>>> _______________________________________________ >>>>>> 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 mailing_lists at railsnewbie.com Wed Apr 11 19:56:24 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 11 Apr 2007 19:56:24 -0400 Subject: [rspec-users] Suggestion: put svn url under "Contribute" section of site In-Reply-To: <8d961d900704110943g4a421f9cn1d54a1c989a2aeb7@mail.gmail.com> References: <359ebde50704110930q11c8f685o2b604908e3817bd9@mail.gmail.com> <8d961d900704110943g4a421f9cn1d54a1c989a2aeb7@mail.gmail.com> Message-ID: I think you should also include that patches should be submitted through the tracker (if it doesn't already say so), and that the patch file should come by running svn diff > patchfile in the trunk dir. Scott On Apr 11, 2007, at 12:43 PM, aslak hellesoy wrote: > On 4/11/07, Chris Hoffman wrote: >> Hello, >> I have been looking to submit a patch to RSpec, and I wanted to go >> about it the right way, so I loaded up >> http://rspec.rubyforge.org/contribute.html. The author of this page >> suggests that one should download from trunk to make any patches. It >> would be great if this section also included a url to the trunk. >> > > The website of the next release will have it > (svn://rubyforge.org/var/svn/rspec/trunk) > > Thanks! > Aslak > >> -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 aslak.hellesoy at gmail.com Wed Apr 11 20:10:09 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 02:10:09 +0200 Subject: [rspec-users] Suggestion: put svn url under "Contribute" section of site In-Reply-To: References: <359ebde50704110930q11c8f685o2b604908e3817bd9@mail.gmail.com> <8d961d900704110943g4a421f9cn1d54a1c989a2aeb7@mail.gmail.com> Message-ID: <8d961d900704111710k15d1dc43wfe8d0d2f40415d4@mail.gmail.com> On 4/12/07, Scott Taylor wrote: > > I think you should also include that patches should be submitted > through the tracker (if it doesn't already say so), and that the > patch file should come by running > > svn diff > patchfile > > in the trunk dir. > > Scott > Yep, I added that too, plus a reminder to check that damned checkbox. Aslak > > On Apr 11, 2007, at 12:43 PM, aslak hellesoy wrote: > > > On 4/11/07, Chris Hoffman wrote: > >> Hello, > >> I have been looking to submit a patch to RSpec, and I wanted to go > >> about it the right way, so I loaded up > >> http://rspec.rubyforge.org/contribute.html. The author of this page > >> suggests that one should download from trunk to make any patches. It > >> would be great if this section also included a url to the trunk. > >> > > > > The website of the next release will have it > > (svn://rubyforge.org/var/svn/rspec/trunk) > > > > Thanks! > > Aslak > > > >> -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 aslak.hellesoy at gmail.com Wed Apr 11 20:13:52 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 02:13:52 +0200 Subject: [rspec-users] redirection doesn't get detected well? In-Reply-To: <251B8073-F345-4C2A-8DEA-2E7E35F4FABA@eminentconsultinggroup.com> References: <27c0ac6d0704111203u4614c8cn31fe646f77f382a7@mail.gmail.com> <57c63afe0704111229n13b1e669n2e4f7fa7253b71df@mail.gmail.com> <27c0ac6d0704111458l845684bxf486c6f42b4907bd@mail.gmail.com> <8d961d900704111516t26097a2aj72090ce45b6033d6@mail.gmail.com> <57c63afe0704111519u2fe2f928oaa92ee68ecdd5210@mail.gmail.com> <27c0ac6d0704111526y3a431405w5c2884d1ae69077b@mail.gmail.com> <57c63afe0704111534j49de525et7df5426fcbadd3d0@mail.gmail.com> <8d961d900704111644s1b4de6c2rae6745609c621d8d@mail.gmail.com> <251B8073-F345-4C2A-8DEA-2E7E35F4FABA@eminentconsultinggroup.com> Message-ID: <8d961d900704111713m69adfe5fg9e1af5751c3d49ff@mail.gmail.com> On 4/12/07, Michael Trier wrote: > On Apr 11, 2007, at 7:44 PM, aslak hellesoy wrote: > > > On 4/12/07, David Chelimsky wrote: > >> On 4/11/07, Matthijs Langenberg wrote: > >>> I think that's the only way and it is quit simple: > >>> > >>> OrderProductsController.class_eval do > >>> def rescue_action(e) raise e end; > >>> end > >>> > >>> 1) > >>> Spec::Mocks::MockExpectationError in 'DELETE on > >>> /order_products?order_id=3&product_id=6 should destroy order_product > >>> with order_id==3 and product_id==6 and redirect to /orders/3.' > >>> OrderProduct expected :find with (:first, {:conditions=> > >>> {:order_id=>3, > >>> :product_id=>"6"}}) but received it with (:first, > >>> {:conditions=>{:order_id=>"3", :product_id=>"6"}}) > >>> /Users/mlangenberg/Documents/rails/pos/config/../app/controllers/ > >>> order_products_controller.rb:3:in > >>> `destroy' > >>> ./spec/controllers/order_products_controller_spec.rb:17: > >>> > >>> Finished in 0.055156 seconds > >>> > >>> 1 example, 1 failure > >>> > >>> Now I wouldn't mind if the controller_name method does this type of > >>> monkeypatching, it saves me a lot of debugging. > >> > >> Interestingly enough, we had that in there and it was recently > >> removed: > >> > >> http://rubyforge.org/tracker/? > >> func=detail&group_id=797&aid=9767&atid=3149 > >> > >> We could make that configurable, but I certainly don't want to simply > >> add it back in. WDYT? > >> > > > > I'm working on adding it back in - this time a little smarter. It will > > only reraise the exception if it is a mock exception, otherwise it > > will be handled by Rails. > > > > Makes sense? > > Sounds good. Thanks aslak. This will help out a lot. > Ok, it's on the trunk. That should get rid of those red(irection) herrings! Aslak > Michael > > >>> > >>> On 4/12/07, David Chelimsky wrote: > >>>> On 4/11/07, aslak hellesoy wrote: > >>>>> On 4/11/07, Matthijs Langenberg wrote: > >>>>>> Thanks for the hint David, when I looked at response.body I > >>>>>> saw the > >>>>>> following HTML passing by: > >>>>>> > >>>>>>
OrderProduct expected :find with (:first, {:conditions=>
> >>>>>> {:order_id=>3, :product_id=>6}}) but received it with (:first,
> >>>>>> {:conditions=>{:order_id=>"3", :product_id=>"6"}})
> >>>>>> > >>>>>> Which makes totally sense since params["order_id"] and > >>>>>> params["product_id"] indeed are String objects instead of Fixnum > >>>>>> objects, however, shouldn't this expectation error raise > >>>>>> earlier and > >>>>>> make that expectation fail instead of the response.should > >>>>>> be_redirect > >>>>>> expectation? > >>>>> > >>>>> RSpec doesn't invoke actions directly - it invokes them via Rails. > >>>>> Rails catches any exceptions that happen in a controller action > >>>>> and > >>>>> prints the backtrace to the response. > >>>>> > >>>>> Would it make sense if we found a way to at least let mock errors > >>>>> ripple through and back to RSpec? > >>>> > >>>> You mean monkey patch Rails to not catch mock failures? That > >>>> sounds scary. > >>>> > >>>>> > >>>>> Aslak > >>>>> > >>>>>> > >>>>>> On 4/11/07, David Chelimsky wrote: > >>>>>>> On 4/11/07, Matthijs Langenberg wrote: > >>>>>>>> I'm doing a redirect in one of my controller actions and > >>>>>>>> somehow I can't > >>>>>>>> spec it, see this pastie: http://pastie.caboo.se/53120. > >>>>>>>> When following the link from a browser I'm being redirected > >>>>>>>> to the right > >>>>>>>> page. > >>>>>>> > >>>>>>> First of all - nice example! > >>>>>>> > >>>>>>> Secondly, this looks like it should work. What's actually in > >>>>>>> the response? > >>>>>>> > >>>>>>> ... > >>>>>>> it "should destroy order_product with order_id==3 and > >>>>>>> product_id==6 > >>>>>>> and redirect to /orders/3." do > >>>>>>> @order_product.should_receive(:destroy) > >>>>>>> delete 'destroy', :id => 'nil', :order_id => > >>>>>>> 3, :product_id => 6 > >>>>>>> puts response.inspect > >>>>>>> response.should be_redirect > >>>>>>> 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 > >>>>>>> > >>>>>> _______________________________________________ > >>>>>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matttemp at gmail.com Wed Apr 11 23:00:08 2007 From: matttemp at gmail.com (Matt Aimonetti) Date: Wed, 11 Apr 2007 20:00:08 -0700 Subject: [rspec-users] RSpec plugin for RadRails In-Reply-To: <8d961d900704110906h60cb939cs8ca320f60c85dd71@mail.gmail.com> References: <8d961d900704110906h60cb939cs8ca320f60c85dd71@mail.gmail.com> Message-ID: Julien, RadRails is not developed anymore and is being merged with Aptana http://www.aptana.com/ You might want to contact them and provide them with the info Aslak gave you. (or you might want to actually write the plugin yourself ;) ) Matt On 4/11/07, aslak hellesoy wrote: > > On 4/11/07, Julien Palmas wrote: > > Hi, > > > > Is there already a plugin for RadRails that would support RSpec ? > > > > Not to my knowledge, but I have outlined what needs to be done here: > http://rspec.rubyforge.org/tools/extensions/editors/ > > Aslak > > > Thx > > Julien > > > > _______________________________________________ > > 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/20070411/f1a9011b/attachment-0001.html From mailing_lists at railsnewbie.com Thu Apr 12 01:33:37 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 12 Apr 2007 01:33:37 -0400 Subject: [rspec-users] dumping data to yaml in specs Message-ID: <7C3068CC-6233-46F5-AD8C-1649D0BB77C3@railsnewbie.com> I'm wondering whether I could dump out an object to yaml if a certain spec fails. I believe you can do this sort of thing in test unit. E.g.: hash_one.should == hash_two if_failed? hash_two.to_yaml Scott From julien.palmas at gmail.com Thu Apr 12 03:38:18 2007 From: julien.palmas at gmail.com (Julien Palmas) Date: Thu, 12 Apr 2007 09:38:18 +0200 Subject: [rspec-users] RSpec plugin for RadRails Message-ID: I was thinking about writing it myself actually ;-) Thing is, I use TextMate at home, but have to work on a PC for my job, and RadRails (now aptana) is the best alternative I've found (quite a good app by the way). So I'll have to learn have to write a plugin now. If I come out with something usable, I'll let the list know ! Cheers, Julien -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070412/cb02e8fc/attachment.html From pezlists at gmail.com Thu Apr 12 04:12:23 2007 From: pezlists at gmail.com (Perryn Fowler) Date: Thu, 12 Apr 2007 18:12:23 +1000 Subject: [rspec-users] rspec on rails: undefined method 'controller_name' In-Reply-To: <1c319b810704120111l56571ff1n4539c7699369f7e9@mail.gmail.com> References: <1c319b810704120111l56571ff1n4539c7699369f7e9@mail.gmail.com> Message-ID: <1c319b810704120112j37f26a20kf99c27d3ca9922f6@mail.gmail.com> Im trying to write a controller spec, but when I run it I get an error like the one below. I found Bug6707 (http://rubyforge.org/pipermail/rspec-devel/2007-March/002147.html ), but I get the error no matter how I run the spec ( whether I use rake or not) Any ideas? I am using 0.8.2 The Error: C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectati ons/sugar.rb:14:in `call': undefined method `controller_name' for # (NoMethodError) from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- 0.8.2 /lib/s pec/expectations/sugar.rb:14:in `_method_missing' from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2 /lib/s pec/expectations/sugar.rb:10:in `method_missing' from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- 0.8.2 /lib/s pec/runner/context_eval.rb:47:in `method_missing' from ./spec/functional/booking_sheet_spec.rb:4 from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2 /lib/s pec/runner/context.rb:14:in `class_eval' from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2 /lib/s pec/runner/context.rb:14:in `initialize' from C:/dev/teetime/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/ context_factory.rb:37:in `new' from C:/dev/teetime/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/ context_factory.rb:37:in `create' from C:/dev/teetime/vendor/plugins/rspec_on_rails/lib/spec/rails/extensi ons/kernel.rb:4:in `context' from ./spec/functional/booking_sheet_spec.rb:3 from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2 /lib/s pec/runner/command_line.rb:24:in `load' from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- 0.8.2 /lib/s pec/runner/command_line.rb:24:in `run' from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2 /lib/s pec/runner/command_line.rb:18:in `each' from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- 0.8.2 /lib/s pec/runner/command_line.rb:18:in `run' from C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2 /bin/s pec:4 from C:/rails/InstantRails/ruby/bin/spec:18:in `load' from C:/rails/InstantRails/ruby/bin/spec:18 -- ----------------------- Perryn Fowler ThoughtWorks -- ----------------------- Perryn Fowler ThoughtWorks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070412/1a73ff0f/attachment.html From aslak.hellesoy at gmail.com Thu Apr 12 05:30:34 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 11:30:34 +0200 Subject: [rspec-users] rspec on rails: undefined method 'controller_name' In-Reply-To: <1c319b810704120112j37f26a20kf99c27d3ca9922f6@mail.gmail.com> References: <1c319b810704120111l56571ff1n4539c7699369f7e9@mail.gmail.com> <1c319b810704120112j37f26a20kf99c27d3ca9922f6@mail.gmail.com> Message-ID: <8d961d900704120230g170c33a4s4d13adbbe1eb93a5@mail.gmail.com> On 4/12/07, Perryn Fowler wrote: > > > Im trying to write a controller spec, but when I run it I get an error like > the one below. > > I found Bug6707 ( > http://rubyforge.org/pipermail/rspec-devel/2007-March/002147.html > ), but I get the error no matter how I run the spec > ( whether I use rake or not) > > Any ideas? > > I am using 0.8.2 > > The Error: > Hi Perryn, I haven't tried to dig into this to find the error, but could you please try with RSpec 0.9.0 beta1? http://www.nabble.com/ANN:-RSpec-0.9.0-beta-1-available-for-download.-t3526973.html Cheers, Aslak > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectati > ons/sugar.rb:14:in `call': undefined method `controller_name' for > # ::ContextEvalModule:0x35e6a98> (NoMethodError) > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/s > pec/expectations/sugar.rb:14:in `_method_missing' > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/s > pec/expectations/sugar.rb:10:in `method_missing' > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/s > pec/runner/context_eval.rb:47:in `method_missing' > from ./spec/functional/booking_sheet_spec.rb:4 > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/s > pec/runner/context.rb:14:in `class_eval' > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/s > pec/runner/context.rb:14:in `initialize' > from > C:/dev/teetime/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/ > context_factory.rb:37:in `new' > from > C:/dev/teetime/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/ > context_factory.rb:37:in `create' > from > C:/dev/teetime/vendor/plugins/rspec_on_rails/lib/spec/rails/extensi > ons/kernel.rb:4:in `context' > from ./spec/functional/booking_sheet_spec.rb:3 > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/s > pec/runner/command_line.rb:24:in `load' > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/s > pec/runner/command_line.rb:24:in `run' > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/s > pec/runner/command_line.rb:18:in `each' > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/s > pec/runner/command_line.rb:18:in `run' > from > C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/s > pec:4 > from C:/rails/InstantRails/ruby/bin/spec:18:in > `load' > from C:/rails/InstantRails/ruby/bin/spec:18 > > > -- > ----------------------- > Perryn Fowler > ThoughtWorks > > -- > ----------------------- > Perryn Fowler > ThoughtWorks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bosshoff at gmail.com Thu Apr 12 08:55:12 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Thu, 12 Apr 2007 08:55:12 -0400 Subject: [rspec-users] Test if view renders appropriate partial? Message-ID: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> Hello, I am testing out a partial that calls another, general purpose partial as part of its processing. Is there a class I can mock in Rails views to accomplish what I need? That is, could I do something like the following: SomeClass.should_receive(:render).with(:partial => "foo", :locals => { :bars => bars }) I tried breakpointing the view, and it looks like I am greeted by an anonymous class, which I am unsure how to mock. Thanks for the help. -Chris From aslak.hellesoy at gmail.com Thu Apr 12 09:19:12 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 15:19:12 +0200 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> Message-ID: <8d961d900704120619q428fb673xc152a8a873a3260b@mail.gmail.com> On 4/12/07, Chris Hoffman wrote: > Hello, > I am testing out a partial that calls another, general purpose > partial as part of its processing. Is there a class I can mock in > Rails views to accomplish what I need? That is, could I do something > like the following: > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > :bars => bars }) > > I tried breakpointing the view, and it looks like I am greeted by an > anonymous class, which I am unsure how to mock. Thanks for the help. > Do you mean like this? http://jakescruggs.blogspot.com/2007/04/stubbingmocking-partial-within-partial.html > -Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 12 09:20:01 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Apr 2007 08:20:01 -0500 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> Message-ID: <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> On 4/12/07, Chris Hoffman wrote: > Hello, > I am testing out a partial that calls another, general purpose > partial as part of its processing. Is there a class I can mock in > Rails views to accomplish what I need? That is, could I do something > like the following: > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > :bars => bars }) What you're interested in is the #render_partial instance method defined in ActionView::Base. The problem is that you need that method to work as expected the first time (to render the outer partial) and mock only the second call (to render the nested partial). There is no support for turning mock methods on and off midstream, so you'd have to do something like this: controller.template.should_receive(:render).with(#opts for outer partial) do #duplicate here what the method actually does in order to render the outer end controller.template.should_receive(:render).with(#opts for inner partial) Of course you're duplicating rails code in your specs to do this, which is bad, but I think it's the best option. Give a shot and let us know how it works. David > > I tried breakpointing the view, and it looks like I am greeted by an > anonymous class, which I am unsure how to mock. Thanks for the help. > > -Chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 12 09:22:20 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Apr 2007 08:22:20 -0500 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <8d961d900704120619q428fb673xc152a8a873a3260b@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <8d961d900704120619q428fb673xc152a8a873a3260b@mail.gmail.com> Message-ID: <57c63afe0704120622t5cdda6c3hce4e0aaded723332@mail.gmail.com> On 4/12/07, aslak hellesoy wrote: > On 4/12/07, Chris Hoffman wrote: > > Hello, > > I am testing out a partial that calls another, general purpose > > partial as part of its processing. Is there a class I can mock in > > Rails views to accomplish what I need? That is, could I do something > > like the following: > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > :bars => bars }) > > > > I tried breakpointing the view, and it looks like I am greeted by an > > anonymous class, which I am unsure how to mock. Thanks for the help. > > > > Do you mean like this? > http://jakescruggs.blogspot.com/2007/04/stubbingmocking-partial-within-partial.html Much better than what I proposed! > > > -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 bosshoff at gmail.com Thu Apr 12 10:22:42 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Thu, 12 Apr 2007 10:22:42 -0400 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> Message-ID: <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> Hello, Well, that site ostensibly showcases just the syntax I need to pull off what I'm looking for, but I am unable to get it working. In fact, I fail to see how stubbing out 'render' under @controller.template could possibly work, given David's discourse above. Has anyone here actually tried the code in this post? -Chris On 4/12/07, David Chelimsky wrote: > On 4/12/07, Chris Hoffman wrote: > > Hello, > > I am testing out a partial that calls another, general purpose > > partial as part of its processing. Is there a class I can mock in > > Rails views to accomplish what I need? That is, could I do something > > like the following: > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > :bars => bars }) > > What you're interested in is the #render_partial instance method > defined in ActionView::Base. > > The problem is that you need that method to work as expected the first > time (to render the outer partial) and mock only the second call (to > render the nested partial). There is no support for turning mock > methods on and off midstream, so you'd have to do something like this: > > controller.template.should_receive(:render).with(#opts for outer partial) do > #duplicate here what the method actually does in order to render the outer > end > > controller.template.should_receive(:render).with(#opts for inner partial) > > Of course you're duplicating rails code in your specs to do this, > which is bad, but I think it's the best option. Give a shot and let us > know how it works. > > David > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > anonymous class, which I am unsure how to mock. Thanks for the 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 > From dchelimsky at gmail.com Thu Apr 12 11:07:07 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Apr 2007 10:07:07 -0500 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> Message-ID: <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> On 4/12/07, Chris Hoffman wrote: > Hello, > Well, that site ostensibly showcases just the syntax I need to pull > off what I'm looking for, but I am unable to get it working. In fact, > I fail to see how stubbing out 'render' under @controller.template > could possibly work, given David's discourse above. > Has anyone here actually tried the code in this post? > > -Chris I just got this working: #spec/views/thing/outer_partial_rhtml_spec.rb require File.dirname(__FILE__) + '/../../spec_helper' describe "/thing/_outer_partial" do it "should render inner_partial" do @controller.template.should_receive(:render).with(:partial => "inner_partial") @controller.template.should_receive(:render).with(:partial => "other_inner_partial") render 'thing/_outer_partial' end end #app/views/thing/thing/_outer_partial.rhtml <%= render :partial => "inner_partial" %> <%= render :partial => "other_inner_partial" %> This works just fine. Is there something you're trying to do that this example is missing? > > On 4/12/07, David Chelimsky wrote: > > On 4/12/07, Chris Hoffman wrote: > > > Hello, > > > I am testing out a partial that calls another, general purpose > > > partial as part of its processing. Is there a class I can mock in > > > Rails views to accomplish what I need? That is, could I do something > > > like the following: > > > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > > :bars => bars }) > > > > What you're interested in is the #render_partial instance method > > defined in ActionView::Base. > > > > The problem is that you need that method to work as expected the first > > time (to render the outer partial) and mock only the second call (to > > render the nested partial). There is no support for turning mock > > methods on and off midstream, so you'd have to do something like this: > > > > controller.template.should_receive(:render).with(#opts for outer partial) do > > #duplicate here what the method actually does in order to render the outer > > end > > > > controller.template.should_receive(:render).with(#opts for inner partial) > > > > Of course you're duplicating rails code in your specs to do this, > > which is bad, but I think it's the best option. Give a shot and let us > > know how it works. > > > > David > > > > > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > > anonymous class, which I am unsure how to mock. Thanks for the 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 > From matttemp at gmail.com Thu Apr 12 11:07:23 2007 From: matttemp at gmail.com (Matt Aimonetti) Date: Thu, 12 Apr 2007 08:07:23 -0700 Subject: [rspec-users] RSpec plugin for RadRails In-Reply-To: References: Message-ID: Bonne chance avec Eclipse ;) Hey, maybe you could blog a bout your experience trying to extend Aptana, I'm sure a lot of people would be interested in reading what you did. ( I would ) Regards, Matt On 4/12/07, Julien Palmas wrote: > > I was thinking about writing it myself actually ;-) > Thing is, I use TextMate at home, but have to work on a PC for my job, and > RadRails (now aptana) is the best alternative I've found (quite a good app > by the way). So I'll have to learn have to write a plugin now. > > If I come out with something usable, I'll let the list know ! > > Cheers, > Julien > > _______________________________________________ > 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/20070412/a73e2e0f/attachment.html From bosshoff at gmail.com Thu Apr 12 11:27:17 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Thu, 12 Apr 2007 11:27:17 -0400 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> Message-ID: <359ebde50704120827r3a75343x8c47189b00b04848@mail.gmail.com> First off, thanks for taking the time to investigate this problem. This group has been fantastic in this respect. The thing that I keep tripping over is the passing of locals. I am trying to do the following, as the blog post indicates: setup do #... @controller.template.stub!(:local_var). and_return { puts "got called"; @local_var_stub} end I put in the puts just to see if it's getting called, which it isn't. -Chris On 4/12/07, David Chelimsky wrote: > On 4/12/07, Chris Hoffman wrote: > > Hello, > > Well, that site ostensibly showcases just the syntax I need to pull > > off what I'm looking for, but I am unable to get it working. In fact, > > I fail to see how stubbing out 'render' under @controller.template > > could possibly work, given David's discourse above. > > Has anyone here actually tried the code in this post? > > > > -Chris > > I just got this working: > > #spec/views/thing/outer_partial_rhtml_spec.rb > require File.dirname(__FILE__) + '/../../spec_helper' > describe "/thing/_outer_partial" do > it "should render inner_partial" do > @controller.template.should_receive(:render).with(:partial => > "inner_partial") > @controller.template.should_receive(:render).with(:partial => > "other_inner_partial") > render 'thing/_outer_partial' > end > end > > #app/views/thing/thing/_outer_partial.rhtml > <%= render :partial => "inner_partial" %> > <%= render :partial => "other_inner_partial" %> > > This works just fine. Is there something you're trying to do that this > example is missing? > > > > > On 4/12/07, David Chelimsky wrote: > > > On 4/12/07, Chris Hoffman wrote: > > > > Hello, > > > > I am testing out a partial that calls another, general purpose > > > > partial as part of its processing. Is there a class I can mock in > > > > Rails views to accomplish what I need? That is, could I do something > > > > like the following: > > > > > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > > > :bars => bars }) > > > > > > What you're interested in is the #render_partial instance method > > > defined in ActionView::Base. > > > > > > The problem is that you need that method to work as expected the first > > > time (to render the outer partial) and mock only the second call (to > > > render the nested partial). There is no support for turning mock > > > methods on and off midstream, so you'd have to do something like this: > > > > > > controller.template.should_receive(:render).with(#opts for outer partial) do > > > #duplicate here what the method actually does in order to render the outer > > > end > > > > > > controller.template.should_receive(:render).with(#opts for inner partial) > > > > > > Of course you're duplicating rails code in your specs to do this, > > > which is bad, but I think it's the best option. Give a shot and let us > > > know how it works. > > > > > > David > > > > > > > > > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > > > anonymous class, which I am unsure how to mock. Thanks for the 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 > From dchelimsky at gmail.com Thu Apr 12 11:45:07 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Apr 2007 10:45:07 -0500 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <359ebde50704120827r3a75343x8c47189b00b04848@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> <359ebde50704120827r3a75343x8c47189b00b04848@mail.gmail.com> Message-ID: <57c63afe0704120845q27b2694ma8f0735e21b3e491@mail.gmail.com> On 4/12/07, Chris Hoffman wrote: > First off, thanks for taking the time to investigate this problem. > This group has been fantastic in this respect. > > The thing that I keep tripping over is the passing of locals. I am > trying to do the following, as the blog post indicates: > > setup do > #... > @controller.template.stub!(:local_var). > and_return { puts "got called"; @local_var_stub} > end I'm confused about your goal here. Let's say you have two partials: _level1 and _level2. If you're trying to specify that _level1 renders _level2 using a mock, you would do what's in Jake's post and my recent example in this thread. In this case, _level2 is never actually rendered because the mock intercepts the call. If you're trying to specify that _level2 interacts with a variable, then you should describe the behaviour of _level2 directly in its own example. Does this make sense? If I'm not getting it, please post the whole example so I can see everything you're trying to do. Thanks, David > > I put in the puts just to see if it's getting called, which it isn't. > > -Chris > > On 4/12/07, David Chelimsky wrote: > > On 4/12/07, Chris Hoffman wrote: > > > Hello, > > > Well, that site ostensibly showcases just the syntax I need to pull > > > off what I'm looking for, but I am unable to get it working. In fact, > > > I fail to see how stubbing out 'render' under @controller.template > > > could possibly work, given David's discourse above. > > > Has anyone here actually tried the code in this post? > > > > > > -Chris > > > > I just got this working: > > > > #spec/views/thing/outer_partial_rhtml_spec.rb > > require File.dirname(__FILE__) + '/../../spec_helper' > > describe "/thing/_outer_partial" do > > it "should render inner_partial" do > > @controller.template.should_receive(:render).with(:partial => > > "inner_partial") > > @controller.template.should_receive(:render).with(:partial => > > "other_inner_partial") > > render 'thing/_outer_partial' > > end > > end > > > > #app/views/thing/thing/_outer_partial.rhtml > > <%= render :partial => "inner_partial" %> > > <%= render :partial => "other_inner_partial" %> > > > > This works just fine. Is there something you're trying to do that this > > example is missing? > > > > > > > > On 4/12/07, David Chelimsky wrote: > > > > On 4/12/07, Chris Hoffman wrote: > > > > > Hello, > > > > > I am testing out a partial that calls another, general purpose > > > > > partial as part of its processing. Is there a class I can mock in > > > > > Rails views to accomplish what I need? That is, could I do something > > > > > like the following: > > > > > > > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > > > > :bars => bars }) > > > > > > > > What you're interested in is the #render_partial instance method > > > > defined in ActionView::Base. > > > > > > > > The problem is that you need that method to work as expected the first > > > > time (to render the outer partial) and mock only the second call (to > > > > render the nested partial). There is no support for turning mock > > > > methods on and off midstream, so you'd have to do something like this: > > > > > > > > controller.template.should_receive(:render).with(#opts for outer partial) do > > > > #duplicate here what the method actually does in order to render the outer > > > > end > > > > > > > > controller.template.should_receive(:render).with(#opts for inner partial) > > > > > > > > Of course you're duplicating rails code in your specs to do this, > > > > which is bad, but I think it's the best option. Give a shot and let us > > > > know how it works. > > > > > > > > David > > > > > > > > > > > > > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > > > > anonymous class, which I am unsure how to mock. Thanks for the 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 > From bosshoff at gmail.com Thu Apr 12 11:56:16 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Thu, 12 Apr 2007 11:56:16 -0400 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <57c63afe0704120845q27b2694ma8f0735e21b3e491@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> <359ebde50704120827r3a75343x8c47189b00b04848@mail.gmail.com> <57c63afe0704120845q27b2694ma8f0735e21b3e491@mail.gmail.com> Message-ID: <359ebde50704120856v70525c75i1447900241c4a336@mail.gmail.com> I'm trying to get _level1 what it needs to avoid erroring out. So, since I am now replacing render :partial => 'view_container/level1', :locals => { :bar => @bar } with render 'view_container/_level1' I need some way to get the locals into the _level1 partial. I cannot seem to achieve this with @controller.template.stub!(:bar).and_return(@bar) Are you able? -Chris On 4/12/07, David Chelimsky wrote: > On 4/12/07, Chris Hoffman wrote: > > First off, thanks for taking the time to investigate this problem. > > This group has been fantastic in this respect. > > > > The thing that I keep tripping over is the passing of locals. I am > > trying to do the following, as the blog post indicates: > > > > setup do > > #... > > @controller.template.stub!(:local_var). > > and_return { puts "got called"; @local_var_stub} > > end > > I'm confused about your goal here. Let's say you have two partials: > _level1 and _level2. If you're trying to specify that _level1 renders > _level2 using a mock, you would do what's in Jake's post and my recent > example in this thread. In this case, _level2 is never actually > rendered because the mock intercepts the call. > > If you're trying to specify that _level2 interacts with a variable, > then you should describe the behaviour of _level2 directly in its own > example. > > Does this make sense? If I'm not getting it, please post the whole > example so I can see everything you're trying to do. > > Thanks, > David > > > > > I put in the puts just to see if it's getting called, which it isn't. > > > > -Chris > > > > On 4/12/07, David Chelimsky wrote: > > > On 4/12/07, Chris Hoffman wrote: > > > > Hello, > > > > Well, that site ostensibly showcases just the syntax I need to pull > > > > off what I'm looking for, but I am unable to get it working. In fact, > > > > I fail to see how stubbing out 'render' under @controller.template > > > > could possibly work, given David's discourse above. > > > > Has anyone here actually tried the code in this post? > > > > > > > > -Chris > > > > > > I just got this working: > > > > > > #spec/views/thing/outer_partial_rhtml_spec.rb > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > describe "/thing/_outer_partial" do > > > it "should render inner_partial" do > > > @controller.template.should_receive(:render).with(:partial => > > > "inner_partial") > > > @controller.template.should_receive(:render).with(:partial => > > > "other_inner_partial") > > > render 'thing/_outer_partial' > > > end > > > end > > > > > > #app/views/thing/thing/_outer_partial.rhtml > > > <%= render :partial => "inner_partial" %> > > > <%= render :partial => "other_inner_partial" %> > > > > > > This works just fine. Is there something you're trying to do that this > > > example is missing? > > > > > > > > > > > On 4/12/07, David Chelimsky wrote: > > > > > On 4/12/07, Chris Hoffman wrote: > > > > > > Hello, > > > > > > I am testing out a partial that calls another, general purpose > > > > > > partial as part of its processing. Is there a class I can mock in > > > > > > Rails views to accomplish what I need? That is, could I do something > > > > > > like the following: > > > > > > > > > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > > > > > :bars => bars }) > > > > > > > > > > What you're interested in is the #render_partial instance method > > > > > defined in ActionView::Base. > > > > > > > > > > The problem is that you need that method to work as expected the first > > > > > time (to render the outer partial) and mock only the second call (to > > > > > render the nested partial). There is no support for turning mock > > > > > methods on and off midstream, so you'd have to do something like this: > > > > > > > > > > controller.template.should_receive(:render).with(#opts for outer partial) do > > > > > #duplicate here what the method actually does in order to render the outer > > > > > end > > > > > > > > > > controller.template.should_receive(:render).with(#opts for inner partial) > > > > > > > > > > Of course you're duplicating rails code in your specs to do this, > > > > > which is bad, but I think it's the best option. Give a shot and let us > > > > > know how it works. > > > > > > > > > > David > > > > > > > > > > > > > > > > > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > > > > > anonymous class, which I am unsure how to mock. Thanks for the 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 dchelimsky at gmail.com Thu Apr 12 12:09:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Apr 2007 11:09:00 -0500 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <359ebde50704120856v70525c75i1447900241c4a336@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> <359ebde50704120827r3a75343x8c47189b00b04848@mail.gmail.com> <57c63afe0704120845q27b2694ma8f0735e21b3e491@mail.gmail.com> <359ebde50704120856v70525c75i1447900241c4a336@mail.gmail.com> Message-ID: <57c63afe0704120909w1f8e7475vcf8c68db079ccfa2@mail.gmail.com> On 4/12/07, Chris Hoffman wrote: > I'm trying to get _level1 what it needs to avoid erroring out. So, > since I am now replacing > > render :partial => 'view_container/level1', :locals => { :bar => @bar } > > with > > render 'view_container/_level1' > > I need some way to get the locals into the _level1 partial. I cannot > seem to achieve this with > > @controller.template.stub!(:bar).and_return(@bar) > > Are you able? Sorry I missed that. Try this: # in spec assigns[:bar] = "bar" render 'view_container/_level1' # in _level1 <%= @bar %> That should work > > -Chris > > On 4/12/07, David Chelimsky wrote: > > On 4/12/07, Chris Hoffman wrote: > > > First off, thanks for taking the time to investigate this problem. > > > This group has been fantastic in this respect. > > > > > > The thing that I keep tripping over is the passing of locals. I am > > > trying to do the following, as the blog post indicates: > > > > > > setup do > > > #... > > > @controller.template.stub!(:local_var). > > > and_return { puts "got called"; @local_var_stub} > > > end > > > > I'm confused about your goal here. Let's say you have two partials: > > _level1 and _level2. If you're trying to specify that _level1 renders > > _level2 using a mock, you would do what's in Jake's post and my recent > > example in this thread. In this case, _level2 is never actually > > rendered because the mock intercepts the call. > > > > If you're trying to specify that _level2 interacts with a variable, > > then you should describe the behaviour of _level2 directly in its own > > example. > > > > Does this make sense? If I'm not getting it, please post the whole > > example so I can see everything you're trying to do. > > > > Thanks, > > David > > > > > > > > I put in the puts just to see if it's getting called, which it isn't. > > > > > > -Chris > > > > > > On 4/12/07, David Chelimsky wrote: > > > > On 4/12/07, Chris Hoffman wrote: > > > > > Hello, > > > > > Well, that site ostensibly showcases just the syntax I need to pull > > > > > off what I'm looking for, but I am unable to get it working. In fact, > > > > > I fail to see how stubbing out 'render' under @controller.template > > > > > could possibly work, given David's discourse above. > > > > > Has anyone here actually tried the code in this post? > > > > > > > > > > -Chris > > > > > > > > I just got this working: > > > > > > > > #spec/views/thing/outer_partial_rhtml_spec.rb > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > describe "/thing/_outer_partial" do > > > > it "should render inner_partial" do > > > > @controller.template.should_receive(:render).with(:partial => > > > > "inner_partial") > > > > @controller.template.should_receive(:render).with(:partial => > > > > "other_inner_partial") > > > > render 'thing/_outer_partial' > > > > end > > > > end > > > > > > > > #app/views/thing/thing/_outer_partial.rhtml > > > > <%= render :partial => "inner_partial" %> > > > > <%= render :partial => "other_inner_partial" %> > > > > > > > > This works just fine. Is there something you're trying to do that this > > > > example is missing? > > > > > > > > > > > > > > On 4/12/07, David Chelimsky wrote: > > > > > > On 4/12/07, Chris Hoffman wrote: > > > > > > > Hello, > > > > > > > I am testing out a partial that calls another, general purpose > > > > > > > partial as part of its processing. Is there a class I can mock in > > > > > > > Rails views to accomplish what I need? That is, could I do something > > > > > > > like the following: > > > > > > > > > > > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > > > > > > :bars => bars }) > > > > > > > > > > > > What you're interested in is the #render_partial instance method > > > > > > defined in ActionView::Base. > > > > > > > > > > > > The problem is that you need that method to work as expected the first > > > > > > time (to render the outer partial) and mock only the second call (to > > > > > > render the nested partial). There is no support for turning mock > > > > > > methods on and off midstream, so you'd have to do something like this: > > > > > > > > > > > > controller.template.should_receive(:render).with(#opts for outer partial) do > > > > > > #duplicate here what the method actually does in order to render the outer > > > > > > end > > > > > > > > > > > > controller.template.should_receive(:render).with(#opts for inner partial) > > > > > > > > > > > > Of course you're duplicating rails code in your specs to do this, > > > > > > which is bad, but I think it's the best option. Give a shot and let us > > > > > > know how it works. > > > > > > > > > > > > David > > > > > > > > > > > > > > > > > > > > > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > > > > > > anonymous class, which I am unsure how to mock. Thanks for the 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeff at jefdean.com Tue Apr 10 20:21:03 2007 From: jeff at jefdean.com (Jeff Dean) Date: Tue, 10 Apr 2007 20:21:03 -0400 Subject: [rspec-users] View Specs Fail with "protected method render" Message-ID: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> I've got rspec and zentest installed as well as the rspec rails plugin, and my model/controller specs all pass and work well. I can't seem to get views to work though - 100% of the specs fail with: NoMethodError in '/users/show.rhtml should render attributes in

' protected method `render' called for # /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in `render' ./spec/views/users/show_rhtml_spec.rb:13: Note the "protected method `render' called for #" Here's an example spec: require File.dirname(__FILE__) + '/../../spec_helper' context "/users/new.rhtml" do include UsersHelper setup do @errors = mock("errors") @errors.stub!(:count).and_return(0) @user = mock_user @user.stub!(:errors).and_return @errors assigns[:user] = @user end specify "should render new form" do render "/users/new.rhtml" response.should_have_tag 'form', :attributes =>{:action => users_path, :method => 'post'} end end Can anyone think of why "render" is protected? Is this a versioning issue? Thanks - Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070410/58f2a03d/attachment.html From aslak.hellesoy at gmail.com Thu Apr 12 12:24:55 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 18:24:55 +0200 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> Message-ID: <8d961d900704120924q5ca1837xc9b2cbcfe4f158a@mail.gmail.com> On 4/11/07, Jeff Dean wrote: > I've got rspec and zentest installed as well as the rspec rails plugin, and > my model/controller specs all pass and work well. I can't seem to get views > to work though - 100% of the specs fail with: > > NoMethodError in '/users/show.rhtml should render attributes in

' > protected method `render' called for > # > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > `render' > ./spec/views/users/show_rhtml_spec.rb:13: > > Note the "protected method `render' called for > #" > > Here's an example spec: > > require File.dirname(__FILE__) + '/../../spec_helper' > > context "/users/new.rhtml" do > include UsersHelper > > setup do > @errors = mock("errors") > @errors.stub!(:count).and_return(0) > > @user = mock_user > @user.stub!(:errors).and_return @errors > assigns[:user] = @user > end > > specify "should render new form" do > render "/users/new.rhtml" > response.should_have_tag 'form', :attributes =>{:action => users_path, > :method => 'post'} > > end > end > > Can anyone think of why "render" is protected? Is this a versioning issue? > What versions of everything do you have? > Thanks - Jeff > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bosshoff at gmail.com Thu Apr 12 12:40:38 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Thu, 12 Apr 2007 12:40:38 -0400 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <57c63afe0704120909w1f8e7475vcf8c68db079ccfa2@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> <359ebde50704120827r3a75343x8c47189b00b04848@mail.gmail.com> <57c63afe0704120845q27b2694ma8f0735e21b3e491@mail.gmail.com> <359ebde50704120856v70525c75i1447900241c4a336@mail.gmail.com> <57c63afe0704120909w1f8e7475vcf8c68db079ccfa2@mail.gmail.com> Message-ID: <359ebde50704120940q6264099fuf9c2b9132e187dbf@mail.gmail.com> So are you saying that the solution to this problem is to circumvent local variable passing? I tend to leverage this passing quite often, such as when I need to call a partial for each member of a collection. As an aside, I have put in a comment to Jake's blog, and hopefully he can tell me how he got his snippet working (if he tried it). -Chris On 4/12/07, David Chelimsky wrote: > On 4/12/07, Chris Hoffman wrote: > > I'm trying to get _level1 what it needs to avoid erroring out. So, > > since I am now replacing > > > > render :partial => 'view_container/level1', :locals => { :bar => @bar } > > > > with > > > > render 'view_container/_level1' > > > > I need some way to get the locals into the _level1 partial. I cannot > > seem to achieve this with > > > > @controller.template.stub!(:bar).and_return(@bar) > > > > Are you able? > > Sorry I missed that. Try this: > > # in spec > assigns[:bar] = "bar" > render 'view_container/_level1' > > # in _level1 > <%= @bar %> > > That should work > > > > > > -Chris > > > > On 4/12/07, David Chelimsky wrote: > > > On 4/12/07, Chris Hoffman wrote: > > > > First off, thanks for taking the time to investigate this problem. > > > > This group has been fantastic in this respect. > > > > > > > > The thing that I keep tripping over is the passing of locals. I am > > > > trying to do the following, as the blog post indicates: > > > > > > > > setup do > > > > #... > > > > @controller.template.stub!(:local_var). > > > > and_return { puts "got called"; @local_var_stub} > > > > end > > > > > > I'm confused about your goal here. Let's say you have two partials: > > > _level1 and _level2. If you're trying to specify that _level1 renders > > > _level2 using a mock, you would do what's in Jake's post and my recent > > > example in this thread. In this case, _level2 is never actually > > > rendered because the mock intercepts the call. > > > > > > If you're trying to specify that _level2 interacts with a variable, > > > then you should describe the behaviour of _level2 directly in its own > > > example. > > > > > > Does this make sense? If I'm not getting it, please post the whole > > > example so I can see everything you're trying to do. > > > > > > Thanks, > > > David > > > > > > > > > > > I put in the puts just to see if it's getting called, which it isn't. > > > > > > > > -Chris > > > > > > > > On 4/12/07, David Chelimsky wrote: > > > > > On 4/12/07, Chris Hoffman wrote: > > > > > > Hello, > > > > > > Well, that site ostensibly showcases just the syntax I need to pull > > > > > > off what I'm looking for, but I am unable to get it working. In fact, > > > > > > I fail to see how stubbing out 'render' under @controller.template > > > > > > could possibly work, given David's discourse above. > > > > > > Has anyone here actually tried the code in this post? > > > > > > > > > > > > -Chris > > > > > > > > > > I just got this working: > > > > > > > > > > #spec/views/thing/outer_partial_rhtml_spec.rb > > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > > describe "/thing/_outer_partial" do > > > > > it "should render inner_partial" do > > > > > @controller.template.should_receive(:render).with(:partial => > > > > > "inner_partial") > > > > > @controller.template.should_receive(:render).with(:partial => > > > > > "other_inner_partial") > > > > > render 'thing/_outer_partial' > > > > > end > > > > > end > > > > > > > > > > #app/views/thing/thing/_outer_partial.rhtml > > > > > <%= render :partial => "inner_partial" %> > > > > > <%= render :partial => "other_inner_partial" %> > > > > > > > > > > This works just fine. Is there something you're trying to do that this > > > > > example is missing? > > > > > > > > > > > > > > > > > On 4/12/07, David Chelimsky wrote: > > > > > > > On 4/12/07, Chris Hoffman wrote: > > > > > > > > Hello, > > > > > > > > I am testing out a partial that calls another, general purpose > > > > > > > > partial as part of its processing. Is there a class I can mock in > > > > > > > > Rails views to accomplish what I need? That is, could I do something > > > > > > > > like the following: > > > > > > > > > > > > > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > > > > > > > :bars => bars }) > > > > > > > > > > > > > > What you're interested in is the #render_partial instance method > > > > > > > defined in ActionView::Base. > > > > > > > > > > > > > > The problem is that you need that method to work as expected the first > > > > > > > time (to render the outer partial) and mock only the second call (to > > > > > > > render the nested partial). There is no support for turning mock > > > > > > > methods on and off midstream, so you'd have to do something like this: > > > > > > > > > > > > > > controller.template.should_receive(:render).with(#opts for outer partial) do > > > > > > > #duplicate here what the method actually does in order to render the outer > > > > > > > end > > > > > > > > > > > > > > controller.template.should_receive(:render).with(#opts for inner partial) > > > > > > > > > > > > > > Of course you're duplicating rails code in your specs to do this, > > > > > > > which is bad, but I think it's the best option. Give a shot and let us > > > > > > > know how it works. > > > > > > > > > > > > > > David > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > > > > > > > anonymous class, which I am unsure how to mock. Thanks for the 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 > > > > > _______________________________________________ > > 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 bosshoff at gmail.com Thu Apr 12 12:47:31 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Thu, 12 Apr 2007 12:47:31 -0400 Subject: [rspec-users] Test if view renders appropriate partial? In-Reply-To: <359ebde50704120940q6264099fuf9c2b9132e187dbf@mail.gmail.com> References: <359ebde50704120555j6eb3d88fme02583420cfe6d56@mail.gmail.com> <57c63afe0704120620x36f15d8fga3910ce1a1e73642@mail.gmail.com> <359ebde50704120722tf23494cj9fff2690db00f5d@mail.gmail.com> <57c63afe0704120807q436b10f0w9abdc30b8e16a4d3@mail.gmail.com> <359ebde50704120827r3a75343x8c47189b00b04848@mail.gmail.com> <57c63afe0704120845q27b2694ma8f0735e21b3e491@mail.gmail.com> <359ebde50704120856v70525c75i1447900241c4a336@mail.gmail.com> <57c63afe0704120909w1f8e7475vcf8c68db079ccfa2@mail.gmail.com> <359ebde50704120940q6264099fuf9c2b9132e187dbf@mail.gmail.com> Message-ID: <359ebde50704120947x6252fcdaw8e49c1a3b5c4490f@mail.gmail.com> Oh, disregard the last post. I get what you are saying. Instead of setting a local variable via :locals, I can set an instance variable. Good idea. -Chris On 4/12/07, Chris Hoffman wrote: > So are you saying that the solution to this problem is to circumvent > local variable passing? I tend to leverage this passing quite often, > such as when I need to call a partial for each member of a collection. > > As an aside, I have put in a comment to Jake's blog, and hopefully he > can tell me how he got his snippet working (if he tried it). > > -Chris > > On 4/12/07, David Chelimsky wrote: > > On 4/12/07, Chris Hoffman wrote: > > > I'm trying to get _level1 what it needs to avoid erroring out. So, > > > since I am now replacing > > > > > > render :partial => 'view_container/level1', :locals => { :bar => @bar } > > > > > > with > > > > > > render 'view_container/_level1' > > > > > > I need some way to get the locals into the _level1 partial. I cannot > > > seem to achieve this with > > > > > > @controller.template.stub!(:bar).and_return(@bar) > > > > > > Are you able? > > > > Sorry I missed that. Try this: > > > > # in spec > > assigns[:bar] = "bar" > > render 'view_container/_level1' > > > > # in _level1 > > <%= @bar %> > > > > That should work > > > > > > > > > > -Chris > > > > > > On 4/12/07, David Chelimsky wrote: > > > > On 4/12/07, Chris Hoffman wrote: > > > > > First off, thanks for taking the time to investigate this problem. > > > > > This group has been fantastic in this respect. > > > > > > > > > > The thing that I keep tripping over is the passing of locals. I am > > > > > trying to do the following, as the blog post indicates: > > > > > > > > > > setup do > > > > > #... > > > > > @controller.template.stub!(:local_var). > > > > > and_return { puts "got called"; @local_var_stub} > > > > > end > > > > > > > > I'm confused about your goal here. Let's say you have two partials: > > > > _level1 and _level2. If you're trying to specify that _level1 renders > > > > _level2 using a mock, you would do what's in Jake's post and my recent > > > > example in this thread. In this case, _level2 is never actually > > > > rendered because the mock intercepts the call. > > > > > > > > If you're trying to specify that _level2 interacts with a variable, > > > > then you should describe the behaviour of _level2 directly in its own > > > > example. > > > > > > > > Does this make sense? If I'm not getting it, please post the whole > > > > example so I can see everything you're trying to do. > > > > > > > > Thanks, > > > > David > > > > > > > > > > > > > > I put in the puts just to see if it's getting called, which it isn't. > > > > > > > > > > -Chris > > > > > > > > > > On 4/12/07, David Chelimsky wrote: > > > > > > On 4/12/07, Chris Hoffman wrote: > > > > > > > Hello, > > > > > > > Well, that site ostensibly showcases just the syntax I need to pull > > > > > > > off what I'm looking for, but I am unable to get it working. In fact, > > > > > > > I fail to see how stubbing out 'render' under @controller.template > > > > > > > could possibly work, given David's discourse above. > > > > > > > Has anyone here actually tried the code in this post? > > > > > > > > > > > > > > -Chris > > > > > > > > > > > > I just got this working: > > > > > > > > > > > > #spec/views/thing/outer_partial_rhtml_spec.rb > > > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > > > describe "/thing/_outer_partial" do > > > > > > it "should render inner_partial" do > > > > > > @controller.template.should_receive(:render).with(:partial => > > > > > > "inner_partial") > > > > > > @controller.template.should_receive(:render).with(:partial => > > > > > > "other_inner_partial") > > > > > > render 'thing/_outer_partial' > > > > > > end > > > > > > end > > > > > > > > > > > > #app/views/thing/thing/_outer_partial.rhtml > > > > > > <%= render :partial => "inner_partial" %> > > > > > > <%= render :partial => "other_inner_partial" %> > > > > > > > > > > > > This works just fine. Is there something you're trying to do that this > > > > > > example is missing? > > > > > > > > > > > > > > > > > > > > On 4/12/07, David Chelimsky wrote: > > > > > > > > On 4/12/07, Chris Hoffman wrote: > > > > > > > > > Hello, > > > > > > > > > I am testing out a partial that calls another, general purpose > > > > > > > > > partial as part of its processing. Is there a class I can mock in > > > > > > > > > Rails views to accomplish what I need? That is, could I do something > > > > > > > > > like the following: > > > > > > > > > > > > > > > > > > SomeClass.should_receive(:render).with(:partial => "foo", :locals => { > > > > > > > > > :bars => bars }) > > > > > > > > > > > > > > > > What you're interested in is the #render_partial instance method > > > > > > > > defined in ActionView::Base. > > > > > > > > > > > > > > > > The problem is that you need that method to work as expected the first > > > > > > > > time (to render the outer partial) and mock only the second call (to > > > > > > > > render the nested partial). There is no support for turning mock > > > > > > > > methods on and off midstream, so you'd have to do something like this: > > > > > > > > > > > > > > > > controller.template.should_receive(:render).with(#opts for outer partial) do > > > > > > > > #duplicate here what the method actually does in order to render the outer > > > > > > > > end > > > > > > > > > > > > > > > > controller.template.should_receive(:render).with(#opts for inner partial) > > > > > > > > > > > > > > > > Of course you're duplicating rails code in your specs to do this, > > > > > > > > which is bad, but I think it's the best option. Give a shot and let us > > > > > > > > know how it works. > > > > > > > > > > > > > > > > David > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I tried breakpointing the view, and it looks like I am greeted by an > > > > > > > > > anonymous class, which I am unsure how to mock. Thanks for the 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 > > > > > > > _______________________________________________ > > > 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 Apr 12 14:21:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Apr 2007 13:21:30 -0500 Subject: [rspec-users] RSpec part of two (count 'em, two) GSoC projects Message-ID: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> Here is the list of Ruby related projects accepted for GSoC. It includes two very similar projects (seemingly the same project, really, but I'm not saying anything ;) ) using RSpec to build a spec suite for implementations of the Ruby language: http://code.google.com/soc/ruby/about.html I'm, personally, very excited about the implications of this. Thanks to all of you who use, talk about and contribute to RSpec! Cheers, David (on behalf the RSpec Development Team) From aslak.hellesoy at gmail.com Thu Apr 12 15:15:27 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 12 Apr 2007 21:15:27 +0200 Subject: [rspec-users] [rspec-devel] RSpec part of two (count 'em, two) GSoC projects In-Reply-To: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> References: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> Message-ID: <8d961d900704121215rd37773al623c8dfb3bb7aad0@mail.gmail.com> On 4/12/07, David Chelimsky wrote: > Here is the list of Ruby related projects accepted for GSoC. It > includes two very similar projects (seemingly the same project, > really, but I'm not saying anything ;) ) using RSpec to build a spec > suite for implementations of the Ruby language: > > http://code.google.com/soc/ruby/about.html > Isn't it quite symptomatic that the two RSpec GSoC projects are essentially the same? I guess Ruby is really in need of a test suite. As late as yesterday I stumbled across a subtle bug in JRuby's handling of equality in hashes: http://jira.codehaus.org/browse/JRUBY-807 Aslak > I'm, personally, very excited about the implications of this. Thanks > to all of you who use, talk about and contribute to RSpec! > > Cheers, > David (on behalf the RSpec Development Team) > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > From mailing_lists at railsnewbie.com Thu Apr 12 18:53:26 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 12 Apr 2007 18:53:26 -0400 Subject: [rspec-users] specing class methods Message-ID: <5882DEB9-59FC-4AB8-8817-BB935EF831CE@railsnewbie.com> Here is an example from autotest: class Autotest def self.run new.run end def new ... end def run ... end ... end How would I spec out Autotest.run? Two complications come to my mind: 1. How do I spec out class methods? (please point me to docs, if any. I can only find class level specing on "partial mocks" (of rails class objects) 2. How can I tell that new.run has been called, without saying should_receive(:new) and should_receive(:run) in separate specs? Another complication: How would I spec out the (instance level) run method, which has an infinite loop? def run hook :run reset add_sigint_handler loop do # ^c handler #...stuff... end hook :quit end Thanks for all of your help, Scott Taylor PS: Sorry for my previous non-sensical emails. I was being stupid. From mailing_lists at railsnewbie.com Thu Apr 12 19:06:38 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 12 Apr 2007 19:06:38 -0400 Subject: [rspec-users] RSpec part of two (count 'em, two) GSoC projects In-Reply-To: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> References: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> Message-ID: Some of you guys may know I thought about signing up for this. I didn't sign up, because Rubinus seems to already have a pretty mature spec library (at least for core). Why can't this be used for the other implementations? Or is the focus on writing drivers for those implementations so that all of the specs can easily be run against multiple implementations? I didn't understand this, nor how a VM works (and still understand neither), so I ended up never signing up. I even talked to David Black and he didn't have any insight on this point, so am I missing some big piece of the puzzle? As far as I can tell, BDD should be used for development, hence the name Behaviour Driven *Development*. So aren't these specs just going to be used to develop rubinus (mainly for the stdlib)? Once these are mature, then the porting should be easy, shouldn't it? Best, Scott Taylor On Apr 12, 2007, at 2:21 PM, David Chelimsky wrote: > Here is the list of Ruby related projects accepted for GSoC. It > includes two very similar projects (seemingly the same project, > really, but I'm not saying anything ;) ) using RSpec to build a spec > suite for implementations of the Ruby language: > > http://code.google.com/soc/ruby/about.html > > I'm, personally, very excited about the implications of this. Thanks > to all of you who use, talk about and contribute to RSpec! > > Cheers, > David (on behalf the RSpec Development Team) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Thu Apr 12 19:07:56 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 12 Apr 2007 19:07:56 -0400 Subject: [rspec-users] RSpec part of two (count 'em, two) GSoC projects In-Reply-To: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> References: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> Message-ID: <3783149A-00A8-46BD-931F-7BE137F25280@railsnewbie.com> As for the *two*, the first listing doesn't seem any different than the second. What was going through the minds of those who wrote the proposals? Scott On Apr 12, 2007, at 2:21 PM, David Chelimsky wrote: > Here is the list of Ruby related projects accepted for GSoC. It > includes two very similar projects (seemingly the same project, > really, but I'm not saying anything ;) ) using RSpec to build a spec > suite for implementations of the Ruby language: > > http://code.google.com/soc/ruby/about.html > > I'm, personally, very excited about the implications of this. Thanks > to all of you who use, talk about and contribute to RSpec! > > Cheers, > David (on behalf the RSpec Development Team) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pat.eyler at gmail.com Thu Apr 12 19:11:13 2007 From: pat.eyler at gmail.com (pat eyler) Date: Thu, 12 Apr 2007 17:11:13 -0600 Subject: [rspec-users] RSpec part of two (count 'em, two) GSoC projects In-Reply-To: References: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> Message-ID: <6fd0654b0704121611r607409d9gace5abec1fd6bd98@mail.gmail.com> On 4/12/07, Scott Taylor wrote: > > Some of you guys may know I thought about signing up for this. I > didn't sign up, because Rubinus seems to already have a pretty mature > spec library (at least for core). Why can't this be used for the > other implementations? The intent is that the tests will be shared across implementations. > > Or is the focus on writing drivers for those implementations so that > all of the specs can easily be run against multiple implementations? > > I didn't understand this, nor how a VM works (and still understand > neither), so I ended up never signing up. I even talked to David > Black and he didn't have any insight on this point, so am I missing > some big piece of the puzzle? I wish you'd joined the general discussion, but there's still time to get involved in one or both projects (albeit not as a sponsored student). > > As far as I can tell, BDD should be used for development, hence the > name Behaviour Driven *Development*. So aren't these specs just > going to be used to develop rubinus (mainly for the stdlib)? Once > these are mature, then the porting should be easy, shouldn't it? > > > Best, > > Scott Taylor > > > On Apr 12, 2007, at 2:21 PM, David Chelimsky wrote: > > > Here is the list of Ruby related projects accepted for GSoC. It > > includes two very similar projects (seemingly the same project, > > really, but I'm not saying anything ;) ) using RSpec to build a spec > > suite for implementations of the Ruby language: > > > > http://code.google.com/soc/ruby/about.html > > > > I'm, personally, very excited about the implications of this. Thanks > > to all of you who use, talk about and contribute to RSpec! > > > > Cheers, > > David (on behalf the RSpec Development Team) > > _______________________________________________ > > 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 > -- thanks, -pate ------------------------- http://on-ruby.blogspot.com http://on-ruby.tumblr.com http://www.rubycentral.org/projects/soc2007 From mailing_lists at railsnewbie.com Thu Apr 12 19:45:07 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 12 Apr 2007 19:45:07 -0400 Subject: [rspec-users] RSpec part of two (count 'em, two) GSoC projects In-Reply-To: <6fd0654b0704121611r607409d9gace5abec1fd6bd98@mail.gmail.com> References: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> <6fd0654b0704121611r607409d9gace5abec1fd6bd98@mail.gmail.com> Message-ID: <58FA004B-89F7-40FF-8240-2ABC17BDE84D@railsnewbie.com> On Apr 12, 2007, at 7:11 PM, pat eyler wrote: > On 4/12/07, Scott Taylor wrote: >> >> Some of you guys may know I thought about signing up for this. I >> didn't sign up, because Rubinus seems to already have a pretty mature >> spec library (at least for core). Why can't this be used for the >> other implementations? > > The intent is that the tests will be shared across implementations. > Yeah, I understand. Why can't the specs which have already been developed for Rubinus be used for the other implementations? From pat.eyler at gmail.com Thu Apr 12 20:21:52 2007 From: pat.eyler at gmail.com (pat eyler) Date: Thu, 12 Apr 2007 18:21:52 -0600 Subject: [rspec-users] RSpec part of two (count 'em, two) GSoC projects In-Reply-To: <58FA004B-89F7-40FF-8240-2ABC17BDE84D@railsnewbie.com> References: <57c63afe0704121121j39de5931l6ca47bcebdeca55d@mail.gmail.com> <6fd0654b0704121611r607409d9gace5abec1fd6bd98@mail.gmail.com> <58FA004B-89F7-40FF-8240-2ABC17BDE84D@railsnewbie.com> Message-ID: <6fd0654b0704121721q35049578rd15a737034bd15ad@mail.gmail.com> On 4/12/07, Scott Taylor wrote: > > On Apr 12, 2007, at 7:11 PM, pat eyler wrote: > > > On 4/12/07, Scott Taylor wrote: > >> > >> Some of you guys may know I thought about signing up for this. I > >> didn't sign up, because Rubinus seems to already have a pretty mature > >> spec library (at least for core). Why can't this be used for the > >> other implementations? > > > > The intent is that the tests will be shared across implementations. > > > > Yeah, I understand. Why can't the specs which have already been > developed for Rubinus be used for the other implementations? > They can be, and it's something Evan, Nick, Charlie, Tom, and Ola are working on. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- thanks, -pate ------------------------- http://on-ruby.blogspot.com http://on-ruby.tumblr.com http://www.rubycentral.org/projects/soc2007 From aslak.hellesoy at gmail.com Thu Apr 12 20:59:53 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 13 Apr 2007 02:59:53 +0200 Subject: [rspec-users] HTML report and Spec::Ui improvements Message-ID: <8d961d900704121759s75105ce7gf052cdc2b62b63ce@mail.gmail.com> The trunk now has some nifty improvements to the HTML report (--format html). Each failing spec will (in addition to the backtrace) have a box with a source code snippet of the offending code. If you have Jamis Buck's syntax gem installed the code will also be syntax highlighted 8-D There has also been some major improvements to Spec::Ui, and it should be much easier to set up than before. Spec::Ui lets you run selenium and Watir/SafariWatir from RSpec and get screenshots in the HTML report. Check out the examples under trunk/spec_ui/examples. Enjoy! Aslak From mtrier at eminentconsultinggroup.com Thu Apr 12 21:45:29 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Thu, 12 Apr 2007 21:45:29 -0400 Subject: [rspec-users] HTML report and Spec::Ui improvements In-Reply-To: <8d961d900704121759s75105ce7gf052cdc2b62b63ce@mail.gmail.com> References: <8d961d900704121759s75105ce7gf052cdc2b62b63ce@mail.gmail.com> Message-ID: <4C8D7DC9-644D-4E8F-9489-1BDE53F8B902@eminentconsultinggroup.com> Awesome work Aslak. Thanks. Michael On Apr 12, 2007, at 8:59 PM, aslak hellesoy wrote: > The trunk now has some nifty improvements to the HTML report (--format > html). Each failing spec will (in addition to the backtrace) have a > box with a source code snippet of the offending code. > > If you have Jamis Buck's syntax gem installed the code will also be > syntax highlighted 8-D > > There has also been some major improvements to Spec::Ui, and it should > be much easier to set up than before. Spec::Ui lets you run selenium > and Watir/SafariWatir from RSpec and get screenshots in the HTML > report. Check out the examples under trunk/spec_ui/examples. > > Enjoy! > Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Thu Apr 12 21:54:45 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 13 Apr 2007 03:54:45 +0200 Subject: [rspec-users] ANN 0.9-beta-2 Message-ID: <8d961d900704121854l1844460cx371245f5cc8b5b82@mail.gmail.com> I've just made a new beta release available that fixes some more bugs to the translator. http://www.nabble.com/ANN:-RSpec-0.9.0-beta-1-available-for-download.-t3526973.html Additional changes since 0.9 beta-1: * Made Spec::Ui *much* easier to install. It will be released separately. Check out trunk/spec_ui/examples * HTML reports now include a syntax highlighted snippet of the source code where the spec failed (needs the syntax gem) * Added [#9735] support flexmock (thanks to Jim Weirich for his modifications to flexmock to support this) * Spec::Rails controller specs will no longer let mock exception ripple through to the response. * Fixed [#9260] IvarProxy does not act like a hash. * Applied [#9458] The rspec_resource generator does not take into account class nesting (Patch from Steve Tendon) * Applied [#9132] Rakefile spec:doc can fail without preparing database (Patch from Steve Ross) * Applied [#9678] Custom runner command line switch, and multi-threaded runner (Patch from Bob Cotton) * Applied [#9926] Rakefile - RSPEC_DEPS constant as an Array of Hashes instead of an Array of Arrays (Patch from Scott Taylor) * Applied [#9925] Changed ".rhtml" to "template" in REST spec generator (Patch from Scott Taylor) * Applied [#9852] Patch for RSpec's Website using Webgen 0.4.2 (Patch from Scott Taylor) Aslak From esad.talks at esse.at Thu Apr 12 22:46:05 2007 From: esad.talks at esse.at (Esad Hajdarevic) Date: Fri, 13 Apr 2007 04:46:05 +0200 Subject: [rspec-users] File.should be_exist? Message-ID: <461EEEED.5000706@esse.at> Hi! Is there a nicer way of writing File.should be_exist('filename')? File.should exist('foo') throws NoMethodError in 'specification' undefined method `exist' for #<#:0x3ebc308> (I'm using rspec from the trunk) Esad From mailing_lists at railsnewbie.com Fri Apr 13 00:22:52 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 13 Apr 2007 00:22:52 -0400 Subject: [rspec-users] spec'ing out a trap/SIGINT Message-ID: <366D5376-F523-41BF-BC8D-B56ED7C543AD@railsnewbie.com> How would you spec out a call to Signal.trap (a ^C or a unix SIGINT)? Scott From mailing_lists at railsnewbie.com Fri Apr 13 00:26:03 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 13 Apr 2007 00:26:03 -0400 Subject: [rspec-users] File.should be_exist? In-Reply-To: <461EEEED.5000706@esse.at> References: <461EEEED.5000706@esse.at> Message-ID: <62937A87-FD9A-4689-8968-7B0EC9185F10@railsnewbie.com> File.exist?(file).should be_true or File.exist?(file).should == true Scott On Apr 12, 2007, at 10:46 PM, Esad Hajdarevic wrote: > Hi! > > Is there a nicer way of writing > > File.should be_exist('filename')? > > > File.should exist('foo') throws NoMethodError in 'specification' > undefined method `exist' for #<#:0x3ebc308> > > (I'm using rspec from the trunk) > > Esad > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Fri Apr 13 00:50:42 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 13 Apr 2007 00:50:42 -0400 Subject: [rspec-users] spec'ing out a trap/SIGINT - BUG? In-Reply-To: <366D5376-F523-41BF-BC8D-B56ED7C543AD@railsnewbie.com> References: <366D5376-F523-41BF-BC8D-B56ED7C543AD@railsnewbie.com> Message-ID: <189AD1F6-33AE-4116-B25A-6751E8C3DAEF@railsnewbie.com> is this a bug? it "should call trap" do blk = lambda { raise Interrupt } @a.should_receive(:trap).with("INT", blk) @a.add_sigint_handler end the corresponding_method: def add_sigint_handler trap("INT") do raise Interrupt end end the output of the spec: Spec::Mocks::MockExpectationError in 'Ctrl-C/SIGINT handler - should call trap' # expected :trap with ("INT", #) but received it with ("INT") . I'm using rspec 0.9 beta 1 in gems Scott On Apr 13, 2007, at 12:22 AM, Scott Taylor wrote: > > How would you spec out a call to Signal.trap (a ^C or a unix SIGINT)? > > Scott > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matttemp at gmail.com Fri Apr 13 02:31:04 2007 From: matttemp at gmail.com (Matt Aimonetti) Date: Thu, 12 Apr 2007 23:31:04 -0700 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! Message-ID: Josh Knowles http://joshknowles.com/ just let me know that ZenTest Autotest 3.50 now handles your RSpec specs. http://blog.zenspider.com/archives/2007/04/zentest_version_350_has_been_released.html That's a great news. Josh also shared with me a quick hack to make autotest work with only the RSpec plugin installed. Add the following into your ~/.autotest file http://pastie.caboo.se/53535 Autotest.add_hook :initialize do |autotest| if autotest.is_a? RspecRailsAutotest autotest.spec_command = 'script/spec --options spec/spec.opts' if File.exist? 'script/spec' end end -Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070412/33a787f2/attachment.html From joshknowles at gmail.com Fri Apr 13 03:34:57 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 13 Apr 2007 00:34:57 -0700 Subject: [rspec-users] ZenTest 3.5 & RSpec 0.9 Message-ID: The latest release of Autotest, bundled in ZenTest 3.5, now has support for running specs! No longer do we need to use the rspec_autotest plugin, now it-just-works. The only problem is that the script is assuming you have the rspec gem installed. If you're keeping up with Edge RSpec on your Rails project you've probably just included rspec and rspec_on_rails into your vendor/plugins directory, which by default in 0.9 will include a script/spec command. If thats the case, and you want to use autotest, check out http://joshknowles.com/2007/4/13/zentest-3-5-rspec-0-9-autospec where I document what you need to add to your ~/.autotest file to make things play nice. Hope this helps! 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/20070413/8bb9a505/attachment.html From bosshoff at gmail.com Fri Apr 13 07:55:31 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Fri, 13 Apr 2007 07:55:31 -0400 Subject: [rspec-users] mock out render call in helper Message-ID: <359ebde50704130455g3ae46b28vf6508882aabe6108@mail.gmail.com> Hello, Does someone know where I can hook in to mock out a render call from a helper in Rails? I know I can do this in view specs with the following @controller.template.stub!(:render) but template doesn't seem to be attached to @controller in a helper context. Thanks. -Chris From bosshoff at gmail.com Fri Apr 13 08:05:17 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Fri, 13 Apr 2007 08:05:17 -0400 Subject: [rspec-users] mock out render call in helper In-Reply-To: <359ebde50704130455g3ae46b28vf6508882aabe6108@mail.gmail.com> References: <359ebde50704130455g3ae46b28vf6508882aabe6108@mail.gmail.com> Message-ID: <359ebde50704130505r5438b090m5cd6683117a75aef@mail.gmail.com> Okay, so if I use @controller.render :foo instead of just render :foo in the helper, I can mock it out fine in the specs with @controller.stub!(:render) Am I wrong to use the shortened "render :foo" form in the helpers, or is this a malfunction of RSpec? On 4/13/07, Chris Hoffman wrote: > Hello, > Does someone know where I can hook in to mock out a render call from > a helper in Rails? I know I can do this in view specs with the > following > > @controller.template.stub!(:render) > > but template doesn't seem to be attached to @controller in a helper > context. Thanks. > > -Chris > From bosshoff at gmail.com Fri Apr 13 09:54:30 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Fri, 13 Apr 2007 09:54:30 -0400 Subject: [rspec-users] mock out render call in helper In-Reply-To: <359ebde50704130505r5438b090m5cd6683117a75aef@mail.gmail.com> References: <359ebde50704130455g3ae46b28vf6508882aabe6108@mail.gmail.com> <359ebde50704130505r5438b090m5cd6683117a75aef@mail.gmail.com> Message-ID: <359ebde50704130654j5a964a89qf673d89fdcf8231c@mail.gmail.com> I guess this question really boils down to the following: what are the proper means to access the object that is including the helper being tested? I have been reading through the documentation, and it indicates that calling helper_name :foo will include FooHelper in the context. How then can I mock out methods in this object? In case I am not being clear: say I have the following helper module FooHelper def hello "hello world" end def look_to_hello hello end end I want to make sure the "look_to_hello" method calls "hello," without "hello" actually being called. Thanks. On 4/13/07, Chris Hoffman wrote: > Okay, so if I use > > @controller.render :foo > > instead of just > > render :foo > > in the helper, I can mock it out fine in the specs with > > @controller.stub!(:render) > > Am I wrong to use the shortened "render :foo" form in the helpers, or > is this a malfunction of RSpec? > > On 4/13/07, Chris Hoffman wrote: > > Hello, > > Does someone know where I can hook in to mock out a render call from > > a helper in Rails? I know I can do this in view specs with the > > following > > > > @controller.template.stub!(:render) > > > > but template doesn't seem to be attached to @controller in a helper > > context. Thanks. > > > > -Chris > > > From bosshoff at gmail.com Fri Apr 13 10:03:25 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Fri, 13 Apr 2007 10:03:25 -0400 Subject: [rspec-users] mock out render call in helper In-Reply-To: <359ebde50704130654j5a964a89qf673d89fdcf8231c@mail.gmail.com> References: <359ebde50704130455g3ae46b28vf6508882aabe6108@mail.gmail.com> <359ebde50704130505r5438b090m5cd6683117a75aef@mail.gmail.com> <359ebde50704130654j5a964a89qf673d89fdcf8231c@mail.gmail.com> Message-ID: <359ebde50704130703k3f71a4amc2048a97cd6bf822@mail.gmail.com> Sorry for this stream of consciousness. I am trying to work through a problem, and without the benefit of being able to discuss these situations with my colleague (who is not with the department any longer), I find it necessary to reason through my conundrums by writing. Anyway, I think I have discovered the proper means to achieve what I was talking about in previous posts. 'self' in the spec seems to give one access to the object that is including the helper being spec'd. -Chris On 4/13/07, Chris Hoffman wrote: > I guess this question really boils down to the following: what are > the proper means to access the object that is including the helper > being tested? I have been reading through the documentation, and it > indicates that calling helper_name :foo will include FooHelper in the > context. How then can I mock out methods in this object? > > In case I am not being clear: say I have the following helper > > module FooHelper > def hello > "hello world" > end > > def look_to_hello > hello > end > end > > I want to make sure the "look_to_hello" method calls "hello," without > "hello" actually being called. > > Thanks. > > On 4/13/07, Chris Hoffman wrote: > > Okay, so if I use > > > > @controller.render :foo > > > > instead of just > > > > render :foo > > > > in the helper, I can mock it out fine in the specs with > > > > @controller.stub!(:render) > > > > Am I wrong to use the shortened "render :foo" form in the helpers, or > > is this a malfunction of RSpec? > > > > On 4/13/07, Chris Hoffman wrote: > > > Hello, > > > Does someone know where I can hook in to mock out a render call from > > > a helper in Rails? I know I can do this in view specs with the > > > following > > > > > > @controller.template.stub!(:render) > > > > > > but template doesn't seem to be attached to @controller in a helper > > > context. Thanks. > > > > > > -Chris > > > > > > From ed.howland at gmail.com Fri Apr 13 10:21:48 2007 From: ed.howland at gmail.com (Ed Howland) Date: Fri, 13 Apr 2007 09:21:48 -0500 Subject: [rspec-users] sqlite3 and rspec_on_rails tests In-Reply-To: <89322292-DCBF-4589-B4BC-AFFE49E7596C@railsnewbie.com> References: <89322292-DCBF-4589-B4BC-AFFE49E7596C@railsnewbie.com> Message-ID: <3df642dd0704130721h3e0a4985p13d1b3b9ffa7e7ed@mail.gmail.com> I Tinyurl'd the singular resources link http://tinyurl.com/2y8jmk And to view with confidence: http://preview.tinyurl.com/2y8jmk Ed On 3/27/07, Scott Taylor wrote: > > As I think I previously mentioned, there is an incompatibility with > rails 1.2.1 and sqlite3 3.3.8. > > see: http://weblog.rubyonrails.org/2007/1/29/using-sqlite3-with-rails > and: http://weblog.rubyonrails.org/2007/2/6/rails-1-2-2-sqlite3-gems- > singular-resources > > Sqlite is now at 3.3.13. > > Because of this, if a developer is trying to create a patch for > rspec_on_rails, he will have one of the following two problems (if he > is using sqlite): > > 1. the rails 1.2.1 specs will fail, if sqlite > 3.3.7 > 2. the rails 1.2.2 and greater will fail if sqlite is < 3.3.8. > > This renders running all of the specs as impossible with sqlite, > doesn't it? > > Either way, there should be *something* in the docs about it. Let > me know what you guys think. > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Ed Howland http://greenprogrammer.blogspot.com From work at ashleymoran.me.uk Fri Apr 13 11:29:32 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Fri, 13 Apr 2007 16:29:32 +0100 Subject: [rspec-users] mock out render call in helper In-Reply-To: <359ebde50704130654j5a964a89qf673d89fdcf8231c@mail.gmail.com> References: <359ebde50704130455g3ae46b28vf6508882aabe6108@mail.gmail.com> <359ebde50704130505r5438b090m5cd6683117a75aef@mail.gmail.com> <359ebde50704130654j5a964a89qf673d89fdcf8231c@mail.gmail.com> Message-ID: On 13 Apr 2007, at 14:54, Chris Hoffman wrote: > module FooHelper > def hello > "hello world" > end > > def look_to_hello > hello > end > end Chris, The approach I've taken is to turn the support methods into methods on separate objects, eg (not that I've had this exact problem) module FooHelper class Greeter def hello "hello world" end end def look_to_hello Greeter.new.hello end end You could make it "hello" class method if you're not bothered about blanket stubbing. (I tend to go with objects just in case I want to inject them later, rather than have them created in-place with new) Ashley From nicksieger at gmail.com Fri Apr 13 11:41:51 2007 From: nicksieger at gmail.com (Nick Sieger) Date: Fri, 13 Apr 2007 10:41:51 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: Message-ID: On 4/13/07, Matt Aimonetti wrote: > > Josh Knowles http://joshknowles.com/ just let me know that ZenTest Autotest > 3.50 now handles your RSpec specs. > > http://blog.zenspider.com/archives/2007/04/zentest_version_350_has_been_released.html > > That's a great news. That's awesome, I had no idea Ryan was even planning to do anything with it. David and I were conversing about putting it in RSpec proper, because I hadn't heard anything. No need now! /Nick From bob.cotton at rallydev.com Fri Apr 13 12:53:48 2007 From: bob.cotton at rallydev.com (Bob Cotton) Date: Fri, 13 Apr 2007 10:53:48 -0600 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: (Nick Sieger's message of "Fri, 13 Apr 2007 10:41:51 -0500") References: Message-ID: "Nick Sieger" writes: > On 4/13/07, Matt Aimonetti wrote: >> >> Josh Knowles http://joshknowles.com/ just let me know that ZenTest Autotest >> 3.50 now handles your RSpec specs. >> >> http://blog.zenspider.com/archives/2007/04/zentest_version_350_has_been_released.html >> >> That's a great news. > > That's awesome, I had no idea Ryan was even planning to do anything > with it. David and I were conversing about putting it in RSpec > proper, because I hadn't heard anything. No need now! The one in ZenTest is only the Rails version, not the standalone one also. - bob > > /Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From court3nay at gmail.com Fri Apr 13 14:30:02 2007 From: court3nay at gmail.com (Courtenay) Date: Fri, 13 Apr 2007 11:30:02 -0700 Subject: [rspec-users] specing class methods In-Reply-To: <5882DEB9-59FC-4AB8-8817-BB935EF831CE@railsnewbie.com> References: <5882DEB9-59FC-4AB8-8817-BB935EF831CE@railsnewbie.com> Message-ID: <4b430c8f0704131130y2fe0ebcbs54af708fbcc74910@mail.gmail.com> > 1. How do I spec out class methods? (please point me to docs, if > any. I can only find class level specing on "partial mocks" (of > rails class objects) This doesn't work? Autotest.spec!(:run) or do you perhaps want to return a proc that gets called? > 2. How can I tell that new.run has been called, without saying > should_receive(:new) and should_receive(:run) in separate specs? If you want instance method stubs, that's handled by mocha but AFAIK not rspec. Mocha does it something like Autotest.any_instance.stubs(:run) This'd be a great rspec feature (or maybe I just couldn't find it). Or maybe you want to do it more like test = Autotest.new test.should_receive(:run) I don't know about the rest, still learning :) From hughes.james at gmail.com Fri Apr 13 14:59:05 2007 From: hughes.james at gmail.com (James Hughes) Date: Fri, 13 Apr 2007 11:59:05 -0700 Subject: [rspec-users] rspec on rails won't install Message-ID: <765a2c230704131159o5a403d52wf4948ddd742b89f@mail.gmail.com> Hi: This command: svn co svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0/rspec_on_rails/vendor/plugins/rspec_on_rail Gives me this output: svn: URL 'svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0/rspec_on_rails/vendor/plugins/rspec_on_rails' doesn't exist If I go the 'script/plugin install' route, I get "Export complete." Anybody know what's happening here? James From joshknowles at gmail.com Fri Apr 13 15:50:33 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 13 Apr 2007 12:50:33 -0700 Subject: [rspec-users] rspec on rails won't install In-Reply-To: <765a2c230704131159o5a403d52wf4948ddd742b89f@mail.gmail.com> References: <765a2c230704131159o5a403d52wf4948ddd742b89f@mail.gmail.com> Message-ID: On 4/13/07, James Hughes wrote: > > Hi: > This command: > svn co > svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0/rspec_on_rails/vendor/plugins/rspec_on_rail > > Anybody know what's happening here? The directory structure changed a bit with 0.9. Try svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0/rspec_on_rails Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070413/b1cc9948/attachment.html From joshknowles at gmail.com Fri Apr 13 15:52:53 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 13 Apr 2007 12:52:53 -0700 Subject: [rspec-users] rspec on rails won't install In-Reply-To: References: <765a2c230704131159o5a403d52wf4948ddd742b89f@mail.gmail.com> Message-ID: On 4/13/07, Josh Knowles wrote: > > > > The directory structure changed a bit with 0.9. Try > svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0/rspec_on_rails > Correction, this should be svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA/rspec_on_rails -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070413/17de4cda/attachment.html From mailing_lists at railsnewbie.com Fri Apr 13 17:05:53 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 13 Apr 2007 17:05:53 -0400 Subject: [rspec-users] specing class methods In-Reply-To: <4b430c8f0704131130y2fe0ebcbs54af708fbcc74910@mail.gmail.com> References: <5882DEB9-59FC-4AB8-8817-BB935EF831CE@railsnewbie.com> <4b430c8f0704131130y2fe0ebcbs54af708fbcc74910@mail.gmail.com> Message-ID: On Apr 13, 2007, at 2:30 PM, Courtenay wrote: >> 1. How do I spec out class methods? (please point me to docs, if >> any. I can only find class level specing on "partial mocks" (of >> rails class objects) > > This doesn't work? > > Autotest.spec!(:run) > > or do you perhaps want to return a proc that gets called? I believe that works. But how would I do it for Kernel.exit ? Kernel is a module (which I suppose is included in Object). I want to make sure that a given method calls exit. Of course I don't want to actually call exit - that should terminate the running of the spec's, should it? So I'd like to spec out Kernel.exit. How would I do that? > >> 2. How can I tell that new.run has been called, without saying >> should_receive(:new) and should_receive(:run) in separate specs? > > If you want instance method stubs, that's handled by mocha but AFAIK > not rspec. Mocha does it something like Well I have a class method which calls new.run, so I suppose I should be stubbing new and run. I want to make sure that the class method calls both of these methods (new and run) in sequence. the class should look something like the following: class Autotest def self.run new.run end def new; ... ; end def run; ...; end end So what I really want is something like: Autotest.run.should_receive(:new).should_receive(:run) or some variation of that. Does that clarify the matter? Scott From joshknowles at gmail.com Fri Apr 13 18:03:08 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 13 Apr 2007 15:03:08 -0700 Subject: [rspec-users] specing class methods In-Reply-To: References: <5882DEB9-59FC-4AB8-8817-BB935EF831CE@railsnewbie.com> <4b430c8f0704131130y2fe0ebcbs54af708fbcc74910@mail.gmail.com> Message-ID: On 4/13/07, Scott Taylor wrote: > Autotest.run.should_receive(:new).should_receive(:run) Is this what you're trying to do? autotest = mock('autotest') autotest.should_receive(:run) Autotest.should_receive(:new).and_return(autotest) -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070413/6da084c3/attachment.html From dchelimsky at gmail.com Fri Apr 13 18:10:30 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Apr 2007 17:10:30 -0500 Subject: [rspec-users] rspec on rails won't install In-Reply-To: References: <765a2c230704131159o5a403d52wf4948ddd742b89f@mail.gmail.com> Message-ID: <57c63afe0704131510q468e05bdt4cad547034be2144@mail.gmail.com> On 4/13/07, Josh Knowles wrote: > > > On 4/13/07, Josh Knowles wrote: > > > > > > > > The directory structure changed a bit with 0.9. Try > svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0/rspec_on_rails > > Correction, this should be > svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA/rspec_on_rails Close, but not quite. Here's the latest: svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_2/rspec svn://rubyforge.org/var/svn/rspec/tags/REL_0_9_0_BETA_2/rspec_on_rails Cheers, David > > > -- > 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 dchelimsky at gmail.com Fri Apr 13 18:22:37 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Apr 2007 17:22:37 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: Message-ID: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> On 4/13/07, Nick Sieger wrote: > On 4/13/07, Matt Aimonetti wrote: > > > > Josh Knowles http://joshknowles.com/ just let me know that ZenTest Autotest > > 3.50 now handles your RSpec specs. > > > > http://blog.zenspider.com/archives/2007/04/zentest_version_350_has_been_released.html > > > > That's a great news. > > That's awesome, I had no idea Ryan was even planning to do anything > with it. David and I were conversing about putting it in RSpec > proper, because I hadn't heard anything. No need now! Well, there might be a need. There are some things that have already changed in RSpec 0.9 that cause this to not work properly (there is no longer a -s option, for example), and not all of the dirs for rails are accounted for (it doesn't pay attention to the view spec directories, for example). I'll see if I can work w/ Ryan to come up w/ a good separation of responsibilities for what should stay in ZenTest and what should be defined directly in RSpec. David > > /Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Fri Apr 13 19:56:20 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 13 Apr 2007 19:56:20 -0400 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> Message-ID: <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> I'm actually pretty close to finishing Autospec - a port of autotest to RSpec (although for the time being it only works for standalone projects). I should probably be done with this standalone version in a week or so. Scott On Apr 13, 2007, at 6:22 PM, David Chelimsky wrote: > On 4/13/07, Nick Sieger wrote: >> On 4/13/07, Matt Aimonetti wrote: >>> >>> Josh Knowles http://joshknowles.com/ just let me know that >>> ZenTest Autotest >>> 3.50 now handles your RSpec specs. >>> >>> http://blog.zenspider.com/archives/2007/04/ >>> zentest_version_350_has_been_released.html >>> >>> That's a great news. >> >> That's awesome, I had no idea Ryan was even planning to do anything >> with it. David and I were conversing about putting it in RSpec >> proper, because I hadn't heard anything. No need now! > > Well, there might be a need. There are some things that have already > changed in RSpec 0.9 that cause this to not work properly (there is no > longer a -s option, for example), and not all of the dirs for rails > are accounted for (it doesn't pay attention to the view spec > directories, for example). I'll see if I can work w/ Ryan to come up > w/ a good separation of responsibilities for what should stay in > ZenTest and what should be defined directly in RSpec. > > 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 From joshknowles at gmail.com Fri Apr 13 20:09:33 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 13 Apr 2007 17:09:33 -0700 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> Message-ID: On 4/13/07, Scott Taylor wrote: > > > I'm actually pretty close to finishing Autospec - a port of autotest > to RSpec (although for the time being it only works for standalone > projects). I should probably be done with this standalone version in > a week or so. While I definitely appreciate you taking the time to add standalone spec support, is there any reason you are forking this as opposed to just submitting a patch to Ryan? He has put in quite a bit of effort in the extensibility of Autotest, I'd hate to see that forked. -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070413/a7b94f0c/attachment-0001.html From dchelimsky at gmail.com Sat Apr 14 00:59:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Apr 2007 23:59:00 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> Message-ID: <57c63afe0704132159mccec6b0mec96bd28128d29c8@mail.gmail.com> On 4/13/07, Josh Knowles wrote: > > > On 4/13/07, Scott Taylor wrote: > > > > I'm actually pretty close to finishing Autospec - a port of autotest > > to RSpec (although for the time being it only works for standalone > > projects). I should probably be done with this standalone version in > > a week or so. > > While I definitely appreciate you taking the time to add standalone spec > support, is there any reason you are forking this as opposed to just > submitting a patch to Ryan? He has put in quite a bit of effort in the > extensibility of Autotest, I'd hate to see that forked. I agree that we should extend rather than replace. The trick is to figure out what belongs in Autotest and what belongs in RSpec. It seems to me that everything related to specific commands and directories should live in RSpec and pretty much everything else belongs in ZenTest. I haven't had time to look to see if this is already doable but it might be. I'll take a peek this coming week. David > > > -- > 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 cwdinfo at gmail.com Sun Apr 15 14:04:20 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 15 Apr 2007 11:04:20 -0700 Subject: [rspec-users] Stubbing Login Stuff In-Reply-To: References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> Message-ID: For some reason, I'm completely blanking on how to do this... Sorry for the lots-o-code example. What I'm trying to do: stub the validate_login method in application_controller so it returns true (user is logged in). What happens: validate_login method in application_controller.rb is called instead of my stub. What I'm struggling with is the syntax to make the stub override the protected method in the parent class. Thanks, application.rb def requires_authorization render(:template => 'shared/login') unless validate_login end protected def validate_login return false if session[:user].blank? || session[:user] != LOGIN_USER_NAME # oversimplification, be gentle return true end admin_controller.rb class AdminController < ApplicationController before_filter :requires_authorization def index end end admin_controller_spec.rb describe "an AdminController should" do controller_name :admin integrate_views it "should grant access to users who are logged in" do stub!(:validate_login).and_return(true) # also tried ApplicationController.stub! (:validate_login).and_return(true). Same result. get :index response.should be_success puts response.body response.should have_tag('h1', 'Administer Site') end end From pergesu at gmail.com Sun Apr 15 14:22:38 2007 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 15 Apr 2007 12:22:38 -0600 Subject: [rspec-users] Stubbing Login Stuff In-Reply-To: References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> Message-ID: <810a540e0704151122m6095603aj943fb81eb1fb8b5@mail.gmail.com> On 4/15/07, s.ross wrote: > For some reason, I'm completely blanking on how to do this... Sorry > for the lots-o-code example. > > What I'm trying to do: stub the validate_login method in > application_controller so it returns true (user is logged in). > What happens: validate_login method in application_controller.rb is > called instead of my stub. In your setup (or wherever), do controller.stub!(:validate_login).and_return true When you called stub! without an explicit receiver, the message gets sent to self, which is a context. Then when you called stub! on ApplicationController, it created a class-level method. In Rails, each request creates a new controller instance, so you need to call stub! on that instance. Pat From cwdinfo at gmail.com Sun Apr 15 15:11:45 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 15 Apr 2007 12:11:45 -0700 Subject: [rspec-users] Stubbing Login Stuff In-Reply-To: <810a540e0704151122m6095603aj943fb81eb1fb8b5@mail.gmail.com> References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> <810a540e0704151122m6095603aj943fb81eb1fb8b5@mail.gmail.com> Message-ID: That was the magic. controller. As it turns out, this doesn't have to happen in setup, so I can specify both the positive and negative specification in one describe, as: describe "an AdminController login process" do controller_name :admin integrate_views it "should deny access if you aren't logged in" do # stuff to determine that user gets a login page end it "should permit access if you are logged in" do controller.stub!(:validate_login).and_return(true) # stuff to determine success end end Is there a benefit to using two describe blocks, one with a setup/ stub! and the other without? Steve On Apr 15, 2007, at 11:22 AM, Pat Maddox wrote: > On 4/15/07, s.ross wrote: >> For some reason, I'm completely blanking on how to do this... Sorry >> for the lots-o-code example. >> >> What I'm trying to do: stub the validate_login method in >> application_controller so it returns true (user is logged in). >> What happens: validate_login method in application_controller.rb is >> called instead of my stub. > > In your setup (or wherever), do > > controller.stub!(:validate_login).and_return true > > When you called stub! without an explicit receiver, the message gets > sent to self, which is a context. Then when you called stub! on > ApplicationController, it created a class-level method. In Rails, > each request creates a new controller instance, so you need to call > stub! on that instance. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Apr 16 05:29:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 16 Apr 2007 04:29:12 -0500 Subject: [rspec-users] Fwd: ANN: FlexMock 0.6.0 Released In-Reply-To: References: Message-ID: <57c63afe0704160229m160ae077l679f24501d122708@mail.gmail.com> FYI - Jim Weirich just released an rspec-compatible version of FlexMock. For those of you using trunk, you can now use either FlexMock, Mocha, or RSpec's built-in mocking framework by saying: Spec::Runner.configure do |config| config.mock_with :flexmock # or :mocha or :rspec (default) end The choice is yours. Mock in peace. Cheers, David ---------- Forwarded message ---------- From: Jim Weirich Date: Apr 15, 2007 9:34 PM Subject: ANN: FlexMock 0.6.0 Released To: ruby-talk ML = FlexMock 0.6.0 Released FlexMock is a flexible mocking library for use in unit testing and behavior specification in Ruby. Version 0.6.0 introduces a number of API enhancements to make testing with mocks even easier than before. == New in 0.6.0 * Better integration with Test::Unit (no need to explicitly include FlexMock::TestCase). * Integration with RSpec (version 0.9.0 or later of RSpec is required). * The +flexmock+ method will now create both regular mocks and partial mocks. flexmock() # => a full mock flexmock(person) # => a partial mock based on person (+flexstub+ is still included for backwards compatibility). * Quick and simple mocks my now be created using an expectation hash. For example: flexmock(:foo => 10, :bar => "Hello") will create a mock with two methods, :foo and :bar,defined. :foo will return 10 when invoked, and :bar will return "Hello". * The +should_receive+ method will now allow multiple methods (with the same constraints) be defined in a single call. For example, the following declares that both :read and :write need to be called at least one time each on the mock object. flexmock.should_receive(:read, :write).at_least.once * +should_recieve+ now will allow expectation hashes as arguments. This is similar to the list of methods, but allows each defined method to have its own return value. flexmock.should_receive(:name => "John", :age => 32) * In addition to using a block for defining constrains, constraints may now be applied directly to the return value of +new_instances+. Combined with the expectation hashes supported by +should_receive+, simple mocking scenarios have become much more succinct. For example: flexmock(Person).new_instances.should_receive(:name => "John", :age => 32) * Improved implementation, allowing for more flexible use and greater consistency between full mock and partial mocks. * Version 0.6.0 also includes a fix for an incompatibility with some older versions of RCov. The FlexMock Rakefile now includes a RCov task (and we have 100% code coverage). == What is FlexMock? FlexMock is a flexible framework for creating mock object for testing. When running unit tests, it is often desirable to use isolate the objects being tested from the "real world" by having them interact with simplified test objects. Sometimes these test objects simply return values when called, other times they verify that certain methods were called with particular arguments in a particular order. FlexMock makes creating these test objects easy. === Features * Easy integration with both Test::Unit and RSpec. Mocks created with the flexmock method are automatically verified at the end of the test or example. * A fluent interface that allows mock behavior to be specified very easily. * A "record mode" where an existing implementation can record its interaction with a mock for later validation against a new implementation. * Easy mocking of individual methods in existing, non-mock objects. * The ability to cause classes to instantiate test instances (instead of real instances) for the duration of a test. === Example Suppose you had a Dog object that wagged a tail when it was happy. Something like this: class Dog def initialize(a_tail) @tail = a_tail end def happy @tail.wag end end To test the +Dog+ class without a real +Tail+ object (perhaps because real +Tail+ objects activate servos in some robotic equipment), you can do something like this: require 'test/unit' require 'flexmock/test_unit' class TestDog < Test::Unit::TestCase def test_dog_wags_tail_when_happy tail = flexmock("tail") tail.should_receive(:wag).once dog = Dog.new(tail) dog.happy end end FlexMock will automatically verify that the mocked tail object received the message +wag+ exactly one time. If it doesn't, the test will not pass. See the FlexMock documentation at http://flexmock.rubyforge.org for details on specifying arguments and return values on mocked methods, as well as a simple technique for mocking tail objects when the Dog class creates the tail objects directly. == Availability You can make sure you have the latest version with a quick RubyGems command: gem install flexmock (you may need root/admin privileges) Otherwise, you can get it from the more traditional places: Download:: http://rubyforge.org/project/showfiles.php?group_id=170 You will find documentation at: http://flexmock.rubyforge.org. -- Jim Weirich -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Apr 16 10:07:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 16 Apr 2007 09:07:29 -0500 Subject: [rspec-users] before before and after after Message-ID: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> Hi all, There are currently a number of ways to extend RSpec that are documented inconsistently and work in sometimes conflicting and/or confusing ways. I'd like to resolve that. The recent addition of Spec::Runner.configure is part of that resolution. The thing I want to tackle now is the stuff that happens before and after each example. Currently (in trunk), things are executed in the following order: describe Thing do before(:all) do #happens first, but only once within this "describe" block end before(:each) do #happens before each example within this "describe" block end it "should ..." do #this is the example end after(:each) do #happens after each example within this "describe" block end after(:all) do #happens last, but only once within this "describe" block end end In addition to this, there have been requests to support global "before" and "after". Here's where I'd like to end up: Spec::DSL::Example.before(:first) do # before "before(:all)" and "before(:each)" end Spec::DSL::Example.before(:last) do # after "before(:all)" and "before(:each)", but before the example end Spec::DSL::Example.after(:first) do # before "after(:each)" and "after(:all)", but after the example end Spec::DSL::Example.after(:last) do # after "after(:each)" and "after(:all)" end So the over all order for every example (a.k.a. specify) would be: before(:first) before(:all) #once per "describe" before(:each) before(:last) example after(:first) after(:each) after(:all) #once per "describe" after(:last) I'm certainly open to other suggestions - this is merely a proposal. In most cases you wouldn't use all of these. In fact, you may not use any of them if you prefer the Object Mother approach (helper methods that create the state you want to start with). But this would give you a lot of choice at both global and granular levels. WDYT? Too confusing? Too limiting? Just right? Thanks, David From mtrier at eminentconsultinggroup.com Mon Apr 16 10:24:53 2007 From: mtrier at eminentconsultinggroup.com (Michael Trier) Date: Mon, 16 Apr 2007 10:24:53 -0400 Subject: [rspec-users] before before and after after In-Reply-To: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> References: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> Message-ID: <7810AB1E-6D5D-41A3-8CAD-4C28C4985802@eminentconsultinggroup.com> > Hi all, > > There are currently a number of ways to extend RSpec that are > documented inconsistently and work in sometimes conflicting and/or > confusing ways. I'd like to resolve that. The recent addition of > Spec::Runner.configure is part of that resolution. > > The thing I want to tackle now is the stuff that happens before and > after each example. Currently (in trunk), things are executed in the > following order: > > describe Thing do > before(:all) do > #happens first, but only once within this "describe" block > end > before(:each) do > #happens before each example within this "describe" block > end > it "should ..." do > #this is the example > end > after(:each) do > #happens after each example within this "describe" block > end > after(:all) do > #happens last, but only once within this "describe" block > end > end > > In addition to this, there have been requests to support global > "before" and "after". Here's where I'd like to end up: > > Spec::DSL::Example.before(:first) do > # before "before(:all)" and "before(:each)" > end > > Spec::DSL::Example.before(:last) do > # after "before(:all)" and "before(:each)", but before the example > end > > Spec::DSL::Example.after(:first) do > # before "after(:each)" and "after(:all)", but after the example > end > > Spec::DSL::Example.after(:last) do > # after "after(:each)" and "after(:all)" > end > > So the over all order for every example (a.k.a. specify) would be: > > before(:first) > before(:all) #once per "describe" > before(:each) > before(:last) > example > after(:first) > after(:each) > after(:all) #once per "describe" > after(:last) > > I'm certainly open to other suggestions - this is merely a proposal. > In most cases you wouldn't use all of these. In fact, you may not use > any of them if you prefer the Object Mother approach (helper methods > that create the state you want to start with). But this would give you > a lot of choice at both global and granular levels. > > WDYT? Too confusing? Too limiting? Just right? It sounds good to me, although I can't see a situation where I would need before(:last) or after(:first), just the outerlying ones (before (:first) and after(:last). Michael From dchelimsky at gmail.com Mon Apr 16 10:29:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 16 Apr 2007 09:29:10 -0500 Subject: [rspec-users] before before and after after In-Reply-To: <7810AB1E-6D5D-41A3-8CAD-4C28C4985802@eminentconsultinggroup.com> References: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> <7810AB1E-6D5D-41A3-8CAD-4C28C4985802@eminentconsultinggroup.com> Message-ID: <57c63afe0704160729l4b8c09e9w97eada3cc5b86460@mail.gmail.com> On 4/16/07, Michael Trier wrote: > > Hi all, > > > > There are currently a number of ways to extend RSpec that are > > documented inconsistently and work in sometimes conflicting and/or > > confusing ways. I'd like to resolve that. The recent addition of > > Spec::Runner.configure is part of that resolution. > > > > The thing I want to tackle now is the stuff that happens before and > > after each example. Currently (in trunk), things are executed in the > > following order: > > > > describe Thing do > > before(:all) do > > #happens first, but only once within this "describe" block > > end > > before(:each) do > > #happens before each example within this "describe" block > > end > > it "should ..." do > > #this is the example > > end > > after(:each) do > > #happens after each example within this "describe" block > > end > > after(:all) do > > #happens last, but only once within this "describe" block > > end > > end > > > > In addition to this, there have been requests to support global > > "before" and "after". Here's where I'd like to end up: > > > > Spec::DSL::Example.before(:first) do > > # before "before(:all)" and "before(:each)" > > end > > > > Spec::DSL::Example.before(:last) do > > # after "before(:all)" and "before(:each)", but before the example > > end > > > > Spec::DSL::Example.after(:first) do > > # before "after(:each)" and "after(:all)", but after the example > > end > > > > Spec::DSL::Example.after(:last) do > > # after "after(:each)" and "after(:all)" > > end > > > > So the over all order for every example (a.k.a. specify) would be: > > > > before(:first) > > before(:all) #once per "describe" > > before(:each) > > before(:last) > > example > > after(:first) > > after(:each) > > after(:all) #once per "describe" > > after(:last) > > > > I'm certainly open to other suggestions - this is merely a proposal. > > In most cases you wouldn't use all of these. In fact, you may not use > > any of them if you prefer the Object Mother approach (helper methods > > that create the state you want to start with). But this would give you > > a lot of choice at both global and granular levels. > > > > WDYT? Too confusing? Too limiting? Just right? > > It sounds good to me, although I can't see a situation where I would > need before(:last) or after(:first), just the outerlying ones (before > (:first) and after(:last). The reason for before(:last) is a situation where you want to be able to set something up most of the time, but not all of the time. Take a look at my last comment on http://rubyforge.org/tracker/?group_id=797&atid=3152&func=detail&aid=9984. If that doesn't clear it up for you, feel free to ask questions here. Thx, David > > Michael > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Apr 16 18:39:17 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 17 Apr 2007 00:39:17 +0200 Subject: [rspec-users] before before and after after In-Reply-To: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> References: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> Message-ID: <8d961d900704161539n5ccda496o11171c097d4a44b@mail.gmail.com> Dave and I have just had a lengthy chat about this and I think we've come up with a pretty elegant solution for an API. It's inspired from the filter chaining mechanism in Rails. Essentially you can specify several before and after blocks. This is actually already supported in RSpec. What we need is a mechanism that allows users to have more fine grained control of the order in which these blocks are executed, and we're thinking of supporting this with 4 basic methods: #prepend_before(where=:each, &proc) #append_before(where=:each, &proc) #prepend_after(where=:each, &proc) #append_after(where=:each, &proc) Further, #before will be an alias for #append_before and #after will be an alias for #prepend_after. This allows users to just write before{..} and after{..} if they don't care about the order. This means that globally specified #before blocks (typically in a spec_helper.rb via Spec::Runner#configure, which usually gets loaded before everything else) will be executed before any #before blocks in individual specs. The opposite will be the case for #after blocks. However, for those of you who wish to execute a #before block *before* the global #before block, you can use #prepend_before in the specs that want to do this. Finally, the #before(:all) blocks will be executed before #prepend_before(:each) blocks - the +where+ argument trumps the prepend/append. None of this is implemented yet, so please chime in soon if you have any comments about this. Aslak On 4/16/07, David Chelimsky wrote: > Hi all, > > There are currently a number of ways to extend RSpec that are > documented inconsistently and work in sometimes conflicting and/or > confusing ways. I'd like to resolve that. The recent addition of > Spec::Runner.configure is part of that resolution. > > The thing I want to tackle now is the stuff that happens before and > after each example. Currently (in trunk), things are executed in the > following order: > > describe Thing do > before(:all) do > #happens first, but only once within this "describe" block > end > before(:each) do > #happens before each example within this "describe" block > end > it "should ..." do > #this is the example > end > after(:each) do > #happens after each example within this "describe" block > end > after(:all) do > #happens last, but only once within this "describe" block > end > end > > In addition to this, there have been requests to support global > "before" and "after". Here's where I'd like to end up: > > Spec::DSL::Example.before(:first) do > # before "before(:all)" and "before(:each)" > end > > Spec::DSL::Example.before(:last) do > # after "before(:all)" and "before(:each)", but before the example > end > > Spec::DSL::Example.after(:first) do > # before "after(:each)" and "after(:all)", but after the example > end > > Spec::DSL::Example.after(:last) do > # after "after(:each)" and "after(:all)" > end > > So the over all order for every example (a.k.a. specify) would be: > > before(:first) > before(:all) #once per "describe" > before(:each) > before(:last) > example > after(:first) > after(:each) > after(:all) #once per "describe" > after(:last) > > I'm certainly open to other suggestions - this is merely a proposal. > In most cases you wouldn't use all of these. In fact, you may not use > any of them if you prefer the Object Mother approach (helper methods > that create the state you want to start with). But this would give you > a lot of choice at both global and granular levels. > > WDYT? Too confusing? Too limiting? Just right? > > Thanks, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at ekenosen.net Mon Apr 16 20:45:05 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Mon, 16 Apr 2007 20:45:05 -0400 Subject: [rspec-users] before before and after after In-Reply-To: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> References: <57c63afe0704160707q7de1ed20j2b2400881085a17f@mail.gmail.com> Message-ID: <276ff9870704161745j35979e17uf30e9919fc154abd@mail.gmail.com> On 4/16/07, David Chelimsky wrote: > The thing I want to tackle now is the stuff that happens before and > after each example. Currently (in trunk), things are executed in the > following order: ... > So the over all order for every example (a.k.a. specify) would be: > > before(:first) > before(:all) #once per "describe" > before(:each) > before(:last) > example > after(:first) > after(:each) > after(:all) #once per "describe" > after(:last) > > I'm certainly open to other suggestions - this is merely a proposal. > In most cases you wouldn't use all of these. ... > WDYT? Too confusing? Too limiting? Just right? I usually would not have a need for any of them except for before(:each). I like the new syntax though. "before(:all)" and "before(:each)" seem better than "context_setup" and "setup". And by declaring all of them, it feels consistent and somewhat intuitive, as well as very customizable. I like it. Slightly tangential, but I hope not to much so... I am curious though if this could be made to work with my earlier suggestion: http://rubyforge.org/pipermail/rspec-users/2007-April/001180.html Specifically, a way of running a specific action ("example"?) for each expectation, but sometimes run it before and sometimes after (depending upon whether the expectation is a mock setup or a state based check). The way I wrote it before, I presented two new scenarios... but one of those scenarios could also be the default. describe Thing do before(:all) do #happens first, but only once within this "describe" block end before(:each) do #happens before each example within this "describe" block end for_each do # happens before each "it" example within this "describe" block end it "should ..." do #this is an expectation about the state after the "for_each" block end after(:each) do #happens after each example within this "describe" block end after(:all) do #happens last, but only once within this "describe" block end end or describe Thing do before(:all) do #happens first, but only once within this "describe" block end before(:each) do #happens before each example within this "describe" block end expect_that_it "should ..." do #this is the mock expectation end for_each do # happens after each "expect_that_it" example within this "describe" block end after(:each) do #happens after each example within this "describe" block end after(:all) do #happens last, but only once within this "describe" block end end Basically, the "for_each" block runs before each "it 'should...'" expectation, and after each "expect_that_it 'should...'" mock expectation. I think that this could significantly increase the readability of specs that use a lot of mock expectations, as well as DRY up the style proposed here: http://blog.davidchelimsky.net/articles/2006/11/09/tutorial-rspec-stubs-and-mocks But it might also make things more confusing... and I'm really not sure that "for_each" is the right phrase to describe the block (I've been using "action" up until now, and that doesn't feel quite right either). I'm I chasing a bad approach here? -- Nick From alex.edwards at workingmouse.com Mon Apr 16 22:23:52 2007 From: alex.edwards at workingmouse.com (Alex Edwards) Date: Tue, 17 Apr 2007 12:23:52 +1000 Subject: [rspec-users] rspec with CI Message-ID: <46242FB8.3040708@workingmouse.com> I am a bit of a rails and rspec noob. I am trying to use rspec in conjunction with CruiseControlrb. When I run a cruise build having spec errors, the build does not indicate a failure. I have tried to track down why this is the case, and my best guess is that the spec task is kicking off the spec via a ruby() method in rake, and that ruby method does not propagate my spec failure back to rake. Any help in setting this up would be much appreciated. Also, if there is a better alternative to cruisecontrolrb that integrates nicely with rspec, please let me know. Thanks From mailing_lists at railsnewbie.com Mon Apr 16 22:47:45 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 16 Apr 2007 22:47:45 -0400 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> Message-ID: Are there tests for Autotest itself? I can't seem to find any. Scott On Apr 13, 2007, at 8:09 PM, Josh Knowles wrote: > > > On 4/13/07, Scott Taylor wrote: > I'm actually pretty close to finishing Autospec - a port of autotest > to RSpec (although for the time being it only works for standalone > projects). I should probably be done with this standalone version in > a week or so. > > While I definitely appreciate you taking the time to add standalone > spec support, is there any reason you are forking this as opposed > to just submitting a patch to Ryan? He has put in quite a bit of > effort in the extensibility of Autotest, I'd hate to see that forked. > > > -- > 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 mailing_lists at railsnewbie.com Mon Apr 16 22:48:43 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 16 Apr 2007 22:48:43 -0400 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> Message-ID: <6983B89D-E05B-47B3-B698-0E2D8F6041B1@railsnewbie.com> Yes, I guess there are tests. I'll look into doing this... Scott On Apr 13, 2007, at 8:09 PM, Josh Knowles wrote: > > > On 4/13/07, Scott Taylor wrote: > I'm actually pretty close to finishing Autospec - a port of autotest > to RSpec (although for the time being it only works for standalone > projects). I should probably be done with this standalone version in > a week or so. > > While I definitely appreciate you taking the time to add standalone > spec support, is there any reason you are forking this as opposed > to just submitting a patch to Ryan? He has put in quite a bit of > effort in the extensibility of Autotest, I'd hate to see that forked. > > > -- > 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 marcus at marcuscrafter.com Mon Apr 16 22:57:08 2007 From: marcus at marcuscrafter.com (Marcus Crafter) Date: Tue, 17 Apr 2007 12:57:08 +1000 Subject: [rspec-users] rspec with CI In-Reply-To: <46242FB8.3040708@workingmouse.com> References: <46242FB8.3040708@workingmouse.com> Message-ID: <715A9F3C-B6F8-40E1-8F02-58EFCFFE9BF0@marcuscrafter.com> Hi Alex, I'm having a similar problem with CC.rb at the moment - from what I can see, CC.rb is trying to run my spec's using the production database, rather than the test one: 1) ActiveRecord::StatementInvalid in 'A new Activation object should be invalid without a name' Mysql::Error: Table 'cms_production.activations' doesn't exist: SHOW FIELDS FROM activations ./spec/models/activation_spec.rb:7: ... Naturally this causes all of the specs to fail. :-/ Running the same 'rake spec' on the command line in my rails app works as expected. I don't have a solution just yet but have also asked if others were having this problem on the cc.rb users mailing list - hopefully we'll have a solution to it soon. If this isn't the problem you're having - would be good to know so we can sort that out too. At least you're not the only one :) Cheers, Marcus On 17/04/2007, at 12:23 PM, Alex Edwards wrote: > I am a bit of a rails and rspec noob. > > I am trying to use rspec in conjunction with CruiseControlrb. > > When I run a cruise build having spec errors, the build does not > indicate a failure. I have tried to track down why this is the case, > and my best guess is that the spec task is kicking off the spec via a > ruby() method in rake, and that ruby method does not propagate my spec > failure back to rake. > > Any help in setting this up would be much appreciated. > Also, if there is a better alternative to cruisecontrolrb that > integrates nicely with rspec, please let me know. > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Mon Apr 16 23:08:34 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 16 Apr 2007 23:08:34 -0400 Subject: [rspec-users] updating textmate bundle Message-ID: <85EA0B93-AF9D-4BD7-B1DA-8BCE629DA4E4@railsnewbie.com> Just to let you know - in the textmate bundle the snippet shra => "Should raise error" is missing an open parenthesis. The snippet code should be this: lambda { $1 }.should raise_error(${2:error}) $0 and not this: lambda { $1 }.should raise_error${2:error}) $0 Best, Scott From alex.edwards at workingmouse.com Mon Apr 16 23:26:16 2007 From: alex.edwards at workingmouse.com (Alex Edwards) Date: Tue, 17 Apr 2007 13:26:16 +1000 Subject: [rspec-users] rspec with CI In-Reply-To: <715A9F3C-B6F8-40E1-8F02-58EFCFFE9BF0@marcuscrafter.com> References: <46242FB8.3040708@workingmouse.com> <715A9F3C-B6F8-40E1-8F02-58EFCFFE9BF0@marcuscrafter.com> Message-ID: <46243E58.8010201@workingmouse.com> I had that problem too. I ended up just changing my database.yml in my projects/work directory so that production pointed towards the correct database. As my database.yml file is not in source control, this works ok as a workaround. But the problem I am facing is different to that. When I run the spec:app task form cc, spec failures do not result in a build failure. As I said, I think this is because the spec task uses the ruby() method to invoke the specs, and that method is not propagating the spec failure out to the build. I am hoping there might be an option I can pass to the spec that would tell it to reraise any errors, or maybe just a different rake task I can use to invoke my specs? Marcus Crafter wrote: > Hi Alex, > > I'm having a similar problem with CC.rb at the moment - from what I > can see, CC.rb is trying to run my spec's using the production > database, rather than the test one: > > 1) ActiveRecord::StatementInvalid in 'A new Activation object should > be invalid without a name' Mysql::Error: Table > 'cms_production.activations' doesn't exist: SHOW FIELDS FROM > activations ./spec/models/activation_spec.rb:7: > ... > > Naturally this causes all of the specs to fail. :-/ > > Running the same 'rake spec' on the command line in my rails app > works as expected. > > I don't have a solution just yet but have also asked if others were > having this problem on the cc.rb users mailing list - hopefully we'll > have a solution to it soon. > > If this isn't the problem you're having - would be good to know so we > can sort that out too. At least you're not the only one :) > > Cheers, > > Marcus > > On 17/04/2007, at 12:23 PM, Alex Edwards wrote: > > >> I am a bit of a rails and rspec noob. >> >> I am trying to use rspec in conjunction with CruiseControlrb. >> >> When I run a cruise build having spec errors, the build does not >> indicate a failure. I have tried to track down why this is the case, >> and my best guess is that the spec task is kicking off the spec via a >> ruby() method in rake, and that ruby method does not propagate my spec >> failure back to rake. >> >> Any help in setting this up would be much appreciated. >> Also, if there is a better alternative to cruisecontrolrb that >> integrates nicely with rspec, please let me know. >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070417/6ea6d559/attachment-0001.html From esad.talks at esse.at Tue Apr 17 01:27:46 2007 From: esad.talks at esse.at (Esad Hajdarevic) Date: Tue, 17 Apr 2007 07:27:46 +0200 Subject: [rspec-users] rspec with CI In-Reply-To: <46242FB8.3040708@workingmouse.com> References: <46242FB8.3040708@workingmouse.com> Message-ID: <46245AD2.9080905@esse.at> Hi Alex, Alex Edwards wrote: > I am trying to use rspec in conjunction with CruiseControlrb. > How are you running the specs? I'm using cruise.task in lib/tasks and it works perfectly. Here it is: (Note that it's a bit complicated because we run firewatir specs too that need some preparations) task 'cruise' do puts "This is cruise rake task running within the #{RAILS_ENV} environment" Rake::Task['db:migrate'].invoke Rake::Task['db:test:clone_structure'] puts "Executing model specs.." Rake::Task['spec:models'].invoke puts "Executing controller specs.." Rake::Task['spec:controllers'].invoke puts "Loading fixtures to the database.." # load fixtures Rake::Task['spec:db:fixtures:load'].invoke # restart server puts "Restarting server/FCGI.." puts `ruby #{File.dirname(__FILE__)+'/../../script/process/reaper -a kill'}` begin start_firefox puts "Running spec:watir.." Rake::Task['spec:watir'].invoke rescue raise "Watir spec failed!" ensure stop_firefox end end Greetings, Esad From dchelimsky at gmail.com Tue Apr 17 02:42:47 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 01:42:47 -0500 Subject: [rspec-users] updating textmate bundle In-Reply-To: <85EA0B93-AF9D-4BD7-B1DA-8BCE629DA4E4@railsnewbie.com> References: <85EA0B93-AF9D-4BD7-B1DA-8BCE629DA4E4@railsnewbie.com> Message-ID: <57c63afe0704162342y5c5ee913gd8d40fa3b9ad5e8f@mail.gmail.com> On 4/16/07, Scott Taylor wrote: > > Just to let you know - in the textmate bundle the snippet shra => > "Should raise error" is missing an open parenthesis. The snippet > code should be this: > > lambda { $1 }.should raise_error(${2:error}) > $0 > > and not this: > > lambda { $1 }.should raise_error${2:error}) > $0 > > Best, > > Scott Fixed - thanks. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matttemp at gmail.com Tue Apr 17 03:16:17 2007 From: matttemp at gmail.com (Matt Aimonetti) Date: Tue, 17 Apr 2007 00:16:17 -0700 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: <6983B89D-E05B-47B3-B698-0E2D8F6041B1@railsnewbie.com> References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> <6983B89D-E05B-47B3-B698-0E2D8F6041B1@railsnewbie.com> Message-ID: Anyone knows how to get autotest to check on a plugin spec? I'm working on a plugin and I would love to use autotest to check on my specs. On a different note, RSpec has a nice rake command: rake spec:plugins but I wish I could do rake spec:plugins PLUGIN=my_plugin and only run the specs ofor my plugin. (I had issues with other plugins crashing the test before it would reach my plugin :( ) Thanks Matt On 4/16/07, Scott Taylor wrote: > > > Yes, I guess there are tests. > > I'll look into doing this... > > Scott > > > On Apr 13, 2007, at 8:09 PM, Josh Knowles wrote: > > > > > > > On 4/13/07, Scott Taylor wrote: > > I'm actually pretty close to finishing Autospec - a port of autotest > > to RSpec (although for the time being it only works for standalone > > projects). I should probably be done with this standalone version in > > a week or so. > > > > While I definitely appreciate you taking the time to add standalone > > spec support, is there any reason you are forking this as opposed > > to just submitting a patch to Ryan? He has put in quite a bit of > > effort in the extensibility of Autotest, I'd hate to see that forked. > > > > > > -- > > 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 > > _______________________________________________ > 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/20070417/d8be2f74/attachment.html From dchelimsky at gmail.com Tue Apr 17 03:23:11 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 02:23:11 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> <6983B89D-E05B-47B3-B698-0E2D8F6041B1@railsnewbie.com> Message-ID: <57c63afe0704170023t5f457c33x167d81a7ef1d5482@mail.gmail.com> On 4/17/07, Matt Aimonetti wrote: > Anyone knows how to get autotest to check on a plugin spec? I'm working on a > plugin and I would love to use autotest to check on my specs. > > On a different note, RSpec has a nice rake command: rake spec:plugins but I > wish I could do rake spec:plugins PLUGIN=my_plugin and only run the specs > ofor my plugin. (I had issues with other plugins crashing the test before it > would reach my plugin :( ) Just add this to your own spec file: desc "Run my plugin's specs" Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['vendor/plugins/my_plugin/spec/**/*_spec.rb'] end > > Thanks > > Matt > > > > > > > On 4/16/07, Scott Taylor wrote: > > > > Yes, I guess there are tests. > > > > I'll look into doing this... > > > > Scott > > > > > > On Apr 13, 2007, at 8:09 PM, Josh Knowles wrote: > > > > > > > > > > > On 4/13/07, Scott Taylor wrote: > > > I'm actually pretty close to finishing Autospec - a port of autotest > > > to RSpec (although for the time being it only works for standalone > > > projects). I should probably be done with this standalone version in > > > a week or so. > > > > > > While I definitely appreciate you taking the time to add standalone > > > spec support, is there any reason you are forking this as opposed > > > to just submitting a patch to Ryan? He has put in quite a bit of > > > effort in the extensibility of Autotest, I'd hate to see that forked. > > > > > > > > > -- > > > 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 > > > > _______________________________________________ > > 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 Apr 17 03:23:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 02:23:50 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: <57c63afe0704170023t5f457c33x167d81a7ef1d5482@mail.gmail.com> References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> <6983B89D-E05B-47B3-B698-0E2D8F6041B1@railsnewbie.com> <57c63afe0704170023t5f457c33x167d81a7ef1d5482@mail.gmail.com> Message-ID: <57c63afe0704170023r2ff55ec8xa02078599bc29f56@mail.gmail.com> On 4/17/07, David Chelimsky wrote: > On 4/17/07, Matt Aimonetti wrote: > > Anyone knows how to get autotest to check on a plugin spec? I'm working on a > > plugin and I would love to use autotest to check on my specs. > > > > On a different note, RSpec has a nice rake command: rake spec:plugins but I > > wish I could do rake spec:plugins PLUGIN=my_plugin and only run the specs > > ofor my plugin. (I had issues with other plugins crashing the test before it > > would reach my plugin :( ) > > Just add this to your own spec file: > > desc "Run my plugin's specs" > Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList['vendor/plugins/my_plugin/spec/**/*_spec.rb'] > end But with :my_plugin: desc "Run my plugin's specs" Spec::Rake::SpecTask.new(:my_plugin => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['vendor/plugins/my_plugin/spec/**/*_spec.rb'] end > > > > > > > Thanks > > > > Matt > > > > > > > > > > > > > > On 4/16/07, Scott Taylor wrote: > > > > > > Yes, I guess there are tests. > > > > > > I'll look into doing this... > > > > > > Scott > > > > > > > > > On Apr 13, 2007, at 8:09 PM, Josh Knowles wrote: > > > > > > > > > > > > > > > On 4/13/07, Scott Taylor wrote: > > > > I'm actually pretty close to finishing Autospec - a port of autotest > > > > to RSpec (although for the time being it only works for standalone > > > > projects). I should probably be done with this standalone version in > > > > a week or so. > > > > > > > > While I definitely appreciate you taking the time to add standalone > > > > spec support, is there any reason you are forking this as opposed > > > > to just submitting a patch to Ryan? He has put in quite a bit of > > > > effort in the extensibility of Autotest, I'd hate to see that forked. > > > > > > > > > > > > -- > > > > 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 > > > > > > _______________________________________________ > > > 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 Apr 17 03:24:42 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 02:24:42 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: <57c63afe0704170023r2ff55ec8xa02078599bc29f56@mail.gmail.com> References: <57c63afe0704131522k627d2e03nc33424b2d20b499f@mail.gmail.com> <4610109D-7FA6-4F06-8F07-437A199EB490@railsnewbie.com> <6983B89D-E05B-47B3-B698-0E2D8F6041B1@railsnewbie.com> <57c63afe0704170023t5f457c33x167d81a7ef1d5482@mail.gmail.com> <57c63afe0704170023r2ff55ec8xa02078599bc29f56@mail.gmail.com> Message-ID: <57c63afe0704170024i3599c1c6me8e85c03d67eb212@mail.gmail.com> On 4/17/07, David Chelimsky wrote: > On 4/17/07, David Chelimsky wrote: > > On 4/17/07, Matt Aimonetti wrote: > > > Anyone knows how to get autotest to check on a plugin spec? I'm working on a > > > plugin and I would love to use autotest to check on my specs. > > > > > > On a different note, RSpec has a nice rake command: rake spec:plugins but I > > > wish I could do rake spec:plugins PLUGIN=my_plugin and only run the specs > > > ofor my plugin. (I had issues with other plugins crashing the test before it > > > would reach my plugin :( ) > > > > Just add this to your own spec file: > > > > desc "Run my plugin's specs" > > Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| > > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > > t.spec_files = FileList['vendor/plugins/my_plugin/spec/**/*_spec.rb'] > > end > > But with :my_plugin: > > desc "Run my plugin's specs" > Spec::Rake::SpecTask.new(:my_plugin => spec_prereq) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList['vendor/plugins/my_plugin/spec/**/*_spec.rb'] > end > D'oh! Your RAKE file. Starting over.... Just add this to your own rake file: desc "Run my plugin's specs" Spec::Rake::SpecTask.new(:my_plugin => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['vendor/plugins/my_plugin/spec/**/*_spec.rb'] end > > > > > > > > > > > > Thanks > > > > > > Matt > > > > > > > > > > > > > > > > > > > > > On 4/16/07, Scott Taylor wrote: > > > > > > > > Yes, I guess there are tests. > > > > > > > > I'll look into doing this... > > > > > > > > Scott > > > > > > > > > > > > On Apr 13, 2007, at 8:09 PM, Josh Knowles wrote: > > > > > > > > > > > > > > > > > > > On 4/13/07, Scott Taylor wrote: > > > > > I'm actually pretty close to finishing Autospec - a port of autotest > > > > > to RSpec (although for the time being it only works for standalone > > > > > projects). I should probably be done with this standalone version in > > > > > a week or so. > > > > > > > > > > While I definitely appreciate you taking the time to add standalone > > > > > spec support, is there any reason you are forking this as opposed > > > > > to just submitting a patch to Ryan? He has put in quite a bit of > > > > > effort in the extensibility of Autotest, I'd hate to see that forked. > > > > > > > > > > > > > > > -- > > > > > 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 > > > > > > > > _______________________________________________ > > > > 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 alex.edwards at workingmouse.com Tue Apr 17 04:14:33 2007 From: alex.edwards at workingmouse.com (Alex Edwards) Date: Tue, 17 Apr 2007 18:14:33 +1000 Subject: [rspec-users] rspec with CI In-Reply-To: <46245AD2.9080905@esse.at> References: <46242FB8.3040708@workingmouse.com> <46245AD2.9080905@esse.at> Message-ID: <462481E9.6060002@workingmouse.com> I think I tracked it down. It seems like the: t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] was causing my spec.opts to be read, and the use of --drb in my spec.opts resulted in spec failures not causing build failures. Not sure why?? I fixed it by writing my own rake task that did not set any spec opts desc "run specs" Spec::Rake::SpecTask.new('my_specs') do |t| # t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['spec/**/*_spec.rb'] end Now my build fails when it is supposed to. I guess it is not so important if I don't use --drb on my build server, as performance there is not really an issue. Any further thoughts? Esad Hajdarevic wrote: > Hi Alex, > > Alex Edwards wrote: > >> I am trying to use rspec in conjunction with CruiseControlrb. >> >> > How are you running the specs? I'm using cruise.task in lib/tasks and it > works perfectly. > Here it is: > > (Note that it's a bit complicated because we run firewatir specs too > that need some preparations) > > task 'cruise' do > puts "This is cruise rake task running within the #{RAILS_ENV} > environment" > > Rake::Task['db:migrate'].invoke > Rake::Task['db:test:clone_structure'] > > puts "Executing model specs.." > Rake::Task['spec:models'].invoke > > puts "Executing controller specs.." > Rake::Task['spec:controllers'].invoke > > puts "Loading fixtures to the database.." > # load fixtures > Rake::Task['spec:db:fixtures:load'].invoke > > # restart server > puts "Restarting server/FCGI.." > puts `ruby #{File.dirname(__FILE__)+'/../../script/process/reaper -a > kill'}` > > begin > start_firefox > puts "Running spec:watir.." > Rake::Task['spec:watir'].invoke > rescue > raise "Watir spec failed!" > ensure > stop_firefox > end > end > > Greetings, > > Esad > _______________________________________________ > 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/20070417/28c4f646/attachment-0001.html From work at ashleymoran.me.uk Tue Apr 17 05:44:11 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Tue, 17 Apr 2007 10:44:11 +0100 Subject: [rspec-users] controller.should render_action ? Message-ID: <188D10FA-A3E5-4D54-8E45-B737C4E0A424@ashleymoran.me.uk> Hi Is there a render_action matcher to go with render_template? I can't see any mention of one in the docs. Do you have to still do it old- school? Thanks Ashley From marcus at ahnve.com Tue Apr 17 07:04:06 2007 From: marcus at ahnve.com (Marcus Ahnve) Date: Tue, 17 Apr 2007 13:04:06 +0200 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: Message-ID: <4d4e79cc0704170404j36311e4fp341afb3945da8706@mail.gmail.com> On 4/13/07, Matt Aimonetti wrote: > > Josh Knowles http://joshknowles.com/ just let me know that ZenTest Autotest > 3.50 now handles your RSpec specs. It seems that autotest assumes you are using integrated views specs. I've changed my rspec_rails_autotest.rb accordingly to run view specs automatically: # when %r%^app/views/layouts/(.*)\.rhtml% then # ["spec/views/layouts/#{$1}_spec.rb"] when %r%^app/views/(.*)\.rhtml$% then ["spec/views/#{$1}_view_spec.rb"] /Marcus From christoph.sturm at gmail.com Tue Apr 17 10:08:25 2007 From: christoph.sturm at gmail.com (Christoph Sturm) Date: Tue, 17 Apr 2007 16:08:25 +0200 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk Message-ID: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> Hey guys! I am using rspec trunk, and I am having a little problem with the latest version. (I am quite sure this worked with an older version about a week ago) heres the spec: it "should render the new user form without layout for a xhr request" do @controller.should_receive(:render).with(:layout=>false) xhr :get,:new end and the controller: def new render :layout=>false end I would have loved to create a failing testcase for this, but I couldnt get the rspec test suite running, if i do a simple "rake" in the root rspec directory i get this error: (in /Users/christophsturm/Projects/rspec/example_rails_app) ** Invoke pre_commit (first_time) ** Execute pre_commit ##################################################### running pre_commit against rails edge ##################################################### ##################################################### ruby script/generate rspec_resource purchase order_id:integer created_at:datetime amount:decimal keyword:string description:text --force ##################################################### /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in `read': No such file or directory - /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml (Errno::ENOENT) what am I doing wrong? regards chris From dchelimsky at gmail.com Tue Apr 17 10:22:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 09:22:34 -0500 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> Message-ID: <57c63afe0704170722j2dd8e8cfpfac2d31633e5b9c1@mail.gmail.com> On 4/17/07, Christoph Sturm wrote: > Hey guys! > > I am using rspec trunk, and I am having a little problem with the > latest version. (I am quite sure this worked with an older version > about a week ago) > > heres the spec: > it "should render the new user form without layout for a xhr request" do > @controller.should_receive(:render).with(:layout=>false) > xhr :get,:new > end > > and the controller: > def new > render :layout=>false > end I don't know why this should be failing. Are you using edge rails? Perhaps something changed there that we don't know about. > > I would have loved to create a failing testcase for this, but I > couldnt get the rspec test suite running, if i do a simple "rake" in > the root rspec directory i get this error: > > (in /Users/christophsturm/Projects/rspec/example_rails_app) > ** Invoke pre_commit (first_time) > ** Execute pre_commit > ##################################################### > running pre_commit against rails edge > ##################################################### > ##################################################### > ruby script/generate rspec_resource purchase order_id:integer > created_at:datetime amount:decimal keyword:string description:text > --force > ##################################################### > /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in > `read': No such file or directory - > /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml > (Errno::ENOENT) > > > what am I doing wrong? We moved the plugin out from within the example_rails_app, so to run the specs you first must say: rake rspec:install_plugin That will copy {project_root}/rspec_on_rails to {project_root}/example_rails_app/vendor/plugins/ Thanks for looking into this. Cheers, David > > > regards > chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Apr 17 10:34:50 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 17 Apr 2007 16:34:50 +0200 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> Message-ID: <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> Are you using the latest beta gem, trunk or the latest release? On 4/17/07, Christoph Sturm wrote: > Hey guys! > > I am using rspec trunk, and I am having a little problem with the > latest version. (I am quite sure this worked with an older version > about a week ago) > > heres the spec: > it "should render the new user form without layout for a xhr request" do > @controller.should_receive(:render).with(:layout=>false) > xhr :get,:new > end > > and the controller: > def new > render :layout=>false > end > > I would have loved to create a failing testcase for this, but I > couldnt get the rspec test suite running, if i do a simple "rake" in > the root rspec directory i get this error: > > (in /Users/christophsturm/Projects/rspec/example_rails_app) > ** Invoke pre_commit (first_time) > ** Execute pre_commit > ##################################################### > running pre_commit against rails edge > ##################################################### > ##################################################### > ruby script/generate rspec_resource purchase order_id:integer > created_at:datetime amount:decimal keyword:string description:text > --force > ##################################################### > /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in > `read': No such file or directory - > /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml > (Errno::ENOENT) > > > what am I doing wrong? > > > regards > chris > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nicksieger at gmail.com Tue Apr 17 10:50:52 2007 From: nicksieger at gmail.com (Nick Sieger) Date: Tue, 17 Apr 2007 09:50:52 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: <4d4e79cc0704170404j36311e4fp341afb3945da8706@mail.gmail.com> References: <4d4e79cc0704170404j36311e4fp341afb3945da8706@mail.gmail.com> Message-ID: On 4/17/07, Marcus Ahnve wrote: > On 4/13/07, Matt Aimonetti wrote: > > > > Josh Knowles http://joshknowles.com/ just let me know that ZenTest Autotest > > 3.50 now handles your RSpec specs. > > It seems that autotest assumes you are using integrated views specs. > > I've changed my rspec_rails_autotest.rb accordingly to run view specs > automatically: > > # when %r%^app/views/layouts/(.*)\.rhtml% then > # ["spec/views/layouts/#{$1}_spec.rb"] > when %r%^app/views/(.*)\.rhtml$% then > ["spec/views/#{$1}_view_spec.rb"] > Yeah, this is reasonable -- when I first wrote the code I more or less ported the autotest for Rails, before RSpec had standalone view testing. It's not clear to me right now how to allow rspec/autotest to be customized depending on whether you do standalone or integrated views, to ensure that the right specs get run, other than to make the change you make here. /Nick From mailing_lists at railsnewbie.com Tue Apr 17 11:36:13 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 17 Apr 2007 11:36:13 -0400 Subject: [rspec-users] Verifying that a block calls a method Message-ID: I have something like the following: def my_fun my_fun2 do raise Error end end I know that I can verify that the method receives my_fun2. How can I mock/stub out the example to verify that it calls raise Error? Scott From mailing_lists at railsnewbie.com Tue Apr 17 11:53:32 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 17 Apr 2007 11:53:32 -0400 Subject: [rspec-users] controller.should render_action ? In-Reply-To: <188D10FA-A3E5-4D54-8E45-B737C4E0A424@ashleymoran.me.uk> References: <188D10FA-A3E5-4D54-8E45-B737C4E0A424@ashleymoran.me.uk> Message-ID: <0F2BC695-9FB4-4AAC-8E27-11463648817B@railsnewbie.com> No, I don't think so. Usually I just do something like this: def do_get get :index, :user_id => 1 end it "should be successful" do do_get response.should be_a_success end Scott On Apr 17, 2007, at 5:44 AM, Ashley Moran wrote: > Hi > > Is there a render_action matcher to go with render_template? I can't > see any mention of one in the docs. Do you have to still do it old- > school? > > Thanks > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From nick at ekenosen.net Tue Apr 17 13:03:06 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Tue, 17 Apr 2007 13:03:06 -0400 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: References: Message-ID: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> On 4/17/07, Scott Taylor wrote: > def my_fun > my_fun2 do > raise Error > end > end > > I know that I can verify that the method receives my_fun2. How can I > mock/stub out the example to verify that it calls raise Error? Have you tried "should raise_error(...)"? lambda { my_fun }.should raise_error http://rspec.rubyforge.org/rdoc/classes/Spec/Matchers.html#M000290 -- Nick From matttemp at gmail.com Tue Apr 17 18:48:32 2007 From: matttemp at gmail.com (Matt Aimonetti) Date: Tue, 17 Apr 2007 15:48:32 -0700 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: <4d4e79cc0704170404j36311e4fp341afb3945da8706@mail.gmail.com> Message-ID: Thanks, but I still have the issue of adding my plugin to be scanned by autotest. (Nick, is there anyway we could add more files to be scanned?) The other issue I'm facing is that my view specs are not checked by autotest. My view specs are in /spec/views/[controller name]/[view_name]_spec.rb I understand this is not related directly to RSpec but is you use RSpec and you want to use AutoTest you will face the same issue. Thanks, Matt On 4/17/07, Nick Sieger wrote: > > On 4/17/07, Marcus Ahnve wrote: > > On 4/13/07, Matt Aimonetti wrote: > > > > > > Josh Knowles http://joshknowles.com/ just let me know that ZenTest > Autotest > > > 3.50 now handles your RSpec specs. > > > > It seems that autotest assumes you are using integrated views specs. > > > > I've changed my rspec_rails_autotest.rb accordingly to run view specs > > automatically: > > > > # when %r%^app/views/layouts/(.*)\.rhtml% then > > # ["spec/views/layouts/#{$1}_spec.rb"] > > when %r%^app/views/(.*)\.rhtml$% then > > ["spec/views/#{$1}_view_spec.rb"] > > > > Yeah, this is reasonable -- when I first wrote the code I more or less > ported the autotest for Rails, before RSpec had standalone view > testing. It's not clear to me right now how to allow rspec/autotest > to be customized depending on whether you do standalone or integrated > views, to ensure that the right specs get run, other than to make the > change you make here. > > /Nick > _______________________________________________ > 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/20070417/24d5bf88/attachment-0001.html From lists at pauldowman.com Tue Apr 17 19:00:05 2007 From: lists at pauldowman.com (Paul Dowman) Date: Tue, 17 Apr 2007 19:00:05 -0400 Subject: [rspec-users] using rake db:fixtures:load with rspec fixtures Message-ID: Hi, I'm new to rspec. I have some fixtures in /spec/fixtures. If they were in /test/fixtures they could be loaded with rake db:fixtures:load. Is there any way other than a symlink to load my rspec fixtures into the database with rake? Or, can I cause rspec to load the fixtures from /test/fixtures? Thanks, Paul From dchelimsky at gmail.com Tue Apr 17 19:12:17 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 18:12:17 -0500 Subject: [rspec-users] using rake db:fixtures:load with rspec fixtures In-Reply-To: References: Message-ID: <57c63afe0704171612h37466a7eh246d53cb3877fee4@mail.gmail.com> On 4/17/07, Paul Dowman wrote: > Hi, I'm new to rspec. I have some fixtures in /spec/fixtures. If they > were in /test/fixtures they could be loaded with rake db:fixtures:load. > > Is there any way other than a symlink to load my rspec fixtures into > the database with rake? Or, can I cause rspec to load the fixtures > from /test/fixtures? The fixture_path gets set in spec/spec_helper.rb. David > > Thanks, > Paul > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joshknowles at gmail.com Tue Apr 17 19:29:29 2007 From: joshknowles at gmail.com (Josh Knowles) Date: Tue, 17 Apr 2007 16:29:29 -0700 Subject: [rspec-users] using rake db:fixtures:load with rspec fixtures In-Reply-To: References: Message-ID: On 4/17/07, Paul Dowman wrote: > > Hi, I'm new to rspec. I have some fixtures in /spec/fixtures. If they > were in /test/fixtures they could be loaded with rake db:fixtures:load. The equivalent rspec command is rake spec:db:fixtures:load. -- Josh Knowles joshknowles at gmail.com http://joshknowles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070417/85fe1adf/attachment.html From matttemp at gmail.com Tue Apr 17 19:55:58 2007 From: matttemp at gmail.com (Matt Aimonetti) Date: Tue, 17 Apr 2007 16:55:58 -0700 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: <4d4e79cc0704170404j36311e4fp341afb3945da8706@mail.gmail.com> Message-ID: Nick, maybe you can help. I modified the tests_for_file function in rspecrails_autotest.rb and I simply added def tests_for_file(filename) case filename when %r%^spec/fixtures/(.*)s.yml% then ["spec/models/#{$1}_spec.rb", "spec/controllers/#{$1}_controller_spec.rb"] when %r%^spec/models/.*rb$% then [filename] when %r%^spec/controllers/.*\.rb$% then [filename] when %r%^spec/views/([^/]*)/.*\.rb$% then [filename] # when %r%^spec/acceptance/.*\.rb$% then # [filename] It now loads all my view specs, what should I do to get that added to the next release of autotest for RSpec? Matt P.s: I wish there was a hook to add more files to test such as my plugin specs ;) On 4/17/07, Matt Aimonetti wrote: > > Thanks, but I still have the issue of adding my plugin to be scanned by > autotest. (Nick, is there anyway we could add more files to be scanned?) > > The other issue I'm facing is that my view specs are not checked by > autotest. My view specs are in /spec/views/[controller > name]/[view_name]_spec.rb > > I understand this is not related directly to RSpec but is you use RSpec > and you want to use AutoTest you will face the same issue. > > Thanks, > > Matt > > > On 4/17/07, Nick Sieger wrote: > > > > On 4/17/07, Marcus Ahnve wrote: > > > On 4/13/07, Matt Aimonetti wrote: > > > > > > > > Josh Knowles http://joshknowles.com/ just let me know that ZenTest > > Autotest > > > > 3.50 now handles your RSpec specs. > > > > > > It seems that autotest assumes you are using integrated views specs. > > > > > > I've changed my rspec_rails_autotest.rb accordingly to run view specs > > > automatically: > > > > > > # when %r%^app/views/layouts/(.*)\.rhtml% then > > > # ["spec/views/layouts/#{$1}_spec.rb"] > > > when %r%^app/views/(.*)\.rhtml$% then > > > ["spec/views/#{$1}_view_spec.rb"] > > > > > > > Yeah, this is reasonable -- when I first wrote the code I more or less > > ported the autotest for Rails, before RSpec had standalone view > > testing. It's not clear to me right now how to allow rspec/autotest > > to be customized depending on whether you do standalone or integrated > > views, to ensure that the right specs get run, other than to make the > > change you make here. > > > > /Nick > > _______________________________________________ > > 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/20070417/3feae0c6/attachment.html From dchelimsky at gmail.com Tue Apr 17 20:27:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 19:27:03 -0500 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: References: <4d4e79cc0704170404j36311e4fp341afb3945da8706@mail.gmail.com> Message-ID: <57c63afe0704171727q68a42a02k4f7f19872a893905@mail.gmail.com> On 4/17/07, Matt Aimonetti wrote: > > Nick, maybe you can help. I modified the tests_for_file function in > rspecrails_autotest.rb and I simply added > > def tests_for_file(filename) > case filename > when %r%^spec/fixtures/(.*)s.yml% then > ["spec/models/#{$1}_spec.rb", > "spec/controllers/#{$1}_controller_spec.rb"] > when %r%^spec/models/.*rb$% then > [filename] > when %r%^spec/controllers/.*\.rb$% then > [filename] > when %r%^spec/views/([^/]*)/.*\.rb$% then > [filename] > # when %r%^spec/acceptance/.*\.rb$% then > # [filename] > > It now loads all my view specs, what should I do to get that added to the > next release of autotest for RSpec? > > Matt > > P.s: I wish there was a hook to add more files to test such as my plugin > specs ;) If you're patching rspec autotest, why not just add your hook. You could make a hash of regexps to related files that you can add to through a class method. David > > > > On 4/17/07, Matt Aimonetti wrote: > > Thanks, but I still have the issue of adding my plugin to be scanned by > autotest. (Nick, is there anyway we could add more files to be scanned?) > > > > The other issue I'm facing is that my view specs are not checked by > autotest. My view specs are in /spec/views/[controller > name]/[view_name]_spec.rb > > > > I understand this is not related directly to RSpec but is you use RSpec > and you want to use AutoTest you will face the same issue. > > > > Thanks, > > > > Matt > > > > > > > > > > On 4/17/07, Nick Sieger wrote: > > > On 4/17/07, Marcus Ahnve wrote: > > > > On 4/13/07, Matt Aimonetti < matttemp at gmail.com> wrote: > > > > > > > > > > Josh Knowles http://joshknowles.com/ just let me know that ZenTest > Autotest > > > > > 3.50 now handles your RSpec specs. > > > > > > > > It seems that autotest assumes you are using integrated views specs. > > > > > > > > I've changed my rspec_rails_autotest.rb accordingly to run view specs > > > > automatically: > > > > > > > > # when %r%^app/views/layouts/(.*)\.rhtml% then > > > > # ["spec/views/layouts/#{$1}_spec.rb"] > > > > when %r%^app/views/(.*)\.rhtml$% then > > > > ["spec/views/#{$1}_view_spec.rb"] > > > > > > > > > > Yeah, this is reasonable -- when I first wrote the code I more or less > > > ported the autotest for Rails, before RSpec had standalone view > > > testing. It's not clear to me right now how to allow rspec/autotest > > > to be customized depending on whether you do standalone or integrated > > > views, to ensure that the right specs get run, other than to make the > > > change you make here. > > > > > > /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 > From cwdinfo at gmail.com Tue Apr 17 21:28:27 2007 From: cwdinfo at gmail.com (s.ross) Date: Tue, 17 Apr 2007 18:28:27 -0700 Subject: [rspec-users] Scaffolding Specs Message-ID: <24222220-552A-4E1D-A52E-B9286431E932@gmail.com> I just wrote a really simple tool that cranks out spec scaffolds for Rails apps. It's new and pretty simple, but you might find it useful: http://calicowebdev.com/blog/show/13 --steve From mailing_lists at railsnewbie.com Tue Apr 17 22:07:11 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 17 Apr 2007 22:07:11 -0400 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> References: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> Message-ID: <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> On Apr 17, 2007, at 1:03 PM, nicholas a. evans wrote: > On 4/17/07, Scott Taylor wrote: >> def my_fun >> my_fun2 do >> raise Error >> end >> end >> >> I know that I can verify that the method receives my_fun2. How can I >> mock/stub out the example to verify that it calls raise Error? > > Have you tried "should raise_error(...)"? > > lambda { my_fun }.should raise_error Sure, I have - the problem is that the method my_fun2 only raises error under certain conditions - if for instance, Control-C is pressed. It is quite different from a block like the following, in which the method call is guaranteed to execute: def my_fun3 [1,2,3].each { |x| puts x } end Then a spec like this should work just fine: describe "my_fun3" do it "should call puts on the first element" do obj.should_receive(:puts).with(1) obj.my_fun3 end end The example shows that the second method being called (puts), should be mocked (because you don't actually want to dump the numbers 1-3 to the terminal during your specs. How do you mock out my_fun3? The only clear advise I've gotten is to pass my_fun3 a stream, and let the default parameter be a STDOUT stream, like so: def my_fun3(stream = STDOUT) [1,2,3].each { |x| stream.puts x } end describe "my_fun3" do setup do @io = mock(io) @io.stub!(:puts).and_return @io end it "should call puts on the first element" do @io.should_receive(:puts).with(1) obj.my_fun3 end end Every time you use this method in production, you just leave off the parameter, and it defaults to calling puts (as normal). The stream parameter is only used during testing. This is a little disturbing, because now you have to change the source to fit your tests for code that will never be used in production. Luckily it's not a big change, so it's probably not a big deal. The specific example that I'm dealing with raises an error *only* when pressing ^C. def add_sigint_handler trap("INT") { raise Interrupt } end Raise only gets called if ^C (or an INT signal) is received. So how would I spec that method? The one thought that I had was that I should be able to pass the block to the method as the last parameter. Unfortunately, this doesn't seem to work. Any other thoughts? Thanks, Scott Taylor > > http://rspec.rubyforge.org/rdoc/classes/Spec/Matchers.html#M000290 > > -- > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Apr 17 22:43:53 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 21:43:53 -0500 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> References: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> Message-ID: <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> On 4/17/07, Scott Taylor wrote: > The only clear advise I've gotten is to > pass my_fun3 a stream, and let the default parameter be a STDOUT > stream, like so: > > def my_fun3(stream = STDOUT) > [1,2,3].each { |x| stream.puts x } > end > > > Every time you use this method in production, you just leave off the > parameter, and it defaults to calling puts (as normal). The stream > parameter is only used during testing. This is a little disturbing, > because now you have to change the source to fit your tests for code > that will never be used in production. This is a very, very common approach in static languages - often used to break dependencies found in legacy (read: un-tested) code. Designing for testability is a tricky thing, for exactly the reason you describe. You end up designing things differently than you would if you didn't care about testing. The trick is finding the boundaries that you're comfortable with. I'm not comfortable with methods that are only used in tests. Parameterized methods or constructors don't bug me at all. They serve the tests, and impose low risk of misuse. That risk is lowered, in my opinion, if you use a constructor parameterize the constructor rather than the method. class MyClass def initialize(io=STDOUT) @io = io end def my_fun3 [1,2,3].each { |x| @io.puts x } end end Hope that helps. David From dchelimsky at gmail.com Tue Apr 17 22:48:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Apr 2007 21:48:10 -0500 Subject: [rspec-users] Scaffolding Specs In-Reply-To: <24222220-552A-4E1D-A52E-B9286431E932@gmail.com> References: <24222220-552A-4E1D-A52E-B9286431E932@gmail.com> Message-ID: <57c63afe0704171948v1b33b4b2ndcf66753af4ddf76@mail.gmail.com> On 4/17/07, s.ross wrote: > I just wrote a really simple tool that cranks out spec scaffolds for > Rails apps. It's new and pretty simple, but you might find it useful: > > http://calicowebdev.com/blog/show/13 Eclipse will do something like this for java. It's very helpful for legacy code. The pitfall is that it tends to inspire newbies to write one test method per method tested, and you end up w/ big tests that take a method through a number of states. I do like the descriptions you are generating: "should do something sensible ...". That seems to be less like the typical test_index that leads to the trouble I described above. FYI - There is an RFE to be able to write: it "should do something" with no block and have that imply something pending; a to-do. I think that would add value to this tool because you would generate a bunch of spec stubs and rspec would tell you what you have yet to implement. Also - in trunk, you need not say "controller_name" if you pass a type instead of a String: describe ContactController do Thanks for sharing. Cheers, David > > --steve > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From alex.edwards at workingmouse.com Wed Apr 18 00:32:08 2007 From: alex.edwards at workingmouse.com (Alex Edwards) Date: Wed, 18 Apr 2007 14:32:08 +1000 Subject: [rspec-users] rspec with CI In-Reply-To: <715A9F3C-B6F8-40E1-8F02-58EFCFFE9BF0@marcuscrafter.com> References: <46242FB8.3040708@workingmouse.com> <715A9F3C-B6F8-40E1-8F02-58EFCFFE9BF0@marcuscrafter.com> Message-ID: <46259F48.6080100@workingmouse.com> Marcus, I have now got my specs working in CI, and have also found that you can make cruise run under the 'test' environment by: cruise start -e test Hope this helps you get around your problem. Marcus Crafter wrote: > Hi Alex, > > I'm having a similar problem with CC.rb at the moment - from what I > can see, CC.rb is trying to run my spec's using the production > database, rather than the test one: > > 1) ActiveRecord::StatementInvalid in 'A new Activation object should > be invalid without a name' Mysql::Error: Table > 'cms_production.activations' doesn't exist: SHOW FIELDS FROM > activations ./spec/models/activation_spec.rb:7: > ... > > Naturally this causes all of the specs to fail. :-/ > > Running the same 'rake spec' on the command line in my rails app > works as expected. > > I don't have a solution just yet but have also asked if others were > having this problem on the cc.rb users mailing list - hopefully we'll > have a solution to it soon. > > If this isn't the problem you're having - would be good to know so we > can sort that out too. At least you're not the only one :) > > Cheers, > > Marcus > > On 17/04/2007, at 12:23 PM, Alex Edwards wrote: > > >> I am a bit of a rails and rspec noob. >> >> I am trying to use rspec in conjunction with CruiseControlrb. >> >> When I run a cruise build having spec errors, the build does not >> indicate a failure. I have tried to track down why this is the case, >> and my best guess is that the spec task is kicking off the spec via a >> ruby() method in rake, and that ruby method does not propagate my spec >> failure back to rake. >> >> Any help in setting this up would be much appreciated. >> Also, if there is a better alternative to cruisecontrolrb that >> integrates nicely with rspec, please let me know. >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070418/f62a2798/attachment.html From marcus at marcuscrafter.com Wed Apr 18 00:54:37 2007 From: marcus at marcuscrafter.com (Marcus Crafter) Date: Wed, 18 Apr 2007 14:54:37 +1000 Subject: [rspec-users] rspec with CI In-Reply-To: <46259F48.6080100@workingmouse.com> References: <46242FB8.3040708@workingmouse.com> <715A9F3C-B6F8-40E1-8F02-58EFCFFE9BF0@marcuscrafter.com> <46259F48.6080100@workingmouse.com> Message-ID: Hi Alex, Thanks for that - I ended up fixing the RAILS_ENV to 'test' in the project's Rakefile directly which also got it working, for some reason my lib/tasks/cruise.task wasn't being picked up but at least it's all working now. Thanks again for your help mate. Much appreciated :) Cheers, Marcus On 18/04/2007, at 2:32 PM, Alex Edwards wrote: > Marcus, > I have now got my specs working in CI, and have also found that you > can make cruise run under the 'test' environment by: > cruise start -e test > > Hope this helps you get around your problem. > > Marcus Crafter wrote: >> Hi Alex, I'm having a similar problem with CC.rb at the moment - >> from what I can see, CC.rb is trying to run my spec's using the >> production database, rather than the test one: 1) >> ActiveRecord::StatementInvalid in 'A new Activation object should >> be invalid without a name' Mysql::Error: Table >> 'cms_production.activations' doesn't exist: SHOW FIELDS FROM >> activations ./spec/models/activation_spec.rb:7: ... Naturally this >> causes all of the specs to fail. :-/ Running the same 'rake spec' >> on the command line in my rails app works as expected. I don't >> have a solution just yet but have also asked if others were having >> this problem on the cc.rb users mailing list - hopefully we'll >> have a solution to it soon. If this isn't the problem you're >> having - would be good to know so we can sort that out too. At >> least you're not the only one :) Cheers, Marcus On 17/04/2007, at >> 12:23 PM, Alex Edwards wrote: >>> I am a bit of a rails and rspec noob. I am trying to use rspec in >>> conjunction with CruiseControlrb. When I run a cruise build >>> having spec errors, the build does not indicate a failure. I have >>> tried to track down why this is the case, and my best guess is >>> that the spec task is kicking off the spec via a ruby() method in >>> rake, and that ruby method does not propagate my spec failure >>> back to rake. Any help in setting this up would be much >>> appreciated. Also, if there is a better alternative to >>> cruisecontrolrb that integrates nicely with rspec, please let me >>> know. 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 Wed Apr 18 01:02:49 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 18 Apr 2007 01:02:49 -0400 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> References: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> Message-ID: <6F3BAFB2-24D7-4123-8791-B124E65A0108@railsnewbie.com> On Apr 17, 2007, at 10:43 PM, David Chelimsky wrote: > On 4/17/07, Scott Taylor wrote: >> The only clear advise I've gotten is to >> pass my_fun3 a stream, and let the default parameter be a STDOUT >> stream, like so: >> >> def my_fun3(stream = STDOUT) >> [1,2,3].each { |x| stream.puts x } >> end >> >> >> Every time you use this method in production, you just leave off the >> parameter, and it defaults to calling puts (as normal). The stream >> parameter is only used during testing. This is a little disturbing, >> because now you have to change the source to fit your tests for code >> that will never be used in production. > > This is a very, very common approach in static languages - often used > to break dependencies found in legacy (read: un-tested) code. > > Designing for testability is a tricky thing, for exactly the reason > you describe. You end up designing things differently than you would > if you didn't care about testing. The trick is finding the boundaries > that you're comfortable with. I'm not comfortable with methods that > are only used in tests. Parameterized methods or constructors don't > bug me at all. They serve the tests, and impose low risk of misuse. > That risk is lowered, in my opinion, if you use a constructor > parameterize the constructor rather than the method. > > class MyClass > def initialize(io=STDOUT) > @io = io > end > def my_fun3 > [1,2,3].each { |x| @io.puts x } > end > end > > Hope that helps. Well it seems to be good advise. Unfortunately, it doesn't help me with the Kernel#trap problem, though, which is what the email was originally about. Scott > > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Wed Apr 18 04:18:45 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 18 Apr 2007 10:18:45 +0200 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> References: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> Message-ID: <8d961d900704180118r71a7d869ua300c5be40ff6983@mail.gmail.com> On 4/18/07, David Chelimsky wrote: > On 4/17/07, Scott Taylor wrote: > > The only clear advise I've gotten is to > > pass my_fun3 a stream, and let the default parameter be a STDOUT > > stream, like so: > > > > def my_fun3(stream = STDOUT) > > [1,2,3].each { |x| stream.puts x } > > end > > > > > > Every time you use this method in production, you just leave off the > > parameter, and it defaults to calling puts (as normal). The stream > > parameter is only used during testing. This is a little disturbing, > > because now you have to change the source to fit your tests for code > > that will never be used in production. > > This is a very, very common approach in static languages - often used > to break dependencies found in legacy (read: un-tested) code. > > Designing for testability is a tricky thing, for exactly the reason > you describe. You end up designing things differently than you would > if you didn't care about testing. The trick is finding the boundaries > that you're comfortable with. I'm not comfortable with methods that > are only used in tests. Parameterized methods or constructors don't > bug me at all. They serve the tests, and impose low risk of misuse. > That risk is lowered, in my opinion, if you use a constructor > parameterize the constructor rather than the method. > A.k.a Constructor Dependency Injection (look it up) - a common principle to aid decoupling. Very common in Java land combined with mocks. Useful in Ruby land too. > class MyClass > def initialize(io=STDOUT) > @io = io > end > def my_fun3 > [1,2,3].each { |x| @io.puts x } > end > end > > Hope that helps. > > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Apr 18 05:51:44 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 18 Apr 2007 11:51:44 +0200 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: <6F3BAFB2-24D7-4123-8791-B124E65A0108@railsnewbie.com> References: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> <6F3BAFB2-24D7-4123-8791-B124E65A0108@railsnewbie.com> Message-ID: <8d961d900704180251h72121710m44d176dc793344@mail.gmail.com> On 4/18/07, Scott Taylor wrote: > > On Apr 17, 2007, at 10:43 PM, David Chelimsky wrote: > > > On 4/17/07, Scott Taylor wrote: > >> The only clear advise I've gotten is to > >> pass my_fun3 a stream, and let the default parameter be a STDOUT > >> stream, like so: > >> > >> def my_fun3(stream = STDOUT) > >> [1,2,3].each { |x| stream.puts x } > >> end > >> > >> > >> Every time you use this method in production, you just leave off the > >> parameter, and it defaults to calling puts (as normal). The stream > >> parameter is only used during testing. This is a little disturbing, > >> because now you have to change the source to fit your tests for code > >> that will never be used in production. > > > > This is a very, very common approach in static languages - often used > > to break dependencies found in legacy (read: un-tested) code. > > > > Designing for testability is a tricky thing, for exactly the reason > > you describe. You end up designing things differently than you would > > if you didn't care about testing. The trick is finding the boundaries > > that you're comfortable with. I'm not comfortable with methods that > > are only used in tests. Parameterized methods or constructors don't > > bug me at all. They serve the tests, and impose low risk of misuse. > > That risk is lowered, in my opinion, if you use a constructor > > parameterize the constructor rather than the method. > > > > class MyClass > > def initialize(io=STDOUT) > > @io = io > > end > > def my_fun3 > > [1,2,3].each { |x| @io.puts x } > > end > > end > > > > Hope that helps. > > Well it seems to be good advise. Unfortunately, it doesn't help me > with the Kernel#trap problem, though, which is what the email was > originally about. > If you want a concise answer, ask a short and concise question ;-) Try this: class Mooky def add_sigint_handler(trapper=Kernel) trapper.trap("INT") { raise Interrupt } end end describe Mooky do it 'should install an INT trap that raises an Interrupted' do mooky = Mooky.new trapper = mock('Kernel') trapper.should_receive(:trap).with("INT").and_yield lambda do mooky.add_sigint_handler(trapper) end.should raise_error(Interrupt) end end Any other suggestions? Aslak > Scott > > > > > > > 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 dchelimsky at gmail.com Wed Apr 18 07:00:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Apr 2007 06:00:34 -0500 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: <8d961d900704180251h72121710m44d176dc793344@mail.gmail.com> References: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> <6F3BAFB2-24D7-4123-8791-B124E65A0108@railsnewbie.com> <8d961d900704180251h72121710m44d176dc793344@mail.gmail.com> Message-ID: <57c63afe0704180400g12262e72q812a9b5c978dd2e5@mail.gmail.com> On 4/18/07, aslak hellesoy wrote: > On 4/18/07, Scott Taylor wrote: > > > > On Apr 17, 2007, at 10:43 PM, David Chelimsky wrote: > > > > > On 4/17/07, Scott Taylor wrote: > > >> The only clear advise I've gotten is to > > >> pass my_fun3 a stream, and let the default parameter be a STDOUT > > >> stream, like so: > > >> > > >> def my_fun3(stream = STDOUT) > > >> [1,2,3].each { |x| stream.puts x } > > >> end > > >> > > >> > > >> Every time you use this method in production, you just leave off the > > >> parameter, and it defaults to calling puts (as normal). The stream > > >> parameter is only used during testing. This is a little disturbing, > > >> because now you have to change the source to fit your tests for code > > >> that will never be used in production. > > > > > > This is a very, very common approach in static languages - often used > > > to break dependencies found in legacy (read: un-tested) code. > > > > > > Designing for testability is a tricky thing, for exactly the reason > > > you describe. You end up designing things differently than you would > > > if you didn't care about testing. The trick is finding the boundaries > > > that you're comfortable with. I'm not comfortable with methods that > > > are only used in tests. Parameterized methods or constructors don't > > > bug me at all. They serve the tests, and impose low risk of misuse. > > > That risk is lowered, in my opinion, if you use a constructor > > > parameterize the constructor rather than the method. > > > > > > class MyClass > > > def initialize(io=STDOUT) > > > @io = io > > > end > > > def my_fun3 > > > [1,2,3].each { |x| @io.puts x } > > > end > > > end > > > > > > Hope that helps. > > > > Well it seems to be good advise. Unfortunately, it doesn't help me > > with the Kernel#trap problem, though, which is what the email was > > originally about. > > > > If you want a concise answer, ask a short and concise question ;-) Try this: > > class Mooky > def add_sigint_handler(trapper=Kernel) > trapper.trap("INT") { raise Interrupt } > end > end > > describe Mooky do > it 'should install an INT trap that raises an Interrupted' do > mooky = Mooky.new > trapper = mock('Kernel') > trapper.should_receive(:trap).with("INT").and_yield > lambda do > mooky.add_sigint_handler(trapper) > end.should raise_error(Interrupt) > end > end > > Any other suggestions? It would be nice to actually send the signal. This, for example, works in isolation: require 'rubygems' require 'spec' class Trapper def add_sigint_handler trap("INT") { raise "trapped" } end end describe "interrupt" do it "should provide trap for INT" do lambda do Trapper.new.add_sigint_handler Process.kill("INT", 0) end.should raise_error(RuntimeError, "trapped") end end The problem is that RSpec handles Interrupt in its own way, and with this you've now changed the way rspec is going to behave when it receives Interrupt so you're likely to get some unexpected results. David > > Aslak > > > Scott > > > > > > > > > > > > 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 mailing_lists at railsnewbie.com Wed Apr 18 07:24:09 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 18 Apr 2007 07:24:09 -0400 Subject: [rspec-users] spec'ing a call to exit Message-ID: <0C9852EC-D004-4F86-8939-ED518499282A@railsnewbie.com> How would I spec a call to exit? I can't seem to stub it - rspec throws an error. Scott From aslak.hellesoy at gmail.com Wed Apr 18 08:02:25 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 18 Apr 2007 14:02:25 +0200 Subject: [rspec-users] spec'ing a call to exit In-Reply-To: <0C9852EC-D004-4F86-8939-ED518499282A@railsnewbie.com> References: <0C9852EC-D004-4F86-8939-ED518499282A@railsnewbie.com> Message-ID: <8d961d900704180502i2c25f9dct40c3bb492a799db3@mail.gmail.com> On 4/18/07, Scott Taylor wrote: > > How would I spec a call to exit? I can't seem to stub it - rspec > throws an error. > I'm not sure what "speccing a call to exit" means because it's too vague. Is the spec calling exit or is the code under test calling exit (perhaps as the result of calling some other method from the spec)? What behaviour are you expecting in what situation? Aslak > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at pauldowman.com Wed Apr 18 11:10:00 2007 From: lists at pauldowman.com (Paul Dowman) Date: Wed, 18 Apr 2007 11:10:00 -0400 Subject: [rspec-users] using rake db:fixtures:load with rspec fixtures In-Reply-To: References: Message-ID: Great, thanks! On 17-Apr-07, at 7:29 PM, Josh Knowles wrote: > > On 4/17/07, Paul Dowman wrote: Hi, I'm new > to rspec. I have some fixtures in /spec/fixtures. If they > were in /test/fixtures they could be loaded with rake > db:fixtures:load. > > > The equivalent rspec command is rake spec:db:fixtures:load. > > > > -- > 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 matttemp at gmail.com Wed Apr 18 11:46:44 2007 From: matttemp at gmail.com (Matt Aimonetti) Date: Wed, 18 Apr 2007 08:46:44 -0700 Subject: [rspec-users] ZenTest autotest now handles RSpec, yay! In-Reply-To: <57c63afe0704171727q68a42a02k4f7f19872a893905@mail.gmail.com> References: <4d4e79cc0704170404j36311e4fp341afb3945da8706@mail.gmail.com> <57c63afe0704171727q68a42a02k4f7f19872a893905@mail.gmail.com> Message-ID: I really like the idea of a hook to add your own regexps. Also, it would be nice to remove the vendor folder from the scan exceptions. class RspecRailsAutotest < Autotest attr_accessor :spec_command def initialize # :nodoc: @spec_command = "spec --diff unified" super @exceptions = %r%^\./(?:coverage|db|doc|log|public|script|vendor)% end Thanks -Matt On 4/17/07, David Chelimsky wrote: > > On 4/17/07, Matt Aimonetti wrote: > > > > Nick, maybe you can help. I modified the tests_for_file function in > > rspecrails_autotest.rb and I simply added > > > > def tests_for_file(filename) > > case filename > > when %r%^spec/fixtures/(.*)s.yml% then > > ["spec/models/#{$1}_spec.rb", > > "spec/controllers/#{$1}_controller_spec.rb"] > > when %r%^spec/models/.*rb$% then > > [filename] > > when %r%^spec/controllers/.*\.rb$% then > > [filename] > > when %r%^spec/views/([^/]*)/.*\.rb$% then > > [filename] > > # when %r%^spec/acceptance/.*\.rb$% then > > # [filename] > > > > It now loads all my view specs, what should I do to get that added to > the > > next release of autotest for RSpec? > > > > Matt > > > > P.s: I wish there was a hook to add more files to test such as my plugin > > specs ;) > > If you're patching rspec autotest, why not just add your hook. You > could make a hash of regexps to related files that you can add to > through a class method. > > David > > > > > > > > > On 4/17/07, Matt Aimonetti wrote: > > > Thanks, but I still have the issue of adding my plugin to be scanned > by > > autotest. (Nick, is there anyway we could add more files to be scanned?) > > > > > > The other issue I'm facing is that my view specs are not checked by > > autotest. My view specs are in /spec/views/[controller > > name]/[view_name]_spec.rb > > > > > > I understand this is not related directly to RSpec but is you use > RSpec > > and you want to use AutoTest you will face the same issue. > > > > > > Thanks, > > > > > > Matt > > > > > > > > > > > > > > > On 4/17/07, Nick Sieger wrote: > > > > On 4/17/07, Marcus Ahnve wrote: > > > > > On 4/13/07, Matt Aimonetti < matttemp at gmail.com> wrote: > > > > > > > > > > > > Josh Knowles http://joshknowles.com/ just let me know that > ZenTest > > Autotest > > > > > > 3.50 now handles your RSpec specs. > > > > > > > > > > It seems that autotest assumes you are using integrated views > specs. > > > > > > > > > > I've changed my rspec_rails_autotest.rb accordingly to run view > specs > > > > > automatically: > > > > > > > > > > # when %r%^app/views/layouts/(.*)\.rhtml% then > > > > > # ["spec/views/layouts/#{$1}_spec.rb"] > > > > > when %r%^app/views/(.*)\.rhtml$% then > > > > > ["spec/views/#{$1}_view_spec.rb"] > > > > > > > > > > > > > Yeah, this is reasonable -- when I first wrote the code I more or > less > > > > ported the autotest for Rails, before RSpec had standalone view > > > > testing. It's not clear to me right now how to allow rspec/autotest > > > > to be customized depending on whether you do standalone or > integrated > > > > views, to ensure that the right specs get run, other than to make > the > > > > change you make here. > > > > > > > > /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 > > > _______________________________________________ > 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/20070418/65b4d1a5/attachment.html From mailing_lists at railsnewbie.com Wed Apr 18 11:55:58 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 18 Apr 2007 11:55:58 -0400 Subject: [rspec-users] spec'ing a call to exit In-Reply-To: <8d961d900704180502i2c25f9dct40c3bb492a799db3@mail.gmail.com> References: <0C9852EC-D004-4F86-8939-ED518499282A@railsnewbie.com> <8d961d900704180502i2c25f9dct40c3bb492a799db3@mail.gmail.com> Message-ID: On Apr 18, 2007, at 8:02 AM, aslak hellesoy wrote: > On 4/18/07, Scott Taylor wrote: >> >> How would I spec a call to exit? I can't seem to stub it - rspec >> throws an error. >> > > I'm not sure what "speccing a call to exit" means because it's too > vague. Is the spec calling exit or is the code under test calling exit > (perhaps as the result of calling some other method from the spec)? > > What behaviour are you expecting in what situation? The behavior is to call exit when a certain exception is raised (for instance, an Interrupt signal). I'm actually going to eliminate this from my code, as I can just call break instead (I'm breaking from an otherwise infinite loop). Just to satisfy my curiosity, though, what are your thoughts? Thanks, Scott From mailing_lists at railsnewbie.com Wed Apr 18 12:23:20 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 18 Apr 2007 12:23:20 -0400 Subject: [rspec-users] Verifying that a block calls a method In-Reply-To: <8d961d900704180251h72121710m44d176dc793344@mail.gmail.com> References: <276ff9870704171003g6e7e349fl4ddcef31ca5d5ac5@mail.gmail.com> <4455B9E7-CB97-4C31-92D4-A31C06C6B2F1@railsnewbie.com> <57c63afe0704171943k367dff23hb006cca0ee8ed1da@mail.gmail.com> <6F3BAFB2-24D7-4123-8791-B124E65A0108@railsnewbie.com> <8d961d900704180251h72121710m44d176dc793344@mail.gmail.com> Message-ID: <4921E51C-B6C7-474D-BE03-699B625C5650@railsnewbie.com> >> >> Well it seems to be good advise. Unfortunately, it doesn't help me >> with the Kernel#trap problem, though, which is what the email was >> originally about. >> > > If you want a concise answer, ask a short and concise question ;-) > Try this: > > class Mooky > def add_sigint_handler(trapper=Kernel) > trapper.trap("INT") { raise Interrupt } > end > end > > describe Mooky do > it 'should install an INT trap that raises an Interrupted' do > mooky = Mooky.new > trapper = mock('Kernel') > trapper.should_receive(:trap).with("INT").and_yield > lambda do > mooky.add_sigint_handler(trapper) > end.should raise_error(Interrupt) > end > end > > Any other suggestions? Ah - I hadn't noticed the "and_yield" method - I was trying to just pass the proc to the "with" method. That really clears things up. Thanks, Aslak. Scott > > Aslak > >> Scott >> >> >> >>> >>> 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 Wed Apr 18 12:35:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Apr 2007 11:35:10 -0500 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> Message-ID: <57c63afe0704180935q17d7a748icb3c13abd15b9472@mail.gmail.com> On 4/17/07, aslak hellesoy wrote: > Are you using the latest beta gem, trunk or the latest release? > > On 4/17/07, Christoph Sturm wrote: > > Hey guys! > > > > I am using rspec trunk, and I am having a little problem with the > > latest version. (I am quite sure this worked with an older version > > about a week ago) > > > > heres the spec: > > it "should render the new user form without layout for a xhr request" do > > @controller.should_receive(:render).with(:layout=>false) > > xhr :get,:new > > end > > > > and the controller: > > def new > > render :layout=>false > > end > > > > I would have loved to create a failing testcase for this, but I > > couldnt get the rspec test suite running, if i do a simple "rake" in > > the root rspec directory i get this error: > > > > (in /Users/christophsturm/Projects/rspec/example_rails_app) > > ** Invoke pre_commit (first_time) > > ** Execute pre_commit > > ##################################################### > > running pre_commit against rails edge > > ##################################################### > > ##################################################### > > ruby script/generate rspec_resource purchase order_id:integer > > created_at:datetime amount:decimal keyword:string description:text > > --force > > ##################################################### > > /Users/christophsturm/Projects/rspec/example_rails_app/vendor/rails/edge/railties/lib/initializer.rb:514:in > > `read': No such file or directory - > > /Users/christophsturm/Projects/rspec/example_rails_app/config/database.yml > > (Errno::ENOENT) > > > > > > what am I doing wrong? > > > > > > regards > > chris FYI - Chris says the error is: expected :render with ({:layout=>false}) but received it with (no args) > > _______________________________________________ > > 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 bkeepers at gmail.com Wed Apr 18 15:09:51 2007 From: bkeepers at gmail.com (Brandon Keepers) Date: Wed, 18 Apr 2007 15:09:51 -0400 Subject: [rspec-users] rspec with CI In-Reply-To: <46242FB8.3040708@workingmouse.com> References: <46242FB8.3040708@workingmouse.com> Message-ID: <08FD7E30-6E99-4F4A-A02E-75C8C29F4464@gmail.com> I am using rspec with Cerberus. I don't remember if this was the result of the test/production environment with Cerberus or not, but I always set the RAILS_ENV at the top of my spec_helper: ENV["RAILS_ENV"] = "test" Brandon On Apr 16, 2007, at 10:23 PM, Alex Edwards wrote: > I am a bit of a rails and rspec noob. > > I am trying to use rspec in conjunction with CruiseControlrb. > > When I run a cruise build having spec errors, the build does not > indicate a failure. I have tried to track down why this is the case, > and my best guess is that the spec task is kicking off the spec via a > ruby() method in rake, and that ruby method does not propagate my spec > failure back to rake. > > Any help in setting this up would be much appreciated. > Also, if there is a better alternative to cruisecontrolrb that > integrates nicely with rspec, please let me know. > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From james at hillyerd.com Wed Apr 18 20:07:57 2007 From: james at hillyerd.com (James Hillyerd) Date: Wed, 18 Apr 2007 17:07:57 -0700 Subject: [rspec-users] Best practice thoughts: Model helpers, mocks Message-ID: <254841be0704181707l3546d24p547f1df1d9b7e6a2@mail.gmail.com> Hello! I'm pretty new to unit testing, and have only been using RSpec for a few weeks. I found that for my controller specs, my setup methods were getting very long building mocks/stubs for all the model objects I needed to work with. I've started creating helpers like the following for each of my models. The "min_" methods are short for "minimum", and are there to give me the minimum set of data that will pass validation for that model. The "obj.send" code is to reduce the length of the data output when RSpec compares expectations to results... A lot of my mocks were several screenfulls long which sucks. I've also started adding code that takes the attribs I define for the mock_ method and stubs out :setter= methods too. Am I going down the right path here? (If so, I have a text mate snippet that creates this stuff pretty quickly I can share) module RenewalSpecHelper def min_renewal_attribs { :member_id => 1, :order_id => 1, :date_renewed => Date.new(2007, 1, 1), :membership_type_id => 1, :shirt_size => 'M', :amount_due => '5000' } end def min_renewal Renewal.new :attributes => min_renewal_attribs end def mock_renewal(stubs = {}) obj = mock_model(Renewal, { :member_id => 1, :date_renewed => Date.new(2007, 1, 1), :membership_type_id => 1, :shirt_size => 'M', :billing_method => 'BM', :amount_due => '5000' }.merge!(stubs)) obj.send(:__mock_handler).instance_eval "def inspect; @name; end" obj end end Below is an example of what I'd like to avoid, one of my controller test setups. It seems like each context, I end up pasting the previous contexts setup, and then adding a few more lines, until it ends up... setup do mem_types = Array.new @membership_type1 = mock_model(MembershipType) @membership_type1.stub!(:id).and_return(1) @membership_type1.stub!(:name).and_return('Name') @membership_type1.stub!(:price_cents).and_return(5000) mem_types << @membership_type1 @membership_type2 = mock_model(MembershipType) @membership_type2.stub!(:id).and_return(2) @membership_type2.stub!(:name).and_return('Name') @membership_type2.stub!(:price_cents).and_return(10000) mem_types << @membership_type2 @membership_type3 = mock_model(MembershipType) @membership_type3.stub!(:id).and_return(3) @membership_type3.stub!(:name).and_return('Name') @membership_type3.stub!(:price_cents).and_return(15000) mem_types << @membership_type3 MembershipType.stub!(:find_available).and_return(mem_types) addl_members = Array.new [ 1, 2, 3, 3 ].each do |i| am = mock_model(AdditionalMember) am.stub!(:blank?).and_return(false) am.stub!(:membership_type_id).and_return(i) am.stub!(:email).and_return('foo at bar.com') am.stub!(:first_name).and_return('John') am.stub!(:last_name).and_return('Doh') am.stub!(:gender).and_return('M') am.stub!(:shirt_size).and_return('L') # am.stub!(:).and_return() addl_members << am end @signup_checkout = mock_model(SignupCheckout) @signup_checkout.stub!(:valid?).and_return(true) @signup_checkout.stub!(:shirt_size).and_return('L') @signup_checkout.stub!(:billing_method).and_return('PP') @signup_checkout.stub!(:additional_members).and_return(addl_members) session[:signup_checkout] = @signup_checkout @member = mock_model(Member) @member.stub!(:valid?).and_return(true) @member.stub!(:membership_type_id).and_return(1) @member.stub!(:membership_type).and_return(@membership_type1) @member.stub!(:full_name).and_return('Some Body') @member.stub!(:addr_line1).and_return('123 Main') @member.stub!(:addr_line2).and_return(nil) @member.stub!(:city).and_return('City') @member.stub!(:province).and_return('WA') @member.stub!(:postal_code).and_return('98008') @member.stub!(:visible_to_public).and_return(true) @member.stub!(:email_newsletter).and_return(true) # @member.stub!(:).and_return() @member.stub!(:lifetime_member=) @member.stub!(:membership_expires_on=) @member.stub!(:save!) session[:member] = @member end (I have since learned that mock_models do stub out a unique ID value, so I don't set those by hand on my newer tests) Thanks for any opinions or insight. :) -james -- James A. Hillyerd From marcus at marcusirven.com Thu Apr 19 01:15:20 2007 From: marcus at marcusirven.com (Marcus Irven) Date: Thu, 19 Apr 2007 00:15:20 -0500 Subject: [rspec-users] Spec'ing Namespaced Controllers Message-ID: <27d4903a0704182215u7c162aabh697b65d531574acb@mail.gmail.com> I'm stucking trying to figure out how to write a spec for a namespaced controller. Any help is appreciated. Thanks, Marcus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070419/75a167fa/attachment.html From court3nay at gmail.com Thu Apr 19 01:59:05 2007 From: court3nay at gmail.com (Courtenay) Date: Wed, 18 Apr 2007 22:59:05 -0700 Subject: [rspec-users] Best practice thoughts: Model helpers, mocks In-Reply-To: <254841be0704181707l3546d24p547f1df1d9b7e6a2@mail.gmail.com> References: <254841be0704181707l3546d24p547f1df1d9b7e6a2@mail.gmail.com> Message-ID: <4b430c8f0704182259s1a320e0cib70ce6d5dd4ec449@mail.gmail.com> > setup do > mem_types = Array.new > @membership_type1 = mock_model(MembershipType) > @membership_type1.stub!(:id).and_return(1) > @membership_type1.stub!(:name).and_return('Name') > @membership_type1.stub!(:price_cents).and_return(5000) this is a little shorter: @membership_type1 = mock_model(MembershipType, :id => 1, :name => 'Name', :price_cents => 5000 also, some questions; Are you really using all those fields in all your specs? if so, looks like some of your code can be pushed to the model. There's rarely a need to define all those stubs, unless of course you have some killer logic. Stub out the fields you are doing logic with, and forget the rest. Finally, check out http://blog.caboo.se/articles/2007/4/16/dynamic-rspec-setup-methods as a way to modularize your setup methods. I am still learning this stuff myself, but a controller setup in my experience usually runs to just a few lines. From marcus at ahnve.com Thu Apr 19 02:35:32 2007 From: marcus at ahnve.com (Marcus Ahnve) Date: Thu, 19 Apr 2007 08:35:32 +0200 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <57c63afe0704180935q17d7a748icb3c13abd15b9472@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> <57c63afe0704180935q17d7a748icb3c13abd15b9472@mail.gmail.com> Message-ID: <4d4e79cc0704182335l71e69d2bqf3eeb8ce21410878@mail.gmail.com> On 4/18/07, David Chelimsky wrote: > [...] > FYI - Chris says the error is: > > expected :render with ({:layout=>false}) > but received it with (no args) I am seeing this as well. I am running a spec like: it "should use application layout" do @controller.should_receive(:render).with(:layout => "/layouts/application") get 'index' end If I change the spec to fail on purpose by for example changing the expected layout name, I get the correct behaviour. The 'no args' thing appears when the spec passes. /Marcus From mlangenberg at gmail.com Thu Apr 19 04:04:06 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Thu, 19 Apr 2007 10:04:06 +0200 Subject: [rspec-users] Best practice thoughts: Model helpers, mocks In-Reply-To: <4b430c8f0704182259s1a320e0cib70ce6d5dd4ec449@mail.gmail.com> References: <254841be0704181707l3546d24p547f1df1d9b7e6a2@mail.gmail.com> <4b430c8f0704182259s1a320e0cib70ce6d5dd4ec449@mail.gmail.com> Message-ID: <27c0ac6d0704190104o63509615jb039129b64aa7f87@mail.gmail.com> I guess you are using integrated views, aren't you? Focus on the behaviour of your controller method, I don't think it would ever need all those stubbed fields, but please prove me wrong. On 4/19/07, Courtenay wrote: > > setup do > > mem_types = Array.new > > @membership_type1 = mock_model(MembershipType) > > @membership_type1.stub!(:id).and_return(1) > > @membership_type1.stub!(:name).and_return('Name') > > @membership_type1.stub!(:price_cents).and_return(5000) > > this is a little shorter: > > @membership_type1 = mock_model(MembershipType, :id => 1, :name => > 'Name', :price_cents => 5000 > > also, some questions; > > Are you really using all those fields in all your specs? if so, looks > like some of your code can be pushed to the model. There's rarely a > need to define all those stubs, unless of course you have some killer > logic. Stub out the fields you are doing logic with, and forget the > rest. > > Finally, check out > > http://blog.caboo.se/articles/2007/4/16/dynamic-rspec-setup-methods > > as a way to modularize your setup methods. > > I am still learning this stuff myself, but a controller setup in my > experience usually runs to just a few lines. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeff at jefdean.com Wed Apr 18 17:48:48 2007 From: jeff at jefdean.com (Jeff Dean) Date: Wed, 18 Apr 2007 14:48:48 -0700 (PDT) Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <8d961d900704120924q5ca1837xc9b2cbcfe4f158a@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <8d961d900704120924q5ca1837xc9b2cbcfe4f158a@mail.gmail.com> Message-ID: <10066654.post@talk.nabble.com> zentest -v = zentest v3.4.3 spec -v = RSpec-0.8.2 (r1560) - BDD for Ruby spec_on_rails is a checkout of REL_0_8_2 aslak hellesoy wrote: > > On 4/11/07, Jeff Dean wrote: >> I've got rspec and zentest installed as well as the rspec rails plugin, >> and >> my model/controller specs all pass and work well. I can't seem to get >> views >> to work though - 100% of the specs fail with: >> >> NoMethodError in '/users/show.rhtml should render attributes in

' >> protected method `render' called for >> # >> /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in >> `render' >> ./spec/views/users/show_rhtml_spec.rb:13: >> >> Note the "protected method `render' called for >> #" >> >> Here's an example spec: >> >> require File.dirname(__FILE__) + '/../../spec_helper' >> >> context "/users/new.rhtml" do >> include UsersHelper >> >> setup do >> @errors = mock("errors") >> @errors.stub!(:count).and_return(0) >> >> @user = mock_user >> @user.stub!(:errors).and_return @errors >> assigns[:user] = @user >> end >> >> specify "should render new form" do >> render "/users/new.rhtml" >> response.should_have_tag 'form', :attributes =>{:action => >> users_path, >> :method => 'post'} >> >> end >> end >> >> Can anyone think of why "render" is protected? Is this a versioning >> issue? >> > > What versions of everything do you have? > > -- View this message in context: http://www.nabble.com/View-Specs-Fail-with-%22protected-method-render%22-tf3566514.html#a10066654 Sent from the rspec-users mailing list archive at Nabble.com. From sean at plazes.com Thu Apr 19 05:19:36 2007 From: sean at plazes.com (Sean Treadway) Date: Thu, 19 Apr 2007 11:19:36 +0200 Subject: [rspec-users] Spec'ing Namespaced Controllers In-Reply-To: <27d4903a0704182215u7c162aabh697b65d531574acb@mail.gmail.com> References: <27d4903a0704182215u7c162aabh697b65d531574acb@mail.gmail.com> Message-ID: <2598ba560704190219rce82f74sa2d7e40ea36a84d2@mail.gmail.com> Hi Marcus, I've been happy with a file naming convention for the specs then using the slashed convention for the controller_name for the controller context. in spec/controllers/sms_messages_controller_spec.rb: require File.dirname(__FILE__) + '/../spec_helper' describe Sms::MessagesController, " when asking for help" do controller_name 'sms/messages' fixtures :users setup do post :create, :body => 'help' end it "should send the usage message" do ... end end script/spec -v RSpec-0.8.3 (r1591) - BDD for Ruby http://rspec.rubyforge.org/ On 4/19/07, Marcus Irven wrote: > I'm stucking trying to figure out how to write a spec for a namespaced > controller. Any help is appreciated. > > Thanks, > Marcus > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 19 10:52:53 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Apr 2007 09:52:53 -0500 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <4d4e79cc0704182335l71e69d2bqf3eeb8ce21410878@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> <57c63afe0704180935q17d7a748icb3c13abd15b9472@mail.gmail.com> <4d4e79cc0704182335l71e69d2bqf3eeb8ce21410878@mail.gmail.com> Message-ID: <57c63afe0704190752pe65d761va845659224a3f643@mail.gmail.com> On 4/19/07, Marcus Ahnve wrote: > On 4/18/07, David Chelimsky wrote: > > [...] > > FYI - Chris says the error is: > > > > expected :render with ({:layout=>false}) > > but received it with (no args) > > I am seeing this as well. > > I am running a spec like: > > it "should use application layout" do > @controller.should_receive(:render).with(:layout => "/layouts/application") > get 'index' > end > > If I change the spec to fail on purpose by for example changing the > expected layout name, I get the correct behaviour. The 'no args' thing > appears when the spec passes. OK - I'm getting somewhere with this. What happens is that render is actually called twice. So if you do this: it "should use application layout" do controller.should_receive(:render).with(:layout => "/layouts/application") controller.should_receive(:render).with(:no_args) get 'index' end ... then the spec will pass. The problem is really one of feedback, IMO. The mock should tell you "hey, you said I should expect a single call w/ these args, but I got another one with these other args". Right now it's not telling you that your expectation was met AND there was a problem - just that there was a problem. Thoughts? > > /Marcus > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 19 10:57:02 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Apr 2007 09:57:02 -0500 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <57c63afe0704190752pe65d761va845659224a3f643@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> <57c63afe0704180935q17d7a748icb3c13abd15b9472@mail.gmail.com> <4d4e79cc0704182335l71e69d2bqf3eeb8ce21410878@mail.gmail.com> <57c63afe0704190752pe65d761va845659224a3f643@mail.gmail.com> Message-ID: <57c63afe0704190757r596ecb7exf3a415cd6c356bda@mail.gmail.com> On 4/19/07, David Chelimsky wrote: > On 4/19/07, Marcus Ahnve wrote: > > On 4/18/07, David Chelimsky wrote: > > > [...] > > > FYI - Chris says the error is: > > > > > > expected :render with ({:layout=>false}) > > > but received it with (no args) > > > > I am seeing this as well. > > > > I am running a spec like: > > > > it "should use application layout" do > > @controller.should_receive(:render).with(:layout => "/layouts/application") > > get 'index' > > end > > > > If I change the spec to fail on purpose by for example changing the > > expected layout name, I get the correct behaviour. The 'no args' thing > > appears when the spec passes. > > OK - I'm getting somewhere with this. What happens is that render is > actually called twice. So if you do this: > > it "should use application layout" do > controller.should_receive(:render).with(:layout => "/layouts/application") > controller.should_receive(:render).with(:no_args) > get 'index' > end > > ... then the spec will pass. > > The problem is really one of feedback, IMO. The mock should tell you > "hey, you said I should expect a single call w/ these args, but I got > another one with these other args". Right now it's not telling you > that your expectation was met AND there was a problem - just that > there was a problem. > > Thoughts? Afterthought - the original post in this thread said that this problem appeared recently. I'm not 100% certain, but I think this is due to a recent change to how Spec::Rails deals with #rescue_action. It used to just catch everything. Now it lets you define the rescue_action in your controller specs and ensures that mock errors are not caught regardless of what you define. So rspec was actually hiding this problem from you in the past, but is now shining a light on it (as it should have all along). Make sense? > > > > > /Marcus > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From aslak.hellesoy at gmail.com Thu Apr 19 11:52:49 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 19 Apr 2007 17:52:49 +0200 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <10066654.post@talk.nabble.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <8d961d900704120924q5ca1837xc9b2cbcfe4f158a@mail.gmail.com> <10066654.post@talk.nabble.com> Message-ID: <8d961d900704190852j547ac9c7mf333b2439d7a2fd6@mail.gmail.com> Rails version? On 4/18/07, Jeff Dean wrote: > > zentest -v = zentest v3.4.3 > spec -v = RSpec-0.8.2 (r1560) - BDD for Ruby > spec_on_rails is a checkout of REL_0_8_2 > > > aslak hellesoy wrote: > > > > On 4/11/07, Jeff Dean wrote: > >> I've got rspec and zentest installed as well as the rspec rails plugin, > >> and > >> my model/controller specs all pass and work well. I can't seem to get > >> views > >> to work though - 100% of the specs fail with: > >> > >> NoMethodError in '/users/show.rhtml should render attributes in

' > >> protected method `render' called for > >> # > >> > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > >> `render' > >> ./spec/views/users/show_rhtml_spec.rb:13: > >> > >> Note the "protected method `render' called for > >> #" > >> > >> Here's an example spec: > >> > >> require File.dirname(__FILE__) + '/../../spec_helper' > >> > >> context "/users/new.rhtml" do > >> include UsersHelper > >> > >> setup do > >> @errors = mock("errors") > >> @errors.stub!(:count).and_return(0) > >> > >> @user = mock_user > >> @user.stub!(:errors).and_return @errors > >> assigns[:user] = @user > >> end > >> > >> specify "should render new form" do > >> render "/users/new.rhtml" > >> response.should_have_tag 'form', :attributes =>{:action => > >> users_path, > >> :method => 'post'} > >> > >> end > >> end > >> > >> Can anyone think of why "render" is protected? Is this a versioning > >> issue? > >> > > > > What versions of everything do you have? > > > > > > -- > View this message in context: > http://www.nabble.com/View-Specs-Fail-with-%22protected-method-render%22-tf3566514.html#a10066654 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeff at jefdean.com Thu Apr 19 12:03:50 2007 From: jeff at jefdean.com (Jeff Dean) Date: Thu, 19 Apr 2007 12:03:50 -0400 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <8d961d900704190852j547ac9c7mf333b2439d7a2fd6@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <8d961d900704120924q5ca1837xc9b2cbcfe4f158a@mail.gmail.com> <10066654.post@talk.nabble.com> <8d961d900704190852j547ac9c7mf333b2439d7a2fd6@mail.gmail.com> Message-ID: <6586e070704190903v24744ea9h53254cac73f54a58@mail.gmail.com> Edge - revision 6512 On 4/19/07, aslak hellesoy wrote: > > Rails version? > > On 4/18/07, Jeff Dean wrote: > > > > zentest -v = zentest v3.4.3 > > spec -v = RSpec-0.8.2 (r1560) - BDD for Ruby > > spec_on_rails is a checkout of REL_0_8_2 > > > > > > aslak hellesoy wrote: > > > > > > On 4/11/07, Jeff Dean wrote: > > >> I've got rspec and zentest installed as well as the rspec rails > plugin, > > >> and > > >> my model/controller specs all pass and work well. I can't seem to > get > > >> views > > >> to work though - 100% of the specs fail with: > > >> > > >> NoMethodError in '/users/show.rhtml should render attributes in

' > > >> protected method `render' called for > > >> # > > >> > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > >> `render' > > >> ./spec/views/users/show_rhtml_spec.rb:13: > > >> > > >> Note the "protected method `render' called for > > >> #" > > >> > > >> Here's an example spec: > > >> > > >> require File.dirname(__FILE__) + '/../../spec_helper' > > >> > > >> context "/users/new.rhtml" do > > >> include UsersHelper > > >> > > >> setup do > > >> @errors = mock("errors") > > >> @errors.stub!(:count).and_return(0) > > >> > > >> @user = mock_user > > >> @user.stub!(:errors).and_return @errors > > >> assigns[:user] = @user > > >> end > > >> > > >> specify "should render new form" do > > >> render "/users/new.rhtml" > > >> response.should_have_tag 'form', :attributes =>{:action => > > >> users_path, > > >> :method => 'post'} > > >> > > >> end > > >> end > > >> > > >> Can anyone think of why "render" is protected? Is this a versioning > > >> issue? > > >> > > > > > > What versions of everything do you have? > > > > > > > > > > -- > > View this message in context: > > > http://www.nabble.com/View-Specs-Fail-with-%22protected-method-render%22-tf3566514.html#a10066654 > > Sent from the rspec-users mailing list archive at Nabble.com. > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070419/f17c5e4b/attachment.html From dchelimsky at gmail.com Thu Apr 19 12:05:37 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Apr 2007 11:05:37 -0500 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> Message-ID: <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> On 4/10/07, Jeff Dean wrote: > I've got rspec and zentest installed as well as the rspec rails plugin, and > my model/controller specs all pass and work well. I can't seem to get views > to work though - 100% of the specs fail with: > > NoMethodError in '/users/show.rhtml should render attributes in

' > protected method `render' called for > # > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > `render' > ./spec/views/users/show_rhtml_spec.rb:13: > > Note the "protected method `render' called for > #" > > Here's an example spec: > > require File.dirname(__FILE__) + '/../../spec_helper' > > context "/users/new.rhtml" do > include UsersHelper > > setup do > @errors = mock("errors") > @errors.stub!(:count).and_return(0) > > @user = mock_user > @user.stub!(:errors).and_return @errors > assigns[:user] = @user > end > > specify "should render new form" do > render "/users/new.rhtml" > response.should_have_tag 'form', :attributes =>{:action => users_path, > :method => 'post'} > > end > end > > Can anyone think of why "render" is protected? Is this a versioning issue? It's protected in ActionController::Base in rails >= 1.2.3 (perhaps before), so Spec::Rails made it protected as well. You mentioned that you've got zentest installed - what does that have to do with this problem? RSpec's dependency on ZenTest has been gone for quite some time now. Are you running specs w/ autotest or rspec_autotest? > > Thanks - Jeff > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jeff at jefdean.com Thu Apr 19 12:08:44 2007 From: jeff at jefdean.com (Jeff Dean) Date: Thu, 19 Apr 2007 12:08:44 -0400 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> Message-ID: <6586e070704190908j6f67fa77j996344cd90b87f6@mail.gmail.com> I run the view specs with rake spec:views. I mentioned zentest only because I wasn't sure if it affected the specs in any way. If render is protected, how should I be writing my view specs? On 4/19/07, David Chelimsky wrote: > > On 4/10/07, Jeff Dean wrote: > > I've got rspec and zentest installed as well as the rspec rails plugin, > and > > my model/controller specs all pass and work well. I can't seem to get > views > > to work though - 100% of the specs fail with: > > > > NoMethodError in '/users/show.rhtml should render attributes in

' > > protected method `render' called for > > # > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > `render' > > ./spec/views/users/show_rhtml_spec.rb:13: > > > > Note the "protected method `render' called for > > #" > > > > Here's an example spec: > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > context "/users/new.rhtml" do > > include UsersHelper > > > > setup do > > @errors = mock("errors") > > @errors.stub!(:count).and_return(0) > > > > @user = mock_user > > @user.stub!(:errors).and_return @errors > > assigns[:user] = @user > > end > > > > specify "should render new form" do > > render "/users/new.rhtml" > > response.should_have_tag 'form', :attributes =>{:action => > users_path, > > :method => 'post'} > > > > end > > end > > > > Can anyone think of why "render" is protected? Is this a versioning > issue? > > It's protected in ActionController::Base in rails >= 1.2.3 (perhaps > before), so Spec::Rails made it protected as well. > > You mentioned that you've got zentest installed - what does that have > to do with this problem? RSpec's dependency on ZenTest has been gone > for quite some time now. Are you running specs w/ autotest or > rspec_autotest? > > > > > > Thanks - Jeff > > > > _______________________________________________ > > 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/20070419/42dac137/attachment.html From james at hillyerd.com Thu Apr 19 12:24:40 2007 From: james at hillyerd.com (James Hillyerd) Date: Thu, 19 Apr 2007 09:24:40 -0700 Subject: [rspec-users] Best practice thoughts: Model helpers, mocks In-Reply-To: <27c0ac6d0704190104o63509615jb039129b64aa7f87@mail.gmail.com> References: <254841be0704181707l3546d24p547f1df1d9b7e6a2@mail.gmail.com> <4b430c8f0704182259s1a320e0cib70ce6d5dd4ec449@mail.gmail.com> <27c0ac6d0704190104o63509615jb039129b64aa7f87@mail.gmail.com> Message-ID: <254841be0704190924n648da9d8r62ff04e3c8142743@mail.gmail.com> I'm not using integrated views, actually not doing any view testing at all right now since 0.8.2 doesn't work with HAML. Not sure I would even if I could though. Part of the reason that setup method has so many objects is that it's part of a wizard, so I am re-validating everything I have stored in the session. The wizard is also converting one object (signup_checkout) into a bunch of other objects (members * 4, renewals * 4). I probably should look at pushing some of my code into my model... But it seems like code dealing with a form object that is never saved to the database (signup_checkout is an "ActiveForm" http://www.realityforge.org/articles/2005/12/02/validations-for-non-activerecord-model-objects) doesn't belong in the model, so I'm a little torn. -james On 4/19/07, Matthijs Langenberg wrote: > I guess you are using integrated views, aren't you? Focus on the > behaviour of your controller method, I don't think it would ever need > all those stubbed fields, but please prove me wrong. > [..snip] -- James A. Hillyerd Chief Technical Officer - ActiveRain Corp From dchelimsky at gmail.com Thu Apr 19 12:31:40 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Apr 2007 11:31:40 -0500 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <6586e070704190908j6f67fa77j996344cd90b87f6@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> <6586e070704190908j6f67fa77j996344cd90b87f6@mail.gmail.com> Message-ID: <57c63afe0704190931w6b038926u3a1e3c4a22b517fa@mail.gmail.com> On 4/19/07, Jeff Dean wrote: > I run the view specs with rake spec:views. I mentioned zentest only because > I wasn't sure if it affected the specs in any way. > > If render is protected, how should I be writing my view specs? #render is protected on the controller - not within your spec - so saying ... it "should render new form" do render "/users/new.rhtml" ... end ... is fine. I think the message about render is a red herring. I'm not sure what the real problem is from the info we've got so far. Would you mind doing this: spec spec/views/users/show_rhtml_spec.rb -b If you are using rspec installed as a plugin then do this: vendor/rspec/bin/spec spec/views/users/show_rhtml_spec.rb -b That will provide the full backtrace info which might help diagnose this. Thanks, David > > > On 4/19/07, David Chelimsky wrote: > > > > On 4/10/07, Jeff Dean wrote: > > > I've got rspec and zentest installed as well as the rspec rails plugin, > and > > > my model/controller specs all pass and work well. I can't seem to get > views > > > to work though - 100% of the specs fail with: > > > > > > NoMethodError in '/users/show.rhtml should render attributes in

' > > > protected method `render' called for > > > # > > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > > `render' > > > ./spec/views/users/show_rhtml_spec.rb:13: > > > > > > Note the "protected method `render' called for > > > #" > > > > > > Here's an example spec: > > > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > > > context "/users/new.rhtml" do > > > include UsersHelper > > > > > > setup do > > > @errors = mock("errors") > > > @errors.stub!(:count).and_return(0) > > > > > > @user = mock_user > > > @user.stub!(:errors).and_return @errors > > > assigns[:user] = @user > > > end > > > > > > specify "should render new form" do > > > render "/users/new.rhtml" > > > response.should_have_tag 'form', :attributes =>{:action => > users_path, > > > :method => 'post'} > > > > > > end > > > end > > > > > > Can anyone think of why "render" is protected? Is this a versioning > issue? > > > > It's protected in ActionController::Base in rails >= 1.2.3 (perhaps > > before), so Spec::Rails made it protected as well. > > > > You mentioned that you've got zentest installed - what does that have > > to do with this problem? RSpec's dependency on ZenTest has been gone > > for quite some time now. Are you running specs w/ autotest or > > rspec_autotest? > > > > > > > > > > Thanks - Jeff > > > > > > _______________________________________________ > > > 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 Thu Apr 19 13:07:36 2007 From: cwdinfo at gmail.com (s.ross) Date: Thu, 19 Apr 2007 10:07:36 -0700 Subject: [rspec-users] Best practice thoughts: Model helpers, mocks In-Reply-To: <254841be0704190924n648da9d8r62ff04e3c8142743@mail.gmail.com> References: <254841be0704181707l3546d24p547f1df1d9b7e6a2@mail.gmail.com> <4b430c8f0704182259s1a320e0cib70ce6d5dd4ec449@mail.gmail.com> <27c0ac6d0704190104o63509615jb039129b64aa7f87@mail.gmail.com> <254841be0704190924n648da9d8r62ff04e3c8142743@mail.gmail.com> Message-ID: <23762BC4-5591-4319-9A4E-1AED72E7B67F@gmail.com> Why doesn't 0.8.2 work with haml? I've never had any issues with haml and I've been using it and rSpec for a while now... On Apr 19, 2007, at 9:24 AM, James Hillyerd wrote: > I'm not using integrated views, actually not doing any view testing at > all right now since 0.8.2 doesn't work with HAML. Not sure I would > even if I could though. > > Part of the reason that setup method has so many objects is that it's > part of a wizard, so I am re-validating everything I have stored in > the session. The wizard is also converting one object > (signup_checkout) into a bunch of other objects (members * 4, renewals > * 4). > > I probably should look at pushing some of my code into my model... But > it seems like code dealing with a form object that is never saved to > the database (signup_checkout is an "ActiveForm" > http://www.realityforge.org/articles/2005/12/02/validations-for-non- > activerecord-model-objects) > doesn't belong in the model, so I'm a little torn. > > -james > > On 4/19/07, Matthijs Langenberg wrote: >> I guess you are using integrated views, aren't you? Focus on the >> behaviour of your controller method, I don't think it would ever need >> all those stubbed fields, but please prove me wrong. >> > [..snip] > > -- > James A. Hillyerd > Chief Technical Officer - ActiveRain Corp > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jeff at jefdean.com Thu Apr 19 13:11:32 2007 From: jeff at jefdean.com (Jeff Dean) Date: Thu, 19 Apr 2007 13:11:32 -0400 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <57c63afe0704190931w6b038926u3a1e3c4a22b517fa@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> <6586e070704190908j6f67fa77j996344cd90b87f6@mail.gmail.com> <57c63afe0704190931w6b038926u3a1e3c4a22b517fa@mail.gmail.com> Message-ID: <6586e070704191011r47bffcdfs1dfb76a71dc3846b@mail.gmail.com> Thanks for all of your help on this. By the way - is there a donate link anywhere? Here's the result of spec spec/views/users/show_rhtml_spec.rb -b NoMethodError in '/users/show.rhtml should render attributes in

' protected method `render' called for # /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:14:in `call' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:14:in `_method_missing' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:10:in `method_missing' /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in `render' ./spec/views/users/show_rhtml_spec.rb:13: /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:66:in `instance_eval' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:66:in `execute_spec' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:31:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:37:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:34:in `each' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:34:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:21:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in `each' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/command_line.rb:29:in `run' /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec:4: /usr/local/bin/spec:18:in `load' /usr/local/bin/spec:18: On 4/19/07, David Chelimsky wrote: > > On 4/19/07, Jeff Dean wrote: > > I run the view specs with rake spec:views. I mentioned zentest only > because > > I wasn't sure if it affected the specs in any way. > > > > If render is protected, how should I be writing my view specs? > > #render is protected on the controller - not within your spec - so saying > ... > > it "should render new form" do > render "/users/new.rhtml" > ... > end > > ... is fine. > > I think the message about render is a red herring. I'm not sure what > the real problem is from the info we've got so far. Would you mind > doing this: > > spec spec/views/users/show_rhtml_spec.rb -b > > If you are using rspec installed as a plugin then do this: > > vendor/rspec/bin/spec spec/views/users/show_rhtml_spec.rb -b > > That will provide the full backtrace info which might help diagnose this. > > Thanks, > David > > > > > > > On 4/19/07, David Chelimsky wrote: > > > > > > On 4/10/07, Jeff Dean wrote: > > > > I've got rspec and zentest installed as well as the rspec rails > plugin, > > and > > > > my model/controller specs all pass and work well. I can't seem to > get > > views > > > > to work though - 100% of the specs fail with: > > > > > > > > NoMethodError in '/users/show.rhtml should render attributes in

' > > > > protected method `render' called for > > > > # > > > > > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > > > `render' > > > > ./spec/views/users/show_rhtml_spec.rb:13: > > > > > > > > Note the "protected method `render' called for > > > > #" > > > > > > > > Here's an example spec: > > > > > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > > > > > context "/users/new.rhtml" do > > > > include UsersHelper > > > > > > > > setup do > > > > @errors = mock("errors") > > > > @errors.stub!(:count).and_return(0) > > > > > > > > @user = mock_user > > > > @user.stub!(:errors).and_return @errors > > > > assigns[:user] = @user > > > > end > > > > > > > > specify "should render new form" do > > > > render "/users/new.rhtml" > > > > response.should_have_tag 'form', :attributes =>{:action => > > users_path, > > > > :method => 'post'} > > > > > > > > end > > > > end > > > > > > > > Can anyone think of why "render" is protected? Is this a versioning > > issue? > > > > > > It's protected in ActionController::Base in rails >= 1.2.3 (perhaps > > > before), so Spec::Rails made it protected as well. > > > > > > You mentioned that you've got zentest installed - what does that have > > > to do with this problem? RSpec's dependency on ZenTest has been gone > > > for quite some time now. Are you running specs w/ autotest or > > > rspec_autotest? > > > > > > > > > > > > > > Thanks - Jeff > > > > > > > > _______________________________________________ > > > > 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/20070419/619bdeb6/attachment.html From dchelimsky at gmail.com Thu Apr 19 13:57:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Apr 2007 12:57:54 -0500 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <6586e070704191011r47bffcdfs1dfb76a71dc3846b@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> <6586e070704190908j6f67fa77j996344cd90b87f6@mail.gmail.com> <57c63afe0704190931w6b038926u3a1e3c4a22b517fa@mail.gmail.com> <6586e070704191011r47bffcdfs1dfb76a71dc3846b@mail.gmail.com> Message-ID: <57c63afe0704191057w6c664babg3730c7a246841677@mail.gmail.com> On 4/19/07, Jeff Dean wrote: > Thanks for all of your help on this. By the way - is there a donate link > anywhere? > > Here's the result of spec spec/views/users/show_rhtml > _spec.rb -b > NoMethodError in '/users/show.rhtml should render attributes in

' > protected method `render' called for > # > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:14:in > `call' > /usr/local/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/spec/expectations/sugar.rb:14:in > `_method_missing' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:10:in > `method_missing' > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > `render' > ./spec/views/users/show_rhtml_spec.rb:13: > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:66:in > `instance_eval' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:66:in > `execute_spec' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:31:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:37:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/spec/runner/context.rb:34:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:34:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:21:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in > `each' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in > `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/spec/runner/command_line.rb:29:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec:4: > /usr/local/bin/spec:18:in `load' > /usr/local/bin/spec:18: Well, I'm not sure why there is a conflict between rspec 0.8.2 and edge rails, but there is apparently. I tried this w/ rails 1.2.3 and also using edge rails/edge rspec - in both cases there was no problem. I guess if you're using edge rails you should probably be using edge rspec too. > > > On 4/19/07, David Chelimsky wrote: > > > > On 4/19/07, Jeff Dean wrote: > > > I run the view specs with rake spec:views. I mentioned zentest only > because > > > I wasn't sure if it affected the specs in any way. > > > > > > If render is protected, how should I be writing my view specs? > > > > #render is protected on the controller - not within your spec - so saying > ... > > > > it "should render new form" do > > render "/users/new.rhtml" > > ... > > end > > > > ... is fine. > > > > I think the message about render is a red herring. I'm not sure what > > the real problem is from the info we've got so far. Would you mind > > doing this: > > > > spec spec/views/users/show_rhtml_spec.rb -b > > > > If you are using rspec installed as a plugin then do this: > > > > vendor/rspec/bin/spec spec/views/users/show_rhtml_spec.rb > -b > > > > That will provide the full backtrace info which might help diagnose this. > > > > Thanks, > > David > > > > > > > > > > > On 4/19/07, David Chelimsky wrote: > > > > > > > > On 4/10/07, Jeff Dean < jeff at jefdean.com> wrote: > > > > > I've got rspec and zentest installed as well as the rspec rails > plugin, > > > and > > > > > my model/controller specs all pass and work well. I can't seem to > get > > > views > > > > > to work though - 100% of the specs fail with: > > > > > > > > > > NoMethodError in '/users/show.rhtml should render attributes in

' > > > > > protected method `render' called for > > > > > > # > > > > > > > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > > > > `render' > > > > > ./spec/views/users/show_rhtml_spec.rb:13: > > > > > > > > > > Note the "protected method `render' called for > > > > > > #" > > > > > > > > > > Here's an example spec: > > > > > > > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > > > > > > > context "/users/new.rhtml" do > > > > > include UsersHelper > > > > > > > > > > setup do > > > > > @errors = mock("errors") > > > > > @errors.stub!(:count).and_return(0) > > > > > > > > > > @user = mock_user > > > > > @user.stub!(:errors).and_return @errors > > > > > assigns[:user] = @user > > > > > end > > > > > > > > > > specify "should render new form" do > > > > > render "/users/new.rhtml" > > > > > response.should_have_tag 'form', :attributes =>{:action => > > > users_path, > > > > > :method => 'post'} > > > > > > > > > > end > > > > > end > > > > > > > > > > Can anyone think of why "render" is protected? Is this a versioning > > > issue? > > > > > > > > It's protected in ActionController::Base in rails >= 1.2.3 (perhaps > > > > before), so Spec::Rails made it protected as well. > > > > > > > > You mentioned that you've got zentest installed - what does that have > > > > to do with this problem? RSpec's dependency on ZenTest has been gone > > > > for quite some time now. Are you running specs w/ autotest or > > > > rspec_autotest? > > > > > > > > > > > > > > > > > > Thanks - Jeff > > > > > > > > > > _______________________________________________ > > > > > 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 jeff at jefdean.com Thu Apr 19 14:56:14 2007 From: jeff at jefdean.com (Jeff Dean) Date: Thu, 19 Apr 2007 14:56:14 -0400 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <57c63afe0704191057w6c664babg3730c7a246841677@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> <6586e070704190908j6f67fa77j996344cd90b87f6@mail.gmail.com> <57c63afe0704190931w6b038926u3a1e3c4a22b517fa@mail.gmail.com> <6586e070704191011r47bffcdfs1dfb76a71dc3846b@mail.gmail.com> <57c63afe0704191057w6c664babg3730c7a246841677@mail.gmail.com> Message-ID: <6586e070704191156q1b244038k31c0f7ba5ef89c13@mail.gmail.com> Are you planning an major breaking changes in edge spec soon? I have to figure out if I want to go edge/edge or stable/stable, and if there aren't any huge feature changes coming down the line I think I'll go with edge. On 4/19/07, David Chelimsky wrote: > > On 4/19/07, Jeff Dean wrote: > > Thanks for all of your help on this. By the way - is there a donate > link > > anywhere? > > > > Here's the result of spec spec/views/users/show_rhtml > > _spec.rb -b > > NoMethodError in '/users/show.rhtml should render attributes in

' > > protected method `render' called for > > # > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/expectations/sugar.rb:14:in > > `call' > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > 0.8.2/lib/spec/expectations/sugar.rb:14:in > > `_method_missing' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/expectations/sugar.rb:10:in > > `method_missing' > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > `render' > > ./spec/views/users/show_rhtml_spec.rb:13: > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/specification.rb:66:in > > `instance_eval' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/specification.rb:66:in > > `execute_spec' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/specification.rb:31:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/context.rb:37:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > 0.8.2/lib/spec/runner/context.rb:34:in `each' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/context.rb:34:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/context_runner.rb:21:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/context_runner.rb:20:in > > `each' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2 > /lib/spec/runner/context_runner.rb:20:in > > `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > 0.8.2/lib/spec/runner/command_line.rb:29:in `run' > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec:4: > > /usr/local/bin/spec:18:in `load' > > /usr/local/bin/spec:18: > > Well, I'm not sure why there is a conflict between rspec 0.8.2 and > edge rails, but there is apparently. I tried this w/ rails 1.2.3 and > also using edge rails/edge rspec - in both cases there was no problem. > I guess if you're using edge rails you should probably be using edge > rspec too. > > > > > > > > > On 4/19/07, David Chelimsky wrote: > > > > > > On 4/19/07, Jeff Dean wrote: > > > > I run the view specs with rake spec:views. I mentioned zentest only > > because > > > > I wasn't sure if it affected the specs in any way. > > > > > > > > If render is protected, how should I be writing my view specs? > > > > > > #render is protected on the controller - not within your spec - so > saying > > ... > > > > > > it "should render new form" do > > > render "/users/new.rhtml" > > > ... > > > end > > > > > > ... is fine. > > > > > > I think the message about render is a red herring. I'm not sure what > > > the real problem is from the info we've got so far. Would you mind > > > doing this: > > > > > > spec spec/views/users/show_rhtml_spec.rb -b > > > > > > If you are using rspec installed as a plugin then do this: > > > > > > vendor/rspec/bin/spec spec/views/users/show_rhtml_spec.rb > > -b > > > > > > That will provide the full backtrace info which might help diagnose > this. > > > > > > Thanks, > > > David > > > > > > > > > > > > > > > On 4/19/07, David Chelimsky wrote: > > > > > > > > > > On 4/10/07, Jeff Dean < jeff at jefdean.com> wrote: > > > > > > I've got rspec and zentest installed as well as the rspec rails > > plugin, > > > > and > > > > > > my model/controller specs all pass and work well. I can't seem > to > > get > > > > views > > > > > > to work though - 100% of the specs fail with: > > > > > > > > > > > > NoMethodError in '/users/show.rhtml should render attributes in >

' > > > > > > protected method `render' called for > > > > > > > > # > > > > > > > > > > > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > > > > > `render' > > > > > > ./spec/views/users/show_rhtml_spec.rb:13: > > > > > > > > > > > > Note the "protected method `render' called for > > > > > > > > #" > > > > > > > > > > > > Here's an example spec: > > > > > > > > > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > > > > > > > > > context "/users/new.rhtml" do > > > > > > include UsersHelper > > > > > > > > > > > > setup do > > > > > > @errors = mock("errors") > > > > > > @errors.stub!(:count).and_return(0) > > > > > > > > > > > > @user = mock_user > > > > > > @user.stub!(:errors).and_return @errors > > > > > > assigns[:user] = @user > > > > > > end > > > > > > > > > > > > specify "should render new form" do > > > > > > render "/users/new.rhtml" > > > > > > response.should_have_tag 'form', :attributes =>{:action => > > > > users_path, > > > > > > :method => 'post'} > > > > > > > > > > > > end > > > > > > end > > > > > > > > > > > > Can anyone think of why "render" is protected? Is this a > versioning > > > > issue? > > > > > > > > > > It's protected in ActionController::Base in rails >= 1.2.3(perhaps > > > > > before), so Spec::Rails made it protected as well. > > > > > > > > > > You mentioned that you've got zentest installed - what does that > have > > > > > to do with this problem? RSpec's dependency on ZenTest has been > gone > > > > > for quite some time now. Are you running specs w/ autotest or > > > > > rspec_autotest? > > > > > > > > > > > > > > > > > > > > > > Thanks - Jeff > > > > > > > > > > > > _______________________________________________ > > > > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070419/fbb94b4e/attachment-0001.html From dchelimsky at gmail.com Thu Apr 19 15:04:20 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Apr 2007 14:04:20 -0500 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <6586e070704191156q1b244038k31c0f7ba5ef89c13@mail.gmail.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <57c63afe0704190905s684a396eua8d730072c4ad50b@mail.gmail.com> <6586e070704190908j6f67fa77j996344cd90b87f6@mail.gmail.com> <57c63afe0704190931w6b038926u3a1e3c4a22b517fa@mail.gmail.com> <6586e070704191011r47bffcdfs1dfb76a71dc3846b@mail.gmail.com> <57c63afe0704191057w6c664babg3730c7a246841677@mail.gmail.com> <6586e070704191156q1b244038k31c0f7ba5ef89c13@mail.gmail.com> Message-ID: <57c63afe0704191204sefd148fpc72537b5619ed836@mail.gmail.com> On 4/19/07, Jeff Dean wrote: > Are you planning an major breaking changes in edge spec soon? I have to > figure out if I want to go edge/edge or stable/stable, and if there aren't > any huge feature changes coming down the line I think I'll go with edge. Well, edge rspec breaks compatibility w/ all of the pre 0.9 "should_xxx" methods (http://rspec.rubyforge.org/upgrade.html), but it comes w/ a translator to convert your existing specs which gets most of it right (we're not looking for 100% - just close). So moving to edge won't be completely pain free if you're still using should_render, etc. Also - there are some more changes afoot in terms of using "before(:all)" instead of "context_setup", but we're not yanking the old names in these cases, so this stuff won't break what you have. You also do get a ton of benefits from 0.9 (http://www.nabble.com/ANN:-RSpec-0.9.0-beta-1-available-for-download.-t3526972.html). Let me know if you have any other questions. David > > > On 4/19/07, David Chelimsky wrote: > > On 4/19/07, Jeff Dean wrote: > > > Thanks for all of your help on this. By the way - is there a donate > link > > > anywhere? > > > > > > Here's the result of spec spec/views/users/show_rhtml > > > _spec.rb -b > > > NoMethodError in '/users/show.rhtml should render attributes in

' > > > protected method `render' called for > > > # > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:14:in > > > `call' > > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > > 0.8.2/lib/spec/expectations/sugar.rb:14:in > > > `_method_missing' > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:10:in > > > `method_missing' > > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > > `render' > > > ./spec/views/users/show_rhtml_spec.rb:13: > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:66:in > > > `instance_eval' > > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/spec/runner/specification.rb:66:in > > > `execute_spec' > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:31:in > > > `run' > > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > 0.8.2/lib/spec/runner/context.rb:37:in > > > `run' > > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > > 0.8.2/lib/spec/runner/context.rb:34:in `each' > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:34:in > > > `run' > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:21:in > > > `run' > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in > > > `each' > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in > > > `run' > > > /usr/local/lib/ruby/gems/1.8/gems/rspec- > > > 0.8.2/lib/spec/runner/command_line.rb:29:in `run' > > > > /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec:4: > > > /usr/local/bin/spec:18:in `load' > > > /usr/local/bin/spec:18: > > > > Well, I'm not sure why there is a conflict between rspec 0.8.2 and > > edge rails, but there is apparently. I tried this w/ rails 1.2.3 and > > also using edge rails/edge rspec - in both cases there was no problem. > > I guess if you're using edge rails you should probably be using edge > > rspec too. > > > > > > > > > > > > > > > On 4/19/07, David Chelimsky wrote: > > > > > > > > On 4/19/07, Jeff Dean < jeff at jefdean.com> wrote: > > > > > I run the view specs with rake spec:views. I mentioned zentest only > > > because > > > > > I wasn't sure if it affected the specs in any way. > > > > > > > > > > If render is protected, how should I be writing my view specs? > > > > > > > > #render is protected on the controller - not within your spec - so > saying > > > ... > > > > > > > > it "should render new form" do > > > > render "/users/new.rhtml" > > > > ... > > > > end > > > > > > > > ... is fine. > > > > > > > > I think the message about render is a red herring. I'm not sure what > > > > the real problem is from the info we've got so far. Would you mind > > > > doing this: > > > > > > > > spec spec/views/users/show_rhtml_spec.rb -b > > > > > > > > If you are using rspec installed as a plugin then do this: > > > > > > > > vendor/rspec/bin/spec > spec/views/users/show_rhtml_spec.rb > > > -b > > > > > > > > That will provide the full backtrace info which might help diagnose > this. > > > > > > > > Thanks, > > > > David > > > > > > > > > > > > > > > > > > > On 4/19/07, David Chelimsky wrote: > > > > > > > > > > > > On 4/10/07, Jeff Dean < jeff at jefdean.com> wrote: > > > > > > > I've got rspec and zentest installed as well as the rspec rails > > > plugin, > > > > > and > > > > > > > my model/controller specs all pass and work well. I can't seem > to > > > get > > > > > views > > > > > > > to work though - 100% of the specs fail with: > > > > > > > > > > > > > > NoMethodError in '/users/show.rhtml should render attributes in >

' > > > > > > > protected method `render' called for > > > > > > > > > > # > > > > > > > > > > > > > > > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > > > > > > `render' > > > > > > > ./spec/views/users/show_rhtml_spec.rb:13: > > > > > > > > > > > > > > Note the "protected method `render' called for > > > > > > > > > > #" > > > > > > > > > > > > > > Here's an example spec: > > > > > > > > > > > > > > require File.dirname(__FILE__) + '/../../spec_helper' > > > > > > > > > > > > > > context "/users/new.rhtml" do > > > > > > > include UsersHelper > > > > > > > > > > > > > > setup do > > > > > > > @errors = mock("errors") > > > > > > > @errors.stub!(:count).and_return(0) > > > > > > > > > > > > > > @user = mock_user > > > > > > > @user.stub!(:errors).and_return @errors > > > > > > > assigns[:user] = @user > > > > > > > end > > > > > > > > > > > > > > specify "should render new form" do > > > > > > > render "/users/new.rhtml" > > > > > > > response.should_have_tag 'form', :attributes =>{:action => > > > > > users_path, > > > > > > > :method => 'post'} > > > > > > > > > > > > > > end > > > > > > > end > > > > > > > > > > > > > > Can anyone think of why "render" is protected? Is this a > versioning > > > > > issue? > > > > > > > > > > > > It's protected in ActionController::Base in rails >= 1.2.3 > (perhaps > > > > > > before), so Spec::Rails made it protected as well. > > > > > > > > > > > > You mentioned that you've got zentest installed - what does that > have > > > > > > to do with this problem? RSpec's dependency on ZenTest has been > gone > > > > > > for quite some time now. Are you running specs w/ autotest or > > > > > > rspec_autotest? > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks - Jeff > > > > > > > > > > > > > > _______________________________________________ > > > > > > > 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 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From james at hillyerd.com Thu Apr 19 16:54:40 2007 From: james at hillyerd.com (James Hillyerd) Date: Thu, 19 Apr 2007 13:54:40 -0700 Subject: [rspec-users] Best practice thoughts: Model helpers, mocks In-Reply-To: <23762BC4-5591-4319-9A4E-1AED72E7B67F@gmail.com> References: <254841be0704181707l3546d24p547f1df1d9b7e6a2@mail.gmail.com> <4b430c8f0704182259s1a320e0cib70ce6d5dd4ec449@mail.gmail.com> <27c0ac6d0704190104o63509615jb039129b64aa7f87@mail.gmail.com> <254841be0704190924n648da9d8r62ff04e3c8142743@mail.gmail.com> <23762BC4-5591-4319-9A4E-1AED72E7B67F@gmail.com> Message-ID: <254841be0704191354s2b7eea77ufa8c0398028cac14@mail.gmail.com> "rake spec" works fine with HAML, but using the DRb server and rake spec:autotest does not at least for me. I think I'm on Rails 1.2.3 w/ HAML 1.5. -james On 4/19/07, s.ross wrote: > Why doesn't 0.8.2 work with haml? I've never had any issues with haml > and I've been using it and rSpec for a while now... > > On Apr 19, 2007, at 9:24 AM, James Hillyerd wrote: > > > I'm not using integrated views, actually not doing any view testing at > > all right now since 0.8.2 doesn't work with HAML. Not sure I would > > even if I could though. > > > > Part of the reason that setup method has so many objects is that it's > > part of a wizard, so I am re-validating everything I have stored in > > the session. The wizard is also converting one object > > (signup_checkout) into a bunch of other objects (members * 4, renewals > > * 4). > > > > I probably should look at pushing some of my code into my model... But > > it seems like code dealing with a form object that is never saved to > > the database (signup_checkout is an "ActiveForm" > > http://www.realityforge.org/articles/2005/12/02/validations-for-non- > > activerecord-model-objects) > > doesn't belong in the model, so I'm a little torn. > > > > -james > > > > On 4/19/07, Matthijs Langenberg wrote: > >> I guess you are using integrated views, aren't you? Focus on the > >> behaviour of your controller method, I don't think it would ever need > >> all those stubbed fields, but please prove me wrong. > >> > > [..snip] > > > > -- > > James A. Hillyerd > > Chief Technical Officer - ActiveRain Corp > > _______________________________________________ > > 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 > -- James A. Hillyerd Chief Technical Officer - ActiveRain Corp From christoph.sturm at gmail.com Thu Apr 19 19:51:09 2007 From: christoph.sturm at gmail.com (Christoph Sturm) Date: Fri, 20 Apr 2007 01:51:09 +0200 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <57c63afe0704190757r596ecb7exf3a415cd6c356bda@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> <57c63afe0704180935q17d7a748icb3c13abd15b9472@mail.gmail.com> <4d4e79cc0704182335l71e69d2bqf3eeb8ce21410878@mail.gmail.com> <57c63afe0704190752pe65d761va845659224a3f643@mail.gmail.com> <57c63afe0704190757r596ecb7exf3a415cd6c356bda@mail.gmail.com> Message-ID: <11dae57c0704191651i851ef62s768886b1920e821f@mail.gmail.com> Hey! On 4/19/07, David Chelimsky wrote: > > The problem is really one of feedback, IMO. The mock should tell you > > "hey, you said I should expect a single call w/ these args, but I got > > another one with these other args". Right now it's not telling you > > that your expectation was met AND there was a problem - just that > > there was a problem. > > > > Thoughts? > > Afterthought - the original post in this thread said that this problem > appeared recently. I'm not 100% certain, but I think this is due to a > recent change to how Spec::Rails deals with #rescue_action. It used to > just catch everything. Now it lets you define the rescue_action in > your controller specs and ensures that mock errors are not caught > regardless of what you define. So rspec was actually hiding this > problem from you in the past, but is now shining a light on it (as it > should have all along). Make sense? Yeah, I agree. If the error message could be fixed all should be good. I think when an expectation failed jmock listed all the expectations and stubs on that mock, and if they were met or not. I think something like that would be great. regards chris From daniel.manges at gmail.com Fri Apr 20 01:18:33 2007 From: daniel.manges at gmail.com (Daniel Manges) Date: Fri, 20 Apr 2007 01:18:33 -0400 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: <10066654.post@talk.nabble.com> References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <8d961d900704120924q5ca1837xc9b2cbcfe4f158a@mail.gmail.com> <10066654.post@talk.nabble.com> Message-ID: I think this was fixed in r1594: http://rubyforge.org/tracker/index.php?func=detail&aid=9232&group_id=797&atid=3151 Dan Manges On 4/18/07, Jeff Dean wrote: > > > zentest -v = zentest v3.4.3 > spec -v = RSpec-0.8.2 (r1560) - BDD for Ruby > spec_on_rails is a checkout of REL_0_8_2 > > > aslak hellesoy wrote: > > > > On 4/11/07, Jeff Dean wrote: > >> I've got rspec and zentest installed as well as the rspec rails plugin, > >> and > >> my model/controller specs all pass and work well. I can't seem to get > >> views > >> to work though - 100% of the specs fail with: > >> > >> NoMethodError in '/users/show.rhtml should render attributes in

' > >> protected method `render' called for > >> # > >> > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > >> `render' > >> ./spec/views/users/show_rhtml_spec.rb:13: > >> > >> Note the "protected method `render' called for > >> #" > >> > >> Here's an example spec: > >> > >> require File.dirname(__FILE__) + '/../../spec_helper' > >> > >> context "/users/new.rhtml" do > >> include UsersHelper > >> > >> setup do > >> @errors = mock("errors") > >> @errors.stub!(:count).and_return(0) > >> > >> @user = mock_user > >> @user.stub!(:errors).and_return @errors > >> assigns[:user] = @user > >> end > >> > >> specify "should render new form" do > >> render "/users/new.rhtml" > >> response.should_have_tag 'form', :attributes =>{:action => > >> users_path, > >> :method => 'post'} > >> > >> end > >> end > >> > >> Can anyone think of why "render" is protected? Is this a versioning > >> issue? > >> > > > > What versions of everything do you have? > > > > > > -- > View this message in context: > http://www.nabble.com/View-Specs-Fail-with-%22protected-method-render%22-tf3566514.html#a10066654 > Sent from the rspec-users mailing list archive at Nabble.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/20070420/13bf9071/attachment.html From jeff at jefdean.com Fri Apr 20 01:56:11 2007 From: jeff at jefdean.com (Jeff Dean) Date: Fri, 20 Apr 2007 01:56:11 -0400 Subject: [rspec-users] View Specs Fail with "protected method render" In-Reply-To: References: <6586e070704101721p41f265a5vf37120e7798edb21@mail.gmail.com> <8d961d900704120924q5ca1837xc9b2cbcfe4f158a@mail.gmail.com> <10066654.post@talk.nabble.com> Message-ID: <6586e070704192256w2b39b3bcv2e8383a46651e52b@mail.gmail.com> Thanks dan - I'll check out to at least that revision and see what I get. On 4/20/07, Daniel Manges wrote: > > I think this was fixed in r1594: http://rubyforge.org/tracker/index.php?func=detail&aid=9232&group_id=797&atid=3151 > > > Dan Manges > > > On 4/18/07, Jeff Dean wrote: > > > > > > zentest -v = zentest v3.4.3 > > spec -v = RSpec-0.8.2 (r1560) - BDD for Ruby > > spec_on_rails is a checkout of REL_0_8_2 > > > > > > aslak hellesoy wrote: > > > > > > On 4/11/07, Jeff Dean < jeff at jefdean.com> wrote: > > >> I've got rspec and zentest installed as well as the rspec rails > > plugin, > > >> and > > >> my model/controller specs all pass and work well. I can't seem to > > get > > >> views > > >> to work though - 100% of the specs fail with: > > >> > > >> NoMethodError in '/users/show.rhtml should render attributes in

' > > >> protected method `render' called for > > >> # > > >> > > /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in > > >> `render' > > >> ./spec/views/users/show_rhtml_spec.rb:13: > > >> > > >> Note the "protected method `render' called for > > >> #" > > >> > > >> Here's an example spec: > > >> > > >> require File.dirname(__FILE__) + '/../../spec_helper' > > >> > > >> context "/users/new.rhtml" do > > >> include UsersHelper > > >> > > >> setup do > > >> @errors = mock("errors") > > >> @errors.stub!(:count).and_return(0) > > >> > > >> @user = mock_user > > >> @user.stub!(:errors).and_return @errors > > >> assigns[:user] = @user > > >> end > > >> > > >> specify "should render new form" do > > >> render "/users/new.rhtml" > > >> response.should_have_tag 'form', :attributes =>{:action => > > >> users_path, > > >> :method => 'post'} > > >> > > >> end > > >> end > > >> > > >> Can anyone think of why "render" is protected? Is this a versioning > > >> issue? > > >> > > > > > > What versions of everything do you have? > > > > > > > > > > -- > > View this message in context: > > http://www.nabble.com/View-Specs-Fail-with-%22protected-method-render%22-tf3566514.html#a10066654 > > Sent from the rspec-users mailing list archive at Nabble.com. > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070420/df5d1ddc/attachment-0001.html From jeff at jefdean.com Fri Apr 20 02:24:28 2007 From: jeff at jefdean.com (Jeff Dean) Date: Fri, 20 Apr 2007 02:24:28 -0400 Subject: [rspec-users] svn url for trunk Message-ID: <6586e070704192324t6bd5e2fega1803fb028289b82@mail.gmail.com> FYI - I want to install rspec_on_rails from trunk - on http://rspec.rubyforge.org/documentation/rails/install.html it points to: - svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails But that doesn't seem to exist anymore. I used: - svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails And it seemed to work. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070420/69651373/attachment.html From jeff at jefdean.com Fri Apr 20 03:12:29 2007 From: jeff at jefdean.com (Jeff Dean) Date: Fri, 20 Apr 2007 03:12:29 -0400 Subject: [rspec-users] getting controller specs to work on edge Message-ID: <6586e070704200012y348805a7y3aed08272dc6aa85@mail.gmail.com> I'm using edge spec, edge rspec_on_rails, edge rails. I just switched to edge and ran the translator tool and I'm trying to get everything to pass again. One of my issues is getting render back up and working for my controller specs, here's an example: describe "Requesting /users using GET" do controller_name :users setup do @user = mock_model(User) User.stub!(:find).and_return(@user) end it "should render index.rhtml" do response.should render_template('index') do_get end end When I run that via rake spec:controllers I get: NoMethodError in 'Requesting /users using GET should render index.rhtml' You have a nil object when you didn't expect it! The error occurred while evaluating nil.first_render .../vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb:12:in `matches?' Originally, after the translator, the "it" section was: it "should render index.rhtml" do controller.should render_template('index') do_get end But that gave me NoMethodError in 'Requesting /users using GET should render index.rhtml' undefined method `rendered_file' for # .../vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb:12:in `matches?' Can anyone see what I'm doing wrong?? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070420/12e750eb/attachment.html From jeff at jefdean.com Fri Apr 20 03:16:10 2007 From: jeff at jefdean.com (Jeff Dean) Date: Fri, 20 Apr 2007 03:16:10 -0400 Subject: [rspec-users] getting controller specs to work on edge In-Reply-To: <6586e070704200012y348805a7y3aed08272dc6aa85@mail.gmail.com> References: <6586e070704200012y348805a7y3aed08272dc6aa85@mail.gmail.com> Message-ID: <6586e070704200016y2bb3a77exad55acda1c7e50cd@mail.gmail.com> Sorry - I solved it. I needed to put the do_get line *before* the response - so this works: describe "Requesting /users using GET" do controller_name :users setup do @user = mock_model(User) User.stub!(:find).and_return(@user) end def do_get get :index end it "should render index.rhtml" do do_get response.should render_template('index') end end On 4/20/07, Jeff Dean wrote: > > I'm using edge spec, edge rspec_on_rails, edge rails. I just switched to > edge and ran the translator tool and I'm trying to get everything to pass > again. One of my issues is getting render back up and working for my > controller specs, here's an example: > > describe "Requesting /users using GET" do > controller_name :users > > setup do > @user = mock_model(User) > User.stub!(:find).and_return(@user) > end > > it "should render index.rhtml" do > response.should render_template('index') > do_get > end > end > > When I run that via rake spec:controllers I get: > > NoMethodError in 'Requesting /users using GET should render index.rhtml' > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.first_render > .../vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb:12:in > `matches?' > > Originally, after the translator, the "it" section was: > > it "should render index.rhtml" do > controller.should render_template('index') > do_get > end > > But that gave me > > NoMethodError in 'Requesting /users using GET should render index.rhtml' > undefined method `rendered_file' for # > .../vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb:12:in > `matches?' > > Can anyone see what I'm doing wrong?? > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070420/6a3ea60a/attachment.html From jeff at jefdean.com Fri Apr 20 03:48:45 2007 From: jeff at jefdean.com (Jeff Dean) Date: Fri, 20 Apr 2007 03:48:45 -0400 Subject: [rspec-users] simply_helpful and edge Message-ID: <6586e070704200048y676b5d6fuf1df14b70764183f@mail.gmail.com> Does anyone have view specs running on edge with simply_helpful? I tried http://blog.methodmissing.com/2006/11/23/using-simply_helpful-with-rspec-controller-tests/but it seems that was written for pre-9 versions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070420/0bc8d366/attachment.html From aslak.hellesoy at gmail.com Fri Apr 20 04:15:54 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 20 Apr 2007 10:15:54 +0200 Subject: [rspec-users] Version numbers Message-ID: <8d961d900704200115j4a0ef777t3b974e5a8dce5ecb@mail.gmail.com> Everybody, When you ask a question, please don't forget to mention what versions of software you're running - for example: * OS X 10.4.9 * Ruby 1.8.6 * RSpec 1.8.2 or RSpec trunk r1643 * Spec::Rails 1.8.2 or Spec::Rails tag r1234... * Rails 1.2.3 or Rails edge r5645 * Whatever other relevant software. Because, you see, without this information it's like solving 1 equation (your question) with 5 unknown variables (the versions). And I think you all know that that is a tough challenge. Please *repeat* this information in new threads - we don't remember from time to time who's using what - nor do we telepathically know when you decide to upgrade or downgrade something. Cheers, Aslak From marcus at ahnve.com Fri Apr 20 08:41:07 2007 From: marcus at ahnve.com (Marcus Ahnve) Date: Fri, 20 Apr 2007 14:41:07 +0200 Subject: [rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk In-Reply-To: <11dae57c0704191651i851ef62s768886b1920e821f@mail.gmail.com> References: <11dae57c0704170708t1c806cfbx63462d0baa0d958d@mail.gmail.com> <8d961d900704170734q136b26dbw6b29c99565740b4a@mail.gmail.com> <57c63afe0704180935q17d7a748icb3c13abd15b9472@mail.gmail.com> <4d4e79cc0704182335l71e69d2bqf3eeb8ce21410878@mail.gmail.com> <57c63afe0704190752pe65d761va845659224a3f643@mail.gmail.com> <57c63afe0704190757r596ecb7exf3a415cd6c356bda@mail.gmail.com> <11dae57c0704191651i851ef62s768886b1920e821f@mail.gmail.com> Message-ID: <4d4e79cc0704200541q5d71cafcje457b0a98421ee33@mail.gmail.com> On 4/20/07, Christoph Sturm wrote: > Hey! > > On 4/19/07, David Chelimsky wrote: > > > The problem is really one of feedback, IMO. The mock should tell you > > > "hey, you said I should expect a single call w/ these args, but I got > > > another one with these other args". Right now it's not telling you > > > that your expectation was met AND there was a problem - just that > > > there was a problem. > > > > > > Thoughts? > > > > Afterthought - the original post in this thread said that this problem > > appeared recently. I'm not 100% certain, but I think this is due to a > > recent change to how Spec::Rails deals with #rescue_action. It used to > > just catch everything. Now it lets you define the rescue_action in > > your controller specs and ensures that mock errors are not caught > > regardless of what you define. So rspec was actually hiding this > > problem from you in the past, but is now shining a light on it (as it > > should have all along). Make sense? > > Yeah, I agree. If the error message could be fixed all should be good. > I think when an expectation failed jmock listed all the expectations > and stubs on that mock, and if they were met or not. I think something > like that would be great. Agree. Thanks for your answer David. /Marcus -- http://marcus.ahnve.net From mailing_lists at railsnewbie.com Fri Apr 20 11:20:19 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 20 Apr 2007 11:20:19 -0400 Subject: [rspec-users] stubbing with and without a string Message-ID: <32C281D4-93F9-4CAD-B9D7-8BBAA0B8E39B@railsnewbie.com> What is the difference between these two ways of mocking (with and without the string): mock('Object') and mock(Object) ? Scott From dchelimsky at gmail.com Fri Apr 20 11:29:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 10:29:29 -0500 Subject: [rspec-users] stubbing with and without a string In-Reply-To: <32C281D4-93F9-4CAD-B9D7-8BBAA0B8E39B@railsnewbie.com> References: <32C281D4-93F9-4CAD-B9D7-8BBAA0B8E39B@railsnewbie.com> Message-ID: <57c63afe0704200829jfc3ab16r5e812fd7ac91b0b3@mail.gmail.com> On 4/20/07, Scott Taylor wrote: > What is the difference between these two ways of mocking (with and > without the string): > > mock('Object') > > and > > mock(Object) > > ? > > Scott IIRC, using the #mock method, there is really no difference (are you observing any difference?). Using the Spec::Rails mock_model method, you must use the class instead of a String. There *was* talk at one point of adding a feature that would allow you to run examples w/ a command line switch that would look for all the mocks created w/ mock(Type) and report back if the type didn't actually support the expected methods. But that's not present so there's really no diff now. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matthew.heidemann at gmail.com Fri Apr 20 11:58:55 2007 From: matthew.heidemann at gmail.com (Matthew Heidemann) Date: Fri, 20 Apr 2007 08:58:55 -0700 Subject: [rspec-users] simply_helpful and edge In-Reply-To: <6586e070704200048y676b5d6fuf1df14b70764183f@mail.gmail.com> References: <6586e070704200048y676b5d6fuf1df14b70764183f@mail.gmail.com> Message-ID: <306e36aa0704200858r1b234d97ka2669b19fc7b8d45@mail.gmail.com> With helper specs I just included them in the describe. But with view specs you can also explicitly call a helper on render: render '/test/test.erb', :helper => SimplyHelpful::RecordIdentificationHelper On 4/20/07, Jeff Dean wrote: > > Does anyone have view specs running on edge with simply_helpful? > > I tried http://blog.methodmissing.com/2006/11/23/using-simply_helpful-with-rspec-controller-tests/ > but it seems that was written for pre-9 versions. > > _______________________________________________ > 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/20070420/5dcbfb62/attachment-0001.html From mailing_lists at railsnewbie.com Fri Apr 20 12:13:49 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 20 Apr 2007 12:13:49 -0400 Subject: [rspec-users] stubbing with and without a string In-Reply-To: <57c63afe0704200829jfc3ab16r5e812fd7ac91b0b3@mail.gmail.com> References: <32C281D4-93F9-4CAD-B9D7-8BBAA0B8E39B@railsnewbie.com> <57c63afe0704200829jfc3ab16r5e812fd7ac91b0b3@mail.gmail.com> Message-ID: What exactly does the mock_model do which is different from the regular mock ? Scott On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote: > On 4/20/07, Scott Taylor wrote: >> What is the difference between these two ways of mocking (with and >> without the string): >> >> mock('Object') >> >> and >> >> mock(Object) >> >> ? >> >> Scott > > IIRC, using the #mock method, there is really no difference (are you > observing any difference?). Using the Spec::Rails mock_model method, > you must use the class instead of a String. > > There *was* talk at one point of adding a feature that would allow you > to run examples w/ a command line switch that would look for all the > mocks created w/ mock(Type) and report back if the type didn't > actually support the expected methods. But that's not present so > there's really no diff now. > > >> _______________________________________________ >> 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 Apr 20 12:26:27 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 11:26:27 -0500 Subject: [rspec-users] stubbing with and without a string In-Reply-To: References: <32C281D4-93F9-4CAD-B9D7-8BBAA0B8E39B@railsnewbie.com> <57c63afe0704200829jfc3ab16r5e812fd7ac91b0b3@mail.gmail.com> Message-ID: <57c63afe0704200926x296fb457rd8fd69b522a536c6@mail.gmail.com> On 4/20/07, Scott Taylor wrote: > > What exactly does the mock_model do which is different from the > regular mock ? It stubs out a bunch of stuff commonly required by rails. Take a look at the code for details - just search for "def mock_model" in the rspec plugin (I'd tell you exactly where to look but it's moved around a couple of times so it depends on which version you have). > > > Scott > > On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote: > > > On 4/20/07, Scott Taylor wrote: > >> What is the difference between these two ways of mocking (with and > >> without the string): > >> > >> mock('Object') > >> > >> and > >> > >> mock(Object) > >> > >> ? > >> > >> Scott > > > > IIRC, using the #mock method, there is really no difference (are you > > observing any difference?). Using the Spec::Rails mock_model method, > > you must use the class instead of a String. > > > > There *was* talk at one point of adding a feature that would allow you > > to run examples w/ a command line switch that would look for all the > > mocks created w/ mock(Type) and report back if the type didn't > > actually support the expected methods. But that's not present so > > there's really no diff now. > > > > > >> _______________________________________________ > >> 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 Apr 20 12:48:18 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 20 Apr 2007 12:48:18 -0400 Subject: [rspec-users] speccing a call to break Message-ID: How can I spec that a method calls break? As far as I can see from ri, break is a pure syntax element (not a method from Kernel or Object), so I'm not sure what to mock... E.g.: class SomeClass def a_method loop do break end end end Scott P.S. Sorry for the annoying questions, but I just want to know! P.P.S: What is the right form of the verb "to spec" in the Progressive? Is it "specing" or "speccing"? From mailing_lists at railsnewbie.com Fri Apr 20 12:58:10 2007 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Fri, 20 Apr 2007 12:58:10 -0400 Subject: [rspec-users] stubbing with and without a string In-Reply-To: <57c63afe0704200926x296fb457rd8fd69b522a536c6@mail.gmail.com> References: <32C281D4-93F9-4CAD-B9D7-8BBAA0B8E39B@railsnewbie.com> <57c63afe0704200829jfc3ab16r5e812fd7ac91b0b3@mail.gmail.com> <57c63afe0704200926x296fb457rd8fd69b522a536c6@mail.gmail.com> Message-ID: On Apr 20, 2007, at 12:26 PM, David Chelimsky wrote: > On 4/20/07, Scott Taylor wrote: >> >> What exactly does the mock_model do which is different from the >> regular mock ? > > It stubs out a bunch of stuff commonly required by rails. Take a look > at the code for details - just search for "def mock_model" in the > rspec plugin (I'd tell you exactly where to look but it's moved around > a couple of times so it depends on which version you have). I know I've seen it before in the rspec code, so I'll search for it again. Thanks David, Scott > >> >> >> Scott >> >> On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote: >> >>> On 4/20/07, Scott Taylor wrote: >>>> What is the difference between these two ways of mocking (with and >>>> without the string): >>>> >>>> mock('Object') >>>> >>>> and >>>> >>>> mock(Object) >>>> >>>> ? >>>> >>>> Scott >>> >>> IIRC, using the #mock method, there is really no difference (are you >>> observing any difference?). Using the Spec::Rails mock_model method, >>> you must use the class instead of a String. >>> >>> There *was* talk at one point of adding a feature that would >>> allow you >>> to run examples w/ a command line switch that would look for all the >>> mocks created w/ mock(Type) and report back if the type didn't >>> actually support the expected methods. But that's not present so >>> there's really no diff now. >>> >>> >>>> _______________________________________________ >>>> 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 Apr 20 13:00:45 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 12:00:45 -0500 Subject: [rspec-users] speccing a call to break In-Reply-To: References: Message-ID: <57c63afe0704201000x3197bc32ib49ece26e82c0eb0@mail.gmail.com> On 4/20/07, Scott Taylor wrote: > > How can I spec that a method calls break? As far as I can see from > ri, break is a pure syntax element (not a method from Kernel or > Object), so I'm not sure what to mock... > > E.g.: > > class SomeClass > def a_method > loop do > break > end > end > end Why are you spec'ing such low level implementation detail? The fact that you're calling break shouldn't matter. What matters is that given some pre-conditions, some behaviour occurs and given other pre-conditions different behaviour occurs. Spec the behaviour, not the implementation. > > > > Scott > > P.S. Sorry for the annoying questions, but I just want to know! > P.P.S: What is the right form of the verb "to spec" in the > Progressive? Is it "specing" or "speccing"? We had a poll about that a while back and I think "spec'ing" won. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 20 13:01:27 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 12:01:27 -0500 Subject: [rspec-users] stubbing with and without a string In-Reply-To: References: <32C281D4-93F9-4CAD-B9D7-8BBAA0B8E39B@railsnewbie.com> <57c63afe0704200829jfc3ab16r5e812fd7ac91b0b3@mail.gmail.com> <57c63afe0704200926x296fb457rd8fd69b522a536c6@mail.gmail.com> Message-ID: <57c63afe0704201001k4c9ea110yc1ad145bcf565b98@mail.gmail.com> On 4/20/07, Scott Taylor wrote: > > On Apr 20, 2007, at 12:26 PM, David Chelimsky wrote: > > > On 4/20/07, Scott Taylor wrote: > >> > >> What exactly does the mock_model do which is different from the > >> regular mock ? > > > > It stubs out a bunch of stuff commonly required by rails. Take a look > > at the code for details - just search for "def mock_model" in the > > rspec plugin (I'd tell you exactly where to look but it's moved around > > a couple of times so it depends on which version you have). > > I know I've seen it before in the rspec code, so I'll search for it > again. To be clear - it's in the Spec::Rails code, not rspec core. > > Thanks David, > > Scott > > > > > >> > >> > >> Scott > >> > >> On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote: > >> > >>> On 4/20/07, Scott Taylor wrote: > >>>> What is the difference between these two ways of mocking (with and > >>>> without the string): > >>>> > >>>> mock('Object') > >>>> > >>>> and > >>>> > >>>> mock(Object) > >>>> > >>>> ? > >>>> > >>>> Scott > >>> > >>> IIRC, using the #mock method, there is really no difference (are you > >>> observing any difference?). Using the Spec::Rails mock_model method, > >>> you must use the class instead of a String. > >>> > >>> There *was* talk at one point of adding a feature that would > >>> allow you > >>> to run examples w/ a command line switch that would look for all the > >>> mocks created w/ mock(Type) and report back if the type didn't > >>> actually support the expected methods. But that's not present so > >>> there's really no diff now. > >>> > >>> > >>>> _______________________________________________ > >>>> 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 james at hillyerd.com Fri Apr 20 17:48:11 2007 From: james at hillyerd.com (James Hillyerd) Date: Fri, 20 Apr 2007 14:48:11 -0700 Subject: [rspec-users] Stubbing Model.new w/ block? Message-ID: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> Ok, I followed the advice of the list and moved more code into my model from my controller. When developing tests for this new code, I ran into a problem... My model code creates a receipt object and sets some values on it: @receipt = Receipt.new do |r| r.x = 1 r.y = 2 # etc end I wanted to be able to stub out Receipt.new so that I could set expectations on the methods called on the resulting Receipt object. If in my test setup I do: @receipt = mock_receipt Receipt.stub!(:new).and_return(@receipt) The block part of the code will never be called. If I do: Receipt.stub!(:new).and_yield(@receipt) Then @receipt in my model will be set to the return value of the block. I also tried something along the lines of: Receipt.stub!(:new) do yield @receipt @receipt end but got some weird no block error. Help? Am I going about this all wrong? -james -- James A. Hillyerd Chief Technical Officer - ActiveRain Corp From dchelimsky at gmail.com Fri Apr 20 18:49:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 17:49:55 -0500 Subject: [rspec-users] Stubbing Model.new w/ block? In-Reply-To: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> References: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> Message-ID: <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> On 4/20/07, James Hillyerd wrote: > Ok, I followed the advice of the list and moved more code into my > model from my controller. When developing tests for this new code, I > ran into a problem... > > My model code creates a receipt object and sets some values on it: > > @receipt = Receipt.new do |r| > r.x = 1 > r.y = 2 > # etc > end > > I wanted to be able to stub out Receipt.new so that I could set > expectations on the methods called on the resulting Receipt object. > If in my test setup I do: > > @receipt = mock_receipt > Receipt.stub!(:new).and_return(@receipt) > > The block part of the code will never be called. If I do: > > Receipt.stub!(:new).and_yield(@receipt) > > Then @receipt in my model will be set to the return value of the block. > > I also tried something along the lines of: > > Receipt.stub!(:new) do > yield @receipt > @receipt > end > > but got some weird no block error. > > Help? Am I going about this all wrong? Any reason you don't just query a real receipt object? describe Person do it "should create an initialized person" do Person.create_initialized("Michael").name.should == "Michael" end end class Person class << self def create_initialized(name) Person.new do |p| p.name = name end end end end What you're trying to mock here doesn't seem to buy you much. Unless I'm missing something. > > -james > > -- > James A. Hillyerd > Chief Technical Officer - ActiveRain Corp > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 20 18:56:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 17:56:34 -0500 Subject: [rspec-users] Stubbing Model.new w/ block? In-Reply-To: <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> References: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> Message-ID: <57c63afe0704201556k181eb549jac4a5a8f3b4e4df3@mail.gmail.com> On 4/20/07, David Chelimsky wrote: > On 4/20/07, James Hillyerd wrote: > > Ok, I followed the advice of the list and moved more code into my > > model from my controller. When developing tests for this new code, I > > ran into a problem... > > > > My model code creates a receipt object and sets some values on it: > > > > @receipt = Receipt.new do |r| > > r.x = 1 > > r.y = 2 > > # etc > > end > > > > I wanted to be able to stub out Receipt.new so that I could set > > expectations on the methods called on the resulting Receipt object. > > If in my test setup I do: > > > > @receipt = mock_receipt > > Receipt.stub!(:new).and_return(@receipt) > > > > The block part of the code will never be called. If I do: > > > > Receipt.stub!(:new).and_yield(@receipt) > > > > Then @receipt in my model will be set to the return value of the block. > > > > I also tried something along the lines of: > > > > Receipt.stub!(:new) do > > yield @receipt > > @receipt > > end > > > > but got some weird no block error. > > > > Help? Am I going about this all wrong? > > Any reason you don't just query a real receipt object? > > describe Person do > it "should create an initialized person" do > Person.create_initialized("Michael").name.should == "Michael" > end > end > > class Person > class << self > def create_initialized(name) > Person.new do |p| > p.name = name > end > end > end > end > > What you're trying to mock here doesn't seem to buy you much. Unless > I'm missing something. I just tried this: irb(main):001:0> class Receipt irb(main):002:1> attr_accessor :name irb(main):003:1> end => nil irb(main):004:0> r = Receipt.new do |r| irb(main):005:1* r.name = "Ruby" irb(main):006:1> end => # irb(main):007:0> r.name => nil Does AR do something special w/ Model.new that Ruby doesn't do already? > > > > > -james > > > > -- > > James A. Hillyerd > > Chief Technical Officer - ActiveRain Corp > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From james at hillyerd.com Fri Apr 20 19:11:04 2007 From: james at hillyerd.com (James Hillyerd) Date: Fri, 20 Apr 2007 16:11:04 -0700 Subject: [rspec-users] Stubbing Model.new w/ block? In-Reply-To: <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> References: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> Message-ID: <254841be0704201611j616da6b1wea2d5702941b49db@mail.gmail.com> I switched to using a real receipt when I couldn't get the stubs to work, but it did make some of the tests more difficult. Plus these tests are actually on the Order object, so it seemed natural to stub out the Receipt so I'm not trying test it as well. I don't quite follow the code that you included... are you essentially overriding the your Person model with your own class for the test? This is the snippet of code I'm trying to test. I won't argue that I need stubs here, just that I was trying to use them and couldn't. :) class Order < ActiveRecord::Base # ... deleted # Builds a receipt and associated receipt_items, # then distributes the payment across them. def build_receipt(date_paid, payment_method, amount_paid_cents) receipt = Receipt.new do |r| r.member = member r.payment_method = payment_method r.date_paid = date_paid end # ... deleted end end Thanks. -james On 4/20/07, David Chelimsky wrote: > On 4/20/07, James Hillyerd wrote: > > Ok, I followed the advice of the list and moved more code into my > > model from my controller. When developing tests for this new code, I > > ran into a problem... > > > > My model code creates a receipt object and sets some values on it: > > > > @receipt = Receipt.new do |r| > > r.x = 1 > > r.y = 2 > > # etc > > end > > > > I wanted to be able to stub out Receipt.new so that I could set > > expectations on the methods called on the resulting Receipt object. > > If in my test setup I do: > > > > @receipt = mock_receipt > > Receipt.stub!(:new).and_return(@receipt) > > > > The block part of the code will never be called. If I do: > > > > Receipt.stub!(:new).and_yield(@receipt) > > > > Then @receipt in my model will be set to the return value of the block. > > > > I also tried something along the lines of: > > > > Receipt.stub!(:new) do > > yield @receipt > > @receipt > > end > > > > but got some weird no block error. > > > > Help? Am I going about this all wrong? > > Any reason you don't just query a real receipt object? > > describe Person do > it "should create an initialized person" do > Person.create_initialized("Michael").name.should == "Michael" > end > end > > class Person > class << self > def create_initialized(name) > Person.new do |p| > p.name = name > end > end > end > end > > What you're trying to mock here doesn't seem to buy you much. Unless > I'm missing something. > > > > > -james > > > > -- > > James A. Hillyerd > > Chief Technical Officer - ActiveRain Corp > > _______________________________________________ > > 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 > -- James A. Hillyerd Chief Technical Officer - ActiveRain Corp From dchelimsky at gmail.com Fri Apr 20 19:22:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 18:22:54 -0500 Subject: [rspec-users] Stubbing Model.new w/ block? In-Reply-To: <254841be0704201611j616da6b1wea2d5702941b49db@mail.gmail.com> References: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> <254841be0704201611j616da6b1wea2d5702941b49db@mail.gmail.com> Message-ID: <57c63afe0704201622i6b0ce73di28e9550c540be332@mail.gmail.com> On 4/20/07, James Hillyerd wrote: > I switched to using a real receipt when I couldn't get the stubs to > work, but it did make some of the tests more difficult. Plus these > tests are actually on the Order object, so it seemed natural to stub > out the Receipt so I'm not trying test it as well. > > I don't quite follow the code that you included... are you essentially > overriding the your Person model with your own class for the test? > > This is the snippet of code I'm trying to test. I won't argue that I > need stubs here, just that I was trying to use them and couldn't. :) > > class Order < ActiveRecord::Base > # ... deleted > > # Builds a receipt and associated receipt_items, > # then distributes the payment across them. > def build_receipt(date_paid, payment_method, amount_paid_cents) > receipt = Receipt.new do |r| > r.member = member > r.payment_method = payment_method > r.date_paid = date_paid > end > > # ... deleted > end > end I don't have a solution for you using mocks - but I wonder why you're not just doing this: Receipt.new(:member => member, :payment_method => payment_method, :amount_paid_cents => amount_paid_cents) Any reason? > > Thanks. > > -james > > On 4/20/07, David Chelimsky wrote: > > On 4/20/07, James Hillyerd wrote: > > > Ok, I followed the advice of the list and moved more code into my > > > model from my controller. When developing tests for this new code, I > > > ran into a problem... > > > > > > My model code creates a receipt object and sets some values on it: > > > > > > @receipt = Receipt.new do |r| > > > r.x = 1 > > > r.y = 2 > > > # etc > > > end > > > > > > I wanted to be able to stub out Receipt.new so that I could set > > > expectations on the methods called on the resulting Receipt object. > > > If in my test setup I do: > > > > > > @receipt = mock_receipt > > > Receipt.stub!(:new).and_return(@receipt) > > > > > > The block part of the code will never be called. If I do: > > > > > > Receipt.stub!(:new).and_yield(@receipt) > > > > > > Then @receipt in my model will be set to the return value of the block. > > > > > > I also tried something along the lines of: > > > > > > Receipt.stub!(:new) do > > > yield @receipt > > > @receipt > > > end > > > > > > but got some weird no block error. > > > > > > Help? Am I going about this all wrong? > > > > Any reason you don't just query a real receipt object? > > > > describe Person do > > it "should create an initialized person" do > > Person.create_initialized("Michael").name.should == "Michael" > > end > > end > > > > class Person > > class << self > > def create_initialized(name) > > Person.new do |p| > > p.name = name > > end > > end > > end > > end > > > > What you're trying to mock here doesn't seem to buy you much. Unless > > I'm missing something. > > > > > > > > -james > > > > > > -- > > > James A. Hillyerd > > > Chief Technical Officer - ActiveRain Corp > > > _______________________________________________ > > > 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 > > > > > -- > James A. Hillyerd > Chief Technical Officer - ActiveRain Corp > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From james at hillyerd.com Fri Apr 20 19:28:47 2007 From: james at hillyerd.com (James Hillyerd) Date: Fri, 20 Apr 2007 16:28:47 -0700 Subject: [rspec-users] Stubbing Model.new w/ block? In-Reply-To: <57c63afe0704201556k181eb549jac4a5a8f3b4e4df3@mail.gmail.com> References: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> <57c63afe0704201556k181eb549jac4a5a8f3b4e4df3@mail.gmail.com> Message-ID: <254841be0704201628i1f950183yb46cd64df9f225d6@mail.gmail.com> Found this in the AR source: # New objects can be instantiated as either empty (pass no construction parameter) or pre-set with # attributes but not yet saved (pass a hash with key names matching the associated table column names). # In both instances, valid attribute keys are determined by the column names of the associated table -- # hence you can't have attributes that aren't part of the table columns. def initialize(attributes = nil) @attributes = attributes_from_column_definition @new_record = true ensure_proper_type self.attributes = attributes unless attributes.nil? yield self if block_given? end -james On 4/20/07, David Chelimsky wrote: > On 4/20/07, David Chelimsky wrote: > > On 4/20/07, James Hillyerd wrote: > > > Ok, I followed the advice of the list and moved more code into my > > > model from my controller. When developing tests for this new code, I > > > ran into a problem... > > > > > > My model code creates a receipt object and sets some values on it: > > > > > > @receipt = Receipt.new do |r| > > > r.x = 1 > > > r.y = 2 > > > # etc > > > end > > > > > > I wanted to be able to stub out Receipt.new so that I could set > > > expectations on the methods called on the resulting Receipt object. > > > If in my test setup I do: > > > > > > @receipt = mock_receipt > > > Receipt.stub!(:new).and_return(@receipt) > > > > > > The block part of the code will never be called. If I do: > > > > > > Receipt.stub!(:new).and_yield(@receipt) > > > > > > Then @receipt in my model will be set to the return value of the block. > > > > > > I also tried something along the lines of: > > > > > > Receipt.stub!(:new) do > > > yield @receipt > > > @receipt > > > end > > > > > > but got some weird no block error. > > > > > > Help? Am I going about this all wrong? > > > > Any reason you don't just query a real receipt object? > > > > describe Person do > > it "should create an initialized person" do > > Person.create_initialized("Michael").name.should == "Michael" > > end > > end > > > > class Person > > class << self > > def create_initialized(name) > > Person.new do |p| > > p.name = name > > end > > end > > end > > end > > > > What you're trying to mock here doesn't seem to buy you much. Unless > > I'm missing something. > > I just tried this: > > irb(main):001:0> class Receipt > irb(main):002:1> attr_accessor :name > irb(main):003:1> end > => nil > irb(main):004:0> r = Receipt.new do |r| > irb(main):005:1* r.name = "Ruby" > irb(main):006:1> end > => # > irb(main):007:0> r.name > => nil > > Does AR do something special w/ Model.new that Ruby doesn't do already? > > > > > > > > > > -james > > > > > > -- > > > James A. Hillyerd > > > Chief Technical Officer - ActiveRain Corp > > > _______________________________________________ > > > 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 > -- James A. Hillyerd Chief Technical Officer - ActiveRain Corp From james at hillyerd.com Fri Apr 20 19:36:10 2007 From: james at hillyerd.com (James Hillyerd) Date: Fri, 20 Apr 2007 16:36:10 -0700 Subject: [rspec-users] Stubbing Model.new w/ block? In-Reply-To: <57c63afe0704201622i6b0ce73di28e9550c540be332@mail.gmail.com> References: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> <254841be0704201611j616da6b1wea2d5702941b49db@mail.gmail.com> <57c63afe0704201622i6b0ce73di28e9550c540be332@mail.gmail.com> Message-ID: <254841be0704201636s799838a3t8c54bb8e521cd26@mail.gmail.com> Nope, no real reason... was just how I wrote the code. Coming from Java, I'm used to creating an object and then calling the setters, the hashed attributes thing looks ugly to me. :) How exactly would I test that if I wanted to set an expectation on :new? Seems fragile to specify the exact Hash of attributes I'm expecting. Maybe ActiveRecord calls the :member= etc methods internally? -james > I don't have a solution for you using mocks - but I wonder why you're > not just doing this: > > Receipt.new(:member => member, :payment_method => payment_method, > :amount_paid_cents => amount_paid_cents) > > Any reason? > > > > > Thanks. > > > > -james > > > > On 4/20/07, David Chelimsky wrote: > > > On 4/20/07, James Hillyerd wrote: > > > > Ok, I followed the advice of the list and moved more code into my > > > > model from my controller. When developing tests for this new code, I > > > > ran into a problem... > > > > > > > > My model code creates a receipt object and sets some values on it: > > > > > > > > @receipt = Receipt.new do |r| > > > > r.x = 1 > > > > r.y = 2 > > > > # etc > > > > end > > > > > > > > I wanted to be able to stub out Receipt.new so that I could set > > > > expectations on the methods called on the resulting Receipt object. > > > > If in my test setup I do: > > > > > > > > @receipt = mock_receipt > > > > Receipt.stub!(:new).and_return(@receipt) > > > > > > > > The block part of the code will never be called. If I do: > > > > > > > > Receipt.stub!(:new).and_yield(@receipt) > > > > > > > > Then @receipt in my model will be set to the return value of the block. > > > > > > > > I also tried something along the lines of: > > > > > > > > Receipt.stub!(:new) do > > > > yield @receipt > > > > @receipt > > > > end > > > > > > > > but got some weird no block error. > > > > > > > > Help? Am I going about this all wrong? > > > > > > Any reason you don't just query a real receipt object? > > > > > > describe Person do > > > it "should create an initialized person" do > > > Person.create_initialized("Michael").name.should == "Michael" > > > end > > > end > > > > > > class Person > > > class << self > > > def create_initialized(name) > > > Person.new do |p| > > > p.name = name > > > end > > > end > > > end > > > end > > > > > > What you're trying to mock here doesn't seem to buy you much. Unless > > > I'm missing something. > > > > > > > > > > > -james > > > > > > > > -- > > > > James A. Hillyerd > > > > Chief Technical Officer - ActiveRain Corp > > > > _______________________________________________ > > > > 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 > > > > > > > > > -- > > James A. Hillyerd > > Chief Technical Officer - ActiveRain Corp > > _______________________________________________ > > 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 > -- James A. Hillyerd Chief Technical Officer - ActiveRain Corp From dchelimsky at gmail.com Fri Apr 20 20:16:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Apr 2007 19:16:33 -0500 Subject: [rspec-users] Stubbing Model.new w/ block? In-Reply-To: <254841be0704201636s799838a3t8c54bb8e521cd26@mail.gmail.com> References: <254841be0704201448g79fa0813l945ed2373c721c49@mail.gmail.com> <57c63afe0704201549h584a7253n3adca7c4f38471ff@mail.gmail.com> <254841be0704201611j616da6b1wea2d5702941b49db@mail.gmail.com> <57c63afe0704201622i6b0ce73di28e9550c540be332@mail.gmail.com> <254841be0704201636s799838a3t8c54bb8e521cd26@mail.gmail.com> Message-ID: <57c63afe0704201716o5aa2307p5d51717350fb45d8@mail.gmail.com> On 4/20/07, James Hillyerd wrote: > Nope, no real reason... was just how I wrote the code. Coming from > Java, I'm used to creating an object and then calling the setters, the > hashed attributes thing looks ugly to me. :) > > How exactly would I test that if I wanted to set an expectation on > :new? Seems fragile to specify the exact Hash of attributes I'm > expecting. Maybe ActiveRecord calls the :member= etc methods > internally? That's how I do this sort of thing: Model.should_receive(:new).with(:a => "b", :c => "d") Model.new(:a => "b", :c => "d") Works fine if *your* code calls .new. Cheers, David > > -james > > > I don't have a solution for you using mocks - but I wonder why you're > > not just doing this: > > > > Receipt.new(:member => member, :payment_method => payment_method, > > :amount_paid_cents => amount_paid_cents) > > > > Any reason? > > > > > > > > Thanks. > > > > > > -james > > > > > > On 4/20/07, David Chelimsky wrote: > > > > On 4/20/07, James Hillyerd wrote: > > > > > Ok, I followed the advice of the list and moved more code into my > > > > > model from my controller. When developing tests for this new code, I > > > > > ran into a problem... > > > > > > > > > > My model code creates a receipt object and sets some values on it: > > > > > > > > > > @receipt = Receipt.new do |r| > > > > > r.x = 1 > > > > > r.y = 2 > > > > > # etc > > > > > end > > > > > > > > > > I wanted to be able to stub out Receipt.new so that I could set > > > > > expectations on the methods called on the resulting Receipt object. > > > > > If in my test setup I do: > > > > > > > > > > @receipt = mock_receipt > > > > > Receipt.stub!(:new).and_return(@receipt) > > > > > > > > > > The block part of the code will never be called. If I do: > > > > > > > > > > Receipt.stub!(:new).and_yield(@receipt) > > > > > > > > > > Then @receipt in my model will be set to the return value of the block. > > > > > > > > > > I also tried something along the lines of: > > > > > > > > > > Receipt.stub!(:new) do > > > > > yield @receipt > > > > > @receipt > > > > > end > > > > > > > > > > but got some weird no block error. > > > > > > > > > > Help? Am I going about this all wrong? > > > > > > > > Any reason you don't just query a real receipt object? > > > > > > > > describe Person do > > > > it "should create an initialized person" do > > > > Person.create_initialized("Michael").name.should == "Michael" > > > > end > > > > end > > > > > > > > class Person > > > > class << self > > > > def create_initialized(name) > > > > Person.new do |p| > > > > p.name = name > > > > end > > > > end > > > > end > > > > end > > > > > > > > What you're trying to mock here doesn't seem to buy you much. Unless > > > > I'm missing something. > > > > > > > > > > > > > > -james > > > > > > > > > > -- > > > > > James A. Hillyerd > > > > > Chief Technical Officer - ActiveRain Corp > > > > > _______________________________________________ > > > > > 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 > > > > > > > > > > > > > -- > > > James A. Hillyerd > > > Chief Technical Officer - ActiveRain Corp > > > _______________________________________________ > > > 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 > > > > > -- > James A. Hillyerd > Chief Technical Officer - ActiveRain Corp > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Apr 24 17:06:13 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 24 Apr 2007 23:06:13 +0200 Subject: [rspec-users] Command line changes on trunk (0.9 beta) Message-ID: <8d961d900704241406m32c2924mfc581010243159b9@mail.gmail.com> I just removed two command line options: --out and --failure. --failure is replaced by --format failing_examples:file.txt --out is replaced simply by your OS' > - or you can use --format html:path/to/file.html Finally - you can use several --format options so you can get both green dots in the console, html to a file and whatever else you might want. Enjoy, Aslak From jeff at jefdean.com Wed Apr 25 03:16:43 2007 From: jeff at jefdean.com (Jeff Dean) Date: Wed, 25 Apr 2007 03:16:43 -0400 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object Message-ID: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> I'm trying to write specs for a plugin I'm developing named audit_fu, and I'm running into a problem which I can't get past it. I've got the same specs setup in the main rails app, and everything works fine there, it's just running the plugin specs that I'm having a problem with. My setup is: - edge rails - edge rspec (in vendor/plugins/rspec) - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) - I ran script/generate rspec - plugin created with rspec_plugin (using script/generate rspec_plugin audit_fu) File contents of: vendor/plugins/audit_fu/spec/audit_fu_spec.rb require File.dirname(__FILE__) + '/spec_helper' define "Widget" do fixtures :widgets it "should find all records" do Widget.count.should==4 end end File contents of: vendor/plugins/audit_fu/spec/spec_helper.rb require File.dirname(__FILE__) + '/../../../../spec/spec_helper' plugin_spec_dir = File.dirname(__FILE__) ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log") databases = YAML::load(IO.read(plugin_spec_dir + "/db/database.yml")) ActiveRecord::Base.establish_connection(databases[ENV["DB"] || "sqlite3"]) load(File.join(plugin_spec_dir, "db", "schema.rb")) The failing command: ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec/audit_fu_spec.rb -- create_table(:widgets, {:force=>true}) -> 0.0553s -- create_table(:gears, {:force=>true}) -> 0.0073s -- initialize_schema_information() -> 0.0006s -- columns("schema_info") -> 0.0005s ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: undefined method `define' for # (NoMethodError) from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in `load' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in `load_specs' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in `each' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in `load_specs' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in `run' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in `run' from vendor/plugins/rspec/bin/spec:3 If I change define/it to context/specify, it gets a little further, but blows up when it hits the fixtures definition: ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec/audit_fu_spec.rb -- create_table(:widgets, {:force=>true}) -> 0.0407s -- create_table(:gears, {:force=>true}) -> 0.0074s -- initialize_schema_information() -> 0.0005s -- columns("schema_info") -> 0.0005s /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in `method_missing': undefined method `fixtures' for # (NoMethodError) from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in `class_eval' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in `initialize' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in `new' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in `create' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in `context' from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in `load' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in `load_specs' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in `each' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in `load_specs' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in `run' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in `run' from vendor/plugins/rspec/bin/spec:3 I think I'm missing an include or require somewhere - can anyone see what I'm missing or what I've done wrong? Thanks for your help - Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070425/1fc7e610/attachment-0001.html From aslak.hellesoy at gmail.com Wed Apr 25 04:34:08 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 25 Apr 2007 10:34:08 +0200 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> Message-ID: <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> It's describe, not define. Aslak On 4/25/07, Jeff Dean wrote: > I'm trying to write specs for a plugin I'm developing named audit_fu, and > I'm running into a problem which I can't get past it. I've got the same > specs setup in the main rails app, and everything works fine there, it's > just running the plugin specs that I'm having a problem with. My setup is: > > - edge rails > - edge rspec (in vendor/plugins/rspec) > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > - I ran script/generate rspec > - plugin created with rspec_plugin (using script/generate rspec_plugin > audit_fu) > > File contents of: vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > require File.dirname(__FILE__) + '/spec_helper' > define "Widget" do > fixtures :widgets > it "should find all records" do > Widget.count.should==4 > end > end > > File contents of: vendor/plugins/audit_fu/spec/spec_helper.rb > > require File.dirname(__FILE__) + '/../../../../spec/spec_helper' > plugin_spec_dir = File.dirname(__FILE__) > ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log") > databases = YAML::load(IO.read(plugin_spec_dir + "/db/database.yml")) > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || "sqlite3"]) > load(File.join(plugin_spec_dir, "db", "schema.rb")) > > The failing command: > > ruby vendor/plugins/rspec/bin/spec > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > -- create_table(:widgets, {:force=>true}) > -> 0.0553s > -- create_table(:gears, {:force=>true}) > -> 0.0073s > -- initialize_schema_information() > -> 0.0006s > -- columns("schema_info") > -> 0.0005s > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: undefined method `define' > for # (NoMethodError) > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > `load' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > `load_specs' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > `each' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > `load_specs' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > `run' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > `run' > from vendor/plugins/rspec/bin/spec:3 > > If I change define/it to context/specify, it gets a little further, but > blows up when it hits the fixtures definition: > > ruby vendor/plugins/rspec/bin/spec > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > -- create_table(:widgets, {:force=>true}) > -> 0.0407s > -- create_table(:gears, {:force=>true}) > -> 0.0074s > -- initialize_schema_information() > -> 0.0005s > -- columns("schema_info") > -> 0.0005s > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > `method_missing': undefined method `fixtures' for > # (NoMethodError) > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > `class_eval' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > `initialize' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > `new' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > `create' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > `context' > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > `load' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > `load_specs' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > `each' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > `load_specs' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > `run' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > `run' > from vendor/plugins/rspec/bin/spec:3 > > I think I'm missing an include or require somewhere - can anyone see what > I'm missing or what I've done wrong? Thanks for your help - Jeff > From mlangenberg at gmail.com Wed Apr 25 06:05:01 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Wed, 25 Apr 2007 12:05:01 +0200 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> Message-ID: <27c0ac6d0704250305t52fffabbw26c96379d858781c@mail.gmail.com> Is it actually possible to run the specifications written for a plugin without having much hassle in setting up a rails application? The one thing holding me back writing specs for plugins (with generators) is the fact that I need to 1) make a change in my generated spec, 2) change the code to let the spec pass, 3) Change the generator so they generate the new spec / code, 4) Use the generator in a new rails application, 5) Run all specs. This is so much hassle that It's really tempting to just let the tests be. (which is ofcourse very wrong). On 4/25/07, aslak hellesoy wrote: > It's describe, not define. > > Aslak > > On 4/25/07, Jeff Dean wrote: > > I'm trying to write specs for a plugin I'm developing named audit_fu, and > > I'm running into a problem which I can't get past it. I've got the same > > specs setup in the main rails app, and everything works fine there, it's > > just running the plugin specs that I'm having a problem with. My setup is: > > > > - edge rails > > - edge rspec (in vendor/plugins/rspec) > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > - I ran script/generate rspec > > - plugin created with rspec_plugin (using script/generate rspec_plugin > > audit_fu) > > > > File contents of: vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > require File.dirname(__FILE__) + '/spec_helper' > > define "Widget" do > > fixtures :widgets > > it "should find all records" do > > Widget.count.should==4 > > end > > end > > > > File contents of: vendor/plugins/audit_fu/spec/spec_helper.rb > > > > require File.dirname(__FILE__) + '/../../../../spec/spec_helper' > > plugin_spec_dir = File.dirname(__FILE__) > > ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log") > > databases = YAML::load(IO.read(plugin_spec_dir + "/db/database.yml")) > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || "sqlite3"]) > > load(File.join(plugin_spec_dir, "db", "schema.rb")) > > > > The failing command: > > > > ruby vendor/plugins/rspec/bin/spec > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > -- create_table(:widgets, {:force=>true}) > > -> 0.0553s > > -- create_table(:gears, {:force=>true}) > > -> 0.0073s > > -- initialize_schema_information() > > -> 0.0006s > > -- columns("schema_info") > > -> 0.0005s > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: undefined method `define' > > for # (NoMethodError) > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load_specs' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `each' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `load_specs' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > `run' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > `run' > > from vendor/plugins/rspec/bin/spec:3 > > > > If I change define/it to context/specify, it gets a little further, but > > blows up when it hits the fixtures definition: > > > > ruby vendor/plugins/rspec/bin/spec > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > -- create_table(:widgets, {:force=>true}) > > -> 0.0407s > > -- create_table(:gears, {:force=>true}) > > -> 0.0074s > > -- initialize_schema_information() > > -> 0.0005s > > -- columns("schema_info") > > -> 0.0005s > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > `method_missing': undefined method `fixtures' for > > # (NoMethodError) > > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > `class_eval' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > `initialize' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > `new' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > `create' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > `context' > > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load_specs' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `each' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `load_specs' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > `run' > > from > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > `run' > > from vendor/plugins/rspec/bin/spec:3 > > > > I think I'm missing an include or require somewhere - can anyone see what > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Apr 25 06:50:04 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 25 Apr 2007 12:50:04 +0200 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <27c0ac6d0704250305t52fffabbw26c96379d858781c@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> <27c0ac6d0704250305t52fffabbw26c96379d858781c@mail.gmail.com> Message-ID: <8d961d900704250350m39544ecetedbbc9c27671ac33@mail.gmail.com> On 4/25/07, Matthijs Langenberg wrote: > Is it actually possible to run the specifications written for a plugin > without having much hassle in setting up a rails application? > It depends on how well decoupled your own code is from Rails. If you decouple it completely you don't need Rails. > The one thing holding me back writing specs for plugins (with > generators) is the fact that I need to 1) make a change in my > generated spec, 2) change the code to let the spec pass, 3) Change the > generator so they generate the new spec / code, 4) Use the generator > in a new rails application, 5) Run all specs. > > This is so much hassle that It's really tempting to just let the tests > be. (which is ofcourse very wrong). > If you're thinking specifically about writing specs for generators, then I agree this is hard. If you dig in the Spec::Rails code you can see how we did it for the rspec generator. P.S. Your post seems unrelated to the original post. Please create a new mail (instead of replying to an existing thread) unless your mail is relevant to the one you're replying to. Aslak > On 4/25/07, aslak hellesoy wrote: > > It's describe, not define. > > > > Aslak > > > > On 4/25/07, Jeff Dean wrote: > > > I'm trying to write specs for a plugin I'm developing named audit_fu, and > > > I'm running into a problem which I can't get past it. I've got the same > > > specs setup in the main rails app, and everything works fine there, it's > > > just running the plugin specs that I'm having a problem with. My setup is: > > > > > > - edge rails > > > - edge rspec (in vendor/plugins/rspec) > > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > > - I ran script/generate rspec > > > - plugin created with rspec_plugin (using script/generate rspec_plugin > > > audit_fu) > > > > > > File contents of: vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > require File.dirname(__FILE__) + '/spec_helper' > > > define "Widget" do > > > fixtures :widgets > > > it "should find all records" do > > > Widget.count.should==4 > > > end > > > end > > > > > > File contents of: vendor/plugins/audit_fu/spec/spec_helper.rb > > > > > > require File.dirname(__FILE__) + '/../../../../spec/spec_helper' > > > plugin_spec_dir = File.dirname(__FILE__) > > > ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log") > > > databases = YAML::load(IO.read(plugin_spec_dir + "/db/database.yml")) > > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || "sqlite3"]) > > > load(File.join(plugin_spec_dir, "db", "schema.rb")) > > > > > > The failing command: > > > > > > ruby vendor/plugins/rspec/bin/spec > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > -- create_table(:widgets, {:force=>true}) > > > -> 0.0553s > > > -- create_table(:gears, {:force=>true}) > > > -> 0.0073s > > > -- initialize_schema_information() > > > -> 0.0006s > > > -- columns("schema_info") > > > -> 0.0005s > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: undefined method `define' > > > for # (NoMethodError) > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load_specs' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `each' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `load_specs' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > `run' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > `run' > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > If I change define/it to context/specify, it gets a little further, but > > > blows up when it hits the fixtures definition: > > > > > > ruby vendor/plugins/rspec/bin/spec > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > -- create_table(:widgets, {:force=>true}) > > > -> 0.0407s > > > -- create_table(:gears, {:force=>true}) > > > -> 0.0074s > > > -- initialize_schema_information() > > > -> 0.0005s > > > -- columns("schema_info") > > > -> 0.0005s > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > `method_missing': undefined method `fixtures' for > > > # (NoMethodError) > > > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `class_eval' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `initialize' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `new' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `create' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > `context' > > > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load_specs' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `each' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `load_specs' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > `run' > > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > `run' > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > I think I'm missing an include or require somewhere - can anyone see what > > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > > > _______________________________________________ > > 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 Wed Apr 25 11:24:50 2007 From: jeff at jefdean.com (Jeff Dean) Date: Wed, 25 Apr 2007 11:24:50 -0400 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> Message-ID: <6586e070704250824i5719f139gf738f7acd37602b0@mail.gmail.com> Thanks - I'll check my code more thoroughly next time before posting. It still blows up with the fixtures declaration, though (even when using context/specify) - am I missing an include file? ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec/audit_fu_spec.rb /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in `method_missing': undefined method `fixtures' for # (NoMethodError) from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in `class_eval' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in `initialize' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in `new' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in `create' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in `context' from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in `load' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in `load_specs' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in `each' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in `load_specs' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in `run' from /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in `run' from vendor/plugins/rspec/bin/spec:3 On 4/25/07, aslak hellesoy wrote: > > It's describe, not define. > > Aslak > > On 4/25/07, Jeff Dean wrote: > > I'm trying to write specs for a plugin I'm developing named audit_fu, > and > > I'm running into a problem which I can't get past it. I've got the > same > > specs setup in the main rails app, and everything works fine there, it's > > just running the plugin specs that I'm having a problem with. My setup > is: > > > > - edge rails > > - edge rspec (in vendor/plugins/rspec) > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > - I ran script/generate rspec > > - plugin created with rspec_plugin (using script/generate > rspec_plugin > > audit_fu) > > > > File contents of: vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > require File.dirname(__FILE__) + '/spec_helper' > > define "Widget" do > > fixtures :widgets > > it "should find all records" do > > Widget.count.should==4 > > end > > end > > > > File contents of: vendor/plugins/audit_fu/spec/spec_helper.rb > > > > require File.dirname(__FILE__) + '/../../../../spec/spec_helper' > > plugin_spec_dir = File.dirname(__FILE__) > > ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log") > > databases = YAML::load(IO.read(plugin_spec_dir + "/db/database.yml")) > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || > "sqlite3"]) > > load(File.join(plugin_spec_dir, "db", "schema.rb")) > > > > The failing command: > > > > ruby vendor/plugins/rspec/bin/spec > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > -- create_table(:widgets, {:force=>true}) > > -> 0.0553s > > -- create_table(:gears, {:force=>true}) > > -> 0.0073s > > -- initialize_schema_information() > > -> 0.0006s > > -- columns("schema_info") > > -> 0.0005s > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: undefined method > `define' > > for # (NoMethodError) > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load_specs' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `each' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `load_specs' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > `run' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > `run' > > from vendor/plugins/rspec/bin/spec:3 > > > > If I change define/it to context/specify, it gets a little further, but > > blows up when it hits the fixtures definition: > > > > ruby vendor/plugins/rspec/bin/spec > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > -- create_table(:widgets, {:force=>true}) > > -> 0.0407s > > -- create_table(:gears, {:force=>true}) > > -> 0.0074s > > -- initialize_schema_information() > > -> 0.0005s > > -- columns("schema_info") > > -> 0.0005s > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > `method_missing': undefined method `fixtures' for > > # (NoMethodError) > > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > `class_eval' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > `initialize' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > `new' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > `create' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > `context' > > from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load_specs' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `each' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `load_specs' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > `run' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > `run' > > from vendor/plugins/rspec/bin/spec:3 > > > > I think I'm missing an include or require somewhere - can anyone see > what > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > _______________________________________________ > 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/20070425/2892a16d/attachment-0001.html From aslak.hellesoy at gmail.com Wed Apr 25 17:06:04 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 25 Apr 2007 23:06:04 +0200 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <6586e070704250824i5719f139gf738f7acd37602b0@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> <6586e070704250824i5719f139gf738f7acd37602b0@mail.gmail.com> Message-ID: <8d961d900704251406n1f550a75h8fcff1cb06ab0c68@mail.gmail.com> I don't know if this is the source of your problem - I haven't investigated it, but I see that your spec is not in a sub folder (spec/models, spec/controllers etc.) what happens if you move your spec down to say, spec/models (and adjust your require to spec_helper.rb - does it still behave the same? A second thing - have you run ruby script/generate rspec lately? There might be some recent changes in the generated spec_helper.rb that your current copy (which was generated - perhaps a while ago) is out of date with. Aslak On 4/25/07, Jeff Dean wrote: > Thanks - I'll check my code more thoroughly next time before posting. > > It still blows up with the fixtures declaration, though (even when using > context/specify) - am I missing an include file? > > ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec > /audit_fu_spec.rb > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > `method_missing': undefined method `fixtures' for > # (NoMethodError) > from > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > `class_eval' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > `initialize' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > `new' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > `create' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > `context' > from > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > `load' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > `load_specs' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > `each' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > `load_specs' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > `run' > from > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > `run' > from vendor/plugins/rspec/bin/spec:3 > > On 4/25/07, aslak hellesoy wrote: > > > > It's describe, not define. > > > > Aslak > > > > On 4/25/07, Jeff Dean wrote: > > > I'm trying to write specs for a plugin I'm developing named audit_fu, > and > > > I'm running into a problem which I can't get past it. I've got the > same > > > specs setup in the main rails app, and everything works fine there, it's > > > just running the plugin specs that I'm having a problem with. My setup > is: > > > > > > - edge rails > > > - edge rspec (in vendor/plugins/rspec) > > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > > - I ran script/generate rspec > > > - plugin created with rspec_plugin (using script/generate > rspec_plugin > > > audit_fu) > > > > > > File contents of: > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > require File.dirname(__FILE__) + '/spec_helper' > > > define "Widget" do > > > fixtures :widgets > > > it "should find all records" do > > > Widget.count.should==4 > > > end > > > end > > > > > > File contents of: > vendor/plugins/audit_fu/spec/spec_helper.rb > > > > > > require File.dirname (__FILE__) + '/../../../../spec/spec_helper' > > > plugin_spec_dir = File.dirname(__FILE__) > > > ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log") > > > databases = YAML::load( IO.read(plugin_spec_dir + "/db/database.yml")) > > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || > "sqlite3"]) > > > load(File.join(plugin_spec_dir, "db", " schema.rb")) > > > > > > The failing command: > > > > > > ruby vendor/plugins/rspec/bin/spec > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > -- create_table(:widgets, {:force=>true}) > > > -> 0.0553s > > > -- create_table(:gears, {:force=>true}) > > > -> 0.0073s > > > -- initialize_schema_information() > > > -> 0.0006s > > > -- columns("schema_info") > > > -> 0.0005s > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: > undefined method `define' > > > for # (NoMethodError) > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `each' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > `run' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > `run' > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > If I change define/it to context/specify, it gets a little further, but > > > blows up when it hits the fixtures definition: > > > > > > ruby vendor/plugins/rspec/bin/spec > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > -- create_table(:widgets, {:force=>true}) > > > -> 0.0407s > > > -- create_table(:gears, {:force=>true}) > > > -> 0.0074s > > > -- initialize_schema_information() > > > -> 0.0005s > > > -- columns("schema_info") > > > -> 0.0005s > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > `method_missing': undefined method `fixtures' for > > > # (NoMethodError) > > > from > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `class_eval' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `initialize' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `new' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `create' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > `context' > > > from > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `each' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > `run' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > `run' > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > I think I'm missing an include or require somewhere - can anyone see > what > > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > > > _______________________________________________ > > 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 Wed Apr 25 21:20:44 2007 From: jeff at jefdean.com (Jeff Dean) Date: Wed, 25 Apr 2007 21:20:44 -0400 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <8d961d900704251406n1f550a75h8fcff1cb06ab0c68@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> <6586e070704250824i5719f139gf738f7acd37602b0@mail.gmail.com> <8d961d900704251406n1f550a75h8fcff1cb06ab0c68@mail.gmail.com> Message-ID: <6586e070704251820k17113fd3n234b111df4ddb48@mail.gmail.com> aslak - you rock. I put the spec in a models directory and it worked like a charm. Thanks again. On 4/25/07, aslak hellesoy wrote: > > I don't know if this is the source of your problem - I haven't > investigated it, but I see that your spec is not in a sub folder > (spec/models, spec/controllers etc.) > > what happens if you move your spec down to say, spec/models (and > adjust your require to spec_helper.rb - does it still behave the same? > > A second thing - have you run ruby script/generate rspec lately? There > might be some recent changes in the generated spec_helper.rb that your > current copy (which was generated - perhaps a while ago) is out of > date with. > > Aslak > > On 4/25/07, Jeff Dean wrote: > > Thanks - I'll check my code more thoroughly next time before posting. > > > > It still blows up with the fixtures declaration, though (even when using > > context/specify) - am I missing an include file? > > > > ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec > > /audit_fu_spec.rb > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > `method_missing': undefined method `fixtures' for > > # (NoMethodError) > > from > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > `class_eval' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > `initialize' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > `new' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > `create' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > `context' > > from > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > `load_specs' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `each' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > `load_specs' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > `run' > > from > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > `run' > > from vendor/plugins/rspec/bin/spec:3 > > > > On 4/25/07, aslak hellesoy wrote: > > > > > > It's describe, not define. > > > > > > Aslak > > > > > > On 4/25/07, Jeff Dean wrote: > > > > I'm trying to write specs for a plugin I'm developing named > audit_fu, > > and > > > > I'm running into a problem which I can't get past it. I've got the > > same > > > > specs setup in the main rails app, and everything works fine there, > it's > > > > just running the plugin specs that I'm having a problem with. My > setup > > is: > > > > > > > > - edge rails > > > > - edge rspec (in vendor/plugins/rspec) > > > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > > > - I ran script/generate rspec > > > > - plugin created with rspec_plugin (using script/generate > > rspec_plugin > > > > audit_fu) > > > > > > > > File contents of: > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > > > require File.dirname(__FILE__) + '/spec_helper' > > > > define "Widget" do > > > > fixtures :widgets > > > > it "should find all records" do > > > > Widget.count.should==4 > > > > end > > > > end > > > > > > > > File contents of: > > vendor/plugins/audit_fu/spec/spec_helper.rb > > > > > > > > require File.dirname (__FILE__) + '/../../../../spec/spec_helper' > > > > plugin_spec_dir = File.dirname(__FILE__) > > > > ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + > "/debug.log") > > > > databases = YAML::load( IO.read(plugin_spec_dir + > "/db/database.yml")) > > > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || > > "sqlite3"]) > > > > load(File.join(plugin_spec_dir, "db", " schema.rb")) > > > > > > > > The failing command: > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > -- create_table(:widgets, {:force=>true}) > > > > -> 0.0553s > > > > -- create_table(:gears, {:force=>true}) > > > > -> 0.0073s > > > > -- initialize_schema_information() > > > > -> 0.0006s > > > > -- columns("schema_info") > > > > -> 0.0005s > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: > > undefined method `define' > > > > for # (NoMethodError) > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > `load' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > `load_specs' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > `each' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > `load_specs' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > `run' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > `run' > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > If I change define/it to context/specify, it gets a little further, > but > > > > blows up when it hits the fixtures definition: > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > -- create_table(:widgets, {:force=>true}) > > > > -> 0.0407s > > > > -- create_table(:gears, {:force=>true}) > > > > -> 0.0074s > > > > -- initialize_schema_information() > > > > -> 0.0005s > > > > -- columns("schema_info") > > > > -> 0.0005s > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > > `method_missing': undefined method `fixtures' for > > > > # (NoMethodError) > > > > from > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > `class_eval' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > `initialize' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > `new' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > `create' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > > `context' > > > > from > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > `load' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > `load_specs' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > `each' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > `load_specs' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > `run' > > > > from > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > `run' > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > I think I'm missing an include or require somewhere - can anyone see > > what > > > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > > > > > _______________________________________________ > > > 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/20070425/2a176520/attachment-0001.html From dchelimsky at gmail.com Wed Apr 25 22:16:40 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 25 Apr 2007 22:16:40 -0400 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <6586e070704251820k17113fd3n234b111df4ddb48@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> <6586e070704250824i5719f139gf738f7acd37602b0@mail.gmail.com> <8d961d900704251406n1f550a75h8fcff1cb06ab0c68@mail.gmail.com> <6586e070704251820k17113fd3n234b111df4ddb48@mail.gmail.com> Message-ID: <57c63afe0704251916n2ea6ec66h8457dc38c07fb4a9@mail.gmail.com> On 4/25/07, Jeff Dean wrote: > aslak - you rock. > > I put the spec in a models directory and it worked like a charm. Thanks > again. You could also do this (as of rev 1810): describe MyPlugin, :rails_component_type => :model do ... end Then you can put it in any directory at all. Cheers, David > On 4/25/07, aslak hellesoy < aslak.hellesoy at gmail.com> wrote: > > I don't know if this is the source of your problem - I haven't > > investigated it, but I see that your spec is not in a sub folder > > (spec/models, spec/controllers etc.) > > > > what happens if you move your spec down to say, spec/models (and > > adjust your require to spec_helper.rb - does it still behave the same? > > > > A second thing - have you run ruby script/generate rspec lately? There > > might be some recent changes in the generated spec_helper.rb that your > > current copy (which was generated - perhaps a while ago) is out of > > date with. > > > > Aslak > > > > On 4/25/07, Jeff Dean wrote: > > > Thanks - I'll check my code more thoroughly next time before posting. > > > > > > It still blows up with the fixtures declaration, though (even when using > > > context/specify) - am I missing an include file? > > > > > > ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec > > > /audit_fu_spec.rb > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > `method_missing': undefined method `fixtures' for > > > # (NoMethodError) > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `class_eval' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `initialize' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `new' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `create' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > `context' > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `each' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > `run' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > `run' > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > On 4/25/07, aslak hellesoy wrote: > > > > > > > > It's describe, not define. > > > > > > > > Aslak > > > > > > > > On 4/25/07, Jeff Dean wrote: > > > > > I'm trying to write specs for a plugin I'm developing named > audit_fu, > > > and > > > > > I'm running into a problem which I can't get past it. I've got the > > > same > > > > > specs setup in the main rails app, and everything works fine there, > it's > > > > > just running the plugin specs that I'm having a problem with. My > setup > > > is: > > > > > > > > > > - edge rails > > > > > - edge rspec (in vendor/plugins/rspec) > > > > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > > > > - I ran script/generate rspec > > > > > - plugin created with rspec_plugin (using script/generate > > > rspec_plugin > > > > > audit_fu) > > > > > > > > > > File contents of: > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > > > > > require File.dirname(__FILE__) + '/spec_helper' > > > > > define "Widget" do > > > > > fixtures :widgets > > > > > it "should find all records" do > > > > > Widget.count.should==4 > > > > > end > > > > > end > > > > > > > > > > File contents of: > > > vendor/plugins/audit_fu/spec/spec_helper.rb > > > > > > > > > > require File.dirname (__FILE__) + '/../../../../spec/spec_helper' > > > > > plugin_spec_dir = File.dirname(__FILE__) > > > > > ActiveRecord::Base.logger = Logger.new (plugin_spec_dir + > "/debug.log") > > > > > databases = YAML::load( IO.read(plugin_spec_dir + > "/db/database.yml")) > > > > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || > > > "sqlite3"]) > > > > > load(File.join(plugin_spec_dir, "db", " schema.rb")) > > > > > > > > > > The failing command: > > > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > -- create_table(:widgets, {:force=>true}) > > > > > -> 0.0553s > > > > > -- create_table(:gears, {:force=>true}) > > > > > -> 0.0073s > > > > > -- initialize_schema_information() > > > > > -> 0.0006s > > > > > -- columns("schema_info") > > > > > -> 0.0005s > > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: > > > undefined method `define' > > > > > for # (NoMethodError) > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `each' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > > `run' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > `run' > > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > > > If I change define/it to context/specify, it gets a little further, > but > > > > > blows up when it hits the fixtures definition: > > > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > -- create_table(:widgets, {:force=>true}) > > > > > -> 0.0407s > > > > > -- create_table(:gears, {:force=>true}) > > > > > -> 0.0074s > > > > > -- initialize_schema_information() > > > > > -> 0.0005s > > > > > -- columns("schema_info") > > > > > -> 0.0005s > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > > > `method_missing': undefined method `fixtures' for > > > > > # (NoMethodError) > > > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > > `class_eval' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > > `initialize' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > > `new' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > > `create' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > > > `context' > > > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `each' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > > `run' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > `run' > > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > > > I think I'm missing an include or require somewhere - can anyone see > > > what > > > > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > > > > > > > _______________________________________________ > > > > 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 Thu Apr 26 01:32:23 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 26 Apr 2007 07:32:23 +0200 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <6586e070704251820k17113fd3n234b111df4ddb48@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> <6586e070704250824i5719f139gf738f7acd37602b0@mail.gmail.com> <8d961d900704251406n1f550a75h8fcff1cb06ab0c68@mail.gmail.com> <6586e070704251820k17113fd3n234b111df4ddb48@mail.gmail.com> Message-ID: <8d961d900704252232h524f95at7419e3d42f9272ab@mail.gmail.com> On 4/26/07, Jeff Dean wrote: > aslak - you rock. > Oh please ;-) > I put the spec in a models directory and it worked like a charm. Thanks > again. > David, why does it have to be in a sub dir? Is that what triggers the weaving in of the fixtures etc. methods? Is there a simple way to make fixtures work even if a spec is not in a sub dir? Aslak > > On 4/25/07, aslak hellesoy < aslak.hellesoy at gmail.com> wrote: > > I don't know if this is the source of your problem - I haven't > > investigated it, but I see that your spec is not in a sub folder > > (spec/models, spec/controllers etc.) > > > > what happens if you move your spec down to say, spec/models (and > > adjust your require to spec_helper.rb - does it still behave the same? > > > > A second thing - have you run ruby script/generate rspec lately? There > > might be some recent changes in the generated spec_helper.rb that your > > current copy (which was generated - perhaps a while ago) is out of > > date with. > > > > Aslak > > > > On 4/25/07, Jeff Dean wrote: > > > Thanks - I'll check my code more thoroughly next time before posting. > > > > > > It still blows up with the fixtures declaration, though (even when using > > > context/specify) - am I missing an include file? > > > > > > ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec > > > /audit_fu_spec.rb > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > `method_missing': undefined method `fixtures' for > > > # (NoMethodError) > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `class_eval' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > `initialize' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `new' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > `create' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > `context' > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `each' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > `load_specs' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > `run' > > > from > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > `run' > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > On 4/25/07, aslak hellesoy wrote: > > > > > > > > It's describe, not define. > > > > > > > > Aslak > > > > > > > > On 4/25/07, Jeff Dean wrote: > > > > > I'm trying to write specs for a plugin I'm developing named > audit_fu, > > > and > > > > > I'm running into a problem which I can't get past it. I've got the > > > same > > > > > specs setup in the main rails app, and everything works fine there, > it's > > > > > just running the plugin specs that I'm having a problem with. My > setup > > > is: > > > > > > > > > > - edge rails > > > > > - edge rspec (in vendor/plugins/rspec) > > > > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > > > > - I ran script/generate rspec > > > > > - plugin created with rspec_plugin (using script/generate > > > rspec_plugin > > > > > audit_fu) > > > > > > > > > > File contents of: > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > > > > > require File.dirname(__FILE__) + '/spec_helper' > > > > > define "Widget" do > > > > > fixtures :widgets > > > > > it "should find all records" do > > > > > Widget.count.should==4 > > > > > end > > > > > end > > > > > > > > > > File contents of: > > > vendor/plugins/audit_fu/spec/spec_helper.rb > > > > > > > > > > require File.dirname (__FILE__) + '/../../../../spec/spec_helper' > > > > > plugin_spec_dir = File.dirname(__FILE__) > > > > > ActiveRecord::Base.logger = Logger.new (plugin_spec_dir + > "/debug.log") > > > > > databases = YAML::load( IO.read(plugin_spec_dir + > "/db/database.yml")) > > > > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || > > > "sqlite3"]) > > > > > load(File.join(plugin_spec_dir, "db", " schema.rb")) > > > > > > > > > > The failing command: > > > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > -- create_table(:widgets, {:force=>true}) > > > > > -> 0.0553s > > > > > -- create_table(:gears, {:force=>true}) > > > > > -> 0.0073s > > > > > -- initialize_schema_information() > > > > > -> 0.0006s > > > > > -- columns("schema_info") > > > > > -> 0.0005s > > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: > > > undefined method `define' > > > > > for # (NoMethodError) > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `each' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > > `run' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > `run' > > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > > > If I change define/it to context/specify, it gets a little further, > but > > > > > blows up when it hits the fixtures definition: > > > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > -- create_table(:widgets, {:force=>true}) > > > > > -> 0.0407s > > > > > -- create_table(:gears, {:force=>true}) > > > > > -> 0.0074s > > > > > -- initialize_schema_information() > > > > > -> 0.0005s > > > > > -- columns("schema_info") > > > > > -> 0.0005s > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > > > `method_missing': undefined method `fixtures' for > > > > > # (NoMethodError) > > > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > > `class_eval' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > > `initialize' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > > `new' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > > `create' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > > > `context' > > > > > from > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `each' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > `load_specs' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > > `run' > > > > > from > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > `run' > > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > > > I think I'm missing an include or require somewhere - can anyone see > > > what > > > > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > > > > > > > _______________________________________________ > > > > 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 Thu Apr 26 06:38:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 26 Apr 2007 06:38:05 -0400 Subject: [rspec-users] Running specs for a plugin - undefined method 'define' for object In-Reply-To: <8d961d900704252232h524f95at7419e3d42f9272ab@mail.gmail.com> References: <6586e070704250016p76cae14bn104f8686dfd47d31@mail.gmail.com> <8d961d900704250134y7ce81ecevba93dd93c3a7230c@mail.gmail.com> <6586e070704250824i5719f139gf738f7acd37602b0@mail.gmail.com> <8d961d900704251406n1f550a75h8fcff1cb06ab0c68@mail.gmail.com> <6586e070704251820k17113fd3n234b111df4ddb48@mail.gmail.com> <8d961d900704252232h524f95at7419e3d42f9272ab@mail.gmail.com> Message-ID: <57c63afe0704260338i29dc2f2apa68be9181a1ae867@mail.gmail.com> On 4/26/07, aslak hellesoy wrote: > On 4/26/07, Jeff Dean wrote: > > aslak - you rock. > > > > Oh please ;-) > > > I put the spec in a models directory and it worked like a charm. Thanks > > again. > > > > David, why does it have to be in a sub dir? Is that what triggers the > weaving in of the fixtures etc. methods? Is there a simple way to make > fixtures work even if a spec is not in a sub dir? Our email must be overlapping somehow. I followed yours up w/ an explanation of that 4 hours before this one was sent. Anyhow - yes, there is. You can do this: describe MyPlugin, :rails_component_type => :model do ... end Take a look at behaviour_factory.rb (in Spec::Rails). > > Aslak > > > > > On 4/25/07, aslak hellesoy < aslak.hellesoy at gmail.com> wrote: > > > I don't know if this is the source of your problem - I haven't > > > investigated it, but I see that your spec is not in a sub folder > > > (spec/models, spec/controllers etc.) > > > > > > what happens if you move your spec down to say, spec/models (and > > > adjust your require to spec_helper.rb - does it still behave the same? > > > > > > A second thing - have you run ruby script/generate rspec lately? There > > > might be some recent changes in the generated spec_helper.rb that your > > > current copy (which was generated - perhaps a while ago) is out of > > > date with. > > > > > > Aslak > > > > > > On 4/25/07, Jeff Dean wrote: > > > > Thanks - I'll check my code more thoroughly next time before posting. > > > > > > > > It still blows up with the fixtures declaration, though (even when using > > > > context/specify) - am I missing an include file? > > > > > > > > ruby vendor/plugins/rspec/bin/spec vendor/plugins/audit_fu/spec > > > > /audit_fu_spec.rb > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > > `method_missing': undefined method `fixtures' for > > > > # (NoMethodError) > > > > from > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > `class_eval' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > `initialize' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > `new' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > `create' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > > `context' > > > > from > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > `load' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > `load_specs' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > `each' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > `load_specs' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > `run' > > > > from > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > `run' > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > On 4/25/07, aslak hellesoy wrote: > > > > > > > > > > It's describe, not define. > > > > > > > > > > Aslak > > > > > > > > > > On 4/25/07, Jeff Dean wrote: > > > > > > I'm trying to write specs for a plugin I'm developing named > > audit_fu, > > > > and > > > > > > I'm running into a problem which I can't get past it. I've got the > > > > same > > > > > > specs setup in the main rails app, and everything works fine there, > > it's > > > > > > just running the plugin specs that I'm having a problem with. My > > setup > > > > is: > > > > > > > > > > > > - edge rails > > > > > > - edge rspec (in vendor/plugins/rspec) > > > > > > - edge rspec_on_rails (in vendor/plugins/rspec_on_rails) > > > > > > - I ran script/generate rspec > > > > > > - plugin created with rspec_plugin (using script/generate > > > > rspec_plugin > > > > > > audit_fu) > > > > > > > > > > > > File contents of: > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > > > > > > > require File.dirname(__FILE__) + '/spec_helper' > > > > > > define "Widget" do > > > > > > fixtures :widgets > > > > > > it "should find all records" do > > > > > > Widget.count.should==4 > > > > > > end > > > > > > end > > > > > > > > > > > > File contents of: > > > > vendor/plugins/audit_fu/spec/spec_helper.rb > > > > > > > > > > > > require File.dirname (__FILE__) + '/../../../../spec/spec_helper' > > > > > > plugin_spec_dir = File.dirname(__FILE__) > > > > > > ActiveRecord::Base.logger = Logger.new (plugin_spec_dir + > > "/debug.log") > > > > > > databases = YAML::load( IO.read(plugin_spec_dir + > > "/db/database.yml")) > > > > > > ActiveRecord::Base.establish_connection(databases[ENV["DB"] || > > > > "sqlite3"]) > > > > > > load(File.join(plugin_spec_dir, "db", " schema.rb")) > > > > > > > > > > > > The failing command: > > > > > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > -- create_table(:widgets, {:force=>true}) > > > > > > -> 0.0553s > > > > > > -- create_table(:gears, {:force=>true}) > > > > > > -> 0.0073s > > > > > > -- initialize_schema_information() > > > > > > -> 0.0006s > > > > > > -- columns("schema_info") > > > > > > -> 0.0005s > > > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: > > > > undefined method `define' > > > > > > for # (NoMethodError) > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > > `load' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > > `load_specs' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > > `each' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > > `load_specs' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > > > `run' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > > `run' > > > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > > > > > If I change define/it to context/specify, it gets a little further, > > but > > > > > > blows up when it hits the fixtures definition: > > > > > > > > > > > > ruby vendor/plugins/rspec/bin/spec > > > > > > vendor/plugins/audit_fu/spec/audit_fu_spec.rb > > > > > > -- create_table(:widgets, {:force=>true}) > > > > > > -> 0.0407s > > > > > > -- create_table(:gears, {:force=>true}) > > > > > > -> 0.0074s > > > > > > -- initialize_schema_information() > > > > > > -> 0.0005s > > > > > > -- columns("schema_info") > > > > > > -> 0.0005s > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in > > > > > > `method_missing': undefined method `fixtures' for > > > > > > # (NoMethodError) > > > > > > from > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4 > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > > > `class_eval' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in > > > > > > `initialize' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > > > `new' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in > > > > > > `create' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in > > > > > > `context' > > > > > > from > > > > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3 > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > > `load' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in > > > > > > `load_specs' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > > `each' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in > > > > > > `load_specs' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in > > > > > > `run' > > > > > > from > > > > > > > > > > > > /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in > > > > > > `run' > > > > > > from vendor/plugins/rspec/bin/spec:3 > > > > > > > > > > > > I think I'm missing an include or require somewhere - can anyone see > > > > what > > > > > > I'm missing or what I've done wrong? Thanks for your help - Jeff > > > > > > > > > > > _______________________________________________ > > > > > 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 tino.breddin at googlemail.com Fri Apr 27 05:58:23 2007 From: tino.breddin at googlemail.com (Tino Breddin) Date: Fri, 27 Apr 2007 11:58:23 +0200 Subject: [rspec-users] Problem at the start Message-ID: <4e80e3c10704270258m49c1a441k3262bb3213e0b2f2@mail.gmail.com> Hi, I'm new to rspec and wanted to translate some of my unit tests into rspecs. Unfortunately my first test fails with "Mysql not loaded". My application is running fine and can access the database. I'd appreciate any help, so I can get started. Tino -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070427/c831c3af/attachment.html From mlangenberg at gmail.com Fri Apr 27 06:53:23 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Fri, 27 Apr 2007 12:53:23 +0200 Subject: [rspec-users] Problem at the start In-Reply-To: <4e80e3c10704270258m49c1a441k3262bb3213e0b2f2@mail.gmail.com> References: <4e80e3c10704270258m49c1a441k3262bb3213e0b2f2@mail.gmail.com> Message-ID: <27c0ac6d0704270353j3945a2ecu10d3f8ee0095b115@mail.gmail.com> Did you define a specific test database in 'config/database.yml' ? On 4/27/07, Tino Breddin wrote: > Hi, > > I'm new to rspec and wanted to translate some of my unit tests into rspecs. > Unfortunately my first test fails with "Mysql not loaded". My application is > running fine and can access the database. > > I'd appreciate any help, so I can get started. > > Tino > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tino.breddin at googlemail.com Fri Apr 27 07:13:41 2007 From: tino.breddin at googlemail.com (Tino Breddin) Date: Fri, 27 Apr 2007 13:13:41 +0200 Subject: [rspec-users] Problem at the start In-Reply-To: <27c0ac6d0704270353j3945a2ecu10d3f8ee0095b115@mail.gmail.com> References: <4e80e3c10704270258m49c1a441k3262bb3213e0b2f2@mail.gmail.com> <27c0ac6d0704270353j3945a2ecu10d3f8ee0095b115@mail.gmail.com> Message-ID: <4e80e3c10704270413j2b936ea8g96434029f6fb7659@mail.gmail.com> Yes, the unit tests run fine with the test database. On 4/27/07, Matthijs Langenberg wrote: > > Did you define a specific test database in 'config/database.yml' ? > > On 4/27/07, Tino Breddin wrote: > > Hi, > > > > I'm new to rspec and wanted to translate some of my unit tests into > rspecs. > > Unfortunately my first test fails with "Mysql not loaded". My > application is > > running fine and can access the database. > > > > I'd appreciate any help, so I can get started. > > > > Tino > > > > _______________________________________________ > > 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/20070427/20af00d6/attachment.html From dchelimsky at gmail.com Fri Apr 27 08:14:25 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Apr 2007 08:14:25 -0400 Subject: [rspec-users] Problem at the start In-Reply-To: <4e80e3c10704270258m49c1a441k3262bb3213e0b2f2@mail.gmail.com> References: <4e80e3c10704270258m49c1a441k3262bb3213e0b2f2@mail.gmail.com> Message-ID: <57c63afe0704270514x2a500476o8da44da758011ce6@mail.gmail.com> On 4/27/07, Tino Breddin wrote: > Hi, > > I'm new to rspec and wanted to translate some of my unit tests into rspecs. > Unfortunately my first test fails with "Mysql not loaded". My application is > running fine and can access the database. > > I'd appreciate any help, so I can get started. What command are you typing? What's the full error? What versions of rspec and rails are you using? > > Tino > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bosshoff at gmail.com Fri Apr 27 09:31:25 2007 From: bosshoff at gmail.com (Chris Hoffman) Date: Fri, 27 Apr 2007 09:31:25 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> Message-ID: <359ebde50704270631h29c32fb8ieadca90b46416c1f@mail.gmail.com> Your's is a good question. I too have been looking for ways to DRY up my controller tests. The more I am starting to obey a CRUD-only design, the more duplication I am encountering in these specs. Right now, I am combating this dilemma by making a bunch of methods in spec_helper that define _context_ and _specify_ statements, such as: def specify_should_handle_an_invalid_id_nicely(params) controller = "#{params[:controller].camelize}Controller" model = params[:controller].classify.constantize params[:redirect_to] ||= { :action => 'index' } params[:actions] ||= [:edit, :update, :show, :destroy] params[:actions].to_a.each do |action| context "#{controller}##{action}, given an id" do controller_name params[:controller] specify "should call #{model}.find_by_id, instead of #{model}.find" do model.should_receive(:find_by_id).with("the id") send(:process, action, :id => "the id") end end context "#{controller}##{action}, not given a valid id" do controller_name params[:controller] setup do model.stub!(:find_by_id) end specify "should redirect_to #{params[:redirect_to]}" do send(:process, action) response.should_redirect_to params[:redirect_to] end specify "should populate the flash with a message indicating that the record wasn't found" do send(:process, action) flash[:notice].should == "#{model} not found" end end end end This approach is obviously clunky, and I would myself like a better way to specify controller-wide contracts, as it were. Just as above, any action that requires an id as a parameter should behave a certain way, and I shouldn't have to define this behavior in each controller's specification; it should be application-wide. -Chris On 4/11/07, nicholas a. evans wrote: > So, I've been following the recommendations for controller specs here: > http://blog.davidchelimsky.net/articles/2006/11/09/tutorial-rspec-stubs-and-mocks > > Most notably: a single expectation per specify block; the setup block > contains only stubs; mock expectations each get their own specify > block. (I'm still using 0.8, so I haven't gotten the describe/it > goodness yet.) > > I don't really mind the stub/mock duplication (between setup and the > specifications). What's annoying me is the action duplication. "get > 'create'" is called in each specify block, sometimes before the actual > specification, sometimes afterward, depending on whether it's a mock > expectation or a state expectation. > > So I played around with creating the following module and then > extending my context with it. > > module MockSpecHelpers > def expect_that_it(msg) > specify msg do > yield > action > end > end > def then_it(msg) > specify msg do > action > yield > end > end > end > > in the context block, I would then "def action do get 'create' end". > And I would replace the following specify blocks > > specify "should create a new person on GET to create" do > Person.should_receive(:new).and_return(@person) > get 'create' > end > > specify "should assign new person to template on GET to create" do > get 'create' > assigns[:person].should_be @person > end > > with > > expect_that_it "should create a new person on GET to create" do > Person.should_receive(:new).and_return(@person) > end > > then_it "should assign new person to template on GET to create" do > assigns[:person].should_be @person > end > > The problem is that my weak Ruby metaprogramming fu has completely > failed me. :-) I can't figure out how to get the block to be > evaluated in a context that has access to the appropriate context > methods (assigns, response, session, etc). I get errors like the > following: > > NameError in 'GET /controller/action/1234 should render the foobar template' > undefined local variable or method `response' for > # > > (Usually the "expect_that_it" blocks work fine, because they aren't > dependent on anything that is specific to their EvalContext.) > > Does someone know how I could get this working? > > I also thought about making an alias for setup called "given" and > instead of "action" it could be "when_action" to more closely follow > the "given/expect/when/then" pattern and naming conventions. > > Does this even look like a good idea, or is there a better way? Would > it make more sense to open the EvalContext rather than trying to > extend a module? > > -- > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 27 09:57:16 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Apr 2007 09:57:16 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <359ebde50704270631h29c32fb8ieadca90b46416c1f@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <359ebde50704270631h29c32fb8ieadca90b46416c1f@mail.gmail.com> Message-ID: <57c63afe0704270657of97664bk469b64b90eb43240@mail.gmail.com> On 4/27/07, Chris Hoffman wrote: > Your's is a good question. I too have been looking for ways to DRY up > my controller tests. The more I am starting to obey a CRUD-only > design, the more duplication I am encountering in these specs. Right > now, I am combating this dilemma by making a bunch of methods in > spec_helper that define _context_ and _specify_ statements, such as: > > def specify_should_handle_an_invalid_id_nicely(params) > controller = "#{params[:controller].camelize}Controller" > model = params[:controller].classify.constantize > params[:redirect_to] ||= { :action => 'index' } > params[:actions] ||= [:edit, :update, :show, :destroy] > > params[:actions].to_a.each do |action| > context "#{controller}##{action}, given an id" do > controller_name params[:controller] > > specify "should call #{model}.find_by_id, instead of #{model}.find" do > model.should_receive(:find_by_id).with("the id") > send(:process, action, :id => "the id") > end > end > > context "#{controller}##{action}, not given a valid id" do > controller_name params[:controller] > > setup do > model.stub!(:find_by_id) > end > > specify "should redirect_to #{params[:redirect_to]}" do > send(:process, action) > response.should_redirect_to params[:redirect_to] > end > > specify "should populate the flash with a message indicating > that the record wasn't found" do > send(:process, action) > flash[:notice].should == "#{model} not found" > end > end > end > end > > This approach is obviously clunky, and I would myself like a better > way to specify controller-wide contracts, as it were. Just as above, > any action that requires an id as a parameter should behave a certain > way, and I shouldn't have to define this behavior in each controller's > specification; it should be application-wide. Would http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9605&atid=3151 satisfy your needs? From chris.c.hoffman at gmail.com Fri Apr 27 10:18:08 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 27 Apr 2007 10:18:08 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <57c63afe0704270657of97664bk469b64b90eb43240@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <359ebde50704270631h29c32fb8ieadca90b46416c1f@mail.gmail.com> <57c63afe0704270657of97664bk469b64b90eb43240@mail.gmail.com> Message-ID: <63c5d3820704270718k3b82f2d6sfc4b855da5ea3de8@mail.gmail.com> That has some potential, indeed. Is there a URL you can point me to that will instruct me on how to install the HEAD of the RSpec repository? It looks like I require 0.9 to take advantage of this patch. Thanks. -Chris On 4/27/07, David Chelimsky wrote: > On 4/27/07, Chris Hoffman wrote: > > Your's is a good question. I too have been looking for ways to DRY up > > my controller tests. The more I am starting to obey a CRUD-only > > design, the more duplication I am encountering in these specs. Right > > now, I am combating this dilemma by making a bunch of methods in > > spec_helper that define _context_ and _specify_ statements, such as: > > > > def specify_should_handle_an_invalid_id_nicely(params) > > controller = "#{params[:controller].camelize}Controller" > > model = params[:controller].classify.constantize > > params[:redirect_to] ||= { :action => 'index' } > > params[:actions] ||= [:edit, :update, :show, :destroy] > > > > params[:actions].to_a.each do |action| > > context "#{controller}##{action}, given an id" do > > controller_name params[:controller] > > > > specify "should call #{model}.find_by_id, instead of #{model}.find" do > > model.should_receive(:find_by_id).with("the id") > > send(:process, action, :id => "the id") > > end > > end > > > > context "#{controller}##{action}, not given a valid id" do > > controller_name params[:controller] > > > > setup do > > model.stub!(:find_by_id) > > end > > > > specify "should redirect_to #{params[:redirect_to]}" do > > send(:process, action) > > response.should_redirect_to params[:redirect_to] > > end > > > > specify "should populate the flash with a message indicating > > that the record wasn't found" do > > send(:process, action) > > flash[:notice].should == "#{model} not found" > > end > > end > > end > > end > > > > This approach is obviously clunky, and I would myself like a better > > way to specify controller-wide contracts, as it were. Just as above, > > any action that requires an id as a parameter should behave a certain > > way, and I shouldn't have to define this behavior in each controller's > > specification; it should be application-wide. > > Would http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9605&atid=3151 > satisfy your needs? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 27 10:20:03 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Apr 2007 10:20:03 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> Message-ID: <57c63afe0704270720m7fe1895ah950f4d3d221e0324@mail.gmail.com> On 4/11/07, nicholas a. evans wrote: > So, I've been following the recommendations for controller specs here: > http://blog.davidchelimsky.net/articles/2006/11/09/tutorial-rspec-stubs-and-mocks > > Most notably: a single expectation per specify block; the setup block > contains only stubs; mock expectations each get their own specify > block. (I'm still using 0.8, so I haven't gotten the describe/it > goodness yet.) > > I don't really mind the stub/mock duplication (between setup and the > specifications). What's annoying me is the action duplication. "get > 'create'" is called in each specify block, sometimes before the actual > specification, sometimes afterward, depending on whether it's a mock > expectation or a state expectation. > > So I played around with creating the following module and then > extending my context with it. > > module MockSpecHelpers > def expect_that_it(msg) > specify msg do > yield > action > end > end > def then_it(msg) > specify msg do > action > yield > end > end > end > > in the context block, I would then "def action do get 'create' end". > And I would replace the following specify blocks > > specify "should create a new person on GET to create" do > Person.should_receive(:new).and_return(@person) > get 'create' > end > > specify "should assign new person to template on GET to create" do > get 'create' > assigns[:person].should_be @person > end > > with > > expect_that_it "should create a new person on GET to create" do > Person.should_receive(:new).and_return(@person) > end > > then_it "should assign new person to template on GET to create" do > assigns[:person].should_be @person > end I like the idea of binding the examples to some method that gets run before or after the example. There is a similar RFE already in the tracker http://rubyforge.org/tracker/?func=detail&group_id=797&aid=10285&atid=3152. The problem is coming up with the right language. It think expect_that_it and then_it would encourage one to write all of the expect_that_its first and the then_its last. It also seems to indicate a relationship between the examples, even though no such relationship exists. In the RFE I mentioned, I proposed something like ... it "should do something", during_event do That seems to work well, but its counterpart ... it "should leave some state", after_event do leaves me cold. It especially fails to align w/ your example "should assign new person to template on GET to create", which seems like a great way to express the behaviour, but followed by "after_event" doesn't really read correctly. Any other suggestions? In general, I'm much more inclined to favor an additional parameter passed to #it over a new method name. Cheers, David From dchelimsky at gmail.com Fri Apr 27 10:34:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Apr 2007 10:34:12 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <63c5d3820704270718k3b82f2d6sfc4b855da5ea3de8@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <359ebde50704270631h29c32fb8ieadca90b46416c1f@mail.gmail.com> <57c63afe0704270657of97664bk469b64b90eb43240@mail.gmail.com> <63c5d3820704270718k3b82f2d6sfc4b855da5ea3de8@mail.gmail.com> Message-ID: <57c63afe0704270734l410902f6j5f6d1ae305c42119@mail.gmail.com> On 4/27/07, Chris Hoffman wrote: > That has some potential, indeed. Is there a URL you can point me to > that will instruct me on how to install the HEAD of the RSpec > repository? It looks like I require 0.9 to take advantage of this > patch. Thanks. Actually, the patch hasn't been applied yet. I was just asking to get your opinion. As for using trunk in a rails project, take a look at http://rspec.rubyforge.org/documentation/rails/install.html. Cheers, David > > -Chris > > On 4/27/07, David Chelimsky wrote: > > On 4/27/07, Chris Hoffman wrote: > > > Your's is a good question. I too have been looking for ways to DRY up > > > my controller tests. The more I am starting to obey a CRUD-only > > > design, the more duplication I am encountering in these specs. Right > > > now, I am combating this dilemma by making a bunch of methods in > > > spec_helper that define _context_ and _specify_ statements, such as: > > > > > > def specify_should_handle_an_invalid_id_nicely(params) > > > controller = "#{params[:controller].camelize}Controller" > > > model = params[:controller].classify.constantize > > > params[:redirect_to] ||= { :action => 'index' } > > > params[:actions] ||= [:edit, :update, :show, :destroy] > > > > > > params[:actions].to_a.each do |action| > > > context "#{controller}##{action}, given an id" do > > > controller_name params[:controller] > > > > > > specify "should call #{model}.find_by_id, instead of #{model}.find" do > > > model.should_receive(:find_by_id).with("the id") > > > send(:process, action, :id => "the id") > > > end > > > end > > > > > > context "#{controller}##{action}, not given a valid id" do > > > controller_name params[:controller] > > > > > > setup do > > > model.stub!(:find_by_id) > > > end > > > > > > specify "should redirect_to #{params[:redirect_to]}" do > > > send(:process, action) > > > response.should_redirect_to params[:redirect_to] > > > end > > > > > > specify "should populate the flash with a message indicating > > > that the record wasn't found" do > > > send(:process, action) > > > flash[:notice].should == "#{model} not found" > > > end > > > end > > > end > > > end > > > > > > This approach is obviously clunky, and I would myself like a better > > > way to specify controller-wide contracts, as it were. Just as above, > > > any action that requires an id as a parameter should behave a certain > > > way, and I shouldn't have to define this behavior in each controller's > > > specification; it should be application-wide. > > > > Would http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9605&atid=3151 > > satisfy your needs? > > _______________________________________________ > > 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 Apr 27 10:44:30 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 27 Apr 2007 10:44:30 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <57c63afe0704270734l410902f6j5f6d1ae305c42119@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <359ebde50704270631h29c32fb8ieadca90b46416c1f@mail.gmail.com> <57c63afe0704270657of97664bk469b64b90eb43240@mail.gmail.com> <63c5d3820704270718k3b82f2d6sfc4b855da5ea3de8@mail.gmail.com> <57c63afe0704270734l410902f6j5f6d1ae305c42119@mail.gmail.com> Message-ID: <63c5d3820704270744h6c208792s795a29aefa1a83cb@mail.gmail.com> Oh, so I wouldn't be able to take advantage of the patch if I applied it myself (e.g., lots of bugs )? I'm sure you can glean my opinion of the idea from the fact that I would like to start using it right away :) It seems like a generalized solution that wouldn't be specific to rails, but easily amenable to it, which works for me. -Chris On 4/27/07, David Chelimsky wrote: > On 4/27/07, Chris Hoffman wrote: > > That has some potential, indeed. Is there a URL you can point me to > > that will instruct me on how to install the HEAD of the RSpec > > repository? It looks like I require 0.9 to take advantage of this > > patch. Thanks. > > Actually, the patch hasn't been applied yet. I was just asking to get > your opinion. > > As for using trunk in a rails project, take a look at > http://rspec.rubyforge.org/documentation/rails/install.html. > > Cheers, > David > > > > > > > -Chris > > > > On 4/27/07, David Chelimsky wrote: > > > On 4/27/07, Chris Hoffman wrote: > > > > Your's is a good question. I too have been looking for ways to DRY up > > > > my controller tests. The more I am starting to obey a CRUD-only > > > > design, the more duplication I am encountering in these specs. Right > > > > now, I am combating this dilemma by making a bunch of methods in > > > > spec_helper that define _context_ and _specify_ statements, such as: > > > > > > > > def specify_should_handle_an_invalid_id_nicely(params) > > > > controller = "#{params[:controller].camelize}Controller" > > > > model = params[:controller].classify.constantize > > > > params[:redirect_to] ||= { :action => 'index' } > > > > params[:actions] ||= [:edit, :update, :show, :destroy] > > > > > > > > params[:actions].to_a.each do |action| > > > > context "#{controller}##{action}, given an id" do > > > > controller_name params[:controller] > > > > > > > > specify "should call #{model}.find_by_id, instead of #{model}.find" do > > > > model.should_receive(:find_by_id).with("the id") > > > > send(:process, action, :id => "the id") > > > > end > > > > end > > > > > > > > context "#{controller}##{action}, not given a valid id" do > > > > controller_name params[:controller] > > > > > > > > setup do > > > > model.stub!(:find_by_id) > > > > end > > > > > > > > specify "should redirect_to #{params[:redirect_to]}" do > > > > send(:process, action) > > > > response.should_redirect_to params[:redirect_to] > > > > end > > > > > > > > specify "should populate the flash with a message indicating > > > > that the record wasn't found" do > > > > send(:process, action) > > > > flash[:notice].should == "#{model} not found" > > > > end > > > > end > > > > end > > > > end > > > > > > > > This approach is obviously clunky, and I would myself like a better > > > > way to specify controller-wide contracts, as it were. Just as above, > > > > any action that requires an id as a parameter should behave a certain > > > > way, and I shouldn't have to define this behavior in each controller's > > > > specification; it should be application-wide. > > > > > > Would http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9605&atid=3151 > > > satisfy your needs? > > > _______________________________________________ > > > 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 Apr 27 10:54:22 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Apr 2007 10:54:22 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <63c5d3820704270744h6c208792s795a29aefa1a83cb@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <359ebde50704270631h29c32fb8ieadca90b46416c1f@mail.gmail.com> <57c63afe0704270657of97664bk469b64b90eb43240@mail.gmail.com> <63c5d3820704270718k3b82f2d6sfc4b855da5ea3de8@mail.gmail.com> <57c63afe0704270734l410902f6j5f6d1ae305c42119@mail.gmail.com> <63c5d3820704270744h6c208792s795a29aefa1a83cb@mail.gmail.com> Message-ID: <57c63afe0704270754gf2cf90dhcc6aea3f50bfd980@mail.gmail.com> On 4/27/07, Chris Hoffman wrote: > Oh, so I wouldn't be able to take advantage of the patch if I applied > it myself (e.g., lots of bugs )? We haven't tried to apply it. It might work just fine. Aslak and I need to take a closer look at it before we agree to apply it and there are other priorities for both of us both in and out of rspec at the moment. If you do apply it and it works, please report to this list about your experience. Cheers, David > I'm sure you can glean my opinion of > the idea from the fact that I would like to start using it right away > :) > > It seems like a generalized solution that wouldn't be specific to > rails, but easily amenable to it, which works for me. > > -Chris > > On 4/27/07, David Chelimsky wrote: > > On 4/27/07, Chris Hoffman wrote: > > > That has some potential, indeed. Is there a URL you can point me to > > > that will instruct me on how to install the HEAD of the RSpec > > > repository? It looks like I require 0.9 to take advantage of this > > > patch. Thanks. > > > > Actually, the patch hasn't been applied yet. I was just asking to get > > your opinion. > > > > As for using trunk in a rails project, take a look at > > http://rspec.rubyforge.org/documentation/rails/install.html. > > > > Cheers, > > David > > > > > > > > > > > > -Chris > > > > > > On 4/27/07, David Chelimsky wrote: > > > > On 4/27/07, Chris Hoffman wrote: > > > > > Your's is a good question. I too have been looking for ways to DRY up > > > > > my controller tests. The more I am starting to obey a CRUD-only > > > > > design, the more duplication I am encountering in these specs. Right > > > > > now, I am combating this dilemma by making a bunch of methods in > > > > > spec_helper that define _context_ and _specify_ statements, such as: > > > > > > > > > > def specify_should_handle_an_invalid_id_nicely(params) > > > > > controller = "#{params[:controller].camelize}Controller" > > > > > model = params[:controller].classify.constantize > > > > > params[:redirect_to] ||= { :action => 'index' } > > > > > params[:actions] ||= [:edit, :update, :show, :destroy] > > > > > > > > > > params[:actions].to_a.each do |action| > > > > > context "#{controller}##{action}, given an id" do > > > > > controller_name params[:controller] > > > > > > > > > > specify "should call #{model}.find_by_id, instead of #{model}.find" do > > > > > model.should_receive(:find_by_id).with("the id") > > > > > send(:process, action, :id => "the id") > > > > > end > > > > > end > > > > > > > > > > context "#{controller}##{action}, not given a valid id" do > > > > > controller_name params[:controller] > > > > > > > > > > setup do > > > > > model.stub!(:find_by_id) > > > > > end > > > > > > > > > > specify "should redirect_to #{params[:redirect_to]}" do > > > > > send(:process, action) > > > > > response.should_redirect_to params[:redirect_to] > > > > > end > > > > > > > > > > specify "should populate the flash with a message indicating > > > > > that the record wasn't found" do > > > > > send(:process, action) > > > > > flash[:notice].should == "#{model} not found" > > > > > end > > > > > end > > > > > end > > > > > end > > > > > > > > > > This approach is obviously clunky, and I would myself like a better > > > > > way to specify controller-wide contracts, as it were. Just as above, > > > > > any action that requires an id as a parameter should behave a certain > > > > > way, and I shouldn't have to define this behavior in each controller's > > > > > specification; it should be application-wide. > > > > > > > > Would http://rubyforge.org/tracker/?func=detail&group_id=797&aid=9605&atid=3151 > > > > satisfy your needs? > > > > _______________________________________________ > > > > 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 nick at ekenosen.net Fri Apr 27 11:36:44 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Fri, 27 Apr 2007 11:36:44 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <57c63afe0704270720m7fe1895ah950f4d3d221e0324@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <57c63afe0704270720m7fe1895ah950f4d3d221e0324@mail.gmail.com> Message-ID: <276ff9870704270836x168f1d92y2e774a6591efddf9@mail.gmail.com> On 4/27/07, David Chelimsky wrote: > I like the idea of binding the examples to some method that gets run > before or after the example. There is a similar RFE already in the > tracker http://rubyforge.org/tracker/?func=detail&group_id=797&aid=10285&atid=3152. I hadn't seen that one. I was originally also thinking about some sort of magic handling whereby mocks are automatically run before and state expectations are automatically run afterwards. But I agree with you: that magic comes at the cost of losing much clarity. > The problem is coming up with the right language. Yes. > In the RFE I mentioned, I proposed something like ... > > it "should do something", during_event do I like that a *lot*. :-) > That seems to work well, but its counterpart ... > > it "should leave some state", after_event do > > leaves me cold. It especially fails to align w/ your example "should > assign new person to template on GET to create", which seems like a > great way to express the behaviour, but followed by "after_event" > doesn't really read correctly. Could during_event, before_event, after_event, when_event, by_end_of_event, on_event (and perhaps some number of other aliases with the same similar before/after behaviour, but different names for readability in different contexts) also be made to append text to the specification string? Likewise, the event itself could include a description. e.g. describe PeopleController do before do @person = mock_model(Person) Person.stub!(:new).and_return(@person) end event "GET to #create" do get "create", :foo => "bar" end it "should create a new person", during_event do Person.should_receive(:new).and_return(@person) end it "should assign new person to template", on_event do assigns[:person].should_be @person end end could generate the following sentences: PeopleController should create a new person during GET to #create PeopleController should assign new person to template on GET to #create What do you think of that? I'm still not sure that "on_event" clearly represents "event then expectation" as clearly as something else might... but it works for me, and it produces the nice string. > In general, I'm much more inclined to favor an additional parameter > passed to #it over a new method name. Yeah, I hadn't even thought about something like that. I like it a *lot*. -- Nick From dchelimsky at gmail.com Fri Apr 27 11:53:29 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Apr 2007 11:53:29 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <276ff9870704270836x168f1d92y2e774a6591efddf9@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <57c63afe0704270720m7fe1895ah950f4d3d221e0324@mail.gmail.com> <276ff9870704270836x168f1d92y2e774a6591efddf9@mail.gmail.com> Message-ID: <57c63afe0704270853i2da53032kfc82bca0a6c79af9@mail.gmail.com> On 4/27/07, nicholas a. evans wrote: > On 4/27/07, David Chelimsky wrote: > > I like the idea of binding the examples to some method that gets run > > before or after the example. There is a similar RFE already in the > > tracker http://rubyforge.org/tracker/?func=detail&group_id=797&aid=10285&atid=3152. > > I hadn't seen that one. I was originally also thinking about some > sort of magic handling whereby mocks are automatically run before and > state expectations are automatically run afterwards. But I agree with > you: that magic comes at the cost of losing much clarity. > > > The problem is coming up with the right language. > > Yes. > > > In the RFE I mentioned, I proposed something like ... > > > > it "should do something", during_event do > > I like that a *lot*. :-) > > > That seems to work well, but its counterpart ... > > > > it "should leave some state", after_event do > > > > leaves me cold. It especially fails to align w/ your example "should > > assign new person to template on GET to create", which seems like a > > great way to express the behaviour, but followed by "after_event" > > doesn't really read correctly. > > Could during_event, before_event, after_event, when_event, > by_end_of_event, on_event (and perhaps some number of other aliases > with the same similar before/after behaviour, but different names for > readability in different contexts) also be made to append text to the > specification string? Likewise, the event itself could include a > description. > > e.g. > > describe PeopleController do > before do > @person = mock_model(Person) > Person.stub!(:new).and_return(@person) > end > event "GET to #create" do > get "create", :foo => "bar" > end > it "should create a new person", during_event do > Person.should_receive(:new).and_return(@person) > end > it "should assign new person to template", on_event do > assigns[:person].should_be @person > end > end > > could generate the following sentences: > > PeopleController should create a new person during GET to #create > PeopleController should assign new person to template on GET to #create > > What do you think of that? I'm still not sure that "on_event" clearly > represents "event then expectation" as clearly as something else > might... but it works for me, and it produces the nice string. Very nice! The trick is that we're merging to concepts here - trying to express the intent of the example and also have it execute the right things in the right order. Words like "during" or "on" are there to coerce rspec to execute things in the right order but they mean the same thing to me in terms of expressing the example - the "when" in GWT. I'd love to come up with words that serve both execution and expression equally. Any other ideas? > > > In general, I'm much more inclined to favor an additional parameter > > passed to #it over a new method name. > > Yeah, I hadn't even thought about something like that. I like it a *lot*. > > -- > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at ekenosen.net Fri Apr 27 11:54:34 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Fri, 27 Apr 2007 11:54:34 -0400 Subject: [rspec-users] it "should ...", encouraging "should" via it_should Message-ID: <276ff9870704270854r281ffbccyc593439cabcca639@mail.gmail.com> On 4/27/07, David Chelimsky wrote: > Any other suggestions? > > In general, I'm much more inclined to favor an additional parameter > passed to #it over a new method name. Since I suggested in the other thread that perhaps during_event and on_event could append text to the spec string, here's another similar (but simpler) suggestion that's been in my mind for a while. it_should could automatically add "should" to the spec string. At first, the "it" syntax left me feeling a bit weird. I like that we've gone from context/specify to describe/it, because it reads far more naturally and there is less of the "what does a context mean, what should I be specifying" questioning. It pushes you gently in the direction of writing the specifications in a descriptive form. However, having recently worked with my coworkers to make the wholesale shift to rspec, I've noticed a surprising number of specs that don't have "should" at the beginning of the spec string, and should. Now, we haven't made the shift to 0.9 yet, so we don't have describe/it yet either. But if the overwhelming majority of specs should include "should" as the first word, instead of it "should do such and such" why not use it_should "do such and such" For some reason, "it_should" feels a lot nicer to me than "it", but on top of that it should go an extra step towards forcing people to word their spec strings in the proper manner. At that point, the primary documentation could tell people to use "it_should", and "it" could be relegated to a dusty corner of the rspec library for people who have some strange reason for not wanting the word "should" automatically included into their spec strings (also for backwards compatibility). Thoughts? -- Nick From work at ashleymoran.me.uk Fri Apr 27 12:07:10 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Fri, 27 Apr 2007 17:07:10 +0100 Subject: [rspec-users] Newlines breaking "should have_tag :text =>" specs Message-ID: <708E29E3-8DA4-41C6-97F8-C69B629E081D@ashleymoran.me.uk> Hi I've got an RJS spec that is failing. It looks like this: specify "should have list of prooducts for particular provider" do @provider.products.each do |product| response.should have_tag("#product_name_#{product.id}", :text => "#{product.name}") end end It fails when it renders a partial containing this: <%= product.name %> and gives this error: 'A rendered show_provider_products_for_dealer view should have list of prooducts for particular provider' FAILED <"product 1"> expected but was <"\\r\n product 1\\r">. is not true. The following change makes it work: <%= product.name % > Bizarrely, while it fails on my Mac, it passes on Windows (both running 0.8.2). Also it doesn't appear to affect RHTML specs, just RJS. Any ideas? Thanks Ashley From chris.c.hoffman at gmail.com Fri Apr 27 12:13:50 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Fri, 27 Apr 2007 12:13:50 -0400 Subject: [rspec-users] Newlines breaking "should have_tag :text =>" specs In-Reply-To: <708E29E3-8DA4-41C6-97F8-C69B629E081D@ashleymoran.me.uk> References: <708E29E3-8DA4-41C6-97F8-C69B629E081D@ashleymoran.me.uk> Message-ID: <63c5d3820704270913q1a717739p3fe123938f6d65a6@mail.gmail.com> You could do the following: :text => /\s*#{product.name}\s*/ which would ignore arbitrary amounts of whitespace. -Chris On 4/27/07, Ashley Moran wrote: > Hi > > I've got an RJS spec that is failing. It looks like this: > > specify "should have list of prooducts for particular provider" do > @provider.products.each do |product| > response.should have_tag("#product_name_#{product.id}", :text > => "#{product.name}") > end > end > > It fails when it renders a partial containing this: > > > <%= product.name %> > > > and gives this error: > > 'A rendered show_provider_products_for_dealer view should have list > of prooducts for particular provider' FAILED > <"product 1"> expected but was > <"\\r\n product 1\\r">. > is not true. > > > The following change makes it work: > > <%= product.name % > > > > > Bizarrely, while it fails on my Mac, it passes on Windows (both > running 0.8.2). Also it doesn't appear to affect RHTML specs, just RJS. > > Any ideas? > > Thanks > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at ekenosen.net Fri Apr 27 12:15:06 2007 From: nick at ekenosen.net (nicholas a. evans) Date: Fri, 27 Apr 2007 12:15:06 -0400 Subject: [rspec-users] DRYer controller specs In-Reply-To: <57c63afe0704270853i2da53032kfc82bca0a6c79af9@mail.gmail.com> References: <276ff9870704110707ve397ac7gbea9c7cb85492207@mail.gmail.com> <57c63afe0704270720m7fe1895ah950f4d3d221e0324@mail.gmail.com> <276ff9870704270836x168f1d92y2e774a6591efddf9@mail.gmail.com> <57c63afe0704270853i2da53032kfc82bca0a6c79af9@mail.gmail.com> Message-ID: <276ff9870704270915n3c191480qef0cc927c860eefc@mail.gmail.com> On 4/27/07, David Chelimsky wrote: > Very nice! The trick is that we're merging to concepts here - trying > to express the intent of the example and also have it execute the > right things in the right order. Words like "during" or "on" are there > to coerce rspec to execute things in the right order but they mean the > same thing to me in terms of expressing the example - the "when" in > GWT. I'd love to come up with words that serve both execution and > expression equally. Any other ideas? It seems to be a hard problem... Ideas for before_event: * during_event I really like that one, and I can't come up with anything better... to me it communicates the execution order. Ideas for after_event: * with_event * by_the_end_of_event * by_event * upon_event PeopleController should assign new person to template with a GET to create PeopleController should assign new person to template by the end of a GET to create PeopleController should assign new person to template upon a GET to create (I added changed the event string to "a GET to create".) Both "upon" and "by_the_end_of it" seem evident to me that the expectations would need to run after the event. Is it getting closer to something good? -- Nick From work at ashleymoran.me.uk Fri Apr 27 12:30:22 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Fri, 27 Apr 2007 17:30:22 +0100 Subject: [rspec-users] Newlines breaking "should have_tag :text =>" specs In-Reply-To: <63c5d3820704270913q1a717739p3fe123938f6d65a6@mail.gmail.com> References: <708E29E3-8DA4-41C6-97F8-C69B629E081D@ashleymoran.me.uk> <63c5d3820704270913q1a717739p3fe123938f6d65a6@mail.gmail.com> Message-ID: <685522D1-DC34-4C57-850F-533F2CC39E16@ashleymoran.me.uk> On 27 Apr 2007, at 17:13, Chris Hoffman wrote: > You could do the following: > > :text => /\s*#{product.name}\s*/ > > which would ignore arbitrary amounts of whitespace. > > -Chris Cool thanks - I'll try that over the weekend. In the mean time, any idea why it passes on Windows and not OS X? Seems very wierd. From dchelimsky at gmail.com Sat Apr 28 10:39:34 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 28 Apr 2007 10:39:34 -0400 Subject: [rspec-users] [ rspec-Patches-9605 ] Patch for ER 9472, shared behaviour In-Reply-To: <20070428143418.393295240B55@rubyforge.org> References: <20070428143418.393295240B55@rubyforge.org> Message-ID: <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> Hi all - I've applied (to trunk) Bob Cotton's patch which supports shared behaviours (link to tracker below). I'm still toying w/ names, so please be aware that until this is released w/ 0.9 it should be considered experimental and there will NOT be translation support for it. It will definitely be included in some form - just the names (specifically it_should_behave_like) might change. That said, I encourage all you trunksters to grab the latest trunk and give this feature a roll. I think it solves the problem of duplication across behaviours very nicely. And please provide feedback. If you have any issues with this I want to know about them before we release 0.9 (which is coming VERY soon). Cheers, David On 4/28/07, noreply at rubyforge.org wrote: > Patches item #9605, was opened at 2007-03-27 04:08 > You can respond by visiting: > http://rubyforge.org/tracker/?func=detail&atid=3151&aid=9605&group_id=797 > > >Category: runner module > Group: None > >Status: Closed > >Resolution: Accepted > Priority: 3 > Submitted By: Bob Cotton (bcotton) > >Assigned to: David Chelimsky (dchelimsky) > Summary: Patch for ER 9472, shared behaviour > > Initial Comment: > I chose behaves_as, as the inclusion method. > > I don't like the use of the global, behavior_runner, in Behavior to find shared behaviors. Putting the collection on Spec::Runner seemed just as bad. > > > > Had to move some methods on module Spec::DSL::BehaviourEval::ModuleMethods from private to protected to faciliate copying things from one EvalModule to another. > > > > There are many combinations of include, setup/teardown, context_setup/context_teardown and inherit that are not covered in the shared_behavior spec. Let me know if you want more. Might be a good place for shared behaviors! > > > > -Bob > > ---------------------------------------------------------------------- > > >Comment By: David Chelimsky (dchelimsky) > Date: 2007-04-28 14:34 > > Message: > Applied to trunk rev 1820. > > > > Nice work Bob - thanks! > > ---------------------------------------------------------------------- > > Comment By: Bob Cotton (bcotton) > Date: 2007-04-02 14:11 > > Message: > Newest version of the patch attached. > > ---------------------------------------------------------------------- > > Comment By: Aslak Helles?y (aslak_hellesoy) > Date: 2007-03-28 11:11 > > Message: > I haven't had time to look into this in detail, but it looks interesting. Right now we're trying to get 0.9 out the door, and we're reluctant to add new features before 0.9 is released. > > > > Let's revisit this post 0.9 > > ---------------------------------------------------------------------- > > Comment By: Bob Cotton (bcotton) > Date: 2007-03-27 12:12 > > Message: > Missed the checkbox. Sorry. > > ---------------------------------------------------------------------- > > Comment By: Bob Cotton (bcotton) > Date: 2007-03-27 12:11 > > Message: > One more thing, rcov is at 100%, but I can't get pre_commit > > to run. It either runs out of memory, or the stack is too deep. > > ---------------------------------------------------------------------- > > Comment By: David Chelimsky (dchelimsky) > Date: 2007-03-27 04:16 > > Message: > File please. > > ---------------------------------------------------------------------- > > Comment By: David Chelimsky (dchelimsky) > Date: 2007-03-27 04:15 > > Message: > Hi Bob - I'll take a look at this tomorrow. Thanks. > > > > FYI - the problem you had running pre_commit was due to something we were trying to fix w/ 1.8.6. I reverted the spectask and you can run pre_commit now. > > ---------------------------------------------------------------------- > > Comment By: Bob Cotton (bcotton) > Date: 2007-03-27 04:10 > > Message: > One more thing, rcov is at 100%, but I can't get pre_commit > > to run. It either runs out of memory, or the stack is too deep. > > ---------------------------------------------------------------------- > > You can respond by visiting: > http://rubyforge.org/tracker/?func=detail&atid=3151&aid=9605&group_id=797 > From dchelimsky at gmail.com Sat Apr 28 11:58:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 28 Apr 2007 11:58:05 -0400 Subject: [rspec-users] [ rspec-Patches-9605 ] Patch for ER 9472, shared behaviour In-Reply-To: <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> References: <20070428143418.393295240B55@rubyforge.org> <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> Message-ID: <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> Sorry for the noise - I applied this patch after some time had passed since it was submitted. I got all the specs passing and assumed all was OK, but I just tried this outside of RSpec's own environment and it doesn't work so I must have botched something up. I'll get this working in the next couple of days and follow up on both lists when its ready to try for real. Cheers, David On 4/28/07, David Chelimsky wrote: > Hi all - I've applied (to trunk) Bob Cotton's patch which supports > shared behaviours (link to tracker below). > > I'm still toying w/ names, so please be aware that until this is > released w/ 0.9 it should be considered experimental and there will > NOT be translation support for it. It will definitely be included in > some form - just the names (specifically it_should_behave_like) might > change. > > That said, I encourage all you trunksters to grab the latest trunk and > give this feature a roll. I think it solves the problem of duplication > across behaviours very nicely. And please provide feedback. If you > have any issues with this I want to know about them before we release > 0.9 (which is coming VERY soon). > > Cheers, > David > > On 4/28/07, noreply at rubyforge.org wrote: > > Patches item #9605, was opened at 2007-03-27 04:08 > > You can respond by visiting: > > http://rubyforge.org/tracker/?func=detail&atid=3151&aid=9605&group_id=797 > > > > >Category: runner module > > Group: None > > >Status: Closed > > >Resolution: Accepted > > Priority: 3 > > Submitted By: Bob Cotton (bcotton) > > >Assigned to: David Chelimsky (dchelimsky) > > Summary: Patch for ER 9472, shared behaviour > > > > Initial Comment: > > I chose behaves_as, as the inclusion method. > > > > I don't like the use of the global, behavior_runner, in Behavior to find shared behaviors. Putting the collection on Spec::Runner seemed just as bad. > > > > > > > > Had to move some methods on module Spec::DSL::BehaviourEval::ModuleMethods from private to protected to faciliate copying things from one EvalModule to another. > > > > > > > > There are many combinations of include, setup/teardown, context_setup/context_teardown and inherit that are not covered in the shared_behavior spec. Let me know if you want more. Might be a good place for shared behaviors! > > > > > > > > -Bob > > > > ---------------------------------------------------------------------- > > > > >Comment By: David Chelimsky (dchelimsky) > > Date: 2007-04-28 14:34 > > > > Message: > > Applied to trunk rev 1820. > > > > > > > > Nice work Bob - thanks! > > > > ---------------------------------------------------------------------- > > > > Comment By: Bob Cotton (bcotton) > > Date: 2007-04-02 14:11 > > > > Message: > > Newest version of the patch attached. > > > > ---------------------------------------------------------------------- > > > > Comment By: Aslak Helles?y (aslak_hellesoy) > > Date: 2007-03-28 11:11 > > > > Message: > > I haven't had time to look into this in detail, but it looks interesting. Right now we're trying to get 0.9 out the door, and we're reluctant to add new features before 0.9 is released. > > > > > > > > Let's revisit this post 0.9 > > > > ---------------------------------------------------------------------- > > > > Comment By: Bob Cotton (bcotton) > > Date: 2007-03-27 12:12 > > > > Message: > > Missed the checkbox. Sorry. > > > > ---------------------------------------------------------------------- > > > > Comment By: Bob Cotton (bcotton) > > Date: 2007-03-27 12:11 > > > > Message: > > One more thing, rcov is at 100%, but I can't get pre_commit > > > > to run. It either runs out of memory, or the stack is too deep. > > > > ---------------------------------------------------------------------- > > > > Comment By: David Chelimsky (dchelimsky) > > Date: 2007-03-27 04:16 > > > > Message: > > File please. > > > > ---------------------------------------------------------------------- > > > > Comment By: David Chelimsky (dchelimsky) > > Date: 2007-03-27 04:15 > > > > Message: > > Hi Bob - I'll take a look at this tomorrow. Thanks. > > > > > > > > FYI - the problem you had running pre_commit was due to something we were trying to fix w/ 1.8.6. I reverted the spectask and you can run pre_commit now. > > > > ---------------------------------------------------------------------- > > > > Comment By: Bob Cotton (bcotton) > > Date: 2007-03-27 04:10 > > > > Message: > > One more thing, rcov is at 100%, but I can't get pre_commit > > > > to run. It either runs out of memory, or the stack is too deep. > > > > ---------------------------------------------------------------------- > > > > You can respond by visiting: > > http://rubyforge.org/tracker/?func=detail&atid=3151&aid=9605&group_id=797 > > > From dchelimsky at gmail.com Sat Apr 28 17:21:51 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 28 Apr 2007 17:21:51 -0400 Subject: [rspec-users] [ rspec-Patches-9605 ] Patch for ER 9472, shared behaviour In-Reply-To: <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> References: <20070428143418.393295240B55@rubyforge.org> <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> Message-ID: <57c63afe0704281421k1da5492dwf2e3a03fb3bc951f@mail.gmail.com> OK - this is actually working now. Check out rev 1825 (or later). Take a peek at examples/shared_behaviours_example.rb to see how to use it. Cheers, David On 4/28/07, David Chelimsky wrote: > Sorry for the noise - I applied this patch after some time had passed > since it was submitted. I got all the specs passing and assumed all > was OK, but I just tried this outside of RSpec's own environment and > it doesn't work so I must have botched something up. > > I'll get this working in the next couple of days and follow up on both > lists when its ready to try for real. > > Cheers, > David > > On 4/28/07, David Chelimsky wrote: > > Hi all - I've applied (to trunk) Bob Cotton's patch which supports > > shared behaviours (link to tracker below). > > > > I'm still toying w/ names, so please be aware that until this is > > released w/ 0.9 it should be considered experimental and there will > > NOT be translation support for it. It will definitely be included in > > some form - just the names (specifically it_should_behave_like) might > > change. > > > > That said, I encourage all you trunksters to grab the latest trunk and > > give this feature a roll. I think it solves the problem of duplication > > across behaviours very nicely. And please provide feedback. If you > > have any issues with this I want to know about them before we release > > 0.9 (which is coming VERY soon). > > > > Cheers, > > David > > > > On 4/28/07, noreply at rubyforge.org wrote: > > > Patches item #9605, was opened at 2007-03-27 04:08 > > > You can respond by visiting: > > > http://rubyforge.org/tracker/?func=detail&atid=3151&aid=9605&group_id=797 > > > > > > >Category: runner module > > > Group: None > > > >Status: Closed > > > >Resolution: Accepted > > > Priority: 3 > > > Submitted By: Bob Cotton (bcotton) > > > >Assigned to: David Chelimsky (dchelimsky) > > > Summary: Patch for ER 9472, shared behaviour > > > > > > Initial Comment: > > > I chose behaves_as, as the inclusion method. > > > > > > I don't like the use of the global, behavior_runner, in Behavior to find shared behaviors. Putting the collection on Spec::Runner seemed just as bad. > > > > > > > > > > > > Had to move some methods on module Spec::DSL::BehaviourEval::ModuleMethods from private to protected to faciliate copying things from one EvalModule to another. > > > > > > > > > > > > There are many combinations of include, setup/teardown, context_setup/context_teardown and inherit that are not covered in the shared_behavior spec. Let me know if you want more. Might be a good place for shared behaviors! > > > > > > > > > > > > -Bob > > > > > > ---------------------------------------------------------------------- > > > > > > >Comment By: David Chelimsky (dchelimsky) > > > Date: 2007-04-28 14:34 > > > > > > Message: > > > Applied to trunk rev 1820. > > > > > > > > > > > > Nice work Bob - thanks! > > > > > > ---------------------------------------------------------------------- > > > > > > Comment By: Bob Cotton (bcotton) > > > Date: 2007-04-02 14:11 > > > > > > Message: > > > Newest version of the patch attached. > > > > > > ---------------------------------------------------------------------- > > > > > > Comment By: Aslak Helles?y (aslak_hellesoy) > > > Date: 2007-03-28 11:11 > > > > > > Message: > > > I haven't had time to look into this in detail, but it looks interesting. Right now we're trying to get 0.9 out the door, and we're reluctant to add new features before 0.9 is released. > > > > > > > > > > > > Let's revisit this post 0.9 > > > > > > ---------------------------------------------------------------------- > > > > > > Comment By: Bob Cotton (bcotton) > > > Date: 2007-03-27 12:12 > > > > > > Message: > > > Missed the checkbox. Sorry. > > > > > > ---------------------------------------------------------------------- > > > > > > Comment By: Bob Cotton (bcotton) > > > Date: 2007-03-27 12:11 > > > > > > Message: > > > One more thing, rcov is at 100%, but I can't get pre_commit > > > > > > to run. It either runs out of memory, or the stack is too deep. > > > > > > ---------------------------------------------------------------------- > > > > > > Comment By: David Chelimsky (dchelimsky) > > > Date: 2007-03-27 04:16 > > > > > > Message: > > > File please. > > > > > > ---------------------------------------------------------------------- > > > > > > Comment By: David Chelimsky (dchelimsky) > > > Date: 2007-03-27 04:15 > > > > > > Message: > > > Hi Bob - I'll take a look at this tomorrow. Thanks. > > > > > > > > > > > > FYI - the problem you had running pre_commit was due to something we were trying to fix w/ 1.8.6. I reverted the spectask and you can run pre_commit now. > > > > > > ---------------------------------------------------------------------- > > > > > > Comment By: Bob Cotton (bcotton) > > > Date: 2007-03-27 04:10 > > > > > > Message: > > > One more thing, rcov is at 100%, but I can't get pre_commit > > > > > > to run. It either runs out of memory, or the stack is too deep. > > > > > > ---------------------------------------------------------------------- > > > > > > You can respond by visiting: > > > http://rubyforge.org/tracker/?func=detail&atid=3151&aid=9605&group_id=797 > > > > > > From cwdinfo at gmail.com Sun Apr 29 03:52:24 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 29 Apr 2007 00:52:24 -0700 Subject: [rspec-users] Stubbing errors for AR In-Reply-To: <57c63afe0704281421k1da5492dwf2e3a03fb3bc951f@mail.gmail.com> References: <20070428143418.393295240B55@rubyforge.org> <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> <57c63afe0704281421k1da5492dwf2e3a03fb3bc951f@mail.gmail.com> Message-ID: When mocking for an update method, I'm using this code. @mock_setting = mock("setting") Setting.should_receive(:find).once.and_return(@mock_setting) @mock_setting.stub!(:save).and_return(false) All well and good, as it's supposed to generate a failed update. However, the <%= error_messages_for 'setting' %> wants a receiver for errors. Has anyone stubbed errors? The AR errors object has to respond to a bunch of stuff and I wanted to find out if someone had already done this (or if it's a dumb idea). Thanks, From jerry.west at ntlworld.com Sun Apr 29 05:15:44 2007 From: jerry.west at ntlworld.com (Jerry West) Date: Sun, 29 Apr 2007 10:15:44 +0100 Subject: [rspec-users] Stubbing errors for AR In-Reply-To: References: <20070428143418.393295240B55@rubyforge.org> <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> <57c63afe0704281421k1da5492dwf2e3a03fb3bc951f@mail.gmail.com> Message-ID: <46346240.4000102@ntlworld.com> Look for mock_model (in the plugin examples???) and/or google for 'making a mockery of ActiveRecord'. Hope this helps, Jerry s.ross wrote: > When mocking for an update method, I'm using this code. > > @mock_setting = mock("setting") > Setting.should_receive(:find).once.and_return(@mock_setting) > @mock_setting.stub!(:save).and_return(false) > > All well and good, as it's supposed to generate a failed update. > However, the > > <%= error_messages_for 'setting' %> > > wants a receiver for errors. Has anyone stubbed errors? The AR errors > object has to respond to a bunch of stuff and I wanted to find out if > someone had already done this (or if it's a dumb idea). > > Thanks, > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cwdinfo at gmail.com Sun Apr 29 18:13:01 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 29 Apr 2007 15:13:01 -0700 Subject: [rspec-users] Stubbing errors for AR In-Reply-To: <46346240.4000102@ntlworld.com> References: <20070428143418.393295240B55@rubyforge.org> <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> <57c63afe0704281421k1da5492dwf2e3a03fb3bc951f@mail.gmail.com> <46346240.4000102@ntlworld.com> Message-ID: Absolutely and totally helpful. What I'm missing is the je ne sais quois about how mock_model works. I'd be happy to submit a doc patch with an example if I could just get one :) Here's what I'm doing and tell me if my approach is haywire or I'm misunderstanding: # the spec it "should fail with POST and bad data" mock_model Setting do |m| # seems mock_model now takes a classname and not a symbol m.should_receive(:find).once.and_return(@setting) add_stubs(m, :save => false) # this can go into the second param to mock_model, I guess end puts "for debugging purposes, save should result in false" POST :update, :id => 1, :setting => {:setting_name => 'first_new_setting', :setting_value => 'first_new_value', :setting_type => 'string'} response_should be_success # because success renders action 'edit' and sets a 200 end # the controller def update @setting = Setting.find(params[:id]) puts "setting is #{@setting.save}" # ... end What I'm seeing from the puts statements is: for debugging purposes, save should result in false setting is true What am I missing about how this should work? Thanks Steve On Apr 29, 2007, at 2:15 AM, Jerry West wrote: > Look for mock_model (in the plugin examples???) and/or google for > 'making a mockery of ActiveRecord'. > > Hope this helps, > Jerry > > s.ross wrote: >> When mocking for an update method, I'm using this code. >> >> @mock_setting = mock("setting") >> Setting.should_receive(:find).once.and_return(@mock_setting) >> @mock_setting.stub!(:save).and_return(false) >> >> All well and good, as it's supposed to generate a failed update. >> However, the >> >> <%= error_messages_for 'setting' %> >> >> wants a receiver for errors. Has anyone stubbed errors? The AR errors >> object has to respond to a bunch of stuff and I wanted to find out if >> someone had already done this (or if it's a dumb idea). >> >> 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 jerry.west at ntlworld.com Sun Apr 29 20:01:11 2007 From: jerry.west at ntlworld.com (Jerry West) Date: Mon, 30 Apr 2007 01:01:11 +0100 Subject: [rspec-users] Stubbing errors for AR In-Reply-To: References: <20070428143418.393295240B55@rubyforge.org> <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> <57c63afe0704281421k1da5492dwf2e3a03fb3bc951f@mail.gmail.com> <46346240.4000102@ntlworld.com> Message-ID: <463531C7.2060405@ntlworld.com> Steve, I'm not at my desk, and can't remember seeing #add_stubs before, though I can guess what it does. However, you seem to be using the parameter m yielded by mock_model as both the class (model) and the instance. If m is the class then the #should_receive(:find) will work as expected. But if so, does that mean #add_stubs is putting the stub for save on Setting (the class) and not @setting? I would make the expectation explicit: @setting.should_receive(:save).and_return(false). If that works check to see what mock_model is yielding (class or instance) and that add_stubs does what you think it does. If the expectation on @setting doesn't make any difference, then I'm stumped without spending much more time on this (it's nearly 1am here, I *really* should not be doing this!). Best wishes, Jerry s.ross wrote: > Absolutely and totally helpful. What I'm missing is the je ne sais > quois about how mock_model works. I'd be happy to submit a doc patch > with an example if I could just get one :) > > Here's what I'm doing and tell me if my approach is haywire or I'm > misunderstanding: > > # the spec > > it "should fail with POST and bad data" > mock_model Setting do |m| # seems mock_model now takes a > classname and not a symbol > m.should_receive(:find).once.and_return(@setting) > add_stubs(m, :save => false) # this can go into the second param > to mock_model, I guess > end > > puts "for debugging purposes, save should result in false" > POST :update, :id => 1, :setting => {:setting_name => > 'first_new_setting', :setting_value => > 'first_new_value', :setting_type => 'string'} > response_should be_success # because success renders action 'edit' > and sets a 200 > end > > # the controller > > def update > @setting = Setting.find(params[:id]) > puts "setting is #{@setting.save}" > # ... > end > > > What I'm seeing from the puts statements is: > > for debugging purposes, save should result in false > setting is true > > > What am I missing about how this should work? > > Thanks > > Steve From cwdinfo at gmail.com Sun Apr 29 20:04:42 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 29 Apr 2007 17:04:42 -0700 Subject: [rspec-users] Stubbing errors for AR In-Reply-To: <463531C7.2060405@ntlworld.com> References: <20070428143418.393295240B55@rubyforge.org> <57c63afe0704280739r2cabe186qe2ae15672c6ab077@mail.gmail.com> <57c63afe0704280858y23876b59o81b8855060bb7067@mail.gmail.com> <57c63afe0704281421k1da5492dwf2e3a03fb3bc951f@mail.gmail.com> <46346240.4000102@ntlworld.com> <463531C7.2060405@ntlworld.com> Message-ID: <493D0B86-68DE-408D-8C2F-7C9393A0E10B@gmail.com> Here's what I wound up doing: setup do @countable = mock('countable') @countable.stub!(:count).and_return(1) @countable.stub!(:full_messages).and_return(['a message']) @setting = mock_model Setting do |m| m.stub!(:save).and_return(true) m.stub!(:errors).and_return(@countable) m.stub!(:setting_name).and_return('first_name') m.stub!(:setting_value).and_return('first_value') m.stub!(:setting_type).and_return('first_type') end end That solves the original problem of the view requesting error messages and barfing and also cleans up the code a lot. Thanks! On Apr 29, 2007, at 5:01 PM, Jerry West wrote: > Steve, > > I'm not at my desk, and can't remember seeing #add_stubs before, > though > I can guess what it does. However, you seem to be using the > parameter m > yielded by mock_model as both the class (model) and the instance. > If m > is the class then the #should_receive(:find) will work as > expected. But > if so, does that mean #add_stubs is putting the stub for save on > Setting > (the class) and not @setting? > > I would make the expectation explicit: > @setting.should_receive(:save).and_return(false). If that works check > to see what mock_model is yielding (class or instance) and that > add_stubs does what you think it does. > > If the expectation on @setting doesn't make any difference, then I'm > stumped without spending much more time on this (it's nearly 1am > here, I > *really* should not be doing this!). > > Best wishes, > Jerry > > > s.ross wrote: >> Absolutely and totally helpful. What I'm missing is the je ne sais >> quois about how mock_model works. I'd be happy to submit a doc patch >> with an example if I could just get one :) >> >> Here's what I'm doing and tell me if my approach is haywire or I'm >> misunderstanding: >> >> # the spec >> >> it "should fail with POST and bad data" >> mock_model Setting do |m| # seems mock_model now takes a >> classname and not a symbol >> m.should_receive(:find).once.and_return(@setting) >> add_stubs(m, :save => false) # this can go into the second param >> to mock_model, I guess >> end >> >> puts "for debugging purposes, save should result in false" >> POST :update, :id => 1, :setting => {:setting_name => >> 'first_new_setting', :setting_value => >> 'first_new_value', :setting_type => 'string'} >> response_should be_success # because success renders action 'edit' >> and sets a 200 >> end >> >> # the controller >> >> def update >> @setting = Setting.find(params[:id]) >> puts "setting is #{@setting.save}" >> # ... >> end >> >> >> What I'm seeing from the puts statements is: >> >> for debugging purposes, save should result in false >> setting is true >> >> >> What am I missing about how this should work? >> >> Thanks >> >> Steve > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From chris.c.hoffman at gmail.com Mon Apr 30 11:51:29 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Mon, 30 Apr 2007 11:51:29 -0400 Subject: [rspec-users] svn head api url? Message-ID: <63c5d3820704300851of30b8c7h2f72c3b8ec3969a6@mail.gmail.com> Hello, Is there a url for the api used on the development branch, which gets updated per commit or so? I am using rspec as a plugin, complete with the externals property, and would like to refer to the new api while I fix all my specs up. Thanks. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070430/50c99eff/attachment.html From dchelimsky at gmail.com Mon Apr 30 11:57:54 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 30 Apr 2007 10:57:54 -0500 Subject: [rspec-users] svn head api url? In-Reply-To: <63c5d3820704300851of30b8c7h2f72c3b8ec3969a6@mail.gmail.com> References: <63c5d3820704300851of30b8c7h2f72c3b8ec3969a6@mail.gmail.com> Message-ID: <57c63afe0704300857g64b4d1b5g4888f9ae83ffcea2@mail.gmail.com> On 4/30/07, Chris Hoffman wrote: > Hello, > Is there a url for the api used on the development branch, which gets > updated per commit or so? I am using rspec as a plugin, complete with the > externals property, and would like to refer to the new api while I fix all > my specs up. Thanks. Sorry - there is not yet. Eventually, we'll get CI set up at which point part of the build will be to do this. You'll just have to rely on the code itself for now. David > > -Chris > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris.c.hoffman at gmail.com Mon Apr 30 12:00:01 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Mon, 30 Apr 2007 12:00:01 -0400 Subject: [rspec-users] svn head api url? In-Reply-To: <57c63afe0704300857g64b4d1b5g4888f9ae83ffcea2@mail.gmail.com> References: <63c5d3820704300851of30b8c7h2f72c3b8ec3969a6@mail.gmail.com> <57c63afe0704300857g64b4d1b5g4888f9ae83ffcea2@mail.gmail.com> Message-ID: <63c5d3820704300900j2cddb5b4i3a4f183494562cc4@mail.gmail.com> Hello, I have run rake doc:plugins, which appears to be doing what I want. I will use this until you get CI going. -Chris On 4/30/07, David Chelimsky wrote: > > On 4/30/07, Chris Hoffman wrote: > > Hello, > > Is there a url for the api used on the development branch, which gets > > updated per commit or so? I am using rspec as a plugin, complete with > the > > externals property, and would like to refer to the new api while I fix > all > > my specs up. Thanks. > > Sorry - there is not yet. Eventually, we'll get CI set up at which > point part of the build will be to do this. > > You'll just have to rely on the code itself for now. > > David > > > > > -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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070430/2ac043e7/attachment.html From dchelimsky at gmail.com Mon Apr 30 12:12:48 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 30 Apr 2007 11:12:48 -0500 Subject: [rspec-users] svn head api url? In-Reply-To: <63c5d3820704300900j2cddb5b4i3a4f183494562cc4@mail.gmail.com> References: <63c5d3820704300851of30b8c7h2f72c3b8ec3969a6@mail.gmail.com> <57c63afe0704300857g64b4d1b5g4888f9ae83ffcea2@mail.gmail.com> <63c5d3820704300900j2cddb5b4i3a4f183494562cc4@mail.gmail.com> Message-ID: <57c63afe0704300912rfdaed4ay3473a6e1fe634a95@mail.gmail.com> On 4/30/07, Chris Hoffman wrote: > Hello, > I have run rake doc:plugins, which appears to be doing what I want. Ah - should have thought of that. Cheers > I > will use this until you get CI going. > > -Chris > > > On 4/30/07, David Chelimsky wrote: > > On 4/30/07, Chris Hoffman < chris.c.hoffman at gmail.com> wrote: > > > Hello, > > > Is there a url for the api used on the development branch, which gets > > > updated per commit or so? I am using rspec as a plugin, complete with > the > > > externals property, and would like to refer to the new api while I fix > all > > > my specs up. Thanks. > > > > Sorry - there is not yet. Eventually, we'll get CI set up at which > > point part of the build will be to do this. > > > > You'll just have to rely on the code itself for now. > > > > David > > > > > > > > -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 Mon Apr 30 15:28:17 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Mon, 30 Apr 2007 15:28:17 -0400 Subject: [rspec-users] Migrating spec_helper with modifications Message-ID: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> 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. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070430/3b6a376e/attachment.html From dchelimsky at gmail.com Mon Apr 30 15:31:12 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 30 Apr 2007 14:31:12 -0500 Subject: [rspec-users] Migrating spec_helper with modifications In-Reply-To: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> References: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> Message-ID: <57c63afe0704301231q3d0f4605gd7d0e53abad4b69a@mail.gmail.com> 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 > From chris.c.hoffman at gmail.com Mon Apr 30 15:41:12 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Mon, 30 Apr 2007 15:41:12 -0400 Subject: [rspec-users] Migrating spec_helper with modifications In-Reply-To: <57c63afe0704301231q3d0f4605gd7d0e53abad4b69a@mail.gmail.com> References: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> <57c63afe0704301231q3d0f4605gd7d0e53abad4b69a@mail.gmail.com> Message-ID: <63c5d3820704301241v2264cda7o4819d9b54ebae12f@mail.gmail.com> 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) -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 > From dchelimsky at gmail.com Mon Apr 30 15:45:10 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 30 Apr 2007 14:45:10 -0500 Subject: [rspec-users] Migrating spec_helper with modifications In-Reply-To: <63c5d3820704301241v2264cda7o4819d9b54ebae12f@mail.gmail.com> References: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> <57c63afe0704301231q3d0f4605gd7d0e53abad4b69a@mail.gmail.com> <63c5d3820704301241v2264cda7o4819d9b54ebae12f@mail.gmail.com> Message-ID: <57c63afe0704301245p27ebaf29l1cefb7d610aae59b@mail.gmail.com> 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 > From chris.c.hoffman at gmail.com Mon Apr 30 15:49:51 2007 From: chris.c.hoffman at gmail.com (Chris Hoffman) Date: Mon, 30 Apr 2007 15:49:51 -0400 Subject: [rspec-users] Migrating spec_helper with modifications In-Reply-To: <57c63afe0704301245p27ebaf29l1cefb7d610aae59b@mail.gmail.com> References: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> <57c63afe0704301231q3d0f4605gd7d0e53abad4b69a@mail.gmail.com> <63c5d3820704301241v2264cda7o4819d9b54ebae12f@mail.gmail.com> <57c63afe0704301245p27ebaf29l1cefb7d610aae59b@mail.gmail.com> Message-ID: <63c5d3820704301249g56f10e2bj7dc11ab59fd43927@mail.gmail.com> 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? -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 > From dchelimsky at gmail.com Mon Apr 30 15:53:22 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 30 Apr 2007 14:53:22 -0500 Subject: [rspec-users] Migrating spec_helper with modifications In-Reply-To: <63c5d3820704301249g56f10e2bj7dc11ab59fd43927@mail.gmail.com> References: <63c5d3820704301228t343df624i3a8aaaafcfe4e341@mail.gmail.com> <57c63afe0704301231q3d0f4605gd7d0e53abad4b69a@mail.gmail.com> <63c5d3820704301241v2264cda7o4819d9b54ebae12f@mail.gmail.com> <57c63afe0704301245p27ebaf29l1cefb7d610aae59b@mail.gmail.com> <63c5d3820704301249g56f10e2bj7dc11ab59fd43927@mail.gmail.com> Message-ID: <57c63afe0704301253o72fce72ayf1c5b621815471c7@mail.gmail.com> 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 > From cwdinfo at gmail.com Mon Apr 30 16:20:36 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 30 Apr 2007 13:20:36 -0700 Subject: [rspec-users] Mocking with Calculated Results Message-ID: I am setting up an AR mock object and wanted to sanity check it. My intent is to mix this into all my examples and then override/add methods where necessary. Note that I've anticipated three cases for find: find with one numeric argument => object find with :all => Array find with anything else => nil This roughly approximates how ActiveRecord::find works in this case (neglecting the optional parameters). My question is: Is this calculation of the return value a bad thing, and if so, how better to accomplish it? Thanks --------- module SettingsMock def setup_mock @countable = mock('countable') @countable.stub!(:count).and_return(1) @countable.stub!(:full_messages).and_return(['a message']) @setting = mock_model Setting do |m| m.stub!(:save).and_return(true) m.stub!(:destroy) m.stub!(:errors).and_return(@countable) m.stub!(:setting_name).and_return('first_name') m.stub!(:setting_value).and_return('first_value') m.stub!(:setting_type).and_return('first_type') end Setting.should_receive(:find).any_number_of_times.and_return do |a| case a when :all then [@setting, @setting] when /\d+/ then @setting else nil end end end end From dchelimsky at gmail.com Mon Apr 30 16:37:00 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 30 Apr 2007 15:37:00 -0500 Subject: [rspec-users] Mocking with Calculated Results In-Reply-To: References: Message-ID: <57c63afe0704301336m57c81e7ele2ba4daff7951b91@mail.gmail.com> On 4/30/07, s.ross wrote: > I am setting up an AR mock object and wanted to sanity check it. My > intent is to mix this into all my examples and then override/add > methods where necessary. Note that I've anticipated three cases for > find: > > find with one numeric argument => object > find with :all => Array > find with anything else => nil > > This roughly approximates how ActiveRecord::find works in this case > (neglecting the optional parameters). > > My question is: Is this calculation of the return value a bad thing, Well, it will make failures more difficult to understand. In my book, that is a very bad thing. > and if so, how better to accomplish it? How about parameterizing setup_mock or coming up w/ 3 separate methods to create the mocks that are supposed to behave 3 different ways? Cheers, David > > Thanks > > --------- > > module SettingsMock > def setup_mock > @countable = mock('countable') > @countable.stub!(:count).and_return(1) > @countable.stub!(:full_messages).and_return(['a message']) > @setting = mock_model Setting do |m| > m.stub!(:save).and_return(true) > m.stub!(:destroy) > m.stub!(:errors).and_return(@countable) > m.stub!(:setting_name).and_return('first_name') > m.stub!(:setting_value).and_return('first_value') > m.stub!(:setting_type).and_return('first_type') > end > Setting.should_receive(:find).any_number_of_times.and_return do |a| > case a > when :all then [@setting, @setting] > when /\d+/ then @setting > else > nil > end > end > end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Mon Apr 30 16:52:23 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 30 Apr 2007 13:52:23 -0700 Subject: [rspec-users] Mocking with Calculated Results In-Reply-To: <57c63afe0704301336m57c81e7ele2ba4daff7951b91@mail.gmail.com> References: <57c63afe0704301336m57c81e7ele2ba4daff7951b91@mail.gmail.com> Message-ID: <60619877-88D0-4C23-A097-58B80CF639A5@gmail.com> Yes, I was afraid that might be the answer. Here's the problem. I have specs that say: describe "The Settings edit/update sequence" do it "should succeed with POST and good data" it "should fail with POST and bad data" it "should fail with POST and bad ID" end The controller case I am trying to capture is that if it does a find (1) everything is hunky-dory. For the second case, I stub save to return false. The third one is the problematic one. In this case, a bogus ID comes in, and the stub should return nil but *then* then controller will do a find(:all) and needs an array (all in the same example). As you can see, I've handled it by examining the parameters. What would be a better approach? Thanks On Apr 30, 2007, at 1:37 PM, David Chelimsky wrote: > On 4/30/07, s.ross wrote: >> I am setting up an AR mock object and wanted to sanity check it. My >> intent is to mix this into all my examples and then override/add >> methods where necessary. Note that I've anticipated three cases for >> find: >> >> find with one numeric argument => object >> find with :all => Array >> find with anything else => nil >> >> This roughly approximates how ActiveRecord::find works in this case >> (neglecting the optional parameters). >> >> My question is: Is this calculation of the return value a bad thing, > > Well, it will make failures more difficult to understand. In my book, > that is a very bad thing. > >> and if so, how better to accomplish it? > > How about parameterizing setup_mock or coming up w/ 3 separate methods > to create the mocks that are supposed to behave 3 different ways? > > Cheers, > David > >> >> Thanks >> >> --------- >> >> module SettingsMock >> def setup_mock >> @countable = mock('countable') >> @countable.stub!(:count).and_return(1) >> @countable.stub!(:full_messages).and_return(['a message']) >> @setting = mock_model Setting do |m| >> m.stub!(:save).and_return(true) >> m.stub!(:destroy) >> m.stub!(:errors).and_return(@countable) >> m.stub!(:setting_name).and_return('first_name') >> m.stub!(:setting_value).and_return('first_value') >> m.stub!(:setting_type).and_return('first_type') >> end >> Setting.should_receive(:find).any_number_of_times.and_return >> do |a| >> case a >> when :all then [@setting, @setting] >> when /\d+/ then @setting >> else >> nil >> end >> end >> 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 james at hillyerd.com Mon Apr 30 17:11:28 2007 From: james at hillyerd.com (James Hillyerd) Date: Mon, 30 Apr 2007 14:11:28 -0700 Subject: [rspec-users] Mocking with Calculated Results In-Reply-To: <60619877-88D0-4C23-A097-58B80CF639A5@gmail.com> References: <57c63afe0704301336m57c81e7ele2ba4daff7951b91@mail.gmail.com> <60619877-88D0-4C23-A097-58B80CF639A5@gmail.com> Message-ID: <254841be0704301411l5c19385ehfec8f6b2bd40f00a@mail.gmail.com> On 4/30/07, s.ross wrote: > > Yes, I was afraid that might be the answer. Here's the problem. I > have specs that say: > > describe "The Settings edit/update sequence" do > it "should succeed with POST and good data" > it "should fail with POST and bad data" > it "should fail with POST and bad ID" > end I don't know if it's right or wrong, but my controller tests have different contexts for each one of those situations. ie: context "POST /foo/blah with invalid :xyz param" I think in some cases where I know find is being called multiple times, I build an array of items, and then do: Object.stub!(:find).and_return(*@items) But that doesn't sound like it would help you. What about: Setting.should_receive(:find).with(:all).any_number_of_times.and_return([@setting, @setting]) Setting.should_receive (:find).with(1).any_number_of_times.and_return(@setting) Don't think I've tried that before. -james -- James A. Hillyerd Chief Technical Officer - ActiveRain Corp -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070430/bb8e7210/attachment.html From dchelimsky at gmail.com Mon Apr 30 17:15:07 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 30 Apr 2007 16:15:07 -0500 Subject: [rspec-users] Migrating spec_helper with modifications In-Reply-To: <57c63afe0704301253o72fce72ayf1c5b621815471c7@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> Message-ID: <57c63afe0704301415g51251fa9q998bbc55b8f8f094@mail.gmail.com> 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 > > > From cwdinfo at gmail.com Mon Apr 30 17:58:10 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 30 Apr 2007 14:58:10 -0700 Subject: [rspec-users] Mocking with Calculated Results In-Reply-To: <254841be0704301411l5c19385ehfec8f6b2bd40f00a@mail.gmail.com> References: <57c63afe0704301336m57c81e7ele2ba4daff7951b91@mail.gmail.com> <60619877-88D0-4C23-A097-58B80CF639A5@gmail.com> <254841be0704301411l5c19385ehfec8f6b2bd40f00a@mail.gmail.com> Message-ID: This would be cool if it worked, but it seems not to. I think there may be a "last one wins" behavior to class method mocking. Any other thoughts? Thanks On Apr 30, 2007, at 2:11 PM, James Hillyerd wrote: > But that doesn't sound like it would help you. What about: > > Setting.should_receive(:find).with > (:all).any_number_of_times.and_return([@setting, @setting]) > Setting.should_receive(:find).with(1).any_number_of_times.and_return > (@setting) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070430/913348e3/attachment.html