From aselder at mac.com Sun Jun 1 00:20:09 2008 From: aselder at mac.com (Andrew Selder) Date: Sat, 31 May 2008 21:20:09 -0700 Subject: [rspec-users] Mixing mocking frameworks? Message-ID: First, it was great meeting a bunch of you at RailsConf. Recently I've run into a problem using RSpec, namely its support for multiple mocking frameworks. Wait you say, isn't that a good thing? Yes, it is until you end up mixing frameworks. I was writing my latest app, and I choose to get the app working and then add in the authentication system. So I went and wrote all my test using Mocha, and everything was all peachy. Then I went to github and got the latest version of restful_authentication. To the console, "script/generated authenticated user sessions --rspec", and run the test suite. BOOM!!!! It turns out that Rick Olson wrote all the specs for RESTful Authentication using RSpec's built-in mocking, and that didn't play nicely with Mocha being declared in the spec.opts file. I think it would be nice to be able to set a mock framework per example group or spec file. I'll grab a fork and start looking at it, but if you have any suggestions, they'd be greatly appreciated. Andrew -- Andrew Selder Lead Developer Boston Logic Technology Partners aselder at bostonlogic.com www.bostonlogic.com www.logicmaps.com www.logicrentals.com From ben at benmabey.com Sun Jun 1 06:19:36 2008 From: ben at benmabey.com (Ben Mabey) Date: Sun, 1 Jun 2008 04:19:36 -0600 (MDT) Subject: [rspec-users] Railsconf and textmate bundle for Story Runner Message-ID: <30482.12.157.240.2.1212315576.squirrel@mail.onticweb.com> Hey guys, A friend and I have been working on a textmate bundle for the story runner while up here at railsconf. It is still pretty new but we think it already has some very helpful features that removes some of the pain points while writing plain text stories. It is on my github account if you want to learn more and try it out: http://github.com/bmabey/rspec-story-tmbundle/tree/master We are hoping to show it off during the lighting talk session at 11:30am on Sunday if you want to see a quick demo. Also, great job David on your presentation. I think a lot of the audience who hadn't seen much of the story runner saw how useful it can be in the development process. Thanks, Ben From rspec-users at kero.tmfweb.nl Sun Jun 1 11:30:09 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Sun, 1 Jun 2008 17:30:09 +0200 Subject: [rspec-users] how to write spec for infinite loop? In-Reply-To: <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> References: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> Message-ID: <20080601153009.GC26796@bumblebee.m38c.nl> >> I've got trouble when describe infinite loop. >> >> code snippet: >> >> def start_loop >> while true >> data = self.server.handle_client >> if data >> self.manager.dispatch(data) >> end >> end >> end >> >> without the loop, it is easy to test the logic. >> but how can I describe it to tell the developer ( me :-) ) that there >> should be an infinite loop inside. > > Here's a tip which Aslak gave me several months ago, and I find myself > repeating it in many different contexts on this mailing list: > > One way is with dependency injection: > > def start_loop(looping_infinitely = true) > while looping_infinitely > ... > end > end > > In your spec, you simply pass false (but production code can call the > method as if there is no option). "while true" is also known as "loop" in Ruby. Really, you do not want to test whether that ruby construct works, do you? (I can imagine it being in the test suite that is for RUby itself) What I think is interesting for you to test, is that your loop keeps running when the dispatcher dies, and possibly other bad-weather cases. I bet your loop is in another Thread, and checking whether a Thread still runs is easy enough (also interesting enough, since threads die by themselves in Ruby, by default, i.e. they do not raise exceptions in other threads unless you set Thread.abort_on_exception = true). From mhennemeyer at googlemail.com Sun Jun 1 15:17:12 2008 From: mhennemeyer at googlemail.com (Matthias Hennemeyer) Date: Sun, 1 Jun 2008 21:17:12 +0200 Subject: [rspec-users] != again Message-ID: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> Hey! I have implemented a quick solution for the should != .. , should ! ~ ... 'problem'. It uses source code inspection (I think it's the only way) and i've done some benchmarking to see if it's really that slow. A direct comparison of running '1.should == 1' with the unmodified rspec source against the rspec-version with source inspect shows that the latter is 7 times slower ... :( But benchmarks with '1.should == 1' inside a real example file are showing 'only' an overall speed decrease of 15% to 50%. That is still bad but having lots of people consider the passing of '1.should != 1' an rspec bug is bad too. Here is the benchmarking script: http://pastie.caboo.se/206853 And the code is at branch 'inspect' in: git://github.com/mhennemeyer/rspec There are examples for should and should_not != and !~ and i will definitely work on performance if you not totally reject this whole idea. Matthias. From pergesu at gmail.com Sun Jun 1 15:57:47 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 1 Jun 2008 12:57:47 -0700 Subject: [rspec-users] != again In-Reply-To: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> References: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> Message-ID: <810a540e0806011257u414454e0l2494c6bc14433d2b@mail.gmail.com> Very cool. Maybe we could print a warning when people use !=. That would let us get the ugly != bug fixed, but not have the perf issues. Pat On 6/1/08, Matthias Hennemeyer wrote: > Hey! > > I have implemented a quick solution for the should != .. , should ! > ~ ... 'problem'. > It uses source code inspection (I think it's the only way) and i've > done some > benchmarking to see if it's really that slow. > > A direct comparison of > running '1.should == 1' > with the unmodified rspec source against the rspec-version with > source inspect > shows that the latter is 7 times slower ... :( > > But benchmarks with '1.should == 1' inside a real example file are > showing 'only' > an overall speed decrease of 15% to 50%. That is still bad but having > lots of people > consider the passing of '1.should != 1' an rspec bug is bad too. > > Here is the benchmarking script: > http://pastie.caboo.se/206853 > > And the code is at branch 'inspect' in: > git://github.com/mhennemeyer/rspec > > There are examples for should and should_not != and !~ and i will > definitely work on performance if you not totally reject this whole > idea. > > Matthias. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Jun 1 16:55:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 1 Jun 2008 13:55:03 -0700 Subject: [rspec-users] != again In-Reply-To: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> References: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> Message-ID: On Jun 1, 2008, at 12:17 PM, Matthias Hennemeyer wrote: > Hey! > > I have implemented a quick solution for the should != .. , should ! > ~ ... 'problem'. > It uses source code inspection (I think it's the only way) and i've > done some > benchmarking to see if it's really that slow. > > A direct comparison of > running '1.should == 1' > with the unmodified rspec source against the rspec-version with > source inspect > shows that the latter is 7 times slower ... :( > > But benchmarks with '1.should == 1' inside a real example file are > showing 'only' > an overall speed decrease of 15% to 50%. That is still bad but > having lots of people > consider the passing of '1.should != 1' an rspec bug is bad too. RSpec is already getting dinged for being slower than test/unit. Making it run any slower than it already does is a deal breaker for me. > Here is the benchmarking script: > http://pastie.caboo.se/206853 > > And the code is at branch 'inspect' in: > git://github.com/mhennemeyer/rspec > > There are examples for should and should_not != and !~ and i will > definitely work on performance if you not totally reject this whole > idea. If you can get the performance up to or better than current, I'm all for it. Cheers, David From mailing_lists at railsnewbie.com Sun Jun 1 22:13:46 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sun, 1 Jun 2008 22:13:46 -0400 Subject: [rspec-users] != again In-Reply-To: References: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> Message-ID: <4EB229E8-FCA9-4E0A-996F-5634FE3B9837@railsnewbie.com> On Jun 1, 2008, at 4:55 PM, David Chelimsky wrote: > On Jun 1, 2008, at 12:17 PM, Matthias Hennemeyer wrote: > >> Hey! >> >> I have implemented a quick solution for the should != .. , should ! >> ~ ... 'problem'. >> It uses source code inspection (I think it's the only way) and i've >> done some >> benchmarking to see if it's really that slow. >> >> A direct comparison of >> running '1.should == 1' >> with the unmodified rspec source against the rspec-version with >> source inspect >> shows that the latter is 7 times slower ... :( >> >> But benchmarks with '1.should == 1' inside a real example file are >> showing 'only' >> an overall speed decrease of 15% to 50%. That is still bad but >> having lots of people >> consider the passing of '1.should != 1' an rspec bug is bad too. > > RSpec is already getting dinged for being slower than test/unit. > Making it run any slower than it already does is a deal breaker for > me. Maybe using autoloading instead of requiring would help the situation? It seems perfectly reasonable that rspec is bigger than test/unit: Test::Unit doesn't have a mocking framework, and so on. On the other hand, if no one uses (rspec's) mocking framework, should rspec have the code in place anyway? Anyway - I've never found it to be too slow. Has anyone done benchmarks on it? Scott > > >> Here is the benchmarking script: >> http://pastie.caboo.se/206853 >> >> And the code is at branch 'inspect' in: >> git://github.com/mhennemeyer/rspec >> >> There are examples for should and should_not != and !~ and i will >> definitely work on performance if you not totally reject this whole >> idea. > > If you can get the performance up to or better than current, I'm all > for it. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tek.katu at gmail.com Sun Jun 1 23:29:08 2008 From: tek.katu at gmail.com (T K) Date: Mon, 2 Jun 2008 12:29:08 +0900 Subject: [rspec-users] Getting annotations in spec files. Message-ID: <5c17ebdc0806012029k1e4be6b9kcfc4808b8dd64822@mail.gmail.com> Hi, I just noticed that `rake notes` in rails 2.0.2 doesn't check `spec` directory. So, what I annotated with "FIXME", "TODO" and "OPTIMIZE" on *_spec.rb are discarded. Is there any quick way to `rake notes` task to check `spec` directory? -T From ashley.moran at patchspace.co.uk Mon Jun 2 06:51:59 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Mon, 2 Jun 2008 11:51:59 +0100 Subject: [rspec-users] Getting annotations in spec files. In-Reply-To: <5c17ebdc0806012029k1e4be6b9kcfc4808b8dd64822@mail.gmail.com> References: <5c17ebdc0806012029k1e4be6b9kcfc4808b8dd64822@mail.gmail.com> Message-ID: <91E63082-69E3-4501-9CC4-9E4C5201752D@patchspace.co.uk> On 2 Jun 2008, at 04:29, T K wrote: > I just noticed that `rake notes` in rails 2.0.2 doesn't check `spec` > directory. So, what I annotated with "FIXME", "TODO" and "OPTIMIZE" on > *_spec.rb are discarded. > > Is there any quick way to `rake notes` task to check `spec` directory? You could redefine the rake tast, but personally I prefer to leave pending specs. I think this is a better way to leave reminders than annotations. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From byrnejb at harte-lyne.ca Mon Jun 2 11:14:13 2008 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Mon, 2 Jun 2008 11:14:13 -0400 (EDT) Subject: [rspec-users] GiT and RSpec In-Reply-To: References: Message-ID: <48476.216.185.71.22.1212419653.squirrel@webmail.harte-lyne.ca> > > Message: 2 > Date: Thu, 29 May 2008 06:35:01 -0700 > From: David Chelimsky > Subject: Re: [rspec-users] Coloured output in rspec 1.1.4 > To: rspec-users at rubyforge.org > Message-ID: <175B70FE-B706-4C03-8B20-C5B207268AD6 at gmail.com> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > On May 29, 2008, at 6:32 AM, Juanma Cervera wrote: > >> David Chelimsky wrote: >>> >>> Actually - that is not from 1.1.4 - it's a patch that was introduced >>> after the 1.1.4 release. Did you follow the install directions at >>> http://github.com/dchelimsky/rspec-rails/wikis? >> >> More or less. >> I have git-cloned from github repositories instead of make >> "script/plugin install" > > script/plugin install doesn't support getting a specific version from > git yet. To do that you have to use 'git clone' and then 'git checkout > 1.1.4' (in this case). > As an alternative to script/plugin or git-clone, you can employ git-submodules (on GiT v1.5.3 or later) to obtain the effect of subversion externals. For example: ---> $ git-submodule add \ git://github.com/dchelimsky/rspec.git \ vendor/plugins/rspec Initialized empty Git repository in /home/byrnejb/projects/proforma.git/vendor/plugins/rspec/.git/ remote: Counting objects: 46810, done. remote: Compressing objects: 100% (10646/10646), done. remote: Total 46810 (delta 33521), reused 46810 (delta 33521) Receiving objects: 100% (46810/46810), 5.99 MiB | 103 KiB/s, done. Resolving deltas: 100% (33521/33521), done. $ ll vendor/plugins total 16 drwxrwxr-x 6 byrnejb byrnejb 4096 May 28 14:06 routing_navigator drwxrwxr-x 12 byrnejb byrnejb 4096 Jun 2 10:09 rspec $ git-submodule add \ git://github.com/dchelimsky/rspec-rails.git \ vendor/plugins/rspec-rails Initialized empty Git repository in /home/byrnejb/projects/proforma.git/vendor/plugins/rspec-rails/.git/ remote: Counting objects: 46530, done. remote: Compressing objects: 100% (10649/10649), done. remote: Total 46530 (delta 33241), reused 46530 (delta 33241) Receiving objects: 100% (46530/46530), 5.94 MiB | 63 KiB/s, done. Resolving deltas: 100% (33241/33241), done. $ git-status # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: .gitmodules # new file: vendor/plugins/rspec # new file: vendor/plugins/rspec-rails # $ git-submodule init Submodule 'vendor/plugins/rspec' (git://github.com/dchelimsky/rspec.git) registered for path 'vendor/plugins/rspec' Submodule 'vendor/plugins/rspec-rails' (git://github.com/dchelimsky/rspec-rails.git) registered for path 'vendor/plugins/rspec-rails' $ git-status # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: .gitmodules # new file: vendor/plugins/rspec # new file: vendor/plugins/rspec-rails # $ git-commit -m "Added Rspec and Rspec-Rails as submodules" Created commit b4d1133: Added Rspec and Rspec-Rails as submodules 3 files changed, 8 insertions(+), 0 deletions(-) create mode 160000 vendor/plugins/rspec create mode 160000 vendor/plugins/rspec-rails $ git-status # On branch master nothing to commit (working directory clean) $ git-push # over ssh !!Warning!! - Any attempt to obtain access to this device without authorization is a criminal act. byrnejb at vcs-git.hamilton.harte-lyne.ca's password: Counting objects: 9, done. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 607 bytes, done. Total 5 (delta 1), reused 0 (delta 0) To ssh://byrnejb at vcs-git.hamilton.harte-lyne.ca/var/data/vcs-git/hll/proforma.git ab5353b..b4d1133 master -> master $ <--- Now, when anyone pulls from the canonical repository they will get Rspec and Rspec-on-Rails as well, but as submodules pulled directly from the RSpec repositories. Further, updating all submodules thereafter requires just these three steps: $git-submodule update $git-commit $git-push This is how I load edge rails as well, as a submodule: $ git-submodule add git://github.com/rails/rails.git vendor/rails $ git-submodule init $ git-commit $ git-push Once you do this you can locally checkout any version or branch that is available in the submodule. Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From rick.denatale at gmail.com Mon Jun 2 13:56:38 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 2 Jun 2008 13:56:38 -0400 Subject: [rspec-users] != again In-Reply-To: <4EB229E8-FCA9-4E0A-996F-5634FE3B9837@railsnewbie.com> References: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> <4EB229E8-FCA9-4E0A-996F-5634FE3B9837@railsnewbie.com> Message-ID: On Sun, Jun 1, 2008 at 10:13 PM, Scott Taylor wrote: > > On Jun 1, 2008, at 4:55 PM, David Chelimsky wrote: > >> >> RSpec is already getting dinged for being slower than test/unit. Making it >> run any slower than it already does is a deal breaker for me. >> > > It seems perfectly reasonable that rspec is bigger than test/unit: > Test::Unit doesn't have a mocking framework, and so on. On the other hand, > if no one uses (rspec's) mocking framework, should rspec have the code in > place anyway? I spoke up on the code size issue some months ago: http://talklikeaduck.denhaven2.com/articles/2008/01/29/why-i-dont-mind-using-rspec-in-fact-ive-come-to-love-it As for whether or not the rspec mocking framework should be separately loadable, that's a separate question. > > > Anyway - I've never found it to be too slow. Has anyone done benchmarks on > it? Like most other things, how slow or fast depends on how you use it. Here at @work, we have a really large rails app with a mixture of legacy tests and new specs. The slowest part of the overall test/spec suite, by far, is the legacy functional tests, which we hope to gradually convert to controller and view specs, using mocking as possible to avoid the db overhead, which is the real culprit. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Mon Jun 2 14:01:47 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Jun 2008 11:01:47 -0700 Subject: [rspec-users] != again In-Reply-To: References: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> Message-ID: <810a540e0806021101o7f0e2363jdb345f03063352f1@mail.gmail.com> On Sun, Jun 1, 2008 at 1:55 PM, David Chelimsky wrote: > On Jun 1, 2008, at 12:17 PM, Matthias Hennemeyer wrote: > >> Hey! >> >> I have implemented a quick solution for the should != .. , should !~ ... >> 'problem'. >> It uses source code inspection (I think it's the only way) and i've done >> some >> benchmarking to see if it's really that slow. >> >> A direct comparison of >> running '1.should == 1' >> with the unmodified rspec source against the rspec-version with source >> inspect >> shows that the latter is 7 times slower ... :( >> >> But benchmarks with '1.should == 1' inside a real example file are >> showing 'only' >> an overall speed decrease of 15% to 50%. That is still bad but having lots >> of people >> consider the passing of '1.should != 1' an rspec bug is bad too. > > RSpec is already getting dinged for being slower than test/unit. Making it > run any slower than it already does is a deal breaker for me. What about showing an ugly warning in the test runner? != is a funky edge case that can really bite people. It'd be nice to have it fixed, but then tell the programmer to change it to == because of performance. Pat From ed.howland at gmail.com Mon Jun 2 14:06:12 2008 From: ed.howland at gmail.com (Ed Howland) Date: Mon, 2 Jun 2008 13:06:12 -0500 Subject: [rspec-users] get method under 1.1.4 in Stories is undefined Message-ID: <3df642dd0806021106t5d28d9bbi507596d0a3e4ab66@mail.gmail.com> HI, After I upgraded to RSpec 1.1.4 (from git), my stories all failed. I was using Webrat and the first thing I noticed was the 'visits' method was gone. I then backtracked to just using 'get' and got the same undefined method exception. I confirmed it was still working in 1.1.3 Eventually, I got it to work doing this: in my first Given: @app = ActionController::Integration::Session.new in some When @app.get page or using Webrat: @aop.visits "/" @app.fills_in field, :with => value Anyone els seen this? Why is creating the AIS needed? Thanks Ed . -- Ed Howland http://greenprogrammer.blogspot.com From pergesu at gmail.com Mon Jun 2 14:10:19 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Jun 2008 11:10:19 -0700 Subject: [rspec-users] get method under 1.1.4 in Stories is undefined In-Reply-To: <3df642dd0806021106t5d28d9bbi507596d0a3e4ab66@mail.gmail.com> References: <3df642dd0806021106t5d28d9bbi507596d0a3e4ab66@mail.gmail.com> Message-ID: <810a540e0806021110h5eed6eacs1e1789d3d8ba2659@mail.gmail.com> On Mon, Jun 2, 2008 at 11:06 AM, Ed Howland wrote: > HI, > > After I upgraded to RSpec 1.1.4 (from git), my stories all failed. I > was using Webrat and the first thing I noticed was the 'visits' method > was gone. I then backtracked to just using 'get' and got the same > undefined method exception. I confirmed it was still working in 1.1.3 > > Eventually, I got it to work doing this: > > in my first Given: > @app = ActionController::Integration::Session.new > > in some When > @app.get page > > or using Webrat: > @aop.visits "/" > @app.fills_in field, :with => value > > Anyone els seen this? Why is creating the AIS needed? Are you running the stories as RailsStory? Seems like you might be missing that. Though it is odd that it worked before, but not now. Can you please paste all the relevant story code? (the step definitions and the line that runs the story) Pat From lists at ruby-forum.com Mon Jun 2 14:28:09 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Mon, 2 Jun 2008 20:28:09 +0200 Subject: [rspec-users] Pretty HTML reporting for stories Message-ID: Hi all, I'm just getting to grips with rspec, and I'm trying to put together a showy demo. We're trying to use the (plain text) stories feature, rather than the specs. I'd like to show off a fancy HTML report of the results if possible. So it seems I can do this from the spec command line tool, but I can't make it work for a story. I've got the three files (story.txt, steps.rb, runner.rb) from the rspec.info homepage, and I can run then by doing ruby runner.rb All splendid so far. By when I try to do spec runner.rb It doesn't want to play. I don't get an error message or anything, it just seems to ignore me. Does spec support stories, or just specs? If so, what am I doing wrong? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Jun 2 14:35:00 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Jun 2008 11:35:00 -0700 Subject: [rspec-users] Pretty HTML reporting for stories In-Reply-To: References: Message-ID: <19DDB705-0EFC-40F3-9C3F-39D22D334408@gmail.com> On Jun 2, 2008, at 11:28 AM, Matt Wynne wrote: > Hi all, > > I'm just getting to grips with rspec, and I'm trying to put together a > showy demo. We're trying to use the (plain text) stories feature, > rather > than the specs. I'd like to show off a fancy HTML report of the > results > if possible. > > So it seems I can do this from the spec command line tool, but I can't > make it work for a story. > > I've got the three files (story.txt, steps.rb, runner.rb) from the > rspec.info homepage, and I can run then by doing > ruby runner.rb > > All splendid so far. > > By when I try to do > spec runner.rb > > It doesn't want to play. I don't get an error message or anything, it > just seems to ignore me. > > Does spec support stories, or just specs? If so, what am I doing > wrong? There is a bug right now when running stories w/ rails using the html formatter. I'm heading out the door right now, but will follow up later with a hack I used to get it to work. Should get fixed in source sometime soon. Cheers, David From rick.denatale at gmail.com Mon Jun 2 14:38:01 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 2 Jun 2008 14:38:01 -0400 Subject: [rspec-users] Cherry-picking mocks?! Message-ID: A colleague just came in and asked me about a problem he was having with stub_render, which reminded me of another issue he had a week or so ago, which seems related. Let me start with the earlier issue. He was trying to write specs for a method which sends the same message possibly multiple times, but with different arguments under different calling conditions. He wanted to write something.should_receive(:foo).with(someArguments) except that the other calls would cause this to fail. He was trying to get this to work by specifying ordered expectations but this was getting messy. What he really wanted was some kind of paired mock and stub, so that the expectation that the method would be invoked with the given arguments could be verified, but the other calls would just be stubbed. Now after today's question, and understanding how expect_render and mock_render differ from normal expectations, these seem to be related. Maybe we should be able to say something like: something.expects(:foo).with(someArguments).with(otherArguments).otherwise(:stub) something_else.expects(:bar).with(arguments).otherwise(:pass) # if the arguments don't match pass the method to the real object Which is really just a strawman to see if a discussion ensues. There are other issues like providing return values, and perhaps optionally passing a method through after verification that it was called with the expected arguments. Comments? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Mon Jun 2 14:40:36 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 02 Jun 2008 12:40:36 -0600 Subject: [rspec-users] Pretty HTML reporting for stories In-Reply-To: References: Message-ID: <48443EA4.9020100@benmabey.com> Matt Wynne wrote: > Hi all, > > I'm just getting to grips with rspec, and I'm trying to put together a > showy demo. We're trying to use the (plain text) stories feature, rather > than the specs. I'd like to show off a fancy HTML report of the results > if possible. > > So it seems I can do this from the spec command line tool, but I can't > make it work for a story. > > I've got the three files (story.txt, steps.rb, runner.rb) from the > rspec.info homepage, and I can run then by doing > ruby runner.rb > > All splendid so far. > > By when I try to do > spec runner.rb > > It doesn't want to play. I don't get an error message or anything, it > just seems to ignore me. > > Does spec support stories, or just specs? If so, what am I doing wrong? > The spec command is just for specs. Although the story runner now uses the same command line option parser. So you can pass in the args when running your runner file. Like so: ruby story.rb -f=html or the verbose way: ruby story.rb --format=html -Ben From ben at benmabey.com Mon Jun 2 14:45:18 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 02 Jun 2008 12:45:18 -0600 Subject: [rspec-users] Pretty HTML reporting for stories In-Reply-To: <19DDB705-0EFC-40F3-9C3F-39D22D334408@gmail.com> References: <19DDB705-0EFC-40F3-9C3F-39D22D334408@gmail.com> Message-ID: <48443FBE.7070407@benmabey.com> David Chelimsky wrote: > On Jun 2, 2008, at 11:28 AM, Matt Wynne wrote: > >> Hi all, >> >> I'm just getting to grips with rspec, and I'm trying to put together a >> showy demo. We're trying to use the (plain text) stories feature, rather >> than the specs. I'd like to show off a fancy HTML report of the results >> if possible. >> >> So it seems I can do this from the spec command line tool, but I can't >> make it work for a story. >> >> I've got the three files (story.txt, steps.rb, runner.rb) from the >> rspec.info homepage, and I can run then by doing >> ruby runner.rb >> >> All splendid so far. >> >> By when I try to do >> spec runner.rb >> >> It doesn't want to play. I don't get an error message or anything, it >> just seems to ignore me. >> >> Does spec support stories, or just specs? If so, what am I doing wrong? > > There is a bug right now when running stories w/ rails using the html > formatter. I'm heading out the door right now, but will follow up > later with a hack I used to get it to work. Should get fixed in source > sometime soon. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users David, Are you sure there is a bug? (what ticket number?) I can get it to work just fine, and just barely verified this. In fact, I am using it in my textmate story bundle that I have on github. -Ben From pergesu at gmail.com Mon Jun 2 14:50:56 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Jun 2008 11:50:56 -0700 Subject: [rspec-users] Cherry-picking mocks?! In-Reply-To: References: Message-ID: <810a540e0806021150o33fe74bg497d3f37dd51cd0a@mail.gmail.com> On Mon, Jun 2, 2008 at 11:38 AM, Rick DeNatale wrote: > A colleague just came in and asked me about a problem he was having with > stub_render, which reminded me of another issue he had a week or so ago, > which seems related. > > Let me start with the earlier issue. > > He was trying to write specs for a method which sends the same message > possibly multiple times, but with different arguments under different > calling conditions. He wanted to write > > something.should_receive(:foo).with(someArguments) > > except that the other calls would cause this to fail. He was trying to get > this to work by specifying ordered expectations but this was getting messy. > > What he really wanted was some kind of paired mock and stub, so that the > expectation that the method would be invoked with the given arguments could > be verified, but the other calls would just be stubbed. > > Now after today's question, and understanding how expect_render and > mock_render differ from normal expectations, these seem to be related. > > Maybe we should be able to say something like: > > > something.expects(:foo).with(someArguments).with(otherArguments).otherwise(:stub) > something_else.expects(:bar).with(arguments).otherwise(:pass) # if the > arguments don't match pass the method to the real object > > Which is really just a strawman to see if a discussion ensues. There are > other issues like providing return values, and perhaps optionally passing a > method through after verification that it was called with the expected > arguments. > > Comments? I've never used *_render before so I'm going to ignore that part. I just tried out describe "Mixed mocks and stubs" do before(:each) do @object = Object.new @object.stub!(:foo).and_return 1 end it "should allow both mocking and stubbing" do @object.should_receive(:foo).with(:mock).and_return 2 @object.foo(:mock).should == 2 #mock @object.foo.should == 1 #stub end end and it passes. Would that be helpful to your coworker's situation? Pat From ed.howland at gmail.com Mon Jun 2 14:55:31 2008 From: ed.howland at gmail.com (Ed Howland) Date: Mon, 2 Jun 2008 13:55:31 -0500 Subject: [rspec-users] get method under 1.1.4 in Stories is undefined In-Reply-To: <810a540e0806021110h5eed6eacs1e1789d3d8ba2659@mail.gmail.com> References: <3df642dd0806021106t5d28d9bbi507596d0a3e4ab66@mail.gmail.com> <810a540e0806021110h5eed6eacs1e1789d3d8ba2659@mail.gmail.com> Message-ID: <3df642dd0806021155h1526994dk28e24ae620bbb21f@mail.gmail.com> Yes, that was it. Thanks Ed On Mon, Jun 2, 2008 at 1:10 PM, Pat Maddox wrote: > On Mon, Jun 2, 2008 at 11:06 AM, Ed Howland wrote: >> HI, >> >> After I upgraded to RSpec 1.1.4 (from git), my stories all failed. I >> was using Webrat and the first thing I noticed was the 'visits' method >> was gone. I then backtracked to just using 'get' and got the same >> uandefined method exception. I confirmed it was still working in 1.1.3 >> >> Eventually, I got it to work doing this: >> >> in my first Given: >> @app = ActionController::Integration::Session.new >> >> in some When >> @app.get page >> >> or using Webrat: >> @aop.visits "/" >> @app.fills_in field, :with => value >> >> Anyone els seen this? Why is creating the AIS needed? > > Are you running the stories as RailsStory? Seems like you might be > missing that. Though it is odd that it worked before, but not now. > Can you please paste all the relevant story code? (the step > definitions and the line that runs the story) > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Ed Howland http://greenprogrammer.blogspot.com "The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." From lists at ruby-forum.com Mon Jun 2 15:20:35 2008 From: lists at ruby-forum.com (Matt Wynne) Date: Mon, 2 Jun 2008 21:20:35 +0200 Subject: [rspec-users] Pretty HTML reporting for stories In-Reply-To: <48443EA4.9020100@benmabey.com> References: <48443EA4.9020100@benmabey.com> Message-ID: Ben Mabey wrote: > The spec command is just for specs. Although the story runner now uses > the same command line option parser. So you can pass in the args when > running your runner file. Like so: > > ruby story.rb -f=html > or the verbose way: > ruby story.rb --format=html Man, you gentlemen are quick of the mark! Thanks for the info guys. Matt -- Posted via http://www.ruby-forum.com/. From steve.downtown at gmail.com Mon Jun 2 15:59:04 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Mon, 2 Jun 2008 12:59:04 -0700 Subject: [rspec-users] Looking for help on two issues with Rails 2.1 and RSpec 1.14 Message-ID: <4fff79200806021259j29f4fb3i6b6b2a915fcbfb6f@mail.gmail.com> I have specs that ran fine in Rails 2.02/RSpec 1.13 that are failing on Rails 2.1/RSpec 1.14. There is one problem and one issue: problem: sometimes (but not always) I get a NoMethodError referencing a has_many association issue: in helper specs, instance variables don't get set unless the HelperModule is included. Using the preferred helper. I can't seem to find a way to check that an instance variable is set: I have several specs that used to look like: it "page_title should assign @browser_title" do page_title("foo") @browser_title.should == "foo" end Now changed to: it "page_title should assign @browser_title" do helper.page_title("foo") helper.assigns[:browser_title].should == "foo" # also tried: assigns[:browser_title].should == "foo" end The output is: expected: "foo", got: nil (using ==) Any help appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jun 2 16:50:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Jun 2008 13:50:23 -0700 Subject: [rspec-users] Pretty HTML reporting for stories In-Reply-To: References: <48443EA4.9020100@benmabey.com> Message-ID: On Jun 2, 2008, at 12:20 PM, Matt Wynne wrote: > Ben Mabey wrote: >> The spec command is just for specs. Although the story runner now >> uses >> the same command line option parser. So you can pass in the args >> when >> running your runner file. Like so: >> >> ruby story.rb -f=html >> or the verbose way: >> ruby story.rb --format=html > > Man, you gentlemen are quick of the mark! > > Thanks for the info guys. Did that work? I'm not able to check this minute, but I recall a bug w/ rspec/rails/stories. > > > Matt > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Mon Jun 2 16:52:58 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 02 Jun 2008 14:52:58 -0600 Subject: [rspec-users] Pretty HTML reporting for stories In-Reply-To: References: <48443EA4.9020100@benmabey.com> Message-ID: <48445DAA.60605@benmabey.com> David Chelimsky wrote: > On Jun 2, 2008, at 12:20 PM, Matt Wynne wrote: > >> Ben Mabey wrote: >>> The spec command is just for specs. Although the story runner now uses >>> the same command line option parser. So you can pass in the args when >>> running your runner file. Like so: >>> >>> ruby story.rb -f=html >>> or the verbose way: >>> ruby story.rb --format=html >> >> Man, you gentlemen are quick of the mark! >> >> Thanks for the info guys. > > Did that work? I'm not able to check this minute, but I recall a bug > w/ rspec/rails/stories. > Yes, there was a bug that prevented it before. I believe this was resolved some time ago with a commit by Aslak... Not sure... But, it is working with rails now. -Ben > >> >> >> Matt >> -- >> Posted via http://www.ruby-forum.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 ben at benmabey.com Mon Jun 2 17:26:16 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 02 Jun 2008 15:26:16 -0600 Subject: [rspec-users] Looking for help on two issues with Rails 2.1 and RSpec 1.14 In-Reply-To: <4fff79200806021259j29f4fb3i6b6b2a915fcbfb6f@mail.gmail.com> References: <4fff79200806021259j29f4fb3i6b6b2a915fcbfb6f@mail.gmail.com> Message-ID: <48446578.6030900@benmabey.com> Steve Downey wrote: > I have specs that ran fine in Rails 2.02/RSpec 1.13 that are failing > on Rails 2.1/RSpec 1.14. > > There is one problem and one issue: > > problem: sometimes (but not always) I get a NoMethodError referencing > a has_many association > > issue: in helper specs, instance variables don't get set unless the > HelperModule is included. Using the preferred helper. I can't > seem to find a way to check that an instance variable is set: > > I have several specs that used to look like: > > it "page_title should assign @browser_title" do > page_title("foo") > @browser_title.should == "foo" > end > > > Now changed to: > > it "page_title should assign @browser_title" do > helper.page_title("foo") > helper.assigns[:browser_title].should == "foo" > # also tried: assigns[:browser_title].should == "foo" > end > > The output is: > > expected: "foo", > got: nil (using ==) > > > Any help appreciated. > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Steve, You are basically testing state here... With that said you can get around this a number of ways. You can forgoe the suggested way of using helper and just include the module directly. You can then verify that your expectation of that variable has been set. Like so: include YourHelper it "page_title should assign @browser_title" do page_title("foo") @browser_title.should == "foo" end You could also reach in and pull the variable out of the helper: it "page_title should assign @browser_title" do helper.page_title("foo") helper.instance_variable_get("@browser_title").should == "foo" end This way smells bad. In fact, both ways send off warning signals. Depending on what you are doing this may be needed though, so I hope one of these ways works for you. -Ben From lists at ruby-forum.com Mon Jun 2 18:46:59 2008 From: lists at ruby-forum.com (Ben Men) Date: Tue, 3 Jun 2008 00:46:59 +0200 Subject: [rspec-users] Cannot log in/authenticate within RSpec Story Message-ID: <0085856a78f867c978fdca90707fda1b@ruby-forum.com> I've been slamming my head against a wall for a while now, and would like some help. I believe this is session related. I have a story that looks like: -------------------------------------------------- Given that a post exists And I am logged in When I visit the post details page Then there should be a link to add a new comment -------------------------------------------------- I am using the following RSpec story functions to assist this scenario (along with others): -------------------------------------------------- Given("I am logged in") do post '/login/login', {:name => 'domain\\username', :password => 'password'} follow_redirect if redirect? end When "I visit the post details page" do get('/posts/1') end Then "there should be a link to add a new comment" do response.should have_text(/.*Add New Comment.*/) end -------------------------------------------------- The "Add New Comment" text will only show up within the view if !session['username'].nil? The login controller looks like this: -------------------------------------------------- def login if request.get? session['username'] = nil else # Split username on domain and alias split_username = params[:name].split('\\', 2) if split_username.length != 2 flash[:notice] = "You did not enter a properly formatted domain and alias" redirect_to :action => 'login' else # Authenticate username and password domain = split_username[0] username = split_username[1] password = params[:password] isAuthenticated = authenticate(domain, username, password) if isAuthenticated # User has been authenticated session['username'] = username redirect_back({:controller => 'posts', :action => 'index'}) else flash[:notice] = "Incorrect username or password" redirect_to :action => 'login' end end end end -------------------------------------------------- After the post to login/login occurs, I've attempted to check the session variable everywhere I could think to, and it does not contain a username in the data hash. Additionally, I'm told that session is a nil object within the login controller if I try something like: -------------------------------------------------- Given("I am logged in") do @lc = LoginController.new @lc.authenticate('domain', 'username', 'password') end -------------------------------------------------- I've also tried setting the session variable directly, but after that particular Given .. do clause is finished, any settings I make directly seem to be lost. Questions: 1. Can controllers within rspec stories set/get session data? 2. What is the scope of the persistence of sessions in rspec? (Scenario? Story?) 3. Any ideas on why my LoginController sets the session['username'] variable, only to have my PostsController unable to read it? Also, keep in mind that the code works when I'm actually using the site, but the rspec story fails because it's not displaying an "Add New Comment" link when it should be due to the PostsController thinking that the user isn't logged in. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Mon Jun 2 18:55:20 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 02 Jun 2008 16:55:20 -0600 Subject: [rspec-users] Cannot log in/authenticate within RSpec Story In-Reply-To: <0085856a78f867c978fdca90707fda1b@ruby-forum.com> References: <0085856a78f867c978fdca90707fda1b@ruby-forum.com> Message-ID: <48447A58.4070706@benmabey.com> Ben Men wrote: > I've been slamming my head against a wall for a while now, and would > like some help. I believe this is session related. > > I have a story that looks like: > > -------------------------------------------------- > > Given that a post exists > And I am logged in > When I visit the post details page > Then there should be a link to add a new comment > > -------------------------------------------------- > > I am using the following RSpec story functions to assist this scenario > (along with others): > > -------------------------------------------------- > > Given("I am logged in") do > post '/login/login', {:name => 'domain\\username', :password => > 'password'} > follow_redirect if redirect? > end > > When "I visit the post details page" do > get('/posts/1') > end > > Then "there should be a link to add a new comment" do > response.should have_text(/.*Add New Comment.*/) > end > > -------------------------------------------------- > > The "Add New Comment" text will only show up within the view if > !session['username'].nil? > > The login controller looks like this: > > -------------------------------------------------- > > def login > if request.get? > session['username'] = nil > else > # Split username on domain and alias > split_username = params[:name].split('\\', 2) > if split_username.length != 2 > flash[:notice] = "You did not enter a properly formatted domain > and alias" > redirect_to :action => 'login' > else > # Authenticate username and password > domain = split_username[0] > username = split_username[1] > password = params[:password] > isAuthenticated = authenticate(domain, username, password) > if isAuthenticated > # User has been authenticated > session['username'] = username > redirect_back({:controller => 'posts', :action => 'index'}) > else > flash[:notice] = "Incorrect username or password" > redirect_to :action => 'login' > end > end > end > end > > -------------------------------------------------- > > After the post to login/login occurs, I've attempted to check the > session variable everywhere I could think to, and it does not contain a > username in the data hash. > > Additionally, I'm told that session is a nil object within the login > controller if I try something like: > > -------------------------------------------------- > > Given("I am logged in") do > @lc = LoginController.new > @lc.authenticate('domain', 'username', 'password') > end > > -------------------------------------------------- > > I've also tried setting the session variable directly, but after that > particular Given .. do clause is finished, any settings I make directly > seem to be lost. > > Questions: > 1. Can controllers within rspec stories set/get session data? > 2. What is the scope of the persistence of sessions in rspec? (Scenario? > Story?) > 3. Any ideas on why my LoginController sets the session['username'] > variable, only to have my PostsController unable to read it? > > Also, keep in mind that the code works when I'm actually using the site, > but the rspec story fails because it's not displaying an "Add New > Comment" link when it should be due to the PostsController thinking that > the user isn't logged in. > I don't have time to parse your entire post or send a lengthy reply. However, this blog post walks through how to do exactly what you are attempting: http://www.glennfu.com/2008/03/31/easy-plaintext-stories-in-ruby-on-rails-using-webrat/ Good luck. -Ben From lists at ruby-forum.com Mon Jun 2 19:54:51 2008 From: lists at ruby-forum.com (Ben Men) Date: Tue, 3 Jun 2008 01:54:51 +0200 Subject: [rspec-users] Cannot log in/authenticate within RSpec Story In-Reply-To: <48447A58.4070706@benmabey.com> References: <0085856a78f867c978fdca90707fda1b@ruby-forum.com> <48447A58.4070706@benmabey.com> Message-ID: <896aa46173633c42cebd0f89e7219d42@ruby-forum.com> Ben Mabey wrote: > > I don't have time to parse your entire post or send a lengthy reply. > However, this blog post walks through how to do exactly what you are > attempting: > >http://www.glennfu.com/2008/03/31/easy-plaintext-stories-in-ruby-on-rails-using-webrat/ I wrote the login "Given" clause using Webrat and now the tests are working, though it does feel like a workaround rather than a solution. I've read over your Webrat post, as well as the linked article, and am happy using Webrat in the manner you've written about, though I'd still like to know why the session variables weren't set upon trying to read them later when not using Webrat.. -- Posted via http://www.ruby-forum.com/. From hans at degraaff.org Tue Jun 3 01:36:16 2008 From: hans at degraaff.org (Hans de Graaff) Date: Tue, 03 Jun 2008 07:36:16 +0200 Subject: [rspec-users] Pretty HTML reporting for stories In-Reply-To: <48445DAA.60605@benmabey.com> References: <48443EA4.9020100@benmabey.com> <48445DAA.60605@benmabey.com> Message-ID: <1212471376.17934.1.camel@ip6-localhost> On Mon, 2008-06-02 at 14:52 -0600, Ben Mabey wrote: > David Chelimsky wrote: > > Did that work? I'm not able to check this minute, but I recall a bug > > w/ rspec/rails/stories. > > > > Yes, there was a bug that prevented it before. I believe this was > resolved some time ago with a commit by Aslak... Not sure... But, it is > working with rails now. I did notice that the stories output is now colored again in my rails project with rspec 1.1.4, so I guess this has also fixed http://rspec.lighthouseapp.com/projects/5645/tickets/286-c-does-not-run-stories-in-color Makes sense as this also involves passing throught the command line options. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: From lists at ruby-forum.com Tue Jun 3 02:09:06 2008 From: lists at ruby-forum.com (Jose Fernandez) Date: Tue, 3 Jun 2008 08:09:06 +0200 Subject: [rspec-users] Build rspec-rails as a gem? Message-ID: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> I can't figure out how to build rspec-rails as a gem when just cloned from github... there isn't any .gemspec file or rake task that does this. Any help? -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Jun 3 02:14:16 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Jun 2008 23:14:16 -0700 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> Message-ID: <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> On Mon, Jun 2, 2008 at 11:09 PM, Jose Fernandez wrote: > I can't figure out how to build rspec-rails as a gem when just cloned > from github... there isn't any .gemspec file or rake task that does > this. Any help? rspec-rails is a rails plugin, not a gem. Pat From lists at ruby-forum.com Tue Jun 3 02:16:49 2008 From: lists at ruby-forum.com (Jose Fernandez) Date: Tue, 3 Jun 2008 08:16:49 +0200 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> Message-ID: <1d0a6550d45b0a168de22a56b7219fa1@ruby-forum.com> So how can I test a mocked rails controller within my plugin's specs? -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Jun 3 02:20:29 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Jun 2008 23:20:29 -0700 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <1d0a6550d45b0a168de22a56b7219fa1@ruby-forum.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> <1d0a6550d45b0a168de22a56b7219fa1@ruby-forum.com> Message-ID: <810a540e0806022320y761a5825q9827a3b262229bd1@mail.gmail.com> On Mon, Jun 2, 2008 at 11:16 PM, Jose Fernandez wrote: > So how can I test a mocked rails controller within my plugin's specs? I don't quite follow you. Can you post an example of what you're trying to do? Pat From lists at ruby-forum.com Tue Jun 3 02:23:20 2008 From: lists at ruby-forum.com (Jose Fernandez) Date: Tue, 3 Jun 2008 08:23:20 +0200 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <810a540e0806022320y761a5825q9827a3b262229bd1@mail.gmail.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> <1d0a6550d45b0a168de22a56b7219fa1@ruby-forum.com> <810a540e0806022320y761a5825q9827a3b262229bd1@mail.gmail.com> Message-ID: <2bfd6e2ba016a684baa24291d9db16e0@ruby-forum.com> Pat Maddox wrote: > On Mon, Jun 2, 2008 at 11:16 PM, Jose Fernandez > wrote: >> So how can I test a mocked rails controller within my plugin's specs? > > I don't quite follow you. Can you post an example of what you're trying > to do? > > Pat http://github.com/jfernandez/submarine/tree/b3853cb0a959813f156bb25239dcd4f4f2c0c406/spec/submarine/submarine_spec.rb That only test wont work because neither the 'controller_name' or 'get' methods are recognized, and I think thats because they are part of rspec-rails. -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Jun 3 02:32:44 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 2 Jun 2008 23:32:44 -0700 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <2bfd6e2ba016a684baa24291d9db16e0@ruby-forum.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> <1d0a6550d45b0a168de22a56b7219fa1@ruby-forum.com> <810a540e0806022320y761a5825q9827a3b262229bd1@mail.gmail.com> <2bfd6e2ba016a684baa24291d9db16e0@ruby-forum.com> Message-ID: <810a540e0806022332l6124e74m484a4fad6eaa7387@mail.gmail.com> On Mon, Jun 2, 2008 at 11:23 PM, Jose Fernandez wrote: > Pat Maddox wrote: >> On Mon, Jun 2, 2008 at 11:16 PM, Jose Fernandez >> wrote: >>> So how can I test a mocked rails controller within my plugin's specs? >> >> I don't quite follow you. Can you post an example of what you're trying >> to do? >> >> Pat > > http://github.com/jfernandez/submarine/tree/b3853cb0a959813f156bb25239dcd4f4f2c0c406/spec/submarine/submarine_spec.rb > > That only test wont work because neither the 'controller_name' or 'get' > methods are recognized, and I think thats because they are part of > rspec-rails. You need to include the app's spec-helper from within your spec. http://github.com/pat-maddox/rspec-plugin-generator/tree/master/generators/rspec_plugin/templates/spec_helper.rb shows what I did in my rspec_plugin generator. You might just be able to require spec/rails, I'm not sure, but you'd have to set up the load path. Pat From aselder at mac.com Tue Jun 3 10:08:53 2008 From: aselder at mac.com (Andrew Selder) Date: Tue, 03 Jun 2008 10:08:53 -0400 Subject: [rspec-users] Autotest/RSpec 1.1.4/Rails 2.1 Infinite Loop? Message-ID: <20A9C048-B70F-40D2-84C6-4169A7F0D44F@mac.com> I just got back from RailsConf, and upgraded on of my development apps to 2.1, and now autotest is going into an infinite loop. It runs tests continuously instead of waiting for files to be saved before rerunning. Has anybody else seen this, or know how to get around it? Thanks, Andrew From ben at benmabey.com Tue Jun 3 12:31:39 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 03 Jun 2008 10:31:39 -0600 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> Message-ID: <484571EB.4080606@benmabey.com> Pat Maddox wrote: > On Mon, Jun 2, 2008 at 11:09 PM, Jose Fernandez wrote: > >> I can't figure out how to build rspec-rails as a gem when just cloned >> from github... there isn't any .gemspec file or rake task that does >> this. Any help? >> > > rspec-rails is a rails plugin, not a gem. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I have needed to use it as a gem before. Why? Well, with ticket 383(http://rspec.lighthouseapp.com/projects/5645/tickets/383-extract-mock_model-out-of-railsexamplegroup) David extracted the mocking features for AR so that it could be reused easily. I was writing a merb app that used AR and I quickly began missing the mock_model and other mock helpers found in rspec-rails. So, I created a gem out of the plugin, installed it locally in my merb app I just required 'spec/rails/mocks'. The gemspec file I created to do this was: Gem::Specification.new do |s| s.name = %q{rspec-rails} s.version = "1.1.4" s.specification_version = 2 if s.respond_to? :specification_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["RSpec Development Team"] s.date = %q{2008-05-25} s.default_executable = %q{spec} s.description = %q{RSpec-Rails is an extension to RSpec to provide a better environment for specing rails.} s.email = %q{rspec-devel at rubyforge.org} s.extra_rdoc_files = ["README", "CHANGES", "MIT-LICENSE"] s.files = ["CHANGES", "MIT-LICENSE", "Rakefile", "README", "lib/autotest/discover.rb", "lib/autotest/rails_rspec.rb", "lib/spec/rails/example/assigns_hash_proxy.rb", "lib/spec/rails/example/controller_example _group.rb", "lib/spec/rails/example/functional_example_group.rb", "lib/spec/rails/example/helper_example_group.rb", "lib/spec/rails/example/model_example_group.rb", "lib/spec/rails/example/rails_example_group.r b", "lib/spec/rails/example/render_observer.rb", "lib/spec/rails/example/view_example_group.rb", "lib/spec/rails/example.rb", "lib/spec/rails/extensions/action_controller/base.rb", "lib/spec/rails/extensions/ac tion_controller/rescue.rb", "lib/spec/rails/extensions/action_controller/test_response.rb", "lib/spec/rails/extensions/action_view/base.rb", "lib/spec/rails/extensions/active_record/base.rb", "lib/spec/rails/ex tensions/object.rb", "lib/spec/rails/extensions/spec/example/configuration.rb", "lib/spec/rails/extensions/spec/matchers/have.rb", "lib/spec/rails/extensions.rb", "lib/spec/rails/matchers/assert_select.rb", "li b/spec/rails/matchers/have_text.rb", "lib/spec/rails/matchers/include_text.rb", "lib/spec/rails/matchers/redirect_to.rb", "lib/spec/rails/matchers/render_template.rb", "lib/spec/rails/matchers.rb", "lib/spec/ra ils/mocks.rb", "lib/spec/rails/story_adapter.rb", "lib/spec/rails/version.rb", "lib/spec/rails.rb"] s.has_rdoc = true s.homepage = %q{http://rspec.rubyforge.org} s.rdoc_options = ["--title", "RSpec-Rails", "--line-numbers", "--inline-source", "--main", "README"] s.require_paths = ["lib"] s.rubygems_version = %q{1.1.0} s.summary = %q{RSpec-Rails-1.1.4 (build 20080526202855) - BDD for Ruby http://rspec.rubyforge.org/} end From dchelimsky at gmail.com Tue Jun 3 12:42:14 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Jun 2008 11:42:14 -0500 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <484571EB.4080606@benmabey.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> <484571EB.4080606@benmabey.com> Message-ID: <0C45494B-CFDA-43C4-B423-93E3376AC16C@gmail.com> On Jun 3, 2008, at 11:31 AM, Ben Mabey wrote: > Pat Maddox wrote: >> On Mon, Jun 2, 2008 at 11:09 PM, Jose Fernandez > forum.com> wrote: >> >>> I can't figure out how to build rspec-rails as a gem when just >>> cloned >>> from github... there isn't any .gemspec file or rake task that does >>> this. Any help? >>> >> >> rspec-rails is a rails plugin, not a gem. >> >> Pat >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > I have needed to use it as a gem before. Why? Well, with ticket > 383(http://rspec.lighthouseapp.com/projects/5645/tickets/383-extract-mock_model-out-of-railsexamplegroup > ) David extracted the mocking features for AR so that it could be > reused easily. I was writing a merb app that used AR and I quickly > began missing the mock_model and other mock helpers found in rspec- > rails. So, I created a gem out of the plugin, installed it locally > in my merb app I just required 'spec/rails/mocks'. > > > The gemspec file I created to do this was: > > Gem::Specification.new do |s| > s.name = %q{rspec-rails} > s.version = "1.1.4" > > s.specification_version = 2 if s.respond_to? :specification_version= > > s.required_rubygems_version = Gem::Requirement.new(">= 0") if > s.respond_to? :required_rubygems_version= > s.authors = ["RSpec Development Team"] > s.date = %q{2008-05-25} > s.default_executable = %q{spec} > s.description = %q{RSpec-Rails is an extension to RSpec to provide a > better environment for specing rails.} > s.email = %q{rspec-devel at rubyforge.org} > s.extra_rdoc_files = ["README", "CHANGES", "MIT-LICENSE"] > s.files = ["CHANGES", "MIT-LICENSE", "Rakefile", "README", "lib/ > autotest/discover.rb", "lib/autotest/rails_rspec.rb", "lib/spec/ > rails/example/assigns_hash_proxy.rb", "lib/spec/rails/example/ > controller_example > _group.rb", "lib/spec/rails/example/functional_example_group.rb", > "lib/spec/rails/example/helper_example_group.rb", "lib/spec/rails/ > example/model_example_group.rb", "lib/spec/rails/example/ > rails_example_group.r > b", "lib/spec/rails/example/render_observer.rb", "lib/spec/rails/ > example/view_example_group.rb", "lib/spec/rails/example.rb", "lib/ > spec/rails/extensions/action_controller/base.rb", "lib/spec/rails/ > extensions/ac > tion_controller/rescue.rb", "lib/spec/rails/extensions/ > action_controller/test_response.rb", "lib/spec/rails/extensions/ > action_view/base.rb", "lib/spec/rails/extensions/active_record/ > base.rb", "lib/spec/rails/ex > tensions/object.rb", "lib/spec/rails/extensions/spec/example/ > configuration.rb", "lib/spec/rails/extensions/spec/matchers/ > have.rb", "lib/spec/rails/extensions.rb", "lib/spec/rails/matchers/ > assert_select.rb", "li > b/spec/rails/matchers/have_text.rb", "lib/spec/rails/matchers/ > include_text.rb", "lib/spec/rails/matchers/redirect_to.rb", "lib/ > spec/rails/matchers/render_template.rb", "lib/spec/rails/ > matchers.rb", "lib/spec/ra > ils/mocks.rb", "lib/spec/rails/story_adapter.rb", "lib/spec/rails/ > version.rb", "lib/spec/rails.rb"] > s.has_rdoc = true > s.homepage = %q{http://rspec.rubyforge.org} > s.rdoc_options = ["--title", "RSpec-Rails", "--line-numbers", "-- > inline-source", "--main", "README"] > s.require_paths = ["lib"] > s.rubygems_version = %q{1.1.0} > s.summary = %q{RSpec-Rails-1.1.4 (build 20080526202855) - BDD for > Ruby http://rspec.rubyforge.org/} > end I can grab this and add it or, if you want, you can gimme a git-patch. Your call. Cheers, David From ben at benmabey.com Tue Jun 3 12:55:34 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 03 Jun 2008 10:55:34 -0600 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <0C45494B-CFDA-43C4-B423-93E3376AC16C@gmail.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> <484571EB.4080606@benmabey.com> <0C45494B-CFDA-43C4-B423-93E3376AC16C@gmail.com> Message-ID: <48457786.7060804@benmabey.com> David Chelimsky wrote: > > On Jun 3, 2008, at 11:31 AM, Ben Mabey wrote: > >> Pat Maddox wrote: >>> On Mon, Jun 2, 2008 at 11:09 PM, Jose Fernandez >>> wrote: >>> >>>> I can't figure out how to build rspec-rails as a gem when just cloned >>>> from github... there isn't any .gemspec file or rake task that does >>>> this. Any help? >>>> >>> >>> rspec-rails is a rails plugin, not a gem. >>> >>> Pat >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> I have needed to use it as a gem before. Why? Well, with ticket >> 383(http://rspec.lighthouseapp.com/projects/5645/tickets/383-extract-mock_model-out-of-railsexamplegroup) >> David extracted the mocking features for AR so that it could be >> reused easily. I was writing a merb app that used AR and I quickly >> began missing the mock_model and other mock helpers found in >> rspec-rails. So, I created a gem out of the plugin, installed it >> locally in my merb app I just required 'spec/rails/mocks'. >> >> >> The gemspec file I created to do this was: >> >> Gem::Specification.new do |s| >> s.name = %q{rspec-rails} >> s.version = "1.1.4" >> >> s.specification_version = 2 if s.respond_to? :specification_version= >> >> s.required_rubygems_version = Gem::Requirement.new(">= 0") if >> s.respond_to? :required_rubygems_version= >> s.authors = ["RSpec Development Team"] >> s.date = %q{2008-05-25} >> s.default_executable = %q{spec} >> s.description = %q{RSpec-Rails is an extension to RSpec to provide a >> better environment for specing rails.} >> s.email = %q{rspec-devel at rubyforge.org} >> s.extra_rdoc_files = ["README", "CHANGES", "MIT-LICENSE"] >> s.files = ["CHANGES", "MIT-LICENSE", "Rakefile", "README", >> "lib/autotest/discover.rb", "lib/autotest/rails_rspec.rb", >> "lib/spec/rails/example/assigns_hash_proxy.rb", >> "lib/spec/rails/example/controller_example >> _group.rb", "lib/spec/rails/example/functional_example_group.rb", >> "lib/spec/rails/example/helper_example_group.rb", >> "lib/spec/rails/example/model_example_group.rb", >> "lib/spec/rails/example/rails_example_group.r >> b", "lib/spec/rails/example/render_observer.rb", >> "lib/spec/rails/example/view_example_group.rb", >> "lib/spec/rails/example.rb", >> "lib/spec/rails/extensions/action_controller/base.rb", >> "lib/spec/rails/extensions/ac >> tion_controller/rescue.rb", >> "lib/spec/rails/extensions/action_controller/test_response.rb", >> "lib/spec/rails/extensions/action_view/base.rb", >> "lib/spec/rails/extensions/active_record/base.rb", "lib/spec/rails/ex >> tensions/object.rb", >> "lib/spec/rails/extensions/spec/example/configuration.rb", >> "lib/spec/rails/extensions/spec/matchers/have.rb", >> "lib/spec/rails/extensions.rb", >> "lib/spec/rails/matchers/assert_select.rb", "li >> b/spec/rails/matchers/have_text.rb", >> "lib/spec/rails/matchers/include_text.rb", >> "lib/spec/rails/matchers/redirect_to.rb", >> "lib/spec/rails/matchers/render_template.rb", >> "lib/spec/rails/matchers.rb", "lib/spec/ra >> ils/mocks.rb", "lib/spec/rails/story_adapter.rb", >> "lib/spec/rails/version.rb", "lib/spec/rails.rb"] >> s.has_rdoc = true >> s.homepage = %q{http://rspec.rubyforge.org} >> s.rdoc_options = ["--title", "RSpec-Rails", "--line-numbers", >> "--inline-source", "--main", "README"] >> s.require_paths = ["lib"] >> s.rubygems_version = %q{1.1.0} >> s.summary = %q{RSpec-Rails-1.1.4 (build 20080526202855) - BDD for >> Ruby http://rspec.rubyforge.org/} >> end > > > I can grab this and add it or, if you want, you can gimme a git-patch. > Your call. > I think a rake task like rspec has would be the best solution. I will create a patch and enter it on lighthouse when I get some time. -Ben From dchelimsky at gmail.com Tue Jun 3 13:06:27 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 3 Jun 2008 12:06:27 -0500 Subject: [rspec-users] Build rspec-rails as a gem? In-Reply-To: <48457786.7060804@benmabey.com> References: <74ec5dc5c3dab6179fabbb3c33153012@ruby-forum.com> <810a540e0806022314g2665d476j38ab4873cf5d092c@mail.gmail.com> <484571EB.4080606@benmabey.com> <0C45494B-CFDA-43C4-B423-93E3376AC16C@gmail.com> <48457786.7060804@benmabey.com> Message-ID: On Jun 3, 2008, at 11:55 AM, Ben Mabey wrote: > David Chelimsky wrote: >> >> On Jun 3, 2008, at 11:31 AM, Ben Mabey wrote: >> >>> Pat Maddox wrote: >>>> On Mon, Jun 2, 2008 at 11:09 PM, Jose Fernandez >>> > wrote: >>>> >>>>> I can't figure out how to build rspec-rails as a gem when just >>>>> cloned >>>>> from github... there isn't any .gemspec file or rake task that >>>>> does >>>>> this. Any help? >>>>> >>>> >>>> rspec-rails is a rails plugin, not a gem. >>>> >>>> Pat >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> I have needed to use it as a gem before. Why? Well, with ticket >>> 383(http://rspec.lighthouseapp.com/projects/5645/tickets/383-extract-mock_model-out-of-railsexamplegroup >>> ) David extracted the mocking features for AR so that it could be >>> reused easily. I was writing a merb app that used AR and I >>> quickly began missing the mock_model and other mock helpers found >>> in rspec-rails. So, I created a gem out of the plugin, installed >>> it locally in my merb app I just required 'spec/rails/mocks'. >>> >>> >>> The gemspec file I created to do this was: >>> >>> Gem::Specification.new do |s| >>> s.name = %q{rspec-rails} >>> s.version = "1.1.4" >>> >>> s.specification_version = 2 if s.respond_to? :specification_version= >>> >>> s.required_rubygems_version = Gem::Requirement.new(">= 0") if >>> s.respond_to? :required_rubygems_version= >>> s.authors = ["RSpec Development Team"] >>> s.date = %q{2008-05-25} >>> s.default_executable = %q{spec} >>> s.description = %q{RSpec-Rails is an extension to RSpec to provide >>> a better environment for specing rails.} >>> s.email = %q{rspec-devel at rubyforge.org} >>> s.extra_rdoc_files = ["README", "CHANGES", "MIT-LICENSE"] >>> s.files = ["CHANGES", "MIT-LICENSE", "Rakefile", "README", "lib/ >>> autotest/discover.rb", "lib/autotest/rails_rspec.rb", "lib/spec/ >>> rails/example/assigns_hash_proxy.rb", "lib/spec/rails/example/ >>> controller_example >>> _group.rb", "lib/spec/rails/example/functional_example_group.rb", >>> "lib/spec/rails/example/helper_example_group.rb", "lib/spec/rails/ >>> example/model_example_group.rb", "lib/spec/rails/example/ >>> rails_example_group.r >>> b", "lib/spec/rails/example/render_observer.rb", "lib/spec/rails/ >>> example/view_example_group.rb", "lib/spec/rails/example.rb", "lib/ >>> spec/rails/extensions/action_controller/base.rb", "lib/spec/rails/ >>> extensions/ac >>> tion_controller/rescue.rb", "lib/spec/rails/extensions/ >>> action_controller/test_response.rb", "lib/spec/rails/extensions/ >>> action_view/base.rb", "lib/spec/rails/extensions/active_record/ >>> base.rb", "lib/spec/rails/ex >>> tensions/object.rb", "lib/spec/rails/extensions/spec/example/ >>> configuration.rb", "lib/spec/rails/extensions/spec/matchers/ >>> have.rb", "lib/spec/rails/extensions.rb", "lib/spec/rails/matchers/ >>> assert_select.rb", "li >>> b/spec/rails/matchers/have_text.rb", "lib/spec/rails/matchers/ >>> include_text.rb", "lib/spec/rails/matchers/redirect_to.rb", "lib/ >>> spec/rails/matchers/render_template.rb", "lib/spec/rails/ >>> matchers.rb", "lib/spec/ra >>> ils/mocks.rb", "lib/spec/rails/story_adapter.rb", "lib/spec/rails/ >>> version.rb", "lib/spec/rails.rb"] >>> s.has_rdoc = true >>> s.homepage = %q{http://rspec.rubyforge.org} >>> s.rdoc_options = ["--title", "RSpec-Rails", "--line-numbers", "-- >>> inline-source", "--main", "README"] >>> s.require_paths = ["lib"] >>> s.rubygems_version = %q{1.1.0} >>> s.summary = %q{RSpec-Rails-1.1.4 (build 20080526202855) - BDD for >>> Ruby http://rspec.rubyforge.org/} >>> end >> >> >> I can grab this and add it or, if you want, you can gimme a git- >> patch. Your call. >> > > I think a rake task like rspec has would be the best solution. I > will create a patch and enter it on lighthouse when I get some time. Great. Thanks. From rfwatson at gmail.com Tue Jun 3 16:12:53 2008 From: rfwatson at gmail.com (rfwatson) Date: Tue, 3 Jun 2008 21:12:53 +0100 Subject: [rspec-users] Autotest/RSpec 1.1.4/Rails 2.1 Infinite Loop? In-Reply-To: <20A9C048-B70F-40D2-84C6-4169A7F0D44F@mac.com> References: <20A9C048-B70F-40D2-84C6-4169A7F0D44F@mac.com> Message-ID: Had this a few times - seems to be something to do with the .autotest file in your home folder, replacing that has helped me before, but I can't be more specific. 2008/6/3 Andrew Selder : > I just got back from RailsConf, and upgraded on of my development apps to > 2.1, and now autotest is going into an infinite loop. It runs tests > continuously instead of waiting for files to be saved before rerunning. > > Has anybody else seen this, or know how to get around it? > > Thanks, > > Andrew > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nabble at mattmcneil.org Tue Jun 3 20:31:03 2008 From: nabble at mattmcneil.org (Matt McNeil) Date: Tue, 3 Jun 2008 17:31:03 -0700 (PDT) Subject: [rspec-users] controller filters running twice in 1.1.4? Message-ID: <17629653.post@talk.nabble.com> since upgrading to 1.1.4 (I had been running without issue on a git snapshot), I'm noticing that my filter actions initiated from application.rb seem to be running twice. I created a test rails project with the rspec scaffold and am also seeing the same behavior here too. Adding this code to application.rb: before_filter :foo def foo "foo" end and an example in users_controller_spec.rb: it "should call foo via a before filter" do controller.should_receive(:foo) do_get end results in this: 1) Spec::Mocks::MockExpectationError in 'UsersController handling GET /users.xml should call foo' Mock 'UsersController' expected :foo with (any args) once, but received it twice script/spec:4: Is any one else seeing this? Thanks, Matt -- View this message in context: http://www.nabble.com/controller-filters-running-twice-in-1.1.4--tp17629653p17629653.html Sent from the rspec-users mailing list archive at Nabble.com. From pergesu at gmail.com Tue Jun 3 22:07:46 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 3 Jun 2008 19:07:46 -0700 Subject: [rspec-users] controller filters running twice in 1.1.4? In-Reply-To: <17629653.post@talk.nabble.com> References: <17629653.post@talk.nabble.com> Message-ID: <810a540e0806031907q60c4fr9c0ac2d45f5cb088@mail.gmail.com> On Tue, Jun 3, 2008 at 5:31 PM, Matt McNeil wrote: > > since upgrading to 1.1.4 (I had been running without issue on a git > snapshot), I'm noticing that my filter actions initiated from application.rb > seem to be running twice. I created a test rails project with the rspec > scaffold and am also seeing the same behavior here too. > > Adding this code to application.rb: > > before_filter :foo > > def foo > "foo" > end > > and an example in users_controller_spec.rb: > > it "should call foo via a before filter" do > controller.should_receive(:foo) > do_get > end > > results in this: > > 1) > Spec::Mocks::MockExpectationError in 'UsersController handling GET > /users.xml should call foo' > Mock 'UsersController' expected :foo with (any args) once, but received it > twice > script/spec:4: > > Is any one else seeing this? Can you put a print statement inside application.rb to see if the file itself is being loaded multiple times? Pat From nabble at mattmcneil.org Tue Jun 3 22:27:48 2008 From: nabble at mattmcneil.org (Matt McNeil) Date: Tue, 3 Jun 2008 19:27:48 -0700 (PDT) Subject: [rspec-users] controller filters running twice in 1.1.4? In-Reply-To: <810a540e0806031907q60c4fr9c0ac2d45f5cb088@mail.gmail.com> References: <17629653.post@talk.nabble.com> <810a540e0806031907q60c4fr9c0ac2d45f5cb088@mail.gmail.com> Message-ID: <17637883.post@talk.nabble.com> Pat Maddox wrote: > > On Tue, Jun 3, 2008 at 5:31 PM, Matt McNeil wrote: >> >> since upgrading to 1.1.4 (I had been running without issue on a git >> snapshot), I'm noticing that my filter actions initiated from >> application.rb >> seem to be running twice. I created a test rails project with the rspec >> scaffold and am also seeing the same behavior here too. >> >> Adding this code to application.rb: >> >> before_filter :foo >> >> def foo >> "foo" >> end >> >> and an example in users_controller_spec.rb: >> >> it "should call foo via a before filter" do >> controller.should_receive(:foo) >> do_get >> end >> >> results in this: >> >> 1) >> Spec::Mocks::MockExpectationError in 'UsersController handling GET >> /users.xml should call foo' >> Mock 'UsersController' expected :foo with (any args) once, but received >> it >> twice >> script/spec:4: >> >> Is any one else seeing this? > > Can you put a print statement inside application.rb to see if the file > itself is being loaded multiple times? > > Pat > _______________________________________________ > > Hi Pat, Yes, application.rb appears to be getting loaded twice. Things are fine when the before_filter is being called from the UsersController: class UsersController < ApplicationController before_filter :foo puts "#{__FILE__} loaded " + Time.now.to_s /opt/local/bin/ruby -S script/spec -O spec/spec.opts spec/controllers/users_controller_spec.rb /Users/matt/test/app/controllers/users_controller.rb loaded Tue Jun 03 19:20:44 -0700 2008 ................................... Finished in 0.256665 seconds 35 examples, 0 failures however, when that filter macro is moved to application.rb: class ApplicationController < ActionController::Base helper :all # include all helpers, all the time before_filter :foo puts "#{__FILE__} loaded " + Time.now.to_s here's what happens: /opt/local/bin/ruby -S script/spec -O spec/spec.opts spec/controllers/users_routing_spec.rb spec/controllers/users_controller_spec.rb /Users/matt/test/app/controllers/application.rb loaded Tue Jun 03 19:23:32 -0700 2008 /Users/matt/test/app/controllers/application.rb loaded Tue Jun 03 19:23:32 -0700 2008 ..........................................F..... 1) Spec::Mocks::MockExpectationError in 'UsersController handling GET /users.xml should call foo via a before filter' Mock 'UsersController' expected :foo with (any args) once, but received it twice script/spec:4: Finished in 0.2891 seconds 48 examples, 1 failure -- View this message in context: http://www.nabble.com/controller-filters-running-twice-in-1.1.4--tp17629653p17637883.html Sent from the rspec-users mailing list archive at Nabble.com. From pergesu at gmail.com Tue Jun 3 23:29:31 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 3 Jun 2008 20:29:31 -0700 Subject: [rspec-users] controller filters running twice in 1.1.4? In-Reply-To: <17637883.post@talk.nabble.com> References: <17629653.post@talk.nabble.com> <810a540e0806031907q60c4fr9c0ac2d45f5cb088@mail.gmail.com> <17637883.post@talk.nabble.com> Message-ID: <810a540e0806032029q13addaaeq760787843144288f@mail.gmail.com> On Tue, Jun 3, 2008 at 7:27 PM, Matt McNeil wrote: > > > Pat Maddox wrote: >> >> On Tue, Jun 3, 2008 at 5:31 PM, Matt McNeil wrote: >>> >>> since upgrading to 1.1.4 (I had been running without issue on a git >>> snapshot), I'm noticing that my filter actions initiated from >>> application.rb >>> seem to be running twice. I created a test rails project with the rspec >>> scaffold and am also seeing the same behavior here too. >>> >>> Adding this code to application.rb: >>> >>> before_filter :foo >>> >>> def foo >>> "foo" >>> end >>> >>> and an example in users_controller_spec.rb: >>> >>> it "should call foo via a before filter" do >>> controller.should_receive(:foo) >>> do_get >>> end >>> >>> results in this: >>> >>> 1) >>> Spec::Mocks::MockExpectationError in 'UsersController handling GET >>> /users.xml should call foo' >>> Mock 'UsersController' expected :foo with (any args) once, but received >>> it >>> twice >>> script/spec:4: >>> >>> Is any one else seeing this? >> >> Can you put a print statement inside application.rb to see if the file >> itself is being loaded multiple times? >> >> Pat >> _______________________________________________ >> >> > Hi Pat, > > Yes, application.rb appears to be getting loaded twice. Things are fine > when the before_filter is being called from the UsersController: > > class UsersController < ApplicationController > > before_filter :foo > > puts "#{__FILE__} loaded " + Time.now.to_s > > > /opt/local/bin/ruby -S script/spec -O spec/spec.opts > spec/controllers/users_controller_spec.rb > /Users/matt/test/app/controllers/users_controller.rb loaded Tue Jun 03 > 19:20:44 -0700 2008 > ................................... > > Finished in 0.256665 seconds > > 35 examples, 0 failures > > however, when that filter macro is moved to application.rb: > > class ApplicationController < ActionController::Base > helper :all # include all helpers, all the time > > before_filter :foo > > puts "#{__FILE__} loaded " + Time.now.to_s > > here's what happens: > > /opt/local/bin/ruby -S script/spec -O spec/spec.opts > spec/controllers/users_routing_spec.rb > spec/controllers/users_controller_spec.rb > /Users/matt/test/app/controllers/application.rb loaded Tue Jun 03 19:23:32 > -0700 2008 > /Users/matt/test/app/controllers/application.rb loaded Tue Jun 03 19:23:32 > -0700 2008 > ..........................................F..... > > 1) > Spec::Mocks::MockExpectationError in 'UsersController handling GET > /users.xml should call foo via a before filter' > Mock 'UsersController' expected :foo with (any args) once, but received it > twice > script/spec:4: > > Finished in 0.2891 seconds > > 48 examples, 1 failure Do you require application.rb from anywhere, but including the whole path? i.e. require File.join(RAILS_ROOT, "app", "controllers", "application"). If you require the same file twice, but using two different paths, then it'll be loaded twice. This may happen from a plugin you've got loaded as well. Another thing to check is the paths in your generated specs. I changed those a couple weeks ago, but to avoid this type of problem. I may have screwed up, or perhaps you've got a mix of requires from older gen'd specs and newer ones. Pat From hans at degraaff.org Wed Jun 4 01:18:03 2008 From: hans at degraaff.org (Hans de Graaff) Date: Wed, 04 Jun 2008 07:18:03 +0200 Subject: [rspec-users] autotest only passing spec files to rspec once In-Reply-To: <9adb5a83daf8fec81cd55225200e5433@ruby-forum.com> References: <9adb5a83daf8fec81cd55225200e5433@ruby-forum.com> Message-ID: <1212556683.29530.2.camel@ip6-localhost> On Fri, 2008-04-11 at 17:16 +0200, Andy Orahood wrote: > When I run autotest it works fine the first time, generating the command > line: > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts > spec/models/timespan_spec.rb spec/models/article_spec.rb ... spec files> > > and all my specs get run. After the first runthrough, however, autotest > pauses for a second and then, without me saving any files, generates > another command line without any of the spec files: > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts This happens because a file got saved that did not match a pattern that autotest can handle. It may even be your test.log. Run 'autotest -v' to see what is really going on and add_exception in the autotest initialize hook to avoid checking those files. Arguably autotest shouldn't even do this empty run when it doesn't find any matching files. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: From hans at degraaff.org Wed Jun 4 01:26:15 2008 From: hans at degraaff.org (Hans de Graaff) Date: Wed, 04 Jun 2008 07:26:15 +0200 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> Message-ID: <1212557175.29530.8.camel@ip6-localhost> On Tue, 2008-04-01 at 08:48 +0100, Ashley Moran wrote: > > Hmm, exact same revision as me. Are we the only one s having > problems? I've also noticed errors along the lines of > "ActionController not found" and "expected XXX to respond to > respond_to?" (or something - that from the developer that sits behind > me). We are seeing the exact same thing with Zentest 3.9.2 and RSpec 1.1.4. The thing I noticed yesterday is that autotest seems to want to run the model or controller directly instead of the spec file, just like in Ashley's original mail. Obviously this leads to an error because that doesn't load spec_helper which in turn doesn't load the rails framework. Presto: ActiveRecord has not been initialized. The real question is: why is autotest running specs with the wrong names? Did anyone resolve this yet? Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: From nabble at mattmcneil.org Wed Jun 4 03:37:50 2008 From: nabble at mattmcneil.org (Matt McNeil) Date: Wed, 4 Jun 2008 00:37:50 -0700 (PDT) Subject: [rspec-users] controller filters running twice in 1.1.4? In-Reply-To: <810a540e0806031907q60c4fr9c0ac2d45f5cb088@mail.gmail.com> References: <17629653.post@talk.nabble.com> <810a540e0806031907q60c4fr9c0ac2d45f5cb088@mail.gmail.com> Message-ID: <17640917.post@talk.nabble.com> Pat Maddox wrote: > > On Tue, Jun 3, 2008 at 5:31 PM, Matt McNeil wrote: >> >> since upgrading to 1.1.4 (I had been running without issue on a git >> snapshot), I'm noticing that my filter actions initiated from >> application.rb >> seem to be running twice. I created a test rails project with the rspec >> scaffold and am also seeing the same behavior here too. >> >> Adding this code to application.rb: >> >> before_filter :foo >> >> def foo >> "foo" >> end >> >> and an example in users_controller_spec.rb: >> >> it "should call foo via a before filter" do >> controller.should_receive(:foo) >> do_get >> end >> >> results in this: >> >> 1) >> Spec::Mocks::MockExpectationError in 'UsersController handling GET >> /users.xml should call foo' >> Mock 'UsersController' expected :foo with (any args) once, but received >> it >> twice >> script/spec:4: >> >> Is any one else seeing this? > > Can you put a print statement inside application.rb to see if the file > itself is being loaded multiple times? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > Application.rb (and the method called by the before filter) only seem to be loaded twice when they're being run with autotest/spec. To reproduce what I'm showing here: $ rails -v Rails 2.1.0 rails test cd test script/plugin install git://github.com/dchelimsky/rspec.git script/plugin install git://github.com/dchelimsky/rspec-rails.git script/generate rspec rsg rspec_scaffold User name:string then add the before_filter :foo to application.rb, the foo method to users_controller.rb, and the example to users_controller_spec.rb. then: $ /opt/local/bin/ruby -S script/spec -O spec/spec.opts spec/controllers/users_controller_spec.rb ..................................F 1) Spec::Mocks::MockExpectationError in 'UsersController handling GET /users should call foo via a before filter' Mock 'UsersController' expected :foo with (any args) once, but received it twice script/spec:4: Finished in 0.252162 seconds 35 examples, 1 failure -- View this message in context: http://www.nabble.com/controller-filters-running-twice-in-1.1.4--tp17629653p17640917.html Sent from the rspec-users mailing list archive at Nabble.com. From self at mattmower.com Wed Jun 4 04:20:43 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 09:20:43 +0100 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: <1212557175.29530.8.camel@ip6-localhost> References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> <1212557175.29530.8.camel@ip6-localhost> Message-ID: On Wed, Jun 4, 2008 at 6:26 AM, Hans de Graaff wrote: > On Tue, 2008-04-01 at 08:48 +0100, Ashley Moran wrote: >> Hmm, exact same revision as me. Are we the only one s having >> problems? I've also noticed errors along the lines of >> "ActionController not found" and "expected XXX to respond to >> respond_to?" (or something - that from the developer that sits behind >> me). > > We are seeing the exact same thing with Zentest 3.9.2 and RSpec 1.1.4. Oh thank goodness, it's not me. I am seeing the same kinds of weirdness too, but only since I upgraded to Rails 2.1 I'm kinda new to RSpec so I wasn't sure if it was something i was doing. In the meantime I've been trying to figure out whether 1.1.4 is the right version of RSpec to run against 2.1. > The thing I noticed yesterday is that autotest seems to want to run the > model or controller directly instead of the spec file, just like in > Ashley's original mail. Obviously this leads to an error because that > doesn't load spec_helper which in turn doesn't load the rails framework. > Presto: ActiveRecord has not been initialized. > Ah, that makes sense. > The real question is: why is autotest running specs with the wrong > names? Did anyone resolve this yet? > One thing I've noticed is that it never seems to do it from a fresh run (either when you start autotest or hit Ctrl+C), only when it re-runs a changed spec. And not every time, only occasionally. I've started running autotest with the -v option to try and figure out what it's doing. Regards, Matt -- Matt Mower :: http://matt.blogs.it/ From self at mattmower.com Wed Jun 4 04:25:55 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 09:25:55 +0100 Subject: [rspec-users] controller filters running twice in 1.1.4? In-Reply-To: <810a540e0806032029q13addaaeq760787843144288f@mail.gmail.com> References: <17629653.post@talk.nabble.com> <810a540e0806031907q60c4fr9c0ac2d45f5cb088@mail.gmail.com> <17637883.post@talk.nabble.com> <810a540e0806032029q13addaaeq760787843144288f@mail.gmail.com> Message-ID: On Wed, Jun 4, 2008 at 4:29 AM, Pat Maddox wrote: > On Tue, Jun 3, 2008 at 7:27 PM, Matt McNeil wrote: >> Yes, application.rb appears to be getting loaded twice. Things are fine >> when the before_filter is being called from the UsersController: >> >> class UsersController < ApplicationController >> > Do you require application.rb from anywhere, but including the whole > path? i.e. require File.join(RAILS_ROOT, "app", "controllers", > "application"). If you require the same file twice, but using two > different paths, then it'll be loaded twice. > > This may happen from a plugin you've got loaded as well. > I've been seeing the same problem. In my case the symptom was a warning about redefining a constant I have in ApplicationController. I checked across my application and the only places I see application being required (outside vendor/rails) are script/spec_server (and it's template) and rspec-rails/lib/spec/rails.rb. > Another thing to check is the paths in your generated specs. I > changed those a couple weeks ago, but to avoid this type of problem. > I may have screwed up, or perhaps you've got a mix of requires from > older gen'd specs and newer ones. > I'm not sure what "paths in your generated specs" means to check this myself. Regards, Matt -- Matt Mower :: http://matt.blogs.it/ From dchelimsky at gmail.com Wed Jun 4 04:26:05 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Jun 2008 03:26:05 -0500 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> <1212557175.29530.8.camel@ip6-localhost> Message-ID: On Jun 4, 2008, at 3:20 AM, Matt Mower wrote: > On Wed, Jun 4, 2008 at 6:26 AM, Hans de Graaff > wrote: >> On Tue, 2008-04-01 at 08:48 +0100, Ashley Moran wrote: >>> Hmm, exact same revision as me. Are we the only one s having >>> problems? I've also noticed errors along the lines of >>> "ActionController not found" and "expected XXX to respond to >>> respond_to?" (or something - that from the developer that sits >>> behind >>> me). >> >> We are seeing the exact same thing with Zentest 3.9.2 and RSpec >> 1.1.4. > > Oh thank goodness, it's not me. I am seeing the same kinds of > weirdness too, but only since I upgraded to Rails 2.1 > > I'm kinda new to RSpec so I wasn't sure if it was something i was > doing. In the meantime I've been trying to figure out whether 1.1.4 is > the right version of RSpec to run against 2.1. > >> The thing I noticed yesterday is that autotest seems to want to run >> the >> model or controller directly instead of the spec file, just like in >> Ashley's original mail. Obviously this leads to an error because that >> doesn't load spec_helper which in turn doesn't load the rails >> framework. >> Presto: ActiveRecord has not been initialized. >> > > Ah, that makes sense. > >> The real question is: why is autotest running specs with the wrong >> names? Did anyone resolve this yet? >> > > One thing I've noticed is that it never seems to do it from a fresh > run (either when you start autotest or hit Ctrl+C), only when it > re-runs a changed spec. And not every time, only occasionally. > > I've started running autotest with the -v option to try and figure out > what it's doing. I've got it figured out. Fix coming shortly (like in 10 minutes) > > > Regards, > > Matt > > -- > Matt Mower :: http://matt.blogs.it/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Jun 4 04:37:26 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Jun 2008 03:37:26 -0500 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> <1212557175.29530.8.camel@ip6-localhost> Message-ID: On Jun 4, 2008, at 3:26 AM, David Chelimsky wrote: > > On Jun 4, 2008, at 3:20 AM, Matt Mower wrote: > >> On Wed, Jun 4, 2008 at 6:26 AM, Hans de Graaff >> wrote: >>> On Tue, 2008-04-01 at 08:48 +0100, Ashley Moran wrote: >>>> Hmm, exact same revision as me. Are we the only one s having >>>> problems? I've also noticed errors along the lines of >>>> "ActionController not found" and "expected XXX to respond to >>>> respond_to?" (or something - that from the developer that sits >>>> behind >>>> me). >>> >>> We are seeing the exact same thing with Zentest 3.9.2 and RSpec >>> 1.1.4. >> >> Oh thank goodness, it's not me. I am seeing the same kinds of >> weirdness too, but only since I upgraded to Rails 2.1 >> >> I'm kinda new to RSpec so I wasn't sure if it was something i was >> doing. In the meantime I've been trying to figure out whether 1.1.4 >> is >> the right version of RSpec to run against 2.1. >> >>> The thing I noticed yesterday is that autotest seems to want to >>> run the >>> model or controller directly instead of the spec file, just like in >>> Ashley's original mail. Obviously this leads to an error because >>> that >>> doesn't load spec_helper which in turn doesn't load the rails >>> framework. >>> Presto: ActiveRecord has not been initialized. >>> >> >> Ah, that makes sense. >> >>> The real question is: why is autotest running specs with the wrong >>> names? Did anyone resolve this yet? >>> >> >> One thing I've noticed is that it never seems to do it from a fresh >> run (either when you start autotest or hit Ctrl+C), only when it >> re-runs a changed spec. And not every time, only occasionally. >> >> I've started running autotest with the -v option to try and figure >> out >> what it's doing. > > I've got it figured out. Fix coming shortly (like in 10 minutes) I believe this is now fixed in http://github.com/dchelimsky/rspec/commit/2b474ac . If any of you can still reproduce this, please let me know. Cheers, David From self at mattmower.com Wed Jun 4 04:47:52 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 09:47:52 +0100 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> <1212557175.29530.8.camel@ip6-localhost> Message-ID: On Wed, Jun 4, 2008 at 9:37 AM, David Chelimsky wrote: >> I've got it figured out. Fix coming shortly (like in 10 minutes) > > > I believe this is now fixed in > http://github.com/dchelimsky/rspec/commit/2b474ac. > > If any of you can still reproduce this, please let me know. > That's quick work David, thanks ;-) I'm still not entirely sure which version of rspec I should be running for Rails 2.1. Is edge a reasonable safe choice? Should I stick with 1.1.4 and wait for 1.1.5. I'm not sure how to make this judgement. Regards, Matt -- Matt Mower :: http://matt.blogs.it/ From dchelimsky at gmail.com Wed Jun 4 04:58:42 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Jun 2008 03:58:42 -0500 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> <1212557175.29530.8.camel@ip6-localhost> Message-ID: On Jun 4, 2008, at 3:47 AM, Matt Mower wrote: > On Wed, Jun 4, 2008 at 9:37 AM, David Chelimsky > wrote: >>> I've got it figured out. Fix coming shortly (like in 10 minutes) >> >> >> I believe this is now fixed in >> http://github.com/dchelimsky/rspec/commit/2b474ac. >> >> If any of you can still reproduce this, please let me know. >> > > That's quick work David, thanks ;-) > > I'm still not entirely sure which version of rspec I should be running > for Rails 2.1. Is edge a reasonable safe choice? Should I stick with > 1.1.4 and wait for 1.1.5. I'm not sure how to make this judgement. There is some broken story stuff in edge right now that will get fixed in the next day or so. If you're not using plain text stories, just grab that. You could always grab the repo, make a 1.1.4 branch and cherry pick this commit. git clone git://github.com/dchelimsky/rspec.git git checkout -b 1.1.4 git cherry-pick 2b474ac78ad877c13d577490b16f4f3380944e83 Sadly there is a conflict in the CHANGES file, but it's easily fixed. After you resolve the conflict .... git add . git commit -c 2b474ac Cheers, David From self at mattmower.com Wed Jun 4 05:19:13 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 10:19:13 +0100 Subject: [rspec-users] any_instance Message-ID: Hi folks. I'm very interested in the status of a port of any_instance from Mocha to RSpec. In particular I have a spec suite that I wrote using RSpec but with Mocha that depends heavily on any_instance. This is because it stubs out one or two methods from an underlying API. In attempting to convert the suite to RSpec mocks (because that's what we're using for the rest of the project) I had to give up. Attempting to replace objects by stubbing :new and returning mocks felt like a huge amount of busy work compared to one-line with any_instance. I noticed that Brian Takita appears to have an implementation of any_instance here: http://github.com/btakita/pain-point/tree/ca9a65e7110ccaa37175c741e1cea1aaa9776180/vendor/plugins/rspec/lib/spec/mocks which I tried, without success, to make work in my own version of rspec (1.1.4). I was able to call any_instance but it didn't seem to be having an effect. I emailed Brian but I think he was at rails conf so I guess he may be fighting a backlog of work/email. Is there any likelyhood of any_instance making it into RSpec proper? If not, has anyone else had any luck implementing it? Regards, Matt. -- Matt Mower :: http://matt.blogs.it/ From raasdnil at gmail.com Wed Jun 4 07:10:38 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Wed, 4 Jun 2008 21:10:38 +1000 Subject: [rspec-users] Why has the --color gone from my life? Message-ID: <57a815bf0806040410l4cec192ex43bc301d695e27ad@mail.gmail.com> Hi all, Running on OSX 10.5.3, Latest Rspec trunk, Rspec rails trunk, latest autotest gem and rails 2.1 I've lost my colour output in autotest. rake spec gives colour output, but autotest gives me black and white. It was working a little bit before, I think I upgraded to the latest versions of everything to get all the textmate snippets talking and being friendly to one another again after I upgraded Ruby from the shipped 111 patch level to 114. Not mission critical, but annoying :) I mean... without it, you can only aim for "All specs grey!" which doesn't quite sound as good. Anyone have any pointers? Mikel -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhennemeyer at googlemail.com Wed Jun 4 08:04:10 2008 From: mhennemeyer at googlemail.com (Matthias Hennemeyer) Date: Wed, 4 Jun 2008 14:04:10 +0200 Subject: [rspec-users] != again In-Reply-To: <810a540e0806021101o7f0e2363jdb345f03063352f1@mail.gmail.com> References: <34D041B6-6D30-4142-AFE9-62687D456E31@googlemail.com> <810a540e0806021101o7f0e2363jdb345f03063352f1@mail.gmail.com> Message-ID: <1B38F4F1-266E-4F23-95B6-99A54B29530C@googlemail.com> Am 02.06.2008 um 20:01 schrieb Pat Maddox: >> > > What about showing an ugly warning in the test runner? != is a funky > edge case that can really bite people. It'd be nice to have it fixed, > but then tell the programmer to change it to == because of > performance. > > Pat > ______________________________________________ The performance is much better now - but that warning thing is interesting. I think people should be able to decide if they use != or not and there should be an option that, when applied, turns out warnings and enables 'negative operator expectations'. One more word on performance: It is possible to see the difference in performance of both versions (with source inspect and without). But only if you run benchmarks that are exclusivley designed for this purpose. Running the rspec spec suite for both versions doesn't show any difference. Matthias -------------- next part -------------- An HTML attachment was scrubbed... URL: From mattlins at gmail.com Wed Jun 4 09:06:56 2008 From: mattlins at gmail.com (Matthew Lins) Date: Wed, 04 Jun 2008 08:06:56 -0500 Subject: [rspec-users] Mock with an attributes that has state Message-ID: I'm developing a rails application. I have an Order model that has_many OrderItems. I mocked the OrderItem model in my Order specs using mock_model. I thought I should focus my specs on each model and always mock associated models. In my Order model I need a way to merge OrderItems which have the same cost and same product_id. That I can spec. The other thing this merge helper function should do is increment the quantity of the merged OrderItems. Below @order_item1 and @order_item4 would be merged into one item with a quantity of 2. Here are my OrderItems mocks: @order_item1 = mock_model(OrderItem, :valid? => true, :product_id => 1, :cost => 1, :null_object => true) @order_item2 = mock_model(OrderItem, :valid? => true, :product_id => 1, :cost => 2, :null_object => true) @order_item3 = mock_model(OrderItem, :valid? => true, :product_id => 2, :cost => 1, :null_object => true) @order_item4 = mock_model(OrderItem, :valid? => true, :product_id => 1, :cost => 1, :null_object => true) Here is the spec I wrote to check for the quantity: it "should increment the quanity of the merged items" do lambda { @order.valid? }.should change(@order_item1, :quantity).from(1).to(2) end How do I create an attribute for 'quantity' that has state on my OrderItem mocks? I realize I could do this differently and just do a should_receive on the OrderItem, looking for '+=' or something, but that doesn't feel right. I don't care how it's incremented, I just want to make sure it's changed. Thanks, Matt From self at mattmower.com Wed Jun 4 09:15:21 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 14:15:21 +0100 Subject: [rspec-users] Not running correct specs under autotest: Message-ID: I know this isn't autotest-users but I'm not sure where else to bring this up: [["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 +0100 2008]] [["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 +0100 2008]] /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S script/spec -O spec/spec.opts spec/models/user_spec.rb I had saved 'contents_controller.rb' but it did not decide to re-run the 'contents_controller_spec.rb' only 'user_spec.rb' (which has a failing spec so is probably held over from the previous runs). If I ctrl+c to run all specs it runs the controller spec again. If I resave the controller the change is again detected but the spec is not run. I'm using Rails 2.1, edge rspec & rspec-rails, and ZenTest 3.9.2 Anyone else seen this? Matt. -- Matt Mower :: http://matt.blogs.it/ From dchelimsky at gmail.com Wed Jun 4 09:18:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Jun 2008 08:18:03 -0500 Subject: [rspec-users] Not running correct specs under autotest: In-Reply-To: References: Message-ID: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> On Jun 4, 2008, at 8:15 AM, Matt Mower wrote: > I know this isn't autotest-users but I'm not sure where else to > bring this up: > > [["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 > +0100 2008]] > [["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 > +0100 2008]] > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S > script/spec -O spec/spec.opts spec/models/user_spec.rb > > I had saved 'contents_controller.rb' but it did not decide to re-run > the 'contents_controller_spec.rb' only 'user_spec.rb' (which has a > failing spec so is probably held over from the previous runs). If I > ctrl+c to run all specs it runs the controller spec again. If I resave > the controller the change is again detected but the spec is not run. > > I'm using Rails 2.1, edge rspec & rspec-rails, and ZenTest 3.9.2 > > Anyone else seen this? This just got fixed a few hours ago. Grab the latest from git:// github.com/dchelimsky/rspec.git. Cheers, David From dchelimsky at gmail.com Wed Jun 4 09:24:00 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Jun 2008 08:24:00 -0500 Subject: [rspec-users] any_instance In-Reply-To: References: Message-ID: <94D46FFB-24CD-45E1-A4B4-04FE966F0440@gmail.com> On Jun 4, 2008, at 4:19 AM, Matt Mower wrote: > Hi folks. > > I'm very interested in the status of a port of any_instance from > Mocha to RSpec. > > In particular I have a spec suite that I wrote using RSpec but with > Mocha that depends heavily on any_instance. This is because it stubs > out one or two methods from an underlying API. In attempting to > convert the suite to RSpec mocks (because that's what we're using for > the rest of the project) I had to give up. Attempting to replace > objects by stubbing :new and returning mocks felt like a huge amount > of busy work compared to one-line with any_instance. > > I noticed that Brian Takita appears to have an implementation of > any_instance here: > > http://github.com/btakita/pain-point/tree/ca9a65e7110ccaa37175c741e1cea1aaa9776180/vendor/plugins/rspec/lib/spec/mocks > > which I tried, without success, to make work in my own version of > rspec (1.1.4). I was able to call any_instance but it didn't seem to > be having an effect. I emailed Brian but I think he was at rails conf > so I guess he may be fighting a backlog of work/email. > > Is there any likelyhood of any_instance making it into RSpec proper? > If not, has anyone else had any luck implementing it? There was an implementation of it that didn't quite work for me in http://github.com/dchelimsky/rspec/commit/45a6837 so we reverted it. I have zero personal interest in this feature (use of which I find to be an anti-pattern) but am open to applying a patch as long as it meets criteria described in http://rspec.lighthouseapp.com/projects/5645/tickets/28 . Until such a patch comes my way, you can re-apply the existing patch (probably have to use git-format patch and tweak some things - any git- pros got advice on the best way to do that?) and it should work for most cases for you. Cheers, David From self at mattmower.com Wed Jun 4 09:33:29 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 14:33:29 +0100 Subject: [rspec-users] Not running correct specs under autotest: In-Reply-To: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> References: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> Message-ID: On Wed, Jun 4, 2008 at 2:18 PM, David Chelimsky wrote: > This just got fixed a few hours ago. Grab the latest from > git://github.com/dchelimsky/rspec.git. > Edge moves fast, I only installed it 3.5hrs ago ;-) Keeping up is awkward because my project is currently still using Subversion and I've not found a good way of managing Git externals in this setup. Another argument for switching the project to Git I guess... Thanks David. M. -- Matt Mower :: http://matt.blogs.it/ From self at mattmower.com Wed Jun 4 09:40:21 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 14:40:21 +0100 Subject: [rspec-users] any_instance In-Reply-To: <94D46FFB-24CD-45E1-A4B4-04FE966F0440@gmail.com> References: <94D46FFB-24CD-45E1-A4B4-04FE966F0440@gmail.com> Message-ID: Hi David. On Wed, Jun 4, 2008 at 2:24 PM, David Chelimsky wrote: > There was an implementation of it that didn't quite work for me in > http://github.com/dchelimsky/rspec/commit/45a6837 so we reverted it. I have > zero personal interest in this feature (use of which I find to be an > anti-pattern) but am open to applying a patch as long as it meets criteria > described in http://rspec.lighthouseapp.com/projects/5645/tickets/28. > I've read the ticket, I was hoping it would explain why you feel any_instance is an anti-pattern. In my situation I am spec'ing a library that depends upon a lower-level for network operations. I use any_instance at certain points to simulate data coming from the network. Trying to stub :new and return a mock was very problematic for me because the object involved does some work with the data which my code depends upon for it's own behaviour. Hence to test that I end up having to do a lot of work in my mocks and it quickly becomes cumbersome. What I really wanted was the "genuine" object with some behaviour changed which is what any_instance gives me. I tried searching the archives of this list but couldn't find an article where you (or anyone else) expands on this view about any_instance. And thanks for the pointer, I guess I will try and assemble the patch and see if I can make it work. Regards, Matt. -- Matt Mower :: http://matt.blogs.it/ From self at mattmower.com Wed Jun 4 09:42:24 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 14:42:24 +0100 Subject: [rspec-users] Not running correct specs under autotest: In-Reply-To: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> References: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> Message-ID: On Wed, Jun 4, 2008 at 2:18 PM, David Chelimsky wrote: > This just got fixed a few hours ago. Grab the latest from > git://github.com/dchelimsky/rspec.git. > It's not fixed for me. My copy of rspec was installed after the commit that closes #369. regards, Matt. -- Matt Mower :: http://matt.blogs.it/ From self at mattmower.com Wed Jun 4 09:44:08 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 14:44:08 +0100 Subject: [rspec-users] Not running correct specs under autotest: In-Reply-To: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> References: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> Message-ID: On Wed, Jun 4, 2008 at 2:18 PM, David Chelimsky wrote: > > On Jun 4, 2008, at 8:15 AM, Matt Mower wrote: > >> I know this isn't autotest-users but I'm not sure where else to bring this >> up: >> >> [["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 +0100 >> 2008]] >> [["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 +0100 >> 2008]] >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S >> script/spec -O spec/spec.opts spec/models/user_spec.rb >> >> I had saved 'contents_controller.rb' but it did not decide to re-run >> the 'contents_controller_spec.rb' only 'user_spec.rb' (which has a >> failing spec so is probably held over from the previous runs). If I >> ctrl+c to run all specs it runs the controller spec again. If I resave >> the controller the change is again detected but the spec is not run. >> >> I'm using Rails 2.1, edge rspec & rspec-rails, and ZenTest 3.9.2 >> >> Anyone else seen this? > > This just got fixed a few hours ago. Grab the latest from > git://github.com/dchelimsky/rspec.git. > Your last fix does seem to have fixed the problem of getting ActiveRecord::Base not found, etc... which was due to autotest running the controller or model as a spec. This problem is different, it's reporting that the controller has changed *but not running the associated spec*. Hope that helps. Matt. -- Matt Mower :: http://matt.blogs.it/ From dchelimsky at gmail.com Wed Jun 4 10:06:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Jun 2008 09:06:25 -0500 Subject: [rspec-users] Not running correct specs under autotest: In-Reply-To: References: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> Message-ID: <80418110-A836-4D09-90C3-C04BA3609DC4@gmail.com> On Jun 4, 2008, at 8:33 AM, Matt Mower wrote: > On Wed, Jun 4, 2008 at 2:18 PM, David Chelimsky > wrote: >> This just got fixed a few hours ago. Grab the latest from >> git://github.com/dchelimsky/rspec.git. >> > > Edge moves fast, I only installed it 3.5hrs ago ;-) I wish it moved faster - this one's been sitting around for a bit. > Keeping up is awkward because my project is currently still using > Subversion and I've not found a good way of managing Git externals in > this setup. Rails 2.1 supports plugins from git. Are you using an older version of rails (come on - 2.1 has been out for 3 days already!). If you are, just follow directions at http://github.com/dchelimsky/rspec-rails/ wikis. Cheers, David From self at mattmower.com Wed Jun 4 10:14:14 2008 From: self at mattmower.com (Matt Mower) Date: Wed, 4 Jun 2008 15:14:14 +0100 Subject: [rspec-users] Not running correct specs under autotest: In-Reply-To: <80418110-A836-4D09-90C3-C04BA3609DC4@gmail.com> References: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> <80418110-A836-4D09-90C3-C04BA3609DC4@gmail.com> Message-ID: On Wed, Jun 4, 2008 at 3:06 PM, David Chelimsky wrote: > I wish it moved faster - this one's been sitting around for a bit. > ;-) > Rails 2.1 supports plugins from git. Are you using an older version of rails > (come on - 2.1 has been out for 3 days already!). If you are, just follow > directions at http://github.com/dchelimsky/rspec-rails/wikis. > Yep 2.1 and I used script/plugin to install from git this time. That's new again to me since I've been using piston for quite a while (or submodules with a git based project). The new, git compatible, "script/plugin update" takes care of the details? M. -- Matt Mower :: http://matt.blogs.it/ From dchelimsky at gmail.com Wed Jun 4 10:16:07 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Jun 2008 09:16:07 -0500 Subject: [rspec-users] Not running correct specs under autotest: In-Reply-To: References: <48D0EF55-19E2-45C1-A09B-3CFF11F445FA@gmail.com> <80418110-A836-4D09-90C3-C04BA3609DC4@gmail.com> Message-ID: <1C868A85-3C39-4A9A-B729-5676FBACFF57@gmail.com> On Jun 4, 2008, at 9:14 AM, Matt Mower wrote: > On Wed, Jun 4, 2008 at 3:06 PM, David Chelimsky > wrote: >> I wish it moved faster - this one's been sitting around for a bit. >> > > ;-) > >> Rails 2.1 supports plugins from git. Are you using an older version >> of rails >> (come on - 2.1 has been out for 3 days already!). If you are, just >> follow >> directions at http://github.com/dchelimsky/rspec-rails/wikis. >> > > Yep 2.1 and I used script/plugin to install from git this time. That's > new again to me since I've been using piston for quite a while (or > submodules with a git based project). The new, git compatible, > "script/plugin update" takes care of the details? I haven't tried update (I usually run a bash script to update from my local repo - I pretty much always have the latest). From duelin.markers at gmail.com Wed Jun 4 10:50:45 2008 From: duelin.markers at gmail.com (John D. Hume) Date: Wed, 4 Jun 2008 10:50:45 -0400 Subject: [rspec-users] Mock with an attributes that has state In-Reply-To: References: Message-ID: On Wed, Jun 4, 2008 at 9:06 AM, Matthew Lins wrote: > I realize I could do this differently and just do a should_receive on the > OrderItem, looking for '+=' or something, but that doesn't feel right. I know this isn't what you're looking for, but note that whether you do: item.quantity = item.quantity + other_item.quantity or item.quantity += other_item.quantity the sequence of calls to item will be the same: first item.quantity, then item.quantity=, with + being sent to the return value of item.quantity in between. To try and help with what you're actually trying to do, I think you could define a singleton method on your mocked model. class << @order_item1 attr_accessor :quantity end but that's smelly. It feels to me like the logic for rolling one item into another belongs in OrderItem. So maybe instead your order spec turns out to be something like: @order_item1.should_receive(:merge).with(@order_item4) If the logic for determining whether to merge also moved into OrderItem, Order (and its spec) could forget about all the attributes of OrderItem. -hume. From mattlins at gmail.com Wed Jun 4 13:30:48 2008 From: mattlins at gmail.com (Matthew Lins) Date: Wed, 04 Jun 2008 12:30:48 -0500 Subject: [rspec-users] Mock with an attributes that has state In-Reply-To: Message-ID: Thanks John. Yes, I think I'm violating TDA with that merge helper sitting in order. But, it can't really sit in OrderItem. I think it'll have to sit on the association proxy. And, I'm assuming that would be tested by an integration test? I think your singleton class on the mock would work too, but you're right it is messy. I was wondering if there was something built in. Time to redesign! > From: "John D. Hume" > Reply-To: rspec-users > Date: Wed, 4 Jun 2008 10:50:45 -0400 > To: rspec-users > Subject: Re: [rspec-users] Mock with an attributes that has state > > On Wed, Jun 4, 2008 at 9:06 AM, Matthew Lins wrote: >> I realize I could do this differently and just do a should_receive on the >> OrderItem, looking for '+=' or something, but that doesn't feel right. > > I know this isn't what you're looking for, but note that whether you do: > item.quantity = item.quantity + other_item.quantity > or > item.quantity += other_item.quantity > the sequence of calls to item will be the same: first item.quantity, > then item.quantity=, with + being sent to the return value of > item.quantity in between. > > To try and help with what you're actually trying to do, I think you > could define a singleton method on your mocked model. > class << @order_item1 > attr_accessor :quantity > end > but that's smelly. > > It feels to me like the logic for rolling one item into another > belongs in OrderItem. So maybe instead your order spec turns out to be > something like: > @order_item1.should_receive(:merge).with(@order_item4) > If the logic for determining whether to merge also moved into > OrderItem, Order (and its spec) could forget about all the attributes > of OrderItem. > > -hume. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Wed Jun 4 22:05:30 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 4 Jun 2008 22:05:30 -0400 Subject: [rspec-users] any_instance In-Reply-To: References: <94D46FFB-24CD-45E1-A4B4-04FE966F0440@gmail.com> Message-ID: <2A25DACC-0E70-45F5-AB2E-7A3423A1ED19@railsnewbie.com> On Jun 4, 2008, at 9:40 AM, Matt Mower wrote: > Hi David. > > On Wed, Jun 4, 2008 at 2:24 PM, David Chelimsky > wrote: >> There was an implementation of it that didn't quite work for me in >> http://github.com/dchelimsky/rspec/commit/45a6837 so we reverted >> it. I have >> zero personal interest in this feature (use of which I find to be an >> anti-pattern) but am open to applying a patch as long as it meets >> criteria >> described in http://rspec.lighthouseapp.com/projects/5645/tickets/28. >> > > I've r