From dchelimsky at gmail.com Fri May 1 00:28:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 23:28:07 -0500 Subject: [rspec-users] script/general rspec_* In-Reply-To: <632154f70904300657k380a72eakd2a71814b016e54d@mail.gmail.com> References: <632154f70904300619o4987d05ake1ca1804a4dfc1b4@mail.gmail.com> <57c63afe0904300624n714d353i57c32db7a402e0a2@mail.gmail.com> <632154f70904300657k380a72eakd2a71814b016e54d@mail.gmail.com> Message-ID: <57c63afe0904302128m32f22bd0pbcbfc7d66c1560ff@mail.gmail.com> On Thu, Apr 30, 2009 at 8:57 AM, Nicholas Van Weerdenburg wrote: > On Thu, Apr 30, 2009 at 9:24 AM, David Chelimsky > wrote: >> >> On Thu, Apr 30, 2009 at 8:19 AM, Nicholas Van Weerdenburg >> wrote: >> > I have started using rspec after generating much of my applications >> > models >> > and controllers. Much of the code is plain vanilla scaffolding. >> > I accept that this is not very BDD, but I'm building a tool that >> > required I >> > do this. >> > Is there a quick way to generate the test stubs- i.e. the equivalent of >> > the >> > Test::Unit ones I now have? Can I run "script/generate rspec_model >> > " >> > and the same for controllers on over-top of things? >> >> $ script/generate >> .... >> Installed Generators >> ?Rubygems: acts_as_taggable_on_migration, cucumber, feature, >> install_rubigen_scripts, rspec, rspec_controller, rspec_model, >> rspec_scaffold, session >> ?Builtin: controller, helper, integration_test, mailer, metal, >> migration, model, observer, performance_test, plugin, resource, >> scaffold, session_migration >> >> Note rspec_controller, rspec_model, rspec_scaffold >> >> Cheers, >> David >> >> > Thanks, >> > Nick > I saw those. My question is whether they run fine if model, controller, > scaffold have already been run. No reason they shouldn't. You should get the opportunity to approve/deny any files that already exist, and the new files will just get written. Let us know if you run into any problems. Cheers, David From dchelimsky at gmail.com Fri May 1 00:29:35 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 23:29:35 -0500 Subject: [rspec-users] Partitioning Specs In-Reply-To: <632154f70904300809n4f9a4601jd75f7180319cd9b6@mail.gmail.com> References: <632154f70904300700r6af74f1by105f1de61a013bdb@mail.gmail.com> <6ffb72010904300702u6a69d7c6i2d81849d296afcbb@mail.gmail.com> <632154f70904300733u3927d85o5fcdb3423f96ddbd@mail.gmail.com> <57c63afe0904300753i11119b38l56baa99f58bf8508@mail.gmail.com> <632154f70904300809n4f9a4601jd75f7180319cd9b6@mail.gmail.com> Message-ID: <57c63afe0904302129j51425684y9b8fad5c9a0628b8@mail.gmail.com> On Thu, Apr 30, 2009 at 10:09 AM, Nicholas Van Weerdenburg wrote: > Sounds good. > So I could start tagging now, and be forward compatible. > Is there or will there be the equivalent of cucumber.yml for rspec? There isn't now. Another thing on the someday list. > Thanks, > Nick > On Thu, Apr 30, 2009 at 10:53 AM, David Chelimsky > wrote: >> >> On Thu, Apr 30, 2009 at 9:33 AM, Nicholas Van Weerdenburg >> wrote: >> > I saw that a couple of days ago- very nice. Will that be added to RSpec? >> >> Sooner or later, yes, but it will be managed through the hash passed >> to the declarations: >> >> describe "something", :tags => [:a,:b] do >> ?it "does something", :tags > [:c] do >> >> etc >> >> You can already access that options hash in custom formatters, so you >> can use this to control reporting. Next step is to use it to control >> what actually gets run. But this won't be right away. >> >> > Also, I suppose I'd have to add tags to the framework myself unless they >> > included it. >> > Thanks, >> > Nick >> > >> > On Thu, Apr 30, 2009 at 10:02 AM, Ben Lovell >> > wrote: >> >> >> >> >> >> On Thu, Apr 30, 2009 at 3:00 PM, Nicholas Van Weerdenburg >> >> wrote: >> >>> >> >>> Hi, >> >>> I installed Restful Authentication and it placed a lot of specs and >> >>> features in cucumber and rspec directories. >> >>> Is there a way frameworks can partition there tests so that "rake >> >>> spec" >> >>> doesn't run all their tests? >> >>> I've actually switched to authlogic because of this, but was curious. >> >>> Thanks, >> >>> Nick >> >> >> >> Take a look at tags: >> >> >> >> http://wiki.github.com/aslakhellesoy/cucumber/tags >> >> >> >> Regards, >> >> Ben >> >> >> >> >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri May 1 00:57:18 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 23:57:18 -0500 Subject: [rspec-users] [ANN] rspec 1.2.6 Released Message-ID: <57c63afe0904302157p1e7f9af0j686a61cea0f40bd4@mail.gmail.com> rspec version 1.2.6 has been released! Behaviour Driven Development for Ruby. Changes: ### Version 1.2.6 / 2009-04-30 * bug fixes * gem actually built with spec executable * * * * * From dchelimsky at gmail.com Fri May 1 00:57:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 23:57:29 -0500 Subject: [rspec-users] [ANN] rspec-rails 1.2.6 Released Message-ID: <57c63afe0904302157t3373efabv780526c3633296e3@mail.gmail.com> rspec-rails version 1.2.6 has been released! Behaviour Driven Development for Ruby on Rails. ### Version 1.2.6 / 2009-04-30 * bug fixes * restored rake tasks for rspec[-rails] as plugins * * * * * From josh at technicalpickles.com Fri May 1 00:57:55 2009 From: josh at technicalpickles.com (Josh Nichols) Date: Fri, 1 May 2009 00:57:55 -0400 Subject: [rspec-users] script/general rspec_* In-Reply-To: <57c63afe0904302128m32f22bd0pbcbfc7d66c1560ff@mail.gmail.com> References: <632154f70904300619o4987d05ake1ca1804a4dfc1b4@mail.gmail.com> <57c63afe0904300624n714d353i57c32db7a402e0a2@mail.gmail.com> <632154f70904300657k380a72eakd2a71814b016e54d@mail.gmail.com> <57c63afe0904302128m32f22bd0pbcbfc7d66c1560ff@mail.gmail.com> Message-ID: If its existing models you're dealing with, you probably will want to add --skip-migration. Just skip over replacing the model. - Josh On Fri, May 1, 2009 at 12:28 AM, David Chelimsky wrote: > On Thu, Apr 30, 2009 at 8:57 AM, Nicholas Van Weerdenburg > wrote: >> On Thu, Apr 30, 2009 at 9:24 AM, David Chelimsky >> wrote: >>> >>> On Thu, Apr 30, 2009 at 8:19 AM, Nicholas Van Weerdenburg >>> wrote: >>> > I have started using rspec after generating much of my applications >>> > models >>> > and controllers. Much of the code is plain vanilla scaffolding. >>> > I accept that this is not very BDD, but I'm building a tool that >>> > required I >>> > do this. >>> > Is there a quick way to generate the test stubs- i.e. the equivalent of >>> > the >>> > Test::Unit ones I now have? Can I run "script/generate rspec_model >>> > " >>> > and the same for controllers on over-top of things? >>> >>> $ script/generate >>> .... >>> Installed Generators >>> ?Rubygems: acts_as_taggable_on_migration, cucumber, feature, >>> install_rubigen_scripts, rspec, rspec_controller, rspec_model, >>> rspec_scaffold, session >>> ?Builtin: controller, helper, integration_test, mailer, metal, >>> migration, model, observer, performance_test, plugin, resource, >>> scaffold, session_migration >>> >>> Note rspec_controller, rspec_model, rspec_scaffold >>> >>> Cheers, >>> David >>> >>> > Thanks, >>> > Nick >> I saw those. My question is whether they run fine if model, controller, >> scaffold have already been run. > > No reason they shouldn't. You should get the opportunity to > approve/deny any files that already exist, and the new files will just > get written. > > Let us know if you run into any problems. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ola at eldoy.no Fri May 1 03:40:23 2009 From: ola at eldoy.no (=?ISO-8859-1?Q?Ola_Eld=F8y?=) Date: Fri, 01 May 2009 09:40:23 +0200 Subject: [rspec-users] Cucumber for testing web services? Message-ID: <49FAA767.6020009@eldoy.no> I am looking for a framework to test web services, and was wondering whether Cucumber is ready to do this "out of the box". (Or is Ruby knowledge required?. I have posted a question on Stackoverflow if anyone wants to chip in there: http://stackoverflow.com/questions/810410/test-framework-for-web-services Cheers, Ola Eld?y From matt at mattwynne.net Fri May 1 07:33:10 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 1 May 2009 12:33:10 +0100 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <74E120B8-50D1-4368-90EE-60D21EA407DD@leviston.net> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> <49F7E9E1.3080503@benmabey.com> <74E120B8-50D1-4368-90EE-60D21EA407DD@leviston.net> Message-ID: <53C09985-2B26-4781-960D-FAED3A7ED8D9@mattwynne.net> On 1 May 2009, at 03:32, Julian Leviston wrote: > Hey ben, > > Selenium is slow, and we have a lot of > Ajax, so I'm just looking at ways to speed it up. Tags will be my > first port of call and splitting out between automated and > simulated. It irks me we can't then simply run all our tests with > one simple cucumber command -we need two. It'd be nice if webrat > could switch between browser types per scenario or per feature. Sigh. Have you looked at celerity? I'm not sure if webrat has an adapter for it yet, but it's a 'headless' browser which drives a lot faster than selenium. Some people on this list are getting a lot of joy out of it. > > > Blog: http://random8.zenunit.com/ > Learn rails: http://sensei.zenunit.com/ > > On 29/04/2009, at 3:47 PM, Ben Mabey wrote: > >> Julian Leviston wrote: >>> Hey Ben, >>> >>> It'd be kinda cool if there was a sort of before and after for a >>> feature rather than each scenario. Is there? >> >> Nope. There is no before(:all) equivalent in cucumber. Just the >> Before and After hooks, which are for scenarios.. and Backgrounds >> which are just for scenarios on the given feature. >>> >>> (Rails context) We often need this. It'd be really helpful for >>> things like when we want to test about 15 things on a particular >>> web page, and they don't require fresh data. We end up with a >>> login and setup type background which gets run every time rather >>> than simply once. >> In the context of webrat a before(:all) would not help you a whole >> lot since each scenario starts with a new session (so you have to >> login each time, for example). I understand the argument for >> complex data setup though. Having the same setup ran for each >> scenario can get costly. I haven't felt enough pain though to >> really justify adding something like that. Cleanup would be messy >> because we couldn't wrap it all in a transaction AFAIK, so you >> would have to have an after(:all) like method to clean up the >> feature. For complex data that I rely on all the time I tend to >> load it once with fixtures at boot up time within env.rb. This is >> usually for look-up data... but if you were really concerned about >> record creation you could do something similar. The question is if >> the additional complexity of keeping all that global state in your >> head worth the faster execution time. For me it generally is not. >>> >>> I guess we could refactor it into a set of examples perhaps... >>> would that work? It just strikes me as quite complicated. It'd be >>> awesome if we had sub-scenarios (and they could be specified to >>> levels) ;-) Perhaps I'm just being too complicated. >> >> I would need more context to really answer your question. However, >> can I ask if your scenarios are written in a declarative or >> imperative fashion[1]? If they are written declaratively, or at >> least partly, then you can specify a lot more behavior in a step >> without adding too much noise to the scenario. Another thing I >> should point out is that you don't need to, and you shouldn't, test >> everything on the Cucumber level. For complex views, for example, >> it may be easier to do RSpec > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From korny at sietsma.com Fri May 1 08:11:26 2009 From: korny at sietsma.com (Korny Sietsma) Date: Fri, 1 May 2009 22:11:26 +1000 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <6ffb72010905010508x12b5503bn7f4acb3d727d7d35@mail.gmail.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> <49F7E9E1.3080503@benmabey.com> <74E120B8-50D1-4368-90EE-60D21EA407DD@leviston.net> <53C09985-2B26-4781-960D-FAED3A7ED8D9@mattwynne.net> <6ffb72010905010508x12b5503bn7f4acb3d727d7d35@mail.gmail.com> Message-ID: <8e15872b0905010511n3beaf73bh5052de11f786c761@mail.gmail.com> Celerity is very cool - when it works. It didn't work with out messy combination of javascript libraries, alas. (Dojo 0.4-ish for legacy bits, GWT for new bits) - apparently it will work with either of these frameworks, but for us, with both, it died mysteriously (and we gave up trying to fix it due to limited time) - Korny On Fri, May 1, 2009 at 10:08 PM, Ben Lovell wrote: > On Fri, May 1, 2009 at 12:33 PM, Matt Wynne wrote: >> >> Have you looked at celerity? I'm not sure if webrat has an adapter for it >> yet, but it's a 'headless' browser which drives a lot faster than selenium. >> Some people on this list are getting a lot of joy out of it. > > +1 to celerity. You need to jump through some hoops with JRuby/Java but it > cut the time it takes to run my features by 3-4 times almost. > > Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" From joe at josephwilk.net Fri May 1 08:51:56 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Fri, 01 May 2009 13:51:56 +0100 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <6ffb72010905010508x12b5503bn7f4acb3d727d7d35@mail.gmail.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> <49F7E9E1.3080503@benmabey.com> <74E120B8-50D1-4368-90EE-60D21EA407DD@leviston.net> <53C09985-2B26-4781-960D-FAED3A7ED8D9@mattwynne.net> <6ffb72010905010508x12b5503bn7f4acb3d727d7d35@mail.gmail.com> Message-ID: <49FAF06C.6090009@josephwilk.net> Ben Lovell wrote: > On Fri, May 1, 2009 at 12:33 PM, Matt Wynne > wrote: > > > Have you looked at celerity? I'm not sure if webrat has an adapter > for it yet, but it's a 'headless' browser which drives a lot > faster than selenium. Some people on this list are getting a lot > of joy out of it. > > > +1 to celerity. You need to jump through some hoops with JRuby/Java > but it cut the time it takes to run my features by 3-4 times almost. I would suggest taking a look at Culerity a nice wrapper for Celerity which takes the headache out of having a non JRuby app use Celerity. http://github.com/langalex/culerity/tree/master There is also a Selenium style equivalent -> WebDriver -> a headless browser. I've not got round to playing with it yet, but it looks nice http://code.google.com/p/webdriver/ -- Joseph Wilk http://blog.josephwilk.net > > Ben > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From guillaumegentil at gmail.com Fri May 1 04:14:52 2009 From: guillaumegentil at gmail.com (Thibaud Guillaume-Gentil) Date: Fri, 1 May 2009 01:14:52 -0700 (PDT) Subject: [rspec-users] spec_server not reloading model classes In-Reply-To: References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> Message-ID: On Mar 30, 1:14?am, Andrew Vit wrote: > It appears this is a bug, with an apparently simple fix in > spec_server.rb (rails 2.3 compatibility): > > https://rspec.lighthouseapp.com/projects/5645/tickets/759 > > However, now that it's reloading my app, it's not reloading the setup > from my fixture/factory gems and throwing up a bunch of errors on re- > run. (I've tried it with bothfactory_girland machinist now.) These > are required in my spec_helper.rb: > > config.gem 'notahat-machinist', :lib => 'machinist', :source => > 'http://gems.github.com' > require File.dirname(__FILE__) + '/blueprints' > > or: > > config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source > => 'http://gems.github.com' > # automatically loaded from spec/factories/*.rb > > Not sure where to look for a solution. Same problem for me with factory_girl and rspec_rails 1.2.6, work fine the first time but get a bunch of errors the second. Any solution? Thanks From matt.songkick at googlemail.com Fri May 1 09:42:42 2009 From: matt.songkick at googlemail.com (Matt Wynne) Date: Fri, 1 May 2009 14:42:42 +0100 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass Message-ID: I'm creating a class in my spec file to test out a module, but when I run the spec a second time in spec_server, I get the error above. I presume this is because rails is un-loading the class, and it's not getting re-loaded properly. Does anyone have a nice workaround for this? cheers, Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From dchelimsky at gmail.com Fri May 1 10:04:15 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 1 May 2009 09:04:15 -0500 Subject: [rspec-users] spec_server not reloading model classes In-Reply-To: References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> Message-ID: <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> On Sun, Mar 29, 2009 at 6:14 PM, Andrew Vit wrote: > It appears this is a bug, with an apparently simple fix in > spec_server.rb (rails 2.3 compatibility): > > https://rspec.lighthouseapp.com/projects/5645/tickets/759 > > However, now that it's reloading my app, it's not reloading the setup > from my fixture/factory gems and throwing up a bunch of errors on re- > run. (I've tried it with both factory_girl and machinist now.) These > are required in my spec_helper.rb: > > config.gem 'notahat-machinist', :lib => 'machinist', :source => > 'http://gems.github.com' > require File.dirname(__FILE__) + '/blueprints' > > or: > > config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source > => 'http://gems.github.com' > # automatically loaded from spec/factories/*.rb In spec_helper? > > Not sure where to look for a solution. > > > On Mar 29, 3:15?am, Andrew Vit wrote: >> On Mar 29, 1:40?am, Scott Taylor wrote: >> >> > Actually I meant poking around your app with a browser in dev mode ;) >> >> Ok, I get it, I wasn't sure what you were driving at! ;-) Yes, >> everything is reloading fine in the browser under development. >> >> > I'm pretty sure that rails will still try to run the test environment, >> > even with RAILS_ENV set to a different value, anyway. >> >> The RAILS_ENV is being set conditionally in my script files, except >> script/autospec where it isn't defined. >> ENV["RAILS_ENV"] ||= 'test' >> >> > I was thinking of any explicit requires which may occur in app/ and lib/. >> >> Nothing out of the ordinary... >> >> > AFAIK, this is more of a rails loading issue than an rspec one. >> >> I just tried this on a clean new rails app, and the reloading still >> doesn't work when running spec_server and autospec with --drb. It >> works fine when I'm not using spec_server, but then it reloads all of >> rails each time. Works fine, except when using spec_server. >> >> The rspec site says: >> [http://rspec.info/rails/runners.html] >> >> > Note that there are some classes and modules that, by default, won?t get reloaded >> > by Rails, which means they won?t be reloaded by spec_server. There are a number >> > of strategies available for coercing Rails to reload files every time in a given >> > environment. See the Rails documentation for more information. >> >> Does that include my app/models? I wouldn't have thought so... Another >> post on this mailing list seemed to suggest those don't need manual >> reloading and "just work". >> >> $ gem list rails >> rails (2.3.2) >> $ gem list rspec >> rspec (1.2.2) >> rspec-rails (1.2.2) >> $ rails test_spec_server && cd test_spec_server >> $ script/plugin install git://github.com/dchelimsky/rspec-rails.git >> $ script/generate rspec >> $ script/generate rspec_model car name:string >> # edit config/environments/test.rb => config.cache_classes = false >> # edit spec/spec.opts => --drb >> $ rake spec:server:start >> $ script/autospec >> # 1 example, 0 failures >> # edit app/models/car.rb => add invalid syntax! >> # 1 example, 0 failures >> >> Can anyone confirm/reproduce? (Or else tell me what I'm doing wrong?) >> >> Thanks, >> Andrew Vit >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri May 1 10:05:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 1 May 2009 09:05:38 -0500 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: References: Message-ID: <57c63afe0905010705i37306970i4404c02421764f0e@mail.gmail.com> On Fri, May 1, 2009 at 8:42 AM, Matt Wynne wrote: > I'm creating a class in my spec file to test out a module, but when I run > the spec a second time in spec_server, I get the error above. > > I presume this is because rails is un-loading the class, and it's not > getting re-loaded properly. > > Does anyone have a nice workaround for this? What version of rspec[-rails]? > > cheers, > Matt Wynne > http://beta.songkick.com > http://blog.mattwynne.net > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Fri May 1 11:44:33 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 01 May 2009 09:44:33 -0600 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <8e15872b0905010511n3beaf73bh5052de11f786c761@mail.gmail.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> <49F7E9E1.3080503@benmabey.com> <74E120B8-50D1-4368-90EE-60D21EA407DD@leviston.net> <53C09985-2B26-4781-960D-FAED3A7ED8D9@mattwynne.net> <6ffb72010905010508x12b5503bn7f4acb3d727d7d35@mail.gmail.com> <8e15872b0905010511n3beaf73bh5052de11f786c761@mail.gmail.com> Message-ID: <49FB18E1.7070009@benmabey.com> Korny Sietsma wrote: > Celerity is very cool - when it works. It didn't work with out messy > combination of javascript libraries, alas. (Dojo 0.4-ish for legacy > bits, GWT for new bits) - apparently it will work with either of these > frameworks, but for us, with both, it died mysteriously (and we gave > up trying to fix it due to limited time) > > - Korny > Yeah, I have had similar experiences with Celerity. To be fair, it is not Celerity's shortcoming but rather it is HTMLUnit's and Rhino's for not being able to support all the JS frameworks yet. If you don't have a legacy system though I think Celerity is the way to go for JS testing. -Ben > On Fri, May 1, 2009 at 10:08 PM, Ben Lovell wrote: > >> On Fri, May 1, 2009 at 12:33 PM, Matt Wynne wrote: >> >>> Have you looked at celerity? I'm not sure if webrat has an adapter for it >>> yet, but it's a 'headless' browser which drives a lot faster than selenium. >>> Some people on this list are getting a lot of joy out of it. >>> >> +1 to celerity. You need to jump through some hoops with JRuby/Java but it >> cut the time it takes to run my features by 3-4 times almost. >> >> Ben >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > > From matt at mattwynne.net Fri May 1 12:26:35 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 1 May 2009 17:26:35 +0100 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass Message-ID: I'm creating a class in my spec file to test out a module, but when I run the spec a second time in spec_server, I get the error above. I presume this is because rails is un-loading the class, and it's not getting re-loaded properly as it doesn't have its own file in the conventional place. Does anyone have a nice workaround for this? cheers, Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Fri May 1 12:52:29 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 1 May 2009 17:52:29 +0100 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: <57c63afe0905010705i37306970i4404c02421764f0e@mail.gmail.com> References: <57c63afe0905010705i37306970i4404c02421764f0e@mail.gmail.com> Message-ID: <9B2E2E54-21FF-4256-AB78-4D7D6C84DCE1@mattwynne.net> On 1 May 2009, at 15:05, David Chelimsky wrote: > On Fri, May 1, 2009 at 8:42 AM, Matt Wynne > wrote: >> I'm creating a class in my spec file to test out a module, but when >> I run >> the spec a second time in spec_server, I get the error above. >> >> I presume this is because rails is un-loading the class, and it's not >> getting re-loaded properly. >> >> Does anyone have a nice workaround for this? > > What version of rspec[-rails]? oh don't... um. rspec 1.2.2 rails 2.2.2 we know we need to upgrade but when you have 4798 examples it's not a task you undertake lightly! is that likely to be the problem? > > >> >> cheers, >> Matt Wynne >> http://beta.songkick.com >> http://blog.mattwynne.net >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Fri May 1 12:57:58 2009 From: lists at ruby-forum.com (Samuel Soares flores) Date: Fri, 1 May 2009 18:57:58 +0200 Subject: [rspec-users] Help with some basics In-Reply-To: <62ad3e390904302021m45a0777ajb1dcba17b2ed3a26@mail.gmail.com> References: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> <57c63afe0904300759t1aa0bad6o6fa433f8145c339a@mail.gmail.com> <62ad3e390904301255j6c7193c6mdf94c7c12dfc368@mail.gmail.com> <57c63afe0904301304g4bf15482k3fb13186af9cb434@mail.gmail.com> <62ad3e390904302021m45a0777ajb1dcba17b2ed3a26@mail.gmail.com> Message-ID: <168a7b15bd09b7705ef8a84c3efaaf28@ruby-forum.com> > > Managed to find the problem, the class ProductTemplate wasn't being > loaded so "it" wasn't working on an object. > The error is not very useful in this situation but I'm moving forward > again. > How did you solved it? I'm having the same problem. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri May 1 13:11:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 1 May 2009 12:11:29 -0500 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: <9B2E2E54-21FF-4256-AB78-4D7D6C84DCE1@mattwynne.net> References: <57c63afe0905010705i37306970i4404c02421764f0e@mail.gmail.com> <9B2E2E54-21FF-4256-AB78-4D7D6C84DCE1@mattwynne.net> Message-ID: <57c63afe0905011011y1c88523bu4d7c7317901206d0@mail.gmail.com> On Fri, May 1, 2009 at 11:52 AM, Matt Wynne wrote: > > On 1 May 2009, at 15:05, David Chelimsky wrote: > >> On Fri, May 1, 2009 at 8:42 AM, Matt Wynne >> wrote: >>> >>> I'm creating a class in my spec file to test out a module, but when I run >>> the spec a second time in spec_server, I get the error above. >>> >>> I presume this is because rails is un-loading the class, and it's not >>> getting re-loaded properly. >>> >>> Does anyone have a nice workaround for this? >> >> What version of rspec[-rails]? > > oh don't... um. > > rspec 1.2.2 > rails 2.2.2 > > we know we need to upgrade but when you have 4798 examples it's not a task > you undertake lightly! > > is that likely to be the problem? It is likely the problem as the 1.2.6 release includes a spec_server fix. There shouldn't be any breaking changes from 1.2.2 to 1.2.6 (famous last words) so I'd give that a quick try in a branch and see how it does. > >> >> >>> >>> cheers, >>> Matt Wynne >>> http://beta.songkick.com >>> http://blog.mattwynne.net >>> >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From andrew at avit.ca Fri May 1 13:16:19 2009 From: andrew at avit.ca (Andrew Vit) Date: Fri, 1 May 2009 10:16:19 -0700 Subject: [rspec-users] spec_server errors when reloading fixture replacement plugins (was: spec_server not reloading model classes) In-Reply-To: <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> Message-ID: On May 1, 2009, at 7:04 AM, David Chelimsky wrote: > On Sun, Mar 29, 2009 at 6:14 PM, Andrew Vit wrote: >> It appears this is a bug, with an apparently simple fix in >> spec_server.rb (rails 2.3 compatibility): >> >> https://rspec.lighthouseapp.com/projects/5645/tickets/759 >> >> However, now that it's reloading my app, it's not reloading the setup >> from my fixture/factory gems and throwing up a bunch of errors on re- >> run. (I've tried it with both factory_girl and machinist now.) These >> are required in my spec_helper.rb: >> >> config.gem 'notahat-machinist', :lib => 'machinist', :source => >> 'http://gems.github.com' >> require File.dirname(__FILE__) + '/blueprints' >> >> or: >> >> config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source >> => 'http://gems.github.com' >> # automatically loaded from spec/factories/*.rb > > In spec_helper? Hi David, Sorry, that wasn't clear the way I wrote it. The config.gem directive was actually in the rails/environments/test.rb file. Then I required the blueprints.rb file in spec_helper (or in factory_girl's case it automatically loads the factory files from spec/factories). These steps showed that rails model reloading wasn't working in 1.2.2 with rails 2.3.2: >>> $ gem list rails >>> rails (2.3.2) >>> $ gem list rspec >>> rspec (1.2.2) >>> rspec-rails (1.2.2) >>> $ rails test_spec_server && cd test_spec_server >>> $ script/plugin install git://github.com/dchelimsky/rspec-rails.git >>> $ script/generate rspec >>> $ script/generate rspec_model car name:string >>> # edit config/environments/test.rb => config.cache_classes = false >>> # edit spec/spec.opts => --drb >>> $ rake spec:server:start >>> $ script/autospec >>> # 1 example, 0 failures >>> # edit app/models/car.rb => add invalid syntax! >>> # 1 example, 0 failures I had given up on spec_server for the time being. The ticket is resolved now, and I just gave these steps another try with a new app using updated versions. Reloading the app classes for each run works fine out of the box now: I can get it to return a success or failure when I change the model on the fly. However, the problem comes when adding Factory Girl: # config/environments/test.rb # add: config.gem "thoughtbot-factory_girl", :lib => 'factory_girl' # spec/factories/car.rb Factory.define :car do |f| f.name "Jetta" end # spec/models/car_spec.rb it "should create a new instance given valid attributes" do car = Factory :car car.name.should == 'Jetta' end It runs fine the first time against drb, but on all subsequent runs I get the following error until I restart spec_server. None of the lines in the stacktrace say "rspec" but I was also getting the same error with Machinist too, so it's not unique to Factory Girl, and I'm guessing something to do with the reloading. TypeError in 'Car should create a new instance given valid attributes' can't dup NilClass /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2189:in `dup' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2189:in `scoped_methods' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2193:in `current_scoped_methods' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2176:in `scoped?' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2440:in `send' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2440:in `initialize' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/proxy/build.rb:5:in `new' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/proxy/build.rb:5:in `initialize' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:284:in `new' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:284:in `run' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:237:in `create' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:268:in `send' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:268:in `default_strategy' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl.rb:20:in `Factory' ./spec/models/car_spec.rb:11: /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/ dependencies.rb:156:in `require' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/ dependencies.rb:521:in `new_constants_in' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/ dependencies.rb:156:in `require' Andrew Vit From lists at ruby-forum.com Fri May 1 14:19:34 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Fri, 1 May 2009 20:19:34 +0200 Subject: [rspec-users] Command to run a single scenario using cucumber Message-ID: <94a1b463add2477cf513bdb76a75f817@ruby-forum.com> Hi, I have installed cucumber and was able to run all the scenarios using rake features, but can body tell me. What is the command to run a single scenario? Thanks, Anil kumar. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 1 14:22:53 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Fri, 1 May 2009 20:22:53 +0200 Subject: [rspec-users] Plugin to generate text logs using cucumber. Message-ID: Hi, I was able to run the scenarios using rake features in cucmber, All the respective results are displayed in colour in std output. is there any plugin using which i can capture these results(that are generated at run time). Please let me know the procedure to capture these logs in to a files. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Fri May 1 15:25:35 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 01 May 2009 13:25:35 -0600 Subject: [rspec-users] Plugin to generate text logs using cucumber. In-Reply-To: <6ffb72010905011206t52c94c44heff17a4db0f0370a@mail.gmail.com> References: <6ffb72010905011206t52c94c44heff17a4db0f0370a@mail.gmail.com> Message-ID: <49FB4CAF.7070100@benmabey.com> Ben Lovell wrote: > On Fri, May 1, 2009 at 7:22 PM, Anil Gollaa > wrote: > > Hi, > I was able to run the scenarios using rake features in cucmber, > All the respective results are displayed in colour in std output. > > is there any plugin using which i can capture these results(that are > generated at run time). > Please let me know the procedure to capture these logs in to a files. > > > cucumber features -o FILE > > Where FILE is the name of the file to redirect the output to. > > Ben > You will probably not want the color so you can use the --no-color flag. FYI, you can specify multiple formatters if you need to. "cucumber --help" for more. Ben Mabey From ben at benmabey.com Fri May 1 15:41:03 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 01 May 2009 13:41:03 -0600 Subject: [rspec-users] Command to run a single scenario using cucumber In-Reply-To: <94a1b463add2477cf513bdb76a75f817@ruby-forum.com> References: <94a1b463add2477cf513bdb76a75f817@ruby-forum.com> Message-ID: <49FB504F.9060104@benmabey.com> Anil Gollaa wrote: > Hi, > I have installed cucumber and was able to run all the scenarios using > rake features, but can body tell me. > What is the command to run a single scenario? > > Thanks, > Anil kumar. > bmabey at BenzII:~/$ cucumber --help Usage: cucumber [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+ Examples: cucumber examples/i18n/en/features cucumber --language it examples/i18n/it/features/somma.feature:6:98:113 cucumber -n -i http://rubyurl.com/eeCl ... ... So, to run a single scenario you just need to specify it's line number with the colon syntax. "cucumber features/something.feature:42" Using the cucumber binary is the preferred way of running cucumber. I like to reserve using the rake task for CI servers. -Ben From nabble at mattmcneil.org Fri May 1 16:10:06 2009 From: nabble at mattmcneil.org (Matt McNeil) Date: Fri, 1 May 2009 13:10:06 -0700 (PDT) Subject: [rspec-users] Rspec-rails without ActiveRecord framework failure Message-ID: <23338988.post@talk.nabble.com> Hello, Our project is not using ActiveRecord and so I've removed database.yml and added this line to the environment.rb file: config.frameworks -= [ :active_record ] Although I see in the rspec-rails source several places where the existence of ActiveRecord::Base is checked, I am still getting the following exception when running my specs: uninitialized constant Spec::Matchers::Change::ActiveRecord When I comment out the code in rspec-rails-1.2.6/lib/spec/rails/matchers/change.rb, this error disappears. Is this expected behavior? If not, is there a workaround I could use until the issue is resolved? I tried undoing the method chain defined in that file (by a monkeypatch in spec_helper.rb) but it unsurprisingly fails because I'm guessing the method is aliased later in the code execution sequence. Thanks for any input, Matt -- View this message in context: http://www.nabble.com/Rspec-rails-without-ActiveRecord-framework-failure-tp23338988p23338988.html Sent from the rspec-users mailing list archive at Nabble.com. From wolfmanjm at gmail.com Fri May 1 16:21:18 2009 From: wolfmanjm at gmail.com (Jim Morris) Date: Fri, 1 May 2009 13:21:18 -0700 (PDT) Subject: [rspec-users] [Cucumber] how to get name from scenario hook? Message-ID: <57e6585c-b65a-4cd8-8bbb-08e261823864@s1g2000prd.googlegroups.com> Hi, Given the hook: After do |scenario| end How do I get the name of the scenario from the scenario parameter? scenario.name doesn't work, and I looked through the source code and it was not immediately obvious to me. Thanks From dchelimsky at gmail.com Fri May 1 16:36:17 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 1 May 2009 15:36:17 -0500 Subject: [rspec-users] Rspec-rails without ActiveRecord framework failure In-Reply-To: <23338988.post@talk.nabble.com> References: <23338988.post@talk.nabble.com> Message-ID: <57c63afe0905011336y20fb6253j49e4fb3e8c3ba1c0@mail.gmail.com> On Fri, May 1, 2009 at 3:10 PM, Matt McNeil wrote: > > Hello, > > Our project is not using ActiveRecord and so I've removed database.yml and > added this line to the environment.rb file: > ?config.frameworks -= [ :active_record ] > > Although I see in the rspec-rails source several places where the existence > of ActiveRecord::Base is checked, I am still getting the following exception > when running my specs: > > uninitialized constant Spec::Matchers::Change::ActiveRecord > > When I comment out the code in > rspec-rails-1.2.6/lib/spec/rails/matchers/change.rb, this error disappears. > > Is this expected behavior? ?If not, is there a workaround I could use until > the issue is resolved? ?I tried undoing the method chain defined in that > file (by a monkeypatch in spec_helper.rb) but it unsurprisingly fails > because I'm guessing the method is aliased later in the code execution > sequence. Can you please file a bug report at http://rspec.lighthouseapp.com? I need to fix something else and do another rspec-rails release over the weekend (before RC) and I'll fix this one in the same release. Don't know about a workaround this minute, but when i look at the ticket later I'll put one in there. Cheers, David > > Thanks for any input, > Matt > > > -- > View this message in context: http://www.nabble.com/Rspec-rails-without-ActiveRecord-framework-failure-tp23338988p23338988.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nabble at mattmcneil.org Fri May 1 17:23:58 2009 From: nabble at mattmcneil.org (Matt McNeil) Date: Fri, 1 May 2009 14:23:58 -0700 (PDT) Subject: [rspec-users] Rspec-rails without ActiveRecord framework failure In-Reply-To: <57c63afe0905011336y20fb6253j49e4fb3e8c3ba1c0@mail.gmail.com> References: <23338988.post@talk.nabble.com> <57c63afe0905011336y20fb6253j49e4fb3e8c3ba1c0@mail.gmail.com> Message-ID: <23339920.post@talk.nabble.com> David Chelimsky-2 wrote: > > > Can you please file a bug report at http://rspec.lighthouseapp.com? I > need to fix something else and do another rspec-rails release over the > weekend (before RC) and I'll fix this one in the same release. Don't > know about a workaround this minute, but when i look at the ticket > later I'll put one in there. > > Cheers, > David > > Thanks for the quick response! I've filed a Lighthouse ticket here: http://tr.im/kfbA cheers, Matt -- View this message in context: http://www.nabble.com/Rspec-rails-without-ActiveRecord-framework-failure-tp23338988p23339920.html Sent from the rspec-users mailing list archive at Nabble.com. From wolfmanjm at gmail.com Fri May 1 19:03:16 2009 From: wolfmanjm at gmail.com (wolfmanjm) Date: Fri, 1 May 2009 16:03:16 -0700 (PDT) Subject: [rspec-users] [Cucumber] how to get name from scenario hook? In-Reply-To: <8d961d900905011451j1b6713eau2b7e2504bec49501@mail.gmail.com> References: <57e6585c-b65a-4cd8-8bbb-08e261823864@s1g2000prd.googlegroups.com> <8d961d900905011451j1b6713eau2b7e2504bec49501@mail.gmail.com> Message-ID: to_sexp should do it for now, but I'll file a ticket as #name would be useful. Thanks On May 1, 2:51?pm, aslak hellesoy wrote: > > Hi, > > > Given the hook: > > > After do |scenario| > > > end > > > How do I get the name of the scenario from the scenario parameter? > > > scenario.name doesn't ?work, and I looked through the source code and > > it was not immediately obvious to me. > > You can call to_sexp on it and get it from there. Or you can file a > Lighthouse ticket if you want the #name accessor. > > > > > Thanks > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From andrew at andrewtimberlake.com Fri May 1 23:45:16 2009 From: andrew at andrewtimberlake.com (Andrew Timberlake) Date: Sat, 2 May 2009 05:45:16 +0200 Subject: [rspec-users] Help with some basics In-Reply-To: <168a7b15bd09b7705ef8a84c3efaaf28@ruby-forum.com> References: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> <57c63afe0904300759t1aa0bad6o6fa433f8145c339a@mail.gmail.com> <62ad3e390904301255j6c7193c6mdf94c7c12dfc368@mail.gmail.com> <57c63afe0904301304g4bf15482k3fb13186af9cb434@mail.gmail.com> <62ad3e390904302021m45a0777ajb1dcba17b2ed3a26@mail.gmail.com> <168a7b15bd09b7705ef8a84c3efaaf28@ruby-forum.com> Message-ID: <62ad3e390905012045s54393183obed060752d6ad596@mail.gmail.com> On Fri, May 1, 2009 at 6:57 PM, Samuel Soares flores wrote: > >> >> Managed to find the problem, the class ProductTemplate wasn't being >> loaded so "it" wasn't working on an object. >> The error is not very useful in this situation but I'm moving forward >> again. >> > > How did you solved it? I'm having the same problem. > -- What I've found is that occasionally when there is a problem loading the base class, the errors become very cryptic. You can get to the base error by adding a very simple spec in the form of: it "" { ... } In my specific case, my model was in a different schema and so ActiveRecord couldn't find the table in the database. Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain From wolfmanjm at gmail.com Sat May 2 00:02:35 2009 From: wolfmanjm at gmail.com (wolfmanjm) Date: Fri, 1 May 2009 21:02:35 -0700 (PDT) Subject: [rspec-users] [Cucumber] how to get name from scenario hook? In-Reply-To: References: <57e6585c-b65a-4cd8-8bbb-08e261823864@s1g2000prd.googlegroups.com> <8d961d900905011451j1b6713eau2b7e2504bec49501@mail.gmail.com> Message-ID: filed the ticket, as it turns out that the name is not available in the sexp for scenario outlines. Thanks On May 1, 4:03?pm, wolfmanjm wrote: > to_sexp should do it for now, but I'll file a ticket as #name would be > useful. > > Thanks > > On May 1, 2:51?pm, aslak hellesoy wrote: > > > > Hi, > > > > Given the hook: > > > > After do |scenario| > > > > end > > > > How do I get the name of the scenario from the scenario parameter? > > > > scenario.name doesn't ?work, and I looked through the source code and > > > it was not immediately obvious to me. > > > You can call to_sexp on it and get it from there. Or you can file a > > Lighthouse ticket if you want the #name accessor. > > > > Thanks > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-us... at rubyforge.org > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sat May 2 02:25:40 2009 From: lists at ruby-forum.com (James Byrne) Date: Sat, 2 May 2009 08:25:40 +0200 Subject: [rspec-users] cucumber - how to bootstrap outside of rails? Message-ID: Setting up cucumber inside a Rails project is no more difficult than running script/generate cucumber. But what does one do when working without Rails at all? How do you generate the features tree and all of its default files? -- Posted via http://www.ruby-forum.com/. From akleak at gmail.com Sat May 2 03:12:55 2009 From: akleak at gmail.com (Arco) Date: Sat, 2 May 2009 00:12:55 -0700 (PDT) Subject: [rspec-users] cucumber - how to bootstrap outside of rails? In-Reply-To: References: Message-ID: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> I use mkdir and touch. On May 1, 11:25?pm, James Byrne wrote: > Setting up cucumber inside a Rails project is no more difficult than > running script/generate cucumber. ?But what does one do when working > without Rails at all? ?How do you generate the features tree and all of > its default files? > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From wolfmanjm at gmail.com Sat May 2 03:30:47 2009 From: wolfmanjm at gmail.com (Jim Morris) Date: Sat, 2 May 2009 00:30:47 -0700 (PDT) Subject: [rspec-users] [Cucumber] Using Cucumber to test Erlang servers directly Message-ID: <69c443df-4005-400e-b728-72b00ab8068d@r31g2000prh.googlegroups.com> I don't know if this will interest anyone, but I thought it was a pretty cool use of Cucumber :) I've posted a Blog article on how I use Cucumber to test an Erlang Server directly by talking to my Erlang Nodes. http://blog.wolfman.com/articles/2009/5/2/using-cucumber-to-test-erlang-servers It uses Cucumber running under JRuby which uses JInterface to talk to the Erlang servers. I hope someone else finds this a fascinating use of Cucumber ;) From aslak.hellesoy at gmail.com Sat May 2 03:45:38 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Sat, 2 May 2009 09:45:38 +0200 Subject: [rspec-users] cucumber - how to bootstrap outside of rails? In-Reply-To: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> Message-ID: > I use mkdir and touch. > Me too > On May 1, 11:25 pm, James Byrne wrote: >> Setting up cucumber inside a Rails project is no more difficult than >> running script/generate cucumber. But what does one do when working >> without Rails at all? How do you generate the features tree and >> all of >> its default files? >> -- >> Posted viahttp://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/ >> rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From bianster at gmail.com Sat May 2 03:11:52 2009 From: bianster at gmail.com (Doug) Date: Sat, 2 May 2009 00:11:52 -0700 (PDT) Subject: [rspec-users] DRB errors running rake pre_commit Message-ID: Hi list, I checked out the rspec-dev repository on a MBP (Leopard) and tried to run the pre_commit task after going through the setup/configuration steps on http://wiki.github.com/dchelimsky/rspec/contribute. I'm getting DRB errors related to script/spec_server when running specs: Address already in use - bind(2) (Errno::EADDRINUSE). Running lsof -i tcp:8989 shows: ruby 9674 douglas 5u IPv4 0x6538a68 0t0 TCP localhost:sunwebadmins (LISTEN) I've tried changing the DRB port to 20111 and running rake pre_commit again but the same problem comes up. Is this something people have come across before? From dchelimsky at gmail.com Sat May 2 08:00:14 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 2 May 2009 07:00:14 -0500 Subject: [rspec-users] DRB errors running rake pre_commit In-Reply-To: References: Message-ID: <57c63afe0905020500r26783e9cg90f91165b8ca1e34@mail.gmail.com> On Sat, May 2, 2009 at 2:11 AM, Doug wrote: > Hi list, > > I checked out the rspec-dev repository on a MBP (Leopard) and tried to > run the pre_commit task after going through the setup/configuration > steps on http://wiki.github.com/dchelimsky/rspec/contribute. > > I'm getting DRB errors related to script/spec_server when running > specs: Address already in use - bind(2) (Errno::EADDRINUSE). Running > lsof -i tcp:8989 shows: > > ruby ? ?9674 douglas ? ?5u ?IPv4 0x6538a68 ? ? ?0t0 ?TCP > localhost:sunwebadmins (LISTEN) > > I've tried changing the DRB port to 20111 and running rake pre_commit > again but the same problem comes up. Is this something people have > come across before? I actually just noticed it a couple of days ago. I was able to resolve it by building and installing the rspec gem, so there is an apparent dependency on that being present. We're going to be re-vamping (read *simplifying*) the whole rspec-dev setup in the next month or so, so I'm not going to try to fix this right now, but installing the gem should solve it for you. Cheers, David From ben at benmabey.com Sat May 2 10:37:47 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 02 May 2009 08:37:47 -0600 Subject: [rspec-users] [Cucumber] Using Cucumber to test Erlang servers directly In-Reply-To: <69c443df-4005-400e-b728-72b00ab8068d@r31g2000prh.googlegroups.com> References: <69c443df-4005-400e-b728-72b00ab8068d@r31g2000prh.googlegroups.com> Message-ID: <49FC5ABB.708@benmabey.com> Jim Morris wrote: > I don't know if this will interest anyone, but I thought it was a > pretty cool use of Cucumber :) > > I've posted a Blog article on how I use Cucumber to test an Erlang > Server directly by talking to my Erlang Nodes. > > http://blog.wolfman.com/articles/2009/5/2/using-cucumber-to-test-erlang-servers > > It uses Cucumber running under JRuby which uses JInterface to talk to > the Erlang servers. > > I hope someone else finds this a fascinating use of Cucumber ;) > > > > That is awesome. Thanks for sharing! -Ben From ben at benmabey.com Sat May 2 10:40:14 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 02 May 2009 08:40:14 -0600 Subject: [rspec-users] cucumber - how to bootstrap outside of rails? In-Reply-To: References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> Message-ID: <49FC5B4E.5070909@benmabey.com> Aslak Helles?y wrote: > > >> I use mkdir and touch. >> > > Me too Yeah, "mkdir -p features/support && mkdir -p features/step_defnintions && touch features/support/env.rb" is really all you need. However, for new projects I really like to use jeweler to bootstrap all the setup for Cucumber, RSpec, Rakefiles, etc... With jeweler you just say "jeweler cool_gem --cucumber --rspec" and all of this gets generated for you: create .gitignore create Rakefile create LICENSE create README.rdoc create .document create lib create lib/cool_gem.rb create spec create spec/spec_helper.rb create spec/cool_gem_spec.rb create features create features/cool_gem.feature create features/support create features/support/env.rb create features/step_definitions create features/step_definitions/cool_gem_steps.rb Here is jewelers site: http://technicalpickles.github.com/jeweler/ -Ben > >> On May 1, 11:25 pm, James Byrne wrote: >>> Setting up cucumber inside a Rails project is no more difficult than >>> running script/generate cucumber. But what does one do when working >>> without Rails at all? How do you generate the features tree and all of >>> its default files? >>> -- >>> Posted viahttp://www.ruby-forum.com/. >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sat May 2 12:00:56 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 2 May 2009 18:00:56 +0200 Subject: [rspec-users] RSpecers point of view about how to create rails association Message-ID: <50c214e61bcd48b2dad936e8da6c4b1f@ruby-forum.com> Hi, Using Ruby on Rails, let's says I have an Article model and Comment model. An Article has_many :comments, Using Rais idiom, one would do something like that in the comments_controller/create: @article = Article.find(params[:id]) @article.comments.create(params[:comment]) I don't like too much this approach because it puts too much intelligence into the controller and it's not easy to test/spec/mock. So I'd like to push this into a model. So would you tell Article model to create a new Comment given params[:comment], or would you tell Comment to create a new Comment given an article_id? >From a BDD point of view, only creating a new comment record is what counts, but I'd like to be more careful about Demeter, encapsulation, tell don't ask, ... -- Posted via http://www.ruby-forum.com/. From julian at leviston.net Sat May 2 12:37:41 2009 From: julian at leviston.net (Julian Leviston) Date: Sun, 3 May 2009 02:37:41 +1000 Subject: [rspec-users] cucumber - referential (inherited?) scenarios In-Reply-To: <49FC5B4E.5070909@benmabey.com> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <49FC5B4E.5070909@benmabey.com> Message-ID: <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> You know what'd be awesome? If Cucumber scenarios were referential. I mean, wouldn't it be awesome if you could refer to them... so you could build on them... So in a login.feature I'd define: Scenario: logging in Given that a default user exists And I am on the login page When I fill in "username" with "username" And I fill in "password" with "password" Then I should be logged in And then in a different feature somewhere else, I could say: another.feature Scenario: make toast Given Scenario "logging in" Given I am on the exciting logged in page Then I .... blah blah blah and so on... Julian. From lee.hambley at gmail.com Sat May 2 14:33:40 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Sat, 2 May 2009 19:33:40 +0100 Subject: [rspec-users] cucumber - referential (inherited?) scenarios In-Reply-To: <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <49FC5B4E.5070909@benmabey.com> <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> Message-ID: Hi Julian, You can do just that, the scenarios stack like that quite well, and it is reasonable to call a step from another, but you should have something like Scenario: Logging In Given there is a user When I visit the login page And I fill in username with ....... And I fill in passowrd with ........ Then I should be logged in as ....... Scenario: Visiting Account Page Given I am logged in When I visit the account page Then I should see my account settings ... "Given I am logged in" you define to call in turn each of the step matchers you wrote to satisfy the first scenario. .. does that fit your expectations / workflow? 2009/5/2 Julian Leviston > You know what'd be awesome? > > If Cucumber scenarios were referential. > > I mean, wouldn't it be awesome if you could refer to them... so you could > build on them... > > So in a login.feature I'd define: > > Scenario: logging in > Given that a default user exists > And I am on the login page > When I fill in "username" with "username" > And I fill in "password" with "password" > Then I should be logged in > > And then in a different feature somewhere else, I could say: > > another.feature > > Scenario: make toast > Given Scenario "logging in" > Given I am on the exciting logged in page > Then I .... blah blah blah > > and so on... > > Julian. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Sat May 2 14:50:28 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 02 May 2009 12:50:28 -0600 Subject: [rspec-users] cucumber - referential (inherited?) scenarios In-Reply-To: <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <49FC5B4E.5070909@benmabey.com> <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> Message-ID: <49FC95F4.1080705@benmabey.com> Julian Leviston wrote: > You know what'd be awesome? > > If Cucumber scenarios were referential. > > I mean, wouldn't it be awesome if you could refer to them... so you > could build on them... > > So in a login.feature I'd define: > > Scenario: logging in > Given that a default user exists > And I am on the login page > When I fill in "username" with "username" > And I fill in "password" with "password" > Then I should be logged in > > And then in a different feature somewhere else, I could say: > > another.feature > > Scenario: make toast > Given Scenario "logging in" > Given I am on the exciting logged in page > Then I .... blah blah blah > > and so on... > > Julian. Believe it or not, this exact feature did exist in Cucumber at one time but was deprecated and is now removed. You can find a good explanation of the reasoning behind that decision and what are the better alternatives on Joseph's blog: http://blog.josephwilk.net/ruby/cucumber-waves-goodbye-to-givenscenario.html -Ben From julian at leviston.net Sat May 2 15:30:57 2009 From: julian at leviston.net (Julian Leviston) Date: Sun, 3 May 2009 05:30:57 +1000 Subject: [rspec-users] cucumber - referential (inherited?) scenarios In-Reply-To: <49FC95F4.1080705@benmabey.com> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <49FC5B4E.5070909@benmabey.com> <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> <49FC95F4.1080705@benmabey.com> Message-ID: <5C721311-523E-4339-B580-9DF0ACFF76C4@leviston.net> Fair enough. The steps from step definitions one is the best approach for what I want, and it's actually what am doing, but I do notice that there's a lot of the time when I'm actually re-typing the same text (ie once in the explicit explanation of what it means to log in, and then once more in the step definitions to refer to that login procedure) when I do this approach. Re-typing the same stuff is pretty retarded, and never a good idea. Hence... my interest in this feature :) How about this... Whenever I refer to other steps from within my steps, they should be printed out on the output line... tabbed in a bit, like so: Given I am logged in: Given a default user exists And I am on the login page And I fill in "username" with "username" And I fill in "password" with "password" Then I should be on the superduper page Given... When... Then... Then the option to turn this feature off or on on the command line. That'd be bloody brilliant. Okay so maybe I should go fork it and do it :) Julian. On 03/05/2009, at 4:50 AM, Ben Mabey wrote: > Julian Leviston wrote: >> You know what'd be awesome? >> >> If Cucumber scenarios were referential. >> >> I mean, wouldn't it be awesome if you could refer to them... so you >> could build on them... >> >> So in a login.feature I'd define: >> >> Scenario: logging in >> Given that a default user exists >> And I am on the login page >> When I fill in "username" with "username" >> And I fill in "password" with "password" >> Then I should be logged in >> >> And then in a different feature somewhere else, I could say: >> >> another.feature >> >> Scenario: make toast >> Given Scenario "logging in" >> Given I am on the exciting logged in page >> Then I .... blah blah blah >> >> and so on... >> >> Julian. > > > Believe it or not, this exact feature did exist in Cucumber at one > time but was deprecated and is now removed. You can find a good > explanation of the reasoning behind that decision and what are the > better alternatives on Joseph's blog: > > http://blog.josephwilk.net/ruby/cucumber-waves-goodbye-to-givenscenario.html > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From r_j_h_box-sf at yahoo.com Sat May 2 16:18:46 2009 From: r_j_h_box-sf at yahoo.com (Randy Harmon) Date: Sat, 02 May 2009 13:18:46 -0700 Subject: [rspec-users] Problem verifying routing error Message-ID: <49FCAAA6.6040600@yahoo.com> Hi, When upgrading to rspec/rspec-rails 1.2.6 gem (from 1.1.12), I'm having a new problem verifying routes that should not exist. This is to support something like this in routes.rb: map.resources :orders do |orders| orders.resources :items, :except => [:index,:show] end I used to use lambda {}.should_raise( routing error ), but it stopped detecting any raised error. Requesting it through the browser produces ActionController::MethodNotAllowed (Only post requests are allowed). But that error wasn't detected. When I skip the lambda, and just ask it to verify that the route does exist (which *should* fail), I get the same result for those :except actions as for a made-up action name. Seems this must have something to do with the change in how route_for delegates back to ActionController's routing assertion (sez the backtrace :). NoMethodError in 'ItemsController route generation should NOT map #indewfefwex' You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.first /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:134:in `recognized_request_for' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:49:in `assert_recognizes' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions.rb:54:in `clean_backtrace' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:47:in `assert_recognizes' ./spec/controllers/thoughts_routing_spec.rb:9: I tried using bypass_rescue in my routing/items_routing_spec.rb file as mentioned by the upgrade doc, but it wasn't valid in the "routing" spec - worked fine when I moved the file back to spec/controllers/, though. Seems like that's not the issue, but I'm mentioning for more completeness. Any ideas what I should be doing instead, or how I can troubleshoot further? Thanks, Randy From lists at ruby-forum.com Sat May 2 16:42:35 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 2 May 2009 22:42:35 +0200 Subject: [rspec-users] RSpecers point of view about how to create rails association In-Reply-To: <00163646c1e623f4010468f20f17@google.com> References: <50c214e61bcd48b2dad936e8da6c4b1f@ruby-forum.com> <00163646c1e623f4010468f20f17@google.com> Message-ID: > You *could* write wrapper methods for chains like this and make Demeter > happy, but to do that for every single call... Thank you for your experience. I myself used to wrap these kind of associations but I felt it started to clutter the Model file, so I started to use association callbacks. My heart balances between both ideas. Anyway if attr_accessible is used, then you must write a wrapper, but in other cases? Which is the most effective / maintainable / etc is still to be questioned. Honestly, each time something backfired at me in a very unexpected manner, it was due to the fact that somewhere far far away I had broken Demeter's law. So I'd like to get this fixed once and for all. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Sat May 2 18:33:20 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 02 May 2009 16:33:20 -0600 Subject: [rspec-users] cucumber - referential (inherited?) scenarios In-Reply-To: <5C721311-523E-4339-B580-9DF0ACFF76C4@leviston.net> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <49FC5B4E.5070909@benmabey.com> <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> <49FC95F4.1080705@benmabey.com> <5C721311-523E-4339-B580-9DF0ACFF76C4@leviston.net> Message-ID: <49FCCA30.2050908@benmabey.com> Julian Leviston wrote: > Fair enough. > > The steps from step definitions one is the best approach for what I > want, and it's actually what am doing, but I do notice that there's a > lot of the time when I'm actually re-typing the same text (ie once in > the explicit explanation of what it means to log in, and then once > more in the step definitions to refer to that login procedure) when I > do this approach. Re-typing the same stuff is pretty retarded, and > never a good idea. > > Hence... my interest in this feature :) > > How about this... Whenever I refer to other steps from within my > steps, they should be printed out on the output line... tabbed in a > bit, like so: > > Given I am logged in: > Given a default user exists > And I am on the login page > And I fill in "username" with "username" > And I fill in "password" with "password" > Then I should be on the superduper page > Given... > When... > Then... > > Then the option to turn this feature off or on on the command line. We would definitely want it as a feature you could turn on or off. By default I think it should be off. I think it adds a lot of noise to the feature output. In most cases I don't care what the exact steps of logging in are. How I log in can change and it doesn't really effect this scenario at all. What is important is that you are logged in- not how you got there. So this is probably not a feature I would personally use. (Especially, given that I don't use steps within steps a whole lot.) That said it seems like a reasonable request... Any other opinions on the suggested feature? Should we move the discussion to lighthouse? -Ben > > That'd be bloody brilliant. Okay so maybe I should go fork it and do > it :) > > Julian. > > On 03/05/2009, at 4:50 AM, Ben Mabey wrote: > >> Julian Leviston wrote: >>> You know what'd be awesome? >>> >>> If Cucumber scenarios were referential. >>> >>> I mean, wouldn't it be awesome if you could refer to them... so you >>> could build on them... >>> >>> So in a login.feature I'd define: >>> >>> Scenario: logging in >>> Given that a default user exists >>> And I am on the login page >>> When I fill in "username" with "username" >>> And I fill in "password" with "password" >>> Then I should be logged in >>> >>> And then in a different feature somewhere else, I could say: >>> >>> another.feature >>> >>> Scenario: make toast >>> Given Scenario "logging in" >>> Given I am on the exciting logged in page >>> Then I .... blah blah blah >>> >>> and so on... >>> >>> Julian. >> >> >> Believe it or not, this exact feature did exist in Cucumber at one >> time but was deprecated and is now removed. You can find a good >> explanation of the reasoning behind that decision and what are the >> better alternatives on Joseph's blog: >> >> http://blog.josephwilk.net/ruby/cucumber-waves-goodbye-to-givenscenario.html >> >> >> -Ben >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 brandtkurowski at gmail.com Sat May 2 23:54:42 2009 From: brandtkurowski at gmail.com (Brandt Kurowski) Date: Sat, 2 May 2009 20:54:42 -0700 (PDT) Subject: [rspec-users] Cucumber - Testing ActionMailer In-Reply-To: <49F86622.8030007@benmabey.com> References: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> <49F68B3D.6040007@benmabey.com> <93ecab56af647631a9be4b0a4b8de281@ruby-forum.com> <5a353b250f4788ec641b3a26092fce9c@ruby-forum.com> <531734da2f7e3dbc67318c15d68479a9@ruby-forum.com> <49F86622.8030007@benmabey.com> Message-ID: <98efdd49-9a51-4a71-adbb-877b6611f1e2@q14g2000vbn.googlegroups.com> On Apr 29, 10:37?am, Ben Mabey wrote: > However, that is not done yet. ?As it stands now you > have two options: a) have the test execution and script in the same > process or b) Use ARMailer[1] in your testing environment. ?ARMailer > places the messages in a database for queuing. ?So instead of checking > the in-memory array EmailSpec will check the queue on the database. ? > Since this is just for testing then you could use a lightweight sqlite3 > db to store this. For what it's worth, I believe that ARMailer requires you to change your base class for mailers from ActionMailer::Base to ActionMailer::ARMailer, which makes it difficult to use ARMailer only in your test environment. However, the adzap-ar_mailer[1] fork supports using the ActionMailer::Base base class, which makes it easy to use ARMailer only for testing (by specifying it in config/ environments/test.rb) while using another delivery mechanism for development/production. 1. http://github.com/adzap/ar_mailer/tree/master From lists at ruby-forum.com Sun May 3 03:59:42 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Sun, 3 May 2009 09:59:42 +0200 Subject: [rspec-users] [rspec]. Inexplicable error in simple specs Message-ID: <0ddfe68313e8de5198edce3d5929b901@ruby-forum.com> Hello. I am having strange errors running some specs. I have just installed the nifty_scaffolds gem from Ryan Bates, and ran "script/generate nifty_authentication --rspec --haml", I have prepared the databases, and run the specs, and I have almost all the specs failing. The odd thing is that it only fails when I run all the spec together, but not when I ran models and controllers independently. "rake spec:models" pass for all the specs "rake spec:controllers" pass for all the specs. But "rake spec" fails in a dozen of model tests. Also "autospec" fails. The code seems clear and ok, and I can't understand why even simple specs for require presence of a field fails. I have only notice as unusual the use of view integration in the controllers specs. Does anyone know about something I can be missing? Thanks Juanma -- Posted via http://www.ruby-forum.com/. From wolfmanjm at gmail.com Sun May 3 04:16:55 2009 From: wolfmanjm at gmail.com (wolfmanjm) Date: Sun, 3 May 2009 01:16:55 -0700 (PDT) Subject: [rspec-users] [Cucumber] Using Cucumber to test Erlang servers directly In-Reply-To: <8d961d900905021938l46ec063eobaa7742da3051de2@mail.gmail.com> References: <69c443df-4005-400e-b728-72b00ab8068d@r31g2000prh.googlegroups.com> <8d961d900905021938l46ec063eobaa7742da3051de2@mail.gmail.com> Message-ID: <3df9d6dc-f8ae-4569-82ec-0d42bc04a787@g31g2000pra.googlegroups.com> Thanks, this is a work in progress it should get more sophisticated as I write more features. BTW Aslak this is why I needed the scenario name in the After hook, I get a lot of Erlang messages which get stored, and the Steps should test for them and consume them off the queue, however as Erlang and messages are totally asynchronous, I don't want to print them out when they come in, or in the After hook, as that screws up the Scenario Outline reports. Hence they are stored and printed in the at_exit hook. Using cucumber to debug asynchronous processes will probably introduce a lot of interesting edge cases ;) Thanks On May 2, 7:38?pm, aslak hellesoy wrote: > > I don't know if this will interest anyone, but I thought it was a > > pretty cool use of Cucumber :) > > OMG sooo cool. > > Added here:http://wiki.github.com/aslakhellesoy/cucumber/tutorials-and-related-b... > > Aslak > > > > > I've posted a Blog article on how I use Cucumber to test an Erlang > > Server directly by talking to my Erlang Nodes. > > >http://blog.wolfman.com/articles/2009/5/2/using-cucumber-to-test-erla... > > > It uses Cucumber running under JRuby which uses JInterface to talk to > > the Erlang servers. > > > I hope someone else finds this a fascinating use of Cucumber ;) > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sun May 3 04:36:31 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Sun, 3 May 2009 10:36:31 +0200 Subject: [rspec-users] [rspec]. Inexplicable error in simple specs In-Reply-To: <0ddfe68313e8de5198edce3d5929b901@ruby-forum.com> References: <0ddfe68313e8de5198edce3d5929b901@ruby-forum.com> Message-ID: <22335270d96a538b079911b1f9da5c04@ruby-forum.com> Well It seems that the problem is not with the view integration but with the fixtures. I didn't know if the fixtures loaded in the spec of a controller may affect the specs of the model, but they indeed do. I thought each spec runs in its own database transaction and the data does not affect other spec. Is it true? Thanks -- Posted via http://www.ruby-forum.com/. From bianster at gmail.com Sun May 3 06:48:57 2009 From: bianster at gmail.com (Doug) Date: Sun, 3 May 2009 03:48:57 -0700 (PDT) Subject: [rspec-users] DRB errors running rake pre_commit In-Reply-To: <57c63afe0905020500r26783e9cg90f91165b8ca1e34@mail.gmail.com> References: <57c63afe0905020500r26783e9cg90f91165b8ca1e34@mail.gmail.com> Message-ID: <771a861d-d371-44b7-967c-dd517212e88f@y34g2000prb.googlegroups.com> Thanks David, that did it for me. On May 2, 8:00?pm, David Chelimsky wrote: > On Sat, May 2, 2009 at 2:11 AM, Doug wrote: > > Hi list, > > > I checked out the rspec-dev repository on a MBP (Leopard) and tried to > > run the pre_commit task after going through the setup/configuration > > steps onhttp://wiki.github.com/dchelimsky/rspec/contribute. > > > I'm getting DRB errors related to script/spec_server when running > > specs: Address already in use - bind(2) (Errno::EADDRINUSE). Running > > lsof -i tcp:8989 shows: > > > ruby ? ?9674 douglas ? ?5u ?IPv4 0x6538a68 ? ? ?0t0 ?TCP > > localhost:sunwebadmins (LISTEN) > > > I've tried changing the DRB port to 20111 and running rake pre_commit > > again but the same problem comes up. Is this something people have > > come across before? > > I actually just noticed it a couple of days ago. I was able to resolve > it by building and installing the rspec gem, so there is an apparent > dependency on that being present. We're going to be re-vamping (read > *simplifying*) the whole rspec-dev setup in the next month or so, so > I'm not going to try to fix this right now, but installing the gem > should solve it for you. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun May 3 09:40:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 3 May 2009 08:40:58 -0500 Subject: [rspec-users] [rspec]. Inexplicable error in simple specs In-Reply-To: <22335270d96a538b079911b1f9da5c04@ruby-forum.com> References: <0ddfe68313e8de5198edce3d5929b901@ruby-forum.com> <22335270d96a538b079911b1f9da5c04@ruby-forum.com> Message-ID: <57c63afe0905030640g4f0d02e2o5bb681b18882f444@mail.gmail.com> On Sun, May 3, 2009 at 3:36 AM, Juanma Cervera wrote: > Well > It seems that the problem is not with the view integration but with the > fixtures. > I didn't know if the fixtures loaded in the spec of a controller may > affect the specs of the model, but they indeed do. > I thought each spec runs in its own database transaction and the data > does not affect other spec. Is it true? Assuming everything is set up correctly, yes. But there are several things that could break that, including: * the wrong configuration in spec/spec_helper.rb * the wrong type of database tables in mysql (gotta use innodb) * setting up fixtures in before(:all) instead of before(:each) Also, this sort of thing is often a sign that the either the examples are leaking state by setting up globals, or the app itself might be doing so. HTH, David > Thanks > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ashley.moran at patchspace.co.uk Sun May 3 12:58:20 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sun, 3 May 2009 17:58:20 +0100 Subject: [rspec-users] cucumber - referential (inherited?) scenarios In-Reply-To: <49FCCA30.2050908@benmabey.com> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <49FC5B4E.5070909@benmabey.com> <56ED850D-85A3-456D-B12B-C54A077E665C@leviston.net> <49FC95F4.1080705@benmabey.com> <5C721311-523E-4339-B580-9DF0ACFF76C4@leviston.net> <49FCCA30.2050908@benmabey.com> Message-ID: <75C888FE-52F2-495E-90F6-D403E5C57E90@patchspace.co.uk> On 2 May 2009, at 23:33, Ben Mabey wrote: > We would definitely want it as a feature you could turn on or off. > By default I think it should be off. I think it adds a lot of noise > to the feature output. In most cases I don't care what the exact > steps of logging in are. How I log in can change and it doesn't > really effect this scenario at all. What is important is that you > are logged in- not how you got there. So this is probably not a > feature I would personally use. (Especially, given that I don't use > steps within steps a whole lot.) That said it seems like a > reasonable request... Any other opinions on the suggested feature? > Should we move the discussion to lighthouse? I think this could be a useful debugging feature, although less compelling since Cucumber started reporting failures in steps called from steps the same way as steps called in a feature file. But sometimes it's useful to see in finer detail what Cucumber is doing. One thing I wrestle with frequently is making scenarios fail fast and transparently. Assumptions about what exactly is going on creep in, and often, the step that reports failure is not the one that fundamentally caused it. Anything to make that assumption-breaking easier would be valuable IMHO. Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From lists at ruby-forum.com Sun May 3 16:19:30 2009 From: lists at ruby-forum.com (James Byrne) Date: Sun, 3 May 2009 22:19:30 +0200 Subject: [rspec-users] Cucumber - Testing ActionMailer In-Reply-To: <98efdd49-9a51-4a71-adbb-877b6611f1e2@q14g2000vbn.googlegroups.com> References: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> <49F68B3D.6040007@benmabey.com> <93ecab56af647631a9be4b0a4b8de281@ruby-forum.com> <5a353b250f4788ec641b3a26092fce9c@ruby-forum.com> <531734da2f7e3dbc67318c15d68479a9@ruby-forum.com> <49F86622.8030007@benmabey.com> <98efdd49-9a51-4a71-adbb-877b6611f1e2@q14g2000vbn.googlegroups.com> Message-ID: <496f528c679be9edaa915f7c8ed93a4d@ruby-forum.com> What I ended up doing is dumping the deliveries array to a file from the standalone script and reading it into the deliveries array inside the step definitions file. A kludge, but it suffices. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun May 3 16:34:24 2009 From: lists at ruby-forum.com (James Byrne) Date: Sun, 3 May 2009 22:34:24 +0200 Subject: [rspec-users] cucumber - how to bootstrap outside of rails? In-Reply-To: References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> Message-ID: <87078e29671263bfdc50e73091dbd1ff@ruby-forum.com> Aslak Helles?y wrote: >> I use mkdir and touch. >> > > Me too Fine for those that know cucumber inside out. A bit sparse for the rest of creation. What I ended up doing was copying an example directory tree from the cucumber gem and deleting most of it. It would be useful for non-Rails users of cucumber if cucumber itself had an option to copy a template directory tree from the gem into a project root. In other words: $ cd project_root $ tree . |-- bin |-- doc `-- lib $ $ cucumber --initialize $ tree . |-- Rakefile |-- bin |-- doc |-- features | |-- sample.feature | |-- step_definitions | | `-- sample_steps.rb | `-- support | |-- env.rb | `-- tag_count_formatter.rb `-- lib -- Posted via http://www.ruby-forum.com/. From kero at chello.nl Sun May 3 18:21:09 2009 From: kero at chello.nl (Kero van Gelder) Date: Mon, 4 May 2009 00:21:09 +0200 Subject: [rspec-users] [Cucumber] gem missing dependencies In-Reply-To: <21283072-6294-412F-962A-B8EFD22ACD51@gmail.com> References: <20090426121649.GA8422@bumblebee.m38c.nl> <8d961d900904260734t24032535pbfc8d18812d3f3de@mail.gmail.com> <20090427212325.GA13970@bumblebee.m38c.nl> <21283072-6294-412F-962A-B8EFD22ACD51@gmail.com> Message-ID: <20090503222108.GE980@bumblebee.m38c.nl> > Polyglot requires hoe because it's built using "newgem". It's a > nuisance, and I'll be happy to remove it, or make hoe a dev-time > dependency only if possible. I've contacted Dr Nic to ask how to > proceed. In my view, using hoe shouldn't add a runtime dependency. Hm, snippet from long `p spec` (from my prev email): @dependencies=[#=", #]]>, @type=:runtime>] So your dependency is/was runtime-only, it seems. But the stuff got fixed in the meantime! I'm guessing it's the rubygems upgrade on my system. $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] $ gem -v 1.3.2 $ gem list *** LOCAL GEMS *** builder (2.1.2) calibre-semaphore (1.0.0) cucumber (0.3.2) diff-lcs (1.1.2) polyglot (0.2.5) rspec (1.2.6) term-ansicolor (1.0.3) treetop (1.2.5) $ gem dependency polyglot Gem polyglot-0.2.5 hoe (>= 1.8.0, development) <= not runtime anymore! same 0.2.5 polyglot gem! $ cucumber 0 scenarios () 0 steps () $ Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From info at timfischbach.de Sun May 3 14:28:12 2009 From: info at timfischbach.de (Tim Fischbach) Date: Sun, 03 May 2009 20:28:12 +0200 Subject: [rspec-users] [cucumber] Assertions about current location in Then steps Message-ID: <49FDE23C.7040703@timfischbach.de> Hello, is there currently a way to make assertions about the current location in Then steps? Here's an example of what I would like to do: Scenario: Creating a post Given I am on the the posts page When I fill in ... And ... Then I should be on the homepage I have seen many cases where the last assertion is replaced by a 'Then I should see ""'. But I can't help but feel that depending on the specific wording is way to brittle. And since I could also check the current location by looking at the address bar (if I ran the test manually) I guess it would not be a violation if cucumber did (as opposed to checking for records in the database etc). Thoughts? Tim From mattvanhorn at gmail.com Sun May 3 21:58:47 2009 From: mattvanhorn at gmail.com (Matthew Van Horn) Date: Sun, 3 May 2009 21:58:47 -0400 Subject: [rspec-users] cucumber - when to stub/mock Message-ID: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> I'm just curious about this, since my solution involved stubbing a call to GeoIp. Is there a good rule of thumb for when you make exceptions to the 'no stubbing' philosophy of Cucumber? My step was: "Given I am accessing the site from Japan," but I can think of other situations - mostly when interacting with web services, that I'd probably want to stub something, rather than requiring a net connection for testing. thanks for any advice, Matt Van Horn From lists at ruby-forum.com Sun May 3 22:08:24 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 4 May 2009 04:08:24 +0200 Subject: [rspec-users] cucumber - how to bootstrap outside of rails? In-Reply-To: <8d961d900905031356w216e13a5i2463e261570fd42a@mail.gmail.com> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <87078e29671263bfdc50e73091dbd1ff@ruby-forum.com> <8d961d900905031356w216e13a5i2463e261570fd42a@mail.gmail.com> Message-ID: <55d96c967a5ebd38c7dd12c8ce907bd1@ruby-forum.com> Aslak Helles?y wrote: > > You only need this to start: > > +-features/ > +-foo.feature > I realize this. I am not complaining. I just think that for a modest amount of effort cucumber could be made self starting for the large number of people who do not have any prior experience with either Rails or Cucumber and who probably do not know about jeweller and newgem. I had no idea such things existed or were possible until I received replies to this thread. I still recall the vast amounts of time it took me to get going with cucumber and BDD. And that was with the benefit of the Rails generators that at least set me up with a skeleton to work from. I think it would be useful to offer non-Rails users a similar facility. -- Posted via http://www.ruby-forum.com/. From mike at mikedoel.com Mon May 4 01:42:56 2009 From: mike at mikedoel.com (Mike Doel) Date: Mon, 4 May 2009 01:42:56 -0400 Subject: [rspec-users] cucumber - when to stub/mock In-Reply-To: <8d961d900905032228o4eb0ef02ud85561cb7cac065@mail.gmail.com> References: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> <8d961d900905032228o4eb0ef02ud85561cb7cac065@mail.gmail.com> Message-ID: On May 4, 2009, at 1:28 AM, aslak hellesoy wrote: > Is there a good rule of thumb for when you make exceptions to the > 'no stubbing' philosophy of Cucumber? > > This is the rule of thumb: http://wiki.github.com/aslakhellesoy/cucumber/mocking-and-stubbing-with-cucumber I'm in a similar boat as Matt. My app does geocoding using Andre Lewis' excellent geokit gem (and the Rails plugin). That stuff hits web-based geocoders (Google in my case). I also scrape other web sites. So, in order to make my testing executable without a net connection and avoid extra traffic on other folks' sites from my tests, I stub out the actual net call with code like this: def stub_geocode_lookup(address,datafile) @xml = File.read(RAILS_ROOT + "/spec/fixtures/geocodes/" + datafile) response = MockSuccess.new response.stubs(:body).returns(@xml) stub_google_call(address,response) end def stub_google_call(address,response) url = "http://maps.google.com/maps/geo? q = #{Geokit ::Inflector ::url_escape (address)}&output=xml&key=#{Geokit::Geocoders::google}&oe=utf-8" Geokit ::Geocoders ::GoogleGeocoder .stubs(:call_geocoder_service).with(url).returns(response) end I also make use of FakeWeb in a couple places to do a similar thing for the scraping of sites. I have a rake task that grabs fresh versions of the pages I'm going to scrape and deposits it into my spec/ fixtures directory. If I run that every couple of days, I reduce my risk of having my fixture data diverge too far from what the production app actually sees. Mike Doel From korny at sietsma.com Mon May 4 03:11:45 2009 From: korny at sietsma.com (Korny Sietsma) Date: Mon, 4 May 2009 17:11:45 +1000 Subject: [rspec-users] cucumber - when to stub/mock In-Reply-To: References: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> <8d961d900905032228o4eb0ef02ud85561cb7cac065@mail.gmail.com> Message-ID: <8e15872b0905040011v5bf356c1t820cb454ea21cb68@mail.gmail.com> It's possibly worth pointing out for anyone else who needs to do stubbing, that you don't necessarily need a framework to stub stuff; I have cucumber tests that stub out some setup code in my app*, and they just use monkey-patching to do the stubbing. For instance, in the example below, you could just do: module Geokit module Geocoders class GoogleGeocoder def call_geocoder_service(url) ... do whatever is needed to return appropriate test data end end end end You could even use alias_method to rename the original call_geocoder_service and call it if it got an unexpected url. I'm not sure which is better - this at least saves you from a dependency on an external stubbing/mocking framework. But it could be seen as uglier. - Korny * I know, this is not ideal, but it's testing a one-off migration script, and I didn't really want to make the script setup code generic, just to make the tests cleaner. On Mon, May 4, 2009 at 3:42 PM, Mike Doel wrote: > > On May 4, 2009, at 1:28 AM, aslak hellesoy wrote: > >> Is there a good rule of thumb for when you make exceptions to the 'no >> stubbing' philosophy of Cucumber? >> >> This is the rule of thumb: >> http://wiki.github.com/aslakhellesoy/cucumber/mocking-and-stubbing-with-cucumber > > I'm in a similar boat as Matt. ?My app does geocoding using Andre Lewis' > excellent geokit gem (and the Rails plugin). ?That stuff hits web-based > geocoders (Google in my case). ?I also scrape other web sites. > > So, in order to make my testing executable without a net connection and > avoid extra traffic on other folks' sites from my tests, I stub out the > actual net call with code like this: > > def stub_geocode_lookup(address,datafile) > ?@xml = File.read(RAILS_ROOT + "/spec/fixtures/geocodes/" + datafile) > ?response = MockSuccess.new > ?response.stubs(:body).returns(@xml) > ?stub_google_call(address,response) > end > > def stub_google_call(address,response) > ?url = > "http://maps.google.com/maps/geo?q=#{Geokit::Inflector::url_escape(address)}&output=xml&key=#{Geokit::Geocoders::google}&oe=utf-8" > ?Geokit::Geocoders::GoogleGeocoder.stubs(:call_geocoder_service).with(url).returns(response) > end > > > I also make use of FakeWeb in a couple places to do a similar thing for the > scraping of sites. ?I have a rake task that grabs fresh versions of the > pages I'm going to scrape and deposits it into my spec/fixtures directory. > ?If I run that every couple of days, I reduce my risk of having my fixture > data diverge too far from what the production app actually sees. > > Mike Doel > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" From mattvanhorn at gmail.com Mon May 4 06:49:23 2009 From: mattvanhorn at gmail.com (Matthew Van Horn) Date: Mon, 4 May 2009 06:49:23 -0400 Subject: [rspec-users] cucumber - when to stub/mock In-Reply-To: <8d961d900905040013x3444f2dfqee473644b36625f0@mail.gmail.com> References: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> <8d961d900905032228o4eb0ef02ud85561cb7cac065@mail.gmail.com> <3c30da400905040003y4e7a1ef1hcff29fa0a2d2225d@mail.gmail.com> <8d961d900905040013x3444f2dfqee473644b36625f0@mail.gmail.com> Message-ID: I followed Bryan's pattern here, and let RSpec reset everything. http://www.brynary.com/2009/2/3/cucumber-step-definition-tip-stubbing-time On May 4, 2009, at 3:13 AM, aslak hellesoy wrote: > > One thing to be aware of when stubbing: There is no cleanup/revert > logic yet in Cucumber. This means that if you stub a class method, > it will remain stubbed for subsequent scenarios. This means high > risk of coupled scenarios and unpredictable behaviour if you run > scenarios in different orders. > > If you need a cleanup facility (remove stubbed methods after a > scenario), please file a feature request. > > Aslak From lists at ruby-forum.com Mon May 4 08:33:12 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Mon, 4 May 2009 14:33:12 +0200 Subject: [rspec-users] Using Rails observers and testability Message-ID: <4698541eeb4afdf6b4dbc31e45140bd7@ruby-forum.com> Hi, Before I do anything stupid, I'd like to know if there are any gotchas when using Rails observers instead of writing my own methods or callbacks? Are they easy to spec/test or will I run into troubles? Are they easily mockable? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon May 4 09:32:38 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 4 May 2009 15:32:38 +0200 Subject: [rspec-users] cucumber - how to bootstrap outside of rails? In-Reply-To: <8d961d900905032237p5e198a97w905e49bec91d34cc@mail.gmail.com> References: <40c5fc4b-841b-4ade-a6fc-59b79f852cbe@d39g2000pra.googlegroups.com> <87078e29671263bfdc50e73091dbd1ff@ruby-forum.com> <8d961d900905031356w216e13a5i2463e261570fd42a@mail.gmail.com> <55d96c967a5ebd38c7dd12c8ce907bd1@ruby-forum.com> <8d961d900905032237p5e198a97w905e49bec91d34cc@mail.gmail.com> Message-ID: <6b8c9af4364845f50a24a5ef3421a944@ruby-forum.com> Aslak Helles?y wrote: > > Then that's a case for better documentation - not more Cucumber > features. > Feel free to create a separate Wiki page for "plain ruby" projects that > points the user to newgem and jeweler. Actually, that was what I was doing when I first raised the question. -- Posted via http://www.ruby-forum.com/. From bj at aboutus.org Mon May 4 13:57:16 2009 From: bj at aboutus.org (BJ Clark) Date: Mon, 4 May 2009 10:57:16 -0700 Subject: [rspec-users] Using Rails observers and testability In-Reply-To: <4698541eeb4afdf6b4dbc31e45140bd7@ruby-forum.com> References: <4698541eeb4afdf6b4dbc31e45140bd7@ruby-forum.com> Message-ID: <1288AC76-6309-4910-979C-45E2FAEC0C36@aboutus.org> Fernando, They are easier to spec with Pat Maddox's "no peeping toms" plugin. http://github.com/pat-maddox/no-peeping-toms/tree/master BJ Clark On May 4, 2009, at 5:33 AM, Fernando Perez wrote: > Hi, > > Before I do anything stupid, I'd like to know if there are any gotchas > when using Rails observers instead of writing my own methods or > callbacks? Are they easy to spec/test or will I run into troubles? Are > they easily mockable? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Mon May 4 15:39:26 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 4 May 2009 15:39:26 -0400 Subject: [rspec-users] Using Rails observers and testability In-Reply-To: <1288AC76-6309-4910-979C-45E2FAEC0C36@aboutus.org> References: <4698541eeb4afdf6b4dbc31e45140bd7@ruby-forum.com> <1288AC76-6309-4910-979C-45E2FAEC0C36@aboutus.org> Message-ID: <85d99afe0905041239n6ddc201bh3ce77d7a16002863@mail.gmail.com> On Mon, May 4, 2009 at 1:57 PM, BJ Clark wrote: > Fernando, > > They are easier to spec with Pat Maddox's "no peeping toms" plugin. > http://github.com/pat-maddox/no-peeping-toms/tree/master I use Pat's no-peeping-toms plugin as well. It's a great tool in Rails toolbox. Brandon Keepers has made some additional enhancements which are nice: http://github.com/collectiveidea/no-peeping-toms/tree/master I don't know if he has requested Pat to pull them in, but Pat if you're listening please check them out and consider pulling them in. As much as I like the ability to fork there's something to be said about having a consistent *official* home for plugins. ;) > > BJ Clark > > > On May 4, 2009, at 5:33 AM, Fernando Perez wrote: > >> Hi, >> >> Before I do anything stupid, I'd like to know if there are any gotchas >> when using Rails observers instead of writing my own methods or >> callbacks? Are they easy to spec/test or will I run into troubles? Are >> they easily mockable? >> -- >> 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 > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From kwevans at gmail.com Mon May 4 17:20:12 2009 From: kwevans at gmail.com (kwe) Date: Mon, 4 May 2009 14:20:12 -0700 (PDT) Subject: [rspec-users] Cucumber - wierd button pressing error Message-ID: I wonder if anyone has some clues as to what is happening in the following.. Output from running the feature.. Quote>> Scenario: Create an Order Given I'm viewing the Rubber Duck product When I press "Add to cart" Then I should see "Rubber Duck" When I press "Checkout" Then I should see "Checkout" When I fill in "order_name" with "Kevin Evans" And I fill in "order_email" with "kwevans at gmail.com" And I fill in "order_spinach" with "55555" And I press "Submit Order" uninitialized constant ActionController::AbstractRequest (NameError) (eval):2:in `/^I press "(.*)"$/' /Users/kwe/Sites/newtoys/features/cart.feature:44:in `And I press "Submit Order"' Then I should see "Thankyou for your order" Specifically, the And I press "Submit Order" uninitialized constant ActionController::AbstractRequest (NameError) (eval):2:in `/^I press "(.*)"$/' The other 'When I press" actions work fine?! From jfrankov at gmail.com Mon May 4 20:17:53 2009 From: jfrankov at gmail.com (jfrankov) Date: Mon, 4 May 2009 17:17:53 -0700 (PDT) Subject: [rspec-users] [Cucumber] undefined method `record' for # (NoMethodError) Message-ID: <89218554-6a80-442e-817b-7db3ec4e1ddd@y33g2000prg.googlegroups.com> I have a step definition file where I'm saving a model object and want to use this syntax (it's common, I see it in examples everywhere): Event.should have(1).record ...but it gives this error: undefined method `record' for # (NoMethodError) Am I missing some library or require or something? I added "require 'spec/expectations'" to my env.rb but no change. Any ideas? Thanks! -Jason From dchelimsky at gmail.com Tue May 5 01:45:14 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 May 2009 22:45:14 -0700 Subject: [rspec-users] [Cucumber] undefined method `record' for # (NoMethodError) In-Reply-To: <89218554-6a80-442e-817b-7db3ec4e1ddd@y33g2000prg.googlegroups.com> References: <89218554-6a80-442e-817b-7db3ec4e1ddd@y33g2000prg.googlegroups.com> Message-ID: <57c63afe0905042245h61270721t70ba556d4e528204@mail.gmail.com> On Mon, May 4, 2009 at 5:17 PM, jfrankov wrote: > I have a step definition file where I'm saving a model object and want > to use this syntax (it's common, I see it in examples everywhere): > > Event.should have(1).record This is an rspec-rails extension of ActiveRecord. It's not cucumber (or rspec-core). Try this (no guarantees): require 'spec/rails/extensions/active_record/base' That's where it's defined right now, though it might move in the future. If it works, please file a feature request at lighthouse and I'll see what I can do about exposing it somewhere more intuitive and permanent. Thanks, David > > ...but it gives this error: > > undefined method `record' for # (NoMethodError) > > Am I missing some library or require or something? I added "require > 'spec/expectations'" to my env.rb but no change. Any ideas? > > Thanks! > -Jason > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lee.hambley at gmail.com Tue May 5 10:03:36 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Tue, 5 May 2009 15:03:36 +0100 Subject: [rspec-users] [cucumber] Bug introduced in 0.3.1 In-Reply-To: References: Message-ID: Hi List, We didn't resolve this in the end, we rolled back to Cucumber 0.3.0; has anyone else seen anything similar? - Lee 2009/4/30 Julian Leviston > I have NO idea if this is relevant, but the way you extend worlds has > changed, I'm fairly sure. > Julian. > > > On 30/04/2009, at 10:15 PM, Lee Hambley wrote: > > Hi All, > > I'm new to the list, but a happy cucumber user with a few weeks experience > now... a bit of a shock this morning when someone upgraded here and happened > to jump up to 0.3.1, we're seeing the following output.. > > I haven't had chance to investigate more, but I will try to.. this goes > away if we roll back to 0.3.0. > > - http://gist.github.com/104429 > > I also listed the relevant local gems as far as I can see, I'll post back > here if I come up with anything, pointers or suggestions would be welcomed! > > Thank you, > > Lee Hambley > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pat.maddox at gmail.com Tue May 5 11:01:56 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Tue, 5 May 2009 08:01:56 -0700 Subject: [rspec-users] Using Rails observers and testability In-Reply-To: <85d99afe0905041239n6ddc201bh3ce77d7a16002863@mail.gmail.com> References: <4698541eeb4afdf6b4dbc31e45140bd7@ruby-forum.com> <1288AC76-6309-4910-979C-45E2FAEC0C36@aboutus.org> <85d99afe0905041239n6ddc201bh3ce77d7a16002863@mail.gmail.com> Message-ID: <2c7e61990905050801p33dd64b5mae5aab1c552e270b@mail.gmail.com> On Mon, May 4, 2009 at 12:39 PM, Zach Dennis wrote: > On Mon, May 4, 2009 at 1:57 PM, BJ Clark wrote: >> Fernando, >> >> They are easier to spec with Pat Maddox's "no peeping toms" plugin. >> http://github.com/pat-maddox/no-peeping-toms/tree/master > > I use Pat's no-peeping-toms plugin as well. It's a great tool in Rails toolbox. > > Brandon Keepers has made some additional enhancements which are nice: > > http://github.com/collectiveidea/no-peeping-toms/tree/master > > I don't know if he has requested Pat to pull them in, but Pat if > you're listening please check them out and consider pulling them in. Okay, done Pat From pat.maddox at gmail.com Tue May 5 12:34:00 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Tue, 5 May 2009 09:34:00 -0700 Subject: [rspec-users] cucumber - when to stub/mock In-Reply-To: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> References: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> Message-ID: <2c7e61990905050934i44a4707bs1fab13c10c0fe5c6@mail.gmail.com> Don't mock the Geolp library directly. Wrap it with an API that fits your domain better. Then write a very simple object that implements the same API but doesn't hit the network. You can use a switch somewhere in env.rb to use your fake implementation or the Geolp one. Pat On Sunday, May 3, 2009, Matthew Van Horn wrote: > I'm just curious about this, since my solution involved stubbing a call to GeoIp. > > Is there a good rule of thumb for when you make exceptions to the 'no stubbing' philosophy of Cucumber? > > My step was: "Given I am accessing the site from Japan," but I can think of other situations - mostly when interacting with web services, that I'd probably want to stub something, rather than requiring a net connection for testing. > > thanks for any advice, > Matt Van Horn > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bkocik at gmail.com Tue May 5 13:31:25 2009 From: bkocik at gmail.com (Bill Kocik) Date: Tue, 5 May 2009 13:31:25 -0400 Subject: [rspec-users] cucumber - when to stub/mock In-Reply-To: <2c7e61990905050934i44a4707bs1fab13c10c0fe5c6@mail.gmail.com> References: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> <2c7e61990905050934i44a4707bs1fab13c10c0fe5c6@mail.gmail.com> Message-ID: <310c80f00905051031w43bcee32id36c075b72885e08@mail.gmail.com> My absolute favorite solution for this: http://github.com/chrisk/fakeweb/tree/master I use that in an application I'm building that uses Twitter's OAuth, and otherwise heavily uses the Twitter API. It allows me to easily fake out all of Twitter's responses so I can do unit/integration/acceptance tests (with Cucumber and WebRat for the latter) without touching the network. As a matter of good practice, I always do this first: FakeWeb.allow_net_connect = false That ensures that any outbound HTTP requests that I forgot to fake out will cause FakeWeb to blow up in my face and let me know that I've missed something rather than silently letting it go by. On Tue, May 5, 2009 at 12:34 PM, Pat Maddox wrote: > Don't mock the Geolp library directly. Wrap it with an API that fits > your domain better. Then write a very simple object that implements > the same API but doesn't hit the network. You can use a switch > somewhere in env.rb to use your fake implementation or the Geolp one. > > Pat > > On Sunday, May 3, 2009, Matthew Van Horn wrote: >> I'm just curious about this, since my solution involved stubbing a call to GeoIp. >> >> Is there a good rule of thumb for when you make exceptions to the 'no stubbing' philosophy of Cucumber? >> >> My step was: "Given I am accessing the site from Japan," but I can think of other situations - mostly when interacting with web services, that I'd probably want to stub something, rather than requiring a net connection for testing. >> >> thanks for any advice, >> Matt Van Horn >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Bill Kocik http://bkocik.net From r_j_h_box-sf at yahoo.com Tue May 5 14:49:46 2009 From: r_j_h_box-sf at yahoo.com (Randy Harmon) Date: Tue, 05 May 2009 11:49:46 -0700 Subject: [rspec-users] Problem verifying routing error In-Reply-To: <49FCAAA6.6040600@yahoo.com> References: <49FCAAA6.6040600@yahoo.com> Message-ID: <4A008A4A.9060502@yahoo.com> Hi again. I haven't heard any responses on this thread (is this thing on? ;) . Is there any known pattern for verifying a route that *doesn't* exist, as of Rspec 1.2.6? Thanks, Randy Randy Harmon wrote: > Hi, > > When upgrading to rspec/rspec-rails 1.2.6 gem (from 1.1.12), I'm having > a new problem verifying routes that should not exist. > > This is to support something like this in routes.rb: > > map.resources :orders do |orders| > orders.resources :items, :except => [:index,:show] > end > > I used to use lambda {}.should_raise( routing error ), but it stopped > detecting any raised error. Requesting it through the browser produces > ActionController::MethodNotAllowed (Only post requests are allowed). But > that error wasn't detected. > > When I skip the lambda, and just ask it to verify that the route does > exist (which *should* fail), I get the same result for those :except > actions as for a made-up action name. Seems this must have something to > do with the change in how route_for delegates back to ActionController's > routing assertion (sez the backtrace :). > > > NoMethodError in 'ItemsController route generation should NOT map > #indewfefwex' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.first > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:134:in > `recognized_request_for' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:49:in > `assert_recognizes' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions.rb:54:in > `clean_backtrace' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:47:in > `assert_recognizes' > ./spec/controllers/thoughts_routing_spec.rb:9: > > > I tried using bypass_rescue in my routing/items_routing_spec.rb file as > mentioned by the upgrade doc, but it wasn't valid in the "routing" spec > - worked fine when I moved the file back to spec/controllers/, though. > Seems like that's not the issue, but I'm mentioning for more completeness. > > Any ideas what I should be doing instead, or how I can troubleshoot further? > > Thanks, > > Randy > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From rjharmon0316 at yahoo.com Tue May 5 14:49:00 2009 From: rjharmon0316 at yahoo.com (Randy Harmon) Date: Tue, 05 May 2009 11:49:00 -0700 Subject: [rspec-users] Problem verifying routing error In-Reply-To: <49FCAAA6.6040600@yahoo.com> References: <49FCAAA6.6040600@yahoo.com> Message-ID: <4A008A1C.4010007@yahoo.com> Hi again. I haven't heard any responses on this thread (is this thing on? ;). Is there any known pattern for verifying a route that *doesn't* exist, as of Rspec 1.2.6? Thanks, Randy Randy Harmon wrote: > Hi, > > When upgrading to rspec/rspec-rails 1.2.6 gem (from 1.1.12), I'm having > a new problem verifying routes that should not exist. > > This is to support something like this in routes.rb: > > map.resources :orders do |orders| > orders.resources :items, :except => [:index,:show] > end > > I used to use lambda {}.should_raise( routing error ), but it stopped > detecting any raised error. Requesting it through the browser produces > ActionController::MethodNotAllowed (Only post requests are allowed). But > that error wasn't detected. > > When I skip the lambda, and just ask it to verify that the route does > exist (which *should* fail), I get the same result for those :except > actions as for a made-up action name. Seems this must have something to > do with the change in how route_for delegates back to ActionController's > routing assertion (sez the backtrace :). > > > NoMethodError in 'ItemsController route generation should NOT map > #indewfefwex' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.first > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:134:in > `recognized_request_for' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:49:in > `assert_recognizes' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions.rb:54:in > `clean_backtrace' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:47:in > `assert_recognizes' > ./spec/controllers/thoughts_routing_spec.rb:9: > > > I tried using bypass_rescue in my routing/items_routing_spec.rb file as > mentioned by the upgrade doc, but it wasn't valid in the "routing" spec > - worked fine when I moved the file back to spec/controllers/, though. > Seems like that's not the issue, but I'm mentioning for more completeness. > > Any ideas what I should be doing instead, or how I can troubleshoot further? > > Thanks, > > Randy > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From sera at fhwang.net Tue May 5 16:29:32 2009 From: sera at fhwang.net (Francis Hwang) Date: Tue, 5 May 2009 16:29:32 -0400 Subject: [rspec-users] DB transactions w/ RSpec Message-ID: <7b561b930905051329h6aeaea1erf4cca8ed8f1d2f10@mail.gmail.com> Sorry if this has been answered elsewhere, Google was not very helpful to me on this one. If I'm running a model spec and am one of those benighted souls who wants to hit the DB while doing so, is there a way for me to tell RSpec to skip transactions? In Test::Unit I can say "uses_transaction :test_should_do_something", but am not sure what the analogous thing would be in RSpec. Thanks in advance, Francis From mattvanhorn at gmail.com Tue May 5 14:43:23 2009 From: mattvanhorn at gmail.com (Matthew Van Horn) Date: Tue, 5 May 2009 14:43:23 -0400 Subject: [rspec-users] cucumber - when to stub/mock In-Reply-To: <2c7e61990905050934i44a4707bs1fab13c10c0fe5c6@mail.gmail.com> References: <1E477BD0-720C-49CD-98B9-3ED6FD155ACC@gmail.com> <2c7e61990905050934i44a4707bs1fab13c10c0fe5c6@mail.gmail.com> Message-ID: <275C0357-E29C-4DDC-8326-201B63A102D0@gmail.com> Actually, I do have my own object wrapping GeoIp, and I stubbed the method on that object that returns a country code for me. I can see maybe creating another object to be used in the test environment, but I can't see what advantages that offers over using the rspec mocking framework. On May 5, 2009, at 12:34 PM, Pat Maddox wrote: > Don't mock the Geolp library directly. Wrap it with an API that fits > your domain better. Then write a very simple object that implements > the same API but doesn't hit the network. You can use a switch > somewhere in env.rb to use your fake implementation or the Geolp one. > > Pat > > On Sunday, May 3, 2009, Matthew Van Horn > wrote: >> I'm just curious about this, since my solution involved stubbing a >> call to GeoIp. >> >> Is there a good rule of thumb for when you make exceptions to the >> 'no stubbing' philosophy of Cucumber? >> >> My step was: "Given I am accessing the site from Japan," but I can >> think of other situations - mostly when interacting with web >> services, that I'd probably want to stub something, rather than >> requiring a net connection for testing. >> >> thanks for any advice, >> Matt Van Horn >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 mattvanhorn at gmail.com Wed May 6 09:50:41 2009 From: mattvanhorn at gmail.com (Matthew Van Horn) Date: Wed, 6 May 2009 09:50:41 -0400 Subject: [rspec-users] cucumber segfaults Message-ID: <1F817FAF-D906-4BD7-BC81-6DB993781A7D@gmail.com> Just started getting this, every time I run rake features: myapp/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/ rack/lint.rb:16: [BUG] Segmentation fault ruby 1.8.6 (2008-03-03) [i686-darwin9.2.2] after updating from cucumber 0.3.0 to 0.3.2 I'm now getting the segfault here: myapp/vendor/gems/nokogiri-1.2.3/lib/nokogiri/xml/node_set.rb:138: [BUG] Segmentation fault ruby 1.8.6 (2008-03-03) [i686-darwin9.2.2] While trying to ascertain a cause, I discovered something weird. It seems to be related to the number of scenarios I'm running. I had 11 scenarios, and I was getting the error every time. I tried to isolate a cause, but the bug would not happen for any individual scenario. I thought maybe there's some combination effect, so I started grouping them. I can get the error to happen about 50% of the time if I have 3 or 4 scenarios (10-12 steps) It happens 100% of the time with more than 6 scenarios. It happens 0% with any of the individual scenarios. any ideas how to debug this? From lists at ruby-forum.com Wed May 6 10:35:21 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 6 May 2009 16:35:21 +0200 Subject: [rspec-users] Cucunber - does not honour here-document syntax? Message-ID: something_steps.rb TEST = 'A constant' puts TEST SCRIPT <<-'END_SCRIPT' ... END_SCRIPT Then /.../ do $ cucumber -r features features/lib/something.feature A constant ./features/lib/step_definitions/something__steps.rb:9: undefined method `SCRIPT' for # (NoMethodError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' from /usr/lib64/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /usr/lib64/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/cucumber/cli/main.rb:79:in `require_files' from /usr/lib64/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/cucumber/cli/main.rb:77:in `each' from /usr/lib64/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/cucumber/cli/main.rb:77:in `require_files' from /usr/lib64/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/cucumber/cli/main.rb:34:in `execute!' from /usr/lib64/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/cucumber/cli/main.rb:20:in `execute' from /usr/lib64/ruby/gems/1.8/gems/cucumber-0.3.2/bin/cucumber:6 from /usr/bin/cucumber:19:in `load' from /usr/bin/cucumber:19 $ Is this a deliberate limitation in Cucumber or a bug? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed May 6 11:28:22 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 6 May 2009 08:28:22 -0700 Subject: [rspec-users] have_selector only matching immediate descendants in block In-Reply-To: <50873a360905060714l3999106bge9345d66dbb1286d@mail.gmail.com> References: <50873a360905060714l3999106bge9345d66dbb1286d@mail.gmail.com> Message-ID: <57c63afe0905060828v25a38ffbj8fdb57f86da2391f@mail.gmail.com> On Wed, May 6, 2009 at 7:14 AM, doug livesey wrote: > Hi -- I have an expectation that looks like this: > > ? it "should display a field for the username" do > ??? do_render > ??? response.should have_selector( "form" ) do |form| > ????? form.should have_selector( "input", :name => "username" ) > ??? end > ? end > > > That gives me this error: > > ? 'session/new.html.haml should display a field for the username' FAILED > ? expected following output to contain a tag: > ?
> ???

> ????? > ? ? ?

> ???

> ????? > ?????

> ??? > ?
> > When I don't try to match inside the form (so just saying "response.should > have_selector( "input" ... )"), it passes fine. > So is have_selector supposed to only match immediate descendants of the > selector in the block definition, or is this a bug ... > ... Or am I being seriously dumb, here? ;) have_selector is from webrat and there is a separate webrat google group. Might want to try there, or filing a bug report with webrat: http://groups.google.com/group/webrat https://webrat.lighthouseapp.com/ Cheers, David > Cheers, Doug. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed May 6 11:52:47 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 6 May 2009 17:52:47 +0200 Subject: [rspec-users] Cucunber - does not honour here-document syntax? In-Reply-To: <8d961d900905060816k596078cbiee6c50617b451792@mail.gmail.com> References: <8d961d900905060816k596078cbiee6c50617b451792@mail.gmail.com> Message-ID: <84d0d3557dc8f64b771c77f379b78094@ruby-forum.com> Aslak Helles?y wrote: > It's Ruby, not Cucumber that parses .rb files. (Even if you have ruby > code > that uses the Cucumber API in them). > > You have a Ruby syntax error. You missed the = sign after SCRIPT ;-) > > Aslak > > something_steps.rb Sigh... -- Posted via http://www.ruby-forum.com/. From sera at fhwang.net Wed May 6 12:43:00 2009 From: sera at fhwang.net (Francis Hwang) Date: Wed, 6 May 2009 12:43:00 -0400 Subject: [rspec-users] DB transactions w/ RSpec In-Reply-To: <632154f70905060647v5ec4104co35a5317cfe32c04f@mail.gmail.com> References: <7b561b930905051329h6aeaea1erf4cca8ed8f1d2f10@mail.gmail.com> <632154f70905060647v5ec4104co35a5317cfe32c04f@mail.gmail.com> Message-ID: <7b561b930905060943p498f7715kc3c1d3110686ec5c@mail.gmail.com> On Wed, May 6, 2009 at 9:47 AM, Nicholas Van Weerdenburg wrote: > As far as I can tell, RSpec simply uses inherited TestCase capabilities for > transactions, including use_transactional_fixtures (it's config setting is > simply passed on) and likely uses_transaction. > I'm guessing you can do something like: > > uses_transaction :create > it "should save message" do > ... > end > > At least it gives no exception for me. > The TestCase logic is pretty simple- it skips transactional fixtures if the > method is in it's array, so I imagine it works. > If not, this shoulda ticket talks about the same need, with a patch that > integrates it into shoulda contexts. That might give some clues. > https://thoughtbot.lighthouseapp.com/projects/5807-shoulda/tickets/97 Any thoughts on what uses_transaction wants as an argument? I can't help but feel like I've tried 10 combinations of ways to do this, and there's some 11th way that will be easy but I haven't thought to try. For context, my code doesn't even use transactions; it's using a 2nd DB connection to a slave DB, which will be different in some envs and not others. This seems to get tripped up by transactions since the master connection makes a change to the DB and the slave connection needs to see it right away. (Yes I know in production there are latency issues, that's acceptable in this case.) > BTW- I happened to be watching your RubyConf2008 Testing Heresies talk > yesterday. Good talk. Thanks! Francis From matt at mattwynne.net Wed May 6 14:15:59 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 6 May 2009 19:15:59 +0100 Subject: [rspec-users] Extending RSpec- Best Practices? In-Reply-To: <632154f70905060652l114b23a1p6615d7b8227d3d16@mail.gmail.com> References: <632154f70905060652l114b23a1p6615d7b8227d3d16@mail.gmail.com> Message-ID: <9653B119-BCDD-4ED8-BFF6-47560576AAAD@mattwynne.net> On 6 May 2009, at 14:52, Nicholas Van Weerdenburg wrote: > Hi, > > I'm reading the RSpec book and it makes references to macros from > shoulda and rspec_on_rail_on_crack, but doesn't integrate them, > simply describing how to write your own macro. I see there is the > "Remarkable" project as well. > > After some more googling, I can't make up my mind if I should use > these with RSpec or not. As I'm new to them all, I'd like to hear > some opinions/experiences in using them with recent versions. > > The one knock I've heard regarding macros is that it can slant > design to fit the macro's. I use them quite a bit, and really like them - I factor them out of repetitive tests to make little DSLs for testing specific things. Can you give us a couple of examples of what you're trying to do? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Wed May 6 14:59:23 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 6 May 2009 19:59:23 +0100 Subject: [rspec-users] [cucumber] How to DRY up table data that I'm seeing across tests ? In-Reply-To: References: Message-ID: <174CD937-1D01-4BDF-A515-07F9A3F7A124@mattwynne.net> On 6 May 2009, at 19:28, John Goodsen wrote: > Another thing I'm looking into is trying to hook into the visitor/ > formatting stuff and just spit out the extra data fixture data when > the test runs... thoughts anyone? > > On Wed, May 6, 2009 at 2:13 PM, John Goodsen > wrote: > I have the following step that I want to re-use in several > scenarios. It looks like this: > > When I submit the form > |form_field_id |value| > |billingAddress.email |mickey_mouse at test.com| > |billingAddress.firstName |Mickey| > |billingAddress.lastName |Mouse| > |billingAddress.street1 |249 Cross Road| > |billingAddress.city |Sanford| > |billingAddress.subCountry |ME| > |billingAddress.zipPostalCode|04073| > |billingAddress.country |US| > > This step fills out a form using Selenium behind the scenes. It's > been copied into several scenarios and I want to DRY it up. I DRY'd > this up by moving this table data into a fixture file > (mickey_mouse.yml), but then the test becomes less descriptive - the > original scenario step above turned into a one-liner: > > When I submit the form for "mickey_mouse" > > I think ideally, I would like some kind of "include_step" feature in > cucumber - where we can write partial snippets and include them > wherever I want. When cucumber runs, it can replace the included > step. So I could keep my tests DRY with something like: > > When I submit the form > Include 'submit_form_for_mickey_mouse' > > but when I run the test, cucumber would spit out the partial > contents in place of the Include to make the test more descriptive. > > Is there anything in cucumber that would help me out right now? > What I'm currently looking into is hooking into the formatting and > overriding some rendering - but it feels like a bad hack. Why not write a wrapper step, something like Given /I submit the billing address form with valid data/ do submit_form { :email => 'mickey_mouse at test.com', :firstName => 'Mickey'} # etc end And call that from your feature? Do you really need to see all the fields in the formatted output? Are they relevant to the particular scenario you're building, or just noise? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From sera at fhwang.net Wed May 6 15:57:02 2009 From: sera at fhwang.net (Francis Hwang) Date: Wed, 6 May 2009 15:57:02 -0400 Subject: [rspec-users] DB transactions w/ RSpec In-Reply-To: <632154f70905061142x5dc35d86l833a8b917de256b1@mail.gmail.com> References: <7b561b930905051329h6aeaea1erf4cca8ed8f1d2f10@mail.gmail.com> <632154f70905060647v5ec4104co35a5317cfe32c04f@mail.gmail.com> <7b561b930905060943p498f7715kc3c1d3110686ec5c@mail.gmail.com> <632154f70905061142x5dc35d86l833a8b917de256b1@mail.gmail.com> Message-ID: <7b561b930905061257k5f95fe11v1074fdede56ee09b@mail.gmail.com> Yeah, that worked for me, thanks. And for whatever reason nesting was part of the problem, but if I put it all in one top-level describe with the examples below it worked fine. FH On Wed, May 6, 2009 at 2:42 PM, Nicholas Van Weerdenburg wrote: > The rails code is pretty straightforward: > ??def uses_transaction(*methods) > ?? ? ? ?@uses_transaction = [] unless defined?(@uses_transaction) > ?? ? ? ?@uses_transaction.concat methods.map(&:to_s) > ?? ? ?end > ?? ? ?def uses_transaction?(method) > ?? ? ? ?@uses_transaction = [] unless defined?(@uses_transaction) > ?? ? ? ?@uses_transaction.include?(method.to_s) > ?? ? ?end > ?? ?end > ?? ?def run_in_transaction? > ?? ? ?use_transactional_fixtures && > ?? ? ? ?!self.class.uses_transaction?(method_name) > ?? ?end > Works for me in my tests. > uses_transaction "it should do this" > it "should do this" do > ??puts "runs in transaction=#{self.run_in_transaction?}" > end > runs as expected, providing false when the uses_transaction is set, and true > otherwise (assuming???config.use_transactional_fixtures = true). > Regards, > Nick > On Wed, May 6, 2009 at 12:43 PM, Francis Hwang wrote: >> >> On Wed, May 6, 2009 at 9:47 AM, Nicholas Van Weerdenburg >> wrote: >> > As far as I can tell, RSpec simply uses inherited TestCase capabilities >> > for >> > transactions, including use_transactional_fixtures (it's config setting >> > is >> > simply passed on) and likely uses_transaction. >> > I'm guessing you can do something like: >> > >> > ? ? uses_transaction :create >> > ? ? it "should save message" do >> > ? ? ? ? ... >> > ? ? end >> > >> > At least it gives no exception for me. >> > The TestCase logic is pretty simple- it skips transactional fixtures if >> > the >> > method is in it's array, so I imagine it works. >> > If not, this shoulda ticket talks about the same need, with a patch that >> > integrates it into shoulda contexts. That might give some clues. >> > https://thoughtbot.lighthouseapp.com/projects/5807-shoulda/tickets/97 >> >> Any thoughts on what uses_transaction wants as an argument? I can't >> help but feel like I've tried 10 combinations of ways to do this, and >> there's some 11th way that will be easy but I haven't thought to try. >> >> For context, my code doesn't even use transactions; it's using a 2nd >> DB connection to a slave DB, which will be different in some envs and >> not others. This seems to get tripped up by transactions since the >> master connection makes a change to the DB and the slave connection >> needs to see it right away. (Yes I know in production there are >> latency issues, that's acceptable in this case.) >> >> > BTW- I happened to be watching your RubyConf2008 Testing Heresies talk >> > yesterday. Good talk. >> >> Thanks! >> >> Francis >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 rick.denatale at gmail.com Wed May 6 20:28:12 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Wed, 6 May 2009 20:28:12 -0400 Subject: [rspec-users] top posting and plain text In-Reply-To: <4A021E5D.3030309@benmabey.com> References: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> <4A021E5D.3030309@benmabey.com> Message-ID: On Wed, May 6, 2009 at 7:33 PM, Ben Mabey wrote: > + 1 > > > aslak hellesoy wrote: > > Folks, > > *snip* > > Thanks, > Aslak So let me get this right, you agreed with Aslak that you shouldn't top post. by top posting???? -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From ben at benmabey.com Wed May 6 20:46:39 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 06 May 2009 17:46:39 -0700 Subject: [rspec-users] top posting and plain text In-Reply-To: References: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> <4A021E5D.3030309@benmabey.com> Message-ID: <4A022F6F.9030105@benmabey.com> Rick DeNatale wrote: > On Wed, May 6, 2009 at 7:33 PM, Ben Mabey wrote: > >> + 1 >> >> >> aslak hellesoy wrote: >> >> Folks, >> >> *snip* >> >> Thanks, >> Aslak >> > > So let me get this right, > > you agreed with Aslak that you shouldn't top post. > > by top posting???? > > lol.. Yes. :) Sarcasm somethings doesn't come across well over email I suppose. -Ben From steve at fenestra.com Wed May 6 20:54:38 2009 From: steve at fenestra.com (Steve Schafer) Date: Wed, 06 May 2009 20:54:38 -0400 Subject: [rspec-users] top posting and plain text In-Reply-To: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> References: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> Message-ID: Just so you know, _your_ message isn't just plain text. Here's a portion of the raw message: >--===============0527642389== >Content-Type: multipart/alternative; boundary=001636c5b0eedf7860046942ecfc > >--001636c5b0eedf7860046942ecfc >Content-Type: text/plain; charset=ISO-8859-1 >Content-Transfer-Encoding: 7bit > >Folks, > >I find it really hard to follow conversations that use top posting ( >http://en.wikipedia.org/wiki/Posting_style). >If you have a [Cucumber] topic, please respond with inline comments. And use >plain text email - not html. > >Thanks, >Aslak > >--001636c5b0eedf7860046942ecfc >Content-Type: text/html; charset=ISO-8859-1 >Content-Transfer-Encoding: quoted-printable > >Folks,

I find it really hard to follow conversations that use top po= >sting (http://en.wik= >ipedia.org/wiki/Posting_style).
If you have a [Cucumber] topic, plea= >se respond with inline comments. And use plain text email - not html.
>
Thanks,
Aslak
> >--001636c5b0eedf7860046942ecfc-- >--===============0527642389== -Steve From sera at fhwang.net Wed May 6 21:09:23 2009 From: sera at fhwang.net (Francis Hwang) Date: Wed, 6 May 2009 21:09:23 -0400 Subject: [rspec-users] top posting and plain text In-Reply-To: <4A022F6F.9030105@benmabey.com> References: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> <4A021E5D.3030309@benmabey.com> <4A022F6F.9030105@benmabey.com> Message-ID: <6F6A581C-CB33-49D2-93A5-28E083ACB8A0@fhwang.net> How about both top and bottom posting? Francis Hwang http://fhwang.net/ On May 6, 2009, at 8:46 PM, Ben Mabey wrote: > lol.. Yes. :) Sarcasm somethings doesn't come across well over > email I suppose. How about both top and bottom posting? Francis Hwang http://fhwang.net/ From andrew at avit.ca Wed May 6 21:17:07 2009 From: andrew at avit.ca (Andrew Vit) Date: Wed, 6 May 2009 18:17:07 -0700 Subject: [rspec-users] top posting and plain text In-Reply-To: References: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> <4A021E5D.3030309@benmabey.com> Message-ID: <9864685B-38EF-4D7D-88CC-7907A259D184@avit.ca> On May 6, 2009, at 5:28 PM, Rick DeNatale wrote: > On Wed, May 6, 2009 at 7:33 PM, Ben Mabey wrote: >> + 1 >> >> >> aslak hellesoy wrote: >> >> Folks, >> >> *snip* >> >> Thanks, >> Aslak > > So let me get this right, > > you agreed with Aslak that you shouldn't top post. > > by top posting???? And Aslak's post was multipart/mime!? Was that just for the irony? You guys are funny... :-) Andrew Vit From apremdas at gmail.com Thu May 7 05:42:51 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 7 May 2009 10:42:51 +0100 Subject: [rspec-users] Features failing to run correctly under 0.3.2 In-Reply-To: <88fd8ddc0905062159p3e775f99q76d1fa47cf4343a3@mail.gmail.com> References: <88fd8ddc0905060920x5a922fe2l731e43badd1cb719@mail.gmail.com> <8d961d900905061108i7d3adb0bne21673b278bc36db@mail.gmail.com> <88fd8ddc0905062159p3e775f99q76d1fa47cf4343a3@mail.gmail.com> Message-ID: <88fd8ddc0905070242y51e89e68y3f76afb363f7c33d@mail.gmail.com> Tried this out using your github repository. Can confirm this fixes our bug - looking forward to next gem release Thanks Andrew 2009/5/7 Andrew Premdas : > Thanks Aslak, I'll try this out when I get to work. > > Andrew > > 2009/5/6 aslak hellesoy >> >> >> On Wed, May 6, 2009 at 9:20 AM, Andrew Premdas wrote: >>> >>> Having significant problems getting an upto date environment with >>> cucumber and rspec since 0.3.0. I have put the relevant files including a >>> backtrace ?in a gist?http://gist.github.com/107586. I'd really appreciate it >>> if someone could take a look at this. >>> All these features ran fine using cuc 0.3.0 and rspec 1.2.2 >> >> There is already a bug report for this: >> >> >> https://rspec.lighthouseapp.com/projects/16211/tickets/309-background-scenario-outline-before-hook-interaction >> >>> >>> Many thanks >>> Andrew From julian at leviston.net Thu May 7 06:02:01 2009 From: julian at leviston.net (Julian Leviston) Date: Thu, 7 May 2009 20:02:01 +1000 Subject: [rspec-users] [Cucumber] Rails Selenium ruby-debug In-Reply-To: <88fd8ddc0905070242y51e89e68y3f76afb363f7c33d@mail.gmail.com> References: <88fd8ddc0905060920x5a922fe2l731e43badd1cb719@mail.gmail.com> <8d961d900905061108i7d3adb0bne21673b278bc36db@mail.gmail.com> <88fd8ddc0905062159p3e775f99q76d1fa47cf4343a3@mail.gmail.com> <88fd8ddc0905070242y51e89e68y3f76afb363f7c33d@mail.gmail.com> Message-ID: <37946975-C26C-44DE-95D2-2739FD7571DB@leviston.net> Hey all, Has anyone else had any issues with trying to get APPLICATION code debugging when using cucumber, selenium & webrat? I can debug steps just fine, but debugs in application code get skipped over under selenium for some reason. Is this usual? Julian. From matt at mattwynne.net Thu May 7 07:44:43 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 7 May 2009 12:44:43 +0100 Subject: [rspec-users] [Cucumber] Rails Selenium ruby-debug In-Reply-To: <37946975-C26C-44DE-95D2-2739FD7571DB@leviston.net> References: <88fd8ddc0905060920x5a922fe2l731e43badd1cb719@mail.gmail.com> <8d961d900905061108i7d3adb0bne21673b278bc36db@mail.gmail.com> <88fd8ddc0905062159p3e775f99q76d1fa47cf4343a3@mail.gmail.com> <88fd8ddc0905070242y51e89e68y3f76afb363f7c33d@mail.gmail.com> <37946975-C26C-44DE-95D2-2739FD7571DB@leviston.net> Message-ID: <1182482F-A731-476B-9E91-EAE5B02B9418@mattwynne.net> On 7 May 2009, at 11:02, Julian Leviston wrote: > Hey all, > > Has anyone else had any issues with trying to get APPLICATION code > debugging when using cucumber, selenium & webrat? > > I can debug steps just fine, but debugs in application code get > skipped over under selenium for some reason. > > Is this usual? Well it's out of process, so that might have something to do with it. I don't know how webrat starts the mongrel to serve pages to selenium, but that's where you'd need to look. I suggest you ask on the webrat mailing list about this. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From julian at leviston.net Thu May 7 05:39:16 2009 From: julian at leviston.net (Julian Leviston) Date: Thu, 7 May 2009 19:39:16 +1000 Subject: [rspec-users] [cucumber] Is it usual that selenium doesn't allow debugger? In-Reply-To: <88fd8ddc0905062153n2a2286d6j71ec1ed4fafd9042@mail.gmail.com> References: <88fd8ddc0905060920x5a922fe2l731e43badd1cb719@mail.gmail.com> <8d961d900905061049g690aa601va0b0e6b42b50cb7e@mail.gmail.com> <88fd8ddc0905062153n2a2286d6j71ec1ed4fafd9042@mail.gmail.com> Message-ID: Hi, We're using Rails 2.3.2, and debugger doesn't seem to work in cucumber/ webrat running selenium mode. Has anyone else had this issue? It seems to be skipping the debugger methods Julian. From lists at ruby-forum.com Thu May 7 09:46:46 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Thu, 7 May 2009 15:46:46 +0200 Subject: [rspec-users] Plugin to generate text logs using cucumber. In-Reply-To: <49FB4CAF.7070100@benmabey.com> References: <6ffb72010905011206t52c94c44heff17a4db0f0370a@mail.gmail.com> <49FB4CAF.7070100@benmabey.com> Message-ID: Hi Thanks for information. It helped me a lot. bascically using cucumber framework(using stdoutput) i want to capture Failed testcase along with log and passed testcasenames. Is there any plugin supported by cucumber ? atleast to generated xml of html or text log for passed and failed testcase. Because --o FILENAME just write standout to the given file. Thanks, -- Posted via http://www.ruby-forum.com/. From devryguy at gmail.com Wed May 6 20:08:00 2009 From: devryguy at gmail.com (DVG) Date: Wed, 6 May 2009 17:08:00 -0700 (PDT) Subject: [rspec-users] Newbie: Rspec, Webrat, Mechanize, Cucumber Message-ID: <9f7f32ad-2bf8-4331-9943-7f28c80685c0@o20g2000vbh.googlegroups.com> Alright, I'm trying to get up to speed with using Rspec, Webrat, Mechanize and Cucumber to test a non rails application. The RSpec Matchers (I think) seem to not be working as expected. When I run my feature, it says the world cannot find the method "contain" I have the following gems installed: cucumber 0.3.2 rspec 1.2.6 mechanize 0.9.2 webrat 0.4.4 My feature is as follows: Feature: Google In order to buy a sweet new laptop As a apple enthusiest I want to find apple.com Scenario: Search for apple Given I visit "http://www.google.com" When I fill in "q" with "apple.com" And I press "Google Search" Then I should see "www.apple.com" #env.rb require 'webrat' Webrat.configure do |config| config.mode = :mechanize end require 'webrat/core/matchers' require 'webrat/mechanize' class MechanizeWorld < Webrat::MechanizeSession require 'spec' include Spec::Matchers end World do MechanizeWorld.new end #webrat_steps ... Given /^I visit "(.*)"$/ do |url| visit(url) end When I run the feature, everything passes except for the last step, "should see" Then /^I should see "([^\"]*)"$/ do |text| response.should contain(text) end The error it gives is: Then I should see "www.apple.com" undefined method `contain' for # (NoMethodError) ./features/step_definitions/webrat_steps.rb:94:in `/^I should see "([^\"]*)"$/' features/google.feature:10:in `Then I should see "www.apple.com"' As far as I know, contain is an rspec matcher which is getting included in MechanizeWorld, but it doesn't seem to be working properly. Any ideas? From jeroenvdoorn at gmail.com Thu May 7 07:32:04 2009 From: jeroenvdoorn at gmail.com (jevado) Date: Thu, 7 May 2009 04:32:04 -0700 (PDT) Subject: [rspec-users] Mocha and rspec_scaffold Message-ID: <0585371a-6aaa-4aec-b7bf-57a0222003db@o30g2000vbc.googlegroups.com> Hi All, I'm busy experimenting with RSpec and encountered a small issue with the scaffolding. As soon as I chooce mocha as my mocking framework in the spec helper the specs created with rspec_scaffold fail. Is this a bug or do the rspec_generators only work with the default mocking framework ? I've tested it on a clean rails app to make sure it wasn't something else. Kind regards, Jeroen From jeroenvdoorn at gmail.com Thu May 7 07:40:35 2009 From: jeroenvdoorn at gmail.com (jevado) Date: Thu, 7 May 2009 04:40:35 -0700 (PDT) Subject: [rspec-users] rspec_scaffold and mocha Message-ID: <22765d31-f530-4cd4-af9d-02db2cb936f2@z7g2000vbh.googlegroups.com> Hi All, I have a question about the rspec_scaffold and if it's compatible with other mocking frameworks. I just created a blank application and a scaffold of a very basic model. The specs run fine untill I choose to use mocha in the spec_helper. Can somebody please tell me if this is ment to be and if so if there's an easy way to make the scaffold work with mocha ? Thanks in advance! Jeroen From julian at coretech.net.au Thu May 7 06:35:11 2009 From: julian at coretech.net.au (Julian Leviston) Date: Thu, 7 May 2009 20:35:11 +1000 Subject: [rspec-users] [Cucumber] Rails Selenium ruby-debug In-Reply-To: <37946975-C26C-44DE-95D2-2739FD7571DB@leviston.net> References: <88fd8ddc0905060920x5a922fe2l731e43badd1cb719@mail.gmail.com> <8d961d900905061108i7d3adb0bne21673b278bc36db@mail.gmail.com> <88fd8ddc0905062159p3e775f99q76d1fa47cf4343a3@mail.gmail.com> <88fd8ddc0905070242y51e89e68y3f76afb363f7c33d@mail.gmail.com> <37946975-C26C-44DE-95D2-2739FD7571DB@leviston.net> Message-ID: <855ED8B8-AE1C-4307-847E-DE296C010A23@coretech.net.au> On 07/05/2009, at 8:02 PM, Julian Leviston wrote: > Hey all, > > Has anyone else had any issues with trying to get APPLICATION code > debugging when using cucumber, selenium & webrat? > > I can debug steps just fine, but debugs in application code get > skipped over under selenium for some reason. > > Is this usual? > > Julian. Hi. I realised that it was because I was simply running the server automatically - when I manually started it, I got access to the debugger server. All good. Thanks Julian. From kero at chello.nl Thu May 7 13:12:47 2009 From: kero at chello.nl (Kero van Gelder) Date: Thu, 7 May 2009 19:12:47 +0200 Subject: [rspec-users] top posting and plain text In-Reply-To: <4A022F6F.9030105@benmabey.com> References: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> <4A021E5D.3030309@benmabey.com> <4A022F6F.9030105@benmabey.com> Message-ID: <20090507171247.GJ980@bumblebee.m38c.nl> >> So let me get this right, >> >> you agreed with Aslak that you shouldn't top post. >> >> by top posting???? >> > lol.. Yes. :) Sarcasm somethings doesn't come across well over email > I suppose. Not only that, he did it in so it was impossible for me to see whether it was top or bottom. The sarcasm was clear enough, tho ;) +1 from me, too. I'm adding a request: cut out the paragraphs of the email that you are not responding to. I'm encountering plenty of emails that don't fit on my screen (which is much bigger than an iPhone) and turn out to contain not much more than "yes", "thanks" or "see lighthouse ". Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From rick.denatale at gmail.com Thu May 7 13:31:33 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 7 May 2009 13:31:33 -0400 Subject: [rspec-users] [cucumber] Is it usual that selenium doesn't allow debugger? In-Reply-To: References: <88fd8ddc0905060920x5a922fe2l731e43badd1cb719@mail.gmail.com> <8d961d900905061049g690aa601va0b0e6b42b50cb7e@mail.gmail.com> <88fd8ddc0905062153n2a2286d6j71ec1ed4fafd9042@mail.gmail.com> Message-ID: On Thu, May 7, 2009 at 5:39 AM, Julian Leviston wrote: > Hi, > > We're using Rails 2.3.2, and debugger doesn't seem to work in > cucumber/webrat running selenium mode. Has anyone else had this issue? > > It seems to be skipping the debugger methods Rails noops the debugger method by default with a method which just logs the call. If Kernel already has a debugger method then it doesn't. If you run script/server with the -u / --debugger option, then it requires 'ruby-debug' and calls ::Debugger.start during initialization. Rails 2.3 does this by inserting a rack app which just does this. David C. and I put support for the -u/--debugger options for the spec command a few releases back, I don't know if this has any effect on cucumber. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From jeroenvdoorn at gmail.com Thu May 7 13:21:25 2009 From: jeroenvdoorn at gmail.com (jevado) Date: Thu, 7 May 2009 10:21:25 -0700 (PDT) Subject: [rspec-users] rspec_scaffold and mocha Message-ID: <4237663a-0250-496e-830c-c625e641bd26@o30g2000vbc.googlegroups.com> Hi all, Sorry if this get's posted several times but I got a message that my previous post wasn't allowed because I'm not a member. I think I am now though. The problem I have is fairly simple. I have some plugins who use rspec and mocha and I want to make use of the rspec_scaffold generator. Unfortunately this doesn't work, the tests fail as soon as I set mocha as my prefered mocking framework. Is this by design or should it work out of the box. If anybody knows about a generator that does work, please let me know All the best! Jeroen From jarmo.p at gmail.com Thu May 7 14:14:37 2009 From: jarmo.p at gmail.com (juuuser) Date: Thu, 7 May 2009 11:14:37 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use Message-ID: <23432383.post@talk.nabble.com> I just upgraded RSpec and noticed that some of my specs started to fail and it is caused by the 1.1.2 update where implicit receiver for should is introduced. Here is one sample example group, which works with older versions naturally. describe "example group" do it "example" do should be_ok end def ok? true end end And gets NoMethodError of course. I tried different things to set as subject, but was unlucky. For example, subject {self} caused SystemStackError although I hoped that this does the trick, since self has method ok? as expected. I also noticed that there is accessor for subject, so I tried something like this instead of def ok?: def subject.ok? true end Why doesn't it work? It works when doing like this: s = "str" def s.ok?; true; end s.ok? # true I found only one way to fix them like this: class String def ok? true end end Of course I'm not happy with that solution :) What are my options to fix these specs? It seems to me that most logical functionality to this problem would be to make the subject {self} line to work as expected. Jarmo -- View this message in context: http://www.nabble.com/-RSpec--implicit-receiver-for-should-problem-when-helper-predicate-methods-are-in-use-tp23432383p23432383.html Sent from the rspec-users mailing list archive at Nabble.com. From Jarmo.P at gmail.com Thu May 7 14:01:16 2009 From: Jarmo.P at gmail.com (juuser) Date: Thu, 7 May 2009 11:01:16 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use Message-ID: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> I just upgraded RSpec and noticed that some of my specs started to fail and it is caused by the 1.1.2 update where implicit receiver for should is introduced. Here is one sample example group, which works with older versions naturally. describe "example group" do it "example" do should be_ok end def ok? true end end And gets NoMethodError of course. I tried different things to set as subject, but was unlucky. For example, subject {self} caused SystemStackError although I hoped that this does the trick, since self has method ok? as expected. I also noticed that there is accessor for subject, so I tried something like this instead of def ok?: def subject.ok? true end Why doesn't it work? It works when doing like this: s = "str" def s.ok?; true; end s.ok? # true I found only one way to fix them like this: class String def ok? true end end Of course I'm not happy with that solution :) What are my options to fix these specs? It seems to me that most logical functionality to this problem would be to make the subject {self} line to work as expected. Jarmo From scott at railsnewbie.com Thu May 7 13:23:01 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 7 May 2009 13:23:01 -0400 Subject: [rspec-users] Mocha and rspec_scaffold In-Reply-To: <0585371a-6aaa-4aec-b7bf-57a0222003db@o30g2000vbc.googlegroups.com> References: <0585371a-6aaa-4aec-b7bf-57a0222003db@o30g2000vbc.googlegroups.com> Message-ID: On May 7, 2009, at 7:32 AM, jevado wrote: > Hi All, > > I'm busy experimenting with RSpec and encountered a small issue with > the scaffolding. > > As soon as I chooce mocha as my mocking framework in the spec helper > the specs created with rspec_scaffold fail. Is this a bug or do the > rspec_generators only work with the default mocking framework ? > I've tested it on a clean rails app to make sure it wasn't something > else. They only work with rspec's mock framework. Generators are a good way to look at some example code, and not much else. I wouldn't advise using it. Scott > > > Kind regards, > Jeroen > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Thu May 7 16:33:47 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 7 May 2009 21:33:47 +0100 Subject: [rspec-users] [cucumber] Multi-line Step Arguments In-Reply-To: References: Message-ID: <86759D2F-AFEF-44A3-B850-CBEC91DA58A1@mattwynne.net> On 7 May 2009, at 21:28, keith shaw wrote: > Hey All, > > I am trying to set up cucumber to use the multiline step argument. > I have my test posted here : http://gist.github.com/108328. You need to use 'Scenario Outline', not 'Scenario' if you're using an Examples table. I think that's the problem. > I am currently using cucumber version 0.2.3. When I run the test > the browser opens for a split second and I receive the following > error : > > /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/ > parser/treetop_ext.rb:42:in `parse_or_fail': test/podPackage.feature: > 13:3: Parse error, expected one of "\n", "\r", "\"\"\"", "#", > "Given", "When", "Then", "And", "But", "@", "Scenario", "Scenario > Outline". (Cucumber::Parser::SyntaxError) > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/parser/treetop_ext.rb:28:in `parse_file' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/parser/treetop_ext.rb:33:in `open' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/parser/treetop_ext.rb:33:in `parse_file' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/cli/main.rb:55:in `load_plain_text_features' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/cli/main.rb:54:in `each' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/cli/main.rb:54:in `load_plain_text_features' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/cli/main.rb:37:in `execute!' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/ > cucumber/cli/main.rb:20:in `execute' > from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 > from /usr/bin/cucumber:19:in `load' > from /usr/bin/cucumber:19 > > Do I have my test set up correctly? Any help is greatly appreciated. > > Thanks, > > Keith > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From Jarmo.P at gmail.com Thu May 7 16:34:48 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Thu, 7 May 2009 13:34:48 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> Message-ID: <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> Okay, I fiddled around a little and made this solution: module Spec module Example module Subject module ExampleMethods def should(matcher=nil) if matcher self == subject ? Spec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher) : subject.should(matcher) else self == subject ? Spec::Expectations::PositiveExpectationHandler.handle_matcher(self) : subject.should end end def should_not(matcher=nil) if matcher self == subject ? Spec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher) : subject.should_not(matcher) else self == subject ? Spec::Expectations::NegativeExpectationHandler.handle_matcher(self) : subject.should_not end end end end end end In short, if subject is set as self then I'm calling Kernel::should method's body directly. I don't know if there's any side effects that I'm omitting block parameter (although original should and should_not also doesn't send any blocks). Any problems that might arise with this patch? Also, if my original example wasn't real life example enough, then I will give another one: require 'watir' describe "Google" do subject {self} before :all do @b = Watir::Browser.new @b.goto "http://www.google.com" end it "has google written on page" do should have_text("Google") end def has_text? text @b.text.include?(text) end end PS! I changed my poster nick, but I'm still the same "juuser" who made original thread. Regards, Jarmo From dchelimsky at gmail.com Thu May 7 17:02:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 May 2009 14:02:10 -0700 Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <23432383.post@talk.nabble.com> References: <23432383.post@talk.nabble.com> Message-ID: <57c63afe0905071402x5c436e10ycd4d659def9dbb80@mail.gmail.com> On Thu, May 7, 2009 at 11:14 AM, juuuser wrote: > > I just upgraded RSpec and noticed that some of my specs started to fail and > it is caused by the 1.1.2 update where implicit receiver for should is > introduced. > > Here is one sample example group, which works with older versions naturally. > > describe "example group" do > ? ? ? ?it "example" do > ? ? ? ? should be_ok > ? ? ? end > > ? ? ? ?def ok? > ? ? ? ? ?true > ? ? ? ?end > end > > And gets NoMethodError of course. I tried different things to set as > subject, but was unlucky. For example, subject {self} caused > SystemStackError although I hoped that this does the trick, since self has > method ok? as expected. > > I also noticed that there is accessor for subject, so I tried something like > this instead of def ok?: > > def subject.ok? > ? true > end > > Why doesn't it work? It works when doing like this: > s = "str" > def s.ok?; true; end > s.ok? # true > > I found only one way to fix them like this: > class String > ? ?def ok? > ? ? ? ?true > ? ?end > end > > Of course I'm not happy with that solution :) > > What are my options to fix these specs? It seems to me that most logical > functionality to this problem would be to make the subject {self} line to > work as expected. I don't understand why you want these to pass in the first place. Can you give an example of where the receiver should be the example itself? > > Jarmo > -- > View this message in context: http://www.nabble.com/-RSpec--implicit-receiver-for-should-problem-when-helper-predicate-methods-are-in-use-tp23432383p23432383.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 7 17:02:55 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 May 2009 14:02:55 -0700 Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> Message-ID: <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> On Thu, May 7, 2009 at 1:34 PM, Jarmo Pertman wrote: > Okay, I fiddled around a little and made this solution: > module Spec > ?module Example > ? ?module Subject > ? ? ?module ExampleMethods > > ? ? ? ?def should(matcher=nil) > ? ? ? ? ?if matcher > ? ? ? ? ? ?self == subject ? > Spec::Expectations::PositiveExpectationHandler.handle_matcher(self, > matcher) : subject.should(matcher) > ? ? ? ? ?else > ? ? ? ? ? ?self == subject ? > Spec::Expectations::PositiveExpectationHandler.handle_matcher(self) : > subject.should > ? ? ? ? ?end > ? ? ? ?end > > ? ? ? ?def should_not(matcher=nil) > ? ? ? ? ?if matcher > ? ? ? ? ? ?self == subject ? > Spec::Expectations::NegativeExpectationHandler.handle_matcher(self, > matcher) : subject.should_not(matcher) > ? ? ? ? ?else > ? ? ? ? ? ?self == subject ? > Spec::Expectations::NegativeExpectationHandler.handle_matcher(self) : > subject.should_not > ? ? ? ? ?end > ? ? ? ?end > ? ? ?end > ? ?end > ?end > end > > In short, if subject is set as self then I'm calling Kernel::should > method's body directly. I don't know if there's any side effects that > I'm omitting block parameter (although original should and should_not > also doesn't send any blocks). > > Any problems that might arise with this patch? The first problem is the dependency on subject, which is a construct from rspec's example groups. This would make rspec's matchers unusable outside rspec. I'm also not clear on what your goal is, per my earlier response. Please help me understand. > > Also, if my original example wasn't real life example enough, then I > will give another one: > require 'watir' > > describe "Google" do > ? subject {self} > > ? before :all do > ? ? @b = Watir::Browser.new > ? ? @b.goto "http://www.google.com" > ?end > > ?it "has google written on page" do > ? ?should have_text("Google") > ?end > > ?def has_text? text > ? ?@b.text.include?(text) > ?end > > end > > PS! I changed my poster nick, but I'm still the same "juuser" who made > original thread. > > Regards, > Jarmo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mike at mikedoel.com Fri May 8 00:55:26 2009 From: mike at mikedoel.com (Mike Doel) Date: Fri, 8 May 2009 00:55:26 -0400 Subject: [rspec-users] Sharing common Cuke steps Message-ID: Cucumber is awesome and destined to rule the world. As that starts to happen, has there been any thought of a mechanism for the community to build a library of common, generally useful steps that can be used across projects? I've got stuff that I use for myself at: http://github.com/mdoel/cukesteps/tree/master This is stuff that I wish were in the default webrat_steps.rb file that you get at the start. Would it be better to fork Cucumber and add them there and send a pull request to Aslak? It seems to me that there's an opportunity for packaging together and sharing steps, but am curious of folks thoughts on the best way to go about this. Mike From Jarmo.P at gmail.com Fri May 8 02:06:10 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Thu, 7 May 2009 23:06:10 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> Message-ID: <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> I think that I don't understand what you mean by that exactly. I mean, I patched the should and should_not methods in moule Subject::ExampleMethods themselves, which means that this changes only behaviour of subject itself e.g. it is already part of RSpec and don't see how it would break matchers outside of RSpec. Please correct me if i'm wrong. Anyway, wasn't that Watir example good enough? I think that You're right when You think that this thing should not be needed when testing Ruby code with RSpec, but as soon as I start using Watir or some similar tool, then I need to write bunch of helper methods to make my specs less verbose. Let me try to make it more clear. module WatirHelperMethods def has_text? text text.is_a?(Regexp) ? $browser.text =~ text : $browser.text.include?(text) end def login user_id # do something so user would be logged in end def logged_in? user_id # return true if user is logged in end def start_browser_on_url url $browser = Browser.new $browser.goto url end end describe "my test" do include WatirHelperMethods before :all do start_browser_on_url "http://url" end it "should log user into application" do login "testuser" should be_logged_in should have_text("Welcome testuser") end after :all do $browser.close end end Something like this. Do You see where I'm going? Or am I doing something what I ain't suppose to do ever? Should I just make WatirHelperMethods as a class instead of module so it would work like this: helper = HelperClass.new($browser); helper.login "testuser"...? Doesn't remove much of a verboseness also. I have also another question: why the should and should_not methods in Spec::Example::Subject::ExampleMethods have this if statement anyway? I mean, the matcher argument has it's default value as nil and it is also as nil on Kernel#should(_not) method so this if doesn't make sense to me. Can't it just be written as subject.should(matcher)? Or is it just some code block which is written like that because of some 3rd party tools? Jarmo > > The first problem is the dependency on subject, which is a construct > from rspec's example groups. This would make rspec's matchers unusable > outside rspec. > > I'm also not clear on what your goal is, per my earlier response. > Please help me understand. From matt at mattwynne.net Fri May 8 03:05:49 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 8 May 2009 08:05:49 +0100 Subject: [rspec-users] Sharing common Cuke steps In-Reply-To: References: Message-ID: <4E520019-B4D9-4394-9451-96A2DD7D0093@mattwynne.net> On 8 May 2009, at 05:55, Mike Doel wrote: > Cucumber is awesome and destined to rule the world. As that starts > to happen, has there been any thought of a mechanism for the > community to build a library of common, generally useful steps that > can be used across projects? I've got stuff that I use for myself at: > > http://github.com/mdoel/cukesteps/tree/master > > This is stuff that I wish were in the default webrat_steps.rb file > that you get at the start. Would it be better to fork Cucumber and > add them there and send a pull request to Aslak? > > It seems to me that there's an opportunity for packaging together > and sharing steps, but am curious of folks thoughts on the best way > to go about this. > > Mike Great stuff, Mike. I had a similar thought a while back, but it never really took off: http://www.mail-archive.com/rspec-users at rubyforge.org/msg07936.html I feel like this might be better suited to being a separate project, as you'll eventually have steps that are only relevant in certain contexts (we have quite a few that depend on factory_girl, for example), and it's likely to change at a different rate to the core cucumber code. It's almost like you want a kind of plug-in mechanism for sharing re- usable step libraries. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From dchelimsky at gmail.com Fri May 8 03:50:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 8 May 2009 00:50:49 -0700 Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> Message-ID: <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> On Thu, May 7, 2009 at 11:06 PM, Jarmo Pertman wrote: > I think that I don't understand what you mean by that exactly. I mean, > I patched the should and should_not methods in moule > Subject::ExampleMethods themselves, which means that this changes only > behaviour of subject itself e.g. it is already part of RSpec and don't > see how it would break matchers outside of RSpec. Please correct me if > i'm wrong. You're correct. I misunderstood. > Anyway, wasn't that Watir example good enough? I think that You're > right when You think that this thing should not be needed when testing > Ruby code with RSpec, but as soon as I start using Watir or some > similar tool, then I need to write bunch of helper methods to make my > specs less verbose. Let me try to make it more clear. > > module WatirHelperMethods > ? ?def has_text? text > ? ? ?text.is_a?(Regexp) ? $browser.text =~ text : > $browser.text.include?(text) > ? ?end > > ? ?def login user_id > ? ? ?# do something so user would be logged in > ? ?end > > ? ?def logged_in? user_id > ? ? ?# return true if user is logged in > ? ?end > > ? ?def start_browser_on_url url > ? ? ?$browser = Browser.new > ? ? ?$browser.goto url > ? ?end > end > > describe "my test" do > ? ?include WatirHelperMethods > > ? ?before :all do > ? ? ?start_browser_on_url "http://url" > ? ?end > > ? ?it "should log user into application" do > ? ? ?login "testuser" > ? ? ?should be_logged_in > ? ? ?should have_text("Welcome testuser") > ? end > > ? after :all do > ? ? $browser.close > ? end > end > > Something like this. Do You see where I'm going? Or am I doing > something what I ain't suppose to do ever? Should I just make > WatirHelperMethods as a class instead of module so it would work like > this: helper = HelperClass.new($browser); helper.login "testuser"...? > Doesn't remove much of a verboseness also. This is pretty helpful, thanks for a more thorough explanation. I did add your patch locally, however, and it doesn't seem to solve the problem (I still get undefined method `ok?' when I run the example in your 2nd post). I need to think about this some more before I agree to go in this direction, as I want to make sure there are no negative impacts that I'm not thinking of right now. That said, I'd need a patch w/ specs that fail without this change and pass with this change. Please file a ticket at http://rspec.lighthouseapp.com w/ a patch. Cheers, David > I have also another question: why the should and should_not methods in > Spec::Example::Subject::ExampleMethods have this if statement anyway? > I mean, the matcher argument has it's default value as nil and it is > also as nil on Kernel#should(_not) method so this if doesn't make > sense to me. Can't it just be written as subject.should(matcher)? Or > is it just some code block which is written like that because of some > 3rd party tools? Good point - thanks! : http://github.com/dchelimsky/rspec/commit/b061f9f40dc8a29d34ddb3e74427b244bbcf0aa8 > > Jarmo > >> >> The first problem is the dependency on subject, which is a construct >> from rspec's example groups. This would make rspec's matchers unusable >> outside rspec. >> >> I'm also not clear on what your goal is, per my earlier response. >> Please help me understand. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From Jarmo.P at gmail.com Fri May 8 05:21:36 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Fri, 8 May 2009 02:21:36 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> Message-ID: <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> On May 8, 10:50?am, David Chelimsky wrote: > This is pretty helpful, thanks for a more thorough explanation. I did > add your patch locally, however, and it doesn't seem to solve the > problem (I still get undefined method `ok?' when I run the example in > your 2nd post). Sorry. It didn't work because I didn't have subject {self} there. > > I need to think about this some more before I agree to go in this > direction, as I want to make sure there are no negative impacts that > I'm not thinking of right now. That said, I'd need a patch w/ specs > that fail without this change and pass with this change. Please file a > ticket athttp://rspec.lighthouseapp.comw/ a patch. Ok, will do that later. > > Cheers, > David > > > I have also another question: why the should and should_not methods in > > Spec::Example::Subject::ExampleMethods have this if statement anyway? > > I mean, the matcher argument has it's default value as nil and it is > > also as nil on Kernel#should(_not) method so this if doesn't make > > sense to me. Can't it just be written as subject.should(matcher)? Or > > is it just some code block which is written like that because of some > > 3rd party tools? > > Good point - thanks! :http://github.com/dchelimsky/rspec/commit/b061f9f40dc8a29d34ddb3e7442... :) Cheers, Jarmo From lists at ruby-forum.com Fri May 8 07:03:46 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 8 May 2009 13:03:46 +0200 Subject: [rspec-users] Error in executing controller spec Message-ID: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> Hello, I am trying to execute controller spec but it gives me error which says @controller is nil: make sure you set it in your test's setup method. I tried to search for the solution but till now no success :( Following is the description of the controller spec. describe ChannelCategoriesController do context "Admin" do before(:each) do @cha_category = ChannelCategory.new end it "should delete categories" do delete :destroy, :id => 1 end end end Please advice :-) -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 8 08:01:49 2009 From: lists at ruby-forum.com (Rainer Kuhn) Date: Fri, 8 May 2009 14:01:49 +0200 Subject: [rspec-users] RCov and Ruby 1.9.1 Message-ID: <81ce5c2ca54b1989986e7754844b45a2@ruby-forum.com> Has anyone got RCov working with Ruby 1.9.1? The rcov gem won't even install, and the spicycode-rcov gem crashes. It would be nice to still benefit from rcovs features. Tick -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Fri May 8 08:55:32 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 8 May 2009 13:55:32 +0100 Subject: [rspec-users] Sharing common Cuke steps In-Reply-To: <8d961d900905080112k6e65568bgc2b86f3aa724547@mail.gmail.com> References: <4E520019-B4D9-4394-9451-96A2DD7D0093@mattwynne.net> <8d961d900905080112k6e65568bgc2b86f3aa724547@mail.gmail.com> Message-ID: On 8 May 2009, at 09:12, aslak hellesoy wrote: > > > On 8 May 2009, at 05:55, Mike Doel wrote: > > Cucumber is awesome and destined to rule the world. As that starts > to happen, has there been any thought of a mechanism for the > community to build a library of common, generally useful steps that > can be used across projects? I've got stuff that I use for myself at: > > http://github.com/mdoel/cukesteps/tree/master > > This is stuff that I wish were in the default webrat_steps.rb file > that you get at the start. Would it be better to fork Cucumber and > add them there and send a pull request to Aslak? > > It seems to me that there's an opportunity for packaging together > and sharing steps, but am curious of folks thoughts on the best way > to go about this. > > Mike > > Great stuff, Mike. > > I had a similar thought a while back, but it never really took off: > http://www.mail-archive.com/rspec-users at rubyforge.org/msg07936.html > > I feel like this might be better suited to being a separate project, > as you'll eventually have steps that are only relevant in certain > contexts (we have quite a few that depend on factory_girl, for > example), and it's likely to change at a different rate to the core > cucumber code. > > It's almost like you want a kind of plug-in mechanism for sharing re- > usable step libraries. > > I agree with Matt - this sounds great. Could you add a link to the > related tools page in the wiki? > > I think we already have a plugin mechanism for this. It's called > RubyGems ;-) > > Aslak So are you saying we'd put the steps in a gem, then include them using require? So I can do this in my env file: gem 'cucumber-steps' require 'cucumber/steps/webrat' require 'cucumber/steps/factory_girl' or in another project that uses the command line: gem 'cucumber-steps' require 'cucumber/steps/console' Is that the kind of thing you mean? I think it would be good to allow for steps that cater to different use cases to all be in the same library but allow you to pick and chose the ones that are relevant to your project. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Fri May 8 08:57:22 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 8 May 2009 13:57:22 +0100 Subject: [rspec-users] Where to spec authentication and roles-based permissions? In-Reply-To: <50873a360905080233q6b6d1c60x1ffe73887984097a@mail.gmail.com> References: <50873a360905080233q6b6d1c60x1ffe73887984097a@mail.gmail.com> Message-ID: <91E9C491-4C26-49E6-8F1C-E50840210AF1@mattwynne.net> On 8 May 2009, at 10:33, doug livesey wrote: > Hi -- I'm writing an app that both requires authentication via a > logon, and also has roles-based permissions (using acl_system2), and > was wondering where to verify that both are happening. > I've started out putting them in a special cucumber feature for > authentication & permissions, but this is becoming a real drag, as > I'm writing a scenario for each case (anonymous, lacking > permissions, permitted) by each controller action. > Can anyone advise me on a better way to organise this? Have you seen Scenario Outlines? I think this is exactly kind of stuff that should be surfaced in a Cucumber test, but you need to organise your steps to facilitate that. Tools like Scenario Outline really help. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From zach.dennis at gmail.com Fri May 8 09:37:50 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 8 May 2009 09:37:50 -0400 Subject: [rspec-users] Where to spec authentication and roles-based permissions? In-Reply-To: <50873a360905080233q6b6d1c60x1ffe73887984097a@mail.gmail.com> References: <50873a360905080233q6b6d1c60x1ffe73887984097a@mail.gmail.com> Message-ID: <85d99afe0905080637w7961ca7cr13be603de16b4675@mail.gmail.com> On Fri, May 8, 2009 at 5:33 AM, doug livesey wrote: > Hi -- I'm writing an app that both requires authentication via a logon, and > also has roles-based permissions (using acl_system2), and was wondering > where to verify that both are happening. > I've started out putting them in a special cucumber feature for > authentication & permissions, but this is becoming a real drag, as I'm > writing a scenario for each case (anonymous, lacking permissions, permitted) > by each controller action. > Can anyone advise me on a better way to organise this? > > Would it be possible to write a security feature for each controller, with > scenarios for each action? Maybe like this: > ? Scenario: Different users trying the index > ? ? Given user is not logged in > ? ? When I go to the controller-a index > ? ? Then I should see "Access Denied" > ? ? Given basic user is logged in > ??? When I go to the controller-a index > ? ? Then I should see "Insufficient Permissions" > ??? Given super user is logged in > ? ? When I go to the controller-a index > ??? Then I should see "Welcome, my lord" > > Any advice is very appreciated -- as you can probably tell, this is getting > messy! I went down the route of using Scenario Outlines for this, and it still became messy. There are simply too many cases to cover and the tables you build up become long and redundant. After a while they all look start to blur together and look alike. I think these kind of things belong in controller specs where you can be confident resources are being protected, but you can also extract out nice little macros. For example, you might end up with: desribe PeopleController, "GET index" do should_allow_logged_in_access_to :superuser end You could use a convention of the controller description to determine the method and the action to hit, or you could parametrize your macro: should_allow_logged_in_access_to :get, :index, :roles => [:superuser] I'd recommend not specifying the roles that are denied since if you had one you'd have to do potentially change every controller spec in your app. Rather I'd have the macro try a non-allowed role to ensure it didn't work for other roles. In the Rails Controllers chapter in The RSpec Book there is a section on extracting out a should_require_login macro which walks through step by step the same technique I'd use for writing the macro you want. > Cheers, > ?? Doug. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From jean-michel at 21croissants.com Fri May 8 09:48:20 2009 From: jean-michel at 21croissants.com (Jean-Michel Garnier) Date: Fri, 8 May 2009 06:48:20 -0700 (PDT) Subject: [rspec-users] [cucumber] how to debug cucumber with netbeans? Message-ID: <23446299.post@talk.nabble.com> 3 months ago, I submitted a patch to cucumber so I could run cucumber from a ruby script and use the debugger in netbeans (https://rspec.lighthouseapp.com/projects/16211/tickets/128-running-feature-from-ruby-script) It worked well at the time but I can't make it work with cucumber 0.3.2. Here is the stacktrace: ruby script/cucumber_netbeans_runner.rb cucumber features/_admin/projects.feature --profile default /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- lib/active_merchant (MissingSourceFile) Failed to load ./vendor/plugins/active_merchant/lib/support/gateway_support.rb from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in `require' from /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' from /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' from /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' from ./vendor/plugins/active_merchant/lib/support/gateway_support.rb:3 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' ... 8 levels... from /Library/Ruby/Gems/1.8/gems/cucumber-0.3.2/lib/cucumber/cli/main.rb:20:in `execute' from script/cucumber_netbeans_runner.rb:29:in `run' from script/cucumber_netbeans_runner.rb:21:in `run_feature' from script/cucumber_netbeans_runner.rb:37 And the script: require 'rubygems' require 'cucumber/cli/main' module Cucumber module Netbeans class Runner def initialize(cucumber_opts=nil) @argv = [] @cucumber_opts = cucumber_opts || " --profile default" end def run_scenario(line_number) @cucumber_opts << " --line #{line_number}" run end def run_feature(feature) @argv << "#{feature}" run end protected def run @argv << @cucumber_opts puts %Q{cucumber #{@argv.join(' ')} \n} Cucumber::Cli::Main.execute(@argv) end end end end Cucumber::Netbeans::Runner.new().run_feature "features/_admin/projects.feature" I wonder if fellow netbeans on cucumber users will have an idea ... Ironically, debugging that script with netbeans crashes the debugger at Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54 For the time being, I am using the "old school" ruby-debug which works pretty well ... JM -- View this message in context: http://www.nabble.com/-cucumber--how-to-debug-cucumber-with-netbeans--tp23446299p23446299.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Fri May 8 12:22:52 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 8 May 2009 09:22:52 -0700 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> Message-ID: <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> On Fri, May 8, 2009 at 4:03 AM, Amit Kulkarni wrote: > Hello, > > ? ? I am trying to execute controller spec but it gives me error which > says > > ? ? @controller is nil: make sure you set it in your test's setup > method. > > I tried to search for the solution but till now no success :( > > Following is the description of the controller spec. > > describe ChannelCategoriesController do > > ?context "Admin" do > > ? ?before(:each) do > ? ? ?@cha_category = ChannelCategory.new > ? ?end > > ? ? ?it "should delete categories" do > ? ? ? ?delete :destroy, :id => 1 > ? ? ?end > ?end > end > > Please advice :-) Questions: * ruby version * rspec version * rails version * OS * what's the path to the file * how are you running the spec (rake, spec command, etc) * pls provide a full backtrace * best in a gist or pastie * script/spec path/to/file --backtrace Cheers, David From ben at benmabey.com Fri May 8 13:25:03 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 08 May 2009 11:25:03 -0600 Subject: [rspec-users] Problem verifying routing error In-Reply-To: <49FCAAA6.6040600@yahoo.com> References: <49FCAAA6.6040600@yahoo.com> Message-ID: <4A046AEF.1090307@benmabey.com> Randy Harmon wrote: > Hi, > > When upgrading to rspec/rspec-rails 1.2.6 gem (from 1.1.12), I'm having > a new problem verifying routes that should not exist. > > This is to support something like this in routes.rb: > > map.resources :orders do |orders| > orders.resources :items, :except => [:index,:show] > end > > I used to use lambda {}.should_raise( routing error ), but it stopped > detecting any raised error. Requesting it through the browser produces > ActionController::MethodNotAllowed (Only post requests are allowed). But > that error wasn't detected. > > When I skip the lambda, and just ask it to verify that the route does > exist (which *should* fail), I get the same result for those :except > actions as for a made-up action name. Seems this must have something to > do with the change in how route_for delegates back to ActionController's > routing assertion (sez the backtrace :). > > > NoMethodError in 'ItemsController route generation should NOT map > #indewfefwex' > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.first > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:134:in > `recognized_request_for' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:49:in > `assert_recognizes' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions.rb:54:in > `clean_backtrace' > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:47:in > `assert_recognizes' > ./spec/controllers/thoughts_routing_spec.rb:9: > > > I tried using bypass_rescue in my routing/items_routing_spec.rb file as > mentioned by the upgrade doc, but it wasn't valid in the "routing" spec > - worked fine when I moved the file back to spec/controllers/, though. > Seems like that's not the issue, but I'm mentioning for more completeness. > > Any ideas what I should be doing instead, or how I can troubleshoot further? > Hmm.. yeah, it seems like it might have to do with how the exceptions are being handled in the newer version of rspec-rials (see https://rspec.lighthouseapp.com/projects/5645/tickets/85-11818-have-mode-for-rails-error-handling). I don't use RSpec to verify my routes very often and have never used it to verify the non-existence of a route so I'm afraid I don't really have any ideas... Does anyone else have an idea to do this? -Ben From denis at haskinferguson.net Fri May 8 16:51:06 2009 From: denis at haskinferguson.net (Denis Haskin) Date: Fri, 08 May 2009 16:51:06 -0400 Subject: [rspec-users] Help with global before behavior... In-Reply-To: <4A0496F2.4050706@haskinferguson.net> References: <4A0496F2.4050706@haskinferguson.net> Message-ID: <4A049B3A.1000103@haskinferguson.net> Okay, I guess I can do this with shared examples. I added to my spec_helper.rb: describe "an admin user is signed in", :shared => true do before( :each ) do @admin_user = Factory(:admin_user) login_as @admin_user end end and then in each controller that needs that behavior: it_should_behave_like "an admin user is signed in" Good enough. I had myself going in circles because I was trying to use a :type and global before behavior, and I think that doesn't work at all how I was expecting it to. Can :type be anything? Or is it limited to some set of values (e.g. :controller, etc)? Thanks, dwh Denis Haskin wrote: > I'm having a devil of a time getting some global before behavior to > work the way I think it should. > > I have a set of controllers that are used only by administrative > users, so login is required. To run examples just against the > functionality, ideally I'd like to be able to set up a before() that > would log an admin user in before each example. > > I tried putting it in as a global in spec_helper.rb: > > Spec::Runner.configure do |config| > ...etc... > config.before(:each) do > @admin_user = Factory(:admin_user) > login_as @admin_user > end > ...etc... > > but it really seems like it's being executed in the configure context, > not the controller context (for example, session[] isn't defined yet, > etc). > > Any recommendations? > > Thanks, > > dwh > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From Jarmo.P at gmail.com Fri May 8 17:29:00 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Fri, 8 May 2009 14:29:00 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> Message-ID: Added patch and specs to https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/816-possibility-to-use-self-as-a-subject-for-explicit-receiver Jarmo From dchelimsky at gmail.com Fri May 8 17:57:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 8 May 2009 14:57:07 -0700 Subject: [rspec-users] Help with global before behavior... In-Reply-To: <4A049B3A.1000103@haskinferguson.net> References: <4A0496F2.4050706@haskinferguson.net> <4A049B3A.1000103@haskinferguson.net> Message-ID: <57c63afe0905081457q28689985y8786c4006413b92c@mail.gmail.com> On Fri, May 8, 2009 at 1:51 PM, Denis Haskin wrote: > Okay, I guess I can do this with shared examples. ?I added to my > spec_helper.rb: > > describe "an admin user is signed in", :shared => true do > ?before( :each ) do > ? @admin_user = Factory(:admin_user) > ? login_as @admin_user > ?end > end > > and then in each controller that needs that behavior: > > ?it_should_behave_like "an admin user is signed in" > > Good enough. ?I had myself going in circles because I was trying to use a > :type and global before behavior, and I think that doesn't work at all how I > was expecting it to. > > Can :type be anything? ?Or is it limited to some set of values (e.g. > :controller, etc)? :type is the type of group (model, view, controller, etc). We're going to be adding some sort of tagging thing eventually where you'd be able to set something up in config that you could later hook w/ a hash passed to describe or it, but that won't be for a bit. Your solution seems like a fine option, given the current constraints. Another thing you could do is make it a macro, so you could say: describe "something" do logged_in_as :admin do it "should behave this way" do ... end end logged_in_as :anonymous do it "should behave differently" do .. end end end Depends on what you find more expressive. Cheers, David > > Thanks, > > dwh > > > Denis Haskin wrote: >> >> I'm having a devil of a time getting some global before behavior to work >> the way I think it should. >> >> I have a set of controllers that are used only by administrative users, so >> login is required. ?To run examples just against the functionality, ideally >> I'd like to be able to set up a before() that would log an admin user in >> before each example. >> >> I tried putting it in as a global in spec_helper.rb: >> >> Spec::Runner.configure do |config| >> ...etc... >> ?config.before(:each) do >> ? ?@admin_user = Factory(:admin_user) >> ? login_as @admin_user >> ?end >> ...etc... >> >> but it really seems like it's being executed in the configure context, not >> the controller context (for example, session[] isn't defined yet, etc). >> >> Any recommendations? >> >> Thanks, >> >> dwh >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 zuperinfinite at gmail.com Fri May 8 18:31:05 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Sat, 9 May 2009 00:31:05 +0200 Subject: [rspec-users] top posting and plain text In-Reply-To: <20090507171247.GJ980@bumblebee.m38c.nl> References: <8d961d900905061154p55fb3a19ic8e4cbe4112b2d66@mail.gmail.com> <4A021E5D.3030309@benmabey.com> <4A022F6F.9030105@benmabey.com> <20090507171247.GJ980@bumblebee.m38c.nl> Message-ID: <2B897B31-D141-4ACB-96E7-545D64C0717D@gmail.com> On 7 mei 2009, at 19:12, Kero van Gelder wrote: >>> So let me get this right, >>> >>> you agreed with Aslak that you shouldn't top post. >>> >>> by top posting???? >>> >> lol.. Yes. :) Sarcasm somethings doesn't come across well over >> email >> I suppose. > > Not only that, he did it in so it was impossible for > me to see whether it was top or bottom. The sarcasm was clear > enough, tho ;) > > +1 from me, too. > > I'm adding a request: cut out the paragraphs of the email > that you are not responding to. Same goes for signatures, if you'd ask me. gr, bartz From scott at railsnewbie.com Fri May 8 21:21:32 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Fri, 08 May 2009 21:21:32 -0400 Subject: [rspec-users] Help with global before behavior... In-Reply-To: <4A0496F2.4050706@haskinferguson.net> References: <4A0496F2.4050706@haskinferguson.net> Message-ID: <4A04DA9C.7020008@railsnewbie.com> Denis Haskin wrote: > I'm having a devil of a time getting some global before behavior to > work the way I think it should. > > I have a set of controllers that are used only by administrative > users, so login is required. To run examples just against the > functionality, ideally I'd like to be able to set up a before() that > would log an admin user in before each example. > > I tried putting it in as a global in spec_helper.rb: > > Spec::Runner.configure do |config| > ...etc... > config.before(:each) do > @admin_user = Factory(:admin_user) > login_as @admin_user > end > ...etc... > > but it really seems like it's being executed in the configure context, > not the controller context (for example, session[] isn't defined yet, > etc). Here's how I do it w/ Flavorpill: Spec::Runner.configure do |config| Spec::Rails::Example::ControllerExampleGroup.class_eval do include SpecHelpers::AdminLoginHelper before(:each) do setup_action end end end Scott > > Any recommendations? > > Thanks, > > dwh > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Fri May 8 22:06:32 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 08 May 2009 20:06:32 -0600 Subject: [rspec-users] [cucumber] -n command line option looks in every feature file In-Reply-To: <3c30da400905081411r48405988j14cc4d6d81ad7b23@mail.gmail.com> References: <3c30da400905081411r48405988j14cc4d6d81ad7b23@mail.gmail.com> Message-ID: <4A04E528.7000506@benmabey.com> Mark Wilden wrote: > Running 'cucumber -n "asdf" features/challenge.feature' seems to load > every feature file from the Rails root on down. In particular, it > loads example features in vendor/gems like Ben's email_spec which > requires Rails 2.2.2. This makes the command fail for us, since we've > frozen 2.3.2. I would imagine it's also loading RSpec's own features, > since that gem is also frozen in our app. > > I don't know if this is defined behavior or not, but it was > surprising. It makes the -n option less useful, IMO. What does the > filespec do in this case? > > ///ark What do you mean by "filespec"? Regardless, I agree with you that this doesn't seem normal at all. Care to add a ticket for it? Thanks, Ben From ben at benmabey.com Fri May 8 22:10:08 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 08 May 2009 20:10:08 -0600 Subject: [rspec-users] [cucumber] how to debug cucumber with netbeans? In-Reply-To: <23446299.post@talk.nabble.com> References: <23446299.post@talk.nabble.com> Message-ID: <4A04E600.4060808@benmabey.com> Jean-Michel Garnier wrote: > 3 months ago, I submitted a patch to cucumber so I could run cucumber from a > ruby script and use the debugger in netbeans > (https://rspec.lighthouseapp.com/projects/16211/tickets/128-running-feature-from-ruby-script) > > It worked well at the time but I can't make it work with cucumber 0.3.2. > Here is the stacktrace: > ruby script/cucumber_netbeans_runner.rb > cucumber features/_admin/projects.feature --profile default > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require': no such file to load -- lib/active_merchant > (MissingSourceFile) > Failed to load > ./vendor/plugins/active_merchant/lib/support/gateway_support.rb from > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `polyglot_original_require' > from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in > `require' > from > /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in > `require' > from > /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in > `new_constants_in' > from > /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in > `require' > from ./vendor/plugins/active_merchant/lib/support/gateway_support.rb:3 > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `polyglot_original_require' > ... 8 levels... > from > /Library/Ruby/Gems/1.8/gems/cucumber-0.3.2/lib/cucumber/cli/main.rb:20:in > `execute' > from script/cucumber_netbeans_runner.rb:29:in `run' > from script/cucumber_netbeans_runner.rb:21:in `run_feature' > from script/cucumber_netbeans_runner.rb:37 > > And the script: > > require 'rubygems' > require 'cucumber/cli/main' > > module Cucumber > module Netbeans > class Runner > def initialize(cucumber_opts=nil) > @argv = [] > @cucumber_opts = cucumber_opts || " --profile default" > end > > def run_scenario(line_number) > @cucumber_opts << " --line #{line_number}" > run > end > > def run_feature(feature) > @argv << "#{feature}" > run > end > > protected > > def run > @argv << @cucumber_opts > puts %Q{cucumber #{@argv.join(' ')} \n} > Cucumber::Cli::Main.execute(@argv) > end > end > end > end > > Cucumber::Netbeans::Runner.new().run_feature > "features/_admin/projects.feature" > > I wonder if fellow netbeans on cucumber users will have an idea ... > Ironically, debugging that script with netbeans crashes the debugger at > Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54 > > For the time being, I am using the "old school" ruby-debug which works > pretty well ... > > JM > So, you can run the feature fine without the debugger? What is confusing is that "lib/active_merchant" is showing up in the backtrace saying it can't be found... What if you try to run the feature with the debugger from outside of Netbeans? Just trying to get an idea of who the culprit really is here. -Ben From zach.dennis at gmail.com Sat May 9 00:11:56 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 9 May 2009 00:11:56 -0400 Subject: [rspec-users] rspec_scaffold and mocha In-Reply-To: <22765d31-f530-4cd4-af9d-02db2cb936f2@z7g2000vbh.googlegroups.com> References: <22765d31-f530-4cd4-af9d-02db2cb936f2@z7g2000vbh.googlegroups.com> Message-ID: <85d99afe0905082111k22ad0b95y6ed36cd47806dd2a@mail.gmail.com> On Thu, May 7, 2009 at 7:40 AM, jevado wrote: > Hi All, > > I have a question about the rspec_scaffold and if it's compatible with > other mocking frameworks. > I just created a blank application and a scaffold of a very basic > model. The specs run fine untill I choose to use mocha in the > spec_helper. > > Can somebody please tell me if this is ment to be and if so if there's > an easy way to make the scaffold work with mocha ? RSpec scaffold is not set up produce scaffold for all of the various mocking libraries. It does so just for what comes with RSpec. I do not know of a way to simply replace scaffolding w/o providing more scaffolding (ones for each mocking library) and then adding a flag to the "script/generate" command to produce scaffolding for rspec+default, rspec+mocha, rspec+rr, etc. Also, in addition to this the normal "script/generate rspec" command could be used to take the same options so it would configure your spec_helper to run with the appropriate libraries. I think your idea for scaffolding with different mocking libraries is a good one. Please open a ticket on lighthouse and let's see if we can get some more input from others in the community as well as the core team. http://rspec.lighthouseapp.com/ > > Thanks in advance! > Jeroen > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From jean-michel at 21croissants.com Sat May 9 04:40:44 2009 From: jean-michel at 21croissants.com (Jean-Michel Garnier) Date: Sat, 9 May 2009 01:40:44 -0700 (PDT) Subject: [rspec-users] [cucumber] how to debug cucumber with netbeans? In-Reply-To: <4A04E600.4060808@benmabey.com> References: <23446299.post@talk.nabble.com> <4A04E600.4060808@benmabey.com> Message-ID: <23458483.post@talk.nabble.com> Jean-Michel Garnier wrote: > 3 months ago, I submitted a patch to cucumber so I could run cucumber from > a > ruby script and use the debugger in netbeans > (https://rspec.lighthouseapp.com/projects/16211/tickets/128-running-feature-from-ruby-script) > > It worked well at the time but I can't make it work with cucumber 0.3.2. > Here is the stacktrace: > Cucumber::Netbeans::Runner.new().run_feature > "features/_admin/projects.feature" > > I wonder if fellow netbeans on cucumber users will have an idea ... > Ironically, debugging that script with netbeans crashes the debugger at > Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54 > > For the time being, I am using the "old school" ruby-debug which works > pretty well ... > > JM > Thanks for your answer, Ben > So, you can run the feature fine without the debugger? * yes, it run fine indeed, I mean it loads everything all right and then crash in a cucumber step with "segmentation fault" >What is > confusing is that "lib/active_merchant" is showing up in the backtrace > saying it can't be found... * I don' understand it either and I suspect it's a Rails / cucumber / polyglot rubygems issue as I have found a few messages describing problems with cucumber and "polyglot_original_require' from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54" * For the time being, I just give up debugging cucumber with netbeans ... > What if you try to run the feature with the > debugger from outside of Netbeans? * You mean with classic ruby-debug? I had never used it before as I come from a java + Eclispe background and always used an IDE to debug. I must admit that ruby-debug is very easy to use and it did well to find the cause of my problem: cucumber calling webrat visit with "eval". There was a bug in a before_filter of a controller which was doing an infinite loop. Apparently, the mac ruby interpreter did not like it and crashed with "segmentation fault". Running Rails in "development" mode was working fine and showing an exception stacktrace... This is the kind of situtation where TDD is actually slower than "prehistoric development with no tests". I spent 3 hours looking for the source of the problems and it took me 15 minutes running Rails in developement mode. In order to improve webrat, I'll spend 1 hour this morning o try to write a spec to reproduce the bug. -- View this message in context: http://www.nabble.com/-cucumber--how-to-debug-cucumber-with-netbeans--tp23446299p23458483.html Sent from the rspec-users mailing list archive at Nabble.com. From court3nay at gmail.com Sat May 9 05:01:07 2009 From: court3nay at gmail.com (court3nay) Date: Sat, 9 May 2009 02:01:07 -0700 (PDT) Subject: [rspec-users] Weird bug in association extensions Message-ID: Hey all, just upgraded an older app to latest rspec and rails. This code runs fine in console but fails under rspec. class User has_many :statuses, :extend => Status:::AssociationExtension end module Status::AssociationExtensions def after(status) find(:first, :conditions => ['statuses.created_at > ?', status.created_at], :order => 'statuses.created_at') end end This code works in the app and from console recent = @user.statuses.first status = @user.statuses.after(recent) But in the spec, I get this: Weird, eh? It thinks that "self.class" == Array and can't find the "find" method on the array instance. Is this something in my code somewhere, or did something change with association collections? 6) NoMethodError in 'StatusesController PUT #update StatusesController (unsuccessful save) assigns @status' undefined method `find' for # /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ active_record/base.rb:1964:in `method_missing_without_paginate' /Users/courtenay/dev/entp/tt/vendor/plugins/will_paginate/lib/ will_paginate/finder.rb:164:in `method_missing' /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ active_record/associations/association_collection.rb:60:in `find' /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ active_record/associations/association_collection.rb:395:in `find_target' /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ active_record/associations/association_collection.rb:349:in `load_target' /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ active_record/associations/association_proxy.rb:139:in `inspect' spec/controllers/statuses_controller_spec.rb:249: spec/controllers/statuses_controller_spec.rb:282: From matt at mattwynne.net Sat May 9 06:38:33 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 9 May 2009 11:38:33 +0100 Subject: [rspec-users] Sharing common Cuke steps In-Reply-To: <8d961d900905080724p12adf0cbt59342d57f093cf75@mail.gmail.com> References: <4E520019-B4D9-4394-9451-96A2DD7D0093@mattwynne.net> <8d961d900905080112k6e65568bgc2b86f3aa724547@mail.gmail.com> <8d961d900905080724p12adf0cbt59342d57f093cf75@mail.gmail.com> Message-ID: <979746AD-6C11-44A9-A160-A9D29E73B1A6@mattwynne.net> On 8 May 2009, at 15:24, aslak hellesoy wrote: >>> So are you saying we'd put the steps in a gem, then include them >>> using require? >>> >>> So I can do this in my env file: >>> >>> gem 'cucumber-steps' >>> >>> require 'cucumber/steps/webrat' >>> require 'cucumber/steps/factory_girl' >>> >>> or in another project that uses the command line: >>> >>> gem 'cucumber-steps' >>> >>> require 'cucumber/steps/console' >>> >>> Is that the kind of thing you mean? >>> > Yes. > >>> I think it would be good to allow for steps that cater to >>> different use cases to all be in the same library but allow you to >>> pick and chose the ones that are relevant to your project. >>> > So several files in the same gem? Different requires? Yes, exactly. WDYT? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From sfeley at gmail.com Sat May 9 10:05:24 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sat, 9 May 2009 10:05:24 -0400 Subject: [rspec-users] Sharing common Cuke steps In-Reply-To: <8d961d900905080724p12adf0cbt59342d57f093cf75@mail.gmail.com> References: <4E520019-B4D9-4394-9451-96A2DD7D0093@mattwynne.net> <8d961d900905080112k6e65568bgc2b86f3aa724547@mail.gmail.com> <8d961d900905080724p12adf0cbt59342d57f093cf75@mail.gmail.com> Message-ID: <1fb4df0905090705w2f5f41f3g3231736bad4ab35d@mail.gmail.com> On Fri, May 8, 2009 at 10:24 AM, aslak hellesoy wrote: >> [ Matt Wynne: ] >> So are you saying we'd put the steps in a gem, then include them using require? > > Yes. Is there any reason not to accept them for inclusion in the Cucumber gem? You already have precedent with the Webrat steps. Obviously you'd need some set of standards of generality and quality, but you could delegate someone else to handle the submissions process. Candidates could be put up on a page in the Wiki, discussed, and then taken off again when they're rolled into a production release or rejected. I love the idea of a repository, but I don't like the idea of having still more highly coupled gems to manage. And I don't think this warrants it. I'd rather either see them _in_ Cucumber, or a pure Web resource where I can do my own copying-and-pasting. -- Have Fun, ? Steve Eley (sfeley at gmail.com) ? ESCAPE POD - The Science Fiction Podcast Magazine ? http://www.escapepod.org From dchelimsky at gmail.com Sat May 9 12:17:34 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 9 May 2009 09:17:34 -0700 Subject: [rspec-users] Weird bug in association extensions In-Reply-To: References: Message-ID: <57c63afe0905090917h6bb2fadaw6c29c7dcc32221c@mail.gmail.com> On Sat, May 9, 2009 at 2:01 AM, court3nay wrote: > Hey all, just upgraded an older app to latest rspec and rails. This > code runs fine in console but fails under rspec. > > ? ?class User > ? ? ?has_many :statuses, :extend => Status:::AssociationExtension > ? ?end > > ? ?module Status::AssociationExtensions > ? ? ?def after(status) > ? ? ? ?find(:first, :conditions => ['statuses.created_at > ?', > status.created_at], :order => 'statuses.created_at') > ? ? ?end > ? ?end > > This code works in the app and from console > > ? ?recent = @user.statuses.first > ? ?status = @user.statuses.after(recent) > > But in the spec, I get this: Weird, eh? It thinks that "self.class" == > Array and can't find the "find" method on the array instance. ?Is this > something in my code somewhere, or did something change with > association collections? The only direct handling of AssociationProxy in rspec-rails is if you're using the change matcher. Does the failing example have 'should change' in it? Could be an rspec bug in that case. If not, I'm not sure what else it could be. Can you try converting it to a test/unit test_case and see if you get the same result? > > 6) > NoMethodError in 'StatusesController PUT #update StatusesController > (unsuccessful save) assigns @status' > undefined method `find' for # > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/base.rb:1964:in `method_missing_without_paginate' > /Users/courtenay/dev/entp/tt/vendor/plugins/will_paginate/lib/ > will_paginate/finder.rb:164:in `method_missing' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_collection.rb:60:in `find' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_collection.rb:395:in > `find_target' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_collection.rb:349:in > `load_target' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_proxy.rb:139:in `inspect' > spec/controllers/statuses_controller_spec.rb:249: > spec/controllers/statuses_controller_spec.rb:282: From scott at railsnewbie.com Sat May 9 12:56:57 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Sat, 09 May 2009 12:56:57 -0400 Subject: [rspec-users] Weird bug in association extensions In-Reply-To: References: Message-ID: <4A05B5D9.7030407@railsnewbie.com> court3nay wrote: > Hey all, just upgraded an older app to latest rspec and rails. This > code runs fine in console but fails under rspec. > > class User > has_many :statuses, :extend => Status:::AssociationExtension > end > > module Status::AssociationExtensions > def after(status) > find(:first, :conditions => ['statuses.created_at > ?', > status.created_at], :order => 'statuses.created_at') > end > end > > This code works in the app and from console > > recent = @user.statuses.first > status = @user.statuses.after(recent) > > But in the spec, I get this: Weird, eh? It thinks that "self.class" == > Array and can't find the "find" method on the array instance. Is this > something in my code somewhere, or did something change with > association collections? > Personally I just always run the debugger whenever I encounter some weird fucked up thing like this in rails. Better to know that to guess. But, if I recall correctly, the association proxy is just an Array which includes a ton of modules - some of which come from AR. http://gist.github.com/10c44efda79f31fd2443 Scott > 6) > NoMethodError in 'StatusesController PUT #update StatusesController > (unsuccessful save) assigns @status' > undefined method `find' for # > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/base.rb:1964:in `method_missing_without_paginate' > /Users/courtenay/dev/entp/tt/vendor/plugins/will_paginate/lib/ > will_paginate/finder.rb:164:in `method_missing' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_collection.rb:60:in `find' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_collection.rb:395:in > `find_target' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_collection.rb:349:in > `load_target' > /Users/courtenay/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/ > active_record/associations/association_proxy.rb:139:in `inspect' > spec/controllers/statuses_controller_spec.rb:249: > spec/controllers/statuses_controller_spec.rb:282: > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Sat May 9 15:29:10 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 09 May 2009 13:29:10 -0600 Subject: [rspec-users] [cucumber] how to debug cucumber with netbeans? In-Reply-To: <23458483.post@talk.nabble.com> References: <23446299.post@talk.nabble.com> <4A04E600.4060808@benmabey.com> <23458483.post@talk.nabble.com> Message-ID: <4A05D986.7000207@benmabey.com> Jean-Michel Garnier wrote: > > Jean-Michel Garnier wrote: > >> 3 months ago, I submitted a patch to cucumber so I could run cucumber from >> a >> ruby script and use the debugger in netbeans >> (https://rspec.lighthouseapp.com/projects/16211/tickets/128-running-feature-from-ruby-script) >> >> It worked well at the time but I can't make it work with cucumber 0.3.2. >> Here is the stacktrace: >> Cucumber::Netbeans::Runner.new().run_feature >> "features/_admin/projects.feature" >> >> I wonder if fellow netbeans on cucumber users will have an idea ... >> Ironically, debugging that script with netbeans crashes the debugger at >> Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54 >> >> For the time being, I am using the "old school" ruby-debug which works >> pretty well ... >> >> JM >> >> > > Thanks for your answer, Ben > > >> So, you can run the feature fine without the debugger? >> > > * yes, it run fine indeed, I mean it loads everything all right and then > crash in a cucumber step with "segmentation fault" > > >> What is >> confusing is that "lib/active_merchant" is showing up in the backtrace >> saying it can't be found... >> > > * I don' understand it either and I suspect it's a Rails / cucumber / > polyglot rubygems issue as I have found a few messages describing problems > with cucumber and "polyglot_original_require' > from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54" > > * For the time being, I just give up debugging cucumber with netbeans ... > > >> What if you try to run the feature with the >> debugger from outside of Netbeans? >> > > * You mean with classic ruby-debug? I had never used it before as I come > from a java + Eclispe background and always used an IDE to debug. > > I must admit that ruby-debug is very easy to use and it did well to find the > cause of my problem: > cucumber calling webrat visit with "eval". There was a bug in a > before_filter of a controller which was doing an infinite loop. Apparently, > the mac ruby interpreter did not like it and crashed with "segmentation > fault". Running Rails in "development" mode was working fine and showing an > exception stacktrace... > > This is the kind of situtation where TDD is actually slower than > "prehistoric development with no tests". I spent 3 hours looking for the > source of the problems and it took me 15 minutes running Rails in > developement mode. > > In order to improve webrat, I'll spend 1 hour this morning o try to write a > spec to reproduce the bug. > Glad you got it fixed. Yeah, TDD/BDD certainly can slow you down at times especially on initial investments like this. It just comes down to if it is worth it for you and this project or if you would be fine with some technical debt. :) -Ben From dchelimsky at gmail.com Sun May 10 14:42:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 10 May 2009 11:42:09 -0700 Subject: [rspec-users] rspec_scaffold and mocha In-Reply-To: <85d99afe0905082111k22ad0b95y6ed36cd47806dd2a@mail.gmail.com> References: <22765d31-f530-4cd4-af9d-02db2cb936f2@z7g2000vbh.googlegroups.com> <85d99afe0905082111k22ad0b95y6ed36cd47806dd2a@mail.gmail.com> Message-ID: <57c63afe0905101142m4a7b7df7u180595cc082dc655@mail.gmail.com> On Fri, May 8, 2009 at 9:11 PM, Zach Dennis wrote: > On Thu, May 7, 2009 at 7:40 AM, jevado wrote: >> Hi All, >> >> I have a question about the rspec_scaffold and if it's compatible with >> other mocking frameworks. >> I just created a blank application and a scaffold of a very basic >> model. The specs run fine untill I choose to use mocha in the >> spec_helper. >> >> Can somebody please tell me if this is ment to be and if so if there's >> an easy way to make the scaffold work with mocha ? > > RSpec scaffold is not set up produce scaffold for all of the various > mocking libraries. It does so just for what comes with RSpec. I do not > know of a way to simply replace scaffolding w/o providing more > scaffolding (ones for each mocking library) and then adding a flag to > the "script/generate" command to produce scaffolding for > rspec+default, rspec+mocha, rspec+rr, etc. > > Also, in addition to this the normal "script/generate rspec" command > could be used to take the same options so it would configure your > spec_helper to run with the appropriate libraries. > > I think your idea for scaffolding with different mocking libraries is > a good one. Please open a ticket on lighthouse and let's see if we can > get some more input from others in the community as well as the core > team. > > http://rspec.lighthouseapp.com/ You can go ahead and file a feature request if you like, but given that there is a GSOC project to deal with rails generators, including support for rspec, I'm not going to be making any significant changes to the rspec generators in the short term. Cheers, David > > >> >> Thanks in advance! >> Jeroen >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com (personal) > http://www.mutuallyhuman.com (hire me) > @zachdennis (twitter) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From kero at chello.nl Sun May 10 15:43:15 2009 From: kero at chello.nl (Kero van Gelder) Date: Sun, 10 May 2009 21:43:15 +0200 Subject: [rspec-users] request for gists / pasties In-Reply-To: <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> Message-ID: <20090510194315.GL980@bumblebee.m38c.nl> > Questions: > [...] > * pls provide a full backtrace > * best in a gist or pastie Imagine someone looking at the problem report two years from now. No pastie. Then the solution (if provided) comes without a complete problem. Like code without a test. Put it in an attachment, or whatever, but keep the two together, please. Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From lists at ruby-forum.com Sun May 10 17:48:48 2009 From: lists at ruby-forum.com (Rainer Kuhn) Date: Sun, 10 May 2009 23:48:48 +0200 Subject: [rspec-users] RCov and Ruby 1.9.1 In-Reply-To: <81ce5c2ca54b1989986e7754844b45a2@ruby-forum.com> References: <81ce5c2ca54b1989986e7754844b45a2@ruby-forum.com> Message-ID: <71c004e0e86db30c7a135759be923d8c@ruby-forum.com> I solved it with relevance-rcov (formerly spicycode-rcov). There were remnants of an the failed "gem install rcov" attempt that caused errors. Some sudo rm -rf ... fixed that. Seemes to work fine on a test project. Tick -- Posted via http://www.ruby-forum.com/. From r_j_h_box-sf at yahoo.com Mon May 11 00:33:32 2009 From: r_j_h_box-sf at yahoo.com (Randy Harmon) Date: Sun, 10 May 2009 21:33:32 -0700 Subject: [rspec-users] Problem verifying routing error In-Reply-To: <4A046AEF.1090307@benmabey.com> References: <49FCAAA6.6040600@yahoo.com> <4A046AEF.1090307@benmabey.com> Message-ID: <4A07AA9C.7010409@yahoo.com> Thanks, Ben. >> NoMethodError in 'ItemsController route generation should NOT map >> #indewfefwex' >> You have a nil object when you didn't expect it! >> You might have expected an instance of Array. >> The error occurred while evaluating nil.first >> /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertions.rb:134:in >> >> `recognized_request_for' [clip] [reordered] Ben Mabey: > Hmm.. yeah, it seems like it might have to do with how the exceptions > are being handled in the newer version of rspec-rials (see > https://rspec.lighthouseapp.com/projects/5645/tickets/85-11818-have-mode-for-rails-error-handling). Right, the bypass_rescue() method. Just to clarify: Me: >> I tried using bypass_rescue in my routing/items_routing_spec.rb file as >> mentioned by the upgrade doc, but it wasn't valid in the "routing" spec >> - worked fine when I moved the file back to spec/controllers/, though. "worked fine", by which I mean "didn't have a problem with me calling it" - but didn't provide any exception for me to catch. Ben: > I don't use RSpec to verify my routes very often and have never used it > to verify the non-existence of a route so I'm afraid I don't really have > any ideas... Maybe I'm out of my tree a bit to want it. I guess I don't really care to validate has_many relationships, why should it matter to validate :except rules? Should I adjust my thinking on this one? Thanks, Randy From aidy.lewis at googlemail.com Mon May 11 05:22:37 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 11 May 2009 10:22:37 +0100 Subject: [rspec-users] [cucumber] how to debug cucumber with netbeans? In-Reply-To: <4A05D986.7000207@benmabey.com> References: <23446299.post@talk.nabble.com> <4A04E600.4060808@benmabey.com> <23458483.post@talk.nabble.com> <4A05D986.7000207@benmabey.com> Message-ID: <7ac2300c0905110222p4f214073nc6400415dca56977@mail.gmail.com> Hi Jean, 2009/5/9 Ben Mabey : > Jean-Michel Garnier wrote: >> >>> >>> 3 months ago, I submitted a patch to cucumber so I could run cucumber >>> from >>> a >>> ruby script and use the debugger in netbeans Is it possible for you to Wiki how to use the Netbeans debugger through Cucumber and your patch? -- Aidy blog: www.agiletester.co.uk twitter: http://twitter.com/aidy_lewis From aidy.lewis at googlemail.com Mon May 11 05:26:07 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 11 May 2009 10:26:07 +0100 Subject: [rspec-users] Sharing common Cuke steps In-Reply-To: References: Message-ID: <7ac2300c0905110226p72703e3bvac9f394b0fd260f4@mail.gmail.com> Hi All > It seems to me that there's an opportunity for packaging together and > sharing steps, but am curious of folks thoughts on the best way to go about > this. > > Mike > Customer/Users are likely to have their 'own' language' and that providing library steps - could thus be argued - to negate BDD. Also we are all using different 'browser' drivers. -- Aidy blog: www.agiletester.co.uk twitter: http://twitter.com/aidy_lewis From lists at ruby-forum.com Mon May 11 09:24:06 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 11 May 2009 15:24:06 +0200 Subject: [rspec-users] Where to spec authentication and roles-based permissions? In-Reply-To: <50873a360905080233q6b6d1c60x1ffe73887984097a@mail.gmail.com> References: <50873a360905080233q6b6d1c60x1ffe73887984097a@mail.gmail.com> Message-ID: <0aaee07cccf33a06b9b1ca9af5c739cd@ruby-forum.com> Doug Livesey wrote: > Hi -- I'm writing an app that both requires authentication via a logon, > and also has roles-based permissions (using acl_system2), ... I am at the point where a more complete authorisation system is required and I was wondering what others here would suggest for implementation. I am looking at both acl9 and declarative_authorization. However, if there are any alternatives to these that people feel strongly about I would like to hear of them. I am leaning towards declarative_authorization but acl9 seems very attractive as well. Any comments on either of these or alternatives? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Mon May 11 13:48:21 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 11 May 2009 18:48:21 +0100 Subject: [rspec-users] question re: stubbing out validations In-Reply-To: <83e853830905110905l72af265u62f67d436531824@mail.gmail.com> References: <83e853830905110905l72af265u62f67d436531824@mail.gmail.com> Message-ID: On 11 May 2009, at 17:05, Barun Singh wrote: > Suppose a "User" has many "widgets", and that we have a method in > the User class that does something like: > > def update_widgets > x = ... code to do some calculations ... > if x > 5 > new_widget = widgets.new > new_widget.save! > else > widgets.first.destroy > end > > widgets.reload > end > > How would one spec this without having to worry about the > validations for new_widget? Is there any way in the spec to tell it > to replace instances of save! with instances of save(false) or > something along those lines? Using message expectations is difficult > in this case because the new_widget doesn't exist before the method > is called, so there's not object that can ahead of time expect to > receive the save! method. If you have a user object in your specs, you could do this: user.widgets.stub!(:new).and_return(mock(Widget, :save! => nil)) but you're getting into some ugly territory mixing mocks with calls to the database (e.g. widgets.reload). What does your spec look like? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From bkocik at gmail.com Mon May 11 15:59:32 2009 From: bkocik at gmail.com (Bill Kocik) Date: Mon, 11 May 2009 15:59:32 -0400 Subject: [rspec-users] Test JSON with Cucumber Message-ID: <310c80f00905111259r8747b66m8c7ba44f4873cf53@mail.gmail.com> Hi Folks - I'm hoping someone has come before me in trying to do this. I want to use Cucumber to acceptance-test my JSON output. So far all I can do is validate that the JSON is valid, with this step: Then /^I should get valid JSON$/ do assert_nothing_raised do ActiveSupport::JSON.decode(@response.body) end What I'd really like to do is be able to drill down into the JSON looking for the presence of certain elements in their correct places. For example, if my JSON is {"foo":{"bar":"baz"}} and parses out to {'foo' => {'bar' => 'baz'}} then I want to be able to test that ['foo']['bar'] gives me 'baz', or at least that ['foo']['bar'] exists. Unfortunately I'm not sure how to go about writing step definitions to do anything like this, since I haven't yet figured out a way to take a regular expression or string and inspect a hash with it. Anyone have any ideas? I could really use a brain-kick here. Thanks... -- Bill Kocik http://bkocik.net From ben at benmabey.com Mon May 11 16:32:22 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 11 May 2009 14:32:22 -0600 Subject: [rspec-users] Test JSON with Cucumber In-Reply-To: <310c80f00905111259r8747b66m8c7ba44f4873cf53@mail.gmail.com> References: <310c80f00905111259r8747b66m8c7ba44f4873cf53@mail.gmail.com> Message-ID: <4A088B56.30604@benmabey.com> Bill Kocik wrote: > Hi Folks - > > I'm hoping someone has come before me in trying to do this. I want to > use Cucumber to acceptance-test my JSON output. So far all I can do is > validate that the JSON is valid, with this step: > > Then /^I should get valid JSON$/ do > assert_nothing_raised do > ActiveSupport::JSON.decode(@response.body) > end > > What I'd really like to do is be able to drill down into the JSON > looking for the presence of certain elements in their correct places. > For example, if my JSON is {"foo":{"bar":"baz"}} and parses out to > {'foo' => {'bar' => 'baz'}} then I want to be able to test that > ['foo']['bar'] gives me 'baz', or at least that ['foo']['bar'] exists. > Unfortunately I'm not sure how to go about writing step definitions to > do anything like this, since I haven't yet figured out a way to take a > regular expression or string and inspect a hash with it. > > Anyone have any ideas? I could really use a brain-kick here. > > Thanks... > > Well.. IIRC ActiveSupport::JSON.decode will return a ruby hash of the JSON, correct? So you should be able to make expectations on it just like a regular hash object. json = ActiveSupport::JSON.decode(@response.body) json['foo']['bar'].should == 'baz'. Does that help or am I missing something about your question? -Ben From lists at ruby-forum.com Mon May 11 17:03:04 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 11 May 2009 23:03:04 +0200 Subject: [rspec-users] Cucumber 0.3.3 - Examples: Message-ID: <42619f83bdf0fa68449d1c53f0c94a5a@ruby-forum.com> Am I correct when I infer that the "Examples" keyword is now only valid in a Scenario Outline? If so, in what version did this change take place? -- Posted via http://www.ruby-forum.com/. From Jarmo.P at gmail.com Mon May 11 17:30:58 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Mon, 11 May 2009 14:30:58 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> Message-ID: <83813a0a-37e9-40f3-ada7-6b39efb74a08@q2g2000vbr.googlegroups.com> Thanks for adding this change into repo! I'm quite surprised that anyone else haven't stumbled upon this problem yet. I guess it's because most of spec'ing is done for Ruby projects, so this functionality is not needed. I have been thinking a little more about this topic and asked myself: why not make it backwards compatible without explicitly stating subject as 'self'? If not making it backwards compatible then all my current specs which use Watir would have to be changed by adding "subject {self}" to them. Why just not use ExampleGroup as a receiver for #should when string is used in ExampleGroup description? I cannot see any negative impacts on that change and rake specs are also passing. Any ideas where this might fail? There probably aren't any specs where description is written as a string and then you want to invoke matchers against that string... Doesn't seem logical to me. So, I've changed locally should method in Spec::Example::Subject::ExampleMethods from: def should(matcher=nil) self == subject ? self.__should_for_example_group__ (matcher) : subject.should(matcher) end to: def should(matcher=nil) if self == subject || (subject.is_a?(String) && subject == instance_eval(&self.class.subject)) self.__should_for_example_group__(matcher) else subject.should(matcher) end end I've added that "&& subject == instance_eval(&self.class.subject)" part as an extra precaution, but i don't have any ideas, why it's needed anyway, because I cannot think of any cases where string is used as a subject... or maybe there are some libraries, which monkey- patch String and want to call #should implicitly?! :) in short, at the moment this seems to work also (rake specs are passing again): def should(matcher=nil) if self == subject || subject.is_a?(String) self.__should_for_example_group__(matcher) else subject.should(matcher) end end If you think that this functionality might be reasonable for wider use (some other Watir or similar library users for example), then I can provide a patch with specs. Regards, Jarmo From bkocik at gmail.com Mon May 11 17:31:04 2009 From: bkocik at gmail.com (Bill Kocik) Date: Mon, 11 May 2009 17:31:04 -0400 Subject: [rspec-users] Test JSON with Cucumber In-Reply-To: <4A088B56.30604@benmabey.com> References: <310c80f00905111259r8747b66m8c7ba44f4873cf53@mail.gmail.com> <4A088B56.30604@benmabey.com> Message-ID: <310c80f00905111431k70ab384cs5ccafa63e0942f23@mail.gmail.com> On Mon, May 11, 2009 at 4:32 PM, Ben Mabey wrote: > Well.. IIRC ActiveSupport::JSON.decode will return a ruby hash of the JSON, > correct? ?So you should be able to make expectations on it just like a > regular hash object. You're absolutely correct - I think I did a poor job of asking my question. Maybe a more concrete example would help. Suppose I have this JSON: response:{code:'200',requestId:'1234'} I want to have a scenario like this in my Cucumber feature file: When I go to "the statuses JSON url" Then I should find "....." # ['response']['code'] And I should find "....." #['response']['requestId'] With a step definition like: Then /^I should find "([^\"]*)"$/ do |the_string| json = ActiveSupport::JSON.decode(@response.body) assert_not_nil ...... #(something with the json obect and the_string) end I don't know what goes in those blanks. Cucumber is going to give me a string it found with the regex, but I don't know what the string would look like in my "Then I should find" line in my feature file, nor what to do with it in my assert line in the step definition. I'm not even sure any of this is possible. Consider if I were dealing with XML instead of JSON - I could put an XPath expression in my "Then I should find" line, and in my step definition I could search the XML with the given XPath expression using hpricot or something. With JSON and it's resultant hash, I have no idea where to start... -- Bill Kocik http://bkocik.net From michael at schuerig.de Mon May 11 18:03:54 2009 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 12 May 2009 00:03:54 +0200 Subject: [rspec-users] Test JSON with Cucumber In-Reply-To: <310c80f00905111431k70ab384cs5ccafa63e0942f23@mail.gmail.com> References: <310c80f00905111259r8747b66m8c7ba44f4873cf53@mail.gmail.com> <4A088B56.30604@benmabey.com> <310c80f00905111431k70ab384cs5ccafa63e0942f23@mail.gmail.com> Message-ID: <200905120003.55469.michael@schuerig.de> On Monday 11 May 2009, Bill Kocik wrote: > On Mon, May 11, 2009 at 4:32 PM, Ben Mabey wrote: > > Well.. IIRC ActiveSupport::JSON.decode will return a ruby hash of > > the JSON, correct? So you should be able to make expectations on > > it just like a regular hash object. > > You're absolutely correct - I think I did a poor job of asking my > question. Maybe a more concrete example would help. Suppose I have > this JSON: > > response:{code:'200',requestId:'1234'} > > I want to have a scenario like this in my Cucumber feature file: > > When I go to "the statuses JSON url" > Then I should find "....." # ['response']['code'] > And I should find "....." #['response']['requestId'] > > With a step definition like: > > Then /^I should find "([^\"]*)"$/ do |the_string| > json = ActiveSupport::JSON.decode(@response.body) > assert_not_nil ...... #(something with the json obect and > the_string) end Do you want to cherry-pick individual pieces from the JSON, i.e. you don't care about the exact response as long as the parts you're looking for are there? Or would it be okay to check against a known good response? The latter case is easier. In the former case, how about a matcher that checks the actual response is a superset of the expected response? [...] > Consider if I were dealing with XML instead of JSON - I could put an > XPath expression in my "Then I should find" line, and in my step > definition I could search the XML with the given XPath expression > using hpricot or something. With JSON and it's resultant hash, I have > no idea where to start... There's JSONPath, but I don't think a Ruby implementation exists. If you always have "definite" paths without wildcards and recursion(?) then you might be able to do with some simple code like this When I go to "the statuses JSON url" Then I should find "response.code" Then /^I should find "([^\"]*)"$/ do |the_string| json = ActiveSupport::JSON.decode(@response.body) obj = traverse(json, the_string) assert_not_nil obj end def traverse(json, path) path.split('.').inject(json) do |value, selector| value = value[selector] end rescue nil end Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From zach.dennis at gmail.com Mon May 11 18:42:24 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 11 May 2009 18:42:24 -0400 Subject: [rspec-users] Test JSON with Cucumber In-Reply-To: <310c80f00905111431k70ab384cs5ccafa63e0942f23@mail.gmail.com> References: <310c80f00905111259r8747b66m8c7ba44f4873cf53@mail.gmail.com> <4A088B56.30604@benmabey.com> <310c80f00905111431k70ab384cs5ccafa63e0942f23@mail.gmail.com> Message-ID: <85d99afe0905111542m79ae2534i5189d8f3ff8282c2@mail.gmail.com> On Mon, May 11, 2009 at 5:31 PM, Bill Kocik wrote: > On Mon, May 11, 2009 at 4:32 PM, Ben Mabey wrote: > >> Well.. IIRC ActiveSupport::JSON.decode will return a ruby hash of the JSON, >> correct? ?So you should be able to make expectations on it just like a >> regular hash object. > > You're absolutely correct - I think I did a poor job of asking my > question. Maybe a more concrete example would help. Suppose I have > this JSON: > > response:{code:'200',requestId:'1234'} > > I want to have a scenario like this in my Cucumber feature file: > > When I go to "the statuses JSON url" > Then I should find "....." # ['response']['code'] > And I should find "....." #['response']['requestId'] > > With a step definition like: > > Then /^I should find "([^\"]*)"$/ do |the_string| > ?json = ActiveSupport::JSON.decode(@response.body) > ?assert_not_nil ...... #(something with the json obect and the_string) > end > > I don't know what goes in those blanks. Cucumber is going to give me a > string it found with the regex, but I don't know what the string would > look like in my "Then I should find" line in my feature file, nor what > to do with it in my assert line in the step definition. I'm not even > sure any of this is possible. > > Consider if I were dealing with XML instead of JSON - I could put an > XPath expression in my "Then I should find" line, and in my step > definition I could search the XML with the given XPath expression > using hpricot or something. With JSON and it's resultant hash, I have > no idea where to start... > Another options is to call #to_xml on the JSON hash returned by #decode, and then use XPath since you seem to already know it, > -- > Bill Kocik > > http://bkocik.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From ben at benmabey.com Mon May 11 18:46:40 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 11 May 2009 16:46:40 -0600 Subject: [rspec-users] Cucumber 0.3.3 - Examples: In-Reply-To: <42619f83bdf0fa68449d1c53f0c94a5a@ruby-forum.com> References: <42619f83bdf0fa68449d1c53f0c94a5a@ruby-forum.com> Message-ID: <4A08AAD0.4070409@benmabey.com> James Byrne wrote: > Am I correct when I infer that the "Examples" keyword is now only valid > in a Scenario Outline? If so, in what version did this change take > place? > Yes... "Examples" is only valid in Scenario Outlines, but you can also use "Scenarios" as well. I don't remember being able to use "Examples" outside of the of Scenario Outlines. Where were you using it before? My guess is that if you were using it before it was an unintentional feature that was removed when things were cleaned up. Aslak or Joesph could give you a more definitive answer. In short, I don't know what version this change happened in- sorry. -Ben From court3nay at gmail.com Mon May 11 19:10:03 2009 From: court3nay at gmail.com (court3nay) Date: Mon, 11 May 2009 16:10:03 -0700 (PDT) Subject: [rspec-users] Running single spec files -- how? Message-ID: <3c54bb03-beb0-4c94-b775-39a425467528@e20g2000vbc.googlegroups.com> Before upgrading from 1.1.11 to 1.2.4 I used to be able to do this: ruby spec/models/user_spec.rb Now it looks like you have to do script/spec spec/models/user_spec.rb Or something like this, which is actually kinda cool: script/spec spec/*/user* Is that correct? Am I missing something? From ben at benmabey.com Mon May 11 19:16:21 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 11 May 2009 17:16:21 -0600 Subject: [rspec-users] Running single spec files -- how? In-Reply-To: <3c54bb03-beb0-4c94-b775-39a425467528@e20g2000vbc.googlegroups.com> References: <3c54bb03-beb0-4c94-b775-39a425467528@e20g2000vbc.googlegroups.com> Message-ID: <4A08B1C5.2010102@benmabey.com> court3nay wrote: > Before upgrading from 1.1.11 to 1.2.4 I used to be able to do this: > > ruby spec/models/user_spec.rb > > Now it looks like you have to do > > script/spec spec/models/user_spec.rb > > Or something like this, which is actually kinda cool: > > script/spec spec/*/user* > > Is that correct? Am I missing something? > There was a change that broke this behaviour, but it was documented in the History and how to get back the old behaviour: === Version 1.2.0 / 2009-03-15 * warnings: * If you use the ruby command to run specs instead of the spec command, you'll need to require 'spec/autorun' or they won't run. This won't affect you if you use the spec command or the Spec::Rake::SpecTask that ships with RSpec. So... just add a require 'spec/autorun' in your spec_helper.rb and you should be good to go. HTH, Ben From scott at railsnewbie.com Mon May 11 19:17:10 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 11 May 2009 19:17:10 -0400 Subject: [rspec-users] Running single spec files -- how? In-Reply-To: <3c54bb03-beb0-4c94-b775-39a425467528@e20g2000vbc.googlegroups.com> References: <3c54bb03-beb0-4c94-b775-39a425467528@e20g2000vbc.googlegroups.com> Message-ID: On May 11, 2009, at 7:10 PM, court3nay wrote: > Before upgrading from 1.1.11 to 1.2.4 I used to be able to do this: > > ruby spec/models/user_spec.rb I would assume that would work if you are requiring test-unit interop mode. I believe in previous versions of rspec it was automatically included if the constants Test && Test::Unit were present (which AR automatically adds once AR is required). > > > Now it looks like you have to do > > script/spec spec/models/user_spec.rb > > Or something like this, which is actually kinda cool: > > script/spec spec/*/user* > > Is that correct? Am I missing something? I've always kept around this alias: alias ss='./script/spec -O spec/spec.opts' So I can do: ss spec/unit/models/event_* Scott From bkocik at gmail.com Mon May 11 19:40:09 2009 From: bkocik at gmail.com (Bill Kocik) Date: Mon, 11 May 2009 19:40:09 -0400 Subject: [rspec-users] Test JSON with Cucumber In-Reply-To: <85d99afe0905111542m79ae2534i5189d8f3ff8282c2@mail.gmail.com> References: <310c80f00905111259r8747b66m8c7ba44f4873cf53@mail.gmail.com> <4A088B56.30604@benmabey.com> <310c80f00905111431k70ab384cs5ccafa63e0942f23@mail.gmail.com> <85d99afe0905111542m79ae2534i5189d8f3ff8282c2@mail.gmail.com> Message-ID: <310c80f00905111640o6f65d8f7o1c104bf89a72eae1@mail.gmail.com> ooh - I love this solution. The downsides that immediately come to mind are that I'd be putting XPath expressions in my acceptance tests which aren't necessarily readable, but since I'm the only one who has to read them that's alright, and that I have to parse JSON into a hash, convert the hash to XML, and then parse that XML again with Nokogiri or something, but assuming that the converters I'm using are well-tested and predictable, that's an acceptable thing to me. The upside is that I can query my JSON with arbitrary depth and precision using XPath. Awesome. I love having access to groups of people who are smarter than me. Thanks for everyone's suggestions... On Mon, May 11, 2009 at 6:42 PM, Zach Dennis wrote: > Another options is to call #to_xml on the JSON hash returned by > #decode, and then use XPath since you seem to already know it, -- Bill Kocik http://bkocik.net From lists at ruby-forum.com Mon May 11 20:54:12 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 12 May 2009 02:54:12 +0200 Subject: [rspec-users] Cucumber 0.3.3 - Examples: In-Reply-To: <4A08AAD0.4070409@benmabey.com> References: <42619f83bdf0fa68449d1c53f0c94a5a@ruby-forum.com> <4A08AAD0.4070409@benmabey.com> Message-ID: Ben Mabey wrote: > In short, I don't know what version this change happened in- sorry. > It was just idle curiosity that prompted the question. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Mon May 11 21:13:10 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 11 May 2009 21:13:10 -0400 Subject: [rspec-users] question re: stubbing out validations In-Reply-To: <83e853830905110905l72af265u62f67d436531824@mail.gmail.com> References: <83e853830905110905l72af265u62f67d436531824@mail.gmail.com> Message-ID: <85d99afe0905111813g6388518dvb7615a5d8fe4aded@mail.gmail.com> On Mon, May 11, 2009 at 12:05 PM, Barun Singh wrote: > Suppose a "User" has many "widgets", and that we have a method in the User > class that does something like: > > def update_widgets > ? x = ... code to do some calculations ... > ? if x > 5 > ??? new_widget = widgets.new > ??? new_widget.save! > ? else > ??? widgets.first.destroy > ? end > > ? widgets.reload > end > > How would one spec this without having to worry about the validations for > new_widget? It seems pretty important that update_widgets is able to produce actual widgets. I would use actual models here rather than try to stub/mock something out. After all the whole method is about creating (or destroying) the widgets. It seems pretty central to the behaviour of the method. However, if what you shared is the "dumbed" down version of your code for us on the ML then perhaps there is something complicated going on that makes it a good candidate to be designed differently. > Is there any way in the spec to tell it to replace instances of > save! with instances of save(false) or something along those lines? Using > message expectations is difficult in this case because the new_widget > doesn't exist before the method is called, so there's not object that can > ahead of time expect to receive the save! method. Are you telling us the full story? In the above code you shared you don't pass any attributes into "widget.new". So, how does it create valid widgets in the actual app? > > Thanks.. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From dchelimsky at gmail.com Mon May 11 23:21:20 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 11 May 2009 22:21:20 -0500 Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <83813a0a-37e9-40f3-ada7-6b39efb74a08@q2g2000vbr.googlegroups.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> <83813a0a-37e9-40f3-ada7-6b39efb74a08@q2g2000vbr.googlegroups.com> Message-ID: <57c63afe0905112021y2c93b2e4p856d13b614392037@mail.gmail.com> On Mon, May 11, 2009 at 4:30 PM, Jarmo Pertman wrote: > Thanks for adding this change into repo! > I'm quite surprised that anyone else haven't stumbled upon this > problem yet. I guess it's because most of spec'ing is done for Ruby > projects, so this functionality is not needed. > > I have been thinking a little more about this topic and asked myself: > why not make it backwards compatible without explicitly stating > subject as 'self'? If not making it backwards compatible then all my > current specs which use Watir would have to be changed by adding > "subject {self}" to them. > > Why just not use ExampleGroup as a receiver for #should when string is > used in ExampleGroup description? I cannot see any negative impacts on > that change and rake specs are also passing. Any ideas where this > might fail? There probably aren't any specs where description is > written as a string and then you want to invoke matchers against that > string... Doesn't seem logical to me. > > So, I've changed locally should method in > Spec::Example::Subject::ExampleMethods from: > > ? ? ? ?def should(matcher=nil) > ? ? ? ? ?self == subject ? self.__should_for_example_group__ > (matcher) : subject.should(matcher) > ? ? ? ?end > > to: > ? ? ? ?def should(matcher=nil) > ? ? ? ? ?if self == subject || (subject.is_a?(String) && subject == > instance_eval(&self.class.subject)) > ? ? ? ? ? ?self.__should_for_example_group__(matcher) > ? ? ? ? ?else > ? ? ? ? ? ?subject.should(matcher) > ? ? ? ? ?end > ? ? ? ?end > > I've added that "&& subject == instance_eval(&self.class.subject)" > part as an extra precaution, but i don't have any ideas, why it's > needed anyway, because I cannot think of any cases where string is > used as a subject... or maybe there are some libraries, which monkey- > patch String and want to call #should implicitly?! :) > > in short, at the moment this seems to work also (rake specs are > passing again): > ? ? ? ?def should(matcher=nil) > ? ? ? ? ?if self == subject || subject.is_a?(String) > ? ? ? ? ? ?self.__should_for_example_group__(matcher) > ? ? ? ? ?else > ? ? ? ? ? ?subject.should(matcher) > ? ? ? ? ?end > ? ? ? ?end > > If you think that this functionality might be reasonable for wider use > (some other Watir or similar library users for example), then I can > provide a patch with specs. I don't want to promote using self as subject. I think being able to do so explicitly, as we can now with your previous patch, is perfectly reasonable. But doing so is a bit of a trick in my view, and runs counter to the overall intent of the structure of examples of behaviour of an object or sub-system. "should" is about that object or sub-system, not self. If your whole suite is using this, you can localize the "subject {self}" call, however, in spec_helper, like this: class Spec::ExampleGroup subject {self} end HTH, David > Regards, > Jarmo From jeroenvdoorn at gmail.com Tue May 12 02:27:41 2009 From: jeroenvdoorn at gmail.com (jevado) Date: Mon, 11 May 2009 23:27:41 -0700 (PDT) Subject: [rspec-users] rspec_scaffold and mocha In-Reply-To: <632154f70905101817i30f3d573gea438c8d0c5d2f53@mail.gmail.com> References: <4237663a-0250-496e-830c-c625e641bd26@o30g2000vbc.googlegroups.com> <632154f70905101817i30f3d573gea438c8d0c5d2f53@mail.gmail.com> Message-ID: Wow, thanks for all the replies ... The rspec scaffold generates more tests than the nifty_scaffold. I didn't look into it in detail yet cause some of the nifty tests where failing too. What I did to get it workin is map the missing methods (used by respec) to methods in mocha. I also use the mislav-rspec-rails-mocha plugin. example: module Mocha class Expectation def and_return(*values) returns(*values) end end end On May 11, 3:17?am, Nicholas Van Weerdenburg wrote: > On Thu, May 7, 2009 at 1:21 PM, jevado wrote: > > Hi all, > > > Sorry if this get's posted several times but I got a message that my > > previous post wasn't allowed because I'm not a member. I think I am > > now though. > > > The problem I have is fairly simple. I have some plugins who use rspec > > and mocha and I want to make use of the rspec_scaffold generator. > > Unfortunately this doesn't work, the tests fail as soon as I set mocha > > as my prefered mocking framework. > > > Is this by design or should it work out of the box. > > > If anybody knows about a generator that does work, please let me know > > > All the best! > > Jeroen > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > As far as I can tell, Nifty_Generators nifty_scaffold (http://github.com/ryanb/nifty-generators/tree/master) generates rspec + > mocha scaffolding. ?I wasn't using Mocha so I didn't look in detail. > > e.g. here is a controller spec generated with nifty_scaffold for some work I > was doing with the authlogic plugin: > > describe UserSessionsController do > ? fixtures :all > ? integrate_views > > ? it "new action should render new template" do > ? ? get :new > ? ? response.should render_template(:new) > ? end > > ? it "create action should render new template when model is invalid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(false) > ? ? post :create > ? ? response.should render_template(:new) > ? end > > ? it "create action should redirect when model is valid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(true) > ? ? post :create > ? ? response.should redirect_to(root_url) > ? end > > ? it "destroy action should destroy model and redirect to index action" do > ? ? user_session = UserSession.first > ? ? delete :destroy, :id => user_session > ? ? response.should redirect_to(root_url) > ? ? UserSession.exists?(user_session.id).should be_false > ? end > end > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From jeroenvdoorn at gmail.com Tue May 12 02:30:09 2009 From: jeroenvdoorn at gmail.com (jevado) Date: Mon, 11 May 2009 23:30:09 -0700 (PDT) Subject: [rspec-users] rspec_scaffold and mocha In-Reply-To: <632154f70905101817i30f3d573gea438c8d0c5d2f53@mail.gmail.com> References: <4237663a-0250-496e-830c-c625e641bd26@o30g2000vbc.googlegroups.com> <632154f70905101817i30f3d573gea438c8d0c5d2f53@mail.gmail.com> Message-ID: <5052878a-7794-4b38-b429-7e47317e7944@r3g2000vbp.googlegroups.com> post wasn't finished yet ... I know that it's not very clean but since it's just for scaffolding and I'll probably rewrite most of the tests later on anyway it's acceptable for now. Thanks again and I'll monitor the GSOC project :) Kind regards, Jeroen On May 11, 3:17?am, Nicholas Van Weerdenburg wrote: > On Thu, May 7, 2009 at 1:21 PM, jevado wrote: > > Hi all, > > > Sorry if this get's posted several times but I got a message that my > > previous post wasn't allowed because I'm not a member. I think I am > > now though. > > > The problem I have is fairly simple. I have some plugins who use rspec > > and mocha and I want to make use of the rspec_scaffold generator. > > Unfortunately this doesn't work, the tests fail as soon as I set mocha > > as my prefered mocking framework. > > > Is this by design or should it work out of the box. > > > If anybody knows about a generator that does work, please let me know > > > All the best! > > Jeroen > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > As far as I can tell, Nifty_Generators nifty_scaffold (http://github.com/ryanb/nifty-generators/tree/master) generates rspec + > mocha scaffolding. ?I wasn't using Mocha so I didn't look in detail. > > e.g. here is a controller spec generated with nifty_scaffold for some work I > was doing with the authlogic plugin: > > describe UserSessionsController do > ? fixtures :all > ? integrate_views > > ? it "new action should render new template" do > ? ? get :new > ? ? response.should render_template(:new) > ? end > > ? it "create action should render new template when model is invalid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(false) > ? ? post :create > ? ? response.should render_template(:new) > ? end > > ? it "create action should redirect when model is valid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(true) > ? ? post :create > ? ? response.should redirect_to(root_url) > ? end > > ? it "destroy action should destroy model and redirect to index action" do > ? ? user_session = UserSession.first > ? ? delete :destroy, :id => user_session > ? ? response.should redirect_to(root_url) > ? ? UserSession.exists?(user_session.id).should be_false > ? end > end > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From jean-michel at 21croissants.com Tue May 12 03:52:45 2009 From: jean-michel at 21croissants.com (Jean-Michel Garnier) Date: Tue, 12 May 2009 00:52:45 -0700 (PDT) Subject: [rspec-users] [cucumber] how to debug cucumber with netbeans? In-Reply-To: <7ac2300c0905110222p4f214073nc6400415dca56977@mail.gmail.com> References: <23446299.post@talk.nabble.com> <4A04E600.4060808@benmabey.com> <23458483.post@talk.nabble.com> <4A05D986.7000207@benmabey.com> <7ac2300c0905110222p4f214073nc6400415dca56977@mail.gmail.com> Message-ID: <23497830.post@talk.nabble.com> aidy_lewis wrote: > > Hi Jean, > > Is it possible for you to Wiki how to use the Netbeans debugger > through Cucumber and your patch? > -- > Aidy > Aidy, I could not use netbeans because of the gems loading problem as I said in my first message. However, I was successfull with ruby-debug, see http://www.sitepoint.com/article/debug-rails-app-ruby-debug/2/ In the meanwhile, I was successful reproducing the bug with a test in webrat : https://webrat.lighthouseapp.com/projects/10503/tickets/243-segmentation-fault-when-visiting-rails-action-with-infinite-loop A simple fix would be to replace the code generation created with "eval". I believe it might speed up also cucumber as eval is slower than normal ruby code ... -- View this message in context: http://www.nabble.com/-cucumber--how-to-debug-cucumber-with-netbeans--tp23446299p23497830.html Sent from the rspec-users mailing list archive at Nabble.com. From matt at mattwynne.net Tue May 12 04:10:34 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 12 May 2009 09:10:34 +0100 Subject: [rspec-users] [cucumber] junit formatter In-Reply-To: <19DF289E9F0F5C49A1339A29172F63E70E82926E@C1-EXG-VS1.corp.org.local> References: <19DF289E9F0F5C49A1339A29172F63E70E82926E@C1-EXG-VS1.corp.org.local> Message-ID: <11A235D7-4408-4522-AEE3-6C16064AAEEB@mattwynne.net> On 12 May 2009, at 05:29, Jones, Gareth wrote: > Hi, > > I?ve knocked together a JUnit xml output formatter for cucumber ? > we?re using it with Hudson and Ant, so it seemed like a good idea. > It?s good enough for our purposes, so I thought we should release it > into the wild, and see if it is useful for anyone else. > > Details here: http://csausdev.wordpress.com/2009/05/12/junit-formatter-for-cucumber/ Yay! thankyou. I've had the idea of writing a cucumber mode for ci_reporter[1] bubbling on my todo list since we switched to hudson, and this is going to make that much easier. [1] http://caldersphere.rubyforge.org/ci_reporter/ Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lee_longmore at yahoo.co.uk Tue May 12 08:36:23 2009 From: lee_longmore at yahoo.co.uk (Lee Longmore) Date: Tue, 12 May 2009 12:36:23 +0000 (GMT) Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View Message-ID: <961005.1326.qm@web23901.mail.ird.yahoo.com> I am new to RSpec and have just started to drive out my first Rails view using a spec. I have used the The RSpec Book (beta) to do the basic stuff like testing for the presence of a field but I am unsure where to start for driving out some AJAX functionality. In the view, I will have a text field that a user can enter a name into and then click on a link to check the availability of this name or otherwise. I plan to implement the check as an AJAX request, returning an HTML snippet or 'available' or 'not available'. I would appreciate some help on what sort of examples one might write and the various mocks, stubs and helpers etc that can be used. Or alternatively a pointer to some existing information/tutorials on this topic. Thanks. mobile: +44(0)775 392 8067 home: +44(0) 208 8358256 email: lee_longmore at yahoo.co.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: From phlip2005 at gmail.com Tue May 12 09:33:19 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 12 May 2009 06:33:19 -0700 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <961005.1326.qm@web23901.mail.ird.yahoo.com> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> Message-ID: Lee Longmore wrote: > I am new to RSpec and have just started to drive out my first Rails view > using a spec. I have used the The RSpec Book (beta) to do the basic > stuff like testing for the presence of a field but I am unsure where to > start for driving out some AJAX functionality. > > In the view, I will have a text field that a user can enter a name into > and then click on a link to check the availability of this name or > otherwise. I plan to implement the check as an AJAX request, returning > an HTML snippet or 'available' or 'not available'. gem install nokogiri rkelly assert2 ... require 'assert2/rjs' specify 'a simple passing assertion works' do xhr :get, :xhr_availability, :name => 'masone' js = @response.body js.should send_js_to(:replace_html, 'label_7', /available/) js.should send_js_to(:replace_html, 'label_7'){ span /available/ } end The first send_js_to just checks for a regexp to match the payload of the Element.update call. The second one uses {} to generate a Nokogiri Builder snippet of HTML, and match that. Here it's just span, but it could have been more complex HTML. Google assert_xhtml for more on that. > I would appreciate some help on what sort of examples one might write > and the various mocks, stubs and helpers etc that can be used. Or > alternatively a pointer to some existing information/tutorials on this > topic. The RSpec community, in my exalted opinion, mocks too much! If you can't use the real thing, it's too coupled, so break it up! -- Phlip http://flea.sourceforge.net/resume.html From phlip2005 at gmail.com Tue May 12 09:42:04 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 12 May 2009 06:42:04 -0700 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <961005.1326.qm@web23901.mail.ird.yahoo.com> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> Message-ID: Lee Longmore wrote: > I am new to RSpec and have just started to drive out my first Rails view > using a spec. I have used the The RSpec Book (beta) to do the basic > stuff like testing for the presence of a field but I am unsure where to > start for driving out some AJAX functionality. To test the onchange='' of the field, start by pulling in the Test::Unit versions of the assertions: Spec::Runner.configure do |c| c.include Test::Unit::Assertions end Now use assert_xhtml to grab your edit field and return it as a Nokogiri node. This line does it for a All: a = assert_xhtml{|x| x.a 'All', :href => '#' } assert{ a[:onclick] =~ /new Ajax.Request.*xhr_run_all/ } .send_js_to is supposed to work in the second line, but I have not yet researched out how get rkelly to parse the Ajax.Request line. The point of using rkelly inside send_js_to (aka assert_rjs_) is it's a real JavaScript lexer, not a Regexp, so when I get it working it will be very accurate! -- Phlip http://flea.sourceforge.net/resume.html From mike at mikedoel.com Tue May 12 10:04:33 2009 From: mike at mikedoel.com (Mike Doel) Date: Tue, 12 May 2009 10:04:33 -0400 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <961005.1326.qm@web23901.mail.ird.yahoo.com> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> Message-ID: <1F080A51-6CC3-414D-9273-69669EB6CF0C@mikedoel.com> On May 12, 2009, at 8:36 AM, Lee Longmore wrote: > I am new to RSpec and have just started to drive out my first Rails > view using a spec. I have used the The RSpec Book (beta) to do the > basic stuff like testing for the presence of a field but I am unsure > where to start for driving out some AJAX functionality. Check out Adam McCrea's fork of webrat: http://github.com/adamlogic/webrat/tree/master It includes a submit_form_via_ajax method that I use to do this. It basically just forces Rails into treating the form request as asking for a .js response. There are limitations on what you can do with the response (e.g. inspecting the entire page is no longer possible), but you are able to look at the response body of the call and match it against regular expressions. So, I use features like: When I go to the homepage And I use a search term of "foo" And I press "search" And the edit_search_form is submitted via ajax Then the search results should have 2 bars with the critical step like: When /^the (.+) is submitted via ajax$/ do |form| submit_form_via_ajax form end I've left out a couple of things here (in particular, a step that fills in form fields to mimic javascript action), but this basic idea makes it possible to have acceptance tests for ajax based features that are written in the language of the customer and yet operate quickly (i.e. you don't need to have selenium or something else like that involved to run this). The drawback of course is that it's not really exercising the full end- to-end system. While I understand that this is frowned upon (and for good reason), in my case, I have decided that the speed of the tests (and thus my willingness to use them) makes up for the drawbacks involved. To limit my exposure, I'm working on including javascript unit tests that will ensure that the behavior I stub out above actually works as expected. Mike Doel From dchelimsky at gmail.com Tue May 12 10:07:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 12 May 2009 09:07:49 -0500 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: References: <961005.1326.qm@web23901.mail.ird.yahoo.com> Message-ID: <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> On Tue, May 12, 2009 at 8:33 AM, Phlip wrote: > Lee Longmore wrote: >> >> I am new to RSpec and have just started to drive out my first Rails view >> using a spec. I have used the The RSpec Book (beta) to do the basic stuff >> like testing for the presence of a field but I am unsure where to start for >> driving out some AJAX functionality. >> >> In the view, I will have a text field that a user can enter a name into >> and then click on a link to check the availability of this name or >> otherwise. I plan to implement the check as an AJAX request, returning an >> HTML snippet or 'available' or 'not available'. > > gem install nokogiri rkelly assert2 > ... > require 'assert2/rjs' > > ?specify 'a simple passing assertion works' do > ? ?xhr :get, :xhr_availability, :name => 'masone' > ? ?js = @response.body > ? ?js.should send_js_to(:replace_html, 'label_7', /available/) > > ? ?js.should send_js_to(:replace_html, 'label_7'){ > ? ? ? ? ? ? ? ?span /available/ > ? ? ? ? ? ? ? ?} > ?end > > The first send_js_to just checks for a regexp to match the payload of the > Element.update call. The second one uses {} to generate a Nokogiri Builder > snippet of HTML, and match that. Here it's just span, but it could have been > more complex HTML. Google assert_xhtml for more on that. > >> I would appreciate some help on what sort of examples one might write and >> the various mocks, stubs and helpers etc that can be used. Or alternatively >> a pointer to some existing information/tutorials on this topic. > > The RSpec community, in my exalted opinion, mocks too much! If you can't use > the real thing, it's too coupled, so break it up! Phlip, You could just say "be careful not to mock too much," which would be really good advice, but instead you make a generalizing and judgmental statement like this. When's the last time you paired with someone in the RSpec community? Lee, Phlip has some really great ideas about some things, and assert2 is lovely, but based on several posts on this and other lists, I'd say he doesn't really like RSpec, nor understand its underlying intent. So by all means listen to his advice, and by all means take advantage of assert2 for this particular problem, but please also understand that he is in no way the voice of the RSpec community. Cheers, David > > -- > ?Phlip > ?http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From Lee.Longmore at googlemail.com Tue May 12 08:31:49 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Tue, 12 May 2009 05:31:49 -0700 (PDT) Subject: [rspec-users] How To Drive Out AJAX Functionality in Rails' Views? Message-ID: <6c7ec173-9b44-445a-be6f-80d0f92e0b73@z7g2000vbh.googlegroups.com> I am new to RSpec and have just started to drive out my first view using a spec. I have used the The RSpec Book (beta) to do the basic stuff like testing for the presence of a field but I am unsure where to start for driving out some AJAX functionality. In the view, I will have a text field that a user can enter a name into and then click on a link to check the availability of this name or otherwise. I plan to implement the check as an AJAX request, returning an HTML snippet or 'available' or 'not available'. I would appreciate some help on what sort of examples one might write and the various mocks, stubs and helpers etc that can be used. Or alternatively a pointer to some existing information/tutorials on this topic. Thanks. From Lee.Longmore at googlemail.com Tue May 12 10:09:15 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Tue, 12 May 2009 07:09:15 -0700 (PDT) Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: References: <961005.1326.qm@web23901.mail.ird.yahoo.com> Message-ID: Thanks Philip. I should have added in my original post that I have included the Webrat::Matchers as instructed in The Rspec Book. Unless I have misunderstood you, it appears that RSpec with Webrat::Matchers do not support the driving out of AJAX functionality in views, hence the need to use Nokogiri. Is my understanding correct? Or is this your preferred approach but there are others? On May 12, 2:42?pm, Phlip wrote: > Lee Longmore wrote: > > I am new to RSpec and have just started to drive out my first Rails view > > using a spec. I have used the The RSpec Book (beta) to do the basic > > stuff like testing for the presence of a field but I am unsure where to > > start for driving out some AJAX functionality. > > To test the onchange='' of the field, start by pulling in the Test::Unit > versions of the assertions: > > ? ?Spec::Runner.configure do |c| > ? ? ?c.include Test::Unit::Assertions > ? ?end > > Now use assert_xhtml to grab your edit field and return it as a Nokogiri node. > This line does it for a All: > > ? ? ?a = assert_xhtml{|x| ?x.a 'All', :href => '#' ?} > ? ? ?assert{ a[:onclick] =~ /new Ajax.Request.*xhr_run_all/ } > > .send_js_to is supposed to work in the second line, but I have not yet > researched out how get rkelly to parse the Ajax.Request line. > > The point of using rkelly inside send_js_to (aka assert_rjs_) is it's a real > JavaScript lexer, not a Regexp, so when I get it working it will be very accurate! > > -- > ? ?Phlip > ? ?http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue May 12 11:04:22 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 12 May 2009 16:04:22 +0100 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> Message-ID: <99AB1F57-7444-4F09-8636-EA6AABED6E47@mattwynne.net> On 12 May 2009, at 15:07, David Chelimsky wrote: > Lee, > > Phlip has some really great ideas about some things, and assert2 is > lovely, but based on several posts on this and other lists, I'd say he > doesn't really like RSpec, nor understand its underlying intent. So by > all means listen to his advice, and by all means take advantage of > assert2 for this particular problem, but please also understand that > he is in no way the voice of the RSpec community. > > Cheers, > David Lee, One thing you might want to consider is looking at using a headless browser like 'celerity' for testing your ajax code. This is quite a bit more involved for initial setup than using RSpec but will give you real confidence as you're actually running your javascript inside a browser. There are quite a few people on this list who are doing this, using the 'progressive enhancement'[1] pattern to build a version of the page that works with raw HTML, then decorate it with javascript behaviour when the page loads. I'm not doing this myself in earnest, so I'll say no more, but hopefully a couple of other people will chime in with some advice. [1]http://en.wikipedia.org/wiki/Progressive_enhancement Matt Wynne http://blog.mattwynne.net http://www.songkick.com From Lee.Longmore at googlemail.com Tue May 12 11:06:30 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Tue, 12 May 2009 08:06:30 -0700 (PDT) Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <1F080A51-6CC3-414D-9273-69669EB6CF0C@mikedoel.com> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> <1F080A51-6CC3-414D-9273-69669EB6CF0C@mikedoel.com> Message-ID: <3ef7b923-544c-4b80-9b67-a7c240f975a3@p4g2000vba.googlegroups.com> Thanks Mike. fyi, I am trying out Cucumber and Culerity for integration testing. Culerity provides for AJAX testing. Having written my first Cucumber (with Culerity) feature and set of scenarios, I was keen to then use RSpec to begin driving out the views, controllers etc so that I can eventually run the e2e Cucumber scenarios. On May 12, 3:04?pm, Mike Doel wrote: > On May 12, 2009, at 8:36 AM, Lee Longmore wrote: > > > I am new to RSpec and have just started to drive out my first Rails ? > > view using a spec. I have used the The RSpec Book (beta) to do the ? > > basic stuff like testing for the presence of a field but I am unsure ? > > where to start for driving out some AJAX functionality. > > Check out Adam McCrea's fork of webrat: > > http://github.com/adamlogic/webrat/tree/master > > It includes a submit_form_via_ajax method that I use to do this. ?It ? > basically just forces Rails into treating the form request as asking ? > for a .js response. ?There are limitations on what you can do with the ? > response (e.g. inspecting the entire page is no longer possible), but ? > you are able to look at the response body of the call and match it ? > against regular expressions. ?So, I use features like: > > ? ? ?When I go to the homepage > ? ? ?And I use a search term of "foo" > ? ? ?And I press "search" > ? ? ?And the edit_search_form is submitted via ajax > ? ? ?Then the search results should have 2 bars > > with the critical step like: > > When /^the (.+) is submitted via ajax$/ do |form| > ? ?submit_form_via_ajax form > end > > I've left out a couple of things here (in particular, a step that ? > fills in form fields to mimic javascript action), but this basic idea ? > makes it possible to have acceptance tests for ajax based features ? > that are written in the language of the customer and yet operate ? > quickly (i.e. you don't need to have selenium or something else like ? > that involved to run this). > > The drawback of course is that it's not really exercising the full end- > to-end system. ?While I understand that this is frowned upon (and for ? > good reason), in my case, I have decided that the speed of the tests ? > (and thus my willingness to use them) makes up for the drawbacks ? > involved. ?To limit my exposure, I'm working on including javascript ? > unit tests that will ensure that the behavior I stub out above ? > actually works as expected. > > Mike Doel > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From Lee.Longmore at googlemail.com Tue May 12 11:07:37 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Tue, 12 May 2009 08:07:37 -0700 (PDT) Subject: [rspec-users] How To Drive Out AJAX Functionality in Rails' Views? In-Reply-To: <6c7ec173-9b44-445a-be6f-80d0f92e0b73@z7g2000vbh.googlegroups.com> References: <6c7ec173-9b44-445a-be6f-80d0f92e0b73@z7g2000vbh.googlegroups.com> Message-ID: My apologies! I posted twice by accident. Please see my other post on this topic. On May 12, 1:31?pm, Lee wrote: > I am new to RSpec and have just started to drive out my first view > using a spec. I have used the The RSpec Book (beta) to do the basic > stuff like testing for the presence of a field but I am unsure where > to start for driving out some AJAX functionality. > > In the view, I will have a text field that a user can enter a name > into and then click on a link to check the availability of this name > or otherwise. I plan to implement the check as an AJAX request, > returning an HTML snippet or 'available' or 'not available'. > > I would appreciate some help on what sort of examples one might write > and the various mocks, stubs and helpers etc that can be used. Or > alternatively a pointer to some existing information/tutorials on this > topic. > > Thanks. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From Lee.Longmore at googlemail.com Tue May 12 11:33:40 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Tue, 12 May 2009 08:33:40 -0700 (PDT) Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <99AB1F57-7444-4F09-8636-EA6AABED6E47@mattwynne.net> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> <99AB1F57-7444-4F09-8636-EA6AABED6E47@mattwynne.net> Message-ID: <5c4c10a9-9be5-4320-9045-37920d06fb69@g19g2000vbi.googlegroups.com> Thanks Matt. I have been trying out Cucumber and Culerity (Celerity) but rather than jump directly from Cucumber to coding the necessary views, controllers and models required for each scenario, I wanted to drive out the code using RSpec. So I've started to spec a view required by a scenario, and this is where I am confused about how I approach the AJAX aspects of the view in my specs. > One thing you might want to consider is looking at using a headless ? > browser like 'celerity' for testing your ajax code. This is quite a ? > bit more involved for initial setup than using RSpec but will give you ? > real confidence as you're actually running your javascript inside a ? > browser. There are quite a few people on this list who are doing this, ? > using the 'progressive enhancement'[1] pattern to build a version of ? > the page that works with raw HTML, then decorate it with javascript ? > behaviour when the page loads. > > I'm not doing this myself in earnest, so I'll say no more, but ? > hopefully a couple of other people will chime in with some advice. > > [1]http://en.wikipedia.org/wiki/Progressive_enhancement > > Matt Wynnehttp://blog.mattwynne.nethttp://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue May 12 12:01:27 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 12 May 2009 17:01:27 +0100 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <5c4c10a9-9be5-4320-9045-37920d06fb69@g19g2000vbi.googlegroups.com> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> <99AB1F57-7444-4F09-8636-EA6AABED6E47@mattwynne.net> <5c4c10a9-9be5-4320-9045-37920d06fb69@g19g2000vbi.googlegroups.com> Message-ID: On 12 May 2009, at 16:33, Lee wrote: > Thanks Matt. > > I have been trying out Cucumber and Culerity (Celerity) but rather > than jump directly from Cucumber to coding the necessary views, > controllers and models required for each scenario, I wanted to drive > out the code using RSpec. So I've started to spec a view required by a > scenario, and this is where I am confused about how I approach the > AJAX aspects of the view in my specs. If you're using progressive enhancement though, I wouldn't expect the views themselves to be any different - the code to add javascript behaviour is all in external js files. I'd personally recommend doing that over using the rails js generators that squirt behaviour into your onclick events. eugh. > >> One thing you might want to consider is looking at using a headless >> browser like 'celerity' for testing your ajax code. This is quite a >> bit more involved for initial setup than using RSpec but will give >> you >> real confidence as you're actually running your javascript inside a >> browser. There are quite a few people on this list who are doing >> this, >> using the 'progressive enhancement'[1] pattern to build a version of >> the page that works with raw HTML, then decorate it with javascript >> behaviour when the page loads. >> >> I'm not doing this myself in earnest, so I'll say no more, but >> hopefully a couple of other people will chime in with some advice. >> >> [1]http://en.wikipedia.org/wiki/Progressive_enhancement >> >> Matt Wynnehttp://blog.mattwynne.nethttp://www.songkick.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From andy at elaptics.co.uk Tue May 12 12:59:15 2009 From: andy at elaptics.co.uk (Andy Henson) Date: Tue, 12 May 2009 17:59:15 +0100 Subject: [rspec-users] [RSpec] problems with a rails controller spec using AASM Message-ID: <8a8977e30905120959s6f5edc49jca4bbf03ff7e0a7d@mail.gmail.com> Hi All, I'm trying to spec out a Rails controller and I'm coming up with a bit of a problem. I'm pretty sure it's something fairly simple but I can no longer see the wood for the trees. I have a Jobs controller that looks like this (this is just the action with the problem for brevity) class JobsController < ApplicationController before_filter :require_user def accept @job = Job.find_by_jobno(params[:id]) unless @job.accepted? @job.accept! add_message "Job accepted" else add_message "Job already accepted" end redirect_to(job_path(@job.jobno)) end end And here's the relevant part of the specs: describe "when accessed through a browser" do before(:each) do @claim = Claim.make() @inspector = Inspector.make(:inspector) @job = Job.make(:jobno => 1) controller.stub!(:current_user).and_return(@inspector) controller.stub!(:login_required).and_return(true) end describe "when accepting a job" do it "should find the job" do Job.should_receive(:find_by_jobno).with("1").and_return(@job) do_accept end it "should redirect to the job page" do do_accept response.should redirect_to(job_path(@job.foxpro_jobno)) end describe "if it's already accepted" do before(:each) do @job.status = "accepted" @job.save end it "should add a flash message" do do_accept flash[:message].should == "Job already accepted" end it "should not change the job status" do do_accept @job.status.should == "accepted" end end describe "if it has yet to be accepted" do it "should accept the job" do @job.should_receive(:accept!) do_accept end it "should add a flash message" do do_accept flash[:message].should == "Job accepted" end it "should change the status" do do_accept @job.status.should == "accepted" end end def do_accept get_with @inspector, :accept, :id => 1 end end end Some info: RSpec 1.2.6. It's a restful controller with the accept method being an additional member. I'm using Machinist to create the objects in the database and I'm using Rubyist's AASM for state changes. The default state for a new Job is "unaccepted". When I run the code through the browser it all works as I would expect but when I run the specs I get the following failures, all other specs pass: Spec::Mocks::MockExpectationError in 'JobsController when accessed through a browser when accepting a job if it has yet to be accepted should accept the job' # expected :accept! with (any args) once, but received it 0 times And 'JobsController when accessed through a browser when accepting a job if it has yet to be accepted should change the status' FAILED expected: "accepted", got: "unaccepted" (using ==) Any help would be much appreciated. Thanks, Andy From matt at mattwynne.net Tue May 12 13:31:33 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 12 May 2009 18:31:33 +0100 Subject: [rspec-users] [RSpec] problems with a rails controller spec using AASM In-Reply-To: <8a8977e30905120959s6f5edc49jca4bbf03ff7e0a7d@mail.gmail.com> References: <8a8977e30905120959s6f5edc49jca4bbf03ff7e0a7d@mail.gmail.com> Message-ID: <48AB5331-D5A6-47C7-BC18-73F47CB78133@mattwynne.net> On 12 May 2009, at 17:59, Andy Henson wrote: > Job.find_by_jobno( needs to be stubbed all the time to return your job, or at least in the examples that are failing. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From andy at elaptics.co.uk Tue May 12 13:41:32 2009 From: andy at elaptics.co.uk (Andy Henson) Date: Tue, 12 May 2009 18:41:32 +0100 Subject: [rspec-users] [RSpec] problems with a rails controller spec using AASM In-Reply-To: <48AB5331-D5A6-47C7-BC18-73F47CB78133@mattwynne.net> References: <8a8977e30905120959s6f5edc49jca4bbf03ff7e0a7d@mail.gmail.com> <48AB5331-D5A6-47C7-BC18-73F47CB78133@mattwynne.net> Message-ID: <8a8977e30905121041t47540660u7ea286d1f0fef09c@mail.gmail.com> Hi Matt, You're a star! That was exactly it. I guess I should start pair programming :) Thanks 2009/5/12 Matt Wynne : > > On 12 May 2009, at 17:59, Andy Henson wrote: > >> Job.find_by_jobno( > > needs to be stubbed all the time to return your job, or at least in the > examples that are failing. > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Tue May 12 13:47:42 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 12 May 2009 10:47:42 -0700 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> References: <961005.1326.qm@web23901.mail.ird.yahoo.com> <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> Message-ID: David Chelimsky wrote: > You could just say "be careful not to mock too much," which would be > really good advice, Sorry; I thought I said that. This industry in general dislikes strong opinions... Mock on, everyone! > but instead you make a generalizing and judgmental > statement like this. When's the last time you paired with someone in > the RSpec community? Well it's not for want of trying! -- Phlip http://flea.sourceforge.net/resume.html From zach.dennis at gmail.com Tue May 12 14:40:31 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 12 May 2009 14:40:31 -0400 Subject: [rspec-users] How To Drive Out AJAX Functionality in Rails' Views? In-Reply-To: <6c7ec173-9b44-445a-be6f-80d0f92e0b73@z7g2000vbh.googlegroups.com> References: <6c7ec173-9b44-445a-be6f-80d0f92e0b73@z7g2000vbh.googlegroups.com> Message-ID: <85d99afe0905121140o6bfab98cuc49e4a39722a93b7@mail.gmail.com> On Tue, May 12, 2009 at 8:31 AM, Lee wrote: > I am new to RSpec and have just started to drive out my first view > using a spec. I have used the The RSpec Book (beta) to do the basic > stuff like testing for the presence of a field but I am unsure where > to start for driving out some AJAX functionality. > > In the view, I will have a text field that a user can enter a name > into and then click on a link to check the availability of this name > or otherwise. I plan to implement the check as an AJAX request, > returning an HTML snippet or 'available' or 'not available'. > > I would appreciate some help on what sort of examples one might write > and the various mocks, stubs and helpers etc that can be used. Or > alternatively a pointer to some existing information/tutorials on this > topic. For end to end coverage you'll need to utilize something like Selenium or Watir. Webrat has built-in Selenium support which I know folks are using successfully (we are at MHS). It is not as polished as the simulated support that Webrat has using an in-memory DOM, but that is starting to change. Selenium and Webrat have a bright future ahead (and a little longer term so does Watir IIRC). For isolated and/or complex client-side logic in JS you can utilize a JS-based testing framework like Screw.Unit or JSSpec: * http://github.com/nkallen/screw-unit/tree/master * http://jania.pe.kr/aw/moin.cgi/JSSpec Sorry I don't have any links to any tutorials, maybe others can provide. For me it was a largely dive-in and figure it out with Selenium a few years back, and I personally haven't taken the time to dump what I've learned to the world. The RSpec Book will include a chapter on automating Cucumber scenarios in the browser with Selenium, although I know that chapter has not been released yet. -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From mortench at gmail.com Tue May 12 13:14:24 2009 From: mortench at gmail.com (mortench) Date: Tue, 12 May 2009 10:14:24 -0700 (PDT) Subject: [rspec-users] Options Hash explanation ? Message-ID: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> The new rspec beta book and the rspec site mentions that it is possible to add a hash to "describe" and "it" constructs but very, very litle information about the particulars. What can the options hash be used for and what should it be used for? F.x. I have some identical examples that I need to run against a wide range of different models that have two configuration parameters that sometimes differ. I am thus thinking of using the has like this in example groups (tptions which are recoginzed in helpers, macros etc): describe XXXX-MODEL, :fixturesRelativeRootDir => ?testfixtures?, :serviceDescriptorRelativePath => ?services/ RubyHelloExample.service? Does usage of custom options like this make sense rspec-wise ? Finally, I did find out myself that I can get the hash from a helper?s Spec::Runner.configure.config.before(:all) using ?self.class?. However, this does not work inside nested ?it? constructs. Any advice ? From srogers1 at gmail.com Tue May 12 16:52:45 2009 From: srogers1 at gmail.com (Steven Rogers) Date: Tue, 12 May 2009 15:52:45 -0500 Subject: [rspec-users] Top level object in model specs In-Reply-To: <8d961d900905110324x14906392rdd4195223b8d7c5b@mail.gmail.com> References: <7ac2300c0905110226p72703e3bvac9f394b0fd260f4@mail.gmail.com> <8d961d900905110324x14906392rdd4195223b8d7c5b@mail.gmail.com> Message-ID: <51E747D5-D15D-4678-91DF-39B91564114F@gmail.com> I want to stub a global method in a model spec, but I can't figure out what's the equivalent in model specs for controller.stub! in controller specs and template.stub! in view specs . . . at least, it seems like I need to do that in order to make acts_as_audited happy in models. Any thoughts? Thanks, Steve From ben at benmabey.com Tue May 12 17:15:32 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 12 May 2009 15:15:32 -0600 Subject: [rspec-users] Top level object in model specs In-Reply-To: <51E747D5-D15D-4678-91DF-39B91564114F@gmail.com> References: <7ac2300c0905110226p72703e3bvac9f394b0fd260f4@mail.gmail.com> <8d961d900905110324x14906392rdd4195223b8d7c5b@mail.gmail.com> <51E747D5-D15D-4678-91DF-39B91564114F@gmail.com> Message-ID: <4A09E6F4.8050500@benmabey.com> Steven Rogers wrote: > > I want to stub a global method in a model spec, but I can't figure out > what's the equivalent in model specs for controller.stub! in > controller specs and template.stub! in view specs . . . at least, it > seems like I need to do that in order to make acts_as_audited happy in > models. Any thoughts? > > Thanks, > Steve I"m not sure what you mean by global method. Do you mean class method? If so then ModelName.stub!(:class_method) should work. If you are talking about an instance method then you just need to call stub! on the instance (it can be a mock object or a real object.) What is the exact problem you are running into though? Mocking may not be the best option.... -Ben From srogers1 at gmail.com Tue May 12 19:08:50 2009 From: srogers1 at gmail.com (Steven Rogers) Date: Tue, 12 May 2009 18:08:50 -0500 Subject: [rspec-users] Top level object in model specs In-Reply-To: <4A09E6F4.8050500@benmabey.com> References: <7ac2300c0905110226p72703e3bvac9f394b0fd260f4@mail.gmail.com> <8d961d900905110324x14906392rdd4195223b8d7c5b@mail.gmail.com> <51E747D5-D15D-4678-91DF-39B91564114F@gmail.com> <4A09E6F4.8050500@benmabey.com> Message-ID: On May 12, 2009, at 4:15 PM, Ben Mabey wrote: > Steven Rogers wrote: >> >> I want to stub a global method in a model spec, but I can't figure >> out what's the equivalent in model specs for controller.stub! in >> controller specs and template.stub! in view specs . . . at least, >> it seems like I need to do that in order to make acts_as_audited >> happy in models. Any thoughts? >> >> Thanks, >> Steve > > I"m not sure what you mean by global method. Do you mean class > method? If so then ModelName.stub!(:class_method) should work. If > you are talking about an instance method then you just need to call > stub! on the instance (it can be a mock object or a real object.) > > What is the exact problem you are running into though? Mocking may > not be the best option.... acts_as_audited has the line (acts_as_audited/lib/acts_as_audited/ audit_sweeper.rb:73) controller.send :current_user if controller.respond_to? (:current_user) which blows up in my audited models. I assume there's something akin to "controller" in controller specs and "template" in view specs that makes it easy to do things like: controller.stub! (:logged_in?).and_return(true) (vs. a stub on the model itself) SR From r_j_h_box-sf at yahoo.com Tue May 12 19:14:42 2009 From: r_j_h_box-sf at yahoo.com (Randy Harmon) Date: Tue, 12 May 2009 16:14:42 -0700 Subject: [rspec-users] Options Hash explanation ? In-Reply-To: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> References: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> Message-ID: <4A0A02E2.9010304@yahoo.com> mortench wrote: > The new rspec beta book and the rspec site mentions that it is > possible to add a hash to "describe" and "it" constructs but very, > very litle information about the particulars. > > What can the options hash be used for and what should it be used for? > > This might be used for tagging examples, marking examples for use with formatters, or other purposes probably not bearing on spec execution. I'm not saying they could or couldn't be used the way you're suggesting, but there are other possibilities you should try first IMO. > F.x. I have some identical examples that I need to run against a wide > range of different models that have two configuration parameters that > sometimes differ. I am thus thinking of using the has like this in > example groups (tptions which are recoginzed in helpers, macros etc): > > I have used a callback for this, but I understand that rspec 1.2 has macros that can take args the way your shared example can't. I haven't dug into them. Here's the callback approach demonstrated. describe "shared", :shared => true it "..." do options = shared_options() ... end end describe "thingy" it_should_behave_like "shared" def shared_options { :foo => 'bar', :baz => 'buz } end end Randy From lists at ruby-forum.com Tue May 12 19:43:42 2009 From: lists at ruby-forum.com (Sunny Bak) Date: Wed, 13 May 2009 01:43:42 +0200 Subject: [rspec-users] uninitialized constant Spec::VERSION::REV (NameError) Message-ID: <15163531c6b8ab88540e346de820a551@ruby-forum.com> I am a newbie for rspec. I am trying to install and run a "test" test, but i get an error. .../lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant Spec::VERSION::REV (NameError) Can someone help me? Thanks. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue May 12 19:46:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 12 May 2009 18:46:25 -0500 Subject: [rspec-users] uninitialized constant Spec::VERSION::REV (NameError) In-Reply-To: <15163531c6b8ab88540e346de820a551@ruby-forum.com> References: <15163531c6b8ab88540e346de820a551@ruby-forum.com> Message-ID: <57c63afe0905121646r241bab83ybe07f9ac7054f593@mail.gmail.com> On Tue, May 12, 2009 at 6:43 PM, Sunny Bak wrote: > I am a newbie for rspec. > I am trying to install and run a "test" test, but i get an error. > > .../lib/active_support/dependencies.rb:440:in `load_missing_constant': > uninitialized constant Spec::VERSION::REV (NameError) > > Can someone help me? Spec::VERSION::REV does not exist anywhere in rspec, so this is coming from something other than rspec. What versions of rails, rspec and ruby are you using? What other plugins and/or libraries? > Thanks. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue May 12 19:51:07 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 13 May 2009 01:51:07 +0200 Subject: [rspec-users] [cucumber] junit formatter In-Reply-To: <19DF289E9F0F5C49A1339A29172F63E70E829989@C1-EXG-VS1.corp.org.local> References: <19DF289E9F0F5C49A1339A29172F63E70E82926E@C1-EXG-VS1.corp.org.local> <11A235D7-4408-4522-AEE3-6C16064AAEEB@mattwynne.net> <8d961d900905120225t1bb58577n195104082e302d98@mail.gmail.com> <19DF289E9F0F5C49A1339A29172F63E70E829989@C1-EXG-VS1.corp.org.local> Message-ID: <8d961d900905121651kc06c498yb7b4af965eeb50@mail.gmail.com> > Of course ? I?m more than happy for anyone to use it. What do you need me to do? Fork my repo Add your code Add a feature (under features/) rake features Update History.txt push send me a pull request Aslak > > > > ________________________________ > > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of aslak hellesoy > Sent: Tuesday, 12 May 2009 7:26 PM > To: rspec-users > Cc: Songkick Developers > Subject: Re: [rspec-users] [cucumber] junit formatter > > > > > > On 12 May 2009, at 05:29, Jones, Gareth wrote: > > Hi, > > I?ve knocked together a JUnit xml output formatter for cucumber ? we?re using it with Hudson and Ant, so it seemed like a good idea. It?s good enough for our purposes, so I thought we should release it into the wild, and see if it is useful for anyone else. > > Details here: http://csausdev.wordpress.com/2009/05/12/junit-formatter-for-cucumber/ > > > > Yay! thankyou. I've had the idea of writing a cucumber mode for ci_reporter[1] bubbling on my todo list since we switched to hudson, and this is going to make that much easier. > > Gareth, would you be interested in donating this to the Cucumber project and have it part of the cucumber gem? > > Aslak > > > [1] http://caldersphere.rubyforge.org/ci_reporter/ > > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > Sensis. Helping you find, buy and sell. > > www.sensis.com.au - www.yellow.com.au - www.whitepages.com.au - www.citysearch.com.au - www.whereis.com.au - www.tradingpost.com.au > > Sensis cares for the environment - think before you print. > > This email and any attachments are intended only for the use of the recipient and may be confidential and/or legally privileged. Sensis Pty Ltd disclaims liability for any errors, omissions, viruses, loss and/or damage arising from using, opening or transmitting this email. If you are not the intended recipient you must not use, interfere with, disclose, copy or retain this email and you should notify the sender immediately by return email or by contacting Sensis Pty Ltd by telephone on [+61 3 8653 5000] > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Tue May 12 21:30:09 2009 From: lists at ruby-forum.com (Sunny Bak) Date: Wed, 13 May 2009 03:30:09 +0200 Subject: [rspec-users] uninitialized constant Spec::VERSION::REV (NameError) In-Reply-To: <57c63afe0905121646r241bab83ybe07f9ac7054f593@mail.gmail.com> References: <15163531c6b8ab88540e346de820a551@ruby-forum.com> <57c63afe0905121646r241bab83ybe07f9ac7054f593@mail.gmail.com> Message-ID: <2df8d000298d33dc8e97ec7e12b9b4b1@ruby-forum.com> David Chelimsky wrote: > On Tue, May 12, 2009 at 6:43 PM, Sunny Bak wrote: >> I am a newbie for rspec. >> I am trying to install and run a "test" test, but i get an error. >> >> .../lib/active_support/dependencies.rb:440:in `load_missing_constant': >> uninitialized constant Spec::VERSION::REV (NameError) >> >> Can someone help me? > > Spec::VERSION::REV does not exist anywhere in rspec, so this is coming > from something other than rspec. What versions of rails, rspec and > ruby are you using? What other plugins and/or libraries? Thank you David, I've attached the whole error messages. The versions are : ruby-oci8 (1.0.4) rspec-rails (1.2.6) rspec (1.2.6) rake (0.8.4) ruby (1.8.7) Thank you for your help! /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant Spec::VERSION::REV (NameError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing' from /home/ror/newdarts/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb:13 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /home/ror/newdarts/vendor/plugins/rspec_on_rails/lib/spec/rails.rb:11 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from ./spec/models/../spec_helper.rb:6 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./spec/models/user_spec.rb:1 from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in `load' from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in `each' from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/options.rb:99:in `run_examples' from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/command_line.rb:9:in `run' from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/bin/spec:4 from /usr/local/bin/spec:19:in `load' from /usr/local/bin/spec:19 -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue May 12 22:27:23 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 12 May 2009 21:27:23 -0500 Subject: [rspec-users] uninitialized constant Spec::VERSION::REV (NameError) In-Reply-To: <2df8d000298d33dc8e97ec7e12b9b4b1@ruby-forum.com> References: <15163531c6b8ab88540e346de820a551@ruby-forum.com> <57c63afe0905121646r241bab83ybe07f9ac7054f593@mail.gmail.com> <2df8d000298d33dc8e97ec7e12b9b4b1@ruby-forum.com> Message-ID: <57c63afe0905121927k1ac97780qb4561c1563cf70c5@mail.gmail.com> On Tue, May 12, 2009 at 8:30 PM, Sunny Bak wrote: > David Chelimsky wrote: >> On Tue, May 12, 2009 at 6:43 PM, Sunny Bak wrote: >>> I am a newbie for rspec. >>> I am trying to install and run a "test" test, but i get an error. >>> >>> .../lib/active_support/dependencies.rb:440:in `load_missing_constant': >>> uninitialized constant Spec::VERSION::REV (NameError) >>> >>> Can someone help me? >> >> Spec::VERSION::REV does not exist anywhere in rspec, so this is coming >> from something other than rspec. What versions of rails, rspec and >> ruby are you using? What other plugins and/or libraries? > > Thank you David, > > I've attached the whole error messages. ?The versions are : > ruby-oci8 (1.0.4) > rspec-rails (1.2.6) > rspec (1.2.6) > rake (0.8.4) > ruby (1.8.7) > Thank you for your help! > > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in > `load_missing_constant': uninitialized constant Spec::VERSION::REV > (NameError) > ? ? ? ?from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in > `const_missing' > ? ? ? ?from > /home/ror/newdarts/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb:13 I think this is the culprit. Looks like you have a VERY old version of rspec-rails (when it was called rspec_on_rails). Are you trying to use rspec[-rails] as plugins or gems? If gems, system or bundled? David > ? ? ? ?from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > ? ? ? ?from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require' > ? ? ? ?from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in > `require' > ? ? ? ?from > /home/ror/newdarts/vendor/plugins/rspec_on_rails/lib/spec/rails.rb:11 > ? ? ? ?from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > ? ? ? ?from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require' > ? ? ? ?from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in > `require' > ? ? ? ?from ./spec/models/../spec_helper.rb:6 > ? ? ? ?from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > ? ? ? ?from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require' > ? ? ? ?from ./spec/models/user_spec.rb:1 > ? ? ? ?from > /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in > `load' > ? ? ? ?from > /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in > `load_files' > ? ? ? ?from > /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in > `each' > ? ? ? ?from > /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > ? ? ? ?from > /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/options.rb:99:in > `run_examples' > ? ? ? ?from > /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/lib/spec/runner/command_line.rb:9:in > `run' > ? ? ? ?from /home/sbak/.gem/ruby/1.8/gems/rspec-1.2.6/bin/spec:4 > ? ? ? ?from /usr/local/bin/spec:19:in `load' > ? ? ? ?from /usr/local/bin/spec:19 > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 13 01:28:00 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 May 2009 00:28:00 -0500 Subject: [rspec-users] Options Hash explanation ? In-Reply-To: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> References: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> Message-ID: <57c63afe0905122228m1ac62d1ei19a630de0e772027@mail.gmail.com> On Tue, May 12, 2009 at 12:14 PM, mortench wrote: > The new rspec beta book and the rspec site mentions that it is > possible to add a hash to "describe" and "it" constructs but very, > very litle information about the particulars. > > What can the options hash be used for and what should it be used for? > > F.x. I have some identical examples that I need to run against a wide > range of different models that have two configuration parameters that > sometimes differ. I am thus thinking of using the has like this in > example groups (tptions which are recoginzed in helpers, macros etc): > > describe XXXX-MODEL, :fixturesRelativeRootDir => > ?testfixtures?, :serviceDescriptorRelativePath => ?services/ > RubyHelloExample.service? > > Does usage of custom options like this make sense rspec-wise ? > > Finally, I did find out myself that I can get the hash from a helper?s > Spec::Runner.configure.config.before(:all) using ?self.class?. > However, this does not work inside nested ?it? constructs. Any advice ? You can access the group and example options from within an example: describe "group options hash", :defined_in => :group do it "is available in examples via self.class.options" do self.class.options[:defined_in].should == :group end end describe "example options hash" do it "is available in examples directly", :defined_in => :example do options[:defined_in].should == :example end end HTH, David From Lee.Longmore at googlemail.com Wed May 13 03:47:49 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Wed, 13 May 2009 00:47:49 -0700 (PDT) Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: References: <961005.1326.qm@web23901.mail.ird.yahoo.com> <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> Message-ID: I found a potential solution from this blog: http://www.rubytutorials.net/2008/02/29/small-rspec-revelations-rjs/ In my spec for the view in which I want to include the AJAX functionality ("new.html.erb_spec.erb"), I have added a couple of Examples to drive out the some of the AJAX functionality: it "should render /Available/ if name does not exist" do @name_exists = false assigns[:name_exists] = @name_exists render "contexts/check.js.rjs" response.should have_rjs(:chained_replace_html, 'checkname') do response.should have_text(/Available/) end end it "should render /Not available/ if name does not exist" do @name_exists = true assigns[:name_exists] = @name_exists render "contexts/check.js.rjs" response.should have_rjs(:chained_replace_html, 'checkname') do response.should have_text(/Not available/) end end The rendered template "check.js.rjs" contains: if @name_exists page['checkname'].update('Not available') else page['checkname'].update('Available') end These examples pass and seem to achieve my objective of using the spec to drive out the required AJAX behaviour, or at least some of it. Though I suspect that this approach may have limitations for other types of AJAX functionality. At this stage, I am wondering whether it is worth trying to drive out any AJAX functionality at the point of writing RSpec view specs. Some replies seem to suggest the use of Cucumber with Culerity/Webrat/ Selenium and I read into this that one would bypass view specs for the AJAX related steps and just write the necessary view code (e.g. JavaScript or Rails Prototype helpers) to get the step to pass. Further thoughts appreciated. Thanks Lee. On 12 May, 18:47, Phlip wrote: > David Chelimsky wrote: > > You could just say "be careful not to mock too much," which would be > > really good advice, > > Sorry; I thought I said that. This industry in general dislikes strong opinions... > > Mock on, everyone! > > ?> but instead you make a generalizing and judgmental > > > statement like this. When's the last time you paired with someone in > > the RSpec community? > > Well it's not for want of trying! > > -- > ? ?Phlip > ? ?http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From matt.songkick at googlemail.com Wed May 13 03:42:57 2009 From: matt.songkick at googlemail.com (Matt Wynne) Date: Wed, 13 May 2009 08:42:57 +0100 Subject: [rspec-users] Rails HTML error page in the console. Message-ID: <255D8CD4-9AB0-4CBB-94DD-40CEAA61E870@songkick.com> I'm still bugged by the fact that when I get an exception during a feature run (e.g. Couldn't find partial) then what I see in the console is all the HTML to report that error in a browser. I have had a few ideas for this bubbling around at the back of my mind. I wondered whether anyone else was thinking about this too. I guess the idea would be to patch rails's ActionController#rescue_action_locally with something that threw the exception out at Cucumber rather than bubbling it up to the web. What do you think? Would it work? What are the drawbacks I haven't thought of? cheers, Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From jds340 at gmail.com Wed May 13 03:53:24 2009 From: jds340 at gmail.com (JDS) Date: Wed, 13 May 2009 00:53:24 -0700 (PDT) Subject: [rspec-users] Can't use Cucumber with Webrat and Selenium In-Reply-To: References: Message-ID: <20c51567-6c06-48bd-a8e9-07c8cb0defbe@j12g2000vbl.googlegroups.com> Well I can't help you but I do have a similar problem. In my case Cucumber-Selenium works, Cucumber-Webrat works but Cucmber-Webrat- Selenium doesn't work because Webrat issues requests to www.example.com and Selenium starts up a mongrel on localhost:3001, connects to it via Firefox and then throws up when it gets a request to go to www.example.com. I need to find a way to change the host name that Webrat uses when it connects via Selenium. On 5 Apr, 15:23, Enrico Listemann wrote: > Hi, > > I followed the instructions athttp://wiki.github.com/aslakhellesoy/cucumber/setting-up-seleniumto getSeleniumandWebratto work with Cucumber. I have no problems usingWebratbut when I switch to useSelenium, I get the following error > message when I try to access the browser(e.g. calling visit(login_path)) > in a step definition. > > Die angeforderte Adresse ist in diesem Kontext ung?ltig. - connect(2) > (Errno::EADDRNOTAVAIL) > E:/SOFTWAREENTWICKLUNG/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout' > (eval):2:in `visit' > > (for those who don't speak german: The requested address is invalid in > this context.) > > I also tried to use Cucumber andSeleniumwithoutWebratand it works > without any problems. > > I'm using Rails 2.3.0, Cucumber 0.2.3,Webrat0.4.3 and RSpec 1.2.2 on a > WinXP machine. > > I would be very pleased if anyone had an idea about the reason for this > failure. > > Enrico > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed May 13 10:07:54 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 13 May 2009 16:07:54 +0200 Subject: [rspec-users] Cucumber Tables Message-ID: <4fd7adf1f4f63e662ecd02dcbbc8a176@ruby-forum.com> I am running into this situation: Feature 1 Scenario A ... Then we should have currency exchange rates for "USD" on file And we should ... Feature 2 Scenario D ... Then we should have currency exchange rates for "USD" on file | code| |"EUR"| |"JPY"| |"KRW"| |"MXN"| And we should not ... This arrangement presently gives a cucumber error because the step definition that matches will either have one argument too many or one too few. However, from a user point of view it strikes me that this situation should not be an error at all. My reasoning is this. The features statement as given is completely logical, straight-forward and applicable in either situation. Having a requirement to create separate invocations for exactly the same test, depending only upon whether one wishes to do it once or several times, strikes me as bending the situation to the limitations of the implementation rather than elaborating the implementation to handle the situation. On the other hand, as this may be quite involved to solve I am not saying what I suggest MUST be the behavior, only that it seems to me that it should be. I seem to recall that when I first used cucumber in December last, that one could either provide additional examples to a matcher in a scenario or not. In either case the matcher would work. I think that this behaviour, if at all possible, might be more natural than requiring two separate matchers that exist only to match to different patterns. What do you all think? -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Wed May 13 11:05:07 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 13 May 2009 17:05:07 +0200 Subject: [rspec-users] Cucumber Tables In-Reply-To: <4fd7adf1f4f63e662ecd02dcbbc8a176@ruby-forum.com> References: <4fd7adf1f4f63e662ecd02dcbbc8a176@ruby-forum.com> Message-ID: <8d961d900905130805w3294853fg90b9b460bccf22e1@mail.gmail.com> > I am running into this situation: > > Feature 1 > > ?Scenario A > ? ?... > ? ?Then we should have currency exchange rates for "USD" on file > ? ? ?And we should ... > > > Feature 2 > > ?Scenario D > ? ?... > ? ?Then we should have currency exchange rates for "USD" on file > ? ? ? ?| code| > ? ? ? ?|"EUR"| > ? ? ? ?|"JPY"| > ? ? ? ?|"KRW"| > ? ? ? ?|"MXN"| > ? ? ?And we should not ... > > This arrangement presently gives a cucumber error because the step > definition that matches will either have one argument too many or one > too few. ?However, from a user point of view it strikes me that this > situation should not be an error at all. > > My reasoning is this. ?The features statement as given is completely > logical, straight-forward and applicable in either situation. A common way to express step definitions that take multiline arguments is to explicitly refer to the multiline argument in the step text. For example: Then I should have the following shoes: |size|model| |43 |Adidas Oslo| |41 |Nike Racer| If you don't do this, the multiline argument is "dangling". Steps that take multiline arguments should be formulated in such a way that removing the multiline argument makes the sentence nonsensical. This is not the case for your example. Remove the table and the sentence still makes sense. That's very confusing. In fact, sticking a table onto that sentence makes no sense at all to me. I have to guess how that table is related to the sentence above it. Be explicit, and you'll save yourself a lot of headache. In your case I would do this: Then we should have currency exchange rates for "USD" on file Then we should have currency exchange rates for "USD" on file with the following codes: | code| |"EUR"| |"JPY"| |"KRW"| |"MXN"| Aslak > Having a > requirement to create separate invocations for exactly the same test, > depending only upon whether one wishes to do it once or several times, > strikes me as bending the situation to the limitations of the > implementation rather than elaborating the implementation to handle the > situation. > > On the other hand, as this may be quite involved to solve I am not > saying what I suggest MUST be the behavior, only that it seems to me > that it should be. > > I seem to recall that when I first used cucumber in December last, that > one could either provide additional examples to a matcher in a scenario > or not. ?In either case the matcher would work. ?I think that this > behaviour, if at all possible, might be more natural than requiring two > separate matchers that exist only to match to different patterns. > > What do you all think? > -- > 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 Wed May 13 11:13:42 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 13 May 2009 09:13:42 -0600 Subject: [rspec-users] Rails HTML error page in the console. In-Reply-To: <255D8CD4-9AB0-4CBB-94DD-40CEAA61E870@songkick.com> References: <255D8CD4-9AB0-4CBB-94DD-40CEAA61E870@songkick.com> Message-ID: <4A0AE3A6.3040500@benmabey.com> Matt Wynne wrote: > I'm still bugged by the fact that when I get an exception during a > feature run (e.g. Couldn't find partial) then what I see in the > console is all the HTML to report that error in a browser. > > I have had a few ideas for this bubbling around at the back of my > mind. I wondered whether anyone else was thinking about this too. > > I guess the idea would be to patch rails's > ActionController#rescue_action_locally with something that threw the > exception out at Cucumber rather than bubbling it up to the web. What > do you think? Would it work? What are the drawbacks I haven't thought of? > > cheers, > Matt Wynne > http://beta.songkick.com > http://blog.mattwynne.net Have you tried catching the error in an After block and opening up the page? Aslak added that functionality: https://rspec.lighthouseapp.com/projects/16211/tickets/272-pick-up-failure-on-after-hook -Ben From Jarmo.P at gmail.com Wed May 13 12:02:09 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Wed, 13 May 2009 09:02:09 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <57c63afe0905112021y2c93b2e4p856d13b614392037@mail.gmail.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> <83813a0a-37e9-40f3-ada7-6b39efb74a08@q2g2000vbr.googlegroups.com> <57c63afe0905112021y2c93b2e4p856d13b614392037@mail.gmail.com> Message-ID: <41aa9363-88f9-410a-8301-fc78ca07ea4b@r3g2000vbp.googlegroups.com> On May 12, 6:21?am, David Chelimsky wrote: > > I don't want to promote using self as subject. I think being able to > do so explicitly, as we can now with your previous patch, is perfectly > reasonable. But doing so is a bit of a trick in my view, and runs > counter to the overall intent of the structure of examples of > behaviour of an object or sub-system. "should" is about that object or > sub-system, not self. I'm also thinking that maybe I'm doing something wrong when using this approach, but cannot think of any better way. Do you have any suggestions how to get rid of using self as a subject in my context? Maybe i'm not aware of some best practices when it comes to using helper methods. Should I monkey-patch Watir (or some other library) to add methods to it like has_text? and so on in which case subject would be $browser (which is actually correct)? > > If your whole suite is using this, you can localize the "subject > {self}" call, however, in spec_helper, like this: > > class Spec::ExampleGroup > ? subject {self} > end Thank you for this great tip! I think that this solution will satisfy me. > > HTH, > David Jarmo From dchelimsky at gmail.com Wed May 13 12:08:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 May 2009 11:08:10 -0500 Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <41aa9363-88f9-410a-8301-fc78ca07ea4b@r3g2000vbp.googlegroups.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> <83813a0a-37e9-40f3-ada7-6b39efb74a08@q2g2000vbr.googlegroups.com> <57c63afe0905112021y2c93b2e4p856d13b614392037@mail.gmail.com> <41aa9363-88f9-410a-8301-fc78ca07ea4b@r3g2000vbp.googlegroups.com> Message-ID: <57c63afe0905130908v7d8db7dfmf6ce72623a94770e@mail.gmail.com> On Wed, May 13, 2009 at 11:02 AM, Jarmo Pertman wrote: > On May 12, 6:21?am, David Chelimsky wrote: >> >> I don't want to promote using self as subject. I think being able to >> do so explicitly, as we can now with your previous patch, is perfectly >> reasonable. But doing so is a bit of a trick in my view, and runs >> counter to the overall intent of the structure of examples of >> behaviour of an object or sub-system. "should" is about that object or >> sub-system, not self. > I'm also thinking that maybe I'm doing something wrong when using this > approach, but cannot think of any better way. Do you have any > suggestions how to get rid of using self as a subject in my context? > Maybe i'm not aware of some best practices when it comes to using > helper methods. Should I monkey-patch Watir (or some other library) to > add methods to it like has_text? and so on in which case subject would > be $browser (which is actually correct)? I actually think that what you're doing is perfectly fine. Just not the common case. That's why I think it's OK to support explicitly assigning self as subject, but not making that a default behaviour. If it were me, and it's *not*, but if it were, I'd wrap those helpers in an object and make explicit calls. >> If your whole suite is using this, you can localize the "subject >> {self}" call, however, in spec_helper, like this: >> >> class Spec::ExampleGroup >> ? subject {self} >> end > Thank you for this great tip! I think that this solution will satisfy > me. > > >> >> HTH, >> David > > Jarmo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 13 12:08:33 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 May 2009 11:08:33 -0500 Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <41aa9363-88f9-410a-8301-fc78ca07ea4b@r3g2000vbp.googlegroups.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> <83813a0a-37e9-40f3-ada7-6b39efb74a08@q2g2000vbr.googlegroups.com> <57c63afe0905112021y2c93b2e4p856d13b614392037@mail.gmail.com> <41aa9363-88f9-410a-8301-fc78ca07ea4b@r3g2000vbp.googlegroups.com> Message-ID: <57c63afe0905130908n6bcaf52eh9a50b15273fbeb8d@mail.gmail.com> On Wed, May 13, 2009 at 11:02 AM, Jarmo Pertman wrote: > On May 12, 6:21?am, David Chelimsky wrote: >> >> I don't want to promote using self as subject. I think being able to >> do so explicitly, as we can now with your previous patch, is perfectly >> reasonable. But doing so is a bit of a trick in my view, and runs >> counter to the overall intent of the structure of examples of >> behaviour of an object or sub-system. "should" is about that object or >> sub-system, not self. > I'm also thinking that maybe I'm doing something wrong when using this > approach, but cannot think of any better way. Do you have any > suggestions how to get rid of using self as a subject in my context? > Maybe i'm not aware of some best practices when it comes to using > helper methods. Should I monkey-patch Watir (or some other library) to > add methods to it like has_text? and so on in which case subject would > be $browser (which is actually correct)? > > >> >> If your whole suite is using this, you can localize the "subject >> {self}" call, however, in spec_helper, like this: >> >> class Spec::ExampleGroup >> ? subject {self} >> end > Thank you for this great tip! I think that this solution will satisfy > me. Great! Cheers, David > > >> >> HTH, >> David > > Jarmo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From Jarmo.P at gmail.com Wed May 13 13:11:39 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Wed, 13 May 2009 10:11:39 -0700 (PDT) Subject: [rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use In-Reply-To: <57c63afe0905130908v7d8db7dfmf6ce72623a94770e@mail.gmail.com> References: <13c74108-e40e-4784-a618-46ed608562ea@21g2000vbk.googlegroups.com> <27ecace1-2e3b-442d-8a9e-0784b6bdda1b@e23g2000vbe.googlegroups.com> <57c63afe0905071402u4419a965h740604f0fb31b610@mail.gmail.com> <78758737-90b8-45c1-b353-ef343f2cce7f@o27g2000vbd.googlegroups.com> <57c63afe0905080050q3ba57ee3h1fb23d3c6e561a62@mail.gmail.com> <775b381b-e964-4944-8617-290d06f8e249@r34g2000vba.googlegroups.com> <83813a0a-37e9-40f3-ada7-6b39efb74a08@q2g2000vbr.googlegroups.com> <57c63afe0905112021y2c93b2e4p856d13b614392037@mail.gmail.com> <41aa9363-88f9-410a-8301-fc78ca07ea4b@r3g2000vbp.googlegroups.com> <57c63afe0905130908v7d8db7dfmf6ce72623a94770e@mail.gmail.com> Message-ID: <4027b084-f127-41f9-8941-31b5149b9f84@q2g2000vbr.googlegroups.com> On May 13, 7:08?pm, David Chelimsky wrote: > > I actually think that what you're doing is perfectly fine. Just not > the common case. That's why I think it's OK to support explicitly > assigning self as subject, but not making that a default behaviour. > > If it were me, and it's *not*, but if it were, I'd wrap those helpers > in an object and make explicit calls. you mean something like this? class PageHelper def has_text? # blah end end describe "cool page" do subject {PageHelper.new} before :all do PageHelper.new end it "has something" do should have_text("blah") end end Doesn't seem too bad. I will give it a thought! Jarmo From cwdinfo at gmail.com Wed May 13 14:22:57 2009 From: cwdinfo at gmail.com (s.ross) Date: Wed, 13 May 2009 11:22:57 -0700 Subject: [rspec-users] How To Drive Out AJAX Functionality in a Rails View In-Reply-To: References: <961005.1326.qm@web23901.mail.ird.yahoo.com> <57c63afe0905120707o4d8ab008sa17a4212b7d306e9@mail.gmail.com> Message-ID: <70C277AA-AEE0-4266-8582-9A50BC7E279B@gmail.com> Hi-- On May 13, 2009, at 12:47 AM, Lee wrote: > I found a potential solution from this blog: > http://www.rubytutorials.net/2008/02/29/small-rspec-revelations-rjs/ > > In my spec for the view in which I want to include the AJAX > functionality ("new.html.erb_spec.erb"), I have added a couple of > Examples to drive out the some of the AJAX functionality: > The one thing I would add is that Rails responds differently when it receives a post with XMLHttpHeaders than when these headers are not present. I typically put this in my spec_helper.rb and then I can include it where necessary. # spec_helper.rb module XmlHttpHelper def set_xhr_headers request.env['HTTP_ACCEPT'] = 'application/json, text/javascript, */ *' request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' end end # things_controller_spec.rb describe ThingssController do include XmlHttpHelper it "should provide a not acceptable response if user is not appropriately related and it's an xhr" do login_as(@unrelated_child.login, 'secret') set_xhr_headers post :slug_collection, :name => 'bob', :collection_name => 'my-things' response.status.should eql('406 Not Acceptable') end end Just a thought... From mortench at gmail.com Wed May 13 15:36:02 2009 From: mortench at gmail.com (mortench) Date: Wed, 13 May 2009 12:36:02 -0700 (PDT) Subject: [rspec-users] Options Hash explanation ? In-Reply-To: <57c63afe0905122228m1ac62d1ei19a630de0e772027@mail.gmail.com> References: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> <57c63afe0905122228m1ac62d1ei19a630de0e772027@mail.gmail.com> Message-ID: <41285f3b-e1d0-4330-bb7c-287e86b0fdb0@t10g2000vbg.googlegroups.com> On 13 Maj, 07:28, David Chelimsky wrote: > You can access the group and example options from within an example: > > describe "group options hash", :defined_in => :group do > ? it "is available in examples via self.class.options" do > ? ? self.class.options[:defined_in].should == :group > ? end > end Yes, I got this to work too but not for nested describes as below: describe "group options hash", :defined_in => :group do .. describe "nested describe wont work" it "is available in examples via self.class.options" do self.class.options[:defined_in].should == :group # WONT work end end end BTW. I am actually accessing the hash from within a common helper files in a before action setup by Spec::Runner.configure. Hence it is important that accessing the Hash work regardless of how the describes are nested. From mortench at gmail.com Wed May 13 15:44:12 2009 From: mortench at gmail.com (mortench) Date: Wed, 13 May 2009 12:44:12 -0700 (PDT) Subject: [rspec-users] Options Hash explanation ? In-Reply-To: <4A0A02E2.9010304@yahoo.com> References: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> <4A0A02E2.9010304@yahoo.com> Message-ID: <4afed803-5ca8-48a2-a1a1-3024a51aac4e@o20g2000vbh.googlegroups.com> On 13 Maj, 01:14, Randy Harmon wrote: > mortench wrote: > > The new rspec beta book and the rspec site mentions that it is > > possible to add a hash to "describe" and "it" constructs but very, > > very litle information about the particulars. > > > What can the options hash be used for and what should it be used for? > > This might be used for tagging examples, marking examples for use with > formatters, or other purposes probably not bearing on spec execution. "not bearing on spec execution". I.e. for meta-data only. Any official word on thos? > I'm not saying they could or couldn't be used the way you're suggesting, > but there are other possibilities you should try first IMO. Ok. Thanks for the advice. > I have used a callback for this, but I understand that rspec 1.2 has > macros that can take args the way your shared example can't. ? I haven't > dug into them. Ok. will look into that. > Here's the callback approach demonstrated. > > describe "shared", :shared => true > ? it "..." do > ? ? options = shared_options() > ? ? ... > ? end > end > > describe "thingy" > ? it_should_behave_like "shared" > ? def shared_options > ? ? { :foo => 'bar', :baz => 'buz } > ? end > end Thanks for the suggestion. I can see how it world work, but for this particular problem I have (where 3parties would need to reuse my tests), I would like something that not only works but is also simple and elegant.... And the above is a bit verbose I think compared to just describe "thingy", :foo => 'bar', :baz => 'buz ... end From lists at ruby-forum.com Wed May 13 16:42:31 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Wed, 13 May 2009 22:42:31 +0200 Subject: [rspec-users] Unable to post to an update action in a controller spec Message-ID: <21c3a7541a88ce7a2bed574cf193caf0@ruby-forum.com> Hi, I use restful routes. In one of my views I have a form that looks like: <%- form_tag '/items/update', :method => :put do -%> ... <%= submit_tag "Recalculate" %> <%- end -%> I know I cheated a bit, as I should be submitting to /items/1 instead. Anyway, now how can I trigger the update action in my controller test? I tried stuff like: post :update, {:method => 'put', :item => {'1' => {:quantity => 5}}} But the route recognition isn't pleased, I guess it's missing an :id. Is it possible to test the way I coded it? PS: please no comment about writing code before testing, I know it's a bad habit, and I am doing my best to change it. -- Posted via http://www.ruby-forum.com/. From bj at aboutus.org Wed May 13 16:48:31 2009 From: bj at aboutus.org (BJ Clark) Date: Wed, 13 May 2009 13:48:31 -0700 Subject: [rspec-users] Unable to post to an update action in a controller spec In-Reply-To: <21c3a7541a88ce7a2bed574cf193caf0@ruby-forum.com> References: <21c3a7541a88ce7a2bed574cf193caf0@ruby-forum.com> Message-ID: <58AD9417-0A8C-4553-A649-92620144237E@aboutus.org> On May 13, 2009, at 1:42 PM, Fernando Perez wrote: > Hi, > > I use restful routes. In one of my views I have a form that looks > like: > > <%- form_tag '/items/update', :method => :put do -%> > ... > <%= submit_tag "Recalculate" %> > <%- end -%> > > I know I cheated a bit, as I should be submitting to /items/1 instead. > Anyway, now how can I trigger the update action in my controller test? > > I tried stuff like: > post :update, {:method => 'put', :item => {'1' => {:quantity => 5}}} put :update, :item => 1 etc. There are 4 methods for the 4 HTTP types. get, post, put, delete. ----- BJ Clark > > But the route recognition isn't pleased, I guess it's missing > an :id. Is > it possible to test the way I coded it? > > > PS: please no comment about writing code before testing, I know it's a > bad habit, and I am doing my best to change it. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From andresmax at gmail.com Wed May 13 18:32:41 2009 From: andresmax at gmail.com (anmaxp) Date: Wed, 13 May 2009 15:32:41 -0700 (PDT) Subject: [rspec-users] How to test update_attribute with mocha? Message-ID: <8a81395a-0286-4ce5-bdcb-3ec52faba993@r13g2000vbr.googlegroups.com> Hey everyone, I'm having sort of an issue here, I'm trying to test the update of the last_login field upon login, here is my test it "assigns a new last_login timestamp" do User.expects(:update_attribute).at_least_once.returns(true) post :create, :email => 'bob at example.com', :password => 'test' end sessions_controller: def create self.current_user = current_account.users.authenticatex(params [:email], params[:password], current_account) if logged_in? Time.zone = current_user.timezone I18n.locale = current_user.language login_flash(current_user) current_user.login_updates(current_account.id) redirect_back_or_default(default_path) else flash.now[:error] = t('flash.notice.invalidcredentials') render :action => 'new' end end and the login updates_method on the user model: def login_updates(account) self.update_attribute(:last_login, Time.zone.now) end no matter what variation of expects(:update), expects (:update_attribute) I always get the same failed test: #.update_attribute(any_parameters) - expected calls: at least 1, actual calls: 0 From lists at ruby-forum.com Wed May 13 22:59:44 2009 From: lists at ruby-forum.com (Matthew Isleb) Date: Thu, 14 May 2009 04:59:44 +0200 Subject: [rspec-users] rake spec loads development environment In-Reply-To: References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> Message-ID: I know this thread is long dead, but I'm finding that I have the same problem. 'rake spec:modles' loads the development environment and clobbers my development database. I have to run set RAILS_ENV=test in order for the tests to run correctly. Commenting out that rake task line does not solve the problem. WHat's going on? Do I really have to remember to always set the environment to test? Shouldn't that be the default? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed May 13 23:15:20 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 May 2009 22:15:20 -0500 Subject: [rspec-users] rake spec loads development environment In-Reply-To: References: <1c51d85b1455b71e6461316a77073874@ruby-forum.com> <1F25F8BD-8DF1-4713-90A3-36A7677CD256@parkerhill.com> <1DF992C3-CC79-485A-9D56-4DCD70F77CBB@parkerhill.com> Message-ID: <57c63afe0905132015s17b9b8by91b95b29ad6dff78@mail.gmail.com> On Wed, May 13, 2009 at 9:59 PM, Matthew Isleb wrote: > I know this thread is long dead, but I'm finding that I have the same > problem. 'rake spec:modles' loads the development environment and > clobbers my development database. I have to run set RAILS_ENV=test in > order for the tests to run correctly. > > Commenting out that rake task line does not solve the problem. What rake task line in what file? > WHat's > going on? Do I really have to remember to always set the environment to > test? Shouldn't that be the default? > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Thu May 14 00:01:41 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 13 May 2009 21:01:41 -0700 Subject: [rspec-users] How to test update_attribute with mocha? In-Reply-To: <8a81395a-0286-4ce5-bdcb-3ec52faba993@r13g2000vbr.googlegroups.com> References: <8a81395a-0286-4ce5-bdcb-3ec52faba993@r13g2000vbr.googlegroups.com> Message-ID: anmaxp wrote: > I'm having sort of an issue here, I'm trying to test the update of the > last_login field upon login, here is my test > > it "assigns a new last_login timestamp" do > User.expects(:update_attribute).at_least_once.returns(true) User.any_instance.expects(:update_attribute).with(:field, value).etc. An instance of User will itself call the .update_attribute. The class won't call it. However, I can't think of a reason not to just write the record, reload it, and check the fields. And a _functional_ test should not care how the record got written (update_attribute, save, or whatever). A unit test might care, but functional tests need a little more float... -- Phlip http://flea.sourceforge.net/resume.html From matt at mattwynne.net Thu May 14 02:53:33 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 14 May 2009 07:53:33 +0100 Subject: [rspec-users] How to test update_attribute with mocha? In-Reply-To: References: <8a81395a-0286-4ce5-bdcb-3ec52faba993@r13g2000vbr.googlegroups.com> Message-ID: <44C6719C-5FC7-4101-8333-85EB975B1F31@mattwynne.net> On 14 May 2009, at 05:01, Phlip wrote: > anmaxp wrote: > >> I'm having sort of an issue here, I'm trying to test the update of >> the >> last_login field upon login, here is my test >> it "assigns a new last_login timestamp" do >> User.expects(:update_attribute).at_least_once.returns(true) > > User.any_instance.expects(:update_attribute).with(:field, value).etc. > > An instance of User will itself call the .update_attribute. The > class won't call it. > > However, I can't think of a reason not to just write the record, > reload it, and check the fields. And a _functional_ test should not > care how the record got written (update_attribute, save, or > whatever). A unit test might care, but functional tests need a > little more float... I've got a reason. You're coupling the tests for this simple little controller class to all the infrastructure and dependencies needed to write the record to the database and reload it again. As easy as Rails makes it for us to manage our database schemas, gratuitously introducing dependencies in your code like this is a bad habit to get into. It can lead to tests that are fragile to failing when code is changed far away from the place they're apparently testing. The tests also run slowly, which makes working on systems written like this boring. I would argue that a true 'functional test'[1] would not even care that there is a controller class, and would be exercising the system via the user interface. [1]http://c2.com/cgi/wiki?FunctionalTest Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From lists at ruby-forum.com Thu May 14 06:23:34 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 14 May 2009 12:23:34 +0200 Subject: [rspec-users] Unable to post to an update action in a controller spec In-Reply-To: <58AD9417-0A8C-4553-A649-92620144237E@aboutus.org> References: <21c3a7541a88ce7a2bed574cf193caf0@ruby-forum.com> <58AD9417-0A8C-4553-A649-92620144237E@aboutus.org> Message-ID: <1c8f0778aa93111f16caecff5899bbe6@ruby-forum.com> > put :update, :item => 1 etc. > I tried that but didn't work. I managed to get it working by simply doing: post :update, {:id => 'dummy', :item => {'1' => ...}} For some reason, I previously tried with :id => 'update' but Rails didn't like it. -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Thu May 14 09:20:54 2009 From: phlip2005 at gmail.com (Phlip) Date: Thu, 14 May 2009 06:20:54 -0700 Subject: [rspec-users] How to test update_attribute with mocha? In-Reply-To: <44C6719C-5FC7-4101-8333-85EB975B1F31@mattwynne.net> References: <8a81395a-0286-4ce5-bdcb-3ec52faba993@r13g2000vbr.googlegroups.com> <44C6719C-5FC7-4101-8333-85EB975B1F31@mattwynne.net> Message-ID: Matt Wynne wrote: > I've got a reason. You're coupling the tests for this simple little > controller class to all the infrastructure and dependencies needed to > write the record to the database and reload it again. As easy as Rails > makes it for us to manage our database schemas, gratuitously introducing > dependencies in your code like this is a bad habit to get into. It can > lead to tests that are fragile to failing when code is changed far away > from the place they're apparently testing. The tests also run slowly, > which makes working on systems written like this boring. The point of unit tests (which include the alleged "functional tests" in Rails) is to fail more often than production code would fail. Not less often. -- Phlip http://flea.sourceforge.net/resume.html From hugo.barauna at gmail.com Thu May 14 08:51:50 2009 From: hugo.barauna at gmail.com (Hugo Barauna) Date: Thu, 14 May 2009 05:51:50 -0700 (PDT) Subject: [rspec-users] [Rspec] Problems with autospec Message-ID: Hi guys, I am having a problem with autospec. I upgraded to rspec-1.2.6, then I tried to run my specs with autospec. All my specs passes (green), until here, that's all ok. The problem is that after all my specs have passed, the autospec stops, I mean, it doesn't continue to run on background. The same behavior happened if one of my specs fails too. Is this the current default behavior os autospec, running your tests, an then stop? From dchelimsky at gmail.com Thu May 14 09:52:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 May 2009 08:52:09 -0500 Subject: [rspec-users] [Rspec] Problems with autospec In-Reply-To: References: Message-ID: <57c63afe0905140652k7d56e423g7b4fc12b26aa167b@mail.gmail.com> On Thu, May 14, 2009 at 7:51 AM, Hugo Barauna wrote: > Hi guys, I am having a problem with autospec. I upgraded to > rspec-1.2.6, then I tried to run my specs with autospec. All my specs > passes (green), until here, that's all ok. The problem is that after > all my specs have passed, the autospec stops, I mean, ?it doesn't > continue to run on background. The same behavior happened if one of my > specs fails too. Is this in a rails app? From aslak.hellesoy at gmail.com Thu May 14 10:48:29 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 14 May 2009 16:48:29 +0200 Subject: [rspec-users] [Cucumber] ANN: Cucumber 0.3.4 Message-ID: <8d961d900905140748nb2fa631mbf71c2efb2538d81@mail.gmail.com> http://github.com/aslakhellesoy/cucumber/blob/173506c4013a7d733c5b4924e7af3dcc49db2218/History.txt Enjoy! From julian at leviston.net Thu May 14 11:04:59 2009 From: julian at leviston.net (Julian Leviston) Date: Fri, 15 May 2009 01:04:59 +1000 Subject: [rspec-users] [Cucumber] ANN: Cucumber 0.3.4 In-Reply-To: <8d961d900905140748nb2fa631mbf71c2efb2538d81@mail.gmail.com> References: <8d961d900905140748nb2fa631mbf71c2efb2538d81@mail.gmail.com> Message-ID: On 15/05/2009, at 12:48 AM, aslak hellesoy wrote: > http://github.com/aslakhellesoy/cucumber/blob/173506c4013a7d733c5b4924e7af3dcc49db2218/History.txt > > Enjoy! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Wicked :) Julian. ---------------------------------------------- Blog: http://random8.zenunit.com/ Learn: http://sensei.zenunit.com/ Twitter: http://twitter.com/random8r From akueken at googlemail.com Thu May 14 11:03:07 2009 From: akueken at googlemail.com (A. Kueken) Date: Thu, 14 May 2009 08:03:07 -0700 (PDT) Subject: [rspec-users] Problem with RSpec and Cucumber Message-ID: Hello everybody, I have a problem get cucumber running properly. Runnink jruby -S rake features ends with: /Users/alexander/lib/jruby/bin/jruby -I "/Users/alexander/lib/ jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/cucumber-0.3.3/lib:lib" "/Users/ alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/cucumber-0.3.3/bin/ cucumber" --format pretty --langauge de --require features/ step_definitions/clients_steps.rb --require features/step_definitions/ webrat_steps.rb --require features/support/env.rb --require features/ support/paths.rb features/manage_clients.feature rake aborted! Command failed with status (1): [/Users/alexander/lib/jruby/bin/jruby - I "/...] (See full trace by running task with --trace) jruby -S cucumber features does not work either: JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL /Users/alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/ activesupport-2.3.2/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant Spec::Expectations::Differs::Default (NameError) from /Users/alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/ activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing_with_dependencies' from /Users/alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/ cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:101:in `enable_diffing' from /Users/alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/ cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:35:in `execute!' from /Users/alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/ cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:20:in `execute' from /Users/alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/ cucumber-0.3.3/bin/cucumber:6 from /Users/alexander/lib/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/ cucumber-0.3.3/bin/cucumber:19:in `load' from /Users/alexander/lib/jruby/bin/cucumber:19 I am using JRuby 1.3RC1 but with 1.2 there is the same problem. Following gems are installed: actionmailer (2.3.2) actionpack (2.3.2) activerecord (2.3.2) activerecord-jdbc-adapter (0.9.1) activerecord-jdbcmysql-adapter (0.9.1) activeresource (2.3.2) activesupport (2.3.2) builder (2.1.2) ci_reporter (1.6.0) cucumber (0.3.3) diff-lcs (1.1.2) faker (0.3.1) gem_plugin (0.2.3) hpricot (0.6.164) jdbc-mysql (5.0.4) mongrel (1.1.5) nokogiri (1.2.3) polyglot (0.2.5) rack (1.0.0) rails (2.3.2) rake (0.8.4) rspec (1.2.6) rspec-rails (1.2.6) rubyist-aasm (2.0.5) sources (0.0.1) term-ansicolor (1.0.3) thoughtbot-factory_girl (1.2.1) treetop (1.2.5) webrat (0.4.4) The application is a Rails 2.3 application ported from 2.2 Any ideas? From lists at ruby-forum.com Thu May 14 16:40:30 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 14 May 2009 22:40:30 +0200 Subject: [rspec-users] Cucumber Tables In-Reply-To: <8d961d900905130805w3294853fg90b9b460bccf22e1@mail.gmail.com> References: <4fd7adf1f4f63e662ecd02dcbbc8a176@ruby-forum.com> <8d961d900905130805w3294853fg90b9b460bccf22e1@mail.gmail.com> Message-ID: <6dcb00976664e073a0da4ac5e8345de8@ruby-forum.com> Aslak Helles?y wrote: > > If you don't do this, the multiline argument is "dangling". Steps that > take multiline arguments should be formulated in such a way that > removing the multiline argument makes the sentence nonsensical. Yes, I understood that. And I also realized that the solution is to have two separately phrased matcher clauses. However, this approach does strike me as incongruous with cucumber's philosophy of reading naturally. Consider this situation. Iteration 1 to 5 Then we should have currency exchange rates for "USD" on file Iteration 6 Then we should have currency exchange rates for "USD" on file with the following codes | code| |"EUR"| |"JPY"| Now, besides begin awkwardly worded, "rates for "USD" on file with the following codes" (which admittedly could be repaired with some thought), this requires that an additional matcher be provided in the step definition file. Further, the similarity of phrasing is an invitation to a matcher collision. I rather suspect that in these cases this is what will end up in the feature files on most occasions: Then we should have currency exchange rates for "USD" on file Then we should have currency exchange rates for "EUR" on file Then we should have currency exchange rates for "JPY" on file This requires far less work as the matcher already exists and one need only replace six characters after a couple of cut and pastes. Presently, the table method works best, I think, when it is employed from the outset. However, when things are elaborated after the initial matchers are written then it seems more work than it is worth to duplicate existing matchers just to cut down somewhat on boilerplate in the feature files. If, instead, one could just add a table under an existing step matcher then this would be more in keeping with what cucumber does so well elsewhere, extend features and scenarios naturally and effortlessly. Then we should have currency exchange rates for "USD" on file | code| |"EUR"| |"JPY"| This is more user friendly because it creates far less of an intellectual load (having to devise a new wording for an existing phrase and implementing same as a special case) than simply extending the existing structure. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu May 14 20:19:20 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 14 May 2009 20:19:20 -0400 Subject: [rspec-users] Unable to post to an update action in a controller spec In-Reply-To: <1c8f0778aa93111f16caecff5899bbe6@ruby-forum.com> References: <21c3a7541a88ce7a2bed574cf193caf0@ruby-forum.com> <58AD9417-0A8C-4553-A649-92620144237E@aboutus.org> <1c8f0778aa93111f16caecff5899bbe6@ruby-forum.com> Message-ID: <85d99afe0905141719k7c93f6dre42838a4f5c4ea78@mail.gmail.com> On Thu, May 14, 2009 at 6:23 AM, Fernando Perez wrote: >> put :update, :item => 1 etc. >> > I tried that but didn't work. I managed to get it working by simply > doing: > > post :update, {:id => 'dummy', :item => {'1' => ...}} > > For some reason, I previously tried with :id => 'update' but Rails > didn't like it. I don't get the impression you're very familiar with RESTful routing in Rails. You may want to look read about it in the Agile Web Development w/Rails book and/or Rails guides: http://guides.rubyonrails.org/routing.html#restful-routing-the-rails-default It should give you a better overview of when/where to use ids, puts, posts, etc. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From matt at mattwynne.net Fri May 15 01:52:23 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 15 May 2009 06:52:23 +0100 Subject: [rspec-users] How to test update_attribute with mocha? In-Reply-To: References: <8a81395a-0286-4ce5-bdcb-3ec52faba993@r13g2000vbr.googlegroups.com> <44C6719C-5FC7-4101-8333-85EB975B1F31@mattwynne.net> Message-ID: <6990D1BD-42CC-402D-8232-5D5E872AC490@mattwynne.net> On 14 May 2009, at 14:20, Phlip wrote: > Matt Wynne wrote: > >> I've got a reason. You're coupling the tests for this simple little >> controller class to all the infrastructure and dependencies needed >> to write the record to the database and reload it again. As easy as >> Rails makes it for us to manage our database schemas, gratuitously >> introducing dependencies in your code like this is a bad habit to >> get into. It can lead to tests that are fragile to failing when >> code is changed far away from the place they're apparently testing. >> The tests also run slowly, which makes working on systems written >> like this boring. > > The point of unit tests (which include the alleged "functional > tests" in Rails) is to fail more often than production code would > fail. Not less often. Yep, I agree that would be silly. On the other hand, if the tests fail for no good reason all the time because they're fragile, people may stop listening to them, and maybe eventually stop writing them. The argument I'm making is really just for slowing down and taking a little more care, with the eventual benefit of tests that are trustworthy and easy to maintain. I would imagine that's your goal too, but we apparently have different approaches :) Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From luke at lukemelia.com Fri May 15 02:01:25 2009 From: luke at lukemelia.com (Luke Melia) Date: Fri, 15 May 2009 02:01:25 -0400 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep Message-ID: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> I'm trying to make sure that my cucumber selenium suite fails if my Rails app returns any 500 response codes. I'm working on what the best way to identify this state, but the question I'd like to put to the list is this: If I want to check for this error condition in an After or AfterStep, how can I force a failure in the scenario? i.e. something like the following non-functional snippet: AfterStep do |scenario| if foo_error_state_detected? scenario.fail("A foo failure has been detected.") end end Ideas? TIA, Luke -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From Lee.Longmore at googlemail.com Fri May 15 02:28:23 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Thu, 14 May 2009 23:28:23 -0700 (PDT) Subject: [rspec-users] Why won't my simple controller spec pass? Message-ID: I have been trying to spec a Rails Controller for the first time, having just completed my first View spec. Having hit a wall trying to spec a controller for my own application, I have tried to get an example in beta of The RSpec Book to work. I am however experiencing the same failures. I would appreciate any pointers on where I am going wrong. Here is the failure: 1) Spec::Mocks::MockExpectationError in 'MessagesController POST create should build a new message' expected :new with ({"body"=>"a quick brown fox"}) once, but received it 0 times ./spec/controllers/messages_controller_spec.rb:7: script/spec:10: Here is the controller spec: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe MessagesController, "POST create" do it "should build a new message" do message=mock_model(Message) Message.should_receive(:new).with("body" => "a quick brown fox").and_return(message) post :create, :message => {"body" => "a quick brown fox"} end it "should save the message" end Here is the controller: class MessagesController < ApplicationController def create message = Message.new params[:message] end end And here is the (mocked) model: class Message end *** As an aside, I already have an implemented model that I'd like to use in my controller spec. In this case, should I be using stub_model() to make use of it e.g.: context = stub_model(Context) Also the constructor expects a name to be passed in so can I write: Context.should_receive(:new).with("name" => "fred").and_return (message) post :create, :context => {"name" => "fred"} And then in the controller 'create' method: Context.new params[:context] I did try this but received an error from my model and trace suggesting that the "name" was not being supplied. Thanks. From aslak.hellesoy at gmail.com Fri May 15 02:38:12 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 08:38:12 +0200 Subject: [rspec-users] [Cucumber] ANN: Cucumber 0.3.5 Message-ID: <8d961d900905142338n211172c4se3c1d5a4cc1490d3@mail.gmail.com> http://github.com/aslakhellesoy/cucumber/blob/20021e90c892030c1a1b46e2d19024c3719af0ba/History.txt Thanks Joseph! From matt at mattwynne.net Fri May 15 03:15:39 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 15 May 2009 08:15:39 +0100 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> Message-ID: On 15 May 2009, at 07:01, Luke Melia wrote: > I'm trying to make sure that my cucumber selenium suite fails if my > Rails app returns any 500 response codes. I'm working on what the > best way to identify this state, but the question I'd like to put to > the list is this: If I want to check for this error condition in an > After or AfterStep, how can I force a failure in the scenario? > > i.e. something like the following non-functional snippet: > > AfterStep do |scenario| > if foo_error_state_detected? > scenario.fail("A foo failure has been detected.") > end > end > > Ideas? +1 to this - I came up against exactly the same problem yesterday. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From Lee.Longmore at googlemail.com Fri May 15 03:16:21 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Fri, 15 May 2009 00:16:21 -0700 (PDT) Subject: [rspec-users] Why won't my simple controller spec pass? In-Reply-To: References: Message-ID: <5c0c8c96-6b7a-4aac-8c83-7ca31951049b@s31g2000vbp.googlegroups.com> I have now managed to get the example to run as expected from The RSpec Book. I would appreciate pointers on the following though: > As an aside, I already have an implemented model that I'd like to use > in my controller spec. In this case, should I be using stub_model() to > make use of it e.g.: > > context = stub_model(Context) > > Also the constructor expects a name to be passed in so can I write: > > Context.should_receive(:new).with("name" => "fred").and_return > (message) > post :create, :context => {"name" => "fred"} > > And then in the controller 'create' method: > > Context.new params[:context] On 15 May, 07:28, Lee wrote: > I have been trying to spec a Rails Controller for the first time, > having just completed my first View spec. > > Having hit a wall trying to spec a controller for my own application, > I have tried to get an example in beta of The RSpec Book to work. I am > however experiencing the same failures. I would appreciate any > pointers on where I am going wrong. > > Here is the failure: > > 1) > Spec::Mocks::MockExpectationError in 'MessagesController POST create > should build a new message' > expected :new with ({"body"=>"a quick brown fox"}) > once, but received it 0 times > ./spec/controllers/messages_controller_spec.rb:7: > script/spec:10: > > Here is the controller spec: > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe MessagesController, "POST create" do > > ? it "should build a new message" do > ? ? message=mock_model(Message) > ? ? Message.should_receive(:new).with("body" => "a quick brown > fox").and_return(message) > ? ? post :create, :message => {"body" => "a quick brown fox"} > ? end > > ? it "should save the message" > > end > > Here is the controller: > > class MessagesController < ApplicationController > ? def create > ? ? message = Message.new params[:message] > ? end > end > > And here is the (mocked) model: > > class Message > end > > *** > > As an aside, I already have an implemented model that I'd like to use > in my controller spec. In this case, should I be using stub_model() to > make use of it e.g.: > > context = stub_model(Context) > > Also the constructor expects a name to be passed in so can I write: > > Context.should_receive(:new).with("name" => "fred").and_return > (message) > post :create, :context => {"name" => "fred"} > > And then in the controller 'create' method: > > Context.new params[:context] > > I did try this but received an error from my model and trace > suggesting that the "name" was not being supplied. > > Thanks. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Fri May 15 04:25:44 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 10:25:44 +0200 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> Message-ID: <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> > I'm trying to make sure that my cucumber selenium suite fails if my Rails > app returns any 500 response codes. I'm working on what the best way to > identify this state, but the question I'd like to put to the list is this: > If I want to check for this error condition in an After or AfterStep, how > can I force a failure in the scenario? > To be honest, I don't remember what happened to AfterStep. I think we had it at some point, but can't see it in the codebase. Did I remove it? Or was that back in the pre-Cucumber days? Help me remember here... > i.e. something like the following non-functional snippet: > > AfterStep do |scenario| > ?if foo_error_state_detected? > ? ?scenario.fail("A foo failure has been detected.") > ?end > end > > Ideas? > I'm not so sure I like the idea of AfterStep - smells like a workaround for something that belongs elsewhere. Can't your have selenium-rc (or a helper method you create around it) raise those exceptions? Given /bla/ do # don't remember the API, but you get the idea @browser.goto_strict('/bla') # raises on 500 errors end Aslak > TIA, > Luke > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luke at lukemelia.com Fri May 15 09:34:00 2009 From: luke at lukemelia.com (Luke Melia) Date: Fri, 15 May 2009 09:34:00 -0400 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> Message-ID: <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> On May 15, 2009, at 4:25 AM, aslak hellesoy wrote: > To be honest, I don't remember what happened to AfterStep. I think we > had it at some point, but can't see it in the codebase. Did I remove > it? Or was that back in the pre-Cucumber days? Help me remember > here... I'm not sure. I saw a reference for it on the wiki: [http://wiki.github.com/aslakhellesoy/cucumber/hooks ] and it seemed to fit this problem, but it's not in the version of cucumber we're running. I thought perhaps it was in trunk but it sounds like that's not the case. > I'm not so sure I like the idea of AfterStep - smells like a > workaround for something that belongs elsewhere. Can't your have > selenium-rc (or a helper method you create around it) raise those > exceptions? > > Given /bla/ do > # don't remember the API, but you get the idea > @browser.goto_strict('/bla') # raises on 500 errors > end Yes, I'd prefer to be able to configure selenium-rc to fail on 500s. The problem I ran into is that selenium client doesn't appear to be able to access the HTTP response code. In addition, ajax-y HTTP requests can get kicked off in our app by lots of different things (a click here, a mouseover there, etc). In our suite today, of step matchers will usually fail if a 500 is raised, due to the user-facing impact (e.g. a div is not updated or a form does not appear), but it usually takes us a few minutes to realize that there was a 500 error raised (vs. incorrect javascript, etc.). I am hoping to short-circuit that investigation time and also catch the cases where a 500 is triggered and we don't have a step matcher that fails. The approach is a little smelly to me because it adds a little translucency to what is mostly black-box-testing, but I think it would be a net positive, at least for our app. Cheers, Luke -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From phlip2005 at gmail.com Fri May 15 10:13:29 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 15 May 2009 07:13:29 -0700 Subject: [rspec-users] How to test update_attribute with mocha? In-Reply-To: <6990D1BD-42CC-402D-8232-5D5E872AC490@mattwynne.net> References: <8a81395a-0286-4ce5-bdcb-3ec52faba993@r13g2000vbr.googlegroups.com> <44C6719C-5FC7-4101-8333-85EB975B1F31@mattwynne.net> <6990D1BD-42CC-402D-8232-5D5E872AC490@mattwynne.net> Message-ID: Matt Wynne wrote: > On the other hand, if the tests fail for no good reason all the time > because they're fragile, people may stop listening to them, and maybe > eventually stop writing them. The argument I'm making is really just for > slowing down and taking a little more care, with the eventual benefit of > tests that are trustworthy and easy to maintain. I would imagine that's > your goal too, but we apparently have different approaches :) The specific umbrage I took over mocking to detect a update_attribute is I worked for 2.5 years on a huge Rails project with hundreds of tests, including mocks, including controller tests that went a little too far, including very fragile tests, and I never once had the inclination to mock update_attribute. The real attribute is just so easy to detect! Run fragile tests more often and revert more often. -- Phlip http://flea.sourceforge.net/resume.html From aslak.hellesoy at gmail.com Fri May 15 10:16:58 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 16:16:58 +0200 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> Message-ID: <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> > On May 15, 2009, at 4:25 AM, aslak hellesoy wrote: > >> To be honest, I don't remember what happened to AfterStep. I think we >> had it at some point, but can't see it in the codebase. Did I remove >> it? Or was that back in the pre-Cucumber days? Help me remember >> here... > > I'm not sure. I saw a reference for it on the wiki: > [http://wiki.github.com/aslakhellesoy/cucumber/hooks] and it seemed to fit > this problem, but it's not in the version of cucumber we're running. I > thought perhaps it was in trunk but it sounds like that's not the case. > >> I'm not so sure I like the idea of AfterStep - smells like a >> workaround for something that belongs elsewhere. Can't your have >> selenium-rc (or a helper method you create around it) raise those >> exceptions? >> >> Given /bla/ do >> ?# don't remember the API, but you get the idea >> ?@browser.goto_strict('/bla') # raises on 500 errors >> end > > Yes, I'd prefer to be able to configure selenium-rc to fail on 500s. The > problem I ran into is that selenium client doesn't appear to be able to > access the HTTP response code. In addition, ajax-y HTTP requests can get > kicked off in our app by lots of different things (a click here, a mouseover > there, etc). > > In our suite today, of step matchers will usually fail if a 500 is raised, > due to the user-facing impact (e.g. a div is not updated or a form does not > appear), but it usually takes us a few minutes to realize that there was a > 500 error raised (vs. incorrect javascript, etc.). I am hoping to > short-circuit that investigation time and also catch the cases where a 500 > is triggered and we don't have a step matcher that fails. > Can you show me the code you would want to put in AfterStep that would detect a 500 error? Aslak > The approach is a little smelly to me because it adds a little translucency > to what is mostly black-box-testing, but I think it would be a net positive, > at least for our app. > > Cheers, > Luke > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From diwakar at angleritech.com Fri May 15 02:02:47 2009 From: diwakar at angleritech.com (manoah) Date: Thu, 14 May 2009 23:02:47 -0700 (PDT) Subject: [rspec-users] Passing user id to spec | error Message-ID: <23553916.post@talk.nabble.com> -----Controller -------------- def update @user = User.find_by_id( user.id ) if request.post? unless params[ :user ].nil? if @user.update_attributes( params[ :user ] ) redirect_to :action => :show end else render :status => 400, :text => 'No user parameters end ------- spec ------------- describe UserProfilesController do before(:each) do @user = mock_model(User) controller.stub!(:requires_user).and_return @user controller.stub!(:user).and_return @user User.stub!(:find_by_id).and_return(@user) @user.stub!(:update_attributes).and_return(true) end it "should find User and return object" do User.should_receive(:find_by_id).with("1").and_return(@user) @user.should_receive(:update_attributes).and_return(true) post :update, :id =>"1", :user => {} end end ------- Error -------------------------------- expected :find_by_id with ("1") but received it with ([1001]) How shall I pass the id to the spec. Please help overcome this issue -- View this message in context: http://www.nabble.com/Passing-user-id-to-spec-%7C-error-tp23553916p23553916.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Fri May 15 10:43:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 May 2009 09:43:29 -0500 Subject: [rspec-users] Passing user id to spec | error In-Reply-To: <23553916.post@talk.nabble.com> References: <23553916.post@talk.nabble.com> Message-ID: <57c63afe0905150743i470a3fe9lfe3a47f503678390@mail.gmail.com> On Fri, May 15, 2009 at 1:02 AM, manoah wrote: > > ?-----Controller -------------- > def update > ? ?@user = User.find_by_id( user.id ) This uses user.id, not params[:id] > ? ?if request.post? > > ? ? ?unless params[ :user ].nil? > > ? ? ? ?if @user.update_attributes( params[ :user ] ) > ? ? ? ? ?redirect_to :action => :show > > ? ? ? ?end > ? ? ?else > ? ? ? ?render :status => 400, > ? ? ? ? ? ? ? :text => 'No user parameters > end > > ?------- spec ------------- > describe UserProfilesController do > > ?before(:each) do > ? ?@user = mock_model(User) The @user gets defined with an ID of 1001 (in this case). Try: @user = mock_model(User, :id => 1) HTH, David > ? ?controller.stub!(:requires_user).and_return @user > ? ?controller.stub!(:user).and_return @user > ? ?User.stub!(:find_by_id).and_return(@user) > ? ?@user.stub!(:update_attributes).and_return(true) > ?end > > it "should find User and return object" do > ?User.should_receive(:find_by_id).with("1").and_return(@user) > ? @user.should_receive(:update_attributes).and_return(true) > ?post :update, :id =>"1", :user => {} > end > end > > ------- Error -------------------------------- > dat > etime, accessed_on: datetime, email_address: string, name_first: string, > name_la > st: string, mailing_address_id: integer, billing_address_id: integer, > name_displ > ay: string, picture_id: integer, url: string, country: string, freelance: > boolea > n, statement: string, hostname_active: boolean, hostname: string, > promotional_ma > ilings: boolean, sales_commission_rate: float, referral_commission_rate: > float, > employee_lock: boolean) (class)> expected :find_by_id with ("1") but > received it > ?with ([1001]) > > How shall I pass the id to the spec. Please help overcome this issue > > -- > View this message in context: http://www.nabble.com/Passing-user-id-to-spec-%7C-error-tp23553916p23553916.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Fri May 15 11:21:07 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 15 May 2009 09:21:07 -0600 Subject: [rspec-users] Cucumber broke my rake tasks! 0.3.5 In-Reply-To: <88fd8ddc0905150304h346f7d41i451d4ce28cfddbae@mail.gmail.com> References: <88fd8ddc0905150304h346f7d41i451d4ce28cfddbae@mail.gmail.com> Message-ID: <4A0D8863.1020502@benmabey.com> Andrew Premdas wrote: > Seem to be having a problem with the new releases 0.3.5 which > completely breaks my rake tasks http://gist.github.com/112149. > > WIth the > > t.fork = true # Explicitly fork for cucumber 0.3.4 and rails > > lines added to the tasks none of my steps are recognised (see second > file in gists) > > Without t.fork line I get an error < undefined method `differ=' > > (trace in third file in gist) > > Running similar profiles using cucumber -p seems to work fine > > All best > > This looks similar to a ticket James opened earlier: https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/325-cucumber-v-035-load-behaviour-change Please follow that ticket and comment there if you agree. -Ben From lists at ruby-forum.com Fri May 15 11:35:53 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 15 May 2009 17:35:53 +0200 Subject: [rspec-users] Cucumber tables Message-ID: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> I cannot seem to locate any documentation on how to implement the new table syntax otherwise I would not bother the list with this. I wish to write something like this: And we do have a forex rate for the following currency code and date |code | date | rate | |"USD"|"2009-04-01"|"0.8555"| |"USD"|"2009-04-05"|"0.8444"| Then /^we do have a forex (.+) for the following currency (.+) and (.+)$/ \ do |rate,code,date,table| # table is a Cucumber::Ast::Table puts rate puts code puts date end All I see from this is: ... rate code date And we do have a forex rate for the following currency code and date # features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:8 | code | date | rate | | "USD" | "2009-04-01" | "0.8555" | | "USD" | "2009-04-05" | "0.8444" | I only get one iteration of output and that only displays the regex matches found in the original string. What is happening with the rest of the data? Is the table data keyed by the headings or is it position dependent on the matcher order? In other words, does the data in the table have to be in the same order as the regexp in the preceding clause. If so, then why the table headings? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Fri May 15 12:29:19 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 15 May 2009 12:29:19 -0400 Subject: [rspec-users] helpers for examples? In-Reply-To: <4A0D687B.2070503@haskinferguson.net> References: <4A0D687B.2070503@haskinferguson.net> Message-ID: <85d99afe0905150929p668fad18jbeccd42be5c14b5c@mail.gmail.com> On Fri, May 15, 2009 at 9:04 AM, Denis Haskin wrote: > Where's the recommended place to put helper methods & etc for examples? > I've started putting them in spec/spec_helper.rb but that's going to get > awfully cluttered.? I'm thinking maybe a spec/lib, and add that to include > path?? Or just put them in lib?? I notice restful_authentication (I think) > put AuthenticatedTestHelper there. I make a spec/spec_helpers/ directory and put them in there. I try to namespace them in the module SpecHelpers to avoid conflict and/or confusion with other modules in the app. I would not use spec/lib/, because a rails app has a lib directory, and convention would have someone assume spec/lib/ are specs for objects in RAILS_ROOT/lib/. > > Thx, > > dwh > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From zach.dennis at gmail.com Fri May 15 12:30:55 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 15 May 2009 12:30:55 -0400 Subject: [rspec-users] helpers for examples? In-Reply-To: <85d99afe0905150929p668fad18jbeccd42be5c14b5c@mail.gmail.com> References: <4A0D687B.2070503@haskinferguson.net> <85d99afe0905150929p668fad18jbeccd42be5c14b5c@mail.gmail.com> Message-ID: <85d99afe0905150930i2dc8a329m75db3644d8ac9a2c@mail.gmail.com> On Fri, May 15, 2009 at 12:29 PM, Zach Dennis wrote: > On Fri, May 15, 2009 at 9:04 AM, Denis Haskin wrote: >> Where's the recommended place to put helper methods & etc for examples? >> I've started putting them in spec/spec_helper.rb but that's going to get >> awfully cluttered.? I'm thinking maybe a spec/lib, and add that to include >> path?? Or just put them in lib?? I notice restful_authentication (I think) >> put AuthenticatedTestHelper there. > > I make a spec/spec_helpers/ directory and put them in there. I try to > namespace them in the module SpecHelpers to avoid conflict and/or > confusion with other modules in the app. > > I would not use spec/lib/, because a rails app has a lib directory, > and convention would have someone assume spec/lib/ are specs for > objects in RAILS_ROOT/lib/. Forgot to add in my spec_helper.rb I load all ruby files in spec/spec_helpers/ Dir[File.dirname(__FILE__) + '/spec_helpers/**/*.rb'].each { |f require f } and then in my spec config I include specific ones I need: Spec::Runner.configure do |config| config.include SpecHelpers::MyApplicationMatchers config.include SpecHelpers::ControllerMacros, :type => :controller end > >> >> Thx, >> >> dwh >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com (personal) > http://www.mutuallyhuman.com (hire me) > @zachdennis (twitter) > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From luke at lukemelia.com Fri May 15 12:53:55 2009 From: luke at lukemelia.com (Luke Melia) Date: Fri, 15 May 2009 12:53:55 -0400 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> Message-ID: <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> On May 15, 2009, at 10:16 AM, aslak hellesoy wrote: > Can you show me the code you would want to put in AfterStep that would > detect a 500 error? I've written a simple piece of rack middleware (included below) that will create a file in the event a 500 is raised. I would clear the file before each scenario and check for it's existence in the AfterStep. For example: Before do File.delete('/tmp/rails.error') if File.exist?('/tmp/rails.error') end AfterStep do |scenario| if File.exist?('/tmp/rails.error') scenario.fail("Failed because app raised a 50x error.") end end Here's the rack piece, for the curious: class RackErrorTouch def initialize(app, options = {}) @app = app @path = options[:path] end def call(env) rack_response = @app.call(env) if rack_response.first >= 500 `touch #{@path}` end rack_response end end -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From rick.denatale at gmail.com Fri May 15 12:50:01 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 15 May 2009 12:50:01 -0400 Subject: [rspec-users] Can I run the same specs with different gems? Ideas? Message-ID: I have a new icalendar Ruby library/gem which is implemented so as require an implementation of the TZInfo::Timezone class, but not to care whether that implementation comes from the tzinfo gem, or the activesupport gem in rails. It also will make use of the TimeWithZone class in recent versions of activesupport if it's loaded, but it leaves the decision of whether to load the activesuport or tzinfo gems up to the user. Now, it that makes sense I'd like to be able to run my specs with the tzinfo gen and then with the activesupport gem. Ideally I'd like to have rake tasks like rake spec:tzinfo rake spec:activesupport rake spec:both The problem is that I think I need something like the fork option for spec task similar to the one in the cucumber task, since once loaded I can't unload one or the other gem in the same ruby process. Is there a trick I'm missing? -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From lists at ruby-forum.com Fri May 15 13:01:01 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 15 May 2009 19:01:01 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> Message-ID: I do not know if I am doing something wrong or not, but I am seeing evidence that feature tables in normal scenarios do not actually do anything. # feature statement And we do have a forex rate for "USD" on "2009-03-31" of "0.8666" | "USD" | "2009-04-01" | "0.8555" | | "USD" | "2009-04-05" | "0.8444" | Then the number of forex rates should be 3 # step definition Then /do have a forex rate for "([^\"]*)" on "([^\"]*)" of "([^\"]*)"/ \ do |code,date,rate,table| my_rate = CurrencyExchangeRate.new my_rate.currency_code_base = 'CAD' my_rate.currency_code_quote = code my_rate.currency_exchange_rate = rate my_rate.currency_exchange_source = 'features test' my_rate.currency_exchange_type = 'TEST' my_rate.effective_from = date my_rate.save! end Then /the number of forex rates should be (\d+)/ do |count| CurrencyExchangeRate.count.should ==(count) end But, the results of this are: And we do have a forex rate for "USD" on "2009-03-31" of "0.8666" # features/app/models/currency_exchange_rates/step_definitions /currency_exchange_rates_steps.rb:8 | "USD" | "2009-04-01" | "0.8555" | | "USD" | "2009-04-05" | "0.8444" | Then the number of forex rates should be 3 # features/app/models/currency_exchange_rates/step_definitions /currency_exchange_rates_steps.rb:81 expected: "3", got: 1 (using ==) Diff: @@ -1,2 +1,2 @@ -3 +1 -- Posted via http://www.ruby-forum.com/. From caifara.subscribe at gmail.com Fri May 15 12:51:23 2009 From: caifara.subscribe at gmail.com (Ivo Dancet) Date: Fri, 15 May 2009 18:51:23 +0200 Subject: [rspec-users] [ANN] rSquery 0.1.1 Message-ID: <6C7F2248-77DD-4379-AA26-1127FD4C3EC9@gmail.com> Hello all rSquery aims to reduce the difficulties involved in writing selenium tests in cucumber environments for webapps that use jQuery. The project contains several methods to help you with writing javascript commands for selenium and javascript based tests for cucumber or even rSpec. It makes it possible to write stuff like (in jQuery enabled webapp): - jquery("#content").wait_for_visible - jquery("#dialog button:contains(Ok)").click - jquery.wait_for_text("User saved...") - jquery.wait_for_element(".some_element") - jquery("#dialog div").text.should have_text(/some_text/) - jquery("#dialog").find(".warning") - jquery("#dialog").html.should have_tag("button", "Ok") - jquery("#dialog").should be_visible - jquery("#dialog") # page must have an element with id 'dialog' The project is at http://github.com/caifara/rsquery/tree/master Ivo Dancet by2.be From aslak.hellesoy at gmail.com Fri May 15 13:36:30 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 19:36:30 +0200 Subject: [rspec-users] Cucumber broke my rake tasks! 0.3.5 In-Reply-To: <4A0D8863.1020502@benmabey.com> References: <88fd8ddc0905150304h346f7d41i451d4ce28cfddbae@mail.gmail.com> <4A0D8863.1020502@benmabey.com> Message-ID: <8d961d900905151036r7e07ffbfyc5fda94fc963a495@mail.gmail.com> > Andrew Premdas wrote: >> >> Seem to be having a problem with the new releases 0.3.5 which >> completely breaks my rake tasks http://gist.github.com/112149. >> >> WIth the >> >> ?t.fork = true # Explicitly fork for cucumber 0.3.4 and rails >> >> lines added to the tasks none of my steps are recognised (see second >> file in gists) >> >> Without t.fork line I get an error ?< undefined method `differ=' > >> (trace in third file in gist) >> >> Running similar profiles using cucumber -p seems to work fine >> >> All best >> >> > > > This looks similar to a ticket James opened earlier: > https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/325-cucumber-v-035-load-behaviour-change > > Please follow that ticket and comment there if you agree. > Can you all try to specify the lib attribute of the rake task? I think that has something to do with this..... Aslak > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri May 15 13:56:58 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 19:56:58 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> Message-ID: <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> > I cannot seem to locate any documentation on how to implement the new > table syntax otherwise I would not bother the list with this. > I'm not sure what you mean by "new" table syntax. The syntax for tables hasn't really changed since it was introduced. > I wish to write something like this: > > ?And we do have a forex rate for the following currency code and date > ? ? ? ?|code | ? ?date ? ?| ?rate ?| > ? ? ? ?|"USD"|"2009-04-01"|"0.8555"| > ? ? ? ?|"USD"|"2009-04-05"|"0.8444"| > Why are you quoting the cell values? > Then /^we do have a forex (.+) for the following currency (.+) and > (.+)$/ \ > ?do |rate,code,date,table| > ?# table is a Cucumber::Ast::Table > ? ?puts rate > ? ?puts code > ? ?puts date > end > > All I see from this is: > ... > rate > code > date Which makes sense - these are the values of the 3 groups in your regexp. > ? ?And we do have a forex rate for the following currency code and date > # > features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:8 > ? ? ?| code ?| date ? ? ? ? | rate ? ? | > ? ? ?| "USD" | "2009-04-01" | "0.8555" | > ? ? ?| "USD" | "2009-04-05" | "0.8444" | > > I only get one iteration of output and that only displays the regex > matches found in the original string. > > What is happening with the rest of the data? Is the table data keyed by > the headings or is it position dependent on the matcher order? ?In other > words, does the data in the table have to be in the same order as the > regexp in the preceding clause. ?If so, then why the table headings? Doc: http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines Please let us know what's missing or unclear about that. Aslak > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From fkchang2000 at yahoo.com Fri May 15 14:15:14 2009 From: fkchang2000 at yahoo.com (Forrest Chang) Date: Fri, 15 May 2009 11:15:14 -0700 (PDT) Subject: [rspec-users] Creating an "integration controller" spec In-Reply-To: References: Message-ID: <786887.42461.qm@web82804.mail.mud.yahoo.com> Hi All: So I have some longer running controller specs that interact with outside API's that I want to move into an integration directory. In doing so, it seems I don't get the (possibly determined by directory?) magic that creates a ControllerExampleGroup, but rather a RailsExampleGroup. How might I set this up to recognize it as a controller spec? Thanks Forrest From lists at ruby-forum.com Fri May 15 15:06:57 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 15 May 2009 21:06:57 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> Message-ID: <93b1fec1e27798e8980b34ee9f01e4b9@ruby-forum.com> Aslak Helles?y wrote: > http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines > > Please let us know what's missing or unclear about that. > That documentation is for scenario outlines. I had gathered that one could also simply use tables with regular scenarios where the table values replaced the rexep in the preceding statement. At one point I am sure that this is what I was doing, although the table followed a complete scenario. However, I have not used tables for the last couple of months and am somewhat perplexed with respect to the changes. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 15 15:08:44 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 15 May 2009 21:08:44 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> Message-ID: Chris Flipse wrote: > They're actually unrelated. Most of my table matchers have no other > regex in the expression > > You're not seeing anything else with the table data because you're not > doing > anything with the table data. > > Given /the following data rates/ do |table| > table.hashes.each do |row| > puts row["code"] > end > end > Thank you very much. Could you give me the rdoc reference for this construct. This is exactly the sort of thing I was looking for and could not find. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri May 15 15:21:20 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 May 2009 14:21:20 -0500 Subject: [rspec-users] Creating an "integration controller" spec In-Reply-To: <786887.42461.qm@web82804.mail.mud.yahoo.com> References: <786887.42461.qm@web82804.mail.mud.yahoo.com> Message-ID: <57c63afe0905151221m582a9305j5e99db34b151b67@mail.gmail.com> On Fri, May 15, 2009 at 1:15 PM, Forrest Chang wrote: > > Hi All: > > So I have some longer running controller specs that interact with outside API's that I want to move into an integration directory. ?In doing so, it seems I don't get the (possibly determined by directory?) magic that creates a ControllerExampleGroup, but rather a RailsExampleGroup. > > > How might I set this up to recognize it as a controller spec? describe "something", :type => :controller do Cheers, David > > > Thanks > > > Forrest > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri May 15 15:28:39 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 21:28:39 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <93b1fec1e27798e8980b34ee9f01e4b9@ruby-forum.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> <93b1fec1e27798e8980b34ee9f01e4b9@ruby-forum.com> Message-ID: <8d961d900905151228r69134cfbyca4911519dc71194@mail.gmail.com> > Aslak Helles?y wrote: > >> http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines >> >> Please let us know what's missing or unclear about that. >> > > That documentation is for scenario outlines. ?I had gathered that one > could also simply use tables with regular scenarios where the table > values replaced the rexep in the preceding statement. ?At one point I am > sure that this is what I was doing, although the table followed a > complete scenario. ?However, I have not used tables for the last couple > of months and am somewhat perplexed with respect to the changes. What are these changes you are talking about?? The only thing that changed was: * the "More Examples" keyword was renamed to "Examples". * "Examples" can only be used under "Scenario Outline", not "Scenario". These are minor changes that haven't really changed anything fundamentally. You can find the documentation for multiline step arguments here: http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments Aslak > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Fri May 15 15:36:19 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 21:36:19 +0200 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> Message-ID: <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> > On May 15, 2009, at 10:16 AM, aslak hellesoy wrote: > >> Can you show me the code you would want to put in AfterStep that would >> detect a 500 error? > > I've written a simple piece of rack middleware (included below) that will > create a file in the event a 500 is raised. I would clear the file before > each scenario and check for it's existence in the AfterStep. For example: > Thanks for doing that. I have one more favour to ask: Can you show me an example of a StepDefinition that would cause the file to be created? Then I might be able to suggest an alternative solution with the same result. Aslak > Before do > ?File.delete('/tmp/rails.error') if File.exist?('/tmp/rails.error') > end > > AfterStep do |scenario| > ?if File.exist?('/tmp/rails.error') > ? ?scenario.fail("Failed because app raised a 50x error.") > ?end > end > > Here's the rack piece, for the curious: > > class RackErrorTouch > ?def initialize(app, options = {}) > ? ?@app = app > ? ?@path = options[:path] > ?end > > ?def call(env) > ? ?rack_response = @app.call(env) > ? ?if rack_response.first >= 500 > ? ? ?`touch #{@path}` > ? ?end > ? ?rack_response > ?end > end > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Fri May 15 15:36:17 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 15 May 2009 15:36:17 -0400 Subject: [rspec-users] Creating an "integration controller" spec In-Reply-To: <786887.42461.qm@web82804.mail.mud.yahoo.com> References: <786887.42461.qm@web82804.mail.mud.yahoo.com> Message-ID: <85d99afe0905151236w5c361066nc7951305a66ccf9@mail.gmail.com> On Fri, May 15, 2009 at 2:15 PM, Forrest Chang wrote: > > Hi All: > > So I have some longer running controller specs that interact with outside API's that I want to move into an integration directory. ?In doing so, it seems I don't get the (possibly determined by directory?) magic that creates a ControllerExampleGroup, but rather a RailsExampleGroup. > > > How might I set this up to recognize it as a controller spec? describe YourController, :type => :controller do ... end > > > Thanks > > > Forrest > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From aslak.hellesoy at gmail.com Fri May 15 15:47:18 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 21:47:18 +0200 Subject: [rspec-users] [ANN] rSquery 0.1.1 In-Reply-To: <6C7F2248-77DD-4379-AA26-1127FD4C3EC9@gmail.com> References: <6C7F2248-77DD-4379-AA26-1127FD4C3EC9@gmail.com> Message-ID: <8d961d900905151247s4c82277fl58692be9d513050c@mail.gmail.com> > Hello all > > rSquery aims to reduce the difficulties involved in writing selenium tests > in cucumber environments for webapps that use jQuery. > > The project contains several methods to help you with writing javascript > commands for selenium and javascript based tests for cucumber or even rSpec. > Excellent! Please add it to the related tools page in the Cucumber wiki (in alphabetical position) > It makes it possible to write stuff like (in jQuery enabled webapp): > > - jquery("#content").wait_for_visible > - jquery("#dialog button:contains(Ok)").click > - jquery.wait_for_text("User saved...") > - jquery.wait_for_element(".some_element") > - jquery("#dialog div").text.should have_text(/some_text/) > - jquery("#dialog").find(".warning") > - jquery("#dialog").html.should have_tag("button", "Ok") > - jquery("#dialog").should be_visible > - jquery("#dialog") # page must have an element with id 'dialog' > Will it work with WebDriver? Selenium as we know it seems to be EOL'ed soon... http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html Aslak > The project is at http://github.com/caifara/rsquery/tree/master > > Ivo Dancet > by2.be > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri May 15 16:30:37 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 22:30:37 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> Message-ID: <8d961d900905151330s2a8d29d6q564dc43ffdffa6f3@mail.gmail.com> > Chris Flipse wrote: > >> They're actually unrelated. ?Most of my table matchers have no other >> regex in the expression >> >> You're not seeing anything else with the table data because you're not >> doing >> anything with the table data. >> >> ?Given /the following data rates/ do |table| >> ? ? table.hashes.each do |row| >> ? ? ? ?puts row["code"] >> ? ? end >> ? end >> > > Thank you very much. Could you give me the rdoc reference for this > construct. ?This is exactly the sort of thing I was looking for and > could not find. > I just added a wiki page for this: http://github.com/aslakhellesoy/cucumber/wikis/rdoc The table RDoc is here: http://localhost:8808/doc_root/cucumber-0.3.5/rdoc/Cucumber/Ast/Table.html Aslak > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri May 15 16:39:33 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 15 May 2009 22:39:33 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <8d961d900905151228r69134cfbyca4911519dc71194@mail.gmail.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> <93b1fec1e27798e8980b34ee9f01e4b9@ruby-forum.com> <8d961d900905151228r69134cfbyca4911519dc71194@mail.gmail.com> Message-ID: <8a7ee369b38e34af72922aa029d2362b@ruby-forum.com> Aslak Helles?y wrote: >> sure that this is what I was doing, although the table followed a >> complete scenario. ?However, I have not used tables for the last couple >> of months and am somewhat perplexed with respect to the changes. > > What are these changes you are talking about?? The only thing that > changed was: > > * the "More Examples" keyword was renamed to "Examples". > * "Examples" can only be used under "Scenario Outline", not "Scenario". > > These are minor changes that haven't really changed anything > fundamentally. You can find the documentation for multiline step > arguments here: Yes, I followed that part. The part I did not comprehend was using multiline step arguments, which are more commonly referred to as tables as well insofar as I can see. I was looking for "tables" in the documentation, not "multiline step arguments", which conveys to me a completely different meaning than the one evidently intended. Nonetheless, Mr. Flipse's post has put me right and I am on to the next bit of confusion. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Fri May 15 16:57:10 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 15 May 2009 22:57:10 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <8a7ee369b38e34af72922aa029d2362b@ruby-forum.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> <93b1fec1e27798e8980b34ee9f01e4b9@ruby-forum.com> <8d961d900905151228r69134cfbyca4911519dc71194@mail.gmail.com> <8a7ee369b38e34af72922aa029d2362b@ruby-forum.com> Message-ID: <8d961d900905151357q43f37aceq10ec3424dc842c68@mail.gmail.com> > Aslak Helles?y wrote: >>> sure that this is what I was doing, although the table followed a >>> complete scenario. ?However, I have not used tables for the last couple >>> of months and am somewhat perplexed with respect to the changes. >> >> What are these changes you are talking about?? The only thing that >> changed was: >> >> * the "More Examples" keyword was renamed to "Examples". >> * "Examples" can only be used under "Scenario Outline", not "Scenario". >> >> These are minor changes that haven't really changed anything >> fundamentally. You can find the documentation for multiline step >> arguments here: > > Yes, I followed that part. ?The part I did not comprehend was using > multiline step arguments, which are more commonly referred to as tables > as well insofar as I can see. ?I was looking for "tables" in the > documentation, not "multiline step arguments", which conveys to me a > completely different meaning than the one evidently intended. > I'm aware that the two different kind of tables can be confusing, so I'll try to always refer to them as: "multiline argument tables" or maybe "step argument tables" or even "argument tables" and "scenario outline tables" or "example tables" Which terms do you think we should adopt and where in the wiki should this be emphasized more clearly? Aslak > Nonetheless, Mr. Flipse's post has put me right and I am on to the next > bit of confusion. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luke at lukemelia.com Fri May 15 17:12:04 2009 From: luke at lukemelia.com (Luke Melia) Date: Fri, 15 May 2009 17:12:04 -0400 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> Message-ID: On May 15, 2009, at 3:36 PM, aslak hellesoy wrote: > Thanks for doing that. I have one more favour to ask: Can you show me > an example of a StepDefinition that would cause the file to be > created? That is a tougher question, because any browser interaction that causes an HTTP request to the app under test could result in a server error. Ajax requests can be triggered by javascript, and in various parts of our app, they are triggered by clicking on links, submitting forms, dragging and dropping divs, hovering over a div, waiting for a page load to complete, as a callback from interacting with a 3rd party web service, or waiting for a setTimeout to execute. So one way I could tackle it is to add a step to the end of every scenario that says "Then the application should not have issued any responses with 50x status codes", but that would be a) repetitive, and b) not fail until all steps had run, making it harder to track down the step in the test where the failure occurred. One way to look at may be that I'm trying to enforce an invariant. Under no circumstances in my test suite is it appropriate for my app to raise a 50x error. In my Rails integration suite, webrat enforces this particular invariant for me, but can't find a good hook in the selenium test stack to do this, which is why I'm looking at this route. Cheers, Luke -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From wayne.simacek at gmail.com Fri May 15 21:23:17 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Fri, 15 May 2009 18:23:17 -0700 (PDT) Subject: [rspec-users] [Cucumber] ANN: Cucumber 0.3.4 In-Reply-To: References: <8d961d900905140748nb2fa631mbf71c2efb2538d81@mail.gmail.com> Message-ID: <6b287d4c-2bd2-439e-8de8-b51b31c1b35f@e23g2000vbe.googlegroups.com> On May 14, 10:04?am, Julian Leviston wrote: > On 15/05/2009, at 12:48 AM, aslak hellesoy wrote: > > >http://github.com/aslakhellesoy/cucumber/blob/173506c4013a7d733c5b492... > > > Enjoy! I just did an upgrade and came up with .0.3.5. The last entry I see on you list was .0.3.4 two days ago? Is this right? ---Wayne > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > Wicked :) > > Julian. > > ---------------------------------------------- > Blog:http://random8.zenunit.com/ > Learn:http://sensei.zenunit.com/ > Twitter:http://twitter.com/random8r > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From wayne.simacek at gmail.com Fri May 15 21:27:58 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Fri, 15 May 2009 18:27:58 -0700 (PDT) Subject: [rspec-users] [Cucumber] ANN: Cucumber 0.3.4 In-Reply-To: References: <8d961d900905140748nb2fa631mbf71c2efb2538d81@mail.gmail.com> Message-ID: <47110cf6-845d-4318-8f35-748f43f04a9b@v4g2000vba.googlegroups.com> On May 14, 10:04?am, Julian Leviston wrote: > On 15/05/2009, at 12:48 AM, aslak hellesoy wrote: > > >http://github.com/aslakhellesoy/cucumber/blob/173506c4013a7d733c5b492... > > > Enjoy! > > ______________ Sorry I didn't read to the bottom and see that you also put in the . 0.3.5. Please excuse me. --Wayne _________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > Wicked :) > > Julian. > > ---------------------------------------------- > Blog:http://random8.zenunit.com/ > Learn:http://sensei.zenunit.com/ > Twitter:http://twitter.com/random8r > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From diwakar at angleritech.com Fri May 15 23:20:33 2009 From: diwakar at angleritech.com (manoah) Date: Fri, 15 May 2009 20:20:33 -0700 (PDT) Subject: [rspec-users] Passing user id to spec | error In-Reply-To: <23553916.post@talk.nabble.com> References: <23553916.post@talk.nabble.com> Message-ID: <23570120.post@talk.nabble.com> manoah wrote: > > -----Controller -------------- > def update > @user = User.find_by_id( user.id ) > if request.post? > > unless params[ :user ].nil? > > if @user.update_attributes( params[ :user ] ) > redirect_to :action => :show > > end > else > render :status => 400, > :text => 'No user parameters > end > > ------- spec ------------- > describe UserProfilesController do > > before(:each) do > @user = mock_model(User) > controller.stub!(:requires_user).and_return @user > controller.stub!(:user).and_return @user > User.stub!(:find_by_id).and_return(@user) > @user.stub!(:update_attributes).and_return(true) > end > > it "should find User and return object" do > User.should_receive(:find_by_id).with("1").and_return(@user) > @user.should_receive(:update_attributes).and_return(true) > post :update, :id =>"1", :user => {} > end > end > > ------- Error -------------------------------- > destroyed_on: dat > etime, accessed_on: datetime, email_address: string, name_first: string, > name_la > st: string, mailing_address_id: integer, billing_address_id: integer, > name_displ > ay: string, picture_id: integer, url: string, country: string, freelance: > boolea > n, statement: string, hostname_active: boolean, hostname: string, > promotional_ma > ilings: boolean, sales_commission_rate: float, referral_commission_rate: > float, > employee_lock: boolean) (class)> expected :find_by_id with ("1") but > received it > with ([1001]) > > How shall I pass the id to the spec. Please help overcome this issue > > --------------------------------------------------------- Now I am getting the below error > expected :find_by_id with ("1") but received it with ([1]) How shall I pass ---------------------------------------------------------- -- View this message in context: http://www.nabble.com/Passing-user-id-to-spec-%7C-error-tp23553916p23570120.html Sent from the rspec-users mailing list archive at Nabble.com. From diwakar at angleritech.com Sat May 16 01:14:26 2009 From: diwakar at angleritech.com (manoah) Date: Fri, 15 May 2009 22:14:26 -0700 (PDT) Subject: [rspec-users] Passing user id to spec | error In-Reply-To: <23553916.post@talk.nabble.com> References: <23553916.post@talk.nabble.com> Message-ID: <23570544.post@talk.nabble.com> manoah wrote: > > -----Controller -------------- > def update > @user = User.find_by_id( user.id ) > if request.post? > > unless params[ :user ].nil? > > if @user.update_attributes( params[ :user ] ) > redirect_to :action => :show > > end > else > render :status => 400, > :text => 'No user parameters > end > > ------- spec ------------- > describe UserProfilesController do > > before(:each) do > @user = mock_model(User) > controller.stub!(:requires_user).and_return @user > controller.stub!(:user).and_return @user > User.stub!(:find_by_id).and_return(@user) > @user.stub!(:update_attributes).and_return(true) > end > > it "should find User and return object" do > User.should_receive(:find_by_id).with("1").and_return(@user) > @user.should_receive(:update_attributes).and_return(true) > post :update, :id =>"1", :user => {} > end > end > > ------- Error -------------------------------- > destroyed_on: dat > etime, accessed_on: datetime, email_address: string, name_first: string, > name_la > st: string, mailing_address_id: integer, billing_address_id: integer, > name_displ > ay: string, picture_id: integer, url: string, country: string, freelance: > boolea > n, statement: string, hostname_active: boolean, hostname: string, > promotional_ma > ilings: boolean, sales_commission_rate: float, referral_commission_rate: > float, > employee_lock: boolean) (class)> expected :find_by_id with ("1") but > received it > with ([1001]) > > How shall I pass the id to the spec. Please help overcome this issue > > Thank you David. The example passes when we pass the id as string @user = mock_model(User, :id=> "1") -- View this message in context: http://www.nabble.com/Passing-user-id-to-spec-%7C-error-tp23553916p23570544.html Sent from the rspec-users mailing list archive at Nabble.com. From lee_longmore at yahoo.co.uk Sat May 16 02:08:01 2009 From: lee_longmore at yahoo.co.uk (Lee Longmore) Date: Sat, 16 May 2009 06:08:01 +0000 (GMT) Subject: [rspec-users] HowTo Specify A Method is Called Within A Controller's Action Message-ID: <501653.91777.qm@web23907.mail.ird.yahoo.com> I am new to RSpec and would appreciate some pointers on how to specify the following for my Rails application... I have a controller called ContextsController and, within this, the usual 'create' method. The first line of this method should be: @member = logged_in_member where logged_in_member is a method that, for simplicity's sake, is a private method of the ContextsController and retrieves a Member model object based on the user_id in the session. I haven't written this method yet so would like to stub it out for now. What might an Example look like to spec this expected behaviour? In particular, I can't work out how to specify that logged_in_member is called. Thanks, Lee. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sat May 16 05:09:40 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Sat, 16 May 2009 11:09:40 +0200 Subject: [rspec-users] [Cucumber] ANN: Cucumber 0.3.4 In-Reply-To: <6b287d4c-2bd2-439e-8de8-b51b31c1b35f@e23g2000vbe.googlegroups.com> References: <8d961d900905140748nb2fa631mbf71c2efb2538d81@mail.gmail.com> <6b287d4c-2bd2-439e-8de8-b51b31c1b35f@e23g2000vbe.googlegroups.com> Message-ID: <391F6D44-1A27-421F-9644-8A65109B231A@gmail.com> > > > On May 14, 10:04 am, Julian Leviston wrote: >> On 15/05/2009, at 12:48 AM, aslak hellesoy wrote: >> >>> http://github.com/aslakhellesoy/cucumber/blob/173506c4013a7d733c5b492 >>> ... >> >>> Enjoy! > > I just did an upgrade and came up with .0.3.5. The last entry I see > on you list was .0.3.4 two days ago? > Is this right? > Yes. I just didn't announce 0.3.5. > ---Wayne > >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-us... at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> Wicked :) >> >> Julian. >> >> ---------------------------------------------- >> Blog:http://random8.zenunit.com/ >> Learn:http://sensei.zenunit.com/ >> Twitter:http://twitter.com/random8r >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/ >> rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From phlip2005 at gmail.com Sat May 16 09:00:59 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 16 May 2009 06:00:59 -0700 Subject: [rspec-users] HowTo Specify A Method is Called Within A Controller's Action In-Reply-To: <501653.91777.qm@web23907.mail.ird.yahoo.com> References: <501653.91777.qm@web23907.mail.ird.yahoo.com> Message-ID: Lee Longmore wrote: > I have a controller called ContextsController and, within this, the > usual 'create' method. The first line of this method should be: > > @member = logged_in_member > > where logged_in_member is a method that, for simplicity's sake, is a > private method of the ContextsController and retrieves a Member model > object based on the user_id in the session. I haven't written this > method yet so would like to stub it out for now. > > What might an Example look like to spec this expected behaviour? If you didn't have that line yet (recommended, because test-first makes this stuff very easy), then what missing behavior would you see in the resulting page? Would it behave as if the user were logged out? Get that behavior going, then specify it didn't happen, and that the correct behavior did. If you merely test that logged_in_member got called, and if it caught a bug, the spec you envision would simply continue to report it was called. Behavior Driven Development is about specifying behaviors at a slightly higher level than their raw source lines! Also, why isn't logged_in_member called from a "before" action? And I would also build a scratch Rails site and throw the "salted authentication" plugin at it. That generates a very nice set of unit tests which show how things like this are done, IIRC! -- Phlip http://flea.sourceforge.net/resume.html From dchelimsky at gmail.com Sat May 16 10:29:36 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 May 2009 09:29:36 -0500 Subject: [rspec-users] HowTo Specify A Method is Called Within A Controller's Action In-Reply-To: <501653.91777.qm@web23907.mail.ird.yahoo.com> References: <501653.91777.qm@web23907.mail.ird.yahoo.com> Message-ID: <57c63afe0905160729k1c8cf95jf6a6abeeab3d1241@mail.gmail.com> On Sat, May 16, 2009 at 1:08 AM, Lee Longmore wrote: > > I am new to RSpec and would appreciate some pointers on how to specify the > following for my Rails application... > > I have a controller called ContextsController and, within this, the usual > 'create' method. The first line of this method should be: > > @member = logged_in_member > > where logged_in_member is a method that, for simplicity's sake, is a private > method of the ContextsController and retrieves a Member model object based > on the user_id in the session. I haven't written this method yet so would > like to stub it out for now. > > What might an Example look like to spec this expected behaviour? > > In particular, I can't work out how to specify that logged_in_member is > called. member = stub_model(Member) controller.should_receive(:logged_in_member).and_return(member) get :action HTH, David > > Thanks, > > Lee. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sat May 16 11:05:41 2009 From: lists at ruby-forum.com (James Byrne) Date: Sat, 16 May 2009 17:05:41 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <8d961d900905151357q43f37aceq10ec3424dc842c68@mail.gmail.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> <93b1fec1e27798e8980b34ee9f01e4b9@ruby-forum.com> <8d961d900905151228r69134cfbyca4911519dc71194@mail.gmail.com> <8a7ee369b38e34af72922aa029d2362b@ruby-forum.com> <8d961d900905151357q43f37aceq10ec3424dc842c68@mail.gmail.com> Message-ID: <4c2f468398f268479e63f8c42cc72fd9@ruby-forum.com> Aslak Helles?y wrote: > > Which terms do you think we should adopt and where in the wiki should > this be emphasized more clearly? > > Aslak The best suggestion that I can come up with is: Outline Tables for Scenario Outlines and Inline Tables for regular scenarios. As far as the wiki goes then I suggest a general entry with the heading "Tables". This page should contain a brief description of each type of table explaining where each is encountered together with links to their respective example. Nothing overly elaborate, just a single place to note that their is more than one type and that their employment and syntax differs somewhat. Cucumber is a marvellous tool, but the rate of enhancement ofttimes leaves me behind for a bit. However, I far prefer having to sprint now and then rather than dragging a moribund tool around behind me, wishing that it had this or did that. -- Posted via http://www.ruby-forum.com/. From caifara.subscribe at gmail.com Sat May 16 11:53:35 2009 From: caifara.subscribe at gmail.com (Ivo Dancet) Date: Sat, 16 May 2009 17:53:35 +0200 Subject: [rspec-users] [ANN] rSquery 0.1.1 In-Reply-To: <8d961d900905151247s4c82277fl58692be9d513050c@mail.gmail.com> References: <6C7F2248-77DD-4379-AA26-1127FD4C3EC9@gmail.com> <8d961d900905151247s4c82277fl58692be9d513050c@mail.gmail.com> Message-ID: <6D1E1750-6AD4-4E6C-914E-F3AD530257C3@gmail.com> Op 15-mei-09, om 21:47 heeft aslak hellesoy het volgende geschreven: >> Hello all >> >> rSquery aims to reduce the difficulties involved in writing >> selenium tests >> in cucumber environments for webapps that use jQuery. >> >> The project contains several methods to help you with writing >> javascript >> commands for selenium and javascript based tests for cucumber or >> even rSpec. >> > > Excellent! Please add it to the related tools page in the Cucumber > wiki (in alphabetical position) Done that > > >> It makes it possible to write stuff like (in jQuery enabled webapp): >> >> - jquery("#content").wait_for_visible >> - jquery("#dialog button:contains(Ok)").click >> - jquery.wait_for_text("User saved...") >> - jquery.wait_for_element(".some_element") >> - jquery("#dialog div").text.should have_text(/some_text/) >> - jquery("#dialog").find(".warning") >> - jquery("#dialog").html.should have_tag("button", "Ok") >> - jquery("#dialog").should be_visible >> - jquery("#dialog") # page must have an element with id 'dialog' >> > > Will it work with WebDriver? Selenium as we know it seems to be > EOL'ed soon... > http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html It won't work right out of the box as it uses selenium in the end. It should however be quite easy to rewrite the two commands that access selenium directly if WebDriver makes it possible to execute js in the loaded document. I did not really look into WebDriver yet, but is there a ruby api? Ivo Dancet by2.be > > > Aslak > >> The project is at http://github.com/caifara/rsquery/tree/master >> >> Ivo Dancet >> by2.be >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat May 16 11:57:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 May 2009 10:57:32 -0500 Subject: [rspec-users] Can I run the same specs with different gems? Ideas? In-Reply-To: References: Message-ID: <57c63afe0905160857m672cc893k46f1be7327cebf04@mail.gmail.com> On Fri, May 15, 2009 at 11:50 AM, Rick DeNatale wrote: > I have a new icalendar Ruby library/gem which is implemented so as > require an implementation of the TZInfo::Timezone class, but not to > care whether that implementation comes from the tzinfo gem, or the > activesupport gem in rails. ?It also will make use of the TimeWithZone > class in recent versions of activesupport if it's loaded, but it > leaves the decision of whether to load the activesuport or tzinfo gems > up to the user. > > Now, it that makes sense I'd like to be able to run my specs with the > tzinfo gen and then with the activesupport gem. ?Ideally I'd like to > have rake tasks like > > rake spec:tzinfo > rake spec:activesupport > rake spec:both > > The problem is that I think I need something like the fork option for > spec task similar to the one in the cucumber task, since once loaded I > can't unload one or the other gem in the same ruby process. > > Is there a trick I'm missing? Sounds like a missing feature, actually. RSpec's own suite has a forker, which I'm pretty sure that Aslak wrote and is likely the source of the cucumber option you're talking about, but it is not exposed as an API, yet. I think it should be. Wanna patch it? > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > WWR: http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn: http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From apremdas at gmail.com Sat May 16 13:49:41 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Sat, 16 May 2009 18:49:41 +0100 Subject: [rspec-users] Cucumber broke my rake tasks! 0.3.5 In-Reply-To: <8d961d900905151036r7e07ffbfyc5fda94fc963a495@mail.gmail.com> References: <88fd8ddc0905150304h346f7d41i451d4ce28cfddbae@mail.gmail.com> <4A0D8863.1020502@benmabey.com> <8d961d900905151036r7e07ffbfyc5fda94fc963a495@mail.gmail.com> Message-ID: <88fd8ddc0905161049x3c283569hd0f47c91ea4e5874@mail.gmail.com> 2009/5/15 aslak hellesoy : >> Andrew Premdas wrote: >>> >>> Seem to be having a problem with the new releases 0.3.5 which >>> completely breaks my rake tasks http://gist.github.com/112149. >>> >>> WIth the >>> >>> ?t.fork = true # Explicitly fork for cucumber 0.3.4 and rails >>> >>> lines added to the tasks none of my steps are recognised (see second >>> file in gists) >>> >>> Without t.fork line I get an error ?< undefined method `differ=' > >>> (trace in third file in gist) >>> >>> Running similar profiles using cucumber -p seems to work fine >>> >>> All best >>> >>> >> >> >> This looks similar to a ticket James opened earlier: >> https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/325-cucumber-v-035-load-behaviour-change >> >> Please follow that ticket and comment there if you agree. >> > > Can you all try to specify the lib attribute of the rake task? I think > that has something to do with this..... > > Aslak Sorry I don't understand what you mean by this, could you be more specific, perhaps a command to run or some more detail. Thanks Andrew From joe at pinkpucker.net Sat May 16 16:53:46 2009 From: joe at pinkpucker.net (Joe Van Dyk) Date: Sat, 16 May 2009 13:53:46 -0700 Subject: [rspec-users] Features running in development mode Message-ID: Hi, On my Rails app, when I run 'rake features', it runs it in development mode. Which is weird. And messes up my development database. What can I do to force it to run in test mode? Joe From aslak.hellesoy at gmail.com Sat May 16 17:32:22 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 16 May 2009 23:32:22 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: References: Message-ID: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> > Hi all, > > Does anyone have an example of how to get the cucumber-java simple example > running? I would like to use cucumber-java but cannot figure out how. > > I've gem installed cucumber and cucumber-java. When I run mvn clean package > in the simple directory, I get this error: > > 19:41:48 agentdh-2:~/Development/tools/cucumber_java/examples/simple > rbarlow$ mvn clean package > Using Java version: 1.5 > [INFO] Scanning for projects... > [INFO] > ------------------------------------------------------------------------ > [INFO] Building Cucumber Simple Example > [INFO]??? task-segment: [clean, package] > [INFO] > ------------------------------------------------------------------------ > Downloading: > http://repo1.maven.org/maven2/cucumber/cucumber-java-parent/0.0.2/cucumber-java-parent-0.0.2.pom > [INFO] > ------------------------------------------------------------------------ > [ERROR] BUILD ERROR > [INFO] > ------------------------------------------------------------------------ > [INFO] Failed to resolve artifact. > > GroupId: cucumber > ArtifactId: cucumber-java-parent > Version: 0.0.2 > > Reason: Unable to download the artifact from any repository > > ? cucumber:cucumber-java-parent:pom:0.0.2 > > from the specified remote repositories: > ? central (http://repo1.maven.org/maven2) > > > [INFO] > ------------------------------------------------------------------------ > [INFO] For more information, run Maven with the -e switch > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1 second > [INFO] Finished at: Sat May 16 19:41:52 BST 2009 > [INFO] Final Memory: 1M/3M > [INFO] > ------------------------------------------------------------------------ > > Any suggestions? Or does anyone have an equivalent ant script? > Try mvn install from the root folder first. Aslak > Cheers, > Raymond Barlow > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Sat May 16 17:33:52 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 16 May 2009 23:33:52 +0200 Subject: [rspec-users] Features running in development mode In-Reply-To: References: Message-ID: <8d961d900905161433o4d821ce7rb2c5506212f5db9c@mail.gmail.com> > Hi, > > On my Rails app, when I run 'rake features', it runs it in development > mode. ?Which is weird. ?And messes up my development database. > > What can I do to force it to run in test mode? > What Cucumber version are you on? Did you upgrade without reading the changelog? (History.txt) Aslak > Joe > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Sat May 16 17:37:31 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 16 May 2009 23:37:31 +0200 Subject: [rspec-users] Cucumber tables In-Reply-To: <4c2f468398f268479e63f8c42cc72fd9@ruby-forum.com> References: <60ea1eb12b658b3d5d8d1c071c690131@ruby-forum.com> <8d961d900905151056k3c5793ccqdf7a1829ca429fcc@mail.gmail.com> <93b1fec1e27798e8980b34ee9f01e4b9@ruby-forum.com> <8d961d900905151228r69134cfbyca4911519dc71194@mail.gmail.com> <8a7ee369b38e34af72922aa029d2362b@ruby-forum.com> <8d961d900905151357q43f37aceq10ec3424dc842c68@mail.gmail.com> <4c2f468398f268479e63f8c42cc72fd9@ruby-forum.com> Message-ID: <8d961d900905161437v2e602886gbd14d66f1b5e1724@mail.gmail.com> > Aslak Helles?y wrote: > >> >> Which terms do you think we should adopt and where in the wiki should >> this be emphasized more clearly? >> >> Aslak > > The best suggestion that I can come up with is: Outline Tables for > Scenario Outlines and Inline Tables for regular scenarios. > > As far as the wiki goes then I suggest a general entry with the heading > "Tables". ?This page should contain a brief description of each type of > table explaining where each is encountered together with links to their > respective example. ?Nothing overly elaborate, just a single place to Good idea > note that their is more than one type and that their employment and > syntax differs somewhat. > Their syntax is identical, but they have different semantics. > Cucumber is a marvellous tool, but the rate of enhancement ofttimes > leaves me ?behind for a bit. ?However, I far prefer having to sprint now > and then rather than dragging a moribund tool around behind me, wishing > that it had this or did that. Hehe. Thanks. Hopefully there won't be any major changes to the language from now on... Hopefully ;-) Aslak > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jeff.brown at gmail.com Sat May 16 19:09:55 2009 From: jeff.brown at gmail.com (Jeff Brown) Date: Sat, 16 May 2009 16:09:55 -0700 Subject: [rspec-users] RSpec support on .Net with Gallio. Message-ID: <35B097ECF1D846F2AD8563D6F4D3869F@Atom> Hi, I'm getting ready to produce an RSpec adapter for use with the Gallio test automation platform (http://www.gallio.org/) on the .Net DLR via IronRuby. The idea is to open up RSpec to a wider audience of .Net developers who might like to write their tests, *ahem* specs ;-), using a friendly syntax in a dynamically typed language such as Ruby. Anyways, this is still a work in progress but I wanted to check on a couple of legal points: 1. Is it cool to redistribute RSpec in source code form for non-commercial purposes? I was unable to find the RSpec license to confirm. Gallio itself is open source and is distributed using the Apache License 2.0. 2. I would like to be able to identify the RSpec framework by way of an icon in Gallio. Unfortunately I was unable to locate an official logo. Assuming there is one, I'd like permission to include an RSpec icon in Gallio. The icon will be used in the following ways: - As a plugin icon when displaying a list of associated plugins. - As a preference icon when providing options for configuring associated plugins. - As an installed feature icon when providing options for installing associated plugins. - As a test framework icon when decribing the list of supported test frameworks and when presenting a report about tests that have been run specifically using that framework. Do you have a suitable 16x16 and 32x32 icon file that I can use for this purpose? Thanks, Jeff. From rick.denatale at gmail.com Sat May 16 20:37:23 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 16 May 2009 20:37:23 -0400 Subject: [rspec-users] RSpec support on .Net with Gallio. In-Reply-To: <35B097ECF1D846F2AD8563D6F4D3869F@Atom> References: <35B097ECF1D846F2AD8563D6F4D3869F@Atom> Message-ID: On Sat, May 16, 2009 at 7:09 PM, Jeff Brown wrote: > Hi, > I'm getting ready to produce an RSpec adapter for use with the Gallio test > automation platform (http://www.gallio.org/) on the .Net DLR via IronRuby. > > The idea is to open up RSpec to a wider audience of .Net developers who > might like to write their tests, *ahem* specs ;-), using a friendly syntax > in a dynamically typed language such as Ruby. > > Anyways, this is still a work in progress but I wanted to check on a couple > of legal points: > > 1. Is it cool to redistribute RSpec in source code form for non-commercial > purposes? ?I was unable to find the RSpec license to confirm. ?Gallio itself > is open source and is distributed using the Apache License 2.0. RSpec is licensed under the MIT license: http://github.com/dchelimsky/rspec/blob/dfffe80e65067e8410f54d30b9de96a942b1fa10/License.txt -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From jeff.brown at gmail.com Sat May 16 22:52:42 2009 From: jeff.brown at gmail.com (Jeff Brown) Date: Sat, 16 May 2009 19:52:42 -0700 Subject: [rspec-users] RSpec support on .Net with Gallio. In-Reply-To: References: <35B097ECF1D846F2AD8563D6F4D3869F@Atom> Message-ID: <9AE5F978A7454913ABE979CF394DD7EF@Atom> Excellent that's what I wanted to hear. :-) Jeff. -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Rick DeNatale Sent: Saturday, May 16, 2009 5:37 PM To: rspec-users Subject: Re: [rspec-users] RSpec support on .Net with Gallio. On Sat, May 16, 2009 at 7:09 PM, Jeff Brown wrote: > Hi, > I'm getting ready to produce an RSpec adapter for use with the Gallio > test automation platform (http://www.gallio.org/) on the .Net DLR via IronRuby. > > The idea is to open up RSpec to a wider audience of .Net developers > who might like to write their tests, *ahem* specs ;-), using a > friendly syntax in a dynamically typed language such as Ruby. > > Anyways, this is still a work in progress but I wanted to check on a > couple of legal points: > > 1. Is it cool to redistribute RSpec in source code form for > non-commercial purposes? ?I was unable to find the RSpec license to > confirm. ?Gallio itself is open source and is distributed using the Apache License 2.0. RSpec is licensed under the MIT license: http://github.com/dchelimsky/rspec/blob/dfffe80e65067e8410f54d30b9de96a942b1 fa10/License.txt -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sun May 17 01:56:50 2009 From: lists at ruby-forum.com (Zhenning Guan) Date: Sun, 17 May 2009 07:56:50 +0200 Subject: [rspec-users] what's wrong with my newbie cucumber test? Message-ID: <784d429b97db99d32fe4a538c353340d@ruby-forum.com> forums.feature = Feature: Tasks In order to keep track of tasks People should be able to Create a list of tasks Scenario: List Tasks When I go to the homepage = forums_steps.rb = When /^I go to the homepage$/ do visit "/forums" end = when I run rake features. == Scenario: List Tasks # features/forums.feature:6 When I go to the homepage # features/forums.feature:7 Ambiguous match of "I go to the homepage": features/step_definitions/webrat_steps.rb:10:in `/^I go to (.+)$/' features/step_definitions/forums_steps.rb:1:in `/^I go to the homepage$/' You can run again with --guess to make Cucumber be more smart about it (Cucumber::Ambiguous) /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/step_mother.rb:210:in `step_match' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:50:in `find_step_match!' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:27:in `invoke' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:22:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:74:in `visit_step' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:124:in `visit_step' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_collection.rb:14:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_collection.rb:13:in `each' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_collection.rb:13:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:70:in `visit_steps' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/scenario.rb:29:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/step_mother.rb:236:in `before_and_after' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/scenario.rb:28:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:45:in `visit_feature_element' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:79:in `visit_feature_element' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:23:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:22:in `each' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:22:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:23:in `visit_feature' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:41:in `visit_feature' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/features.rb:21:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/features.rb:20:in `each' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/features.rb:20:in `accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:19:in `visit_features' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:26:in `visit_features' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:9:in `__send__' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:9:in `method_missing' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:8:in `map' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:8:in `method_missing' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:41:in `execute!' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:20:in `execute' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/cucumber:6 features/forums.feature:7:in `When I go to the homepage' 1 scenario (1 failed) 1 step (1 failed) rake aborted! Command failed with status (1): [/usr/bin/ruby -I "/home/ning/.gem/ruby/1.8...] == does anyone can tell me what's wrong with my test? -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Sun May 17 09:46:57 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 17 May 2009 09:46:57 -0400 Subject: [rspec-users] Can I run the same specs with different gems? Ideas? In-Reply-To: <57c63afe0905160857m672cc893k46f1be7327cebf04@mail.gmail.com> References: <57c63afe0905160857m672cc893k46f1be7327cebf04@mail.gmail.com> Message-ID: On Sat, May 16, 2009 at 11:57 AM, David Chelimsky wrote: > On Fri, May 15, 2009 at 11:50 AM, Rick DeNatale wrote: >> ?Ideally I'd like to >> have rake tasks like >> >> rake spec:tzinfo >> rake spec:activesupport >> rake spec:both >> >> The problem is that I think I need something like the fork option for >> spec task similar to the one in the cucumber task, since once loaded I >> can't unload one or the other gem in the same ruby process. >> >> Is there a trick I'm missing? > > Sounds like a missing feature, actually. RSpec's own suite has a > forker, which I'm pretty sure that Aslak wrote and is likely the > source of the cucumber option you're talking about, but it is not > exposed as an API, yet. I think it should be. Wanna patch it? Well, I looked it, and it seems that the RSpec spectask does in fact run rspec in a separate process using the system command. So I tried to make a spectask to run the specs after require in activesupport by adding this in my rake file: desc "Run all specs with activesupport" Spec::Rake::SpecTask.new(:spec_as) do |t| t.spec_opts = ['--options', "spec/spec.opts"] t.ruby_opts = ['-rrubygems', '-ractive_support'] t.spec_files = FileList['spec/**/*_spec.rb'] t.verbose = true end Unfortunately, it seems that the ruby command only handles a single -r option, the -rrubygems gets ignored and things fail because it can't find active_support.rb, the same thing happens if I just try: $ruby -rrubygems -ractive_support -e'puts "Hello"' Right now the only approach I can think of is to somehow set an environment variable which my spec helper would look at to determine whether to require activesupport, but I don't even know if that's possible with Kernel#system particularly in a platform independent way. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From lists at ruby-forum.com Sun May 17 11:51:35 2009 From: lists at ruby-forum.com (James Byrne) Date: Sun, 17 May 2009 17:51:35 +0200 Subject: [rspec-users] what's wrong with my newbie cucumber test? In-Reply-To: <784d429b97db99d32fe4a538c353340d@ruby-forum.com> References: <784d429b97db99d32fe4a538c353340d@ruby-forum.com> Message-ID: <70ca7d30daac58a20977f5448ac8dba4@ruby-forum.com> Zhenning Guan wrote: > > when I run rake features. > == > Scenario: List Tasks # features/forums.feature:6 > When I go to the homepage # features/forums.feature:7 > Ambiguous match of "I go to the homepage": > > features/step_definitions/webrat_steps.rb:10:in `/^I go to (.+)$/' > features/step_definitions/forums_steps.rb:1:in `/^I go to the > homepage$/' > > You can run again with --guess to make Cucumber be more smart > about it > (Cucumber::Ambiguous) > > does anyone can tell me what's wrong with my test? You have duplicate step matchers, one in webrat_steps.rb at line 10 and the other in forums_steps at line 1. The regexp /^I go to (.+)$/ matches the same thing as /^I go to the homepage$/. Change them so as to be more specific. /^ I go to the forum (.+)$/ and /^I go to the user homepage$/ Personally, I drop the leading pronoun together with the start/end of line symbols as well. /\bgo to the user homepage\b/ -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Sun May 17 12:00:46 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 17 May 2009 12:00:46 -0400 Subject: [rspec-users] Can I run the same specs with different gems? Ideas? In-Reply-To: References: <57c63afe0905160857m672cc893k46f1be7327cebf04@mail.gmail.com> Message-ID: On Sun, May 17, 2009 at 9:46 AM, Rick DeNatale wrote: > So I tried to make a spectask to run the specs after require in > activesupport by adding this in my rake file: > > desc "Run all specs with activesupport" > Spec::Rake::SpecTask.new(:spec_as) do |t| > ?t.spec_opts = ['--options', "spec/spec.opts"] > ?t.ruby_opts = ['-rrubygems', '-ractive_support'] > ?t.spec_files = FileList['spec/**/*_spec.rb'] > ?t.verbose = true > end > > Unfortunately, it seems that the ruby command only handles a single -r > option, the -rrubygems gets ignored and things fail because it can't > find active_support.rb, the same thing happens if I just try: > > $ruby -rrubygems -ractive_support -e'puts "Hello"' > > Right now the only approach I can think of is to somehow set an > environment variable which my spec helper would look at to determine > whether to require activesupport, but I don't even know if that's > possible with Kernel#system particularly in a platform independent > way. Follow up. I figured it out. The problem wasn't that Ruby doesn't allow multiple -r options, it was that the way it's done -rubygems -rsomegem won't work since -r doesn't use the same mechanism as require so that rubygems doesn't get involved. I fixed it by having an auxiliary .rb files which require rubygems and either activesupport or tzinfo and -r requiring that. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From adamandersonis at gmail.com Sun May 17 12:45:35 2009 From: adamandersonis at gmail.com (Adam Anderson) Date: Sun, 17 May 2009 09:45:35 -0700 Subject: [rspec-users] Including extra directories for Autospec Message-ID: <8d18f1f80905170945t6927777bn716e6f3111774186@mail.gmail.com> Is there a way to tell autospec for rails to run _all_ the spec files in the spec directory a la spec/**/*_spec.rb instead of just the ones in model/controller/etc? I've experimented with adding my own mappings in /.autotest but haven't had any luck. From matt at mattwynne.net Sun May 17 12:58:00 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 17 May 2009 17:58:00 +0100 Subject: [rspec-users] Rails HTML error page in the console. In-Reply-To: <4A0AE3A6.3040500@benmabey.com> References: <255D8CD4-9AB0-4CBB-94DD-40CEAA61E870@songkick.com> <4A0AE3A6.3040500@benmabey.com> Message-ID: <16E9A868-1714-40E2-B479-50CF7D6833A2@mattwynne.net> On 13 May 2009, at 16:13, Ben Mabey wrote: > Matt Wynne wrote: >> I'm still bugged by the fact that when I get an exception during a >> feature run (e.g. Couldn't find partial) then what I see in the >> console is all the HTML to report that error in a browser. >> >> I have had a few ideas for this bubbling around at the back of my >> mind. I wondered whether anyone else was thinking about this too. >> >> I guess the idea would be to patch rails's >> ActionController#rescue_action_locally with something that threw >> the exception out at Cucumber rather than bubbling it up to the >> web. What do you think? Would it work? What are the drawbacks I >> haven't thought of? >> >> cheers, >> Matt Wynne >> http://beta.songkick.com >> http://blog.mattwynne.net > > > Have you tried catching the error in an After block and opening up > the page? Aslak added that functionality: > > https://rspec.lighthouseapp.com/projects/16211/tickets/272-pick-up-failure-on-after-hook > > -Ben I think I've actually realised this must be happening because we're using an old version of webrat - I've just set up a fresh rails app with shiny new cucumber and webrat version and it reports just the exception backtrace in the console, rather than the whole HTML error page. That hook is handy though, thanks for the tip Ben. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Sun May 17 13:08:17 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 17 May 2009 18:08:17 +0100 Subject: [rspec-users] Rails HTML error page in the console. In-Reply-To: <6ffb72010905130340n4fc1d101i3bd1ad848b3967f0@mail.gmail.com> References: <255D8CD4-9AB0-4CBB-94DD-40CEAA61E870@songkick.com> <6ffb72010905130340n4fc1d101i3bd1ad848b3967f0@mail.gmail.com> Message-ID: On 13 May 2009, at 11:40, Ben Lovell wrote: > On Wed, May 13, 2009 at 8:42 AM, Matt Wynne > wrote: > This is definitely something that irks me regularly too. If the HTML > displayed were more focused to the actual section that was under > inspection that would be hella nice. Although, I realise this would > be pretty difficult to achieve. That said, there certainly are times > when you _need_ to see the whole HTML. > > Ben L I think we're talking about different things actually. Do you know about the #within method in webrat? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Sun May 17 17:31:22 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 May 2009 16:31:22 -0500 Subject: [rspec-users] Including extra directories for Autospec In-Reply-To: <8d18f1f80905170945t6927777bn716e6f3111774186@mail.gmail.com> References: <8d18f1f80905170945t6927777bn716e6f3111774186@mail.gmail.com> Message-ID: <57c63afe0905171431m7828bed4tddb95d11b6f84aec@mail.gmail.com> On Sun, May 17, 2009 at 11:45 AM, Adam Anderson wrote: > Is there a way to tell autospec for rails to run _all_ the spec files > in the spec directory a la spec/**/*_spec.rb instead of just the ones > in model/controller/etc? I've experimented with adding my own mappings > in /.autotest but haven't had any luck. See if this helps: http://blog.davidchelimsky.net/2008/01/15/rspec-1-1-2-and-zentest-3-8-0/ From adamandersonis at gmail.com Sun May 17 19:24:49 2009 From: adamandersonis at gmail.com (Adam Anderson) Date: Sun, 17 May 2009 16:24:49 -0700 Subject: [rspec-users] Including extra directories for Autospec In-Reply-To: <57c63afe0905171431m7828bed4tddb95d11b6f84aec@mail.gmail.com> References: <8d18f1f80905170945t6927777bn716e6f3111774186@mail.gmail.com> <57c63afe0905171431m7828bed4tddb95d11b6f84aec@mail.gmail.com> Message-ID: <8d18f1f80905171624y7a4d8716jbf322cf50ad82aa7@mail.gmail.com> I'm really not sure what I'm doing wrong so I tried started from scratch still with no positive results. Here's my setup: rails 2.3.2 rspec 1.2.6 rspec-rails 1.2.6 ZenTest 4.0.0 Here's what I did: $ rails foo $ cd foo $ ./script/generate rspec $ ./script/generate rspec_model Bar $ rake db:migrate RAILS_ENV=test $ autospec # => runs and passes one example $ mkdir spec/something $ touch ./autotest spec/something/lol_spec.rb $ autospec -v # => correctly does not find a mapping for spec/something/lol_spec.rb Then I edit the files like so: ./autotest: Autotest.add_hook :initialize do |at| at.add_mapping(%r%^spec/something/.*_spec\.rb$%) do at.files_matching(%r%^spec/something/.*_spec\.rb$%) end end spec/something/lol_spec.rb: describe "Lol" do it "should do a thing" do false.should be_true end end $ autospec -v # => still not finding a match for spec/something/lol_spec.rb loading autotest/rails_rspec No tests matched app/helpers/application_helper.rb No tests matched spec/rcov.opts No tests matched test/test_helper.rb No tests matched lib/tasks/rspec.rake No tests matched Rakefile No tests matched README No tests matched .autotest No tests matched spec/something/lol_spec.rb No tests matched test/performance/browsing_test.rb No tests matched spec/spec.opts /opt/local/bin/ruby /opt/local/lib/ruby/gems/1.8/gems/rspec-1.2.6/bin/spec --autospec spec/models/bar_spec.rb -O spec/spec.opts . Finished in 0.135414 seconds 1 example, 0 failures # Waiting since 2009-05-17 16:22:56 Sorry to be so verbose but I'm honestly very lost at this point... I've also tried variations of this the add_mapping method by using the block variables but no go. -Adam On Sun, May 17, 2009 at 2:31 PM, David Chelimsky wrote: > On Sun, May 17, 2009 at 11:45 AM, Adam Anderson > wrote: >> Is there a way to tell autospec for rails to run _all_ the spec files >> in the spec directory a la spec/**/*_spec.rb instead of just the ones >> in model/controller/etc? I've experimented with adding my own mappings >> in /.autotest but haven't had any luck. > > See if this helps: > http://blog.davidchelimsky.net/2008/01/15/rspec-1-1-2-and-zentest-3-8-0/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sun May 17 22:44:13 2009 From: lists at ruby-forum.com (Jason Calleiro) Date: Mon, 18 May 2009 04:44:13 +0200 Subject: [rspec-users] New setup error. no such file to load -- spec/story Message-ID: <864a324e1885e3949b7769fd4eb7c14c@ruby-forum.com> gems: rspec (1.2.6) rspec-rails (1.2.6) cucumber (0.3.4, 0.3.2) webrat (0.4.4) Just got my new machine (I'm learning rails, im a front end designer). pulled a repo that we've been working on to run rake and get started and im getting this error. /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- spec/story (MissingSourceFile) from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /Users/jasoncalleiro/Dev/Ruby/ventnation/spec/spec_helper.rb:4 from ./spec/controllers/categories_controller_spec.rb:1:in `require' from ./spec/controllers/categories_controller_spec.rb:1 from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in `load' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in `each' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options.rb:99:in `run_examples' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/command_line.rb:9:in `run' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/bin/spec:4 rake aborted! Command /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I"/Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib" "/Library/Ruby/Gems/1.8/gems/rspec-1.2.6/bin/spec" "spec/controllers/categories_controller_spec.rb" "spec/controllers/vents_controller_spec.rb" "spec/models/category_spec.rb" "spec/models/message_vent_spec.rb" "spec/models/user_spec.rb" "spec/models/video_vent_spec.rb" --options "/Users/jasoncalleiro/Dev/Ruby/ventnation/spec/spec.opts" failed Tried to doing the google search thing but dont really come up with anything. Let me know if you can help, Thanks! Jason -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon May 18 04:02:18 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 10:02:18 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> Message-ID: <8d961d900905180102u5b99a52bhb0c35fddfed89044@mail.gmail.com> On Sun, May 17, 2009 at 12:01 AM, Raymond Barlow wrote: > OK, that seemed to help a bit. That installed a bunch of stuff, and then I > did the mvn clean package in the examples directory--which built the example > jar. > > So I guess my next step would be to > cucumber features > in the featuers directory of the simple example? > > I tried this a got an error about pico_container. So I thought that maybe I > hadn't setup correctly. > Can you tell us exactly what the error and stacktrace was. > So, back to the start. > > did > jruby -S gem install hoe --no-rdoc --no-ri > and that worked fine. > > The next step listed on the cucumber-java page is to > jruby -S rake gem > > when I do this, I get this error: > (in /Users/rbarlow/Development/tools/cucumber_java) > rake aborted! > Don't know how to build task 'gem' > > (See full trace by running task with --trace) > > Am I perhaps in the wrong directory when I do this? > > > > Sorry, just feeling my way around at the moment. > Sorry about the sparse documentation. I think we should yank all the README files and start using the wiki instead. Any objections? > > Cheers! > Raymond Barlow > 2009/5/16 aslak hellesoy >> >> > Hi all, >> > >> > Does anyone have an example of how to get the cucumber-java simple >> > example >> > running? I would like to use cucumber-java but cannot figure out how. >> > >> > I've gem installed cucumber and cucumber-java. When I run mvn clean >> > package >> > in the simple directory, I get this error: >> > >> > 19:41:48 agentdh-2:~/Development/tools/cucumber_java/examples/simple >> > rbarlow$ mvn clean package >> > Using Java version: 1.5 >> > [INFO] Scanning for projects... >> > [INFO] >> > ------------------------------------------------------------------------ >> > [INFO] Building Cucumber Simple Example >> > [INFO]??? task-segment: [clean, package] >> > [INFO] >> > ------------------------------------------------------------------------ >> > Downloading: >> > >> > http://repo1.maven.org/maven2/cucumber/cucumber-java-parent/0.0.2/cucumber-java-parent-0.0.2.pom >> > [INFO] >> > ------------------------------------------------------------------------ >> > [ERROR] BUILD ERROR >> > [INFO] >> > ------------------------------------------------------------------------ >> > [INFO] Failed to resolve artifact. >> > >> > GroupId: cucumber >> > ArtifactId: cucumber-java-parent >> > Version: 0.0.2 >> > >> > Reason: Unable to download the artifact from any repository >> > >> > ? cucumber:cucumber-java-parent:pom:0.0.2 >> > >> > from the specified remote repositories: >> > ? central (http://repo1.maven.org/maven2) >> > >> > >> > [INFO] >> > ------------------------------------------------------------------------ >> > [INFO] For more information, run Maven with the -e switch >> > [INFO] >> > ------------------------------------------------------------------------ >> > [INFO] Total time: 1 second >> > [INFO] Finished at: Sat May 16 19:41:52 BST 2009 >> > [INFO] Final Memory: 1M/3M >> > [INFO] >> > ------------------------------------------------------------------------ >> > >> > Any suggestions? Or does anyone have an equivalent ant script? >> > >> >> Try mvn install from the root folder first. >> >> Aslak >> >> > Cheers, >> > Raymond Barlow >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon May 18 04:57:38 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 10:57:38 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> <8d961d900905180102u5b99a52bhb0c35fddfed89044@mail.gmail.com> Message-ID: <8d961d900905180157m4a59f353r6015677eaee6b161@mail.gmail.com> > > > On Mon, May 18, 2009 at 10:02 AM, aslak hellesoy > wrote: >> >> On Sun, May 17, 2009 at 12:01 AM, Raymond Barlow >> wrote: >> > OK, that seemed to help a bit. That installed a bunch of stuff, and then >> > I >> > did the mvn clean package in the examples directory--which built the >> > example >> > jar. >> > >> > So I guess my next step would be to >> > cucumber features >> > in the featuers directory of the simple example? >> > >> > I tried this a got an error about pico_container. So I thought that >> > maybe I >> > hadn't setup correctly. >> > >> >> Can you tell us exactly what the error and stacktrace was. >> >> > So, back to the start. >> > >> > did >> > jruby -S gem install hoe --no-rdoc --no-ri >> > and that worked fine. >> > >> > The next step listed on the cucumber-java page is to >> > jruby -S rake gem >> > >> > when I do this, I get this error: >> > (in /Users/rbarlow/Development/tools/cucumber_java) >> > rake aborted! >> > Don't know how to build task 'gem' >> > >> > (See full trace by running task with --trace) >> > >> > Am I perhaps in the wrong directory when I do this? >> > >> > >> > >> > Sorry, just feeling my way around at the moment. >> > >> >> Sorry about the sparse documentation. I think we should yank all the >> README files and start using the wiki instead. Any objections? > > Should development information be stacked in the wiki? I agree that the > README files are in desperate need of a cleanup.. > I think it should. There is a very blurry line between user doc and developer doc, and by having it in the Wiki it's easier for everyone to improve it. Aslak >> >> > >> > Cheers! >> > Raymond Barlow >> > 2009/5/16 aslak hellesoy >> >> >> >> > Hi all, >> >> > >> >> > Does anyone have an example of how to get the cucumber-java simple >> >> > example >> >> > running? I would like to use cucumber-java but cannot figure out how. >> >> > >> >> > I've gem installed cucumber and cucumber-java. When I run mvn clean >> >> > package >> >> > in the simple directory, I get this error: >> >> > >> >> > 19:41:48 agentdh-2:~/Development/tools/cucumber_java/examples/simple >> >> > rbarlow$ mvn clean package >> >> > Using Java version: 1.5 >> >> > [INFO] Scanning for projects... >> >> > [INFO] >> >> > >> >> > ------------------------------------------------------------------------ >> >> > [INFO] Building Cucumber Simple Example >> >> > [INFO]??? task-segment: [clean, package] >> >> > [INFO] >> >> > >> >> > ------------------------------------------------------------------------ >> >> > Downloading: >> >> > >> >> > >> >> > http://repo1.maven.org/maven2/cucumber/cucumber-java-parent/0.0.2/cucumber-java-parent-0.0.2.pom >> >> > [INFO] >> >> > >> >> > ------------------------------------------------------------------------ >> >> > [ERROR] BUILD ERROR >> >> > [INFO] >> >> > >> >> > ------------------------------------------------------------------------ >> >> > [INFO] Failed to resolve artifact. >> >> > >> >> > GroupId: cucumber >> >> > ArtifactId: cucumber-java-parent >> >> > Version: 0.0.2 >> >> > >> >> > Reason: Unable to download the artifact from any repository >> >> > >> >> > ? cucumber:cucumber-java-parent:pom:0.0.2 >> >> > >> >> > from the specified remote repositories: >> >> > ? central (http://repo1.maven.org/maven2) >> >> > >> >> > >> >> > [INFO] >> >> > >> >> > ------------------------------------------------------------------------ >> >> > [INFO] For more information, run Maven with the -e switch >> >> > [INFO] >> >> > >> >> > ------------------------------------------------------------------------ >> >> > [INFO] Total time: 1 second >> >> > [INFO] Finished at: Sat May 16 19:41:52 BST 2009 >> >> > [INFO] Final Memory: 1M/3M >> >> > [INFO] >> >> > >> >> > ------------------------------------------------------------------------ >> >> > >> >> > Any suggestions? Or does anyone have an equivalent ant script? >> >> > >> >> >> >> Try mvn install from the root folder first. >> >> >> >> Aslak >> >> >> >> > Cheers, >> >> > Raymond Barlow >> >> > >> >> > _______________________________________________ >> >> > rspec-users mailing list >> >> > rspec-users at rubyforge.org >> >> > http://rubyforge.org/mailman/listinfo/rspec-users >> >> > >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > TronD > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon May 18 05:30:39 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Mon, 18 May 2009 11:30:39 +0200 Subject: [rspec-users] REG: Colour setting for html logs Message-ID: Hi, When i run some testcases using cucumber sample.feature --format html>features.html. 1) After execution, By default in the html file, background colour is black. How can i set the background color any other colour i want. Like we can set other passed, failed colours using the below command. export CUCUMBER_COLORS=passed=white 2) The generated HTML just gives the scenarios description but its doest not show then no of scenarious passed or failed e.tc How can get the information in htmloutput as well. Please help me in this regard. Thanks, Anil kumar -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Mon May 18 06:08:25 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Mon, 18 May 2009 11:08:25 +0100 Subject: [rspec-users] REG: Colour setting for html logs In-Reply-To: References: Message-ID: <4A113399.204@josephwilk.net> Anil Gollaa wrote: > Hi, > When i run some testcases using cucumber sample.feature --format > html>features.html. > > 1) After execution, By default in the html file, background colour is > black. > How can i set the background color any other colour i want. Like we can > set > other passed, failed colours using the below command. > > export CUCUMBER_COLORS=passed=white > Currently we do not support customising any of the colours in the HTML formatter. These are all defined within a css file. Rather than passing colours on the command line for the HTML formatter I would prefer if you could specify your own css file to use. Perhaps: @@@ cucumber --format html --css my_own_special_colours.css @@@ The other option which is possible now is to create your own formatter (http://wiki.github.com/aslakhellesoy/cucumber/custom-formatters) extending the HTML formatter. Overide 'def inline_css' so that it provides your own CSS file. > 2) The generated HTML just gives the scenarios description but its doest > not show then no of scenarious passed or failed e.tc > How can get the information in htmloutput as well. > > We have a ticket open on this, please direct any input they have there. https://rspec.lighthouseapp.com/projects/16211/tickets/285-html-formatter-summary > Please help me in this regard. > > Thanks, > Anil kumar > HTH, -- Joseph Wilk http://blog.josephwilk.net From aslak.hellesoy at gmail.com Mon May 18 07:53:34 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 13:53:34 +0200 Subject: [rspec-users] REG: Colour setting for html logs In-Reply-To: <4A113399.204@josephwilk.net> References: <4A113399.204@josephwilk.net> Message-ID: <8d961d900905180453n14df7d24ib231295bf1f4462c@mail.gmail.com> > Anil Gollaa wrote: >> >> Hi, >> When i run some testcases using cucumber sample.feature --format >> html>features.html. >> >> 1) After execution, By default in the html file, background colour is >> black. >> How can i set the background color any other colour i want. Like we can >> set >> other passed, failed colours using the below command. >> >> export CUCUMBER_COLORS=passed=white >> > > Currently we do not support customising any of the colours in the HTML > formatter. These are all defined within a css file. > > Rather than passing colours on the command line for the HTML formatter I > would prefer if you could specify your own css file to use. > > Perhaps: > @@@ > cucumber --format html --css my_own_special_colours.css > @@@ > > The other option which is possible now is to create your own formatter > (http://wiki.github.com/aslakhellesoy/cucumber/custom-formatters) extending > the HTML formatter. Overide 'def inline_css' so that it provides your own > CSS file. This is the option I recommend. I'm not keen on adding a new switch to the cucumber command line just to accommodate for one of the formatters. >> >> 2) The generated HTML just gives the scenarios description but its doest >> not show then no of scenarious passed or failed e.tc >> How can get the information in htmloutput as well. >> >> > > We have a ticket open on this, please direct any input they have there. > https://rspec.lighthouseapp.com/projects/16211/tickets/285-html-formatter-summary >> >> Please help me in this regard. Please help us by providing a patch. Aslak >> >> Thanks, >> Anil kumar >> > > > HTH, > -- > Joseph Wilk > http://blog.josephwilk.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon May 18 08:09:12 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 14:09:12 +0200 Subject: [rspec-users] Cucumber broke my rake tasks! 0.3.5 In-Reply-To: <88fd8ddc0905161049x3c283569hd0f47c91ea4e5874@mail.gmail.com> References: <88fd8ddc0905150304h346f7d41i451d4ce28cfddbae@mail.gmail.com> <4A0D8863.1020502@benmabey.com> <8d961d900905151036r7e07ffbfyc5fda94fc963a495@mail.gmail.com> <88fd8ddc0905161049x3c283569hd0f47c91ea4e5874@mail.gmail.com> Message-ID: <8d961d900905180509p4048b6ffv85e2c5aeced994f@mail.gmail.com> > 2009/5/15 aslak hellesoy : >>> Andrew Premdas wrote: >>>> >>>> Seem to be having a problem with the new releases 0.3.5 which >>>> completely breaks my rake tasks http://gist.github.com/112149. >>>> >>>> WIth the >>>> >>>> ?t.fork = true # Explicitly fork for cucumber 0.3.4 and rails >>>> >>>> lines added to the tasks none of my steps are recognised (see second >>>> file in gists) >>>> >>>> Without t.fork line I get an error ?< undefined method `differ=' > >>>> (trace in third file in gist) >>>> >>>> Running similar profiles using cucumber -p seems to work fine >>>> >>>> All best >>>> >>>> >>> >>> >>> This looks similar to a ticket James opened earlier: >>> https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/325-cucumber-v-035-load-behaviour-change >>> >>> Please follow that ticket and comment there if you agree. >>> >> >> Can you all try to specify the lib attribute of the rake task? I think >> that has something to do with this..... >> >> Aslak > > Sorry I don't understand what you mean by this, could you be more > specific, perhaps a command to run or some more detail. > The Rake task has a lib attribute (t.libs = ...). Could you try to set that? http://rdoc.info/projects/aslakhellesoy/cucumber http://rdoc.info/rdoc/aslakhellesoy/cucumber/blob/50d4738d4dbfda681333d49dcb2f4d27d91a0156/Cucumber/Rake/Task.html Aslak > Thanks > > Andrew > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lawrence.pit at gmail.com Mon May 18 08:04:27 2009 From: lawrence.pit at gmail.com (lawrence.pit) Date: Mon, 18 May 2009 05:04:27 -0700 (PDT) Subject: [rspec-users] running 1 example Message-ID: <5e9bfa52-c4d6-43d8-9c9e-a5828c4518cf@x1g2000prh.googlegroups.com> Hi, Suppose you have a file with dozens of examples within several describe/context blocks, and you wanted to focus on just one example. Is there an easy way to run just that one example instead of all the examples in the file? Cheers, Lawrence From mikael.vik at bekk.no Mon May 18 07:05:31 2009 From: mikael.vik at bekk.no (mikaelvik) Date: Mon, 18 May 2009 04:05:31 -0700 (PDT) Subject: [rspec-users] [Cucumber] JUnit, Spring and autowiring Message-ID: <23595316.post@talk.nabble.com> We are having trouble with JUnit-tests that are doing dependency injection in the setup of database connections. The stacktrace identifies autowiring of sessionFactory as the problem. During bean creation of sessionFactory we get a NoSuchMethodError; probably because of trouble when initializing the cglib class net.sf.cglib.proxy.Enhancer. I am using cucumber-maven-plugin on a pretty standard Spring project with Spring MVC, Hibernate and Java 1.6, deploying to Tomcat and Jetty. -- Test Class (autowiring daoImpl): [code=java] @ContextConfiguration(locations = {"/test-config-db.xml"}) @RunWith(SpringJUnit4ClassRunner.class) public class SdbCollectorDbTest { @Autowired private EventFactory eventFactory; @Autowired @Qualifier("sdbDaoImpl") // tried using autowiring by name, it made no difference protected SdbDao sdbDao; [/code] -- DaoImpl (autowiring sessionFactory): [code=java] @Repository @Qualifier("sdbDaoImpl") // tried using autowiring by name, it made no difference @Transactional(readOnly = true) public class SdbDaoImpl implements SdbDao { @Autowired private SessionFactory sessionFactory; [/code] -- Bean-config for sessionFactory and transactionManager: [code=xml] ... cut... ...cut... [/code] -- Stacktrace: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:203) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:93) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:130) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:99) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sdbDaoImpl': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory .SdbDaoImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [datasource.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:42) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:173) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:199) ... 22 more Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory .adiseksport.dao.SdbDaoImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [datasource.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435) at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240) ... 39 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [datasource.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412) ... 41 more Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V at net.sf.cglib.core.DebuggingClassWriter.(DebuggingClassWriter.java:47) at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104) at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117) at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43) at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162) at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:135) at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:55) at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56) at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:302) at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:434) at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:226) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) ... 53 more -- View this message in context: http://www.nabble.com/-Cucumber--JUnit%2C-Spring-and-autowiring-tp23595316p23595316.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Mon May 18 09:46:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 May 2009 08:46:10 -0500 Subject: [rspec-users] running 1 example In-Reply-To: <5e9bfa52-c4d6-43d8-9c9e-a5828c4518cf@x1g2000prh.googlegroups.com> References: <5e9bfa52-c4d6-43d8-9c9e-a5828c4518cf@x1g2000prh.googlegroups.com> Message-ID: <57c63afe0905180646s584d0329g79c06c1feb09e40b@mail.gmail.com> On Mon, May 18, 2009 at 7:04 AM, lawrence.pit wrote: > Hi, > > Suppose you have a file with dozens of examples within several > describe/context blocks, and you wanted to focus on just one example. > Is there an easy way to run just that one example instead of all the > examples in the file? $ spec --help ... -l, --line LINE_NUMBER Execute example group or example at given line. ... HTH, David > > > > Cheers, > Lawrence > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon May 18 09:59:35 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 May 2009 14:59:35 +0100 Subject: [rspec-users] New setup error. no such file to load -- spec/story In-Reply-To: <864a324e1885e3949b7769fd4eb7c14c@ruby-forum.com> References: <864a324e1885e3949b7769fd4eb7c14c@ruby-forum.com> Message-ID: <61C30CD6-BC41-4BE0-BF44-FE642C168E0E@mattwynne.net> On 18 May 2009, at 03:44, Jason Calleiro wrote: > gems: > rspec (1.2.6) > rspec-rails (1.2.6) > cucumber (0.3.4, 0.3.2) > webrat (0.4.4) > > Just got my new machine (I'm learning rails, im a front end designer). > pulled a repo that we've been working on to run rake and get started > and > im getting this error. > > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require': no such file to load -- spec/story > (MissingSourceFile) > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require' > from > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/ > dependencies.rb:158:in > `require' > from /Users/jasoncalleiro/Dev/Ruby/ventnation/spec/spec_helper.rb:4 This looks like the problem here. Can you show us line 4 of your spec_helper file? > > from ./spec/controllers/categories_controller_spec.rb:1:in `require' > from ./spec/controllers/categories_controller_spec.rb:1 > from > /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/ > example_group_runner.rb:15:in > `load' > from > /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/ > example_group_runner.rb:15:in > `load_files' > from > /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/ > example_group_runner.rb:14:in > `each' > from > /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/ > example_group_runner.rb:14:in > `load_files' > from > /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options.rb: > 99:in > `run_examples' > from > /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/ > command_line.rb:9:in > `run' > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/bin/spec:4 > rake aborted! > Command > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby > -I"/Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib" > "/Library/Ruby/Gems/1.8/gems/rspec-1.2.6/bin/spec" > "spec/controllers/categories_controller_spec.rb" > "spec/controllers/vents_controller_spec.rb" > "spec/models/category_spec.rb" "spec/models/message_vent_spec.rb" > "spec/models/user_spec.rb" "spec/models/video_vent_spec.rb" --options > "/Users/jasoncalleiro/Dev/Ruby/ventnation/spec/spec.opts" failed > > > Tried to doing the google search thing but dont really come up with > anything. Let me know if you can help, Thanks! > > Jason > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Mon May 18 10:04:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 May 2009 09:04:37 -0500 Subject: [rspec-users] New setup error. no such file to load -- spec/story In-Reply-To: <61C30CD6-BC41-4BE0-BF44-FE642C168E0E@mattwynne.net> References: <864a324e1885e3949b7769fd4eb7c14c@ruby-forum.com> <61C30CD6-BC41-4BE0-BF44-FE642C168E0E@mattwynne.net> Message-ID: <57c63afe0905180704r7aae9575i350708cd5d762e96@mail.gmail.com> On Mon, May 18, 2009 at 8:59 AM, Matt Wynne wrote: > > On 18 May 2009, at 03:44, Jason Calleiro wrote: > >> gems: >> rspec (1.2.6) >> rspec-rails (1.2.6) >> cucumber (0.3.4, 0.3.2) >> webrat (0.4.4) >> >> Just got my new machine (I'm learning rails, im a front end designer). >> pulled a repo that we've been working on to run rake and get started and >> im getting this error. >> >> /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require': no such file to load -- spec/story >> (MissingSourceFile) >> ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' >> ?from >> >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in >> `require' >> ?from /Users/jasoncalleiro/Dev/Ruby/ventnation/spec/spec_helper.rb:4 > > This looks like the problem here. Can you show us line 4 of your spec_helper > file? I'm pretty sure it's because you didn't run "script/generate rspec" when you upgraded to 1.2.x. 'spec/story' loaded rspec's story runner, which hasn't been part of rspec since pre 1.2. > >> >> ?from ./spec/controllers/categories_controller_spec.rb:1:in `require' >> ?from ./spec/controllers/categories_controller_spec.rb:1 >> ?from >> >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in >> `load' >> ?from >> >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:15:in >> `load_files' >> ?from >> >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in >> `each' >> ?from >> >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example_group_runner.rb:14:in >> `load_files' >> ?from >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options.rb:99:in >> `run_examples' >> ?from >> >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib/spec/runner/command_line.rb:9:in >> `run' >> ?from /Library/Ruby/Gems/1.8/gems/rspec-1.2.6/bin/spec:4 >> rake aborted! >> Command >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby >> -I"/Library/Ruby/Gems/1.8/gems/rspec-1.2.6/lib" >> "/Library/Ruby/Gems/1.8/gems/rspec-1.2.6/bin/spec" >> "spec/controllers/categories_controller_spec.rb" >> "spec/controllers/vents_controller_spec.rb" >> "spec/models/category_spec.rb" "spec/models/message_vent_spec.rb" >> "spec/models/user_spec.rb" "spec/models/video_vent_spec.rb" --options >> "/Users/jasoncalleiro/Dev/Ruby/ventnation/spec/spec.opts" failed >> >> >> Tried to doing the google search thing but dont really come up with >> anything. Let me know if you can help, Thanks! >> >> Jason From apremdas at gmail.com Mon May 18 10:09:28 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 18 May 2009 15:09:28 +0100 Subject: [rspec-users] Cucumber broke my rake tasks! 0.3.5 In-Reply-To: <8d961d900905180509p4048b6ffv85e2c5aeced994f@mail.gmail.com> References: <88fd8ddc0905150304h346f7d41i451d4ce28cfddbae@mail.gmail.com> <4A0D8863.1020502@benmabey.com> <8d961d900905151036r7e07ffbfyc5fda94fc963a495@mail.gmail.com> <88fd8ddc0905161049x3c283569hd0f47c91ea4e5874@mail.gmail.com> <8d961d900905180509p4048b6ffv85e2c5aeced994f@mail.gmail.com> Message-ID: <88fd8ddc0905180709o998ecb2n43c3ac2ee12b48e0@mail.gmail.com> Sorry for being a bit slow, but what would you like me to set it to?? 2009/5/18 aslak hellesoy : >> 2009/5/15 aslak hellesoy : >>>> Andrew Premdas wrote: >>>>> >>>>> Seem to be having a problem with the new releases 0.3.5 which >>>>> completely breaks my rake tasks http://gist.github.com/112149. >>>>> >>>>> WIth the >>>>> >>>>> ?t.fork = true # Explicitly fork for cucumber 0.3.4 and rails >>>>> >>>>> lines added to the tasks none of my steps are recognised (see second >>>>> file in gists) >>>>> >>>>> Without t.fork line I get an error ?< undefined method `differ=' > >>>>> (trace in third file in gist) >>>>> >>>>> Running similar profiles using cucumber -p seems to work fine >>>>> >>>>> All best >>>>> >>>>> >>>> >>>> >>>> This looks similar to a ticket James opened earlier: >>>> https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/325-cucumber-v-035-load-behaviour-change >>>> >>>> Please follow that ticket and comment there if you agree. >>>> >>> >>> Can you all try to specify the lib attribute of the rake task? I think >>> that has something to do with this..... >>> >>> Aslak >> >> Sorry I don't understand what you mean by this, could you be more >> specific, perhaps a command to run or some more detail. >> > > The Rake task has a lib attribute (t.libs = ...). Could you try to set that? > > http://rdoc.info/projects/aslakhellesoy/cucumber > http://rdoc.info/rdoc/aslakhellesoy/cucumber/blob/50d4738d4dbfda681333d49dcb2f4d27d91a0156/Cucumber/Rake/Task.html > > Aslak > >> Thanks >> >> Andrew >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 lee.hambley at gmail.com Mon May 18 10:13:01 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Mon, 18 May 2009 15:13:01 +0100 Subject: [rspec-users] List Split Message-ID: I'm honestly sure that nobody cares, but this list needs to split, I can't handle the volume of `junk` that is completely irrelevant because I am subscribed looking for to keep up to date with cucumber wisdom; I'm going to see how this message is received, and unsubscribe myself later today. The SNR ratio is absurd, and the list users should really consider a split. Thanks for the things I've learned, and the tips and tricks that I have been fortunate enough to pick up. - Lee -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis at haskinferguson.net Mon May 18 11:02:40 2009 From: denis at haskinferguson.net (Denis Haskin) Date: Mon, 18 May 2009 11:02:40 -0400 Subject: [rspec-users] Recommendations on multi-view scenarios? Message-ID: <4A117890.3010201@haskinferguson.net> I'm trying to find out best practices for a multi-view scenario. Take the classic example of ecommerce, where you might first enter address information, then credit card information, then confirm it all and the purchase is made. Seems to me this has to be done with a separate scenario for each view? The whole process would be: Scenario: I purchase a widget by paying for it with a credit card Given I am logged in as Sheila And I have a widget in my cart that costs $5 When I press "Checkout" And enter my address information And press "OK" And enter my credit card information And press "OK" And press "OK" Then my credit card balance should be reduced by $5 And I have a completed transaction in my order history But that seems really really wrong. So I assume it needs to be like this? Scenario: I purchase a widget by entering my address information Given I am logged in as Sheila And I have a widget in my cart that costs $5 When I press "Checkout" And enter complete address information And press "OK" Then I do not get an error message And I am on the "credit card information" page Scenario: I purchase a widget by entering my credit card information Given I am logged in as Sheila And I have a widget in my cart that costs $5 And I am on the "credit card information page" When I enter valid credit card information And press OK" Then I do not get an error message And I am on the "confirm purchase" page ...etc... Yes? No? Examples? Thanks, dwh From wayne.simacek at gmail.com Mon May 18 11:31:03 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Mon, 18 May 2009 08:31:03 -0700 (PDT) Subject: [rspec-users] Fixture::FormatError parsing YAML Message-ID: Hi, I'm trying to test restful_authentication plugin and am getting errors with my install. ==>I've been through the YAML specification and actually copied the fixture file into word looking for tabs instead of spaces. I've played with various parts of the formatting, but I need a fresh pair of eyes on this one. 1) Error: test_the_truth(PostTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object Here's the related fixtures.yml quentin: id: 1 login: quentin email: quentin at example.com salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 created_at: <%= 5.days.ago.to_s :db %> <% if options[:include_activation] %> activation_code: 8f24789ae988411ccf33ab0c30fe9106fab32e9b <% end %> <% if options[:include_activation] %> activated_at: <%= 5.days.ago.to_s :db %> <% end %> <% if options[:stateful] %> state: active<% end %> aaron: id: 2 login: aaron email: aaron at example.com salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 created_at: <%= 1.days.ago.to_s :db %> <% if options[:include_activation] %> activation_code: 8f24789ae988411ccf33ab0c30fe9106fab32e9a <% end %> <% if options[:stateful] %> state: pending<% end %> From lists at ruby-forum.com Mon May 18 11:36:14 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Mon, 18 May 2009 17:36:14 +0200 Subject: [rspec-users] Skipping the testscenario based on Given block execution. Message-ID: <627ad93f4950cf910ed1ef7883fea4b3@ruby-forum.com> Hi, Generally in cucumber, we write the preconditions in GIVEN block, Is there any way in cucumber using which test scenario execution is skipped, based on the Given block execution. Because there is no point in executing the test scenario when precondition itself fails. Please help me in this regard -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Mon May 18 11:46:48 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 18 May 2009 11:46:48 -0400 Subject: [rspec-users] List Split In-Reply-To: References: Message-ID: <85d99afe0905180846s7a16a0d8u766aee288d4b80d3@mail.gmail.com> On Mon, May 18, 2009 at 10:13 AM, Lee Hambley wrote: > I'm honestly sure that nobody cares, but this list needs to split, I can't > handle the volume of `junk` that is completely irrelevant because I am > subscribed looking for to keep up to date with cucumber wisdom; I'm going to > see how this message is received, and unsubscribe myself later today. > The SNR ratio is absurd, and the list users should really consider a split. > Thanks for the things I've learned, and the tips and tricks that I have been > fortunate enough to pick up. Over the entire weekend I received a little over 30 messages on this list. I wouldn't exactly consider that high-volume or absurd. I use both RSpec and Cucumber and I don't personally mind them being on the same list as it allows me participate in discussions that pertain to the full cycle of outside-in development. I can see where you are coming from though since you only seem to care about the Cucumber aspect of things. If the lists are split I will simply subscribe to both. A nice thing about having the two ML's combined at this point is that discussions and questions which span the entire BDD process can be asked and answered. The down-side of this is that not all folks who use Cucumber use RSpec (or even Ruby). I don't encourage the split, but I think it is becoming inevitable. Cucumber itself is becoming large and wide. I can't think of a good reason for Java programmers who want to use Cucumber to join the RSpec ML. > - Lee > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From aslak.hellesoy at gmail.com Mon May 18 11:48:42 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 17:48:42 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> Message-ID: <8d961d900905180848l3ad5b804x11f7fc257025d114@mail.gmail.com> > Run the examples using maven, or you have to set your classpath yourself.. > See README.textile in simple and spring. It has some command line snippets with classpath. I use this to omit Maven. > Trond. > > On Mon, May 18, 2009 at 5:10 PM, Raymond Barlow > wrote: >> >> With your help I am progressing :) >> >> I've managed to install the cucmber-java gem. But now, if I >> >> jruby -S cucumber features >> >> from any directory, I get this error: >> >> cannot link Java class cucumber.internal.PicoContainerStepMother, probable >> missing dependency: org/picocontainer/MutablePicoContainer (NameError) >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >> `const_missing' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-java-0.0.2/lib/cucumber/pico_container.rb:2 >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-java-0.0.2/lib/cucumber/pico_container.rb:36:in >> `require' >> >> /Users/dev/tools/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in >> `require' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >> `require' >> ./simple/features/support/env.rb:1 >> ./simple/features/support/env.rb:31:in `require' >> >> /Users/dev/tools/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `require' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >> `require' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:77:in >> `require_files' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:75:in >> `each' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:75:in >> `require_files' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:34:in >> `execute!' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:20:in >> `execute' >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/cucumber:8 >> >> /Users/dev/tools/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/cucumber:19:in >> `load' >> /Users/dev/tools/jruby/bin/cucumber:19 >> >> ideas? >> >> :) >> >> Oh, and another question, is the above command the correct thing to run to >> see the examples run? And if so, do I run it in examples/simple or >> examples/simple/features? >> >> /Raymond >> >> 2009/5/18 Trond Marius ?vstetun >>> >>> I believe (someone correct me if I'm wrong..) that the version of >>> cucumber_java you have installed is an older version from a central >>> repository. cucumber/pico_container is the result of a recent refactoring >>> (as is cucumber/spring). >>> For me it helped to use cp instead of mv in the Rakefile at some point. >>> And to remove the line executing mvn from the rake task. Then I was able to >>> install the updated gem. >>> >>> regards, Trond >>> >>> On Mon, May 18, 2009 at 11:20 AM, Raymond Barlow >>> wrote: >>>> >>>> Hi Trond, >>>> >>>> Thanks for your help! >>>> >>>> For a start, I'm running OSX (not windoze). >>>> >>>> OK, it seems that I have successfully installed the cucmber-java >>>> gem....I think. I couldn't get the >>>> >>>> ?jruby -S rake gem >>>> >>>> step to work from the cucumber-java directory. If I did this, all I get >>>> is >>>> >>>> * README.txt is missing or in the wrong format for auto-intuiting. >>>> ?? run `sow blah` and look at its text files >>>> ** History.txt is missing or in the wrong format for auto-intuiting. >>>> ?? run `sow blah` and look at its text files >>>> rake aborted! >>>> Don't know how to build task 'lib/cucumber-java-0.0.2.jar' >>>> >>>> (See full trace by running task with --trace) >>>> >>>> >>>> >>>> It seems that I can install the cucumber-java gem by just doing >>>> >>>> jruby -S gem install cucumber-java >>>> >>>> So I definitely have cucumber-java gem installed. I assume that now I >>>> should be able to run the examples. But, if I go to the >>>> examples/simple/features >>>> directory, and run >>>> >>>> $ jruby -S cucumber features >>>> no such file to load -- cucumber/pico_container >>>> Failed to load ./support/env.rb (LoadError) >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:81:in >>>> `require_files' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:75:in >>>> `each' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:75:in >>>> `require_files' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:34:in >>>> `execute!' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:20:in >>>> `execute' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/cucumber:8 >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/cucumber:19:in >>>> `load' >>>> /Users/dev/tools/jruby-1.1.4/bin/cucumber:19 >>>> >>>> So I then added the directory with cucumber/pico_container.rb in it to >>>> the classpath. try again, and now get >>>> >>>> no such file to load -- cucumber-java-0.0.2 >>>> Failed to load ./support/env.rb (LoadError) >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:81:in >>>> `require_files' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:75:in >>>> `each' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:75:in >>>> `require_files' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:34:in >>>> `execute!' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/cli/main.rb:20:in >>>> `execute' >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/cucumber:8 >>>> >>>> /Users/dev/tools/jruby-1.1.4/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/cucumber:19:in >>>> `load' >>>> /Users/dev/tools/jruby-1.1.4/bin/cucumber:19 >>>> >>>> So, I guess I have again missed something.... >>>> >>>> Cheers, >>>> Raymond Barlow >>>> >>>> 2009/5/18 Trond Marius ?vstetun >>>>> >>>>> On Sun, May 17, 2009 at 12:01 AM, Raymond Barlow >>>>> wrote: >>>>>> >>>>>> OK, that seemed to help a bit. That installed a bunch of stuff, and >>>>>> then I did the mvn clean package in the examples directory--which built the >>>>>> example jar. >>>>>> >>>>>> So I guess my next step would be to >>>>>> cucumber features >>>>>> in the featuers directory of the simple example? >>>>>> >>>>>> I tried this a got an error about pico_container. So I thought that >>>>>> maybe I hadn't setup correctly. >>>>>> >>>>>> So, back to the start. >>>>>> >>>>>> did >>>>>> jruby -S gem install hoe --no-rdoc --no-ri >>>>>> and that worked fine. >>>>>> >>>>>> The next step listed on the cucumber-java page is to >>>>>> jruby -S rake gem >>>>>> >>>>>> when I do this, I get this error: >>>>>> (in /Users/rbarlow/Development/tools/cucumber_java) >>>>>> rake aborted! >>>>>> Don't know how to build task 'gem' >>>>> >>>>> The task you are referring to should be run from the cucumber-java >>>>> subproject, not the root project. >>>>> I have had problems running the rake tasks using Windows (both cygwin >>>>> and the regular cmd-tool) and had to edit the Rakefile manually for my >>>>> environment. >>>>> After installing your own gem using jruby -S gem install >>>>> pkg/cucumber... you can run mvn cucumber:features from each of the >>>>> example-projects. >>>>> >>>>>> >>>>>> (See full trace by running task with --trace) >>>>>> >>>>>> Am I perhaps in the wrong directory when I do this? >>>>>> >>>>>> >>>>>> >>>>>> Sorry, just feeling my way around at the moment. >>>>>> >>>>>> >>>>>> Cheers! >>>>>> Raymond Barlow >>>>>> 2009/5/16 aslak hellesoy >>>>>>> >>>>>>> > Hi all, >>>>>>> > >>>>>>> > Does anyone have an example of how to get the cucumber-java simple >>>>>>> > example >>>>>>> > running? I would like to use cucumber-java but cannot figure out >>>>>>> > how. >>>>>>> > >>>>>>> > I've gem installed cucumber and cucumber-java. When I run mvn clean >>>>>>> > package >>>>>>> > in the simple directory, I get this error: >>>>>>> > >>>>>>> > 19:41:48 >>>>>>> > agentdh-2:~/Development/tools/cucumber_java/examples/simple >>>>>>> > rbarlow$ mvn clean package >>>>>>> > Using Java version: 1.5 >>>>>>> > [INFO] Scanning for projects... >>>>>>> > [INFO] >>>>>>> > >>>>>>> > ------------------------------------------------------------------------ >>>>>>> > [INFO] Building Cucumber Simple Example >>>>>>> > [INFO]??? task-segment: [clean, package] >>>>>>> > [INFO] >>>>>>> > >>>>>>> > ------------------------------------------------------------------------ >>>>>>> > Downloading: >>>>>>> > >>>>>>> > http://repo1.maven.org/maven2/cucumber/cucumber-java-parent/0.0.2/cucumber-java-parent-0.0.2.pom >>>>>>> > [INFO] >>>>>>> > >>>>>>> > ------------------------------------------------------------------------ >>>>>>> > [ERROR] BUILD ERROR >>>>>>> > [INFO] >>>>>>> > >>>>>>> > ------------------------------------------------------------------------ >>>>>>> > [INFO] Failed to resolve artifact. >>>>>>> > >>>>>>> > GroupId: cucumber >>>>>>> > ArtifactId: cucumber-java-parent >>>>>>> > Version: 0.0.2 >>>>>>> > >>>>>>> > Reason: Unable to download the artifact from any repository >>>>>>> > >>>>>>> > ? cucumber:cucumber-java-parent:pom:0.0.2 >>>>>>> > >>>>>>> > from the specified remote repositories: >>>>>>> > ? central (http://repo1.maven.org/maven2) >>>>>>> > >>>>>>> > >>>>>>> > [INFO] >>>>>>> > >>>>>>> > ------------------------------------------------------------------------ >>>>>>> > [INFO] For more information, run Maven with the -e switch >>>>>>> > [INFO] >>>>>>> > >>>>>>> > ------------------------------------------------------------------------ >>>>>>> > [INFO] Total time: 1 second >>>>>>> > [INFO] Finished at: Sat May 16 19:41:52 BST 2009 >>>>>>> > [INFO] Final Memory: 1M/3M >>>>>>> > [INFO] >>>>>>> > >>>>>>> > ------------------------------------------------------------------------ >>>>>>> > >>>>>>> > Any suggestions? Or does anyone have an equivalent ant script? >>>>>>> > >>>>>>> >>>>>>> Try mvn install from the root folder first. >>>>>>> >>>>>>> Aslak >>>>>>> >>>>>>> > Cheers, >>>>>>> > Raymond Barlow >>>>>>> > >>>>>>> > _______________________________________________ >>>>>>> > rspec-users mailing list >>>>>>> > rspec-users at rubyforge.org >>>>>>> > http://rubyforge.org/mailman/listinfo/rspec-users >>>>>>> > >>>>>>> _______________________________________________ >>>>>>> rspec-users mailing list >>>>>>> rspec-users at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>>> >>>>> >>>>> -- >>>>> TronD >>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >>> >>> -- >>> TronD >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > TronD > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lee.hambley at gmail.com Mon May 18 11:54:25 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Mon, 18 May 2009 16:54:25 +0100 Subject: [rspec-users] List Split In-Reply-To: <85d99afe0905180846s7a16a0d8u766aee288d4b80d3@mail.gmail.com> References: <85d99afe0905180846s7a16a0d8u766aee288d4b80d3@mail.gmail.com> Message-ID: Zach, You hit the nail on the head exactly, the problem was compounded by my being on vacation for a week, and coming back to a flood of emails, regrettably my gmail filters can't even take the strain, I can't restrict it accurately enough, as there isn't enough standardization in subject tagging ([rspec-users] [cucumber]) to filter accurately. It was a general moan on my part, and not really fair to air it to the list, but looking at the archives, this comes up from time to time, and I agree completely for anyone using the whole package, it is an invaluable resource... I'm not sure what the solution is, or how my participation will continue (not that the list will feel my absence!) I do however want the best for the list, and to voice my distress with the volume of traffic that could very well be largely irrelevant to the `typical` user... as it happens we are using the rspec+cucumber stack with MRI ruby, and a rails project, it doesn't get more mainstream for rspec and cucumber than that, but even so I find most of the rspec centric conversations on the list to be distracting and confusing. Considerately, - Lee 2009/5/18 Zach Dennis > On Mon, May 18, 2009 at 10:13 AM, Lee Hambley > wrote: > > I'm honestly sure that nobody cares, but this list needs to split, I > can't > > handle the volume of `junk` that is completely irrelevant because I am > > subscribed looking for to keep up to date with cucumber wisdom; I'm going > to > > see how this message is received, and unsubscribe myself later today. > > > The SNR ratio is absurd, and the list users should really consider a > split. > > Thanks for the things I've learned, and the tips and tricks that I have > been > > fortunate enough to pick up. > > Over the entire weekend I received a little over 30 messages on this > list. I wouldn't exactly consider that high-volume or absurd. > > I use both RSpec and Cucumber and I don't personally mind them being > on the same list as it allows me participate in discussions that > pertain to the full cycle of outside-in development. I can see where > you are coming from though since you only seem to care about the > Cucumber aspect of things. If the lists are split I will simply > subscribe to both. > > A nice thing about having the two ML's combined at this point is that > discussions and questions which span the entire BDD process can be > asked and answered. The down-side of this is that not all folks who > use Cucumber use RSpec (or even Ruby). > > I don't encourage the split, but I think it is becoming inevitable. > Cucumber itself is becoming large and wide. I can't think of a good > reason for Java programmers who want to use Cucumber to join the RSpec > ML. > > > > - Lee > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Zach Dennis > http://www.continuousthinking.com (personal) > http://www.mutuallyhuman.com (hire me) > @zachdennis (twitter) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon May 18 12:19:30 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 May 2009 11:19:30 -0500 Subject: [rspec-users] Insight needed into misbehaving expectations needed In-Reply-To: References: Message-ID: <57c63afe0905180919l172715aepcc1a95ab3cb877bf@mail.gmail.com> On Mon, May 18, 2009 at 10:23 AM, Kenneth Kalmer wrote: > Hi everyone > > I have a peculiar scenario that I don't know how to debug, or get to the > bottom of, and need some insight. > > Environment: > > * Rails 2.3.2 > * rspec 1.2.6 & rspec-rails 1.2.6 (vendored gems) > * mocha 0.9.5 (vendored) > > Scenario: > > * I have expectations setup in a before block, as well as in the examples > themselves. > * Running the suite on it's own, everything runs perfectly and passes > * Running rake spec, the expectations in the examples aren't met, but the > expectations from the before blocks are (for controller specs and model > specs) > * Running rake spec:controllers, same as above > * Running rake spec:models, *not* the same as above, works exactly as > supposed to This usually indicates that one or more of your examples are leaking state. > > I've got other controllers with almost identical expectation setups that > work no matter how they are run. In my case it seems that one controller's > specs fail horribly, and it's something I cannot yet trace. > > I'm hoping someone can shed some light from experience, or onto the rspec > internals, so I can dig this out and solve the issue. > > I'm in IRC as well, but it seems very much like an idle space at the > moment... I'm in IRC now - don't have too much time to spare but can spare a couple of minutes if you pop into #rspec on freenode. > > Kind regards > > -- > Kenneth Kalmer > kenneth.kalmer at gmail.com > http://opensourcery.co.za > @kennethkalmer > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Mon May 18 12:30:18 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 18 May 2009 12:30:18 -0400 Subject: [rspec-users] List Split In-Reply-To: <85d99afe0905180846s7a16a0d8u766aee288d4b80d3@mail.gmail.com> References: <85d99afe0905180846s7a16a0d8u766aee288d4b80d3@mail.gmail.com> Message-ID: On Mon, May 18, 2009 at 11:46 AM, Zach Dennis wrote: > On Mon, May 18, 2009 at 10:13 AM, Lee Hambley wrote: >> I'm honestly sure that nobody cares, but this list needs to split, I can't >> handle the volume of `junk` that is completely irrelevant because I am >> subscribed looking for to keep up to date with cucumber wisdom; I'm going to >> see how this message is received, and unsubscribe myself later today. > >> The SNR ratio is absurd, and the list users should really consider a split. >> Thanks for the things I've learned, and the tips and tricks that I have been >> fortunate enough to pick up. > I use both RSpec and Cucumber and I don't personally mind them being > on the same list as it allows me participate in discussions that > pertain to the full cycle of outside-in development. I can see where > you are coming from though since you only seem to care about the > Cucumber aspect of things. If the lists are split I will simply > subscribe to both. > > A nice thing about having the two ML's combined at this point is that > discussions and questions which span the entire BDD process can be > asked and answered. The down-side of this is that not all folks who > use Cucumber use RSpec (or even Ruby). > > I don't encourage the split, but I think it is becoming inevitable. > Cucumber itself is becoming large and wide. I can't think of a good > reason for Java programmers who want to use Cucumber to join the RSpec > ML. > As a long-time RSpec, and now Cucumber user, to me the Java stuff is the noise . -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From jonathan at parkerhill.com Mon May 18 12:46:32 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Mon, 18 May 2009 12:46:32 -0400 Subject: [rspec-users] List Split In-Reply-To: References: <85d99afe0905180846s7a16a0d8u766aee288d4b80d3@mail.gmail.com> Message-ID: makes no difference to me, if the list were to split, i'd subscribe to both so I'd see the same signal and noise. --linoj From lee.hambley at gmail.com Mon May 18 12:51:58 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Mon, 18 May 2009 17:51:58 +0100 Subject: [rspec-users] List Split In-Reply-To: References: <85d99afe0905180846s7a16a0d8u766aee288d4b80d3@mail.gmail.com> Message-ID: Rick, To me too, maybe we could get some mileage by just having a convention of tagging subjects properly [rspec-users][cucumber][java] etc.. and people could filter out what they just don't care about Actually, looking at today's mail, its the Java thread that broke the proverbial camel's back and prompted me to post this thread - Lee 2009/5/18 Jonathan Linowes > makes no difference to me, if the list were to split, i'd subscribe to both > so I'd see the same signal and noise. > > --linoj > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon May 18 13:48:34 2009 From: lists at ruby-forum.com (David Nawara) Date: Mon, 18 May 2009 19:48:34 +0200 Subject: [rspec-users] Cucumber + Authorize.net CIM Message-ID: <49397b007d1e87b661ca3e6b131134e6@ruby-forum.com> Hi all, I'm curious how one would recommend testing authorize.net customer information manager storage with cucumber stories. In my checkout process testing, my code sends user profile/card/address information to the authorize.net test servers, which then stores the sensitive data for me. Obviously, transactions do not remove this data, as it's not in my database. My models are set to destroy the data with callbacks, but since destroys aren't called on my models these callbacks are never triggered. Therefor, subsequent tests fail since I have artifacts left on the Authorize.net CIM. I'm reluctant to remove use_transactional_fixtures, but I don't really see any other options or hooks to use to fix my situation, short of using a Before hook that manually destroys all models in my test db. Any help greatly appreciated! Regards, Dave Nawara -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon May 18 14:12:03 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 20:12:03 +0200 Subject: [rspec-users] [Cucumber] ANN: New Google Group for Cucumber Message-ID: <8d961d900905181112i66878548rfff8e2794326cc6b@mail.gmail.com> David Chelimsky and I have decided that it's now best to create a separate mailing list for Cucumber. The RSpec mailing lists remain the same, but we're hoping that you will all move Cucumber related discussions to this new list. I have already sent an invitation to the 98 people who have provided patches to Cucumber (taken from the Git log). Others can subscribe manually. See you at http://groups.google.com/group/cukes Cheers, Aslak From aslak.hellesoy at gmail.com Mon May 18 14:15:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 20:15:08 +0200 Subject: [rspec-users] Cucumber + Authorize.net CIM In-Reply-To: <49397b007d1e87b661ca3e6b131134e6@ruby-forum.com> References: <49397b007d1e87b661ca3e6b131134e6@ruby-forum.com> Message-ID: <8d961d900905181115x6e75fcebo3455e9e4362cbf56@mail.gmail.com> > Hi all, > > I'm curious how one would recommend testing authorize.net customer > information manager storage with cucumber stories. > > In my checkout process testing, my code sends user profile/card/address > information to the authorize.net test servers, which then stores the Introduce an abstraction layer for that site with an API you define. You'll have one implementation of that API that just sends requests to authorize.net. You'll use this in production. Implement the same API in a different class, but instead of sending requests to authorize.net, just hard code some users and roles. Use this implementation when you run Cucumber. Aslak > sensitive data for me. ?Obviously, transactions do not remove this data, > as it's not in my database. ?My models are set to destroy the data with > callbacks, but since destroys aren't called on my models these callbacks > are never triggered. ?Therefor, subsequent tests fail since I have > artifacts left on the Authorize.net CIM. > > I'm reluctant to remove use_transactional_fixtures, but I don't really > see any other options or hooks to use to fix my situation, short of > using a Before hook that manually destroys all models in my test db. > > Any help greatly appreciated! > > Regards, > Dave Nawara > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon May 18 14:26:00 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 18 May 2009 19:26:00 +0100 Subject: [rspec-users] Recommendations on multi-view scenarios? In-Reply-To: <4A117890.3010201@haskinferguson.net> References: <4A117890.3010201@haskinferguson.net> Message-ID: <693F6628-5958-4F71-AF68-902B89C5939B@mattwynne.net> On 18 May 2009, at 16:02, Denis Haskin wrote: > I'm trying to find out best practices for a multi-view scenario. > Take the classic example of ecommerce, where you might first enter > address information, then credit card information, then confirm it > all and the purchase is made. > > Seems to me this has to be done with a separate scenario for each > view? > > The whole process would be: > > Scenario: I purchase a widget by paying for it with a credit card > Given I am logged in as Sheila > And I have a widget in my cart that costs $5 > When I press "Checkout" > And enter my address information > And press "OK" > And enter my credit card information > And press "OK" > And press "OK" > Then my credit card balance should be reduced by $5 > And I have a completed transaction in my order history > > But that seems really really wrong. So I assume it needs to be like > this? > > Scenario: I purchase a widget by entering my address information > Given I am logged in as Sheila > And I have a widget in my cart that costs $5 > When I press "Checkout" > And enter complete address information > And press "OK" > Then I do not get an error message > And I am on the "credit card information" page > > Scenario: I purchase a widget by entering my credit card information > Given I am logged in as Sheila > And I have a widget in my cart that costs $5 > And I am on the "credit card information page" > When I enter valid credit card information > And press OK" > Then I do not get an error message > And I am on the "confirm purchase" page > ...etc... > > Yes? No? Examples? This is a common question. See http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ and also http://wiki.github.com/aslakhellesoy/cucumber/calling-steps-from-step-definitions Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lee.hambley at gmail.com Mon May 18 14:43:22 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Mon, 18 May 2009 19:43:22 +0100 Subject: [rspec-users] [Cucumber] ANN: New Google Group for Cucumber In-Reply-To: <8d961d900905181112i66878548rfff8e2794326cc6b@mail.gmail.com> References: <8d961d900905181112i66878548rfff8e2794326cc6b@mail.gmail.com> Message-ID: Excellent news, thankyou Aslak, this was exactly what I was hoping for. 2009/5/18 aslak hellesoy > David Chelimsky and I have decided that it's now best to create a > separate mailing list for Cucumber. > The RSpec mailing lists remain the same, but we're hoping that you > will all move Cucumber related discussions to this new list. > I have already sent an invitation to the 98 people who have provided > patches to Cucumber (taken from the Git log). Others can subscribe > manually. > > See you at http://groups.google.com/group/cukes > > Cheers, > Aslak > _______________________________________________ > 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 lee.hambley at gmail.com Mon May 18 14:43:38 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Mon, 18 May 2009 19:43:38 +0100 Subject: [rspec-users] Skipping the testscenario based on Given block execution. In-Reply-To: <627ad93f4950cf910ed1ef7883fea4b3@ruby-forum.com> References: <627ad93f4950cf910ed1ef7883fea4b3@ruby-forum.com> Message-ID: Anil, Your precondition shouldn't fail? - Lee 2009/5/18 Anil Gollaa > > Hi, > Generally in cucumber, we write the preconditions in GIVEN block, > Is there any way in cucumber using which test scenario execution is > skipped, based on the Given block execution. > Because there is no point in executing the test scenario when > precondition itself fails. > > Please help me in this regard > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mattvanhorn at gmail.com Mon May 18 14:49:17 2009 From: mattvanhorn at gmail.com (Matthew Van Horn) Date: Mon, 18 May 2009 14:49:17 -0400 Subject: [rspec-users] Cucumber rake/webrat issue. Message-ID: <8F60A90E-3581-48EE-99BC-EFE64DF1B90A@gmail.com> I'm probably missing something really obvious, but I just upgraded cucumber, rspec/rails, and webrat on a project, and for some reason, cucumber is not seeing any of the webrat steps (or bmabey's email steps) when running from rake. It seems ok when running using the cucumber binary. The versions are (most recent of the following): bmabey-email_spec (0.1.3) cucumber (0.3.5, 0.3.2, 0.3.0) rspec (1.2.6, 1.2.4) rspec-rails (1.2.6, 1.2.4) webrat (0.4.4) My env.rb looks like this: # Sets up the Rails environment for Cucumber ENV["RAILS_ENV"] ||= "test" require File.expand_path(File.dirname(__FILE__) + '/../../config/ environment') require 'cucumber/rails/world' require 'email_spec/cucumber' require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support Cucumber::Rails.use_transactional_fixtures Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling # (e.g. rescue_action_in_public / rescue_responses / rescue_from) require 'webrat' Webrat.configure do |config| config.mode = :rails end require 'cucumber/rails/rspec' require 'webrat/core/matchers' Lib tasks cucumber.rake looks like: $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') begin require 'cucumber/rake/task' Cucumber::Rake::Task.new(:features) do |t| t.fork = true t.cucumber_opts = %w{--format pretty} end task :features => 'db:test:prepare' rescue LoadError desc 'Cucumber rake task not available' task :features do abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' end end From kero at chello.nl Mon May 18 14:55:10 2009 From: kero at chello.nl (Kero van Gelder) Date: Mon, 18 May 2009 20:55:10 +0200 Subject: [rspec-users] Including extra directories for Autospec In-Reply-To: <8d18f1f80905171624y7a4d8716jbf322cf50ad82aa7@mail.gmail.com> References: <8d18f1f80905170945t6927777bn716e6f3111774186@mail.gmail.com> <57c63afe0905171431m7828bed4tddb95d11b6f84aec@mail.gmail.com> <8d18f1f80905171624y7a4d8716jbf322cf50ad82aa7@mail.gmail.com> Message-ID: <20090518185510.GN980@bumblebee.m38c.nl> > Then I edit the files like so: > > ./autotest: > Autotest.add_hook :initialize do |at| > at.add_mapping(%r%^spec/something/.*_spec\.rb$%) do > at.files_matching(%r%^spec/something/.*_spec\.rb$%) > end > end Do you perhaps have a ~/.autotest with a hook to :initialize ? If so, let it return nil, like this: Autotest.add_hook :initialize do |at| %w{.svn .hg .git}.each {|exception| at.add_exception(exception) } nil end It's documented, but a nasty default behaviour. Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From aslak.hellesoy at gmail.com Mon May 18 15:08:07 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 18 May 2009 21:08:07 +0200 Subject: [rspec-users] Cucumber rake/webrat issue. In-Reply-To: <8F60A90E-3581-48EE-99BC-EFE64DF1B90A@gmail.com> References: <8F60A90E-3581-48EE-99BC-EFE64DF1B90A@gmail.com> Message-ID: <8d961d900905181208m20d13363sa2060624f96b4f71@mail.gmail.com> Hi Matthew, Please repost to the new list: http://www.nabble.com/-Cucumber--ANN%3A-New-Google-Group-for-Cucumber-td23602831.html On Mon, May 18, 2009 at 8:49 PM, Matthew Van Horn wrote: > I'm probably missing something really obvious, but I just upgraded cucumber, > rspec/rails, and webrat on a project, and for some reason, cucumber is not > seeing any of the webrat steps (or bmabey's email steps) when running from > rake. ?It seems ok when running using the cucumber binary. > > The versions are (most recent of the following): > bmabey-email_spec (0.1.3) > cucumber (0.3.5, 0.3.2, 0.3.0) > rspec (1.2.6, 1.2.4) > rspec-rails (1.2.6, 1.2.4) > webrat (0.4.4) > > My env.rb looks like this: > > # Sets up the Rails environment for Cucumber > ENV["RAILS_ENV"] ||= "test" > require File.expand_path(File.dirname(__FILE__) + > '/../../config/environment') > require 'cucumber/rails/world' > require 'email_spec/cucumber' > > require 'cucumber/formatter/unicode' # Comment out this line if you don't > want Cucumber Unicode support > Cucumber::Rails.use_transactional_fixtures > Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own > error handling > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# (e.g. rescue_action_in_public / > rescue_responses / rescue_from) > > require 'webrat' > > Webrat.configure do |config| > ?config.mode = :rails > end > > require 'cucumber/rails/rspec' > require 'webrat/core/matchers' > > > Lib tasks cucumber.rake looks like: > $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if > File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') > > begin > ?require 'cucumber/rake/task' > > ?Cucumber::Rake::Task.new(:features) do |t| > ? ?t.fork = true > ? ?t.cucumber_opts = %w{--format pretty} > ?end > ?task :features => 'db:test:prepare' > rescue LoadError > ?desc 'Cucumber rake task not available' > ?task :features do > ? ?abort 'Cucumber rake task is not available. Be sure to install cucumber > as a gem or plugin' > ?end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Mon May 18 15:08:11 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 18 May 2009 13:08:11 -0600 Subject: [rspec-users] Cucumber rake/webrat issue. In-Reply-To: <8F60A90E-3581-48EE-99BC-EFE64DF1B90A@gmail.com> References: <8F60A90E-3581-48EE-99BC-EFE64DF1B90A@gmail.com> Message-ID: <4A11B21B.9050903@benmabey.com> Matthew Van Horn wrote: > I'm probably missing something really obvious, but I just upgraded > cucumber, rspec/rails, and webrat on a project, and for some reason, > cucumber is not seeing any of the webrat steps (or bmabey's email > steps) when running from rake. It seems ok when running using the cucumb Did you read the History on how to upgrade? If not see if it helps.. here is the pertinent info: ** IMPORTANT UPGRADE NOTES FOR RAILS USERS ** Running Cucumber features in the same Ruby interpreter as Rake doesn't seem to work, so you have to explicitly tell the task to fork (like it was doing by default in prior versions). In lib/tasks/cucumber.rake: Cucumber::Rake::Task.new(:features) do |t| t.fork = true # Explicitly fork t.cucumber_opts = %w{--format pretty} end (If you run script/generate cucumber this will be done for you). Alternatively you can omit forking and run features like this: RAILS_ENV=test rake features However, setting the RAILS_ENV is easy to forget, so I don't recommend relying on this. -Ben > > The versions are (most recent of the following): > bmabey-email_spec (0.1.3) > cucumber (0.3.5, 0.3.2, 0.3.0) > rspec (1.2.6, 1.2.4) > rspec-rails (1.2.6, 1.2.4) > webrat (0.4.4) > > My env.rb looks like this: > > # Sets up the Rails environment for Cucumber > ENV["RAILS_ENV"] ||= "test" > require File.expand_path(File.dirname(__FILE__) + > '/../../config/environment') > require 'cucumber/rails/world' > require 'email_spec/cucumber' > > require 'cucumber/formatter/unicode' # Comment out this line if you > don't want Cucumber Unicode support > Cucumber::Rails.use_transactional_fixtures > Cucumber::Rails.bypass_rescue # Comment out this line if you want > Rails own error handling > # (e.g. rescue_action_in_public / > rescue_responses / rescue_from) > > require 'webrat' > > Webrat.configure do |config| > config.mode = :rails > end > > require 'cucumber/rails/rspec' > require 'webrat/core/matchers' > > > Lib tasks cucumber.rake looks like: > $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if > File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') > > begin > require 'cucumber/rake/task' > > Cucumber::Rake::Task.new(:features) do |t| > t.fork = true > t.cucumber_opts = %w{--format pretty} > end > task :features => 'db:test:prepare' > rescue LoadError > desc 'Cucumber rake task not available' > task :features do > abort 'Cucumber rake task is not available. Be sure to install > cucumber as a gem or plugin' > end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon May 18 15:16:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 May 2009 14:16:47 -0500 Subject: [rspec-users] Fixture::FormatError parsing YAML In-Reply-To: References: Message-ID: <57c63afe0905181216t69d5f4f9u96d0f2c5e922f98@mail.gmail.com> On Mon, May 18, 2009 at 10:31 AM, WJSimacek wrote: > Hi, > ? ?I'm trying to test restful_authentication plugin and am getting > errors with my install. > ? ? ?==>I've been through the YAML specification and actually copied > the fixture file into word looking for tabs instead of spaces. I've > played with various parts of the formatting, but I need a fresh pair > of eyes on this one. > > ?1) Error: > test_the_truth(PostTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object What line/file is this last bit happening on? I wonder if the YML problem is a red herring. > > Here's the related fixtures.yml > quentin: > ?id: 1 > ?login: quentin > ?email: quentin at example.com > ?salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd > ?crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 > ?created_at: <%= 5.days.ago.to_s :db %> > <% if options[:include_activation] %> ?activation_code: > 8f24789ae988411ccf33ab0c30fe9106fab32e9b <% end %> > <% if options[:include_activation] %> ?activated_at: <%= > 5.days.ago.to_s :db %> <% end %> > <% if options[:stateful] %> ?state: active<% end %> > aaron: > ?id: 2 > ?login: aaron > ?email: aaron at example.com > ?salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd > ?crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 > ?created_at: <%= 1.days.ago.to_s :db %> > <% if options[:include_activation] %> ?activation_code: > 8f24789ae988411ccf33ab0c30fe9106fab32e9a <% end %> > <% if options[:stateful] %> ?state: pending<% end %> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From wayne.simacek at gmail.com Mon May 18 15:50:02 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Mon, 18 May 2009 12:50:02 -0700 (PDT) Subject: [rspec-users] Fixture::FormatError parsing YAML In-Reply-To: <57c63afe0905181216t69d5f4f9u96d0f2c5e922f98@mail.gmail.com> References: <57c63afe0905181216t69d5f4f9u96d0f2c5e922f98@mail.gmail.com> Message-ID: <214291c9-497c-4713-80ef-a44f2f3629da@f16g2000vbf.googlegroups.com> On May 18, 2:16?pm, David Chelimsky wrote: > On Mon, May 18, 2009 at 10:31 AM, WJSimacek wrote: > > Hi, > > ? ?I'm trying to test restful_authentication plugin and am getting > > errors with my install. > > ? ? ?==>I've been through the YAML specification and actually copied > > the fixture file into word looking for tabs instead of spaces. I've > > played with various parts of the formatting, but I need a fresh pair > > of eyes on this one. > > > ?1) Error: > > test_the_truth(PostTest): > > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > > that YAML must be consistently indented using spaces. Tabs are not > > allowed. Please have a look athttp://www.yaml.org/faq.html > > The exact error was: > > ?NameError: undefined local variable or method `options' for > > main:Object > > What line/file is this last bit happening on? I wonder if the YML > problem is a red herring. > I'm not sure how to answer your question? Is there a way I can re-run the specific test with a --trace option to have something more to send you? --Wayne [p.s. --this is just one of several YAML parsing errors I'm getting. If it is a red herring....it's a Whopper! Here's some related ones-- 1) Error: test_should_create_post(PostsControllerTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object 2) Error: test_should_destroy_post(PostsControllerTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object 3) Error: test_should_get_edit(PostsControllerTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object 4) Error: test_should_get_index(PostsControllerTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object 5) Error: test_should_get_new(PostsControllerTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object 6) Error: test_should_show_post(PostsControllerTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object 7) Error: test_should_update_post(PostsControllerTest): Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NameError: undefined local variable or method `options' for main:Object 8) Error: test_should_delete_token_on_logout(SessionsControllerTest): NoMethodError: undefined method `login_as' for # /test/functional/sessions_controller_test.rb:50:in `test_should_delete_token_on_logout' 9) Error: test_should_fail_cookie_login(SessionsControllerTest): NoMethodError: undefined method `users' for # /test/functional/sessions_controller_test.rb:71:in `test_should_fail_cookie_login' 10) Error: test_should_fail_expired_cookie_login(SessionsControllerTest): NoMethodError: undefined method `users' for # /test/functional/sessions_controller_test.rb:63:in `test_should_fail_expired_cookie_login' 11) Error: test_should_fail_login_and_not_redirect(SessionsControllerTest): NoMethodError: undefined method `post' for # /test/functional/sessions_controller_test.rb:27:in `test_should_fail_login_and_not_redirect' 12) Error: test_should_login_and_redirect(SessionsControllerTest): NoMethodError: undefined method `post' for # /test/functional/sessions_controller_test.rb:21:in `test_should_login_and_redirect' 13) Error: test_should_login_with_cookie(SessionsControllerTest): NoMethodError: undefined method `users' for # /test/functional/sessions_controller_test.rb:56:in `test_should_login_with_cookie' 14) Error: test_should_logout(SessionsControllerTest): NoMethodError: undefined method `login_as' for # /test/functional/sessions_controller_test.rb:33:in `test_should_logout' 15) Error: test_should_not_remember_me(SessionsControllerTest): NoMethodError: undefined method `post' for # /test/functional/sessions_controller_test.rb:45:in `test_should_not_remember_me' 16) Error: test_should_remember_me(SessionsControllerTest): NoMethodError: undefined method `post' for # /test/functional/sessions_controller_test.rb:40:in `test_should_remember_me' 16 tests, 0 assertions, 0 failures, 16 errors > > > > > > Here's the related fixtures.yml > > quentin: > > ?id: 1 > > ?login: quentin > > ?email: quen... at example.com > > ?salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd > > ?crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 > > ?created_at: <%= 5.days.ago.to_s :db %> > > <% if options[:include_activation] %> ?activation_code: > > 8f24789ae988411ccf33ab0c30fe9106fab32e9b <% end %> > > <% if options[:include_activation] %> ?activated_at: <%= > > 5.days.ago.to_s :db %> <% end %> > > <% if options[:stateful] %> ?state: active<% end %> > > aaron: > > ?id: 2 > > ?login: aaron > > ?email: aa... at example.com > > ?salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd > > ?crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 > > ?created_at: <%= 1.days.ago.to_s :db %> > > <% if options[:include_activation] %> ?activation_code: > > 8f24789ae988411ccf33ab0c30fe9106fab32e9a <% end %> > > <% if options[:stateful] %> ?state: pending<% end %> > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Mon May 18 17:02:58 2009 From: lists at ruby-forum.com (David Nawara) Date: Mon, 18 May 2009 23:02:58 +0200 Subject: [rspec-users] Cucumber + Authorize.net CIM In-Reply-To: <8d961d900905181115x6e75fcebo3455e9e4362cbf56@mail.gmail.com> References: <49397b007d1e87b661ca3e6b131134e6@ruby-forum.com> <8d961d900905181115x6e75fcebo3455e9e4362cbf56@mail.gmail.com> Message-ID: Aslak Helles?y wrote: > Introduce an abstraction layer for that site with an API you define. > > Aslak Thanks Aslak. I'll give this method a shot. -- Posted via http://www.ruby-forum.com/. From glin at employees.org Mon May 18 22:51:12 2009 From: glin at employees.org (Gary Lin) Date: Mon, 18 May 2009 19:51:12 -0700 Subject: [rspec-users] Using "return" in rspec test Message-ID: <4A121EA0.2030004@employees.org> Hi, I am still new to rspec and I wonder if anyone can give me some insight about the problem I have encountered. I notice whenever I use "return" in my test, it will skip all the examples and exit right out of my test run. Here is a small example that demonstrate the problem: describe "This tests uses return in my code" do it "should print Hello" do puts "Hello" # skip some test scenario if product is in demo mode if @product.demoMode? return; else # rest of the test goes here. end end it "should print hi" do puts "hi" end end With the above spec, the second "it should print hi" test will never get executed. I found it would be very useful to use "return" to skip some of the test code if a particular scenario occurs. So I wonder if I cannot use "return" to achieve this, is there any way I can workaround it? Thanks, --Gary From phlip2005 at gmail.com Mon May 18 23:23:03 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 18 May 2009 20:23:03 -0700 Subject: [rspec-users] Using "return" in rspec test In-Reply-To: <4A121EA0.2030004@employees.org> References: <4A121EA0.2030004@employees.org> Message-ID: Gary Lin wrote: > describe "This tests uses return in my code" do > it "should print Hello" do > puts "Hello" # skip some test scenario if product is in > demo mode > if @product.demoMode? > return; use 'break' (However, generally speaking, tests should either pass or fail, and they should not skip any blocks.) -- Phlip From bj at aboutus.org Mon May 18 23:47:43 2009 From: bj at aboutus.org (BJ Clark) Date: Mon, 18 May 2009 20:47:43 -0700 Subject: [rspec-users] Using "return" in rspec test In-Reply-To: <4A121EA0.2030004@employees.org> References: <4A121EA0.2030004@employees.org> Message-ID: On May 18, 2009, at 7:51 PM, Gary Lin wrote: > Hi, > > I am still new to rspec and I wonder if anyone can give me some > insight about the problem I have encountered. I notice whenever I > use "return" in my test, it will skip all the examples and exit > right out of my test run. Here is a small example that demonstrate > the problem: > > describe "This tests uses return in my code" do > it "should print Hello" do > puts "Hello" # skip some test scenario if product is in > demo mode > if @product.demoMode? > return; > else > # rest of the test goes here. > end > end > it "should print hi" do > puts "hi" > end > end Gary, It's better to not have an if/else in a test. Why not try: describe "This tests uses return in my code" do context "in demo mode" do @product.stub!(:demoMode?).and_return(true) something.should be_true end context "not in demo mode" do @product.stub!(:demoMode?).and_return(false) something.should_not be_true end end ----- BJ Clark AboutUs.org > > With the above spec, the second "it should print hi" test will never > get executed. I found it would be very useful to use "return" to > skip some of the test code if a particular scenario occurs. So I > wonder if I cannot use "return" to achieve this, is there any way I > can workaround it? > > Thanks, > > --Gary > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From adamandersonis at gmail.com Tue May 19 01:54:20 2009 From: adamandersonis at gmail.com (Adam Anderson) Date: Mon, 18 May 2009 22:54:20 -0700 Subject: [rspec-users] Including extra directories for Autospec In-Reply-To: <20090518185510.GN980@bumblebee.m38c.nl> References: <8d18f1f80905170945t6927777bn716e6f3111774186@mail.gmail.com> <57c63afe0905171431m7828bed4tddb95d11b6f84aec@mail.gmail.com> <8d18f1f80905171624y7a4d8716jbf322cf50ad82aa7@mail.gmail.com> <20090518185510.GN980@bumblebee.m38c.nl> Message-ID: <8d18f1f80905182254x3bd6920fief5ed45b1f614207@mail.gmail.com> Yeah. I apologize that was a typo on my part. It should have said ./.autotest -Adam On Mon, May 18, 2009 at 11:55 AM, Kero van Gelder wrote: >> Then I edit the files like so: >> >> ./autotest: >> Autotest.add_hook :initialize do |at| >> ? at.add_mapping(%r%^spec/something/.*_spec\.rb$%) do >> ? ? at.files_matching(%r%^spec/something/.*_spec\.rb$%) >> ? end >> end > > Do you perhaps have a ~/.autotest with a hook to :initialize ? > If so, let it return nil, like this: > > Autotest.add_hook :initialize do |at| > ?%w{.svn .hg .git}.each {|exception| > ? ?at.add_exception(exception) > ?} > ?nil > end > > > It's documented, but a nasty default behaviour. > > Bye, > Kero. > > ___ > How can I change the world if I can't even change myself? > ?-- Faithless, Salva Mea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Tue May 19 02:04:23 2009 From: tero at tilus.net (Tero Tilus) Date: Tue, 19 May 2009 09:04:23 +0300 Subject: [rspec-users] [RSpec, Rails] POST create action spec and before_filter In-Reply-To: References: Message-ID: <20090519060423.GI10196@uivelo.tilus.net> 2009-05-18 21:40, Florent Florent: > I have this controller: http://pastie.org/482270 > I wrote this spec: http://pastie.org/482273 There are a few spots which draw my attention. At spec line 4 you create a mock Page with #save that always fails (succesfull save returns true). Is that intentional? At line 9 you .and_return a value from a variable you don't set anywhere. Moreover the "should set @context" is imo a spec smell (even though it's in description string), because it refers to internal state of a PagesController instance, which you should not be interested in, but the external behavior. > The spec "should set @context" works fine. But when running the > spec "should build a new message" I got this error: > > datetime, updated_at: datetime) (class)> expected :new with > ({"title"=>"Introduction", "content"=>"page d'introduction"}) once, > but received it 0 time Could that have something to do with the fact that you end up stubbing Page.new one or two times before setting the expectation on it at line 14? It shouldn't, but you never know. > I can not find why Page model does not receive new call, and playing > around I can have the spec running successfully when I remove > :create from the before_filter line! Could your filter be failing and the failure not showin up somehow? Does "should set @context" _really_ succeed? Comment the other example one out and then try again. Generally you shouldn't expect your examples (or specs) to run in any particular order. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From lists at ruby-forum.com Tue May 19 04:30:31 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Tue, 19 May 2009 10:30:31 +0200 Subject: [rspec-users] Skipping the testscenario based on Given block execution. In-Reply-To: References: <627ad93f4950cf910ed1ef7883fea4b3@ruby-forum.com> Message-ID: <821fb1aa17516a364eba42de42ad6b7e@ruby-forum.com> Hi, I think i am not clear. My query is while running the testcases, Some times precondition of testcase fails, when precondition itself fails there is no point in executing the testcase further. so , is there any way in cucumber to skip execution of scenario when precondition of testcase fails. Thanks, Anil -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue May 19 04:30:48 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Tue, 19 May 2009 10:30:48 +0200 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> Message-ID: <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> Ruby version : 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] rspec - 1.2.4 rails - 2.1.2 OS - Vista Home I am running a single file by the command spec channels_controller(filename)_spec.rb Contents of the file: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') def setup @controller = ChannelsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def user_attributes { :login => 'foo', :password => 'foobar', :password_confirmation => 'foobar', :email => 'foo at dibistore.it', :privacy => '1', :idiom => nil, :role_id => 2 } end describe ChannelsController do fixtures :channels, :users context "Brand Manager" do @user = User.find_by_login("amit") it "should not create channel" do user = User.new user.attributes = user_attributes post :create, :channel => {:brand_name => 'by manager'} end end end Now when i run this file i get error which says RuntimeError in 'ChannelsController Brand Manager should not create chnnel' @controller is nil: mke sure you set it in your test's setup method. Backtrace is as follows: C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ test_process.rb:378:in `process' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ test_process.rb:376:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ test_process.rb:376:in `process' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ test_process.rb:365:in `post' ./chnnels_controller_spec.rb:141: C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m ethods.rb:41:in `instnce_evl' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m ethods.rb:41:in `execute' C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m ethods.rb:38:in `execute' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g roup_methods.rb:203:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g roup_methods.rb:201:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g roup_methods.rb:201:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g roup_methods.rb:99:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g roup_runner.rb:23:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g roup_runner.rb:22:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g roup_runner.rb:22:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/options. rb:119:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/commnd_l ine.rb:9:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/bin/spec:4 C:/Progrm Files/ruby/bin/spec:19:in `lod' C:/Progrm Files/ruby/bin/spec:19 Please Advice -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Tue May 19 05:42:49 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Tue, 19 May 2009 10:42:49 +0100 Subject: [rspec-users] Skipping the testscenario based on Given block execution. In-Reply-To: <821fb1aa17516a364eba42de42ad6b7e@ruby-forum.com> References: <627ad93f4950cf910ed1ef7883fea4b3@ruby-forum.com> <821fb1aa17516a364eba42de42ad6b7e@ruby-forum.com> Message-ID: <4A127F19.8030501@josephwilk.net> Anil Gollaa wrote: > Hi, > I think i am not clear. > My query is while running the testcases, > Some times precondition of testcase fails, when precondition itself > fails there is no point in executing the testcase further. > so , is there any way in cucumber to skip execution of scenario when > precondition of testcase fails. > In a Scenario if any step fails the following steps of that scenario are skipped. This is the current behaviour of Cucumber. Older versions of Cucumber had some trouble with properly skipping these steps. HTHs -- Joseph Wilk http://blog.josephwilk.net > Thanks, > Anil > From aslak.hellesoy at gmail.com Tue May 19 05:48:59 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 19 May 2009 11:48:59 +0200 Subject: [rspec-users] Skipping the testscenario based on Given block execution. In-Reply-To: <821fb1aa17516a364eba42de42ad6b7e@ruby-forum.com> References: <627ad93f4950cf910ed1ef7883fea4b3@ruby-forum.com> <821fb1aa17516a364eba42de42ad6b7e@ruby-forum.com> Message-ID: <8d961d900905190248x6767289dta35fa32262ac5175@mail.gmail.com> > Hi, > I think i am not clear. > My query is while running the testcases, > Some times precondition of testcase fails, when precondition itself > fails there is no point in executing the testcase further. > so , is there any way in cucumber to skip execution of scenario when > precondition of testcase fails. > The intention is that when a Before block raises an error, the steps of the scenario are skipped. However, this isn't working properly, but a fix is in progress: https://rspec.lighthouseapp.com/projects/16211/tickets/330-gracefully-handle-exceptions-in-after-block For new threads, please use the Cucumber google group: http://groups.google.com/group/cukes Cheers, Aslak > Thanks, > Anil > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mattvanhorn at gmail.com Tue May 19 07:13:09 2009 From: mattvanhorn at gmail.com (Matthew Van Horn) Date: Tue, 19 May 2009 07:13:09 -0400 Subject: [rspec-users] Cucumber rake/webrat issue. In-Reply-To: <4A11B21B.9050903@benmabey.com> References: <8F60A90E-3581-48EE-99BC-EFE64DF1B90A@gmail.com> <4A11B21B.9050903@benmabey.com> Message-ID: <8B2DC935-A65F-4C2F-AC17-D4C313EAA36A@gmail.com> On May 18, 2009, at 3:08 PM, Ben Mabey wrote: > Matthew Van Horn wrote: >> I'm probably missing something really obvious, but I just upgraded >> cucumber, rspec/rails, and webrat on a project, and for some >> reason, cucumber is not seeing any of the webrat steps (or bmabey's >> email steps) when running from rake. It seems ok when running >> using the cucumb > > > Did you read the History on how to upgrade? If not see if it > helps.. here is the pertinent info: > > ** IMPORTANT UPGRADE NOTES FOR RAILS USERS ** > > Running Cucumber features in the same Ruby interpreter as Rake > doesn't seem to work, > so you have to explicitly tell the task to fork (like it was doing > by default in prior > versions). In lib/tasks/cucumber.rake: > > Cucumber::Rake::Task.new(:features) do |t| > t.fork = true # Explicitly fork > t.cucumber_opts = %w{--format pretty} > end > > (If you run script/generate cucumber this will be done for you). > Alternatively you can omit forking and run features like this: > > RAILS_ENV=test rake features > > However, setting the RAILS_ENV is easy to forget, so I don't > recommend relying on this. > > > -Ben I posted this on the new list, but this is what I had, and it looks correct to me. (I re-ran the generator.) >> Lib tasks cucumber.rake looks like: >> $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if >> File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') >> >> begin >> require 'cucumber/rake/task' >> >> Cucumber::Rake::Task.new(:features) do |t| >> t.fork = true >> t.cucumber_opts = %w{--format pretty} >> end >> task :features => 'db:test:prepare' >> rescue LoadError >> desc 'Cucumber rake task not available' >> task :features do >> abort 'Cucumber rake task is not available. Be sure to install >> cucumber as a gem or plugin' >> end >> end From dchelimsky at gmail.com Tue May 19 09:21:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 May 2009 08:21:47 -0500 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> Message-ID: <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> On Tue, May 19, 2009 at 3:30 AM, Amit Kulkarni wrote: > Ruby version : 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > rspec - 1.2.4 > rails - 2.1.2 > OS - Vista Home > I am running a single file by the command > spec channels_controller(filename)_spec.rb Where is this file? For rspec-rails to know that it's supposed to be a controller spec, it either needs to be inside the PROJECT_ROOT/spec/controllers directory, or you need to change the describe declaration to this: describe ChannelsController, :type => :controller do > > Contents of the file: > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > def setup > ?@controller ?= ChannelsController.new > ?@request ? ? = ActionController::TestRequest.new > ?@response ? ?= ActionController::TestResponse.new > end Get rid of this setup. First of all, RSpec does this for you automatically inside controller example groups. Secondly, this is outside any example group (describe block), so it's not related to anything anyway. > > def user_attributes > ? ?{ > ? ? ?:login => 'foo', > ? ? ?:password => 'foobar', > ? ? ?:password_confirmation => 'foobar', > ? ? ?:email => 'foo at dibistore.it', > ? ? ?:privacy => '1', > ? ? ?:idiom => nil, > ? ? ?:role_id => 2 > ? ?} > end I'd move user_attributes inside the example group too. That way it's scoped. If not, it's going to be available to (and possibly in conflict with) any files that get loaded after this one. > describe ChannelsController do > ? ?fixtures :channels, :users > ? ?context "Brand Manager" do > ? ?@user = User.find_by_login("amit") > ? ? ?it "should not create channel" do > ? ? ? ?user = User.new > ? ? ? ?user.attributes = user_attributes > ? ? ? ?post :create, :channel => {:brand_name => 'by manager'} > ? ? ?end > ? ?end > end > > Now when i run this file i get error which says > RuntimeError in 'ChannelsController Brand Manager should not create > chnnel' > @controller is nil: mke sure you set it in your test's setup method. Uh, where are all the 'a's in the backtrace? > Backtrace is as follows: > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ > test_process.rb:378:in `process' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ > test_process.rb:376:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ > test_process.rb:376:in `process' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/ > test_process.rb:365:in `post' > ./chnnels_controller_spec.rb:141: > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m > ethods.rb:41:in `instnce_evl' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m > ethods.rb:41:in `execute' > C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m > ethods.rb:38:in `execute' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g > roup_methods.rb:203:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g > roup_methods.rb:201:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g > roup_methods.rb:201:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g > roup_methods.rb:99:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g > roup_runner.rb:23:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g > roup_runner.rb:22:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g > roup_runner.rb:22:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/options. > rb:119:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/commnd_l > ine.rb:9:in `run' > C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/bin/spec:4 > C:/Progrm Files/ruby/bin/spec:19:in `lod' > C:/Progrm Files/ruby/bin/spec:19 > > Please Advice > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lee_longmore at yahoo.co.uk Tue May 19 09:53:56 2009 From: lee_longmore at yahoo.co.uk (Lee Longmore) Date: Tue, 19 May 2009 13:53:56 +0000 (GMT) Subject: [rspec-users] When to stub_model? Message-ID: <499150.46456.qm@web23901.mail.ird.yahoo.com> I am trying to specify a controller with RSpec for the first time. I have been using mock_model to date but, given that the models are fully implemented, I am wondering if I should be using stub_model. Based on what I have read, I am struggling to understand the advantages that stub_model over mock_model might provide. Should I be using stub_model and if so, why? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue May 19 10:04:54 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Tue, 19 May 2009 16:04:54 +0200 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> Message-ID: Hi, Thanks for quick response My channels_controller_spec.rb file is inside controller spec only i.e. PROJECT_ROOT/spec/controllers/channels_controller_spec.rb. As per your suggestion i removed the setup method and moved user_attributes under example groups. but i am getting the same error which says RuntimeError in 'ChannelsController Brand Manager should not create channel' @controller is nil: make sure you set it in your test's setup method. Still confused why is this coming again. Following is the backtrace(Regarding a's its a minor prob.will do it) RuntimeError in 'ChannelsController Brand Manager should not create channel' @controller is nil: make sure you set it in your test's setup method. C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control ler/test_process.rb:378:in `process' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control ler/test_process.rb:376:in `each' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control ler/test_process.rb:376:in `process' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control ler/test_process.rb:365:in `post' ./channels_controller_spec1.rb:149: C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl e_methods.rb:40:in `instance_eval' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl e_methods.rb:40:in `execute' C:/Program Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl e_methods.rb:37:in `execute' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl e_group_methods.rb:207:in `run_examples' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl e_group_methods.rb:205:in `each' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl e_group_methods.rb:205:in `run_examples' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl e_group_methods.rb:103:in `run' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example _group_runner.rb:23:in `run' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example _group_runner.rb:22:in `each' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example _group_runner.rb:22:in `run' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options .rb:119:in `run_examples' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/command _line.rb:9:in `run' C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/bin/spec:4 C:/Program Files/ruby/bin/spec:19:in `load' C:/Program Files/ruby/bin/spec:19 > Where is this file? For rspec-rails to know that it's supposed to be a > controller spec, it either needs to be inside the > PROJECT_ROOT/spec/controllers directory, or you need to change the > describe declaration to this: > > describe ChannelsController, :type => :controller do > >> >> Contents of the file: >> >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> >> def setup >> ?@controller ?= ChannelsController.new >> ?@request ? ? = ActionController::TestRequest.new >> ?@response ? ?= ActionController::TestResponse.new >> end > > Get rid of this setup. First of all, RSpec does this for you > automatically inside controller example groups. Secondly, this is > outside any example group (describe block), so it's not related to > anything anyway. > >> ? ?} >> end > > I'd move user_attributes inside the example group too. That way it's > scoped. If not, it's going to be available to (and possibly in > conflict with) any files that get loaded after this one. > >> end >> >> Now when i run this file i get error which says >> RuntimeError in 'ChannelsController Brand Manager should not create >> chnnel' >> @controller is nil: mke sure you set it in your test's setup method. > > Uh, where are all the 'a's in the backtrace? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue May 19 10:27:31 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 May 2009 09:27:31 -0500 Subject: [rspec-users] Error in executing controller spec In-Reply-To: References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> Message-ID: <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> On Tue, May 19, 2009 at 9:04 AM, Amit Kulkarni wrote: > Hi, > > Thanks for quick response > > My channels_controller_spec.rb file is inside controller spec only > i.e. PROJECT_ROOT/spec/controllers/channels_controller_spec.rb. > > As per your suggestion i removed the setup method and moved > user_attributes under example groups. > > but i am getting the same error which says ?RuntimeError in > 'ChannelsController Brand Manager should not create channel' > @controller is nil: make sure you set it in your test's setup method. > > Still confused why is this coming again. > > Following is the backtrace(Regarding a's its a minor prob.will do it) > RuntimeError in 'ChannelsController Brand Manager should not create > channel' > @controller is nil: make sure you set it in your test's setup method. > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control > ler/test_process.rb:378:in `process' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control > ler/test_process.rb:376:in `each' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control > ler/test_process.rb:376:in `process' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control > ler/test_process.rb:365:in `post' > ./channels_controller_spec1.rb:149: It looks like you're calling the file from the spec/controllers directory. Just for fun, step up to the project root and run: script/spec spec/controllers/channels_controller_spec1.rb > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl > e_methods.rb:40:in `instance_eval' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl > e_methods.rb:40:in `execute' > C:/Program Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl > e_methods.rb:37:in `execute' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl > e_group_methods.rb:207:in `run_examples' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl > e_group_methods.rb:205:in `each' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl > e_group_methods.rb:205:in `run_examples' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/example/exampl > e_group_methods.rb:103:in `run' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example > _group_runner.rb:23:in `run' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example > _group_runner.rb:22:in `each' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/example > _group_runner.rb:22:in `run' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options > .rb:119:in `run_examples' > C:/Program > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/command > _line.rb:9:in `run' > C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/bin/spec:4 > C:/Program Files/ruby/bin/spec:19:in `load' > C:/Program Files/ruby/bin/spec:19 > >> Where is this file? For rspec-rails to know that it's supposed to be a >> controller spec, it either needs to be inside the >> PROJECT_ROOT/spec/controllers directory, or you need to change the >> describe declaration to this: >> >> describe ChannelsController, :type => :controller do >> >>> >>> Contents of the file: >>> >>> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >>> >>> def setup >>> ?@controller ?= ChannelsController.new >>> ?@request ? ? = ActionController::TestRequest.new >>> ?@response ? ?= ActionController::TestResponse.new >>> end >> >> Get rid of this setup. First of all, RSpec does this for you >> automatically inside controller example groups. Secondly, this is >> outside any example group (describe block), so it's not related to >> anything anyway. >> >>> ? ?} >>> end >> >> I'd move user_attributes inside the example group too. That way it's >> scoped. If not, it's going to be available to (and possibly in >> conflict with) any files that get loaded after this one. >> >>> end >>> >>> Now when i run this file i get error which says >>> RuntimeError in 'ChannelsController Brand Manager should not create >>> chnnel' >>> @controller is nil: mke sure you set it in your test's setup method. >> >> Uh, where are all the 'a's in the backtrace? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Tue May 19 11:09:21 2009 From: lists at ruby-forum.com (Zhenning Guan) Date: Tue, 19 May 2009 17:09:21 +0200 Subject: [rspec-users] Forum.count.should, should doesn't work? Message-ID: <9cb02f05bd159090dedf1285f671d924@ruby-forum.com> Scenario: List Tasks Then I should have 3 forums ------------- Then /^I should have ([0-9]+) forums$/ do |counts| Forum.count.should == counts.to_i end ==== When I go to the homepage # features/step_definitions/webrat_steps.rb:10 Then I should have 3 forums # features/step_definitions/forums_steps.rb:1 expected: 3, got: 0 (using ==) Diff: @@ -1,2 +1,2 @@ -3 +0 (Spec::Expectations::ExpectationNotMetError) features/forums.feature:8:in `Then I should have 3 forums' 1 scenario (1 failed) 2 steps (1 failed, 1 passed) === Forum.count == counts.to_i does fine! why Forum.count.should throw a error? how could I do? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue May 19 11:19:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 May 2009 10:19:08 -0500 Subject: [rspec-users] Forum.count.should, should doesn't work? In-Reply-To: <9cb02f05bd159090dedf1285f671d924@ruby-forum.com> References: <9cb02f05bd159090dedf1285f671d924@ruby-forum.com> Message-ID: <57c63afe0905190819p1a42abb1g4dc3d9778a111de6@mail.gmail.com> On Tue, May 19, 2009 at 10:09 AM, Zhenning Guan wrote: > Scenario: List Tasks > ?Then I should have 3 forums > ------------- > > Then /^I should have ([0-9]+) forums$/ do |counts| > ?Forum.count.should == counts.to_i > end > > ==== > ?When I go to the homepage ? # > features/step_definitions/webrat_steps.rb:10 > ? ?Then I should have 3 forums # > features/step_definitions/forums_steps.rb:1 > ? ? ?expected: 3, > ? ? ? ? ? got: 0 (using ==) > ? ? ?Diff: > ? ? ?@@ -1,2 +1,2 @@ > ? ? ?-3 > ? ? ?+0 > ? ? ? (Spec::Expectations::ExpectationNotMetError) > ? ? ?features/forums.feature:8:in `Then I should have 3 forums' > > 1 scenario (1 failed) > 2 steps (1 failed, 1 passed) > > === > Forum.count == counts.to_i does fine That's not an expectation so it won't pass or fail. I'd bet that's returning false, which is not going to make a step fail (only an error will). > why Forum.count.should throw a > error? > how could I do? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue May 19 12:54:59 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Tue, 19 May 2009 18:54:59 +0200 Subject: [rspec-users] RSpec for Rails plugin Message-ID: I'm trying to write specs to test a Rails plugin and I'm not clear on what needs to be installed and required. Works fine for many specs, but view testing fails (i.e. anything relying rspec-rails over just rspec). In other words, how can I use the rspec-rails gem to test a plugin? Thanks, Sarah -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue May 19 13:11:40 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 19 May 2009 18:11:40 +0100 Subject: [rspec-users] When to stub_model? In-Reply-To: <499150.46456.qm@web23901.mail.ird.yahoo.com> References: <499150.46456.qm@web23901.mail.ird.yahoo.com> Message-ID: <526E5C03-703F-42FF-A799-CEBFEFBE6B65@mattwynne.net> On 19 May 2009, at 14:53, Lee Longmore wrote: > I am trying to specify a controller with RSpec for the first time. > > I have been using mock_model to date but, given that the models are > fully implemented, I am wondering if I should be using stub_model. > > Based on what I have read, I am struggling to understand the > advantages that stub_model over mock_model might provide. > > Should I be using stub_model and if so, why? *Should* is a big word here. It depends. When you use a stub model, you get a real instance of your AR model object, with the database connection crippled so you can't accidentally do something that will make your specs slow. The benefit of this is that you get all the methods on the model available to the controller. For example, if you have a User class which takes a date_of_birth attribute in it's constructor, you can call the #age method. This can make your tests easier to read. The cost of this is that your controller specs will be covering code in the model classes as well as the controller you're explicitly testing. There is a chance you'll make a change to the #age method on your User (maybe you want to specify in days rather than years), make the user specs pass, and check in believing you're done. Unwittingly, you have just broken the controller specs too. If you read what from the really experienced guys who started this stuff off[1] say, you'll hear that mocks are really a design tool. By creating a mock_model in your controller specs rather than leaning on the stub_model, you're designing your 'ideal model', rather than being constrained by whatever default methods activerecord gives you, or you have already written. I often find that this process drives out much more elegant interfaces onto the models, and sometimes even shows me where I need to introduce an intermediate class. I think this is something you really have to play around with for yourself to find the right balance for you and your team. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Tue May 19 14:09:45 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 19 May 2009 19:09:45 +0100 Subject: [rspec-users] When to stub_model? In-Reply-To: <526E5C03-703F-42FF-A799-CEBFEFBE6B65@mattwynne.net> References: <499150.46456.qm@web23901.mail.ird.yahoo.com> <526E5C03-703F-42FF-A799-CEBFEFBE6B65@mattwynne.net> Message-ID: <6D8825B9-4178-4BC1-9EEB-73DD8055D6FC@mattwynne.net> On 19 May 2009, at 18:11, Matt Wynne wrote: > > On 19 May 2009, at 14:53, Lee Longmore wrote: > >> I am trying to specify a controller with RSpec for the first time. >> >> I have been using mock_model to date but, given that the models are >> fully implemented, I am wondering if I should be using stub_model. >> >> Based on what I have read, I am struggling to understand the >> advantages that stub_model over mock_model might provide. >> >> Should I be using stub_model and if so, why? > > *Should* is a big word here. It depends. > > When you use a stub model, you get a real instance of your AR model > object, with the database connection crippled so you can't > accidentally do something that will make your specs slow. The > benefit of this is that you get all the methods on the model > available to the controller. For example, if you have a User class > which takes a date_of_birth attribute in it's constructor, you can > call the #age method. > > This can make your tests easier to read. > > The cost of this is that your controller specs will be covering code > in the model classes as well as the controller you're explicitly > testing. There is a chance you'll make a change to the #age method > on your User (maybe you want to specify in days rather than years), > make the user specs pass, and check in believing you're done. > Unwittingly, you have just broken the controller specs too. > > If you read what from the really experienced guys who started this > stuff off[1] say, you'll hear that mocks are really a design tool. > By creating a mock_model in your controller specs rather than > leaning on the stub_model, you're designing your 'ideal model', > rather than being constrained by whatever default methods > activerecord gives you, or you have already written. I often find > that this process drives out much more elegant interfaces onto the > models, and sometimes even shows me where I need to introduce an > intermediate class. > > I think this is something you really have to play around with for > yourself to find the right balance for you and your team. > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com [1]http://www.m3p.co.uk/blog/2009/03/08/mock-roles-not-objects-live-and-in-person/ Matt Wynne http://blog.mattwynne.net http://www.songkick.com From tero at tilus.net Tue May 19 15:11:35 2009 From: tero at tilus.net (Tero Tilus) Date: Tue, 19 May 2009 22:11:35 +0300 Subject: [rspec-users] [RSpec, Rails] POST create action spec and before_filter In-Reply-To: References: <20090519060423.GI10196@uivelo.tilus.net> Message-ID: <20090519191135.GA15324@uivelo.tilus.net> 2009-05-19 10:22, Florent Florent: > BTW how can I spec that my @context is correctly set by my filter? How can you tell from _outside_ if the context is properly set or not? What does your controller use the context for? And what happens if the controller does or doesn't know about the context? -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Tue May 19 15:54:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 May 2009 14:54:38 -0500 Subject: [rspec-users] RSpec for Rails plugin In-Reply-To: References: Message-ID: <57c63afe0905191254u302ac93br5398eba7e9526e89@mail.gmail.com> On Tue, May 19, 2009 at 11:54 AM, Sarah Allen wrote: > I'm trying to write specs to test a Rails plugin and I'm not clear on > what needs to be installed and required. ?Works fine for many specs, but > view testing fails (i.e. anything relying rspec-rails over just rspec). > > In other words, how can I use the rspec-rails gem to test a plugin?' Check out Pat's rspec plugin generator: http://github.com/pat-maddox/rspec-plugin-generator/tree/master > > Thanks, > Sarah > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue May 19 17:21:21 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 May 2009 16:21:21 -0500 Subject: [rspec-users] unexpected message expectations issue In-Reply-To: <83e853830905191250p5bb1a533vb16a016f0135845c@mail.gmail.com> References: <83e853830905191250p5bb1a533vb16a016f0135845c@mail.gmail.com> Message-ID: <57c63afe0905191421j33360c7ah2ab68a118b0410c6@mail.gmail.com> On Tue, May 19, 2009 at 2:50 PM, Barun Singh wrote: > Suppose a User has many Items, and I want to spec that when a user is > destroyed its associated items are destroyed.? I'm seeing some unexpected > behavior: > > describe User do > ? before(:each) do > ? ? @user = create_user?? # helper method that actually creates & saves a > user > ? ? @item = create_item > ? ? @user.items << @item > ? end > > ? # THIS WORKS > ? it "should delete associated items when a user is destroyed" do > ? ? @item.should == @user.items[0] > ? ? @user.items[0].should_receive(:destroy) > ? ? @user.destroy > ? end > > ? # THIS FAILS > ?? it "should delete associated items when a user is destroyed" do > ? ? @item.should_receive(:destroy) > ? ? @user.destroy > ? end > end > > Why does the message expectation fail on @item but succeed on > @user.items[0], even though @user.items[0] == @item ? But @user.items[0].equal?(@item) wiil return false. They're not the same object. One of the mysteries of AR associations and proxies. > > Thanks... > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From szimek at gmail.com Tue May 19 17:13:09 2009 From: szimek at gmail.com (szimek) Date: Tue, 19 May 2009 14:13:09 -0700 (PDT) Subject: [rspec-users] Problem with testing Rails action that uses return keyword Message-ID: <245e6fe5-9449-458a-97df-fb9174940b83@n8g2000vbb.googlegroups.com> Hi, I'm trying to test Rails action that looks like this: def create unless facebook_session authentication_failed and return end ... @facebook_user = facebook_session.user ... end authentication_failed method redirects to '/'. The test looks like this: it 'should call authentication_failed' do controller.should_receive(:authentication_failed) get :create end The problem is that in the test, despite the fact that facebook_session is nil and the authentication_failed method is called, the action does not return and I got error in facebook_session.user line, because facebook_session is nil. If I move the return keyword to the next line, the test complains then about missing create.erb template. Any ideas how to solve it? From luke at lukemelia.com Tue May 19 18:26:49 2009 From: luke at lukemelia.com (Luke Melia) Date: Tue, 19 May 2009 18:26:49 -0400 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> Message-ID: Any further thoughts on this, Aslak? I'd prefer to go with a solution in line with the future direction of Cucumber if possible. Cheers, Luke On May 15, 2009, at 5:12 PM, Luke Melia wrote: > On May 15, 2009, at 3:36 PM, aslak hellesoy wrote: > >> Thanks for doing that. I have one more favour to ask: Can you show me >> an example of a StepDefinition that would cause the file to be >> created? > > That is a tougher question, because any browser interaction that > causes an HTTP request to the app under test could result in a > server error. > > Ajax requests can be triggered by javascript, and in various parts > of our app, they are triggered by clicking on links, submitting > forms, dragging and dropping divs, hovering over a div, waiting for > a page load to complete, as a callback from interacting with a 3rd > party web service, or waiting for a setTimeout to execute. > > So one way I could tackle it is to add a step to the end of every > scenario that says "Then the application should not have issued any > responses with 50x status codes", but that would be a) repetitive, > and b) not fail until all steps had run, making it harder to track > down the step in the test where the failure occurred. > > One way to look at may be that I'm trying to enforce an invariant. > Under no circumstances in my test suite is it appropriate for my app > to raise a 50x error. In my Rails integration suite, webrat enforces > this particular invariant for me, but can't find a good hook in the > selenium test stack to do this, which is why I'm looking at this > route. > > Cheers, > Luke > > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From aslak.hellesoy at gmail.com Tue May 19 19:04:07 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 May 2009 01:04:07 +0200 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> Message-ID: <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> > Any further thoughts on this, Aslak? I'd prefer to go with a solution in > line with the future direction of Cucumber if possible. > Sorry, forgot to get back to you Luke. I'm convinced. We'll add an AfterStep hook. Do you want to give a stab at a patch? Start by writing a feature - see features/after_block_exceptions.feature for a good example of the style we like... Aslak > Cheers, > Luke > > On May 15, 2009, at 5:12 PM, Luke Melia wrote: > >> On May 15, 2009, at 3:36 PM, aslak hellesoy wrote: >> >>> Thanks for doing that. I have one more favour to ask: Can you show me >>> an example of a StepDefinition that would cause the file to be >>> created? >> >> That is a tougher question, because any browser interaction that causes an >> HTTP request to the app under test could result in a server error. >> >> Ajax requests can be triggered by javascript, and in various parts of our >> app, they are triggered by clicking on links, submitting forms, dragging and >> dropping divs, hovering over a div, waiting for a page load to complete, as >> a callback from interacting with a 3rd party web service, or waiting for a >> setTimeout to execute. >> >> So one way I could tackle it is to add a step to the end of every scenario >> that says "Then the application should not have issued any responses with >> 50x status codes", but that would be a) repetitive, and b) not fail until >> all steps had run, making it harder to track down the step in the test where >> the failure occurred. >> >> One way to look at may be that I'm trying to enforce an invariant. Under >> no circumstances in my test suite is it appropriate for my app to raise a >> 50x error. In my Rails integration suite, webrat enforces this particular >> invariant for me, but can't find a good hook in the selenium test stack to >> do this, which is why I'm looking at this route. >> >> Cheers, >> Luke >> >> -- >> Luke Melia >> luke at lukemelia.com >> http://www.lukemelia.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Tue May 19 19:50:19 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 20 May 2009 00:50:19 +0100 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> Message-ID: <55C8C94B-5F23-4F5E-AF94-B45135C45355@mattwynne.net> On 20 May 2009, at 00:04, aslak hellesoy wrote: >> Any further thoughts on this, Aslak? I'd prefer to go with a >> solution in >> line with the future direction of Cucumber if possible. >> > > Sorry, forgot to get back to you Luke. > > I'm convinced. We'll add an AfterStep hook. Do you want to give a stab > at a patch? Start by writing a feature - see > features/after_block_exceptions.feature for a good example of the > style we like... Can I make a mild plea for After(:step) rather than AfterStep? I think it looks nicer and it's one less method added to the API... Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From ben at benmabey.com Tue May 19 22:39:25 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 19 May 2009 20:39:25 -0600 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> Message-ID: <4A136D5D.8090807@benmabey.com> Luke Melia wrote: > Any further thoughts on this, Aslak? I'd prefer to go with a solution > in line with the future direction of Cucumber if possible. > > Cheers, > Luke Have you seen what Matt added recently? https://rspec.lighthouseapp.com/projects/16211/tickets/330-gracefully-handle-exceptions-in-after-block#ticket-330-11 I think this should cover your use case... WDYT? -Ben > > On May 15, 2009, at 5:12 PM, Luke Melia wrote: > >> On May 15, 2009, at 3:36 PM, aslak hellesoy wrote: >> >>> Thanks for doing that. I have one more favour to ask: Can you show me >>> an example of a StepDefinition that would cause the file to be >>> created? >> >> That is a tougher question, because any browser interaction that >> causes an HTTP request to the app under test could result in a server >> error. >> >> Ajax requests can be triggered by javascript, and in various parts of >> our app, they are triggered by clicking on links, submitting forms, >> dragging and dropping divs, hovering over a div, waiting for a page >> load to complete, as a callback from interacting with a 3rd party web >> service, or waiting for a setTimeout to execute. >> >> So one way I could tackle it is to add a step to the end of every >> scenario that says "Then the application should not have issued any >> responses with 50x status codes", but that would be a) repetitive, >> and b) not fail until all steps had run, making it harder to track >> down the step in the test where the failure occurred. >> >> One way to look at may be that I'm trying to enforce an invariant. >> Under no circumstances in my test suite is it appropriate for my app >> to raise a 50x error. In my Rails integration suite, webrat enforces >> this particular invariant for me, but can't find a good hook in the >> selenium test stack to do this, which is why I'm looking at this route. >> >> Cheers, >> Luke >> >> -- >> Luke Melia >> luke at lukemelia.com >> http://www.lukemelia.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luke at lukemelia.com Tue May 19 22:43:43 2009 From: luke at lukemelia.com (Luke Melia) Date: Tue, 19 May 2009 22:43:43 -0400 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> Message-ID: <3063013F-5181-478E-8097-32F05DD2FB9B@lukemelia.com> On May 19, 2009, at 7:04 PM, aslak hellesoy wrote: > I'm convinced. We'll add an AfterStep hook. Do you want to give a stab > at a patch? Start by writing a feature - see > features/after_block_exceptions.feature for a good example of the > style we like... Sounds good. I'll give it a whirl tonight. Cheers, Luke > > Aslak > >> Cheers, >> Luke >> >> On May 15, 2009, at 5:12 PM, Luke Melia wrote: >> >>> On May 15, 2009, at 3:36 PM, aslak hellesoy wrote: >>> >>>> Thanks for doing that. I have one more favour to ask: Can you >>>> show me >>>> an example of a StepDefinition that would cause the file to be >>>> created? >>> >>> That is a tougher question, because any browser interaction that >>> causes an >>> HTTP request to the app under test could result in a server error. >>> >>> Ajax requests can be triggered by javascript, and in various parts >>> of our >>> app, they are triggered by clicking on links, submitting forms, >>> dragging and >>> dropping divs, hovering over a div, waiting for a page load to >>> complete, as >>> a callback from interacting with a 3rd party web service, or >>> waiting for a >>> setTimeout to execute. >>> >>> So one way I could tackle it is to add a step to the end of every >>> scenario >>> that says "Then the application should not have issued any >>> responses with >>> 50x status codes", but that would be a) repetitive, and b) not >>> fail until >>> all steps had run, making it harder to track down the step in the >>> test where >>> the failure occurred. >>> >>> One way to look at may be that I'm trying to enforce an invariant. >>> Under >>> no circumstances in my test suite is it appropriate for my app to >>> raise a >>> 50x error. In my Rails integration suite, webrat enforces this >>> particular >>> invariant for me, but can't find a good hook in the selenium test >>> stack to >>> do this, which is why I'm looking at this route. >>> >>> Cheers, >>> Luke >>> >>> -- >>> Luke Melia >>> luke at lukemelia.com >>> http://www.lukemelia.com/ >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> -- >> Luke Melia >> luke at lukemelia.com >> http://www.lukemelia.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 -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From ben at benmabey.com Tue May 19 22:57:22 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 19 May 2009 20:57:22 -0600 Subject: [rspec-users] autotest? In-Reply-To: <4A136BE9.2060608@haskinferguson.net> References: <4A136BE9.2060608@haskinferguson.net> Message-ID: <4A137192.30102@benmabey.com> Denis Haskin wrote: > Can someone point me to some decent doc on autotest? Everything I'm > finding seems either pretty old, or says "autotest and rspec work out > of the box", which it isn't for me... > > I installed the grosser-autotest gem (just guessing) and when I run > autotest it only runs (legacy) test/unit tests. > > Suggestions? RSpec now ships with an autospec command that acts as a wrapper.. are you using it? -Ben > > Thanks... > > dwh > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Tue May 19 23:16:22 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 19 May 2009 21:16:22 -0600 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <4A136D5D.8090807@benmabey.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <4A136D5D.8090807@benmabey.com> Message-ID: <4A137606.9010806@benmabey.com> Ben Mabey wrote: > Luke Melia wrote: >> Any further thoughts on this, Aslak? I'd prefer to go with a solution >> in line with the future direction of Cucumber if possible. >> >> Cheers, >> Luke > > Have you seen what Matt added recently? > > https://rspec.lighthouseapp.com/projects/16211/tickets/330-gracefully-handle-exceptions-in-after-block#ticket-330-11 > > > I think this should cover your use case... WDYT? > > -Ben > Never mind, I just reread the thread... :) >> >> On May 15, 2009, at 5:12 PM, Luke Melia wrote: >> >>> On May 15, 2009, at 3:36 PM, aslak hellesoy wrote: >>> >>>> Thanks for doing that. I have one more favour to ask: Can you show me >>>> an example of a StepDefinition that would cause the file to be >>>> created? >>> >>> That is a tougher question, because any browser interaction that >>> causes an HTTP request to the app under test could result in a >>> server error. >>> >>> Ajax requests can be triggered by javascript, and in various parts >>> of our app, they are triggered by clicking on links, submitting >>> forms, dragging and dropping divs, hovering over a div, waiting for >>> a page load to complete, as a callback from interacting with a 3rd >>> party web service, or waiting for a setTimeout to execute. >>> >>> So one way I could tackle it is to add a step to the end of every >>> scenario that says "Then the application should not have issued any >>> responses with 50x status codes", but that would be a) repetitive, >>> and b) not fail until all steps had run, making it harder to track >>> down the step in the test where the failure occurred. >>> >>> One way to look at may be that I'm trying to enforce an invariant. >>> Under no circumstances in my test suite is it appropriate for my app >>> to raise a 50x error. In my Rails integration suite, webrat enforces >>> this particular invariant for me, but can't find a good hook in the >>> selenium test stack to do this, which is why I'm looking at this route. >>> >>> Cheers, >>> Luke >>> >>> -- >>> Luke Melia >>> luke at lukemelia.com >>> http://www.lukemelia.com/ >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> -- >> Luke Melia >> luke at lukemelia.com >> http://www.lukemelia.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 korny at sietsma.com Tue May 19 23:29:01 2009 From: korny at sietsma.com (Korny Sietsma) Date: Wed, 20 May 2009 13:29:01 +1000 Subject: [rspec-users] Issue with jruby and cucumber step with 4 parameters Message-ID: <8e15872b0905192029w6da935bbgf70464effd7fcc2@mail.gmail.com> Hi - sorry for the cross-list post, but this issue happens only with cucumber and jruby, and I'm not 100% sure which has the problem. It doesn't happen with non-j ruby though. Versions: cucumber 0.2.3 jruby 1.2.0 on Ubuntu amd64 When I have a cucumber feature with a "Then" step: (well, really it's an "And" step): And the association between "oh" and "apf" has an active adpoint named "ap" with id "7890" which translates to the ruby code: Then /^the association between "(.*)" and "(.*)" has an active adpoint named "(.*)" with id "(.*)"$/ do |arg1,arg2, arg3, arg4| # nothing needed here to cause the problem... end In JRuby (with --backtrace enabled), I get: And the association between "oh" and "apf" has an active adpoint named "ap" with id "7890" # test/features/step_definitions/migration_steps.rb:122 wrong # of arguments(4 for 3) (ArgumentError) /home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/core_ext/instance_exec.rb:20:in `cucumber_instance_exec' /home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/core_ext/instance_exec.rb:38:in `cucumber_run_with_backtrace_filtering' /home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/core_ext/instance_exec.rb:10:in `cucumber_instance_exec' /home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/step_definition.rb:105:in `invoke' ... rest of stack trace elided In the normal ruby version of cucumber, this works fine. I looked at the specific code line, but it's just a call to: instance_exec(*args, &block) Does JRuby have a problem with large numbers of regexp capture groups? Or is there something else going on here? - Korny -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" From denis at haskinferguson.net Tue May 19 23:35:21 2009 From: denis at haskinferguson.net (Denis Haskin) Date: Tue, 19 May 2009 23:35:21 -0400 Subject: [rspec-users] autotest? In-Reply-To: <4A137192.30102@benmabey.com> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> Message-ID: <4A137A79.1030300@haskinferguson.net> Hmm. Okay, tried that but: $ autospec (Not running features. To run features in autotest, set AUTOFEATURE=true.) loading autotest/rails_rspec Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. I'm running my rails rspec examples just fine manually... dwh Ben Mabey wrote: > RSpec now ships with an autospec command that acts as a wrapper.. are > you using it? > > -Ben > From scott at railsnewbie.com Wed May 20 00:14:15 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 20 May 2009 00:14:15 -0400 Subject: [rspec-users] autotest? In-Reply-To: <4A137A79.1030300@haskinferguson.net> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> Message-ID: <4A138397.2090907@railsnewbie.com> Denis Haskin wrote: > Hmm. Okay, tried that but: > > $ autospec > (Not running features. To run features in autotest, set > AUTOFEATURE=true.) > loading autotest/rails_rspec > Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. > > I'm running my rails rspec examples just fine manually... > > dwh > What version of the ZenTest gem do you have? > > Ben Mabey wrote: >> RSpec now ships with an autospec command that acts as a wrapper.. are >> you using it? >> >> -Ben >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From scott at railsnewbie.com Wed May 20 01:08:41 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 20 May 2009 01:08:41 -0400 Subject: [rspec-users] auto test? In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013A0F45@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F45@awww.armis.com> Message-ID: <4A139059.80506@railsnewbie.com> Diwakar, ANGLER - EIT wrote: > I am new to rspec > > I am using ZenTest gem. I ran the autospec from the root directory. > > I am getting the below error. > > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in > `expand_path': couldn't find HOME environment -- expanding > `~/.autotest' (ArgumentError) > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in > `initialize' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in `new' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in `run' > from c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest:55 > from c:/ruby/bin/autotest:19:in `load' > from c:/ruby/bin/autotest:19 > > How should I resolve the above issue and run autospec command? sudo gem update ZenTest Scott > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luke at lukemelia.com Wed May 20 01:21:35 2009 From: luke at lukemelia.com (Luke Melia) Date: Wed, 20 May 2009 01:21:35 -0400 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <3063013F-5181-478E-8097-32F05DD2FB9B@lukemelia.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> <3063013F-5181-478E-8097-32F05DD2FB9B@lukemelia.com> Message-ID: <308B2ED5-138D-453D-8265-A022457FA471@lukemelia.com> On May 19, 2009, at 10:43 PM, Luke Melia wrote: > On May 19, 2009, at 7:04 PM, aslak hellesoy wrote: > >> I'm convinced. We'll add an AfterStep hook. Do you want to give a >> stab >> at a patch? Start by writing a feature - see >> features/after_block_exceptions.feature for a good example of the >> style we like... > > Sounds good. I'll give it a whirl tonight. Here's my first pass: http://github.com/weplay/cucumber/commit/39601bc5eb6f0761dd7bedddc5484cdd895ca787 Not crazy about the way it tracks the current_scenario or the exception_fails_scenario parameter on Hook#execute_in. Unlike Before and After hooks, I think it's preferable for AfterStep to fail the step than to call scenario.fail! Thoughts? Cheers, Luke -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From diwakar at angleritech.com Wed May 20 01:27:04 2009 From: diwakar at angleritech.com (Diwakar, ANGLER - EIT) Date: Wed, 20 May 2009 10:57:04 +0530 Subject: [rspec-users] auto test? In-Reply-To: <4A139059.80506@railsnewbie.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F45@awww.armis.com> <4A139059.80506@railsnewbie.com> Message-ID: <09CAF7492BB188429DDFABCD8218F283013A0F6B@awww.armis.com> I am still getting the same error c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in `expand_path ': couldn't find HOME environment -- expanding `~/.autotest' (ArgumentError) from c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in `initialize' from ./vendor/plugins/rspec/lib/autotest/rspec.rb:23:in `initialize' from c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in `new' from c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in `run' from c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/bin/autotest:55 from c:/ruby/bin/autotest:19:in `load' from c:/ruby/bin/autotest:19 -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Scott Taylor Sent: Wednesday, May 20, 2009 10:39 AM To: rspec-users Subject: Re: [rspec-users] auto test? Diwakar, ANGLER - EIT wrote: > I am new to rspec > > I am using ZenTest gem. I ran the autospec from the root directory. > > I am getting the below error. > > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in > `expand_path': couldn't find HOME environment -- expanding > `~/.autotest' (ArgumentError) > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in > `initialize' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in `new' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in `run' > from c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest:55 > from c:/ruby/bin/autotest:19:in `load' > from c:/ruby/bin/autotest:19 > > How should I resolve the above issue and run autospec command? sudo gem update ZenTest Scott > ---------------------------------------------------------------------- > -- > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From scott at railsnewbie.com Wed May 20 01:58:02 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 20 May 2009 01:58:02 -0400 Subject: [rspec-users] auto test? In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013A0F6B@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F45@awww.armis.com> <4A139059.80506@railsnewbie.com> <09CAF7492BB188429DDFABCD8218F283013A0F6B@awww.armis.com> Message-ID: <4A139BEA.2080201@railsnewbie.com> Diwakar, ANGLER - EIT wrote: > > > I am still getting the same error > > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in > `expand_path > ': couldn't find HOME environment -- expanding `~/.autotest' > (ArgumentError) > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in > `initialize' > from ./vendor/plugins/rspec/lib/autotest/rspec.rb:23:in > `initialize' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in > `new' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in > `run' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/bin/autotest:55 > from c:/ruby/bin/autotest:19:in `load' > from c:/ruby/bin/autotest:19 > I haven't used Windows in a few years, but some simple googling turned up this: http://dirk.net/2008/01/30/autotest-rails-on-windows/ Scott > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org > [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Scott Taylor > Sent: Wednesday, May 20, 2009 10:39 AM > To: rspec-users > Subject: Re: [rspec-users] auto test? > > Diwakar, ANGLER - EIT wrote: > >> I am new to rspec >> >> I am using ZenTest gem. I ran the autospec from the root directory. >> >> I am getting the below error. >> >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in >> `expand_path': couldn't find HOME environment -- expanding >> `~/.autotest' (ArgumentError) >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in >> `initialize' >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in >> > `new' > >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in >> > `run' > >> from >> > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest:55 > >> from c:/ruby/bin/autotest:19:in `load' >> from c:/ruby/bin/autotest:19 >> >> How should I resolve the above issue and run autospec command? >> > sudo gem update ZenTest > > Scott > > >> ---------------------------------------------------------------------- >> -- >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 20 01:58:18 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 May 2009 00:58:18 -0500 Subject: [rspec-users] getting strings in results In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013A0F60@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F60@awww.armis.com> Message-ID: <57c63afe0905192258v636d6f82yd7c98ba73c22073@mail.gmail.com> On Wed, May 20, 2009 at 12:12 AM, Diwakar, ANGLER - EIT wrote: > Earlier I used rspec for a small module in which I could see the string used > in the example displayed in the results > > for eg. > > ?1.should be success > ?2. should?be redirect(failed) > > 2?examples, 1 failure > > Now I upgraded the rails version and getting the results as > > 2?examples, 1 failure. > > what may be the reason? > > my rails/rspec versions > > rails version 2.3.2 > rspec 1.1.8 Rails 2.3 requires rspec 1.2 or greater. From lists at ruby-forum.com Wed May 20 02:39:14 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 20 May 2009 08:39:14 +0200 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Tue, May 19, 2009 at 9:04 AM, Amit Kulkarni > wrote: >> but i am getting the same error which says RuntimeError in >> Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control >> ./channels_controller_spec1.rb:149: > It looks like you're calling the file from the spec/controllers > directory. Just for fun, step up to the project root and run: > > script/spec spec/controllers/channels_controller_spec1.rb Hey It worked thanks a lot. :-) Can you tell me the difference why it was not running earlier and now it is running.Just for my understanding. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Wed May 20 02:47:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 May 2009 08:47:08 +0200 Subject: [rspec-users] Issue with jruby and cucumber step with 4 parameters In-Reply-To: <8e15872b0905192029w6da935bbgf70464effd7fcc2@mail.gmail.com> References: <8e15872b0905192029w6da935bbgf70464effd7fcc2@mail.gmail.com> Message-ID: <8d961d900905192347x18b0fafcp778e24d8325449b3@mail.gmail.com> The Cucumber list has moved: http://www.nabble.com/-Cucumber--ANN%3A-New-Google-Group-for-Cucumber-td23602831.html On Wed, May 20, 2009 at 5:29 AM, Korny Sietsma wrote: > Hi - sorry for the cross-list post, but this issue happens only with > cucumber and jruby, and I'm not 100% sure which has the problem. It > doesn't happen with non-j ruby though. > Versions: > ?cucumber 0.2.3 > ?jruby 1.2.0 on Ubuntu amd64 > > When I have a cucumber feature with a "Then" step: (well, really it's > an "And" step): > ? ? ? ?And the association between "oh" and "apf" has an active adpoint > named "ap" with id "7890" > which translates to the ruby code: > ? ? ? Then /^the association between "(.*)" and "(.*)" has an active > adpoint named "(.*)" with id "(.*)"$/ do |arg1,arg2, arg3, arg4| > ? ? ? ? ? # nothing needed here to cause the problem... > ? ? ? end > > In JRuby (with --backtrace enabled), I get: > ? ?And the association between "oh" and "apf" has an active adpoint > named "ap" with id "7890" # > test/features/step_definitions/migration_steps.rb:122 > ? ? ?wrong # of arguments(4 for 3) (ArgumentError) > ? ? ?/home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/core_ext/instance_exec.rb:20:in > `cucumber_instance_exec' > ? ? ?/home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/core_ext/instance_exec.rb:38:in > `cucumber_run_with_backtrace_filtering' > ? ? ?/home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/core_ext/instance_exec.rb:10:in > `cucumber_instance_exec' > ? ? ?/home/yellow/Projects/cmt_workspace/cmtapps/jruby/lib/ruby/gems/1.8/gems/cucumber-0.3.5/bin/../lib/cucumber/step_definition.rb:105:in > `invoke' > ... rest of stack trace elided > > In the normal ruby version of cucumber, this works fine. > > I looked at the specific code line, but it's just a call to: > ? instance_exec(*args, &block) > > Does JRuby have a problem with large numbers of regexp capture groups? > ?Or is there something else going on here? > > - Korny > -- > Kornelis Sietsma ?korny at my surname dot com > "Every jumbled pile of person has a thinking part > that wonders what the part that isn't thinking > isn't thinking of" > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed May 20 02:47:44 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 20 May 2009 08:47:44 +0200 Subject: [rspec-users] Error in executing controller spec In-Reply-To: References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> Message-ID: <1b534ddfb9cb2b19c34c497fd6e3509e@ruby-forum.com> Amit Kulkarni wrote: > David Chelimsky wrote: >> On Tue, May 19, 2009 at 9:04 AM, Amit Kulkarni >> wrote: >>> but i am getting the same error which says RuntimeError in >>> Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control >>> ./channels_controller_spec1.rb:149: >> It looks like you're calling the file from the spec/controllers >> directory. Just for fun, step up to the project root and run: >> >> script/spec spec/controllers/channels_controller_spec1.rb > > Hey It worked thanks a lot. :-) > > Can you tell me the difference why it was not running earlier and now it > is running.Just for my understanding. It is not the case that i will always run spec from the root project.So if i want to run from spec/controllers direcrtory then what should i do since i am getting the error. -- Posted via http://www.ruby-forum.com/. From diwakar at angleritech.com Wed May 20 02:48:36 2009 From: diwakar at angleritech.com (Diwakar, ANGLER - EIT) Date: Wed, 20 May 2009 12:18:36 +0530 Subject: [rspec-users] getting strings in results In-Reply-To: <57c63afe0905192258v636d6f82yd7c98ba73c22073@mail.gmail.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F60@awww.armis.com> <57c63afe0905192258v636d6f82yd7c98ba73c22073@mail.gmail.com> Message-ID: <09CAF7492BB188429DDFABCD8218F283013A0F90@awww.armis.com> I updated rspec to 1.2 still I am not getting string values Diwa -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky Sent: Wednesday, May 20, 2009 11:28 AM To: rspec-users Subject: Re: [rspec-users] getting strings in results On Wed, May 20, 2009 at 12:12 AM, Diwakar, ANGLER - EIT wrote: > Earlier I used rspec for a small module in which I could see the > string used in the example displayed in the results > > for eg. > > ?1.should be success > ?2. should?be redirect(failed) > > 2?examples, 1 failure > > Now I upgraded the rails version and getting the results as > > 2?examples, 1 failure. > > what may be the reason? > > my rails/rspec versions > > rails version 2.3.2 > rspec 1.1.8 Rails 2.3 requires rspec 1.2 or greater. _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed May 20 03:12:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 May 2009 02:12:08 -0500 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <1b534ddfb9cb2b19c34c497fd6e3509e@ruby-forum.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> <1b534ddfb9cb2b19c34c497fd6e3509e@ruby-forum.com> Message-ID: <57c63afe0905200012w7fff2711ka103defc00cc483f@mail.gmail.com> On Wed, May 20, 2009 at 1:47 AM, Amit Kulkarni wrote: > Amit Kulkarni wrote: >> David Chelimsky wrote: >>> On Tue, May 19, 2009 at 9:04 AM, Amit Kulkarni >>> wrote: >>>> but i am getting the same error which says ?RuntimeError in >>>> Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_control >>>> ./channels_controller_spec1.rb:149: >>> It looks like you're calling the file from the spec/controllers >>> directory. Just for fun, step up to the project root and run: >>> >>> script/spec spec/controllers/channels_controller_spec1.rb >> >> Hey It worked thanks a lot. :-) >> >> Can you tell me the difference why it was not running earlier and now it >> is running.Just for my understanding. > > It is not the case that i will always run spec from the root project.So > if i want to run from spec/controllers direcrtory then what should i do > since i am getting the error. Unfortunately, you're going to have to run it from the project root because that's the only it works, apparently. You can file a bug report at http://rspec.lighthouseapp.com if you're interested. Cheers, David From dchelimsky at gmail.com Wed May 20 03:13:15 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 May 2009 02:13:15 -0500 Subject: [rspec-users] getting strings in results In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013A0F90@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F60@awww.armis.com> <57c63afe0905192258v636d6f82yd7c98ba73c22073@mail.gmail.com> <09CAF7492BB188429DDFABCD8218F283013A0F90@awww.armis.com> Message-ID: <57c63afe0905200013q56d52aacic32cbd50d7dc6e8f@mail.gmail.com> On Wed, May 20, 2009 at 1:48 AM, Diwakar, ANGLER - EIT wrote: > I updated rspec to 1.2 still I am not getting string values I'm going to need a bit more context than that. Please post some code, rspec examples and backtraces. > > Diwa > > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Wednesday, May 20, 2009 11:28 AM > To: rspec-users > Subject: Re: [rspec-users] getting strings in results > > On Wed, May 20, 2009 at 12:12 AM, Diwakar, ANGLER - EIT wrote: >> Earlier I used rspec for a small module in which I could see the >> string used in the example displayed in the results >> >> for eg. >> >> ?1.should be success >> ?2. should?be redirect(failed) >> >> 2?examples, 1 failure >> >> Now I upgraded the rails version and getting the results as >> >> 2?examples, 1 failure. >> >> what may be the reason? >> >> my rails/rspec versions >> >> rails version 2.3.2 >> rspec 1.1.8 > > Rails 2.3 requires rspec 1.2 or greater. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed May 20 03:26:19 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 May 2009 09:26:19 +0200 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <308B2ED5-138D-453D-8265-A022457FA471@lukemelia.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> <3063013F-5181-478E-8097-32F05DD2FB9B@lukemelia.com> <308B2ED5-138D-453D-8265-A022457FA471@lukemelia.com> Message-ID: <8d961d900905200026m3ff312faia70a4446e5422780@mail.gmail.com> > On May 19, 2009, at 10:43 PM, Luke Melia wrote: > >> On May 19, 2009, at 7:04 PM, aslak hellesoy wrote: >> >>> I'm convinced. We'll add an AfterStep hook. Do you want to give a stab >>> at a patch? Start by writing a feature - see >>> features/after_block_exceptions.feature for a good example of the >>> style we like... >> >> Sounds good. I'll give it a whirl tonight. > > Here's my first pass: > > http://github.com/weplay/cucumber/commit/39601bc5eb6f0761dd7bedddc5484cdd895ca787 > > Not crazy about the way it tracks the current_scenario or the > exception_fails_scenario parameter on Hook#execute_in. Unlike Before and > After hooks, I think it's preferable for AfterStep to fail the step than to > call scenario.fail! > I agree - I'm not crazy about those small hacks you did, but completely understand why you did it. I'd probably have done the same myself. Some refactorings are needed in order to make this cleaner. They are small enough hacks that I'll pull it in :-) Aslak > Thoughts? > > Cheers, > Luke > -- > Luke Melia > luke at lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed May 20 03:47:27 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 20 May 2009 09:47:27 +0200 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <57c63afe0905200012w7fff2711ka103defc00cc483f@mail.gmail.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> <1b534ddfb9cb2b19c34c497fd6e3509e@ruby-forum.com> <57c63afe0905200012w7fff2711ka103defc00cc483f@mail.gmail.com> Message-ID: <68ef1261461f21693580f4a09d9be2de@ruby-forum.com> David Chelimsky wrote: > On Wed, May 20, 2009 at 1:47 AM, Amit Kulkarni > wrote: >>>> script/spec spec/controllers/channels_controller_spec1.rb >>> >>> Hey It worked thanks a lot. :-) >>> >>> Can you tell me the difference why it was not running earlier and now it >>> is running.Just for my understanding. >> >> It is not the case that i will always run spec from the root project.So >> if i want to run from spec/controllers direcrtory then what should i do >> since i am getting the error. > > Unfortunately, you're going to have to run it from the project root > because that's the only it works, apparently. You can file a bug > report at http://rspec.lighthouseapp.com if you're interested. > > Cheers, > David Thank a lot. But is the case that all controller specs are run from the root directory. I had had written spec models and it runs fine from inside the spec directory. I will sure file a ticket on the site u mentioned. Also it will be good if i get to know the reason behind this :-) -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Wed May 20 04:33:29 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 May 2009 10:33:29 +0200 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <55C8C94B-5F23-4F5E-AF94-B45135C45355@mattwynne.net> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> <55C8C94B-5F23-4F5E-AF94-B45135C45355@mattwynne.net> Message-ID: <8d961d900905200133l3f03f957gce53b4509bc46643@mail.gmail.com> > > On 20 May 2009, at 00:04, aslak hellesoy wrote: > >>> Any further thoughts on this, Aslak? I'd prefer to go with a solution in >>> line with the future direction of Cucumber if possible. >>> >> >> Sorry, forgot to get back to you Luke. >> >> I'm convinced. We'll add an AfterStep hook. Do you want to give a stab >> at a patch? Start by writing a feature - see >> features/after_block_exceptions.feature for a good example of the >> style we like... > > Can I make a mild plea for After(:step) rather than AfterStep? I think it > looks nicer and it's one less method added to the API... > That would be confusing, since After already takes arguments (tags). Aslak > Matt Wynne > http://beta.songkick.com > http://blog.mattwynne.net > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed May 20 04:58:24 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 20 May 2009 10:58:24 +0200 Subject: [rspec-users] [Cucumber] JUnit, Spring and autowiring In-Reply-To: <23595316.post@talk.nabble.com> References: <23595316.post@talk.nabble.com> Message-ID: <8d961d900905200158ge13824dge06412ff7a679c06@mail.gmail.com> > > We are having trouble with JUnit-tests that are doing dependency injection in > the setup of database connections. The stacktrace identifies autowiring of > sessionFactory as the problem. During bean creation of sessionFactory we get > a NoSuchMethodError; probably because of trouble when initializing the cglib > class net.sf.cglib.proxy.Enhancer. I am using cucumber-maven-plugin on a The cucumber-maven plugin is intended to run Cucumber features, not JUnit tests, so I'm not sure I understand what you're trying to do. There is nothing JRuby or Cucumber specific in your stack trace. Could you please follow the guidelines for contributing and commit a fork to the cucumber_java project that shows how to reproduce the problem? http://wiki.github.com/aslakhellesoy/cucumber/contributing For new posts, please use the new ML: http://www.nabble.com/-Cucumber--ANN%3A-New-Google-Group-for-Cucumber-td23602831.html Aslak > pretty standard Spring project with Spring MVC, Hibernate and Java 1.6, > deploying to Tomcat and Jetty. > > -- Test Class (autowiring daoImpl): > [code=java] > @ContextConfiguration(locations = {"/test-config-db.xml"}) > @RunWith(SpringJUnit4ClassRunner.class) > public class SdbCollectorDbTest { > > ? ?@Autowired > ? ?private EventFactory eventFactory; > > ? ?@Autowired > ? ?@Qualifier("sdbDaoImpl") // tried using autowiring by name, it made no > difference > ? ?protected SdbDao sdbDao; > [/code] > > -- DaoImpl (autowiring sessionFactory): > [code=java] > @Repository > @Qualifier("sdbDaoImpl") // tried using autowiring by name, it made no > difference > @Transactional(readOnly = true) > public class SdbDaoImpl implements SdbDao { > > ? ?@Autowired > ? ?private SessionFactory sessionFactory; > [/code] > > -- Bean-config for sessionFactory and transactionManager: > [code=xml] > ? ? > ? ? > ? ? class="org.springframework.orm.hibernate3.HibernateTransactionManager"> > ? ? ? ? > ? ? > ? ? class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> > ? ? ? ? > ? ? ? ? > ? ? ? ? ? ?... cut... > ? ? ? ? > ? ? ? ? > ? ? ? ? ? ?...cut... > ? ? ? ? > > ? ? ? ? > ? ? > [/code] > > -- Stacktrace: > java.lang.IllegalStateException: Failed to load ApplicationContext > ? ? ? ? ? ? ? at > org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:203) > ? ? ? ? ? ? ? at > org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) > ? ? ? ? ? ? ? at > org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) > ? ? ? ? ? ? ? at > org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255) > ? ? ? ? ? ? ? at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:93) > ? ? ? ? ? ? ? at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:130) > ? ? ? ? ? ? ? at > org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) > ? ? ? ? ? ? ? at > org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) > ? ? ? ? ? ? ? at > org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) > ? ? ? ? ? ? ? at > org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) > ? ? ? ? ? ? ? at > org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) > ? ? ? ? ? ? ? at > com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:99) > ? ? ? ? ? ? ? at > com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40) > ? ? ? ? ? ? ? at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > ? ? ? ? ? ? ? at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > ? ? ? ? ? ? ? at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > ? ? ? ? ? ? ? at > com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sdbDaoImpl': Autowiring of fields failed; nested > exception is org.springframework.beans.factory.BeanCreationException: Could > not autowire field: private org.hibernate.SessionFactory > .SdbDaoImpl.sessionFactory; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'sessionFactory' defined in class path resource [datasource.xml]: > Invocation of init method failed; nested exception is > java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V > ? ? ? ? ? ? ? at > org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) > ? ? ? ? ? ? ? at java.security.AccessController.doPrivileged(Native Method) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) > ? ? ? ? ? ? ? at > org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) > ? ? ? ? ? ? ? at > org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) > ? ? ? ? ? ? ? at > org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84) > ? ? ? ? ? ? ? at > org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:42) > ? ? ? ? ? ? ? at > org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:173) > ? ? ? ? ? ? ? at > org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:199) > ? ? ? ? ? ? ? ... 22 more > Caused by: org.springframework.beans.factory.BeanCreationException: Could > not autowire field: private org.hibernate.SessionFactory > .adiseksport.dao.SdbDaoImpl.sessionFactory; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'sessionFactory' defined in class path resource [datasource.xml]: > Invocation of init method failed; nested exception is > java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V > ? ? ? ? ? ? ? at > org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240) > ? ? ? ? ? ? ? ... 39 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sessionFactory' defined in class path resource > [datasource.xml]: Invocation of init method failed; nested exception is > java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) > ? ? ? ? ? ? ? at java.security.AccessController.doPrivileged(Native Method) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412) > ? ? ? ? ? ? ? ... 41 more > Caused by: java.lang.NoSuchMethodError: > org.objectweb.asm.ClassWriter.(Z)V > ? ? ? ? ? ? ? at > net.sf.cglib.core.DebuggingClassWriter.(DebuggingClassWriter.java:47) > ? ? ? ? ? ? ? at > net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30) > ? ? ? ? ? ? ? at > net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24) > ? ? ? ? ? ? ? at > net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) > ? ? ? ? ? ? ? at > net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145) > ? ? ? ? ? ? ? at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117) > ? ? ? ? ? ? ? at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108) > ? ? ? ? ? ? ? at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104) > ? ? ? ? ? ? ? at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69) > ? ? ? ? ? ? ? at > org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117) > ? ? ? ? ? ? ? at > org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43) > ? ? ? ? ? ? ? at > org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162) > ? ? ? ? ? ? ? at > org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:135) > ? ? ? ? ? ? ? at > org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:55) > ? ? ? ? ? ? ? at > org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56) > ? ? ? ? ? ? ? at > org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:302) > ? ? ? ? ? ? ? at > org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:434) > ? ? ? ? ? ? ? at > org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109) > ? ? ? ? ? ? ? at > org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) > ? ? ? ? ? ? ? at > org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:226) > ? ? ? ? ? ? ? at > org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300) > ? ? ? ? ? ? ? at > org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814) > ? ? ? ? ? ? ? at > org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732) > ? ? ? ? ? ? ? at > org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) > ? ? ? ? ? ? ? at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) > ? ? ? ? ? ? ? ... 53 more > > > -- > View this message in context: http://www.nabble.com/-Cucumber--JUnit%2C-Spring-and-autowiring-tp23595316p23595316.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed May 20 05:11:08 2009 From: lists at ruby-forum.com (Zhenning Guan) Date: Wed, 20 May 2009 11:11:08 +0200 Subject: [rspec-users] Forum.count.should, should doesn't work? In-Reply-To: <57c63afe0905190819p1a42abb1g4dc3d9778a111de6@mail.gmail.com> References: <9cb02f05bd159090dedf1285f671d924@ruby-forum.com> <57c63afe0905190819p1a42abb1g4dc3d9778a111de6@mail.gmail.com> Message-ID: <0cc1cc90b12a5ffbc6d9c74fef4b4192@ruby-forum.com> David Chelimsky wrote: > On Tue, May 19, 2009 at 10:09 AM, Zhenning Guan > wrote: >> features/step_definitions/webrat_steps.rb:10 >> >> 1 scenario (1 failed) >> 2 steps (1 failed, 1 passed) >> >> === >> Forum.count == counts.to_i does fine > > That's not an expectation so it won't pass or fail. I'd bet that's > returning false, which is not going to make a step fail (only an error > will). I means.... Forum.count == counts.to_i doesn't work... -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed May 20 05:18:00 2009 From: lists at ruby-forum.com (Zhenning Guan) Date: Wed, 20 May 2009 11:18:00 +0200 Subject: [rspec-users] Forum.count.should, should doesn't work? In-Reply-To: <0cc1cc90b12a5ffbc6d9c74fef4b4192@ruby-forum.com> References: <9cb02f05bd159090dedf1285f671d924@ruby-forum.com> <57c63afe0905190819p1a42abb1g4dc3d9778a111de6@mail.gmail.com> <0cc1cc90b12a5ffbc6d9c74fef4b4192@ruby-forum.com> Message-ID: Zhenning Guan wrote: > David Chelimsky wrote: >> On Tue, May 19, 2009 at 10:09 AM, Zhenning Guan >> wrote: >>> features/step_definitions/webrat_steps.rb:10 >>> >>> 1 scenario (1 failed) >>> 2 steps (1 failed, 1 passed) >>> >>> === >>> Forum.count == counts.to_i does fine >> >> That's not an expectation so it won't pass or fail. I'd bet that's >> returning false, which is not going to make a step fail (only an error >> will). > > I means.... > Forum.count == counts.to_i > doesn't work... correct it Forum.count.should == counts.to_i doesn't work. -- Posted via http://www.ruby-forum.com/. From diwakar at angleritech.com Wed May 20 05:40:21 2009 From: diwakar at angleritech.com (Diwakar, ANGLER - EIT) Date: Wed, 20 May 2009 15:10:21 +0530 Subject: [rspec-users] auto test? In-Reply-To: <4A139BEA.2080201@railsnewbie.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F45@awww.armis.com> <4A139059.80506@railsnewbie.com><09CAF7492BB188429DDFABCD8218F283013A0F6B@awww.armis.com> <4A139BEA.2080201@railsnewbie.com> Message-ID: <09CAF7492BB188429DDFABCD8218F283013A0FCB@awww.armis.com> While running autospec I am getting the following error LIBMYSQL_.dll was not found and core_rl_magick_.dll was not found What should I do. -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Scott Taylor Sent: Wednesday, May 20, 2009 11:28 AM To: rspec-users Subject: Re: [rspec-users] auto test? Diwakar, ANGLER - EIT wrote: > > > I am still getting the same error > > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in > `expand_path > ': couldn't find HOME environment -- expanding `~/.autotest' > (ArgumentError) > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in > `initialize' > from ./vendor/plugins/rspec/lib/autotest/rspec.rb:23:in > `initialize' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in > `new' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in > `run' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/bin/autotest:55 > from c:/ruby/bin/autotest:19:in `load' > from c:/ruby/bin/autotest:19 > I haven't used Windows in a few years, but some simple googling turned up this: http://dirk.net/2008/01/30/autotest-rails-on-windows/ Scott > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org > [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Scott Taylor > Sent: Wednesday, May 20, 2009 10:39 AM > To: rspec-users > Subject: Re: [rspec-users] auto test? > > Diwakar, ANGLER - EIT wrote: > >> I am new to rspec >> >> I am using ZenTest gem. I ran the autospec from the root directory. >> >> I am getting the below error. >> >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in >> `expand_path': couldn't find HOME environment -- expanding >> `~/.autotest' (ArgumentError) >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in >> `initialize' >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in >> > `new' > >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in >> > `run' > >> from >> > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest:55 > >> from c:/ruby/bin/autotest:19:in `load' >> from c:/ruby/bin/autotest:19 >> >> How should I resolve the above issue and run autospec command? >> > sudo gem update ZenTest > > Scott > > >> --------------------------------------------------------------------- >> - >> -- >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From diwakar at angleritech.com Wed May 20 06:17:38 2009 From: diwakar at angleritech.com (Diwakar, ANGLER - EIT) Date: Wed, 20 May 2009 15:47:38 +0530 Subject: [rspec-users] auto test? In-Reply-To: <4A139BEA.2080201@railsnewbie.com> References: <09CAF7492BB188429DDFABCD8218F283013A0F45@awww.armis.com> <4A139059.80506@railsnewbie.com><09CAF7492BB188429DDFABCD8218F283013A0F6B@awww.armis.com> <4A139BEA.2080201@railsnewbie.com> Message-ID: <09CAF7492BB188429DDFABCD8218F283013A0FEE@awww.armis.com> Thanks a lot. It works How should I run a single file using autospec -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Scott Taylor Sent: Wednesday, May 20, 2009 11:28 AM To: rspec-users Subject: Re: [rspec-users] auto test? Diwakar, ANGLER - EIT wrote: > > > I am still getting the same error > > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in > `expand_path > ': couldn't find HOME environment -- expanding `~/.autotest' > (ArgumentError) > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:194:in > `initialize' > from ./vendor/plugins/rspec/lib/autotest/rspec.rb:23:in > `initialize' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in > `new' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/autotest.rb:138:in > `run' > from > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/bin/autotest:55 > from c:/ruby/bin/autotest:19:in `load' > from c:/ruby/bin/autotest:19 > I haven't used Windows in a few years, but some simple googling turned up this: http://dirk.net/2008/01/30/autotest-rails-on-windows/ Scott > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org > [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Scott Taylor > Sent: Wednesday, May 20, 2009 10:39 AM > To: rspec-users > Subject: Re: [rspec-users] auto test? > > Diwakar, ANGLER - EIT wrote: > >> I am new to rspec >> >> I am using ZenTest gem. I ran the autospec from the root directory. >> >> I am getting the below error. >> >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in >> `expand_path': couldn't find HOME environment -- expanding >> `~/.autotest' (ArgumentError) >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:190:in >> `initialize' >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in >> > `new' > >> from >> c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in >> > `run' > >> from >> > c:/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest:55 > >> from c:/ruby/bin/autotest:19:in `load' >> from c:/ruby/bin/autotest:19 >> >> How should I resolve the above issue and run autospec command? >> > sudo gem update ZenTest > > Scott > > >> --------------------------------------------------------------------- >> - >> -- >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From denis at haskinferguson.net Wed May 20 06:34:09 2009 From: denis at haskinferguson.net (Denis Haskin) Date: Wed, 20 May 2009 06:34:09 -0400 Subject: [rspec-users] autotest? In-Reply-To: <4A138397.2090907@railsnewbie.com> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> Message-ID: <4A13DCA1.4090105@haskinferguson.net> I didn't have ZenTest installed. I just did, but I still get the same error. Should I *not* have grosser-autotest installed? $ gem list | grep -i test grosser-autotest (4.0.4) test-unit (2.0.2) ZenTest (4.0.0) dwh Scott Taylor wrote: > Denis Haskin wrote: >> Hmm. Okay, tried that but: >> >> $ autospec >> (Not running features. To run features in autotest, set >> AUTOFEATURE=true.) >> loading autotest/rails_rspec >> Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. >> >> I'm running my rails rspec examples just fine manually... >> >> dwh >> > What version of the ZenTest gem do you have? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lee.Longmore at googlemail.com Wed May 20 07:03:43 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Wed, 20 May 2009 04:03:43 -0700 (PDT) Subject: [rspec-users] When to stub_model? In-Reply-To: <6D8825B9-4178-4BC1-9EEB-73DD8055D6FC@mattwynne.net> References: <499150.46456.qm@web23901.mail.ird.yahoo.com> <526E5C03-703F-42FF-A799-CEBFEFBE6B65@mattwynne.net> <6D8825B9-4178-4BC1-9EEB-73DD8055D6FC@mattwynne.net> Message-ID: <3e77d55f-278f-40f8-9c5c-33479d7e0867@r34g2000vbi.googlegroups.com> Thanks Matt. Very helpful. I have tried out stub_model. The constructor of one of my models (Namespace) requires a mandatory :name attribute to be provided. So when I try to stub_model it - e.g. representative_namespace = stub_model(Namespace) - I get the following spec error. 1) RuntimeError in 'ContextsController POST create authenticated user should assign a representative namespace to the new context' A namespace must be assigned a valid name /Users/leelon/work/cbox/app/models/namespace.rb:696:in `raise_no_name_error' /Users/leelon/work/cbox/app/models/namespace.rb:688:in `get_processed_name' /Users/leelon/work/cbox/app/models/namespace.rb:643:in `set_name' /Users/leelon/work/cbox/app/models/namespace.rb:64:in `initialize' ./spec/controllers/contexts_controller_spec.rb:37: script/spec:10: Is there a way around this while still making :name a mandatory requirement of the constructor? I have tried stubbing out :name in the call to stub_model but this doesn't help: representative_namespace = stub_model(Namespace, :name => 'A name') Thanks. From lists at ruby-forum.com Wed May 20 07:35:35 2009 From: lists at ruby-forum.com (Robert Lorimor) Date: Wed, 20 May 2009 13:35:35 +0200 Subject: [rspec-users] [Rspec] Problems with autospec In-Reply-To: <57c63afe0905140652k7d56e423g7b4fc12b26aa167b@mail.gmail.com> References: <57c63afe0905140652k7d56e423g7b4fc12b26aa167b@mail.gmail.com> Message-ID: <696a5f6e059d244860e7f9a90521cff4@ruby-forum.com> David Chelimsky wrote: > On Thu, May 14, 2009 at 7:51 AM, Hugo Barauna > wrote: >> Hi guys, I am having a problem with autospec. I upgraded to >> rspec-1.2.6, then I tried to run my specs with autospec. All my specs >> passes (green), until here, that's all ok. The problem is that after >> all my specs have passed, the autospec stops, I mean, ?it doesn't >> continue to run on background. The same behavior happened if one of my >> specs fails too. > > Is this in a rails app? I was having the same problem until I discoved that I forgot to setup the .autotest_images folder referenced in my .autotest file. :) -- Posted via http://www.ruby-forum.com/. From loop at superinfinite.com Wed May 20 05:10:49 2009 From: loop at superinfinite.com (Bart Zonneveld) Date: Wed, 20 May 2009 11:10:49 +0200 Subject: [rspec-users] [Cucumber] [Ann] Salad, aka Multi-instance Cucumber Message-ID: (Apologies for crossposting) Yesterday, my pair and I wrote a rough rake task to run features against multiple instances of Cucumber. We decided to call it Salad, since multiple cucumbers makes a nice salad :). The script is very rough, and scratches mostly our own itch. The rake task itself can be found at http://gist.github.com/114709. On a 8-core Mac Pro running with 8 instances, we see a speed increase of roughly 75%, reducing running time of our entire suite from ~7m30s to ~2m30s. We've only tested this script on Mac OS X 10.5. Basic flow is this: - Create n extra test databases, similar to the test database in config/database.yml - Split all features evenly in n feature "groups" - Fork n Cucumber processes, and let them run their designated feature groups We both are neither Cucumber internal experts, nor Ruby experts, so this could use a lot of work. I personally would love to have this all as a command line option to cucumber itself. Two major caveats: - You need to explicitly set RAILS_ENV to 'test'. We couldn't find an easy way to force this env from within the rake task - The project we used to test this all on has some random failures on specific features with this rake task, whereas rake features doesn't report any failures at all. This could probably have something to do with either transactional fixtures or some sort of memory leaks. We found it happens more frequent when using more instances of cucumber. So, try it out from http://gist.github.com/114709, and post your findings! cheers, bartz From scott at railsnewbie.com Wed May 20 09:00:31 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 20 May 2009 09:00:31 -0400 Subject: [rspec-users] autotest? In-Reply-To: <4A13DCA1.4090105@haskinferguson.net> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> Message-ID: <4A13FEEF.1070807@railsnewbie.com> Denis Haskin wrote: > I didn't have ZenTest installed. I just did, but I still get the same > error. Should I *not* have grosser-autotest installed? > > $ gem list | grep -i test > grosser-autotest (4.0.4) > test-unit (2.0.2) > ZenTest (4.0.0) Try removing it. Make sure to grab the latest ZenTest (which you now have), and rspec (and rspec-on-rails, if you are in a rails project). Aslak used to have some good abbreviation for this phrase: what versions of everything are you using? - rspec - rspec on rails (if in a rails project) - rails (if in a rails project) - OS Scott > > dwh > > Scott Taylor wrote: >> Denis Haskin wrote: >>> Hmm. Okay, tried that but: >>> >>> $ autospec >>> (Not running features. To run features in autotest, set >>> AUTOFEATURE=true.) >>> loading autotest/rails_rspec >>> Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. >>> >>> I'm running my rails rspec examples just fine manually... >>> >>> dwh >>> >> What version of the ZenTest gem do you have? >> > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Wed May 20 09:13:20 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 20 May 2009 14:13:20 +0100 Subject: [rspec-users] When to stub_model? In-Reply-To: <3e77d55f-278f-40f8-9c5c-33479d7e0867@r34g2000vbi.googlegroups.com> References: <499150.46456.qm@web23901.mail.ird.yahoo.com> <526E5C03-703F-42FF-A799-CEBFEFBE6B65@mattwynne.net> <6D8825B9-4178-4BC1-9EEB-73DD8055D6FC@mattwynne.net> <3e77d55f-278f-40f8-9c5c-33479d7e0867@r34g2000vbi.googlegroups.com> Message-ID: <3FEE71BC-1F79-4BE4-85D8-BFB316626B81@mattwynne.net> On 20 May 2009, at 12:03, Lee wrote: > Thanks Matt. Very helpful. > > I have tried out stub_model. The constructor of one of my models > (Namespace) requires a mandatory :name attribute to be provided. So > when I try to stub_model it - e.g. representative_namespace = > stub_model(Namespace) - I get the following spec error. > > 1) > RuntimeError in 'ContextsController POST create authenticated user > should assign a representative namespace to the new context' > A namespace must be assigned a valid name > /Users/leelon/work/cbox/app/models/namespace.rb:696:in > `raise_no_name_error' > /Users/leelon/work/cbox/app/models/namespace.rb:688:in > `get_processed_name' > /Users/leelon/work/cbox/app/models/namespace.rb:643:in `set_name' > /Users/leelon/work/cbox/app/models/namespace.rb:64:in `initialize' > ./spec/controllers/contexts_controller_spec.rb:37: > script/spec:10: > > Is there a way around this while still making :name a mandatory > requirement of the constructor? I have tried stubbing out :name in the > call to stub_model but this doesn't help: > > representative_namespace = stub_model(Namespace, :name => 'A name') I can't remember if you can do that, to be honest. I think the hash of parameters to stub_model is used to set up stubs on the object - so they won't get passed to the constructor. Hopefully someone else on the list should be able to tell you if this is possible. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Wed May 20 09:19:42 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 20 May 2009 14:19:42 +0100 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <8d961d900905200133l3f03f957gce53b4509bc46643@mail.gmail.com> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150125g229bbb73q631b4f2634129a98@mail.gmail.com> <88EB6664-C240-446E-98EC-157138091015@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> <55C8C94B-5F23-4F5E-AF94-B45135C45355@mattwynne.net> <8d961d900905200133l3f03f957gce53b4509bc46643@mail.gmail.com> Message-ID: <783D9FA7-ABC5-4B0C-AD88-63D40103E161@mattwynne.net> On 20 May 2009, at 09:33, aslak hellesoy wrote: >> >> On 20 May 2009, at 00:04, aslak hellesoy wrote: >> >>>> Any further thoughts on this, Aslak? I'd prefer to go with a >>>> solution in >>>> line with the future direction of Cucumber if possible. >>>> >>> >>> Sorry, forgot to get back to you Luke. >>> >>> I'm convinced. We'll add an AfterStep hook. Do you want to give a >>> stab >>> at a patch? Start by writing a feature - see >>> features/after_block_exceptions.feature for a good example of the >>> style we like... >> >> Can I make a mild plea for After(:step) rather than AfterStep? I >> think it >> looks nicer and it's one less method added to the API... >> > > That would be confusing, since After already takes arguments (tags). So why not make the API be like After(:scenario_tagged => "@emails") { clean_up_emails } After(:each_scenario) { clean_up_database } #the default After(:step) { do_stuff_for_luke } Having less methods makes the protocol more extensible, IMO. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From Lee.Longmore at googlemail.com Wed May 20 09:20:37 2009 From: Lee.Longmore at googlemail.com (Lee) Date: Wed, 20 May 2009 06:20:37 -0700 (PDT) Subject: [rspec-users] When to stub_model? In-Reply-To: <3FEE71BC-1F79-4BE4-85D8-BFB316626B81@mattwynne.net> References: <499150.46456.qm@web23901.mail.ird.yahoo.com> <526E5C03-703F-42FF-A799-CEBFEFBE6B65@mattwynne.net> <6D8825B9-4178-4BC1-9EEB-73DD8055D6FC@mattwynne.net> <3e77d55f-278f-40f8-9c5c-33479d7e0867@r34g2000vbi.googlegroups.com> <3FEE71BC-1F79-4BE4-85D8-BFB316626B81@mattwynne.net> Message-ID: <7d5f6ce5-5098-4d3c-80b0-d422ed00eb68@z5g2000vba.googlegroups.com> > I can't remember if you can do that, to be honest. I think the hash of > parameters to stub_model is used to set up stubs on the object - so > they won't get passed to the constructor. Hopefully someone else on > the list should be able to tell you if this is possible. Matt, I have since looked at the source for stub_model on RSpec's RDoc and I think you're right and it's not possible. I guess one option would be to fallback to mock_model for this model. From dchelimsky at gmail.com Wed May 20 10:15:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 May 2009 09:15:16 -0500 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <68ef1261461f21693580f4a09d9be2de@ruby-forum.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> <1b534ddfb9cb2b19c34c497fd6e3509e@ruby-forum.com> <57c63afe0905200012w7fff2711ka103defc00cc483f@mail.gmail.com> <68ef1261461f21693580f4a09d9be2de@ruby-forum.com> Message-ID: <57c63afe0905200715k473b1478y898dbd838ced72a4@mail.gmail.com> On Wed, May 20, 2009 at 2:47 AM, Amit Kulkarni wrote: > David Chelimsky wrote: >> On Wed, May 20, 2009 at 1:47 AM, Amit Kulkarni >> wrote: >>>>> script/spec spec/controllers/channels_controller_spec1.rb >>>> >>>> Hey It worked thanks a lot. :-) >>>> >>>> Can you tell me the difference why it was not running earlier and now it >>>> is running.Just for my understanding. >>> >>> It is not the case that i will always run spec from the root project.So >>> if i want to run from spec/controllers direcrtory then what should i do >>> since i am getting the error. >> >> Unfortunately, you're going to have to run it from the project root >> because that's the only it works, apparently. You can file a bug >> report at http://rspec.lighthouseapp.com if you're interested. >> >> Cheers, >> David > > Thank a lot. > But is the case that all controller specs are run from the root > directory. > I had had written spec models and it runs fine from inside the spec > directory. > > I will sure file a ticket on the site u mentioned. > Also it will be good if i get to know the reason behind this :-) It's not by design. It's a bug. From dchelimsky at gmail.com Wed May 20 10:23:24 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 May 2009 09:23:24 -0500 Subject: [rspec-users] Forum.count.should, should doesn't work? In-Reply-To: References: <9cb02f05bd159090dedf1285f671d924@ruby-forum.com> <57c63afe0905190819p1a42abb1g4dc3d9778a111de6@mail.gmail.com> <0cc1cc90b12a5ffbc6d9c74fef4b4192@ruby-forum.com> Message-ID: <57c63afe0905200723k2a9b6731id64a085f4fe47713@mail.gmail.com> On Wed, May 20, 2009 at 4:18 AM, Zhenning Guan wrote: > Zhenning Guan wrote: >> David Chelimsky wrote: >>> On Tue, May 19, 2009 at 10:09 AM, Zhenning Guan >>> wrote: >>>> features/step_definitions/webrat_steps.rb:10 >>>> >>>> 1 scenario (1 failed) >>>> 2 steps (1 failed, 1 passed) >>>> >>>> === >>>> Forum.count == counts.to_i does fine >>> >>> That's not an expectation so it won't pass or fail. I'd bet that's >>> returning false, which is not going to make a step fail (only an error >>> will). >> >> I means.... >> Forum.count == counts.to_i >> doesn't work... > > correct it > Forum.count.should == counts.to_i > doesn't work. You're confusing me now :) So, if I understand correctly, this fails: Forum.count.should == counts.to_i and this passes Forurm.count == counts.to_i The fact that the latter is passing is a false positive, because it is not actually testing anything. It is a boolean statement that returns true or false, and it doesn't matter whether it returns true or false because the step will pass in either case. The only thing that makes a step fail is an error. When you say "Forum.count.should == counts.to_i" and those two values are not equal, an ExpectationNotMet error is raised by RSpec. In that case you get a failure. The reason "Forum.count.should == counts.to_i" is failing is because ... well, it is failing. Forum.count is returning 0 when you're expecting 3. HTH, David From tatyree at googlemail.com Wed May 20 07:01:33 2009 From: tatyree at googlemail.com (tatyree) Date: Wed, 20 May 2009 04:01:33 -0700 (PDT) Subject: [rspec-users] Change cache_classes on the fly? Message-ID: <612c7e38-427c-4b80-9b71-35ba43302cd1@e20g2000vbc.googlegroups.com> Strange request, I know...also seems pretty unlikely that it will work, but: Any thoughts on how I might change the setting on the fly (or stub it)? I'm stopping certain classes loading in production, and I'd like to be able to test the behavior without having to manually change the setting in test.rb. Thanks, Todd From dchelimsky at gmail.com Wed May 20 11:00:04 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 May 2009 10:00:04 -0500 Subject: [rspec-users] Change cache_classes on the fly? In-Reply-To: <612c7e38-427c-4b80-9b71-35ba43302cd1@e20g2000vbc.googlegroups.com> References: <612c7e38-427c-4b80-9b71-35ba43302cd1@e20g2000vbc.googlegroups.com> Message-ID: <57c63afe0905200800r3285f721w251af3afa560ba52@mail.gmail.com> On Wed, May 20, 2009 at 6:01 AM, tatyree wrote: > Strange request, I know...also seems pretty unlikely that it will > work, but: > > Any thoughts on how I might change the setting on the fly (or stub > it)? ?I'm stopping certain classes loading in production, and I'd like > to be able to test the behavior without having to manually change the > setting in test.rb. Have you looked at the rails code that uses it? That's what you'd need to look at to know what to stub. > > Thanks, > Todd From lists at ruby-forum.com Wed May 20 11:43:42 2009 From: lists at ruby-forum.com (Zhenning Guan) Date: Wed, 20 May 2009 17:43:42 +0200 Subject: [rspec-users] how to deal with redirect_to on cucumber? Message-ID: <2488f385dab9d63d6788d2b3ca50cf3d@ruby-forum.com> I have a controller name forums and a action like this: def show redirect_to forum_topics_path(:forum_id => params[:id]) end my scenario is (not completed) ========== Scenario: User input data correct When I run to the forum 1 -- When /^I run to the (.*)$/ do |topic_lists| visit path_to(topic_lists) end def path_to(page_name) case page_name when /forum 1/ forum_path(1) ========== when I runned rake features got a error.. ++++++++++++++++ Scenario: User input data correct # features/forums.feature:10 When I run to the topic lists # features/step_definitions/forums_steps.rb:10 Couldn't find Forum with ID=1 (ActiveRecord::RecordNotFound) /home/ning/blank/app/controllers/topics_controller.rb:71:in `load_forum' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' (eval):2:in `/^I run to the (.*)$/' features/forums.feature:11:in `When I run to the topic lists' ++++++++++++++++++ so is that redirect_to problems? how to implement the scenario? any thought here? -- Posted via http://www.ruby-forum.com/. From denis at haskinferguson.net Wed May 20 13:08:24 2009 From: denis at haskinferguson.net (Denis Haskin) Date: Wed, 20 May 2009 13:08:24 -0400 Subject: [rspec-users] autotest? In-Reply-To: <4A13FEEF.1070807@railsnewbie.com> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> Message-ID: <4A143908.3030506@haskinferguson.net> Thanks. Ok -- removing grosser-autotest lets autotest run, but it's only running my unit tests, not rspec: $ autotest (Not running features. To run features in autotest, set AUTOFEATURE=true.) loading autotest/rails /usr/bin/ruby1.8 -I.:lib:test -rubygems -e "%w[test/unit test/unit/design_test.rb test/functional/admin/user_controller_test.rb test/unit/helpers/admin/user_helper_test.rb test/unit/garment_test.rb test/functional/admin/admin_controller_test.rb test/unit/helpers/admin/admin_helper_test.rb].each { |f| require f }" | unit_diff -u Here's all my versions: cucumber (0.3.3) rails (2.3.2, 2.2.2) rspec (1.2.6, 1.1.12) rspec-rails (1.2.6) ZenTest (4.0.0) OS: Ubuntu 8.10 I *was* missing rspec-rails, but even after installing it, same result as above. Is there some configuration I need to do to get rid of unit/functional tests and only run rspec+cucumber? Thanks! dwh Scott Taylor wrote: > Denis Haskin wrote: >> I didn't have ZenTest installed. I just did, but I still get the >> same error. Should I *not* have grosser-autotest installed? >> >> $ gem list | grep -i test >> grosser-autotest (4.0.4) >> test-unit (2.0.2) >> ZenTest (4.0.0) > Try removing it. > > Make sure to grab the latest ZenTest (which you now have), and rspec > (and rspec-on-rails, if you are in a rails project). > > Aslak used to have some good abbreviation for this phrase: what > versions of everything are you using? > > - rspec > - rspec on rails (if in a rails project) > - rails (if in a rails project) > - OS > > Scott > > > >> >> dwh >> >> Scott Taylor wrote: >>> Denis Haskin wrote: >>>> Hmm. Okay, tried that but: >>>> >>>> $ autospec >>>> (Not running features. To run features in autotest, set >>>> AUTOFEATURE=true.) >>>> loading autotest/rails_rspec >>>> Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. >>>> >>>> I'm running my rails rspec examples just fine manually... >>>> >>>> dwh >>>> >>> What version of the ZenTest gem do you have? > From phlip2005 at gmail.com Wed May 20 13:44:13 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 20 May 2009 10:44:13 -0700 Subject: [rspec-users] Cucumber vs Rails Fixtures Message-ID: Cucumberists: Apologies for not jumping into some wild alternate fixture (or mock!) system, but the unit tests at my new day gig are >cough< hanging by a thread as it is. I need to show off some cute Cuke, _without_ rocking the boat! How do I actually use real, pre-existing Rails fixtures, the same as the unit tests use? For familiarity? Putting this at the top of the step.rb seems just a leeettle bit tacky... $fixtures_installed ||= ( ENV['RAILS_ENV'] = 'test' RAILS_ENV.replace('test') system('rake db:fixtures:load') ) I have attempted to load Rails Fixtures on demand before, and I'm the first to admit their architecture sucks - loading them on demand ain't pretty! And exactly why was 'rake features' running in RAILS_ENV=development mode? Do developers _like_ having their scratch database screwed up each time they run fixtures? Enquiring minds want to know! -- Phlip From ben at benmabey.com Wed May 20 14:03:13 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 20 May 2009 12:03:13 -0600 Subject: [rspec-users] Cucumber vs Rails Fixtures In-Reply-To: References: Message-ID: <4A1445E1.3070204@benmabey.com> Phlip wrote: > Cucumberists: FYI, Cucumber now has it's own mailing list: http://groups.google.com/group/cukes > > Apologies for not jumping into some wild alternate fixture (or mock!) > system, but the unit tests at my new day gig are >cough< hanging by a > thread as it is. > > I need to show off some cute Cuke, _without_ rocking the boat! > > How do I actually use real, pre-existing Rails fixtures, the same as > the unit tests use? For familiarity? http://wiki.github.com/aslakhellesoy/cucumber/fixtures -Ben From phlip2005 at gmail.com Wed May 20 14:10:16 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 20 May 2009 11:10:16 -0700 Subject: [rspec-users] Cucumber vs Rails Fixtures In-Reply-To: <4A1445E1.3070204@benmabey.com> References: <4A1445E1.3070204@benmabey.com> Message-ID: Ben Mabey wrote: > http://wiki.github.com/aslakhellesoy/cucumber/fixtures Ding! That would have been my next click in my Googling. Let's hope this thread pushes that up. > http://groups.google.com/group/cukes What, no gmane yet?? (-: -- Phlip From denis at haskinferguson.net Wed May 20 14:12:27 2009 From: denis at haskinferguson.net (Denis Haskin) Date: Wed, 20 May 2009 14:12:27 -0400 Subject: [rspec-users] [Rspec] Problems with autospec In-Reply-To: <696a5f6e059d244860e7f9a90521cff4@ruby-forum.com> References: <57c63afe0905140652k7d56e423g7b4fc12b26aa167b@mail.gmail.com> <696a5f6e059d244860e7f9a90521cff4@ruby-forum.com> Message-ID: <4A14480B.6070304@haskinferguson.net> Is this fabled .autotest file fully documented somewhere? It keeps getting referenced in lots of answers and doc, but I haven't located complete doc on it. I'm probably not looking in the right place... thx dwh Robert Lorimor wrote: > David Chelimsky wrote: > >> On Thu, May 14, 2009 at 7:51 AM, Hugo Barauna >> wrote: >> >>> Hi guys, I am having a problem with autospec. I upgraded to >>> rspec-1.2.6, then I tried to run my specs with autospec. All my specs >>> passes (green), until here, that's all ok. The problem is that after >>> all my specs have passed, the autospec stops, I mean, ?it doesn't >>> continue to run on background. The same behavior happened if one of my >>> specs fails too. >>> >> Is this in a rails app? >> > > I was having the same problem until I discoved that I forgot to setup > the .autotest_images folder referenced in my .autotest file. > > :) > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Wed May 20 14:46:06 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 20 May 2009 12:46:06 -0600 Subject: [rspec-users] Change cache_classes on the fly? In-Reply-To: <612c7e38-427c-4b80-9b71-35ba43302cd1@e20g2000vbc.googlegroups.com> References: <612c7e38-427c-4b80-9b71-35ba43302cd1@e20g2000vbc.googlegroups.com> Message-ID: <4A144FEE.3000102@benmabey.com> tatyree wrote: > Strange request, I know...also seems pretty unlikely that it will > work, but: > > Any thoughts on how I might change the setting on the fly (or stub > it)? I'm stopping certain classes loading in production, and I'd like > to be able to test the behavior without having to manually change the > setting in test.rb. > > Thanks, > Todd > > Try changing the Rails.configuration.cache_classes setting at the appropriate times... -Ben From zach.dennis at gmail.com Wed May 20 17:04:55 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 20 May 2009 17:04:55 -0400 Subject: [rspec-users] [webrat] failing feature step when have_selector uses block In-Reply-To: <50873a360905200230s20a1252ah229f95c0095056f1@mail.gmail.com> References: <50873a360905200230s20a1252ah229f95c0095056f1@mail.gmail.com> Message-ID: <85d99afe0905201404r4de7175by4b4b98ffe08676ac@mail.gmail.com> On Wed, May 20, 2009 at 5:30 AM, doug livesey wrote: > Hi -- I have a strange bug. > The following step will pass: > > Then /^I should not see any options for the properties$/ do > ? response.should have_selector( "table thead" ) > end > > But this will fail: > > Then /^I should not see any options for the properties$/ do > ? response.should have_selector( "table thead" ) do |thead| > ??? thead.should_not contain( "Options" ) > ? end > end > > The strange thing is that it isn't the inner specification that fails, but > the outer one that is (or should be) identical to the first example (which > is just a reduced version of the second to investigate what was failing). > This is the second weird thing I have seen with nested blocks in > have_selector (the first was nested calls to have_selector only checking > immediate descendants of the block parameter). Is there something about > their use that I'm not understanding? Are you using selenium or just with webrat? > Cheers, > ?? Doug. > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google Groups > "webrat" group. > To post to this group, send email to webrat at googlegroups.com > To unsubscribe from this group, send email to > webrat+unsubscribe at googlegroups.com > For more options, visit this group at > http://groups.google.com/group/webrat?hl=en > -~----------~----~----~----~------~----~------~--~--- > > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From glin at employees.org Wed May 20 18:32:46 2009 From: glin at employees.org (Gary Lin) Date: Wed, 20 May 2009 15:32:46 -0700 Subject: [rspec-users] How do I get additional information from the Matcher? Message-ID: <4A14850E.3030406@employees.org> Hi, I am trying to implement my own matcher which use a special algorithm to do the semantics diff-ing between two proprietary configuration file. When come to the report, I would like my formatter to be able to have access to the original configuration file content as well as the diff-ing result. By digging through the code, looks like all formatter can get is an ExpectationNotMetError with a string-based message embedded inside. How do I make the matcher pass additional information to my formatter? I see there is a class level variable called ::Spec::Matchers.last_matcher which allows me to access the last matcher. Is that the right away to implement this? Or if there is any better way for me to add additional information into the ExpectationNotMetError exception? Thanks, --Gary From scott at railsnewbie.com Thu May 21 01:55:44 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 21 May 2009 01:55:44 -0400 Subject: [rspec-users] autotest? In-Reply-To: <4A143908.3030506@haskinferguson.net> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> <4A143908.3030506@haskinferguson.net> Message-ID: <4A14ECE0.4040305@railsnewbie.com> Denis Haskin wrote: > Thanks. Ok -- removing grosser-autotest lets autotest run, but it's > only running my unit tests, not rspec: > > $ autotest > (Not running features. To run features in autotest, set > AUTOFEATURE=true.) > loading autotest/rails > /usr/bin/ruby1.8 -I.:lib:test -rubygems -e "%w[test/unit > test/unit/design_test.rb test/functional/admin/user_controller_test.rb > test/unit/helpers/admin/user_helper_test.rb test/unit/garment_test.rb > test/functional/admin/admin_controller_test.rb > test/unit/helpers/admin/admin_helper_test.rb].each { |f| require f }" > | unit_diff -u > > Here's all my versions: > > cucumber (0.3.3) > rails (2.3.2, 2.2.2) > rspec (1.2.6, 1.1.12) > rspec-rails (1.2.6) > ZenTest (4.0.0) > > OS: Ubuntu 8.10 > > I *was* missing rspec-rails, but even after installing it, same result > as above. > > Is there some configuration I need to do to get rid of unit/functional > tests and only run rspec+cucumber? > Run "autospec", which should come with the latest rspec gem. Scott From kero at chello.nl Thu May 21 02:46:37 2009 From: kero at chello.nl (Kero van Gelder) Date: Thu, 21 May 2009 08:46:37 +0200 Subject: [rspec-users] autotest? In-Reply-To: <4A143908.3030506@haskinferguson.net> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> <4A143908.3030506@haskinferguson.net> Message-ID: <20090521064637.GB5921@bumblebee.m38c.nl> > Is there some configuration I need to do to get rid of unit/functional > tests and only run rspec+cucumber? This eplains all there is to explain (though terse and not from your use case) http://zentest.rubyforge.org/ZenTest/Autotest.html and you now have to add code from that to your .autotest If you want to clear existing mappings, and add new mappings, while also ignoring any temp file created by cucumber (or autotest will keep triggering because it saw an updated file; which surprises me, as there is no mapping for those files...) you get something like this: Autotest.add_hook(:initialize) {|at| at.add_exception %r{^\.git} at.add_exception %r{^./tmp} at.clear_mappings # take out the default (test/test*rb) at.add_mapping(%r{^lib/.*\.rb$}) {|filename, _| Dir['spec/**/*.rb'] } nil } The nil make sure that other :initialize hooks get executed. Very relevant if you have both ~/.autotest and .autotest I guess I should add this in some form to the rspec wiki ;) Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From kero at chello.nl Thu May 21 03:27:06 2009 From: kero at chello.nl (Kero van Gelder) Date: Thu, 21 May 2009 09:27:06 +0200 Subject: [rspec-users] autotest? In-Reply-To: <20090521064637.GB5921@bumblebee.m38c.nl> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> <4A143908.3030506@haskinferguson.net> <20090521064637.GB5921@bumblebee.m38c.nl> Message-ID: <20090521072706.GC5921@bumblebee.m38c.nl> > > Is there some configuration I need to do to get rid of unit/functional > > tests and only run rspec+cucumber? [...] > I guess I should add this in some form to the rspec wiki ;) Done: http://wiki.github.com/dchelimsky/rspec/autotest-integration Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From matt at mattwynne.net Thu May 21 03:34:58 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 21 May 2009 08:34:58 +0100 Subject: [rspec-users] how to deal with redirect_to on cucumber? In-Reply-To: <2488f385dab9d63d6788d2b3ca50cf3d@ruby-forum.com> References: <2488f385dab9d63d6788d2b3ca50cf3d@ruby-forum.com> Message-ID: <6F49CD27-7981-4885-8DE3-D2176D37F3BC@mattwynne.net> On 20 May 2009, at 16:43, Zhenning Guan wrote: > I have a controller name forums and a action like this: > def show > redirect_to forum_topics_path(:forum_id => params[:id]) > end > > my scenario is (not completed) > ========== > Scenario: User input data correct > When I run to the forum 1 > > -- > When /^I run to the (.*)$/ do |topic_lists| > visit path_to(topic_lists) > end > > def path_to(page_name) > case page_name > > when /forum 1/ > forum_path(1) > ========== > > when I runned rake features > got a error.. > ++++++++++++++++ > Scenario: User input data correct # features/forums.feature:10 > When I run to the topic lists # > features/step_definitions/forums_steps.rb:10 > Couldn't find Forum with ID=1 (ActiveRecord::RecordNotFound) > /home/ning/blank/app/controllers/topics_controller.rb:71:in > `load_forum' > /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' > (eval):2:in `/^I run to the (.*)$/' > features/forums.feature:11:in `When I run to the topic lists' > ++++++++++++++++++ > > so is that redirect_to problems? how to implement the scenario? any > thought here? You are trying to visit the page for a 'forum' object (with ID=1) that does not exist in your database. In each scenario, you need to imagine your application starts from a completely empty state, just like it would if you started the application with script/server. You need a step in your scenario that says 'Given there is a Forum' which creates the record in the database. If you don't mind me saying so, this question suggests to me that you have quite a bit to learn about Cucumber. While people on this list are pretty patient and helpful, they are also busy and will be more keen to help if you spend some time helping yourself too. I suggest you start with the recent railscast on Cucumber. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Thu May 21 04:17:30 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Thu, 21 May 2009 10:17:30 +0200 Subject: [rspec-users] Cucumber vs Rails Fixtures In-Reply-To: References: <4A1445E1.3070204@benmabey.com> Message-ID: <8783CDFE-5142-45DC-9ACB-E6975612C3A6@gmail.com> > Ben Mabey wrote: > >> http://wiki.github.com/aslakhellesoy/cucumber/fixtures > > Ding! That would have been my next click in my Googling. Let's hope > this thread pushes that up. > > > http://groups.google.com/group/cukes > > What, no gmane yet?? (-: > I would have preferred: "I have set up GMane" Thanks Philip ;-) > -- > Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Thu May 21 04:55:49 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 21 May 2009 10:55:49 +0200 Subject: [rspec-users] how to deal with redirect_to on cucumber? In-Reply-To: <6F49CD27-7981-4885-8DE3-D2176D37F3BC@mattwynne.net> References: <2488f385dab9d63d6788d2b3ca50cf3d@ruby-forum.com> <6F49CD27-7981-4885-8DE3-D2176D37F3BC@mattwynne.net> Message-ID: <8d961d900905210155r41d19600m52d96c40203d8b8f@mail.gmail.com> Instead of answering Cucumber questions on this list, please redirect people to the new one: http://www.nabble.com/-Cucumber--ANN%3A-New-Google-Group-for-Cucumber-td23602831.html Aslak On Thu, May 21, 2009 at 9:34 AM, Matt Wynne wrote: > > On 20 May 2009, at 16:43, Zhenning Guan wrote: > >> I have a controller name forums and a action like this: >> ?def show >> ? ?redirect_to forum_topics_path(:forum_id => params[:id]) >> ?end >> >> my scenario is (not completed) >> ========== >> Scenario: User input data correct >> ?When I run to the forum 1 >> >> -- >> When /^I run to the (.*)$/ do |topic_lists| >> ?visit path_to(topic_lists) >> end >> >> def path_to(page_name) >> ? case page_name >> >> ? when /forum 1/ >> ? ? forum_path(1) >> ========== >> >> when I runned rake features >> got a error.. >> ++++++++++++++++ >> Scenario: User input data correct # features/forums.feature:10 >> ? When I run to the topic lists ? # >> features/step_definitions/forums_steps.rb:10 >> ? ? Couldn't find Forum with ID=1 (ActiveRecord::RecordNotFound) >> ? ? /home/ning/blank/app/controllers/topics_controller.rb:71:in >> `load_forum' >> ? ? /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' >> ? ? (eval):2:in `/^I run to the (.*)$/' >> ? ? features/forums.feature:11:in `When I run to the topic lists' >> ++++++++++++++++++ >> >> so is that redirect_to problems? how to implement the scenario? any >> thought here? > > You are trying to visit the page for a 'forum' object (with ID=1) that does > not exist in your database. > > In each scenario, you need to imagine your application starts from a > completely empty state, just like it would if you started the application > with script/server. > > You need a step in your scenario that says 'Given there is a Forum' which > creates the record in the database. > > If you don't mind me saying so, this question suggests to me that you have > quite a bit to learn about Cucumber. While people on this list are pretty > patient and helpful, they are also busy and will be more keen to help if you > spend some time helping yourself too. I suggest you start with the recent > railscast on Cucumber. > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From michael at schuerig.de Thu May 21 05:26:47 2009 From: michael at schuerig.de (Michael Schuerig) Date: Thu, 21 May 2009 11:26:47 +0200 Subject: [rspec-users] rspec-rails: how to run checks? Message-ID: <200905211126.47411.michael@schuerig.de> I'm trying to run the specs of the rspec-rails master branch, but both plain rake as well as rake spec fail. The default task fails because there is no cucumber.yml. rake spec fails, when it requires a file that is not part of the repo: rspec-rails/spec/spec_helper.rb refers to require File.expand_path("#{dir}/../../../../spec/spec_helper") Commenting out this line doesn't make everything magically work, of course. However, when I do that, I hit "uninitialized constant ActionController". So, I surmise that the missing spec_helper.rb among other things sees to it that Rails is properly required. Any hints on how to get the specs to work? Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From aslak.hellesoy at gmail.com Thu May 21 05:40:04 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 21 May 2009 11:40:04 +0200 Subject: [rspec-users] Cucumber vs Rails Fixtures In-Reply-To: <8783CDFE-5142-45DC-9ACB-E6975612C3A6@gmail.com> References: <4A1445E1.3070204@benmabey.com> <8783CDFE-5142-45DC-9ACB-E6975612C3A6@gmail.com> Message-ID: <8d961d900905210240u73d190ddm555beba4866905ef@mail.gmail.com> > >> Ben Mabey wrote: >> >>> http://wiki.github.com/aslakhellesoy/cucumber/fixtures >> >> Ding! That would have been my next click in my Googling. Let's hope this >> thread pushes that up. >> >> > http://groups.google.com/group/cukes >> >> What, no gmane yet?? (-: >> > I would have preferred: "I have set up GMane" > > Thanks Philip ;-) Sorry about the spelling Phlip Aklas >> >> -- >> ?Phlip >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu May 21 06:11:00 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Thu, 21 May 2009 12:11:00 +0200 Subject: [rspec-users] Error in executing controller spec In-Reply-To: <57c63afe0905200715k473b1478y898dbd838ced72a4@mail.gmail.com> References: <2dd99fdb726b853b3e7c14e875ee17a6@ruby-forum.com> <57c63afe0905080922pb5a7f85h3ced91af5d42b126@mail.gmail.com> <936b19e56bb8af1726e4a488b6c8d88b@ruby-forum.com> <57c63afe0905190621t15b94914v563f982acd8d8a96@mail.gmail.com> <57c63afe0905190727t28d53272r8a92593da7d80e77@mail.gmail.com> <1b534ddfb9cb2b19c34c497fd6e3509e@ruby-forum.com> <57c63afe0905200012w7fff2711ka103defc00cc483f@mail.gmail.com> <68ef1261461f21693580f4a09d9be2de@ruby-forum.com> <57c63afe0905200715k473b1478y898dbd838ced72a4@mail.gmail.com> Message-ID: <185a5c606eccb32130e6fb748ebe25ed@ruby-forum.com> David Chelimsky wrote: > On Wed, May 20, 2009 at 2:47 AM, Amit Kulkarni > wrote: >>>> It is not the case that i will always run spec from the root project.So >> Thank a lot. >> But is the case that all controller specs are run from the root >> directory. >> I had had written spec models and it runs fine from inside the spec >> directory. >> >> I will sure file a ticket on the site u mentioned. >> Also it will be good if i get to know the reason behind this :-) > > It's not by design. It's a bug Ok. Thanks a lot. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu May 21 06:41:41 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 May 2009 05:41:41 -0500 Subject: [rspec-users] [Rspec] Problems with autospec In-Reply-To: <4A14480B.6070304@haskinferguson.net> References: <57c63afe0905140652k7d56e423g7b4fc12b26aa167b@mail.gmail.com> <696a5f6e059d244860e7f9a90521cff4@ruby-forum.com> <4A14480B.6070304@haskinferguson.net> Message-ID: <57c63afe0905210341kf6da66dre0864a0e50d4c2@mail.gmail.com> On Wed, May 20, 2009 at 1:12 PM, Denis Haskin wrote: > Is this fabled .autotest file fully documented somewhere?? It keeps getting > referenced in lots of answers and doc, but I haven't located complete doc on > it.? I'm probably not looking in the right place... I'm not aware of a single definitive source. There is some overall autotest doc at http://zentest.rubyforge.org/ZenTest/Autotest.html, but aside from looking at the code I don't know of a source that talks about how/when .autotest gets loaded. Anybody else know of such? > > thx > > dwh > > > Robert Lorimor wrote: > > David Chelimsky wrote: > > > On Thu, May 14, 2009 at 7:51 AM, Hugo Barauna > wrote: > > > Hi guys, I am having a problem with autospec. I upgraded to > rspec-1.2.6, then I tried to run my specs with autospec. All my specs > passes (green), until here, that's all ok. The problem is that after > all my specs have passed, the autospec stops, I mean, ?it doesn't > continue to run on background. The same behavior happened if one of my > specs fails too. > > > Is this in a rails app? > > > I was having the same problem until I discoved that I forgot to setup > the .autotest_images folder referenced in my .autotest file. > > :) > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 21 06:56:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 May 2009 05:56:53 -0500 Subject: [rspec-users] autotest? In-Reply-To: <20090521072706.GC5921@bumblebee.m38c.nl> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> <4A143908.3030506@haskinferguson.net> <20090521064637.GB5921@bumblebee.m38c.nl> <20090521072706.GC5921@bumblebee.m38c.nl> Message-ID: <57c63afe0905210356k37eacf75gf1a36a7d75290b01@mail.gmail.com> On Thu, May 21, 2009 at 2:27 AM, Kero van Gelder wrote: >> > Is there some configuration I need to do to get rid of unit/functional >> > tests and only run rspec+cucumber? > > [...] >> I guess I should add this in some form to the rspec wiki ;) > > Done: > ? http://wiki.github.com/dchelimsky/rspec/autotest-integration Thanks Kero. I added a bit of information about autospec to that wiki page. Cheers, David > > Bye, > Kero. > ___ > How can I change the world if I can't even change myself? > ?-- Faithless, Salva Mea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 21 07:04:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 May 2009 06:04:11 -0500 Subject: [rspec-users] rspec-rails: how to run checks? In-Reply-To: <200905211126.47411.michael@schuerig.de> References: <200905211126.47411.michael@schuerig.de> Message-ID: <57c63afe0905210404l356b8fe7g47752c47869c47f8@mail.gmail.com> On Thu, May 21, 2009 at 4:26 AM, Michael Schuerig wrote: > > I'm trying to run the specs of the rspec-rails master branch, but both > plain rake as well as rake spec fail. Right now the only way to run them is in the context of the rspec-dev suite: http://github.com/dchelimsky/rspec-dev I added this ticket: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/822 Please feel free to comment on that ticket. Thanks, David > The default task fails because > there is no cucumber.yml. rake spec fails, when it requires a file that > is not part of the repo: rspec-rails/spec/spec_helper.rb refers to > > require File.expand_path("#{dir}/../../../../spec/spec_helper") > > Commenting out this line doesn't make everything magically work, of > course. However, when I do that, I hit "uninitialized constant > ActionController". So, I surmise that the missing spec_helper.rb among > other things sees to it that Rails is properly required. > > Any hints on how to get the specs to work? > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lawrence.pit at gmail.com Wed May 20 23:27:15 2009 From: lawrence.pit at gmail.com (lawrence.pit) Date: Wed, 20 May 2009 20:27:15 -0700 (PDT) Subject: [rspec-users] before(:all) Message-ID: <6fd630b3-7faf-40bc-9d30-284da2e89787@d38g2000prn.googlegroups.com> Hi All, When I execute database actions within a before(:each) they are rolled back after each example test has run. I expected that if I execute db actions within a before(:all) they would all be rolled back after all examples finished running. This appears not to be the case, in my case. Is there a way to get this behavior? Cheers, Lawrence From aslak.hellesoy at gmail.com Thu May 21 07:46:12 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 21 May 2009 13:46:12 +0200 Subject: [rspec-users] [Cucumber] Fail a scenario from After or AfterStep In-Reply-To: <783D9FA7-ABC5-4B0C-AD88-63D40103E161@mattwynne.net> References: <6622217A-83E0-4876-8632-F42DE7DDACD2@lukemelia.com> <8d961d900905150716s28c00a88qff8e2d71483119e1@mail.gmail.com> <99581A94-D112-4EE9-BDF9-74D8E69A89D0@lukemelia.com> <8d961d900905151236j409c53e1ld98123077a34f3f6@mail.gmail.com> <8d961d900905191604w6f4784f9k42889ba40158c0d6@mail.gmail.com> <55C8C94B-5F23-4F5E-AF94-B45135C45355@mattwynne.net> <8d961d900905200133l3f03f957gce53b4509bc46643@mail.gmail.com> <783D9FA7-ABC5-4B0C-AD88-63D40103E161@mattwynne.net> Message-ID: <8d961d900905210446ib7ec2fdvb92303da4fd958b4@mail.gmail.com> > > On 20 May 2009, at 09:33, aslak hellesoy wrote: > >>> >>> On 20 May 2009, at 00:04, aslak hellesoy wrote: >>> >>>>> Any further thoughts on this, Aslak? I'd prefer to go with a solution >>>>> in >>>>> line with the future direction of Cucumber if possible. >>>>> >>>> >>>> Sorry, forgot to get back to you Luke. >>>> >>>> I'm convinced. We'll add an AfterStep hook. Do you want to give a stab >>>> at a patch? Start by writing a feature - see >>>> features/after_block_exceptions.feature for a good example of the >>>> style we like... >>> >>> Can I make a mild plea for After(:step) rather than AfterStep? I think it >>> looks nicer and it's one less method added to the API... >>> >> >> That would be confusing, since After already takes arguments (tags). > > So why not make the API be like > > After(:scenario_tagged => "@emails") { clean_up_emails } > After(:each_scenario) { clean_up_database } #the default > After(:step) { do_stuff_for_luke } > > Having less methods makes the protocol more extensible, IMO. > What you suggest would break backwards compatibility. I actually think that one method makes the protocol *less* extensible, since there will always be compatibility issues. Besides, I actually think Before(*tags), After(*tags) and AfterStep(*tags) is more readable. In any case, you don't have to write this a lot, only a couple of times per project. So we'll stick with the current API Aslak > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu May 21 07:46:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 May 2009 06:46:53 -0500 Subject: [rspec-users] before(:all) In-Reply-To: <6fd630b3-7faf-40bc-9d30-284da2e89787@d38g2000prn.googlegroups.com> References: <6fd630b3-7faf-40bc-9d30-284da2e89787@d38g2000prn.googlegroups.com> Message-ID: <57c63afe0905210446i31f9a12fl1dfdde4684538ed2@mail.gmail.com> On Wed, May 20, 2009 at 10:27 PM, lawrence.pit wrote: > Hi All, > > When I execute database actions within a before(:each) they are rolled > back after each example test has run. I expected that if I execute db > actions within a before(:all) they would all be rolled back after all > examples finished running. This appears not to be the case, in my > case. Is there a way to get this behavior? Nothing built in, and it's probably not something we'd support in rspec-rails, which simply wraps the transaction handling provided by rails, which rolls back after every test method (equivalent of an rspec example). You're not the first to have asked for this, so having a solution for it that would work with rails out of the box and with rspec would be helpful to the community. But I think that would have to be in a separate gem. > Cheers, > Lawrence From michael at schuerig.de Thu May 21 07:50:25 2009 From: michael at schuerig.de (Michael Schuerig) Date: Thu, 21 May 2009 13:50:25 +0200 Subject: [rspec-users] rspec-rails: how to run checks? In-Reply-To: <57c63afe0905210404l356b8fe7g47752c47869c47f8@mail.gmail.com> References: <200905211126.47411.michael@schuerig.de> <57c63afe0905210404l356b8fe7g47752c47869c47f8@mail.gmail.com> Message-ID: <200905211350.25552.michael@schuerig.de> On Thursday 21 May 2009, David Chelimsky wrote: > On Thu, May 21, 2009 at 4:26 AM, Michael Schuerig wrote: > > I'm trying to run the specs of the rspec-rails master branch, but > > both plain rake as well as rake spec fail. > > Right now the only way to run them is in the context of the rspec-dev > suite: http://github.com/dchelimsky/rspec-dev > > I added this ticket: > https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/822 > > Please feel free to comment on that ticket. As a social workaround, would you mind to add a note to that effect to the rspec-rails README? Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From scott at railsnewbie.com Thu May 21 09:48:05 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 21 May 2009 09:48:05 -0400 Subject: [rspec-users] autotest? In-Reply-To: <20090521072706.GC5921@bumblebee.m38c.nl> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> <4A143908.3030506@haskinferguson.net> <20090521064637.GB5921@bumblebee.m38c.nl> <20090521072706.GC5921@bumblebee.m38c.nl> Message-ID: <4A155B95.5080403@railsnewbie.com> Kero van Gelder wrote: >>> Is there some configuration I need to do to get rid of unit/functional >>> tests and only run rspec+cucumber? >>> > > [...] > >> I guess I should add this in some form to the rspec wiki ;) >> > > Done: > http://wiki.github.com/dchelimsky/rspec/autotest-integration > +1. Thanks Kero. Scott > Bye, > Kero. > ___ > How can I change the world if I can't even change myself? > -- Faithless, Salva Mea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Thu May 21 09:59:52 2009 From: phlip2005 at gmail.com (Phlip) Date: Thu, 21 May 2009 06:59:52 -0700 Subject: [rspec-users] Cucumber vs Rails Fixtures In-Reply-To: <8d961d900905210240u73d190ddm555beba4866905ef@mail.gmail.com> References: <4A1445E1.3070204@benmabey.com> <8783CDFE-5142-45DC-9ACB-E6975612C3A6@gmail.com> <8d961d900905210240u73d190ddm555beba4866905ef@mail.gmail.com> Message-ID: aslak hellesoy wrote: >>> http://groups.google.com/group/cukes >> What, no gmane yet?? (-: > I would have preferred: "I have set up GMane" Netiquette: I would _not_ set someone else's group up on GMane - even if it were just a Google Group... -- Phlip http://flea.sourceforge.net/resume.html From kero at chello.nl Thu May 21 11:34:07 2009 From: kero at chello.nl (Kero van Gelder) Date: Thu, 21 May 2009 17:34:07 +0200 Subject: [rspec-users] autotest? In-Reply-To: <57c63afe0905210356k37eacf75gf1a36a7d75290b01@mail.gmail.com> References: <4A136BE9.2060608@haskinferguson.net> <4A137192.30102@benmabey.com> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> <4A143908.3030506@haskinferguson.net> <20090521064637.GB5921@bumblebee.m38c.nl> <20090521072706.GC5921@bumblebee.m38c.nl> <57c63afe0905210356k37eacf75gf1a36a7d75290b01@mail.gmail.com> Message-ID: <20090521153407.GD5921@bumblebee.m38c.nl> > >> > Is there some configuration I need to do to get rid of unit/functional > >> > tests and only run rspec+cucumber? > > > > [...] > >> I guess I should add this in some form to the rspec wiki ;) > > > > Done: > > ? http://wiki.github.com/dchelimsky/rspec/autotest-integration > > Thanks Kero. I added a bit of information about autospec to that wiki page. I keep learning things... add_mapping returns nil, that's why it works for autotest/rspec.rb But I've ran strace to confirm the problem I had with non-nil myself: ~/.autotest is ran *before* ./.autotest on my system (debian unstable). Are you sure it's the other way around on your system? I haven't seen autospec docs that claim one or the other. Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From dchelimsky at gmail.com Thu May 21 11:49:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 May 2009 10:49:37 -0500 Subject: [rspec-users] autotest? In-Reply-To: <20090521153407.GD5921@bumblebee.m38c.nl> References: <4A136BE9.2060608@haskinferguson.net> <4A137A79.1030300@haskinferguson.net> <4A138397.2090907@railsnewbie.com> <4A13DCA1.4090105@haskinferguson.net> <4A13FEEF.1070807@railsnewbie.com> <4A143908.3030506@haskinferguson.net> <20090521064637.GB5921@bumblebee.m38c.nl> <20090521072706.GC5921@bumblebee.m38c.nl> <57c63afe0905210356k37eacf75gf1a36a7d75290b01@mail.gmail.com> <20090521153407.GD5921@bumblebee.m38c.nl> Message-ID: <57c63afe0905210849hac85408t215c31ed69113646@mail.gmail.com> On Thu, May 21, 2009 at 10:34 AM, Kero van Gelder wrote: >> >> > Is there some configuration I need to do to get rid of unit/functional >> >> > tests and only run rspec+cucumber? >> > >> > [...] >> >> I guess I should add this in some form to the rspec wiki ;) >> > >> > Done: >> > ? http://wiki.github.com/dchelimsky/rspec/autotest-integration >> >> Thanks Kero. I added a bit of information about autospec to that wiki page. > > I keep learning things... > add_mapping returns nil, that's why it works for autotest/rspec.rb > > But I've ran strace to confirm the problem I had with non-nil myself: > ~/.autotest is ran *before* ./.autotest on my system (debian unstable). > Are you sure it's the other way around on your system? > I haven't seen autospec docs that claim one or the other. No - you're correct - I had it wrong- and what you're experiencing makes more sense. The local .autotest should load after the global ~/.autotest so it can do app-specific stuff. I'll update the wiki page as soon as I can load it (having trouble reaching github this moment). Cheers, David > > Bye, > Kero. From lists at ruby-forum.com Thu May 21 15:17:45 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 21 May 2009 21:17:45 +0200 Subject: [rspec-users] Using resource_controller (make_resourceful etc) and tes In-Reply-To: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> References: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> Message-ID: Andrew Premdas wrote: > Hi all, > > Trying to get some opinions about the use of such plugins and in > particular > about how they test, and how we test with them. Can they work well with > BDD > or do they do to much magic and create difficulties for features and > tests 5 months after the initial post, any experience to share? I am about to use one of these plugins in order to simplify my admin controllers code. Thanks for your feedback -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 22 02:41:17 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 22 May 2009 08:41:17 +0200 Subject: [rspec-users] Troble running controller spec Message-ID: Hi, I am trying to execute controller spec by referring to RSpec book but it is diving me error. Following are the details: Ruby version : 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] rspec - 1.2.4 rails - 2.1.2 OS - Vista Home My channels_controller_spec.rb(which is under rootproject/spec/controller directory) file contains: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ChannelsController do describe "Channel Creation" do before(:each) do @channel = mock_model(Channel, :save => nil) Channel.stub!(:new).and_return(@channel) end it "should create channel" do Channel.should_receive(:new).with(:brand_name => "test" ).and_return(@channel) post :create, :channel => { :brand_name => "test" } end it "should save channel" do @channel.should_receive(:save) post :create end end end Similarly my channels_controller.rb contains def create @channel= Channel.new params[:channel] @channel.save end Now when i try to execute the spec it shows me error which i have mentiond below along with its backtrace FF. 1) Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion should cre te chnnel' expected :new with ({:brnd_nme=>"mnger"}) once, but received it 0 times ./spec/controllers/chnnels_controller_spec.rb:11: C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen ertor.rb:53:in `__rise' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen ertor.rb:26:in `rise_expecttion_error' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex pecttion.rb:229:in `generte_error' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex pecttion.rb:192:in `verify_messges_received' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 190:in `verify_expecttions' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 189:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 189:in `verify_expecttions' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 66:in `verify' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r b:34:in `rspec_verify' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1 0:in `verify_ll' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 :in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 :in `verify_ll' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm eworks/rspec.rb:13:in `verify_mocks_for_rspec' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m ethods.rb:129:in `fter_ech_exmple' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m ethods.rb:45:in `execute' C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m ethods.rb:37:in `execute' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:207:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:205:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:205:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:103:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g roup_runner.rb:23:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g roup_runner.rb:22:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g roup_runner.rb:22:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options. rb:119:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l ine.rb:9:in `run' script/spec:4: 2) Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion should sve chnnel' Mock 'Chnnel_1002' expected :sve with (ny rgs) once, but received it 0 times ./spec/controllers/chnnels_controller_spec.rb:16: C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen ertor.rb:53:in `__rise' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen ertor.rb:26:in `rise_expecttion_error' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex pecttion.rb:229:in `generte_error' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex pecttion.rb:192:in `verify_messges_received' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 190:in `verify_expecttions' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 189:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 189:in `verify_expecttions' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: 66:in `verify' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r b:34:in `rspec_verify' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1 0:in `verify_ll' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 :in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 :in `verify_ll' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm eworks/rspec.rb:13:in `verify_mocks_for_rspec' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m ethods.rb:129:in `fter_ech_exmple' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m ethods.rb:45:in `execute' C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m ethods.rb:37:in `execute' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:207:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:205:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:205:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g roup_methods.rb:103:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g roup_runner.rb:23:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g roup_runner.rb:22:in `ech' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g roup_runner.rb:22:in `run' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options. rb:119:in `run_exmples' C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l ine.rb:9:in `run' I had done same which is mentioned in the book still i dont know why i am getting this error. Please suggest :-) -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri May 22 06:35:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 May 2009 05:35:26 -0500 Subject: [rspec-users] Troble running controller spec In-Reply-To: References: Message-ID: <57c63afe0905220335s3c7a9657xf6562acd8a4b7998@mail.gmail.com> On Fri, May 22, 2009 at 1:41 AM, Amit Kulkarni wrote: > Hi, > > ? ?I am trying to execute controller spec by referring to RSpec book > but it is diving me error. > > Following are the details: > Ruby version : 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > rspec - 1.2.4 > rails - 2.1.2 > OS - Vista Home > > My channels_controller_spec.rb(which is under > rootproject/spec/controller directory) file contains: > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe ChannelsController do > ?describe "Channel Creation" do > ? before(:each) do > ? ?@channel = mock_model(Channel, :save => nil) > ? ?Channel.stub!(:new).and_return(@channel) > ? end > > ? it "should create channel" do > ? ?Channel.should_receive(:new).with(:brand_name => "test" > ).and_return(@channel) I *think* Rails converts the keys in this hash to strings. Try: Channel.should_receive(:new).with('brand_name' => 'test'). and_return(@channel) HTH, David > ? ?post :create, :channel => { :brand_name => "test" } > ?end > > ?it "should save channel" do > ? ?@channel.should_receive(:save) > ? ?post :create > ?end > ?end > end > > Similarly my channels_controller.rb contains > > def create > ?@channel= Channel.new params[:channel] > ?@channel.save > end > > Now when i try to execute the spec it shows me error which i have > mentiond below along with its backtrace > > FF. > > 1) > Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion > should cre > te chnnel' > logo_file_size: st > ring, logo_content_type: string, points: integer, rnk: integer, > overruled_rnk: b > oolen, title: string, description: text, tgs: string, url: string, > kit_file_nme: > ?string, kit_file_size: string, kit_content_type: string, ctive: boolen, > bg_colo > r: string, font_color: string, title_color: string, title_style: string, > emotion > l_file_nme: string, emotionl_file_size: string, emotionl_content_type: > string, n > cestor_id: integer, chnnel_ctegory_id: integer, creted_t: dtetime, > updted_t: dte > time) (clss)> expected :new with ({:brnd_nme=>"mnger"}) once, but > received it 0 > times > ./spec/controllers/chnnels_controller_spec.rb:11: > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen > ertor.rb:53:in `__rise' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen > ertor.rb:26:in `rise_expecttion_error' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex > pecttion.rb:229:in `generte_error' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex > pecttion.rb:192:in `verify_messges_received' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 190:in `verify_expecttions' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 189:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 189:in `verify_expecttions' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 66:in `verify' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r > b:34:in `rspec_verify' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1 > 0:in `verify_ll' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 > :in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 > :in `verify_ll' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm > eworks/rspec.rb:13:in `verify_mocks_for_rspec' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m > ethods.rb:129:in `fter_ech_exmple' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m > ethods.rb:45:in `execute' > C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m > ethods.rb:37:in `execute' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:207:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:205:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:205:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:103:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g > roup_runner.rb:23:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g > roup_runner.rb:22:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g > roup_runner.rb:22:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options. > rb:119:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l > ine.rb:9:in `run' > script/spec:4: > > 2) > Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion > should sve > ?chnnel' > Mock 'Chnnel_1002' expected :sve with (ny rgs) once, but received it 0 > times > ./spec/controllers/chnnels_controller_spec.rb:16: > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen > ertor.rb:53:in `__rise' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen > ertor.rb:26:in `rise_expecttion_error' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex > pecttion.rb:229:in `generte_error' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex > pecttion.rb:192:in `verify_messges_received' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 190:in `verify_expecttions' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 189:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 189:in `verify_expecttions' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb: > 66:in `verify' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r > b:34:in `rspec_verify' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1 > 0:in `verify_ll' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 > :in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9 > :in `verify_ll' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm > eworks/rspec.rb:13:in `verify_mocks_for_rspec' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m > ethods.rb:129:in `fter_ech_exmple' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m > ethods.rb:45:in `execute' > C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m > ethods.rb:37:in `execute' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:207:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:205:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:205:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g > roup_methods.rb:103:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g > roup_runner.rb:23:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g > roup_runner.rb:22:in `ech' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g > roup_runner.rb:22:in `run' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options. > rb:119:in `run_exmples' > C:/Progrm > Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l > ine.rb:9:in `run' > > I had done same which is mentioned in the book still i dont know why i > am getting this error. > Please suggest :-) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri May 22 06:49:14 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 May 2009 05:49:14 -0500 Subject: [rspec-users] passing param values In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013A1484@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013A1484@awww.armis.com> Message-ID: <57c63afe0905220349p5b17d7bdwfad664428ab23724@mail.gmail.com> On Fri, May 22, 2009 at 4:34 AM, Diwakar, ANGLER - EIT wrote: > My controller spec is like below > > describe UsersController do > > ?describe " create action"?do > ? before(:each)? do > ??? @user = mock_model(User,:user => "value") #don't need to set the user in this @user = mock_model(User) > ??? controller.stub!(:require_user).and_return(@user) > ??? controller.stub!(:uses_mailer).and_return(@user) > ??? User.stub!(:new).and_return(@user) > ? end > ? it "should create a new user object" do > ????? User.should_receive(:new).with(:user=>"value").and_return(@user) #use 'user' instead of :user because Rails converts the keys User.should_receive(:new).with('user' => 'value').and_return(@user) > ????? post :create,:user => "value" > ? end > ?end > end > > Error: > > dat > etime, accessed_on: datetime, email_address: string, name_first: string, > name_la > st: string, mailing_address_id: integer, billing_address_id: integer, > name_displ > ay: string, picture_id: integer, url: string, country: string, freelance: > boolea > n, statement: string, hostname_active: boolean, hostname: string, > promotional_ma > ilings: boolean, sales_commission_rate: float, referral_commission_rate: > float, > employee_lock: boolean) (class)> expected :new with ({:user=>"value"}) once, > but > ?received it 0 times > > How should I pass the params? > > > Diwa > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From diwakar at angleritech.com Fri May 22 07:29:21 2009 From: diwakar at angleritech.com (Diwakar, ANGLER - EIT) Date: Fri, 22 May 2009 16:59:21 +0530 Subject: [rspec-users] passing param values In-Reply-To: <57c63afe0905220349p5b17d7bdwfad664428ab23724@mail.gmail.com> References: <09CAF7492BB188429DDFABCD8218F283013A1484@awww.armis.com> <57c63afe0905220349p5b17d7bdwfad664428ab23724@mail.gmail.com> Message-ID: <09CAF7492BB188429DDFABCD8218F283013A14D3@awww.armis.com> Still I am getting the same error describe UsersController do describe :create do before(:each) do controller.stub!(:require_user).and_return(@user) controller.stub!(:uses_mailer).and_return(@user) User.stub!(:new).and_return(@user) post :create,{:terms_and_conditions => "1",:promotional_mailings => "0",:email_address => "raja at test.com"},:user => {} end it "should create a new user object" do User.should_receive(:new).with({"terms_and_conditions" => "1","promotional_mailings" => "0","email_address" => "raja at test.com"}).and_return(@user) post :create,{:terms_and_conditions => "1",:promotional_mailings => "0",:email_address => "raja at test.com"},:user => {} end end end Error Spec::Mocks::MockExpectationError in 'UsersController create should create a new user object' expected :new with ({"terms_and_conditions"=>"1 ", "promotional_mailings"=>"0", "email_address"=>"raja at test.com"}) once, but rec eived it 0 times -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky Sent: Friday, May 22, 2009 4:19 PM To: rspec-users Subject: Re: [rspec-users] passing param values On Fri, May 22, 2009 at 4:34 AM, Diwakar, ANGLER - EIT wrote: > My controller spec is like below > > describe UsersController do > > ?describe " create action"?do > ? before(:each)? do > ??? @user = mock_model(User,:user => "value") #don't need to set the user in this @user = mock_model(User) > ??? controller.stub!(:require_user).and_return(@user) > ??? controller.stub!(:uses_mailer).and_return(@user) > ??? User.stub!(:new).and_return(@user) > ? end > ? it "should create a new user object" do > ????? User.should_receive(:new).with(:user=>"value").and_return(@user) #use 'user' instead of :user because Rails converts the keys User.should_receive(:new).with('user' => 'value').and_return(@user) > ????? post :create,:user => "value" > ? end > ?end > end > > Error: > > dat > etime, accessed_on: datetime, email_address: string, name_first: > string, name_la > st: string, mailing_address_id: integer, billing_address_id: integer, > name_displ > ay: string, picture_id: integer, url: string, country: string, freelance: > boolea > n, statement: string, hostname_active: boolean, hostname: string, > promotional_ma > ilings: boolean, sales_commission_rate: float, referral_commission_rate: > float, > employee_lock: boolean) (class)> expected :new with ({:user=>"value"}) > once, but > ?received it 0 times > > How should I pass the params? > > > Diwa > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.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 jhenderson at anu.ie Fri May 22 11:29:14 2009 From: jhenderson at anu.ie (JohnnyH) Date: Fri, 22 May 2009 08:29:14 -0700 (PDT) Subject: [rspec-users] Cucumber: Running one feature under one profile Message-ID: <6edfff72-8ba6-490d-b4a8-0ccf5685a7c6@o14g2000vbo.googlegroups.com> Hey Folks, I followed the instructions on http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium and created 2 profiles: default and selenium. It works, but not if I want to run one feature under a specifc profile. For example, I tried: cucumber -p default --require features features/plain/ manage_users.feature and I get all the tests including the selenium server. What's goin' on like? Thanks From aepstein607 at gmail.com Fri May 22 08:26:20 2009 From: aepstein607 at gmail.com (Ari) Date: Fri, 22 May 2009 05:26:20 -0700 (PDT) Subject: [rspec-users] Latest cucumber 0.3.6 + rspec >1.2.2 broken? Message-ID: <02350542-93fe-4ca6-a75a-793d6d3f6171@v4g2000vba.googlegroups.com> Hi all, It looks like the following line was removed from "/lib/spec/ expectations.rb" on April 11: attr_accessor :differ When I try to use cucumber (version 0.3.6), it tries to call ::Spec:Expectations.differ= and fails. There does not seem to be anything in the history regarding the removal/deprecation of this method -- is this a bug in rspec, bug in cucumber, both, or neither? From dchelimsky at gmail.com Fri May 22 14:59:52 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 May 2009 14:59:52 -0400 Subject: [rspec-users] Latest cucumber 0.3.6 + rspec >1.2.2 broken? In-Reply-To: <02350542-93fe-4ca6-a75a-793d6d3f6171@v4g2000vba.googlegroups.com> References: <02350542-93fe-4ca6-a75a-793d6d3f6171@v4g2000vba.googlegroups.com> Message-ID: <57c63afe0905221159n7bc64db4s203a5844ff488fe0@mail.gmail.com> On Fri, May 22, 2009 at 8:26 AM, Ari wrote: > Hi all, > > It looks like the following line was removed from "/lib/spec/ > expectations.rb" on April 11: > > attr_accessor :differ > > When I try to use cucumber (version 0.3.6), it tries to > call ::Spec:Expectations.differ= and fails. ?There does not seem to be > anything in the history regarding the removal/deprecation of this > method -- is this a bug in rspec, bug in cucumber, both, or neither? Depends on your viewpoint :) Regardless of whose bug it is, this was fixed in the cucumber release that followed the rspec release that broke cucumber (follow all that?) So if it's recurred it sounds like a regression in cucumber. From aslak.hellesoy at gmail.com Fri May 22 15:24:47 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 22 May 2009 21:24:47 +0200 Subject: [rspec-users] Cucumber: Running one feature under one profile In-Reply-To: <6edfff72-8ba6-490d-b4a8-0ccf5685a7c6@o14g2000vbo.googlegroups.com> References: <6edfff72-8ba6-490d-b4a8-0ccf5685a7c6@o14g2000vbo.googlegroups.com> Message-ID: <8d961d900905221224q4143cc2fqea2aada602f16373@mail.gmail.com> > Hey Folks, > Aargh profiles. The initial intention was that you could just do cucumber -p foo. And then you wouldn't have to type a lot of arguments. The intention was *not* to use -p along with additional arguments, although cucumber lets you do it by merging stuff together. Using profiles as a mechanism to run various subsets of features and step definitions that live underneath the same features directory is something I do *not* recommend. It's much easier to have several different root folders: features # regular stuff selenium_features # only selenium stuff And a rake task for each. Or run cucumber selenium_features or cucumber features as you see fit. I know the wiki recommends all this crazy profile stuff. I'm sorry about that - I didn't write it. > I followed the instructions on http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium > and created 2 profiles: default and selenium. It works, but not if I > want to run one feature under a specifc profile. For example, I tried: > > cucumber -p default --require features features/plain/ > manage_users.feature > > and I get all the tests including the selenium server. > > What's goin' on like? Try to add --verbose to see what's going on. Or better - organise your features like I described above, and lose the profiles. Aslak > > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri May 22 15:26:31 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 22 May 2009 21:26:31 +0200 Subject: [rspec-users] Latest cucumber 0.3.6 + rspec >1.2.2 broken? In-Reply-To: <02350542-93fe-4ca6-a75a-793d6d3f6171@v4g2000vba.googlegroups.com> References: <02350542-93fe-4ca6-a75a-793d6d3f6171@v4g2000vba.googlegroups.com> Message-ID: <8d961d900905221226h171808c0oe8faf8e4ecfb160c@mail.gmail.com> > Hi all, > > It looks like the following line was removed from "/lib/spec/ > expectations.rb" on April 11: > > attr_accessor :differ > > When I try to use cucumber (version 0.3.6), it tries to > call ::Spec:Expectations.differ= and fails. ?There does not seem to be The actual command, error message and stacktrace would be helpful. > anything in the history regarding the removal/deprecation of this > method -- is this a bug in rspec, bug in cucumber, both, or neither? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Fri May 22 16:32:09 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 22 May 2009 14:32:09 -0600 Subject: [rspec-users] Cucumber: Running one feature under one profile In-Reply-To: <8d961d900905221224q4143cc2fqea2aada602f16373@mail.gmail.com> References: <6edfff72-8ba6-490d-b4a8-0ccf5685a7c6@o14g2000vbo.googlegroups.com> <8d961d900905221224q4143cc2fqea2aada602f16373@mail.gmail.com> Message-ID: <4A170BC9.4010603@benmabey.com> aslak hellesoy wrote: >> Hey Folks, >> >> > > Aargh profiles. The initial intention was that you could just do > cucumber -p foo. > And then you wouldn't have to type a lot of arguments. > > The intention was *not* to use -p along with additional arguments, > although cucumber lets you do it by merging stuff together. > > Using profiles as a mechanism to run various subsets of features and > step definitions that live underneath the same features directory is > something I do *not* recommend. It's much easier to have several > different root folders: > > features # regular stuff > selenium_features # only selenium stuff > > And a rake task for each. Or run cucumber selenium_features or > cucumber features as you see fit. > > I know the wiki recommends all this crazy profile stuff. I'm sorry > about that - I didn't write it. > I somewhat disagree, the combination of profiles + tags is a good way to organize the features IMO. The feature file talks about the feature regardless of if it uses JS or not. So, if you have a feature that uses webrat 90% of the time but then has one or two scenarios that require JS you don't need to split that feature into two separate features files- you can just tag them. I can see how having separate dirs can be helpful as well, but in general I kinda like the "crazy profile" stuff. :) FWIW, Ben > >> I followed the instructions on http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium >> and created 2 profiles: default and selenium. It works, but not if I >> want to run one feature under a specifc profile. For example, I tried: >> >> cucumber -p default --require features features/plain/ >> manage_users.feature >> >> and I get all the tests including the selenium server. >> >> What's goin' on like? >> > > Try to add --verbose to see what's going on. Or better - organise your > features like I described above, and lose the profiles. > > Aslak > > >> Thanks >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri May 22 18:02:52 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 23 May 2009 00:02:52 +0200 Subject: [rspec-users] Cucumber: Running one feature under one profile In-Reply-To: <4A170BC9.4010603@benmabey.com> References: <6edfff72-8ba6-490d-b4a8-0ccf5685a7c6@o14g2000vbo.googlegroups.com> <8d961d900905221224q4143cc2fqea2aada602f16373@mail.gmail.com> <4A170BC9.4010603@benmabey.com> Message-ID: <8d961d900905221502q58b87687kcff65fdb2fb72deb@mail.gmail.com> > aslak hellesoy wrote: >>> >>> Hey Folks, >>> >>> >> >> Aargh profiles. The initial intention was that you could just do >> cucumber -p foo. >> And then you wouldn't have to type a lot of arguments. >> >> The intention was *not* to use -p along with additional arguments, >> although cucumber lets you do it by merging stuff together. >> >> Using profiles as a mechanism to run various subsets of features and >> step definitions that live underneath the same features directory is >> something I do *not* recommend. It's much easier to have several >> different root folders: >> >> features # regular stuff >> selenium_features # only selenium stuff >> >> And a rake task for each. Or run cucumber selenium_features or >> cucumber features as you see fit. >> >> I know the wiki recommends all this crazy profile stuff. I'm sorry >> about that - I didn't write it. >> > > I somewhat disagree, the combination of profiles + tags is a good way to > organize the features IMO. > The feature file talks about the feature > regardless of if it uses JS or not. ?So, if you have a feature that uses > webrat 90% of the time but then has one or two scenarios that require JS you > don't need to split that feature into two separate features files- you can > just tag them. ? I can see how having separate dirs can be helpful as well, > but in general I kinda like the "crazy profile" stuff. :) > Good points Ben. People ask questions almost daily about Selenium, and many of them seem related to profiles. Since I don't use either of them much I'm not in a good position to help people with it. That's why I recommend people go for a less complex setup. Aslak > FWIW, > > Ben > >> >>> >>> I followed the instructions on >>> http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium >>> and created 2 profiles: default and selenium. It works, but not if I >>> want to run one feature under a specifc profile. For example, I tried: >>> >>> cucumber -p default --require features features/plain/ >>> manage_users.feature >>> >>> and I get all the tests including the selenium server. >>> >>> What's goin' on like? >>> >> >> Try to add --verbose to see what's going on. Or better - organise your >> features like I described above, and lose the profiles. >> >> Aslak >> >> >>> >>> Thanks >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri May 22 18:55:07 2009 From: lists at ruby-forum.com (Ben Johnson) Date: Sat, 23 May 2009 00:55:07 +0200 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> Message-ID: Did anyone ever figure out the factory_girl / machinist issues? I am having the same problems and can figure out how to fix it for the life of me. The first run works fine, then afterwards I get a bunch of these errors: No blueprint for class Venue Any ideas? Thanks! -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Fri May 22 19:41:43 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Fri, 22 May 2009 19:41:43 -0400 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> Message-ID: <4A173837.7090605@railsnewbie.com> Ben Johnson wrote: > Did anyone ever figure out the factory_girl / machinist issues? I am > having the same problems and can figure out how to fix it for the life > of me. The first run works fine, then afterwards I get a bunch of these > errors: > > No blueprint for class Venue > > Any ideas? Thanks! > I don't know about Machinist or Factory Girl. Basically, here's the deal: If those libraries use require instead of load, you are screwed. Same goes for autoload'ing. If those libraries internally use load, or load_dependency, and you have cache_classes = false in your dev env, you could try manually reloading it. Here's FixtureReplacement in script/console (@ version 2.1) after reload! is called: http://gist.github.com/116422 From scott at railsnewbie.com Fri May 22 19:53:39 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Fri, 22 May 2009 19:53:39 -0400 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> Message-ID: <4A173B03.8010409@railsnewbie.com> Ben Johnson wrote: > Did anyone ever figure out the factory_girl / machinist issues? I am > having the same problems and can figure out how to fix it for the life > of me. The first run works fine, then afterwards I get a bunch of these > errors: > > No blueprint for class Venue > > Any ideas? Thanks! > Actually, I decided to make a tiny release. See this commit: http://github.com/smtlaissezfaire/fixturereplacement/commit/6aba70c51f0701820b46dc687e965b43e21eca41 Scott From lists at ruby-forum.com Sat May 23 00:30:50 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Sat, 23 May 2009 06:30:50 +0200 Subject: [rspec-users] RSpec for Rails plugin In-Reply-To: <57c63afe0905191254u302ac93br5398eba7e9526e89@mail.gmail.com> References: <57c63afe0905191254u302ac93br5398eba7e9526e89@mail.gmail.com> Message-ID: <2bc7b644773cbaf78ee18ef36e184c27@ruby-forum.com> David Chelimsky wrote: > Check out Pat's rspec plugin generator: > > http://github.com/pat-maddox/rspec-plugin-generator/tree/master Hey thanks. That sounds like just the thing, but I'm kind of new to this stuff. I guessed where to put it and it seemed to work so far. I'm adding notes as I go to the wiki: http://wiki.github.com/pat-maddox/rspec-plugin-generator/installation-and-basic-use I'm following along with http://guides.rubyonrails.org/plugins.html but I'm feeling my way around in the dark a bit since I'm relatively new to rspec and plugins. If anyone is inspired to read the new wiki page and let me know if there's any points I'm missing, that would be nice. I expected to be able to run 'spec:plugins' but it appears to have no effect: $ rake spec:plugins (in /Users/sarah/src/yaffle_guide) It does work if I call spec on the spec.rb file $ spec vendor/plugins/yaffle/spec/yaffle_spec.rb -- create_table(:hickwalls, {:force=>true}) -> 0.0663s -- create_table(:wickwalls, {:force=>true}) -> 0.0114s -- create_table(:woodpeckers, {:force=>true}) -> 0.0075s -- initialize_schema_migrations_table() -> 0.0011s -- assume_migrated_upto_version(0) -> 0.0009s . Finished in 0.005407 seconds 1 example, 0 failures With a plugin that has many spec.rb files, how do I run all of them? Thanks, Sarah -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat May 23 01:27:38 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Sat, 23 May 2009 07:27:38 +0200 Subject: [rspec-users] undefined method `assert_select' Message-ID: I'm having trouble getting the specs to run for a plugin where I want to fix a bug. (I've actually already found and fixed the bug, but I don't want to submit a fix without a test!) When I started the specs weren't running, but it may be that I'm using Rails 2.3.3 and the plugin has been tested on 2.1 and earlier. I went through writing a spec for a very simple plugin to get some perspective on how things fit together, and I've resolved some issues, but still see this error: $ spec vendor/plugins/openlaszlo_plugin/spec/swfobject_view_helper_spec.rb FFFFFFF 1) NoMethodError in 'ActionView::Helpers::SwfObjectHelper swfobject_tag should call swfobject.embedSWF' undefined method `assert_select' for # ./vendor/plugins/openlaszlo_plugin/spec/swfobject_view_helper_spec.rb:17: line 17 is: html.should have_tag('script', /swfobject.embedSWF/) Can anyone give me a hint? Thanks, Sarah -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat May 23 08:13:30 2009 From: lists at ruby-forum.com (Rishi Gh) Date: Sat, 23 May 2009 14:13:30 +0200 Subject: [rspec-users] How to execute code if a rspec test fails Message-ID: I am trying to make a call to a class/fxn I made, depending on whether an Rspec test fails. If it fails, I want to make the call, otherwise I won't need to. Is there some error message or specific syntax for checking this? Also, WHERE should I place this to pickup failed tests, and make the call? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat May 23 13:42:28 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 23 May 2009 19:42:28 +0200 Subject: [rspec-users] Writing specs pointed out I need to refactor my admin area Message-ID: Hi, My app now nearly has 100% coverage and when refactoring the code, potential bugs are immediately pointed out. So that's a big win. Moreover when writing specs for my controllers and views of the admin zone, I quickly realized that I was often copying/pasting code and tests. That annoyed me. Controller LOC: 700, associated tests LOC: 1500!!! That's stupid! So I wrote an AdminController from which my other controllers inherit from, and that enables me to drastically cut down the lines of redundant code in the controller. But then what to do with the views? I still need to make sure they get rendered correctly, so I still can cut down on the tests. One solution I see is to write an abstract set of views that controllers will be using, but for some reason I think it will blow in my fa?e at some point. Some views need to display images others don't, some display a table others don't, etc. What do you guys do for your admin zone to make sure it is well covered with tests and that don't feel redundant? Do you use something like Steamlined or ActiveScaffold? Regards, -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat May 23 14:18:00 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Sat, 23 May 2009 20:18:00 +0200 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: References: Message-ID: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> Sarah Allen wrote: > line 17 is: > html.should have_tag('script', /swfobject.embedSWF/) I order to use have_tag, it appears I have to include: # just enough infrastructure to get 'assert_select' to work require 'action_controller' require 'action_controller/assertions/selector_assertions' include ActionController::Assertions::SelectorAssertions borrowed from: http://intertwingly.net/stories/2009/05/06/checkdepot.rb Odd, because it seems like this used to work without that in a previous version of Rails, but I would need to investigate more to isolate what went wrong. I figured I would go ahead and post this as something that works. Sarah -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat May 23 15:00:02 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Sat, 23 May 2009 21:00:02 +0200 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> Message-ID: <2a6c5dc5ebdeb3ebd60427d612926f3e@ruby-forum.com> Sarah Allen wrote: > Sarah Allen wrote: >> line 17 is: >> html.should have_tag('script', /swfobject.embedSWF/) > > I order to use have_tag, it appears I have to include: > > # just enough infrastructure to get 'assert_select' to work > require 'action_controller' > require 'action_controller/assertions/selector_assertions' > include ActionController::Assertions::SelectorAssertions Confirmed that this is is required in Rails 2.3.2 and not in 2.1.0, although I still don't understand why. Sarah -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sat May 23 16:46:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 May 2009 16:46:32 -0400 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: <2a6c5dc5ebdeb3ebd60427d612926f3e@ruby-forum.com> References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> <2a6c5dc5ebdeb3ebd60427d612926f3e@ruby-forum.com> Message-ID: <57c63afe0905231346m13f622a4x98fae1d8c9622f25@mail.gmail.com> On Sat, May 23, 2009 at 3:00 PM, Sarah Allen wrote: > Sarah Allen wrote: >> Sarah Allen wrote: >>> line 17 is: >>> ? ? ? html.should have_tag('script', /swfobject.embedSWF/) >> >> I order to use have_tag, it appears I have to include: >> >> # just enough infrastructure to get 'assert_select' to work >> require 'action_controller' >> require 'action_controller/assertions/selector_assertions' >> include ActionController::Assertions::SelectorAssertions > > Confirmed that this is is required in Rails 2.3.2 and not in 2.1.0, > although I still don't understand why. Me neither :) What version of rspec are you using? > > Sarah > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat May 23 18:02:43 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 May 2009 18:02:43 -0400 Subject: [rspec-users] RSpec for Rails plugin In-Reply-To: <2bc7b644773cbaf78ee18ef36e184c27@ruby-forum.com> References: <57c63afe0905191254u302ac93br5398eba7e9526e89@mail.gmail.com> <2bc7b644773cbaf78ee18ef36e184c27@ruby-forum.com> Message-ID: <57c63afe0905231502q78215636lf0704e4d79037f18@mail.gmail.com> On Sat, May 23, 2009 at 12:30 AM, Sarah Allen wrote: > David Chelimsky wrote: >> Check out Pat's rspec plugin generator: >> >> http://github.com/pat-maddox/rspec-plugin-generator/tree/master > > Hey thanks. ?That sounds like just the thing, but I'm kind of new to > this stuff. ?I guessed where to put it and it seemed to work so far. > I'm adding notes as I go to the wiki: > http://wiki.github.com/pat-maddox/rspec-plugin-generator/installation-and-basic-use > > I'm following along with http://guides.rubyonrails.org/plugins.html but > I'm feeling my way around in the dark a bit since I'm relatively new to > rspec and plugins. ?If anyone is inspired to read the new wiki page and > let me know if there's any points I'm missing, that would be nice. > > I expected to be able to run 'spec:plugins' but it appears to have no > effect: > ?$ rake spec:plugins > ?(in /Users/sarah/src/yaffle_guide) > > It does work if I call spec on the spec.rb file > > $ spec vendor/plugins/yaffle/spec/yaffle_spec.rb > -- create_table(:hickwalls, {:force=>true}) > ? -> 0.0663s > -- create_table(:wickwalls, {:force=>true}) > ? -> 0.0114s > -- create_table(:woodpeckers, {:force=>true}) > ? -> 0.0075s > -- initialize_schema_migrations_table() > ? -> 0.0011s > -- assume_migrated_upto_version(0) > ? -> 0.0009s > . > > Finished in 0.005407 seconds > > 1 example, 0 failures > > > With a plugin that has many spec.rb files, how do I run all of them? I'm not sure why 'rake spec:plugins' is not working for you, but short of solving that problem, you can type the spec command directly if you have rspec and rspec-rails gems installed: spec vendor/plugins/yaffle/spec By default, that will pick up all the files below vendor/plugins/yaffle/spec that end in _spec.rb. You can learn more about how to use the command by typing: spec --help Cheers, David > > Thanks, > Sarah > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat May 23 18:05:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 May 2009 18:05:11 -0400 Subject: [rspec-users] How to execute code if a rspec test fails In-Reply-To: References: Message-ID: <57c63afe0905231505p70c1d1a5sa13e8d010085e290@mail.gmail.com> On Sat, May 23, 2009 at 8:13 AM, Rishi Gh wrote: > I am trying to make a call to a class/fxn I made, depending on whether > an Rspec test fails. If it fails, I want to make the call, otherwise I > won't need to. > Is there some error message or specific syntax for checking this? Also, > WHERE should I place this to pickup failed tests, and make the call? Right now the only supported place to pick up this information is in a custom formatter. See http://wiki.github.com/dchelimsky/rspec/custom-formatters to get started. Cheers, David From lists at ruby-forum.com Sat May 23 18:22:54 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Sun, 24 May 2009 00:22:54 +0200 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: <57c63afe0905231346m13f622a4x98fae1d8c9622f25@mail.gmail.com> References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> <2a6c5dc5ebdeb3ebd60427d612926f3e@ruby-forum.com> <57c63afe0905231346m13f622a4x98fae1d8c9622f25@mail.gmail.com> Message-ID: <59b0dfeb6b0eaedabdc2df38f8eb817e@ruby-forum.com> David Chelimsky wrote: > What version of rspec are you using? 1.2.6 -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Sun May 24 01:16:41 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 23 May 2009 23:16:41 -0600 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <4A173837.7090605@railsnewbie.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> Message-ID: <4A18D839.6030709@benmabey.com> Scott Taylor wrote: > Ben Johnson wrote: >> Did anyone ever figure out the factory_girl / machinist issues? I am >> having the same problems and can figure out how to fix it for the >> life of me. The first run works fine, then afterwards I get a bunch >> of these errors: >> >> No blueprint for class Venue >> >> Any ideas? Thanks! >> > I don't know about Machinist or Factory Girl. Basically, here's the > deal: > > If those libraries use require instead of load, you are screwed. Same > goes for autoload'ing. Yep. You might want to check out Spork[1]. It is a drop-in replacement for spec_server that uses Kernel.fork instead of reloading classes to ensure a clean app state. My coworker, Tim Harper, wrote it and it has been working great for us so far. (There is a little setup, so not quite drop-in but it just works with the --drb flag for rspec.) 1. http://github.com/timcharper/spork/tree/master -Ben > > If those libraries internally use load, or load_dependency, and you > have cache_classes = false in your dev env, you could try manually > reloading it. > Here's FixtureReplacement in script/console (@ version 2.1) after > reload! is called: > > http://gist.github.com/116422 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From scott at railsnewbie.com Sun May 24 05:30:54 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Sun, 24 May 2009 05:30:54 -0400 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <4A18D839.6030709@benmabey.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> <4A18D839.6030709@benmabey.com> Message-ID: <4A1913CE.4070409@railsnewbie.com> Ben Mabey wrote: > Scott Taylor wrote: >> Ben Johnson wrote: >>> Did anyone ever figure out the factory_girl / machinist issues? I am >>> having the same problems and can figure out how to fix it for the >>> life of me. The first run works fine, then afterwards I get a bunch >>> of these errors: >>> >>> No blueprint for class Venue >>> >>> Any ideas? Thanks! >>> >> I don't know about Machinist or Factory Girl. Basically, here's the >> deal: >> >> If those libraries use require instead of load, you are screwed. >> Same goes for autoload'ing. > Yep. You might want to check out Spork[1]. It is a drop-in > replacement for spec_server that uses Kernel.fork instead of reloading > classes to ensure a clean app state. My coworker, Tim Harper, wrote > it and it has been working great for us so far. (There is a little > setup, so not quite drop-in but it just works with the --drb flag for > rspec.) > > 1. http://github.com/timcharper/spork/tree/master > > -Ben That's absolutely awesome. Have there been any attempts to generalize this, so that mongrel will fork on each request (a la shotgun)? (I'm still stuck on rails 2.0.2, so a non-rack based reloading scheme would be great). Scott > > >> >> If those libraries internally use load, or load_dependency, and you >> have cache_classes = false in your dev env, you could try manually >> reloading it. >> Here's FixtureReplacement in script/console (@ version 2.1) after >> reload! is called: >> >> http://gist.github.com/116422 >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From nick at deadorange.com Sun May 24 12:25:18 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 24 May 2009 12:25:18 -0400 Subject: [rspec-users] Class method not being stubbed Message-ID: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> Hi guys. I'm setting an expectation on a class method. For some reason, the method isn't being stubbed, and the expectation isn't seeing the call. In KeywordListsController#create, I call the private method #create_keywords_and_associate, which calls AdSenseHeavenParser#parse . Thus, some of my specs set an expectation on AdSenseHeavenParser#parse . However, that expectation isn't stubbing out #parse . In the "output" section of my paste: http://pastie.org/488160 you can see that the second line is "*** create_keywords_and_associate ***". However, that string shouldn't be printed if AdSenseHeavenParser#parse is stubbed out. I've been beating my head against this for a couple of hours. Any thoughts? Thanks, Nick From lists at ruby-forum.com Sun May 24 12:49:59 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 24 May 2009 18:49:59 +0200 Subject: [rspec-users] Class method not being stubbed In-Reply-To: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> Message-ID: > I've been beating my head against this for a couple of hours. Any > thoughts? The easiest for you is to use the debugger and go through each line in the controller. Maybe @keyword_list.save is returning false? Stub it out and see by yourself. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun May 24 13:01:25 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 24 May 2009 19:01:25 +0200 Subject: [rspec-users] Writing specs pointed out I need to refactor my admin area In-Reply-To: References: Message-ID: <635a8774ff21f1cf494c350f35915b5a@ruby-forum.com> So I tried to implement Django's AutoAdmin, but actually it quite quickly blew in my face. Although the views all look similar, there almost as many little differences as they are models and that's painful to abstract. So I prefer to write my views for each model. Now I have another problem, so my models are fully covered, my controllers too, but what prevents my views from having for instance an incorrect form that would be posting incorrect parameters to my controllers? How do you test that? Cucumber + Webrat? -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Sun May 24 13:10:49 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 24 May 2009 13:10:49 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> Message-ID: On Sun, May 24, 2009 at 12:25 PM, Nick Hoffman wrote: > Hi guys. I'm setting an expectation on a class method. For some > reason, the method isn't being stubbed, and the expectation isn't > seeing the call. > > In KeywordListsController#create, I call the private method > #create_keywords_and_associate, which calls AdSenseHeavenParser#parse > . > > Thus, some of my specs set an expectation on AdSenseHeavenParser#parse > . However, that expectation isn't stubbing out #parse . That's because it isn't a class method, it's an instance method, so instead of: AdSenseHeavenParser.should_receive(:parse).with(keyword_list_contents).and_return({:keywords => [], :errors => []}) You should have controller.should_receive(:parse).with(keyword_list_contents).and_return({:keywords => [], :errors => []}) -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From nick at deadorange.com Sun May 24 13:25:36 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 24 May 2009 13:25:36 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> Message-ID: <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> On Sun, May 24, 2009 at 12:49 PM, Fernando Perez wrote: >> I've been beating my head against this for a couple of hours. Any >> thoughts? > The easiest for you is to use the debugger and go through each line in > the controller. > > Maybe @keyword_list.save is returning false? Stub it out and see by > yourself. Hi Fernando. In this case, I don't think it's a matter of using the debugger. I've already stubbed out #save on @keyword_list, and confirmed that AdSenseHeavenParser#parse is being called. I know the latter is occuring because this is being displayed when the spec is run: *** create_keywords_and_associate *** If AdSenseHeavenParser#parse was actually stubbed out, or wasn't called at all, then that line wouldn't be displayed. -Nick From nick at deadorange.com Sun May 24 13:47:53 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 24 May 2009 13:47:53 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> Message-ID: <16827fa20905241047u7f5c123cmdf030f78fe852505@mail.gmail.com> On Sun, May 24, 2009 at 1:10 PM, Rick DeNatale wrote: > On Sun, May 24, 2009 at 12:25 PM, Nick Hoffman wrote: >> Hi guys. I'm setting an expectation on a class method. For some >> reason, the method isn't being stubbed, and the expectation isn't >> seeing the call. >> >> In KeywordListsController#create, I call the private method >> #create_keywords_and_associate, which calls AdSenseHeavenParser#parse >> . >> >> Thus, some of my specs set an expectation on AdSenseHeavenParser#parse >> . However, that expectation isn't stubbing out #parse . > > That's because it isn't a class method, it's an instance method, so instead of: > > AdSenseHeavenParser.should_receive(:parse).with(keyword_list_contents).and_return({:keywords > => [], :errors => []}) > > You should have > controller.should_receive(:parse).with(keyword_list_contents).and_return({:keywords > => [], :errors => []}) > > -- > Rick DeNatale Hi Rick. I'm not sure what gave you the impression that #parse is an instance method, but it definitely isn't. #parse is a class method inside the AdSenseHeavenParser class. KeywordListsController doesn't have a #parse method: http://pastie.org/488252 -Nick From lists at ruby-forum.com Sun May 24 14:13:49 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 24 May 2009 20:13:49 +0200 Subject: [rspec-users] Class method not being stubbed In-Reply-To: <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> Message-ID: <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> > Hi Fernando. In this case, I don't think it's a matter of using the > debugger. I suspect a problem in: require 'lib/adsense_heaven_parser', the code maybe never gets out of this require statement. The debugger would allow you to immediately clear things out. -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Sun May 24 14:24:08 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 24 May 2009 14:24:08 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> Message-ID: <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> On Sun, May 24, 2009 at 2:13 PM, Fernando Perez wrote: >> Hi Fernando. In this case, I don't think it's a matter of using the >> debugger. > > I suspect a problem in: require 'lib/adsense_heaven_parser', the code > maybe never gets out of this require statement. The debugger would allow > you to immediately clear things out. Hi Fernando. I'm not sure what you mean by "the code never gets out of this require statement". However, that doesn't really matter. The call to #require shouldn't happen, because the method is supposed to be stubbed out. -Nick From lists at ruby-forum.com Sun May 24 14:25:53 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 24 May 2009 20:25:53 +0200 Subject: [rspec-users] Is stubbing a call to super possible? In-Reply-To: <5801C06E-DB6A-4308-988F-EF0DA44DBBBA@elctech.com> References: <775CBF16-A5BF-4753-9424-A4E5FEE39605@elctech.com> <5801C06E-DB6A-4308-988F-EF0DA44DBBBA@elctech.com> Message-ID: <123ffe7150c22b665e7662c8adbe840b@ruby-forum.com> > In the meantime I have used alias_method_chain to override the method > in the super class. I up this old post, but I was having the same problem mocking super() so I had to alias_method_chain my method. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun May 24 14:35:22 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 24 May 2009 20:35:22 +0200 Subject: [rspec-users] Class method not being stubbed In-Reply-To: <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> Message-ID: <1d2597565d2058042471f1fe08ee44a7@ruby-forum.com> > Hi Fernando. I'm not sure what you mean by "the code never gets out of > this require statement". I should have said 'the interpreter never ...' > However, that doesn't really matter. The call to #require shouldn't > happen, because the method is supposed to be stubbed out. You are making a lot of suppositions that are not obvious to us. Nowhere in your pastie is your require call stubbed. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun May 24 15:20:14 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Sun, 24 May 2009 21:20:14 +0200 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> Message-ID: Sarah Allen wrote: > Sarah Allen wrote: >> line 17 is: >> html.should have_tag('script', /swfobject.embedSWF/) > > I order to use have_tag, it appears I have to include: > > # just enough infrastructure to get 'assert_select' to work > require 'action_controller' > require 'action_controller/assertions/selector_assertions' > include ActionController::Assertions::SelectorAssertions I just worked on this a bit with RailsBridge mentor, Zach Moazeni, who figured out that the problem was that I had not specifies a type for my view helper example group: describe SwfObjectHelper, :type => :helper do I thought I would post it here in case anyone else runs into the same issue. Sarah -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Sun May 24 15:25:56 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 24 May 2009 15:25:56 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> Message-ID: On Sun, May 24, 2009 at 2:24 PM, Nick Hoffman wrote: > On Sun, May 24, 2009 at 2:13 PM, Fernando Perez wrote: >>> Hi Fernando. In this case, I don't think it's a matter of using the >>> debugger. >> >> I suspect a problem in: require 'lib/adsense_heaven_parser', the code >> maybe never gets out of this require statement. The debugger would allow >> you to immediately clear things out. > > Hi Fernando. I'm not sure what you mean by "the code never gets out of > this require statement". > > However, that doesn't really matter. The call to #require shouldn't > happen, because the method is supposed to be stubbed out. No that's what confused me. class KeywordListsController < ApplicationController ... private ... def create_keywords_and_associate(keyword_list_contents, keyword_list) puts '*** create_keywords_and_associate ***' require 'lib/adsense_heaven_parser' parsed_list = AdSenseHeavenParser.parse keyword_list_contents The controller method has the require and then calls parse. One thing which strikes me is that if Rails naming conventions were being followed: 1) the file name be lib/ad_sense_heaven_parser not lib/adsense_heaven_parser 2) the require wouldn't be needed since it would be autoloaded. Perhaps the problem lies there somewhere. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From nick at deadorange.com Sun May 24 16:44:07 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 24 May 2009 16:44:07 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: <1d2597565d2058042471f1fe08ee44a7@ruby-forum.com> References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> <1d2597565d2058042471f1fe08ee44a7@ruby-forum.com> Message-ID: <16827fa20905241344l136dd1f7h385b09697f0b8c05@mail.gmail.com> >> Hi Fernando. I'm not sure what you mean by "the code never gets out of >> this require statement". > I should have said 'the interpreter never ...' Ah, I understand what you mean now. >> However, that doesn't really matter. The call to #require shouldn't >> happen, because the method is supposed to be stubbed out. > You are making a lot of suppositions that are not obvious to us. Nowhere > in your pastie is your require call stubbed. I'm not sure why the call to #require would need to be stubbed. What I'm trying to say is that I've set a message expectation on AdSenseHeavenParser#parse , which should prevent the method from being called in the first place. -Nick From nick at deadorange.com Sun May 24 16:49:52 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 24 May 2009 16:49:52 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> Message-ID: <16827fa20905241349i6ce09b95xd209d2793ec40cf4@mail.gmail.com> On Sun, May 24, 2009 at 3:25 PM, Rick DeNatale wrote: >> However, that doesn't really matter. The call to #require shouldn't >> happen, because the method is supposed to be stubbed out. > > No that's what confused me. > > class KeywordListsController < ApplicationController > ... > ? private > ... > ?def create_keywords_and_associate(keyword_list_contents, keyword_list) > ? ?puts '*** create_keywords_and_associate ***' > ? ?require 'lib/adsense_heaven_parser' > ? ?parsed_list = AdSenseHeavenParser.parse keyword_list_contents > > The controller method has the require and then calls parse. Yup! But in my specs, when the controller method calls #parse , the stub should consume the method call. > One thing which strikes me is that if Rails naming conventions were > being followed: > > ?1) the file name be lib/ad_sense_heaven_parser not lib/adsense_heaven_parser Normally, the file would be named like that. However, the class represents a service called "AdSense Heaven", which doesn't have a space between "Ad" and "Sense"...or should that still cause the file to be named "ad_sense_..."? > ?2) the require wouldn't be needed since it would be autoloaded. I thought that everything in lib/ should be autoloaded. When I found that lib/adsense_heaven_parser.rb wasn't being autoloaded, I figured I was wrong, and simply #require'd it in. > Perhaps the problem lies there somewhere. That's a good idea. I'll look into it and let you know. Thanks, Nick From dchelimsky at gmail.com Sun May 24 18:05:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 May 2009 18:05:37 -0400 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> Message-ID: <57c63afe0905241505l7d45a3f8t232a8c32290e3b2e@mail.gmail.com> On Sun, May 24, 2009 at 3:20 PM, Sarah Allen wrote: > Sarah Allen wrote: >> Sarah Allen wrote: >>> line 17 is: >>> ? ? ? html.should have_tag('script', /swfobject.embedSWF/) >> >> I order to use have_tag, it appears I have to include: >> >> # just enough infrastructure to get 'assert_select' to work >> require 'action_controller' >> require 'action_controller/assertions/selector_assertions' >> include ActionController::Assertions::SelectorAssertions > > I just worked on this a bit with RailsBridge mentor, Zach Moazeni, who > figured out that the problem was that I had not specifies a type for my > view helper example group: > > describe SwfObjectHelper, :type => :helper do FYI - if you put this file in spec/helpers/swf_object_helper_spec.rb, then :type => :helper is implied, so you don't have to make it explicit. Cheers, David > > I thought I would post it here in case anyone else runs into the same > issue. > > Sarah > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sun May 24 18:55:51 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 25 May 2009 00:55:51 +0200 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: <57c63afe0905241505l7d45a3f8t232a8c32290e3b2e@mail.gmail.com> References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> <57c63afe0905241505l7d45a3f8t232a8c32290e3b2e@mail.gmail.com> Message-ID: <40179834e69c5e6a688e3d6dde7a4827@ruby-forum.com> David Chelimsky wrote: > FYI - if you put this file in spec/helpers/swf_object_helper_spec.rb, > then :type => :helper is implied, so you don't have to make it > explicit. Nice. By the way, I've been enjoying The RSpec Book, but it looks like I had to figure out view helpers before that chapter was ready. Thank for your help on this list! Sarah -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun May 24 19:15:43 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 25 May 2009 01:15:43 +0200 Subject: [rspec-users] modules and stub Message-ID: <258f844c2771c1285812dc1a17cb5080@ruby-forum.com> If there is a method defined on a module, how do I stub it? Imagine I have a module like this: Module Foo Module Bar def self.do_something(path) ... end end end Somewhere in the code, there is this call: Foo::Bar::do_something(path) In my test I want the above call to do nothing, so I tried this: before(:each) do Foo::Bar.stub!(:do_something).and_return end but I confirm that do_something is getting called by adding a puts in it. Do I not have the module/stub syntax correct? How can I isolate this further? I tried looking at the doc ( http://rspec.rubyforge.org/rspec/1.2.6/ ) but I couldn't really make sense of it. Thanks, Sarah -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun May 24 19:38:06 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 25 May 2009 01:38:06 +0200 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: <57c63afe0905241505l7d45a3f8t232a8c32290e3b2e@mail.gmail.com> References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> <57c63afe0905241505l7d45a3f8t232a8c32290e3b2e@mail.gmail.com> Message-ID: <3a653e5c98fba9bdd1f724db03764732@ruby-forum.com> David Chelimsky wrote: > FYI - if you put this file in spec/helpers/swf_object_helper_spec.rb, > then :type => :helper is implied, so you don't have to make it > explicit. just curious... are there any other magic directories I should know about? Thanks, Sarah -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun May 24 23:50:44 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 May 2009 23:50:44 -0400 Subject: [rspec-users] undefined method `assert_select' In-Reply-To: <3a653e5c98fba9bdd1f724db03764732@ruby-forum.com> References: <4c916c68d1df0a584cf6214a56ff4ead@ruby-forum.com> <57c63afe0905241505l7d45a3f8t232a8c32290e3b2e@mail.gmail.com> <3a653e5c98fba9bdd1f724db03764732@ruby-forum.com> Message-ID: <57c63afe0905242050n4ed026bfp11cedc2df6c13ac3@mail.gmail.com> On Sun, May 24, 2009 at 7:38 PM, Sarah Allen wrote: > David Chelimsky wrote: >> FYI - if you put this file in spec/helpers/swf_object_helper_spec.rb, >> then :type => :helper is implied, so you don't have to make it >> explicit. > > just curious... are there any other magic directories I should know > about? All directories under spec/ are potentially magic - rspec will always look at spec/:directory/:filename and see if it has an example group type registered for whatever directory is. So if there *is* a foo example group type, it will be used for any spec file in spec/foos. rspec-rails uses that feature of rspec to implicitly load custom groups for models, views, controllers and helpers in spec/models, spec/views, spec/controllers and spec/helpers. Cheers, David > > Thanks, > Sarah > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun May 24 23:52:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 May 2009 23:52:38 -0400 Subject: [rspec-users] modules and stub In-Reply-To: <258f844c2771c1285812dc1a17cb5080@ruby-forum.com> References: <258f844c2771c1285812dc1a17cb5080@ruby-forum.com> Message-ID: <57c63afe0905242052r318953fl208aa4dfd6f9a93@mail.gmail.com> On Sun, May 24, 2009 at 7:15 PM, Sarah Allen wrote: > If there is a method defined on a module, how do I stub it? > > Imagine I have a module like this: > > Module Foo > ? Module Bar > > ? ?def self.do_something(path) > ?... > ? ?end > > > ? end > end > > > Somewhere in the code, there is this call: > ? ? ? ? ? ? ? Foo::Bar::do_something(path) > > In my test I want the above call to do nothing, so I tried this: > ? ?before(:each) do > ? ? ?Foo::Bar.stub!(:do_something).and_return > ? ?end > > but I confirm that do_something is getting called by adding a puts in > it. Do I not have the module/stub syntax correct? ?How can I isolate > this further? > > I tried looking at the doc ( http://rspec.rubyforge.org/rspec/1.2.6/ ) > but I couldn't really make sense of it. Stub methods on objects, not modules. The method can be one that *comes from* a module, but you need to stub it on the specific object that is at play in the example. module Foo def do_something end class Bar include Foo end describe Bar do before(:each) do @bar = Bar.new @bar.stub(:do_something) end ... end HTH, David > > Thanks, > Sarah > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon May 25 00:03:21 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 25 May 2009 06:03:21 +0200 Subject: [rspec-users] modules and stub In-Reply-To: <57c63afe0905242052r318953fl208aa4dfd6f9a93@mail.gmail.com> References: <258f844c2771c1285812dc1a17cb5080@ruby-forum.com> <57c63afe0905242052r318953fl208aa4dfd6f9a93@mail.gmail.com> Message-ID: David Chelimsky wrote: > Stub methods on objects, not modules. The method can be one that > *comes from* a module, but you need to stub it on the specific object > that is at play in the example. That makes sense, except the code does this: Foo::Bar::do_something(path) I'm not an expert with modules, but that looks like it is calling the method directly on the module without an object. Is there any way for me to stub that? or is that not a good thing to be doing? Thanks, Sarah -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon May 25 00:54:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 May 2009 00:54:54 -0400 Subject: [rspec-users] modules and stub In-Reply-To: References: <258f844c2771c1285812dc1a17cb5080@ruby-forum.com> <57c63afe0905242052r318953fl208aa4dfd6f9a93@mail.gmail.com> Message-ID: <57c63afe0905242154y162e17a6td1e3658984bc1a3@mail.gmail.com> On Mon, May 25, 2009 at 12:03 AM, Sarah Allen wrote: > David Chelimsky wrote: >> Stub methods on objects, not modules. The method can be one that >> *comes from* a module, but you need to stub it on the specific object >> that is at play in the example. > > That makes sense, except the code does this: > ?Foo::Bar::do_something(path) > > I'm not an expert with modules, but that looks like it is calling the > method directly on the module without an object. You're correct. > Is there any way for me to stub that? You can stub that like this: Foo::Bar.stub(:do_something) > or is that not a good thing to be doing? This really depends on a lot of different factors. Whether Bar is a module or a class, do_something is essentially a global, and globals are *generally* problematic for testing because they increase the risk of leaking state from example to example. That said, the four mock frameworks supported directly by rspec (rspec, mocha, flexmock and rr) all roll back stubs after each example and they all seem to work just fine. Therefore that risk is mitigated. But that doesn't mean it's 100% risk-free. Ruby is very flexible and powerful, and just as mock/stub frameworks can momentarily change an object's behaviour, so can any library code or application code. If you stub, for example, do_something on this module, but it turns out that do_something gets added to the module through some dynamic means *after the stub declaration*, the stub declaration will be overwritten and you'll get surprising results. This is not just true of globals - it's true of any methods that appear through the magic of metaprogramming. HTH, David > Thanks, > Sarah > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon May 25 01:04:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 May 2009 01:04:26 -0400 Subject: [rspec-users] Is stubbing a call to super possible? In-Reply-To: <123ffe7150c22b665e7662c8adbe840b@ruby-forum.com> References: <775CBF16-A5BF-4753-9424-A4E5FEE39605@elctech.com> <5801C06E-DB6A-4308-988F-EF0DA44DBBBA@elctech.com> <123ffe7150c22b665e7662c8adbe840b@ruby-forum.com> Message-ID: <57c63afe0905242204s29515bcauefa338ec52efb957@mail.gmail.com> On Sun, May 24, 2009 at 2:25 PM, Fernando Perez wrote: >> In the meantime I have used alias_method_chain to override the method >> in the super class. > I up this old post, but I was having the same problem mocking super() so > I had to alias_method_chain my method. You can't mock super because super doesn't behave like other methods. It is a language keyword that invokes the same method on the parent class. So if you do this: def foo super end ... the call to super calls foo on the superclass. Since we don't get into the class hierarchy in rspec's mock/stub framework, there is no facility for managing this. I believe that is the case for mocha, flexmock and rr as well, though I could be wrong. HTH, David From ben at benmabey.com Mon May 25 01:17:07 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 24 May 2009 23:17:07 -0600 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <4A1913CE.4070409@railsnewbie.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> <4A18D839.6030709@benmabey.com> <4A1913CE.4070409@railsnewbie.com> Message-ID: <4A1A29D3.9020102@benmabey.com> Scott Taylor wrote: > Ben Mabey wrote: >> Scott Taylor wrote: >>> Ben Johnson wrote: >>>> Did anyone ever figure out the factory_girl / machinist issues? I >>>> am having the same problems and can figure out how to fix it for >>>> the life of me. The first run works fine, then afterwards I get a >>>> bunch of these errors: >>>> >>>> No blueprint for class Venue >>>> >>>> Any ideas? Thanks! >>>> >>> I don't know about Machinist or Factory Girl. Basically, here's the >>> deal: >>> >>> If those libraries use require instead of load, you are screwed. >>> Same goes for autoload'ing. >> Yep. You might want to check out Spork[1]. It is a drop-in >> replacement for spec_server that uses Kernel.fork instead of >> reloading classes to ensure a clean app state. My coworker, Tim >> Harper, wrote it and it has been working great for us so far. >> (There is a little setup, so not quite drop-in but it just works with >> the --drb flag for rspec.) >> >> 1. http://github.com/timcharper/spork/tree/master >> >> -Ben > > That's absolutely awesome. > Have there been any attempts to generalize this, so that mongrel will > fork on each request (a la shotgun)? (I'm still stuck on rails 2.0.2, > so a non-rack based reloading scheme would be great). Well, so Spork was really created with testing in mind. It is more general purpose than spec_server though. You can use it with any Ruby project, not just Rails. You can also potentially use it with any other testing framework that adds support for it (I've been meaning to do this for Cucumber). I know that Tim's original work with Kernel.fork was actually dealing with Mongrel but I'm not sure what the exact details of it are. I'll try to find out for you though. -Ben From lists at ruby-forum.com Mon May 25 01:51:02 2009 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 25 May 2009 07:51:02 +0200 Subject: [rspec-users] modules and stub In-Reply-To: <57c63afe0905242154y162e17a6td1e3658984bc1a3@mail.gmail.com> References: <258f844c2771c1285812dc1a17cb5080@ruby-forum.com> <57c63afe0905242052r318953fl208aa4dfd6f9a93@mail.gmail.com> <57c63afe0905242154y162e17a6td1e3658984bc1a3@mail.gmail.com> Message-ID: <94914cd0ea560718e5f8f391c480b5e6@ruby-forum.com> David Chelimsky wrote: > > Foo::Bar.stub(:do_something) hmm. that's pretty close to where I started. > If you stub, for example, do_something on this module, but it turns > out that do_something gets added to the module through some dynamic > means *after the stub declaration*, the stub declaration will be > overwritten and you'll get surprising results. This is not just true > of globals - it's true of any methods that appear through the magic of > metaprogramming. Ah, the joys of dynamic languages. After further looking at the code, I see that the module 'require' is intentionally inside an if, so that it will only get loaded as needed. If I explicitly require file containing the module in the spec.rb file, then it works. I suppose the require in the code I'm testing will only have an effect when it's not present in the calling code. Still puzzled why I could call the module before without getting a syntax error. Thanks so much for your help. Sarah -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon May 25 09:27:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 May 2009 09:27:25 -0400 Subject: [rspec-users] spec for not null In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013F6522@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013F6522@awww.armis.com> Message-ID: <57c63afe0905250627y30ce11bbo377b2de5c6553d4a@mail.gmail.com> On Mon, May 25, 2009 at 6:51 AM, Diwakar, ANGLER - EIT wrote: > how should we check not null in rspec > > ???????? user_valid = @user.valid? > ??????? password_credential_valid = @password.valid? > > > ???I am getting the below error > > ??? Mock 'User_1001' received unexpected message :valid? with (no args) Assuming that @user is the same mock object that is causing the error, you need to tell the @user that it should receive valid?: @user.should_receive(:valid?).and_return(true) I'm not sure what this has to do with checking for not null. - David > > Diwa From Jarmo.P at gmail.com Mon May 25 15:28:30 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Mon, 25 May 2009 12:28:30 -0700 (PDT) Subject: [rspec-users] [rspec] http://rspec.info examples are broken Message-ID: <05d51392-494b-4bd9-8a8a-c5a2a670dac5@o18g2000yqi.googlegroups.com> It seems that some examples at http://rspec.info are broken with invalid html. For example: http://rspec.info/documentation/before_and_after.html All those spans there should not be visible, I think :) Isn't rspec.info web tested well enough? :P Best regards, Jarmo From aslak.hellesoy at gmail.com Mon May 25 15:43:28 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 25 May 2009 21:43:28 +0200 Subject: [rspec-users] [rspec] http://rspec.info examples are broken In-Reply-To: <05d51392-494b-4bd9-8a8a-c5a2a670dac5@o18g2000yqi.googlegroups.com> References: <05d51392-494b-4bd9-8a8a-c5a2a670dac5@o18g2000yqi.googlegroups.com> Message-ID: <8d961d900905251243n5b2c74c3ga7121695c9ff8e9a@mail.gmail.com> > It seems that some examples at http://rspec.info are broken with > invalid html. > > For example: http://rspec.info/documentation/before_and_after.html > I assume you're referring to: http://validator.w3.org/check?uri=http%3A%2F%2Frspec.info%2Fdocumentation%2Fbefore_and_after.html&charset=(detect+automatically)&doctype=Inline&group=0 > All those spans there should not be visible, I think :) Isn't > rspec.info web tested well enough? :P > It's not tested at all. Any suggestions about how to improve it? Aslak > Best regards, > Jarmo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon May 25 22:06:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 May 2009 22:06:54 -0400 Subject: [rspec-users] [rspec] http://rspec.info examples are broken In-Reply-To: <8d961d900905251243n5b2c74c3ga7121695c9ff8e9a@mail.gmail.com> References: <05d51392-494b-4bd9-8a8a-c5a2a670dac5@o18g2000yqi.googlegroups.com> <8d961d900905251243n5b2c74c3ga7121695c9ff8e9a@mail.gmail.com> Message-ID: <57c63afe0905251906q49210df5mbd0ce0c0d4aace00@mail.gmail.com> On Mon, May 25, 2009 at 3:43 PM, aslak hellesoy wrote: >> It seems that some examples at http://rspec.info are broken with >> invalid html. >> >> For example: http://rspec.info/documentation/before_and_after.html >> > > I assume you're referring to: > http://validator.w3.org/check?uri=http%3A%2F%2Frspec.info%2Fdocumentation%2Fbefore_and_after.html&charset=(detect+automatically)&doctype=Inline&group=0 > >> All those spans there should not be visible, I think :) Isn't >> rspec.info web tested well enough? :P >> > > It's not tested at all. Any suggestions about how to improve it? I think the reason it's broken is because we generated the website using webby, which depends on something that depends on something that depends on something that I upgraded and it broke the website generation. The website will soon be replaced, so I'm not really interested in spending time improving what's there now. > > Aslak > >> Best regards, >> Jarmo >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From diwakar at angleritech.com Tue May 26 03:18:58 2009 From: diwakar at angleritech.com (Diwakar, ANGLER - EIT) Date: Tue, 26 May 2009 12:48:58 +0530 Subject: [rspec-users] spec for not null In-Reply-To: <57c63afe0905250627y30ce11bbo377b2de5c6553d4a@mail.gmail.com> References: <09CAF7492BB188429DDFABCD8218F283013F6522@awww.armis.com> <57c63afe0905250627y30ce11bbo377b2de5c6553d4a@mail.gmail.com> Message-ID: <09CAF7492BB188429DDFABCD8218F283013F675E@awww.armis.com> Thank you David it works -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky Sent: Monday, May 25, 2009 6:57 PM To: rspec-users Subject: Re: [rspec-users] spec for not null On Mon, May 25, 2009 at 6:51 AM, Diwakar, ANGLER - EIT wrote: > how should we check not null in rspec > > ???????? user_valid = @user.valid? > ??????? password_credential_valid = @password.valid? > > > ???I am getting the below error > > ??? Mock 'User_1001' received unexpected message :valid? with (no > args) Assuming that @user is the same mock object that is causing the error, you need to tell the @user that it should receive valid?: @user.should_receive(:valid?).and_return(true) I'm not sure what this has to do with checking for not null. - David > > Diwa _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue May 26 09:53:01 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 May 2009 09:53:01 -0400 Subject: [rspec-users] get_via_redirect in controller specs In-Reply-To: <88fd8ddc0905260642y68ec69fbw6185cd84db8a834a@mail.gmail.com> References: <88fd8ddc0905260642y68ec69fbw6185cd84db8a834a@mail.gmail.com> Message-ID: <57c63afe0905260653k75a0d173oe708d6d025627762@mail.gmail.com> On Tue, May 26, 2009 at 9:42 AM, Andrew Premdas wrote: > Want to do the following in my controller spec > describe CheckoutController, "handling stale session" do > > ??before do > ?? session[:order_id] = 5 > ?? Order.delete_all > ?end > > ?it "should not throw a 404" do > ?? get_via_direct?:index > ?end > Getting the following error message, > NoMethodError in 'CheckoutController handling stale session should not throw > a 404' > undefined method `get_via_redirect' for > # > > not sure why I can call 'get' and 'put' but can't call this method get_via_direct is available in ActionController::IntegrationTest, not ActionController::TestCase, which is what is wrapped by controller specs. HTH, David > > > Rails 2.3.2 > RSpec 1.2.6 > TIA > Andrew > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jona.hunt777 at gmail.com Tue May 26 10:32:20 2009 From: jona.hunt777 at gmail.com (Hunt Jon) Date: Tue, 26 May 2009 23:32:20 +0900 Subject: [rspec-users] How to spec two lines in application_controller.rb Message-ID: <5e1f1f1f0905260732o70964da1u9defa9eb42343547@mail.gmail.com> I need to spec the following lines: helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryProtection for detail Can anybody give me a hint? I create "application_controller_spec.rb" and now what? Jon From andrew at andrewtimberlake.com Tue May 26 11:14:56 2009 From: andrew at andrewtimberlake.com (Andrew Timberlake) Date: Tue, 26 May 2009 17:14:56 +0200 Subject: [rspec-users] How to spec two lines in application_controller.rb In-Reply-To: <5e1f1f1f0905260732o70964da1u9defa9eb42343547@mail.gmail.com> References: <5e1f1f1f0905260732o70964da1u9defa9eb42343547@mail.gmail.com> Message-ID: <62ad3e390905260814l186473ke71dd7bb04752d2@mail.gmail.com> On Tue, May 26, 2009 at 4:32 PM, Hunt Jon wrote: > I need to spec the following lines: > > ?helper :all # include all helpers, all the time > ?protect_from_forgery # See > ActionController::RequestForgeryProtection for detail > > Can anybody give me a hint? > > I create "application_controller_spec.rb" and now what? > > Jon You shouldn't need to spec those two lines specifically. What you want to do is spec the behaviour. So if you want a particular helper method to be available, write a spec that relies on that helper method (in another controller because they all use ApplicationController). If you then take out helper :all, your spec may fail (don't know, never tried) If it doesn't, well then you don't need the line :-) For protect_from_forgery, again spec the behaviour you expect (again, in a different controller spec) If you take out the line and your code still works, you don't need the line. If you take it out and the spec breaks, you know you've tested the behaviour you want, and not a line! I never spec either of these lines because their behaviour is tested in the Rails code. I am only concerned with testing my applications and the behaviour I want out of them. As an aside, if you're concerned about code coverage, both lines should execute with every controller test as they must execute while creating the ApplicationController class. Regards Andrew Timberlake http://ramblingsonrails.com http://MyMvelope.com - The SIMPLE way to manage your savings From lists at ruby-forum.com Tue May 26 12:52:00 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Tue, 26 May 2009 18:52:00 +0200 Subject: [rspec-users] How to spec two lines in application_controller.rb In-Reply-To: <5e1f1f1f0905260732o70964da1u9defa9eb42343547@mail.gmail.com> References: <5e1f1f1f0905260732o70964da1u9defa9eb42343547@mail.gmail.com> Message-ID: Hunt Jon wrote: > I need to spec the following lines: No you don't. They are thoroughly tested in the Rails framework and you didn't add any behavior to them, so reading them makes it immediately clear what they are doing. Don't worry without specing these 2 lines you'll still get your 100% coverage. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue May 26 13:32:44 2009 From: lists at ruby-forum.com (Ben Johnson) Date: Tue, 26 May 2009 19:32:44 +0200 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <3c30da400905261022t1839a207m5824fad50b73a846@mail.gmail.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <49CF1F6E.7080905@railsnewbie.com> <7a9e7cb7-5bc3-499e-9986-36cb6e4a8e69@j9g2000prh.googlegroups.com> <49CF3411.9040409@railsnewbie.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> <4A18D839.6030709@benmabey.com> <4A1913CE.4070409@railsnewbie.com> <4A1A29D3.9020102@benmabey.com> <3c30da400905261022t1839a207m5824fad50b73a846@mail.gmail.com> Message-ID: <5e62f6f34e444a8e7267736994822cd8@ruby-forum.com> Mark Wilden wrote: > On Sun, May 24, 2009 at 10:17 PM, Ben Mabey wrote: > Spork seems to have the same problem that I have with spec_server: it > doesn't reload classes I change. So if I'm doing TDD between a model and > its > spec, it doesn't help. > > ///ark I have the same problem. I like spork, but I had to restart the spork server anytime I made a change to a model file. The only way I know how to avoid this is to not proload the rails env, which kind of defeats the purpose. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Tue May 26 14:31:44 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 26 May 2009 12:31:44 -0600 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <1EC5DB58-E684-45F5-B57D-1982DBA6D4EE@railsnewbie.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> <4A18D839.6030709@benmabey.com> <4A1913CE.4070409@railsnewbie.com> <4A1A29D3.9020102@benmabey.com> <3c30da400905261022t1839a207m5824fad50b73a846@mail.gmail.com> <1EC5DB58-E684-45F5-B57D-1982DBA6D4EE@railsnewbie.com> Message-ID: <4A1C3590.9050405@benmabey.com> Scott Taylor wrote: > > On May 26, 2009, at 1:22 PM, Mark Wilden wrote: > >> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey > > wrote: >> >> >> Well, so Spork was really created with testing in mind. It is >> more general purpose than spec_server though. You can use it >> with any Ruby project, not just Rails. You can also potentially >> use it with any other testing framework that adds support for it >> (I've been meaning to do this for Cucumber). I know that Tim's >> original work with Kernel.fork was actually dealing with Mongrel >> but I'm not sure what the exact details of it are. I'll try to >> find out for you though. >> >> >> Spork seems to have the same problem that I have with spec_server: it >> doesn't reload classes I change. So if I'm doing TDD between a model >> and its spec, it doesn't help. > > I noticed the same thing. It must be a bug in spork, correct? > > Scott What does your spec_helper look like? It should be something like: require 'rubygems' require 'spork' Spork.prefork do ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") # Load other stuff that only needs to be setup once and never reloaded (i.e. rspec and configuring it) end Spork.each_run do ActiveRecord::Base.establish_connection # make sure that the db connection is ready. require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") # You could use FixtureReplacement, FactorGirl, etc... Spec::Runner.configure do |config| config.include Fixjour include SharedSpecHelpers include DatabaseHelpers include AuthenticatedTestHelper end end Keep in mind that the code in Spork.prefork must not require any of your models inadvertently. If your environment file does this or a plugin does then your models will not be reloaded. Look over your spec_helper file and try to see who is requiring your models initially. We have really only tested this on is our apps where Tim and I work... So, there could very well be bugs we need to iron out. -Ben From scott at railsnewbie.com Tue May 26 14:46:49 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 26 May 2009 14:46:49 -0400 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <4A1C3590.9050405@benmabey.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> <4A18D839.6030709@benmabey.com> <4A1913CE.4070409@railsnewbie.com> <4A1A29D3.9020102@benmabey.com> <3c30da400905261022t1839a207m5824fad50b73a846@mail.gmail.com> <1EC5DB58-E684-45F5-B57D-1982DBA6D4EE@railsnewbie.com> <4A1C3590.9050405@benmabey.com> Message-ID: <64C42AE5-F727-46BA-B5C2-D837AEB5A968@railsnewbie.com> On May 26, 2009, at 2:31 PM, Ben Mabey wrote: > Scott Taylor wrote: >> >> On May 26, 2009, at 1:22 PM, Mark Wilden wrote: >> >>> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey >> >> wrote: >>> >>> >>> Well, so Spork was really created with testing in mind. It is >>> more general purpose than spec_server though. You can use it >>> with any Ruby project, not just Rails. You can also potentially >>> use it with any other testing framework that adds support for it >>> (I've been meaning to do this for Cucumber). I know that Tim's >>> original work with Kernel.fork was actually dealing with Mongrel >>> but I'm not sure what the exact details of it are. I'll try to >>> find out for you though. >>> >>> >>> Spork seems to have the same problem that I have with spec_server: >>> it doesn't reload classes I change. So if I'm doing TDD between a >>> model and its spec, it doesn't help. >> >> I noticed the same thing. It must be a bug in spork, correct? >> >> Scott > > What does your spec_helper look like? > > It should be something like: > > require 'rubygems' > require 'spork' > > Spork.prefork do > ENV["RAILS_ENV"] = "test" > require File.expand_path(File.dirname(__FILE__) + "/../config/ > environment") > # Load other stuff that only needs to be setup once and never > reloaded (i.e. rspec and configuring it) > end > > Spork.each_run do > ActiveRecord::Base.establish_connection # make sure that the db > connection is ready. > require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") # > You could use FixtureReplacement, FactorGirl, etc... > Spec::Runner.configure do |config| > config.include Fixjour > include SharedSpecHelpers > include DatabaseHelpers > include AuthenticatedTestHelper > end > end > > > > Keep in mind that the code in Spork.prefork must not require any of > your models inadvertently. If your environment file does this or a > plugin does then your models will not be reloaded. Look over your > spec_helper file and try to see who is requiring your models > initially. We have really only tested this on is our apps where Tim > and I work... So, there could very well be bugs we need to iron out. Sweet! Seems to be working great now. Looks like the README has changed over the weekend - previously, I had been starting the spec server with script/spec_server. Running spork directly seems to work just fine. Thanks a TON! Scott From ben at benmabey.com Tue May 26 15:06:40 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 26 May 2009 13:06:40 -0600 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <64C42AE5-F727-46BA-B5C2-D837AEB5A968@railsnewbie.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> <4A18D839.6030709@benmabey.com> <4A1913CE.4070409@railsnewbie.com> <4A1A29D3.9020102@benmabey.com> <3c30da400905261022t1839a207m5824fad50b73a846@mail.gmail.com> <1EC5DB58-E684-45F5-B57D-1982DBA6D4EE@railsnewbie.com> <4A1C3590.9050405@benmabey.com> <64C42AE5-F727-46BA-B5C2-D837AEB5A968@railsnewbie.com> Message-ID: <4A1C3DC0.4030404@benmabey.com> Scott Taylor wrote: > > On May 26, 2009, at 2:31 PM, Ben Mabey wrote: > >> Scott Taylor wrote: >>> >>> On May 26, 2009, at 1:22 PM, Mark Wilden wrote: >>> >>>> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey >>> > wrote: >>>> >>>> >>>> Well, so Spork was really created with testing in mind. It is >>>> more general purpose than spec_server though. You can use it >>>> with any Ruby project, not just Rails. You can also potentially >>>> use it with any other testing framework that adds support for it >>>> (I've been meaning to do this for Cucumber). I know that Tim's >>>> original work with Kernel.fork was actually dealing with Mongrel >>>> but I'm not sure what the exact details of it are. I'll try to >>>> find out for you though. >>>> >>>> >>>> Spork seems to have the same problem that I have with spec_server: >>>> it doesn't reload classes I change. So if I'm doing TDD between a >>>> model and its spec, it doesn't help. >>> >>> I noticed the same thing. It must be a bug in spork, correct? >>> >>> Scott >> >> What does your spec_helper look like? >> >> It should be something like: >> >> require 'rubygems' >> require 'spork' >> >> Spork.prefork do >> ENV["RAILS_ENV"] = "test" >> require File.expand_path(File.dirname(__FILE__) + >> "/../config/environment") >> # Load other stuff that only needs to be setup once and never >> reloaded (i.e. rspec and configuring it) >> end >> >> Spork.each_run do >> ActiveRecord::Base.establish_connection # make sure that the db >> connection is ready. >> require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") # >> You could use FixtureReplacement, FactorGirl, etc... >> Spec::Runner.configure do |config| >> config.include Fixjour >> include SharedSpecHelpers >> include DatabaseHelpers >> include AuthenticatedTestHelper >> end >> end >> >> >> >> Keep in mind that the code in Spork.prefork must not require any of >> your models inadvertently. If your environment file does this or a >> plugin does then your models will not be reloaded. Look over your >> spec_helper file and try to see who is requiring your models >> initially. We have really only tested this on is our apps where Tim >> and I work... So, there could very well be bugs we need to iron out. > > Sweet! Seems to be working great now. > > Looks like the README has changed over the weekend - previously, I had > been starting the spec server with script/spec_server. Running spork > directly seems to work just fine. > > Thanks a TON! > > Scott > Ok cool. Seems like the bug may of been poor documentation... please send a pull request if you think it can be improved. :) -Ben From scott at railsnewbie.com Tue May 26 15:10:18 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 26 May 2009 15:10:18 -0400 Subject: [rspec-users] spec_server errors when reloading fixture replacement pl In-Reply-To: <4A1C3DC0.4030404@benmabey.com> References: <1106da77-505a-4262-b9df-a67c9af6027b@w35g2000prg.googlegroups.com> <4eab1d15-ce00-4992-a81a-9fdcc9d02eb0@z16g2000prd.googlegroups.com> <57c63afe0905010704r254bab7bn5ac3d32b8027672f@mail.gmail.com> <4A173837.7090605@railsnewbie.com> <4A18D839.6030709@benmabey.com> <4A1913CE.4070409@railsnewbie.com> <4A1A29D3.9020102@benmabey.com> <3c30da400905261022t1839a207m5824fad50b73a846@mail.gmail.com> <1EC5DB58-E684-45F5-B57D-1982DBA6D4EE@railsnewbie.com> <4A1C3590.9050405@benmabey.com> <64C42AE5-F727-46BA-B5C2-D837AEB5A968@railsnewbie.com> <4A1C3DC0.4030404@benmabey.com> Message-ID: <72E98D75-3D93-4566-BC3C-CE38D95AE073@railsnewbie.com> On May 26, 2009, at 3:06 PM, Ben Mabey wrote: > Scott Taylor wrote: >> >> On May 26, 2009, at 2:31 PM, Ben Mabey wrote: >> >>> Scott Taylor wrote: >>>> >>>> On May 26, 2009, at 1:22 PM, Mark Wilden wrote: >>>> >>>>> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey >>>> >> wrote: >>>>> >>>>> >>>>> Well, so Spork was really created with testing in mind. It is >>>>> more general purpose than spec_server though. You can use it >>>>> with any Ruby project, not just Rails. You can also potentially >>>>> use it with any other testing framework that adds support for it >>>>> (I've been meaning to do this for Cucumber). I know that Tim's >>>>> original work with Kernel.fork was actually dealing with Mongrel >>>>> but I'm not sure what the exact details of it are. I'll try to >>>>> find out for you though. >>>>> >>>>> >>>>> Spork seems to have the same problem that I have with >>>>> spec_server: it doesn't reload classes I change. So if I'm doing >>>>> TDD between a model and its spec, it doesn't help. >>>> >>>> I noticed the same thing. It must be a bug in spork, correct? >>>> >>>> Scott >>> >>> What does your spec_helper look like? >>> >>> It should be something like: >>> >>> require 'rubygems' >>> require 'spork' >>> >>> Spork.prefork do >>> ENV["RAILS_ENV"] = "test" >>> require File.expand_path(File.dirname(__FILE__) + "/../config/ >>> environment") >>> # Load other stuff that only needs to be setup once and never >>> reloaded (i.e. rspec and configuring it) >>> end >>> >>> Spork.each_run do >>> ActiveRecord::Base.establish_connection # make sure that the db >>> connection is ready. >>> require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") >>> # You could use FixtureReplacement, FactorGirl, etc... >>> Spec::Runner.configure do |config| >>> config.include Fixjour >>> include SharedSpecHelpers >>> include DatabaseHelpers >>> include AuthenticatedTestHelper >>> end >>> end >>> >>> >>> >>> Keep in mind that the code in Spork.prefork must not require any >>> of your models inadvertently. If your environment file does this >>> or a plugin does then your models will not be reloaded. Look over >>> your spec_helper file and try to see who is requiring your models >>> initially. We have really only tested this on is our apps where >>> Tim and I work... So, there could very well be bugs we need to >>> iron out. >> >> Sweet! Seems to be working great now. >> >> Looks like the README has changed over the weekend - previously, I >> had been starting the spec server with script/spec_server. Running >> spork directly seems to work just fine. >> >> Thanks a TON! >> >> Scott >> > > > Ok cool. Seems like the bug may of been poor documentation... > please send a pull request if you think it can be improved. :) BTW: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets Scott From glin at employees.org Tue May 26 19:33:20 2009 From: glin at employees.org (Gary Lin) Date: Tue, 26 May 2009 16:33:20 -0700 Subject: [rspec-users] Any way to continue on Assertion Failure Message-ID: <4A1C7C40.2020501@employees.org> Hi, I wonder if there is any way to tell the test script to continue even when encountering an assertion failure? The reason I am asking this is because I have a test flow that can take a long time to run and it would be very useful if I can perform all verification at the end of test flow in one shot rather than fail one and exit immediately. Of course, I could break each verification point into separate test case, but then it will double or triple the overall execution time. Does RSpec support this? Thanks, --Gary From dchelimsky at gmail.com Tue May 26 19:58:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 May 2009 19:58:09 -0400 Subject: [rspec-users] Any way to continue on Assertion Failure In-Reply-To: <4A1C7C40.2020501@employees.org> References: <4A1C7C40.2020501@employees.org> Message-ID: <57c63afe0905261658i3b3d7a0fwd2b9bf41c62be859@mail.gmail.com> On Tue, May 26, 2009 at 7:33 PM, Gary Lin wrote: > Hi, > > I wonder if there is any way to tell the test script to continue even when > encountering an assertion failure? ?The reason I am asking this is because I > have a test flow that can take a long time to run and it would be very > useful if I can perform all verification at the end of test flow in one shot > rather than fail one and exit immediately. ?Of course, I could break each > verification point into separate test case, but then it will double or > triple the overall execution time. ?Does RSpec support this? Nope. RSpec is all about isolated examples of small bits of behaviour. > > Thanks, > > --Gary > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue May 26 20:14:51 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 May 2009 20:14:51 -0400 Subject: [rspec-users] Any way to continue on Assertion Failure In-Reply-To: <57c63afe0905261658i3b3d7a0fwd2b9bf41c62be859@mail.gmail.com> References: <4A1C7C40.2020501@employees.org> <57c63afe0905261658i3b3d7a0fwd2b9bf41c62be859@mail.gmail.com> Message-ID: <57c63afe0905261714v6be300c7q45386b93012c817a@mail.gmail.com> On Tue, May 26, 2009 at 7:58 PM, David Chelimsky wrote: > On Tue, May 26, 2009 at 7:33 PM, Gary Lin wrote: >> Hi, >> >> I wonder if there is any way to tell the test script to continue even when >> encountering an assertion failure? ?The reason I am asking this is because I >> have a test flow that can take a long time to run and it would be very >> useful if I can perform all verification at the end of test flow in one shot >> rather than fail one and exit immediately. ?Of course, I could break each >> verification point into separate test case, but then it will double or >> triple the overall execution time. ?Does RSpec support this? > > Nope. RSpec is all about isolated examples of small bits of behaviour. I don't mean there is no way to do it, btw. Just that RSpec doesn't offer a way out of the box. Each example is, essentially, run in a begin/rescue block. RSpec expectation matchers raise errors on failure. To get what you're after, you *could* write some sort of wrapper like this: def report_later(&block) begin yield rescue Exception => e # report the error somewhere but don't raise end end describe Something do it "should do something" do report_later do # example code with expectations go here end end end If you do this, though, you're really working against the intent of RSpec. The trick about having a series of expectations within one example is that if one fails early, you can't really trust the state of everything that comes after. This is one reason why RSpec is designed the way it is - to focus on one expectation in each example. HTH, David > >> >> Thanks, >> >> --Gary From julian at leviston.net Tue May 26 22:38:30 2009 From: julian at leviston.net (Julian Leviston) Date: Wed, 27 May 2009 12:38:30 +1000 Subject: [rspec-users] Any way to continue on Assertion Failure In-Reply-To: <4A1C7C40.2020501@employees.org> References: <4A1C7C40.2020501@employees.org> Message-ID: <6747A39A-4B9D-455C-B6DB-92814A906AA8@leviston.net> On 27/05/2009, at 9:33 AM, Gary Lin wrote: > Hi, > > I wonder if there is any way to tell the test script to continue > even when encountering an assertion failure? The reason I am asking > this is because I have a test flow that can take a long time to run > and it would be very useful if I can perform all verification at the > end of test flow in one shot rather than fail one and exit > immediately. Of course, I could break each verification point into > separate test case, but then it will double or triple the overall > execution time. Does RSpec support this? > Isn't this usual behaviour? Julian. ---------------------------------------------- Learn: http://sensei.zenunit.com/ Last updated 20-May-09 (Rails, Basic Unix) Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r > Thanks, > > --Gary > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue May 26 23:35:40 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 May 2009 23:35:40 -0400 Subject: [rspec-users] passing param values In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013A14D3@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013A1484@awww.armis.com> <57c63afe0905220349p5b17d7bdwfad664428ab23724@mail.gmail.com> <09CAF7492BB188429DDFABCD8218F283013A14D3@awww.armis.com> Message-ID: <57c63afe0905262035i1f24a8aev6b44da7cf9a11bd7@mail.gmail.com> On Fri, May 22, 2009 at 7:29 AM, Diwakar, ANGLER - EIT wrote: > > Still I am getting the same error > > describe UsersController do > > ?describe :create ? ? ? do > ?before(:each) ?do > ? ?controller.stub!(:require_user).and_return(@user) > ? ?controller.stub!(:uses_mailer).and_return(@user) > ? ?User.stub!(:new).and_return(@user) > ? ? post :create,{:terms_and_conditions => "1",:promotional_mailings => "0",:email_address => "raja at test.com"},:user => {} > ?end > ?it "should create a new user object" do > ? ? ?User.should_receive(:new).with({"terms_and_conditions" => "1","promotional_mailings" => "0","email_address" => "raja at test.com"}).and_return(@user) > ? ? ?post :create,{:terms_and_conditions => "1",:promotional_mailings => "0",:email_address => "raja at test.com"},:user => {} > ?end > ?end > end > > Error > > Spec::Mocks::MockExpectationError in 'UsersController create should create a new > ?user object' > etime, accessed_on: datetime, email_address: string, name_first: string, name_la > st: string, mailing_address_id: integer, billing_address_id: integer, name_displ > ay: string, picture_id: integer, url: string, country: string, freelance: boolea > n, statement: string, hostname_active: boolean, hostname: string, promotional_ma > ilings: boolean, sales_commission_rate: float, referral_commission_rate: float, > employee_lock: boolean) (class)> expected :new with ({"terms_and_conditions"=>"1 > ", "promotional_mailings"=>"0", "email_address"=>"raja at test.com"}) once, but rec > eived it 0 times Please show us the controller code. > > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Friday, May 22, 2009 4:19 PM > To: rspec-users > Subject: Re: [rspec-users] passing param values > > On Fri, May 22, 2009 at 4:34 AM, Diwakar, ANGLER - EIT wrote: >> My controller spec is like below >> >> describe UsersController do >> >> ?describe " create action"?do >> ? before(:each)? do >> ??? @user = mock_model(User,:user => "value") > > #don't need to set the user in this > @user = mock_model(User) > >> ??? controller.stub!(:require_user).and_return(@user) >> ??? controller.stub!(:uses_mailer).and_return(@user) >> ??? User.stub!(:new).and_return(@user) >> ? end >> ? it "should create a new user object" do >> ????? User.should_receive(:new).with(:user=>"value").and_return(@user) > > #use 'user' instead of :user because Rails converts the keys User.should_receive(:new).with('user' => 'value').and_return(@user) > >> ????? post :create,:user => "value" >> ? end >> ?end >> end >> >> Error: >> >> > dat >> etime, accessed_on: datetime, email_address: string, name_first: >> string, name_la >> st: string, mailing_address_id: integer, billing_address_id: integer, >> name_displ >> ay: string, picture_id: integer, url: string, country: string, freelance: >> boolea >> n, statement: string, hostname_active: boolean, hostname: string, >> promotional_ma >> ilings: boolean, sales_commission_rate: float, referral_commission_rate: >> float, >> employee_lock: boolean) (class)> expected :new with ({:user=>"value"}) >> once, but >> ?received it 0 times >> >> How should I pass the params? >> >> >> Diwa >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue May 26 23:39:22 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 May 2009 23:39:22 -0400 Subject: [rspec-users] How do I get additional information from the Matcher? In-Reply-To: <4A14850E.3030406@employees.org> References: <4A14850E.3030406@employees.org> Message-ID: <57c63afe0905262039o7f31ec66u7a9dc6b802056f48@mail.gmail.com> On Wed, May 20, 2009 at 6:32 PM, Gary Lin wrote: > Hi, > > I am trying to implement my own matcher which use a special algorithm to do > the semantics diff-ing between two proprietary configuration file. ?When > come to the report, I would like my formatter to be able to have access to > the original configuration file content as well as the diff-ing result. ?By > digging through the code, looks like all formatter can get is an > ExpectationNotMetError with a string-based message embedded inside. ?How do > I make the matcher pass additional information to my formatter? ?I see there > is a class level variable called ::Spec::Matchers.last_matcher which allows > me to access the last matcher. ?Is that the right away to implement this? > ?Or if there is any better way for me to add additional information into the > ExpectationNotMetError exception? There's nothing built in. If you have any recommendations as to how this should work, please feel free to file a feature request at http://rspec.lighthouseapp.com. Thanks, David > > Thanks, > > --Gary > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Wed May 27 04:07:51 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 May 2009 09:07:51 +0100 Subject: [rspec-users] Any way to continue on Assertion Failure In-Reply-To: <6747A39A-4B9D-455C-B6DB-92814A906AA8@leviston.net> References: <4A1C7C40.2020501@employees.org> <6747A39A-4B9D-455C-B6DB-92814A906AA8@leviston.net> Message-ID: <294057C5-CACC-4DE2-BDD2-C8C134A9977F@mattwynne.net> On 27 May 2009, at 03:38, Julian Leviston wrote: > On 27/05/2009, at 9:33 AM, Gary Lin wrote: > >> Hi, >> >> I wonder if there is any way to tell the test script to continue >> even when encountering an assertion failure? The reason I am >> asking this is because I have a test flow that can take a long time >> to run and it would be very useful if I can perform all >> verification at the end of test flow in one shot rather than fail >> one and exit immediately. Of course, I could break each >> verification point into separate test case, but then it will double >> or triple the overall execution time. Does RSpec support this? >> > > Isn't this usual behaviour? > > Julian. Yeah I'm a little confused by the question (and David's response) so maybe I've misunderstood something. Normal RSpec test runs will catch all the test failures and report them at the end of the run. I wonder whether the OP is talking about a situation where the interaction with the system takes a long time, so that using lots of examples of the desired behaviour causes that interaction to be run several times making the whole run very slow. I also wonder whether he's just thinking in the test/unit mindset, which I see a lot, where you have examples like this it "should do foo and bar" do set_up_state do_something_to_system_under_test assert_that_foo_was_done assert_that_bar_was_done end Here's my normal RSpec flow: before(:each) do set_up_state do_something_to_system_under_test end it "should have done foo" do assert_that_foo_was_done end it "should have done bar" do assert_that_bar_was_done end if set_up_state and/or do_something_to_system_under_test take ages, you could use a before(:all) block instead, but that comes with obvious leaky state disadvantages. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From dchelimsky at gmail.com Wed May 27 04:17:34 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 04:17:34 -0400 Subject: [rspec-users] RSpec support on .Net with Gallio. In-Reply-To: <35B097ECF1D846F2AD8563D6F4D3869F@Atom> References: <35B097ECF1D846F2AD8563D6F4D3869F@Atom> Message-ID: <57c63afe0905270117w385172b4kdee201fb5e77ba05@mail.gmail.com> On Sat, May 16, 2009 at 7:09 PM, Jeff Brown wrote: > Hi, > I'm getting ready to produce an RSpec adapter for use with the Gallio test > automation platform (http://www.gallio.org/) on the .Net DLR via IronRuby. > > The idea is to open up RSpec to a wider audience of .Net developers who > might like to write their tests, *ahem* specs ;-), using a friendly syntax > in a dynamically typed language such as Ruby. > > Anyways, this is still a work in progress but I wanted to check on a couple > of legal points: > > 1. Is it cool to redistribute RSpec in source code form for non-commercial > purposes? ?I was unable to find the RSpec license to confirm. ?Gallio itself > is open source and is distributed using the Apache License 2.0. > > 2. I would like to be able to identify the RSpec framework by way of an icon > in Gallio. ?Unfortunately I was unable to locate an official logo. ?Assuming > there is one, I'd like permission to include an RSpec icon in Gallio. The > icon will be used in the following ways: > > - As a plugin icon when displaying a list of associated plugins. > - As a preference icon when providing options for configuring associated > plugins. > - As an installed feature icon when providing options for installing > associated plugins. > - As a test framework icon when decribing the list of supported test > frameworks and when presenting a report about tests that have been run > specifically using that framework. > > Do you have a suitable 16x16 and 32x32 icon file that I can use for this > purpose? There is not an official icon now, but there will be within the next month or so. What is your time frame for releasing this adapter? Cheers, David > > Thanks, > Jeff. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 27 04:23:55 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 04:23:55 -0400 Subject: [rspec-users] Problem with testing Rails action that uses return keyword In-Reply-To: <245e6fe5-9449-458a-97df-fb9174940b83@n8g2000vbb.googlegroups.com> References: <245e6fe5-9449-458a-97df-fb9174940b83@n8g2000vbb.googlegroups.com> Message-ID: <57c63afe0905270123n4b05c806ga2f0272141d61e61@mail.gmail.com> On Tue, May 19, 2009 at 5:13 PM, szimek wrote: > Hi, > > I'm trying to test Rails action that looks like this: > > def create > ?unless facebook_session > ? ?authentication_failed and return > ?end > ?... > ?@facebook_user = facebook_session.user > ?... > end > > authentication_failed method redirects to '/'. > > The test looks like this: > > it 'should call authentication_failed' do > ?controller.should_receive(:authentication_failed) > ?get :create If you're using facebooker, you should use facebook_get instead of get: facebook_get :create Also - shouldn't this be a post? > end > > The problem is that in the test, despite the fact that > facebook_session is nil and the authentication_failed method is > called, the action does not return and I got error in > facebook_session.user line, because facebook_session is nil. > > If I move the return keyword to the next line, the test complains then > about missing create.erb template. > > Any ideas how to solve it? From dchelimsky at gmail.com Wed May 27 04:26:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 04:26:02 -0400 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: References: Message-ID: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> On Fri, May 1, 2009 at 12:26 PM, Matt Wynne wrote: > I'm creating a class in my spec file to test out a module, but when I run > the spec a second time in spec_server, I get the error above. > > I presume this is because rails is un-loading the class, and it's not > getting re-loaded properly as it doesn't have its own file in the > conventional place. > > Does anyone have a nice workaround for this? Judging from the silence, I think the answer is no. There is some interesting stuff going on in other threads about spork. Don't know if it solves this for you, but you may want to give it a whirl. > > cheers, > Matt Wynne > http://beta.songkick.com > http://blog.mattwynne.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 27 04:28:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 04:28:42 -0400 Subject: [rspec-users] Fixture::FormatError parsing YAML In-Reply-To: <214291c9-497c-4713-80ef-a44f2f3629da@f16g2000vbf.googlegroups.com> References: <57c63afe0905181216t69d5f4f9u96d0f2c5e922f98@mail.gmail.com> <214291c9-497c-4713-80ef-a44f2f3629da@f16g2000vbf.googlegroups.com> Message-ID: <57c63afe0905270128r57d05ff1ife2fec72b3d025ef@mail.gmail.com> On Mon, May 18, 2009 at 3:50 PM, WJSimacek wrote: > > > On May 18, 2:16?pm, David Chelimsky wrote: >> On Mon, May 18, 2009 at 10:31 AM, WJSimacek wrote: >> > Hi, >> > ? ?I'm trying to test restful_authentication plugin and am getting >> > errors with my install. >> > ? ? ?==>I've been through the YAML specification and actually copied >> > the fixture file into word looking for tabs instead of spaces. I've >> > played with various parts of the formatting, but I need a fresh pair >> > of eyes on this one. >> >> > ?1) Error: >> > test_the_truth(PostTest): >> > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ >> > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note >> > that YAML must be consistently indented using spaces. Tabs are not >> > allowed. Please have a look athttp://www.yaml.org/faq.html >> > The exact error was: >> > ?NameError: undefined local variable or method `options' for >> > main:Object >> >> What line/file is this last bit happening on? I wonder if the YML >> problem is a red herring. >> > I'm not sure how to answer your question? Is there a way I can re-run > the specific test with a --trace option to have something more to send > you? --Wayne [p.s. --this is just one of several YAML parsing errors > I'm getting. If it is a red herring....it's a Whopper! Unfortunately you're using a combination of tools and platforms that I don't have any experience with. Anybody else using Aptana on Windows who can help debug this? > > Here's some related ones-- > ?1) Error: > test_should_create_post(PostsControllerTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object > > > ?2) Error: > test_should_destroy_post(PostsControllerTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object > > > ?3) Error: > test_should_get_edit(PostsControllerTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object > > > ?4) Error: > test_should_get_index(PostsControllerTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object > > > ?5) Error: > test_should_get_new(PostsControllerTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object > > > ?6) Error: > test_should_show_post(PostsControllerTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object > > > ?7) Error: > test_should_update_post(PostsControllerTest): > Fixture::FormatError: a YAML error occurred parsing C:/Users/Wayne/ > Documents/Aptana Studio/blog/test/fixtures/fixtures.yml. Please note > that YAML must be consistently indented using spaces. Tabs are not > allowed. Please have a look at http://www.yaml.org/faq.html > The exact error was: > ?NameError: undefined local variable or method `options' for > main:Object > > > ?8) Error: > test_should_delete_token_on_logout(SessionsControllerTest): > NoMethodError: undefined method `login_as' for > # > ? ?/test/functional/sessions_controller_test.rb:50:in > `test_should_delete_token_on_logout' > > ?9) Error: > test_should_fail_cookie_login(SessionsControllerTest): > NoMethodError: undefined method `users' for # 0x5fd7f00> > ? ?/test/functional/sessions_controller_test.rb:71:in > `test_should_fail_cookie_login' > > ?10) Error: > test_should_fail_expired_cookie_login(SessionsControllerTest): > NoMethodError: undefined method `users' for # 0x5fd7ed8> > ? ?/test/functional/sessions_controller_test.rb:63:in > `test_should_fail_expired_cookie_login' > > ?11) Error: > test_should_fail_login_and_not_redirect(SessionsControllerTest): > NoMethodError: undefined method `post' for # 0x5fd7eb0> > ? ?/test/functional/sessions_controller_test.rb:27:in > `test_should_fail_login_and_not_redirect' > > ?12) Error: > test_should_login_and_redirect(SessionsControllerTest): > NoMethodError: undefined method `post' for # 0x5fd7e88> > ? ?/test/functional/sessions_controller_test.rb:21:in > `test_should_login_and_redirect' > > ?13) Error: > test_should_login_with_cookie(SessionsControllerTest): > NoMethodError: undefined method `users' for # 0x5fd7e60> > ? ?/test/functional/sessions_controller_test.rb:56:in > `test_should_login_with_cookie' > > ?14) Error: > test_should_logout(SessionsControllerTest): > NoMethodError: undefined method `login_as' for > # > ? ?/test/functional/sessions_controller_test.rb:33:in > `test_should_logout' > > ?15) Error: > test_should_not_remember_me(SessionsControllerTest): > NoMethodError: undefined method `post' for # 0x5fd7e10> > ? ?/test/functional/sessions_controller_test.rb:45:in > `test_should_not_remember_me' > > ?16) Error: > test_should_remember_me(SessionsControllerTest): > NoMethodError: undefined method `post' for # 0x5fd7de8> > ? ?/test/functional/sessions_controller_test.rb:40:in > `test_should_remember_me' > > 16 tests, 0 assertions, 0 failures, 16 errors > > > > > >> >> >> >> >> > Here's the related fixtures.yml >> > quentin: >> > ?id: 1 >> > ?login: quentin >> > ?email: quen... at example.com >> > ?salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd >> > ?crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 >> > ?created_at: <%= 5.days.ago.to_s :db %> >> > <% if options[:include_activation] %> ?activation_code: >> > 8f24789ae988411ccf33ab0c30fe9106fab32e9b <% end %> >> > <% if options[:include_activation] %> ?activated_at: <%= >> > 5.days.ago.to_s :db %> <% end %> >> > <% if options[:stateful] %> ?state: active<% end %> >> > aaron: >> > ?id: 2 >> > ?login: aaron >> > ?email: aa... at example.com >> > ?salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd >> > ?crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 >> > ?created_at: <%= 1.days.ago.to_s :db %> >> > <% if options[:include_activation] %> ?activation_code: >> > 8f24789ae988411ccf33ab0c30fe9106fab32e9a <% end %> >> > <% if options[:stateful] %> ?state: pending<% end %> >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-us... at rubyforge.org >> >http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 27 04:31:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 04:31:59 -0400 Subject: [rspec-users] Including extra directories for Autospec In-Reply-To: <8d18f1f80905182254x3bd6920fief5ed45b1f614207@mail.gmail.com> References: <8d18f1f80905170945t6927777bn716e6f3111774186@mail.gmail.com> <57c63afe0905171431m7828bed4tddb95d11b6f84aec@mail.gmail.com> <8d18f1f80905171624y7a4d8716jbf322cf50ad82aa7@mail.gmail.com> <20090518185510.GN980@bumblebee.m38c.nl> <8d18f1f80905182254x3bd6920fief5ed45b1f614207@mail.gmail.com> Message-ID: <57c63afe0905270131t6adb5a18i87b2e78f9687667b@mail.gmail.com> Adam, that's not what Kero was asking about. In addition to the ./.autotest file, do you also have a ~/.autotest file? On Tue, May 19, 2009 at 1:54 AM, Adam Anderson wrote: > Yeah. I apologize that was a typo on my part. It should have said ./.autotest > > > -Adam > > On Mon, May 18, 2009 at 11:55 AM, Kero van Gelder wrote: >>> Then I edit the files like so: >>> >>> ./autotest: >>> Autotest.add_hook :initialize do |at| >>> ? at.add_mapping(%r%^spec/something/.*_spec\.rb$%) do >>> ? ? at.files_matching(%r%^spec/something/.*_spec\.rb$%) >>> ? end >>> end >> >> Do you perhaps have a ~/.autotest with a hook to :initialize ? >> If so, let it return nil, like this: >> >> Autotest.add_hook :initialize do |at| >> ?%w{.svn .hg .git}.each {|exception| >> ? ?at.add_exception(exception) >> ?} >> ?nil >> end >> >> >> It's documented, but a nasty default behaviour. >> >> Bye, >> Kero. >> >> ___ >> How can I change the world if I can't even change myself? >> ?-- Faithless, Salva Mea >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed May 27 04:38:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 04:38:25 -0400 Subject: [rspec-users] Options Hash explanation ? In-Reply-To: <41285f3b-e1d0-4330-bb7c-287e86b0fdb0@t10g2000vbg.googlegroups.com> References: <5087f5f1-c2c7-4b28-91b7-58f6af347971@l28g2000vba.googlegroups.com> <57c63afe0905122228m1ac62d1ei19a630de0e772027@mail.gmail.com> <41285f3b-e1d0-4330-bb7c-287e86b0fdb0@t10g2000vbg.googlegroups.com> Message-ID: <57c63afe0905270138i71303f60u2dd7de6fd918fc58@mail.gmail.com> On Wed, May 13, 2009 at 3:36 PM, mortench wrote: > On 13 Maj, 07:28, David Chelimsky wrote: >> You can access the group and example options from within an example: >> >> describe "group options hash", :defined_in => :group do >> ? it "is available in examples via self.class.options" do >> ? ? self.class.options[:defined_in].should == :group >> ? end >> end > > Yes, I got this to work too but not for nested describes as below: > > describe "group options hash", :defined_in => :group do > ? .. > ? describe "nested describe wont work" > ? ?it "is available in examples via self.class.options" do > ? ? self.class.options[:defined_in].should == :group # WONT work > ? ?end > ? end > > end > > BTW. I am actually accessing the hash from within a common helper > files in a before action setup by Spec::Runner.configure. Hence it is > important that accessing the Hash work regardless of how the describes > are nested. Just catching up on some old mail here - would you please add a feature request for this? http://rspec.lighthouseapp.com From dchelimsky at gmail.com Wed May 27 04:46:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 04:46:16 -0400 Subject: [rspec-users] modules and stub In-Reply-To: <94914cd0ea560718e5f8f391c480b5e6@ruby-forum.com> References: <258f844c2771c1285812dc1a17cb5080@ruby-forum.com> <57c63afe0905242052r318953fl208aa4dfd6f9a93@mail.gmail.com> <57c63afe0905242154y162e17a6td1e3658984bc1a3@mail.gmail.com> <94914cd0ea560718e5f8f391c480b5e6@ruby-forum.com> Message-ID: <57c63afe0905270146r68df1a29jb71ec72302d3e1e6@mail.gmail.com> On Mon, May 25, 2009 at 1:51 AM, Sarah Allen wrote: > David Chelimsky wrote: >> >> Foo::Bar.stub(:do_something) > > hmm. that's pretty close to where I started. > >> If you stub, for example, do_something on this module, but it turns >> out that do_something gets added to the module through some dynamic >> means *after the stub declaration*, the stub declaration will be >> overwritten and you'll get surprising results. This is not just true >> of globals - it's true of any methods that appear through the magic of >> metaprogramming. > > Ah, the joys of dynamic languages. ?After further looking at the code, I > see that the module 'require' is intentionally inside an if, so that it > will only get loaded as needed. ?If I explicitly require file containing > the module in the spec.rb file, then it works. ?I suppose the require in > the code I'm testing will only have an effect when it's not present in > the calling code. ?Still puzzled why I could call the module before > without getting a syntax error. By "before" do you mean in an earlier version of your app or of rspec? Or do you mean within the app somewhere? > > Thanks so much for your help. > > Sarah > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed May 27 05:20:00 2009 From: lists at ruby-forum.com (Smita Sreekanth) Date: Wed, 27 May 2009 11:20:00 +0200 Subject: [rspec-users] Cucmber Step to insert Test Data into Database Message-ID: <97a92377da4082454c7581a55c035cf9@ruby-forum.com> Hi, We run the feature created for a form to identify the fields and also to add data into the respective fields. But while running the cucumber features, all the scenario and steps are getting passed but the record is not getting inserted into the application / the database. We have also wrote the feature as: Feature: Adding a user In order to add a user to the organization As a administrator I want to create and add new user Scenario: Create User Given that I have no users And I am on the "List of users" When I follow "New User" And I fill in "First Name" with "Rebecca" And I fill in "Second Name" with "Martin" And I fill in "Title" with "Miss" And I fill in "Email" with "rebeccamartin at me.com" And I fill in "Telephone" with "01617867645" And I fill in "Mobile" with "01777867645" And I fill in "Fax" with "01617867640?" And I fill in "Address Line 1" with "58" And I fill in "Address Line 2" with "West Tree rd" And I fill in "Address Line 3" with "Stockport" And I fill in "County" with "Cheshire" And I fill in "Country" with "United Kingdom" And I fill in "Zip Code" with "sk8 4ty" And I press "Create" Then I should have 1 user And steps as: Then /^I should have ([0-9]+) user$/ do |c| User.count.should==c.to_i end Given /^that I have no users$/ do User.delete_all end If somebody could help us out, how to execute the steps so that the data gets inserted into the database. Smita. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed May 27 05:25:06 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 05:25:06 -0400 Subject: [rspec-users] Cucmber Step to insert Test Data into Database In-Reply-To: <97a92377da4082454c7581a55c035cf9@ruby-forum.com> References: <97a92377da4082454c7581a55c035cf9@ruby-forum.com> Message-ID: <57c63afe0905270225j1a0fe0fbn1f31766404eeaf5c@mail.gmail.com> On Wed, May 27, 2009 at 5:20 AM, Smita Sreekanth wrote: > Hi, > > We run the feature created for a form to identify the fields and also to > add data into the respective fields. > > But while running the cucumber features, all the scenario and steps are > getting passed but the record is not getting inserted into the > application / the database. > > We have also wrote the feature as: > > Feature: Adding a user > ?In order to add a user to the organization > ?As a administrator > ?I want to create and add new user > > Scenario: Create User > ?Given that I have no users > ?And I am on the "List of users" > ?When I follow "New User" > ?And I fill in "First Name" with "Rebecca" > ?And I fill in "Second Name" with "Martin" > ?And I fill in "Title" with "Miss" > ?And I fill in "Email" with "rebeccamartin at me.com" > ?And I fill in "Telephone" with "01617867645" > ?And I fill in "Mobile" with "01777867645" > ?And I fill in "Fax" with "01617867640?" > ?And I fill in "Address Line 1" with "58" > ?And I fill in "Address Line 2" with "West Tree rd" > ?And I fill in "Address Line 3" with "Stockport" > ?And I fill in "County" with "Cheshire" > ?And I fill in "Country" with "United Kingdom" > ?And I fill in "Zip Code" with "sk8 4ty" > ?And I press "Create" > ?Then I should have 1 user > > > And steps as: > > Then /^I should have ([0-9]+) user$/ do |c| > ?User.count.should==c.to_i > end > > Given /^that I have no users$/ do > ?User.delete_all > end > > If somebody could help us out, how to execute the steps so that the data > gets inserted into the database. > > Smita. Hi Smita. Please use the new Cucumber google group for new threads about Cucumber: http://groups.google.com/group/cukes Cheers, David From dchelimsky at gmail.com Wed May 27 08:25:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 May 2009 08:25:08 -0400 Subject: [rspec-users] spec for authenticated user In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013F6AB7@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013F6AB7@awww.armis.com> Message-ID: <57c63afe0905270525n4d55269ap18681cd38a0f1f4@mail.gmail.com> On Wed, May 27, 2009 at 7:08 AM, Diwakar, ANGLER - EIT wrote: > ? before_filter :requires_user, > ?????????????? :except => :create > > ?def show > ? #------- > > ??? # the currently authenticated user > ??? @user = user > > ? end > > How shall?we check the currently authenticated user using rspec? What's in requires_user? From matt at mattwynne.net Wed May 27 08:41:59 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 May 2009 13:41:59 +0100 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> References: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> Message-ID: <21466D30-2E00-499E-BFC3-156761F49A2C@mattwynne.net> On 27 May 2009, at 09:26, David Chelimsky wrote: > On Fri, May 1, 2009 at 12:26 PM, Matt Wynne > wrote: >> I'm creating a class in my spec file to test out a module, but when >> I run >> the spec a second time in spec_server, I get the error above. >> >> I presume this is because rails is un-loading the class, and it's not >> getting re-loaded properly as it doesn't have its own file in the >> conventional place. >> >> Does anyone have a nice workaround for this? > > Judging from the silence, I think the answer is no. > > There is some interesting stuff going on in other threads about spork. > Don't know if it solves this for you, but you may want to give it a > whirl. Actually you told me (some time ago) to upgrade to the latest version of RSpec, as there is some bug-fix with spec_server. I still haven't got around to doing that, but I'll feed back when I have. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From diwakar at angleritech.com Wed May 27 08:40:44 2009 From: diwakar at angleritech.com (Diwakar, ANGLER - EIT) Date: Wed, 27 May 2009 18:10:44 +0530 Subject: [rspec-users] spec for authenticated user In-Reply-To: <57c63afe0905270525n4d55269ap18681cd38a0f1f4@mail.gmail.com> References: <09CAF7492BB188429DDFABCD8218F283013F6AB7@awww.armis.com> <57c63afe0905270525n4d55269ap18681cd38a0f1f4@mail.gmail.com> Message-ID: <09CAF7492BB188429DDFABCD8218F283013F6AF9@awww.armis.com> private; def requires_user if user.nil? if request.format.html? session[ :redirected_from ] ||= request.env[ "REQUEST_URI" ] redirect_to( sign_in_url ) else render( :status => 403, :text => 'An authenticated user is required.' ) end end end -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky Sent: Wednesday, May 27, 2009 5:55 PM To: rspec-users Subject: Re: [rspec-users] spec for authenticated user > ? before_filter :requires_user, > ?????????????? :except => :create > > ?def show > ? #------- > > ??? # the currently authenticated user > ??? @user = user > > ? end > > How shall?we check the currently authenticated user using rspec? What's in requires_user? _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From scott at railsnewbie.com Wed May 27 09:36:58 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 27 May 2009 09:36:58 -0400 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> References: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> Message-ID: <4A1D41FA.6010805@railsnewbie.com> David Chelimsky wrote: > On Fri, May 1, 2009 at 12:26 PM, Matt Wynne wrote: > >> I'm creating a class in my spec file to test out a module, but when I run >> the spec a second time in spec_server, I get the error above. >> >> I presume this is because rails is un-loading the class, and it's not >> getting re-loaded properly as it doesn't have its own file in the >> conventional place. >> >> Does anyone have a nice workaround for this? >> > > Have you tried manually loading the file in the spec itself? Scott > Judging from the silence, I think the answer is no. > > There is some interesting stuff going on in other threads about spork. > Don't know if it solves this for you, but you may want to give it a > whirl. > > >> cheers, >> Matt Wynne >> http://beta.songkick.com >> http://blog.mattwynne.net >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 scott at railsnewbie.com Wed May 27 09:38:15 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 27 May 2009 09:38:15 -0400 Subject: [rspec-users] Cucmber Step to insert Test Data into Database In-Reply-To: <57c63afe0905270225j1a0fe0fbn1f31766404eeaf5c@mail.gmail.com> References: <97a92377da4082454c7581a55c035cf9@ruby-forum.com> <57c63afe0905270225j1a0fe0fbn1f31766404eeaf5c@mail.gmail.com> Message-ID: <4A1D4247.2090306@railsnewbie.com> David Chelimsky wrote: > On Wed, May 27, 2009 at 5:20 AM, Smita Sreekanth wrote: > >> Hi, >> >> We run the feature created for a form to identify the fields and also to >> add data into the respective fields. >> >> But while running the cucumber features, all the scenario and steps are >> getting passed but the record is not getting inserted into the >> application / the database. >> >> We have also wrote the feature as: >> >> Feature: Adding a user >> In order to add a user to the organization >> As a administrator >> I want to create and add new user >> >> Scenario: Create User >> Given that I have no users >> And I am on the "List of users" >> When I follow "New User" >> And I fill in "First Name" with "Rebecca" >> And I fill in "Second Name" with "Martin" >> And I fill in "Title" with "Miss" >> And I fill in "Email" with "rebeccamartin at me.com" >> And I fill in "Telephone" with "01617867645" >> And I fill in "Mobile" with "01777867645" >> And I fill in "Fax" with "01617867640?" >> And I fill in "Address Line 1" with "58" >> And I fill in "Address Line 2" with "West Tree rd" >> And I fill in "Address Line 3" with "Stockport" >> And I fill in "County" with "Cheshire" >> And I fill in "Country" with "United Kingdom" >> And I fill in "Zip Code" with "sk8 4ty" >> And I press "Create" >> Then I should have 1 user >> >> >> And steps as: >> >> Then /^I should have ([0-9]+) user$/ do |c| >> User.count.should==c.to_i >> end >> >> Given /^that I have no users$/ do >> User.delete_all >> end >> >> If somebody could help us out, how to execute the steps so that the data >> gets inserted into the database. >> >> Smita. >> > > Hi Smita. Please use the new Cucumber google group for new threads > about Cucumber: > > http://groups.google.com/group/cukes > When was the decision made to split off the cucumber group? Scott From lee.hambley at gmail.com Wed May 27 10:04:24 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Wed, 27 May 2009 15:04:24 +0100 Subject: [rspec-users] Cucmber Step to insert Test Data into Database In-Reply-To: <4A1D4247.2090306@railsnewbie.com> References: <97a92377da4082454c7581a55c035cf9@ruby-forum.com> <57c63afe0905270225j1a0fe0fbn1f31766404eeaf5c@mail.gmail.com> <4A1D4247.2090306@railsnewbie.com> Message-ID: Scott, Last mondayish ? - Lee 2009/5/27 Scott Taylor > David Chelimsky wrote: > >> On Wed, May 27, 2009 at 5:20 AM, Smita Sreekanth >> wrote: >> >> >>> Hi, >>> >>> We run the feature created for a form to identify the fields and also to >>> add data into the respective fields. >>> >>> But while running the cucumber features, all the scenario and steps are >>> getting passed but the record is not getting inserted into the >>> application / the database. >>> >>> We have also wrote the feature as: >>> >>> Feature: Adding a user >>> In order to add a user to the organization >>> As a administrator >>> I want to create and add new user >>> >>> Scenario: Create User >>> Given that I have no users >>> And I am on the "List of users" >>> When I follow "New User" >>> And I fill in "First Name" with "Rebecca" >>> And I fill in "Second Name" with "Martin" >>> And I fill in "Title" with "Miss" >>> And I fill in "Email" with "rebeccamartin at me.com" >>> And I fill in "Telephone" with "01617867645" >>> And I fill in "Mobile" with "01777867645" >>> And I fill in "Fax" with "01617867640?" >>> And I fill in "Address Line 1" with "58" >>> And I fill in "Address Line 2" with "West Tree rd" >>> And I fill in "Address Line 3" with "Stockport" >>> And I fill in "County" with "Cheshire" >>> And I fill in "Country" with "United Kingdom" >>> And I fill in "Zip Code" with "sk8 4ty" >>> And I press "Create" >>> Then I should have 1 user >>> >>> >>> And steps as: >>> >>> Then /^I should have ([0-9]+) user$/ do |c| >>> User.count.should==c.to_i >>> end >>> >>> Given /^that I have no users$/ do >>> User.delete_all >>> end >>> >>> If somebody could help us out, how to execute the steps so that the data >>> gets inserted into the database. >>> >>> Smita. >>> >>> >> >> Hi Smita. Please use the new Cucumber google group for new threads >> about Cucumber: >> >> http://groups.google.com/group/cukes >> >> > > When was the decision made to split off the cucumber group? > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Wed May 27 10:06:46 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 27 May 2009 08:06:46 -0600 Subject: [rspec-users] Cucmber Step to insert Test Data into Database In-Reply-To: <4A1D4247.2090306@railsnewbie.com> References: <97a92377da4082454c7581a55c035cf9@ruby-forum.com> <57c63afe0905270225j1a0fe0fbn1f31766404eeaf5c@mail.gmail.com> <4A1D4247.2090306@railsnewbie.com> Message-ID: <4A1D48F6.2080007@benmabey.com> Scott Taylor wrote: > David Chelimsky wrote: >> On Wed, May 27, 2009 at 5:20 AM, Smita Sreekanth >> wrote: >> >>> Hi, >>> >>> We run the feature created for a form to identify the fields and >>> also to >>> add data into the respective fields. >>> >>> But while running the cucumber features, all the scenario and steps are >>> getting passed but the record is not getting inserted into the >>> application / the database. >>> >>> We have also wrote the feature as: >>> >>> Feature: Adding a user >>> In order to add a user to the organization >>> As a administrator >>> I want to create and add new user >>> >>> Scenario: Create User >>> Given that I have no users >>> And I am on the "List of users" >>> When I follow "New User" >>> And I fill in "First Name" with "Rebecca" >>> And I fill in "Second Name" with "Martin" >>> And I fill in "Title" with "Miss" >>> And I fill in "Email" with "rebeccamartin at me.com" >>> And I fill in "Telephone" with "01617867645" >>> And I fill in "Mobile" with "01777867645" >>> And I fill in "Fax" with "01617867640?" >>> And I fill in "Address Line 1" with "58" >>> And I fill in "Address Line 2" with "West Tree rd" >>> And I fill in "Address Line 3" with "Stockport" >>> And I fill in "County" with "Cheshire" >>> And I fill in "Country" with "United Kingdom" >>> And I fill in "Zip Code" with "sk8 4ty" >>> And I press "Create" >>> Then I should have 1 user >>> >>> >>> And steps as: >>> >>> Then /^I should have ([0-9]+) user$/ do |c| >>> User.count.should==c.to_i >>> end >>> >>> Given /^that I have no users$/ do >>> User.delete_all >>> end >>> >>> If somebody could help us out, how to execute the steps so that the >>> data >>> gets inserted into the database. >>> >>> Smita. >>> >> >> Hi Smita. Please use the new Cucumber google group for new threads >> about Cucumber: >> >> http://groups.google.com/group/cukes >> > > When was the decision made to split off the cucumber group? > > Scott http://rubyforge.org/pipermail/rspec-users/2009-May/014502.html -Ben From lists at ruby-forum.com Wed May 27 15:43:42 2009 From: lists at ruby-forum.com (Shane Hayes) Date: Wed, 27 May 2009 21:43:42 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> Message-ID: <2f73c57b3eb38e77bd4248bc88096ae4@ruby-forum.com> Trond Marius ?vstetun wrote: > I believe (someone correct me if I'm wrong..) that the version of > cucumber_java you have installed is an older version from a central > repository. cucumber/pico_container is the result of a recent > refactoring > (as is cucumber/spring). > For me it helped to use cp instead of mv in the Rakefile at some point. > And > to remove the line executing mvn from the rake task. Then I was able to > install the updated gem. > > regards, Trond I'm having the same problem as Raymond, but on Windoze. Is there another version? The only I can seem to find is the 0.0.1 on http://github.com/aslakhellesoy/cucumber_java/downloads -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Wed May 27 16:03:55 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 27 May 2009 22:03:55 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: <2f73c57b3eb38e77bd4248bc88096ae4@ruby-forum.com> References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> <2f73c57b3eb38e77bd4248bc88096ae4@ruby-forum.com> Message-ID: <8d961d900905271303o6cb10c41o3f941ea30e641168@mail.gmail.com> > Trond Marius ?vstetun wrote: >> I believe (someone correct me if I'm wrong..) that the version of >> cucumber_java you have installed is an older version from a central >> repository. cucumber/pico_container is the result of a recent >> refactoring >> (as is cucumber/spring). >> For me it helped to use cp instead of mv in the Rakefile at some point. >> And >> to remove the line executing mvn from the rake task. Then I was able to >> install the updated gem. >> >> regards, Trond > > I'm having the same problem as Raymond, but on Windoze. Is there another > version? The only I can seem to find is the 0.0.1 on > http://github.com/aslakhellesoy/cucumber_java/downloads > No more recent versions have been released since 0.0.1. There are some bugfixes on Github, but you have to build it yourself. I'll announce here when there is a new release. Any help moving it forward is appreciated. Aslak > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Wed May 27 16:59:26 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 May 2009 21:59:26 +0100 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: <4A1D41FA.6010805@railsnewbie.com> References: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> <4A1D41FA.6010805@railsnewbie.com> Message-ID: On 27 May 2009, at 14:36, Scott Taylor wrote: > David Chelimsky wrote: >> On Fri, May 1, 2009 at 12:26 PM, Matt Wynne >> wrote: >> >>> I'm creating a class in my spec file to test out a module, but >>> when I run >>> the spec a second time in spec_server, I get the error above. >>> >>> I presume this is because rails is un-loading the class, and it's >>> not >>> getting re-loaded properly as it doesn't have its own file in the >>> conventional place. >>> >>> Does anyone have a nice workaround for this? >>> >> >> > > Have you tried manually loading the file in the spec itself? > > Scott erm.... I create the class *in the spec* itself so not sure how I'd do that. I think I might be better off using an anonymous type instead. > > >> Judging from the silence, I think the answer is no. >> >> There is some interesting stuff going on in other threads about >> spork. >> Don't know if it solves this for you, but you may want to give it a >> whirl. >> >> >>> cheers, >>> Matt Wynne >>> http://beta.songkick.com >>> http://blog.mattwynne.net >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From scott at railsnewbie.com Wed May 27 17:03:51 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 27 May 2009 17:03:51 -0400 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: References: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> <4A1D41FA.6010805@railsnewbie.com> Message-ID: <34C0DA17-E4FF-47B1-BA07-C639C9342001@railsnewbie.com> On May 27, 2009, at 4:59 PM, Matt Wynne wrote: > > On 27 May 2009, at 14:36, Scott Taylor wrote: > >> David Chelimsky wrote: >>> On Fri, May 1, 2009 at 12:26 PM, Matt Wynne >>> wrote: >>> >>>> I'm creating a class in my spec file to test out a module, but >>>> when I run >>>> the spec a second time in spec_server, I get the error above. >>>> >>>> I presume this is because rails is un-loading the class, and it's >>>> not >>>> getting re-loaded properly as it doesn't have its own file in the >>>> conventional place. >>>> >>>> Does anyone have a nice workaround for this? >>>> >>> >>> >> >> Have you tried manually loading the file in the spec itself? >> >> Scott > > erm.... I create the class *in the spec* itself so not sure how I'd > do that. I think I might be better off using an anonymous type > instead. Is it some sort of class only used for testing behaviour inherited from AR::Base? Scott From matt at mattwynne.net Wed May 27 17:24:45 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 27 May 2009 22:24:45 +0100 Subject: [rspec-users] [rspec]spec_server: already initialized constant MyTestClass In-Reply-To: <34C0DA17-E4FF-47B1-BA07-C639C9342001@railsnewbie.com> References: <57c63afe0905270126o21932fefw4c9bb36a541cb759@mail.gmail.com> <4A1D41FA.6010805@railsnewbie.com> <34C0DA17-E4FF-47B1-BA07-C639C9342001@railsnewbie.com> Message-ID: <7E2C931B-E01D-49E7-8B0D-ECF44752B3E3@mattwynne.net> On 27 May 2009, at 22:03, Scott Taylor wrote: > > On May 27, 2009, at 4:59 PM, Matt Wynne wrote: > >> >> On 27 May 2009, at 14:36, Scott Taylor wrote: >> >>> David Chelimsky wrote: >>>> On Fri, May 1, 2009 at 12:26 PM, Matt Wynne >>>> wrote: >>>> >>>>> I'm creating a class in my spec file to test out a module, but >>>>> when I run >>>>> the spec a second time in spec_server, I get the error above. >>>>> >>>>> I presume this is because rails is un-loading the class, and >>>>> it's not >>>>> getting re-loaded properly as it doesn't have its own file in the >>>>> conventional place. >>>>> >>>>> Does anyone have a nice workaround for this? >>>>> >>>> >>>> >>> >>> Have you tried manually loading the file in the spec itself? >>> >>> Scott >> >> erm.... I create the class *in the spec* itself so not sure how I'd >> do that. I think I might be better off using an anonymous type >> instead. > > Is it some sort of class only used for testing behaviour inherited > from AR::Base? > > Scott Doesn't inherit from AR::Base I don't think - why? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Wed May 27 19:47:11 2009 From: lists at ruby-forum.com (Shane Hayes) Date: Thu, 28 May 2009 01:47:11 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: <8d961d900905271303o6cb10c41o3f941ea30e641168@mail.gmail.com> References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> <2f73c57b3eb38e77bd4248bc88096ae4@ruby-forum.com> <8d961d900905271303o6cb10c41o3f941ea30e641168@mail.gmail.com> Message-ID: Aslak Helles?y wrote: >>> >>> regards, Trond >> >> I'm having the same problem as Raymond, but on Windoze. Is there another >> version? The only I can seem to find is the 0.0.1 on >> http://github.com/aslakhellesoy/cucumber_java/downloads >> > > No more recent versions have been released since 0.0.1. There are some > bugfixes on Github, but you have to build it yourself. I'll announce > here when there is a new release. Any help moving it forward is > appreciated. > > Aslak Thanks for letting me know. I think getting Cucumber working directly with Java is a great idea!! and I appreciate the efforts already put in. At first I thought the calls had to go through jruby. The native java support is important for java groups so they don't need to learn another language (unless they are lucky enough to be transitioning to Ruby, but I suspect it will be a long time for many teams). I'll try to help, but I suspect I'll consume more resources getting going than the benefits added :) I'll work on getting the latest out of git. Shane -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Wed May 27 20:19:08 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 28 May 2009 01:19:08 +0100 Subject: [rspec-users] thoughts on this? Message-ID: <61AA9060-64E7-49E5-A57B-67595F4D22CB@mattwynne.net> http://robertlally.com/post/bdd-not-so-much Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From sfeley at gmail.com Wed May 27 23:03:55 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 27 May 2009 23:03:55 -0400 Subject: [rspec-users] thoughts on this? In-Reply-To: <61AA9060-64E7-49E5-A57B-67595F4D22CB@mattwynne.net> References: <61AA9060-64E7-49E5-A57B-67595F4D22CB@mattwynne.net> Message-ID: <1fb4df0905272003n2ec6a26g7850853966f7534a@mail.gmail.com> On Wed, May 27, 2009 at 8:19 PM, Matt Wynne wrote: > http://robertlally.com/post/bdd-not-so-much *shrug* I think he's being too literal and missing the substance of the practice by criticizing its veneer. I personally don't use BDD as a path to customer communication; in the majority of my projects I'm the primary 'customer,' so it's to help *me* think, not somebody else. I also don't use "should" in my specs. I don't care about should-vs.-assert. I use active, immediate language. My failure to use "should" doesn't make my specs any less functional, and as I'm not required to submit them to any BDD experts for grading, no one suffers. For that matter, I've never found that the semantic argument about "What is BDD?" vs. "What is TDD?" has ever made any practical difference to my code. I like RSpec because it helps me think in English about what I'm going to do before I do it. So does Cucumber. Both are better at different sorts of problems. The mental model of coding practice that they facilitate is useful to me and makes better code. I really don't care what anyone calls it. I also don't understand his apparent assumption that using a "structured textual format" for functional specs means it's the *only* thing one uses. Sometimes I make diagrams to understand my design thoughts better. Sometimes I do mind maps. Sometimes I write long rambling blog posts (http://tinyurl.com/d6w4t8). And I still use RSpec and Cucumber. They're not exclusive of each other. They're all useful. They all shine different lights on the same cave wall. Finally, and most relevant: I personally don't understand vodka. It doesn't taste like anything to me. I do not accept that a vodka martini is truly a martini. It will never work for me, and I tell my friends frequently that their 'martini' is a misuse of the word and that they can't possibly like what they're drinking. I am, of course, wrong. This could be really obnoxious of me, except... Well, who cares? While I'm babbling on, they've got a martini in their hand and they're enjoying it. Thus, they win. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From ben at benmabey.com Thu May 28 01:32:09 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 27 May 2009 23:32:09 -0600 Subject: [rspec-users] thoughts on this? In-Reply-To: <1fb4df0905272003n2ec6a26g7850853966f7534a@mail.gmail.com> References: <61AA9060-64E7-49E5-A57B-67595F4D22CB@mattwynne.net> <1fb4df0905272003n2ec6a26g7850853966f7534a@mail.gmail.com> Message-ID: <4A1E21D9.5010207@benmabey.com> Stephen Eley wrote: > On Wed, May 27, 2009 at 8:19 PM, Matt Wynne wrote: > >> http://robertlally.com/post/bdd-not-so-much >> > > *shrug* > > I'll add a *sigh* as well... Robert says his "problem is with the definition of BDD itself". He points out that no one can really agree on what BDD is exactly, which is true to a certain extent. However, he then makes arguments against BDD using his poor understanding of it. *snip* > For that matter, I've never found that the semantic argument about > "What is BDD?" vs. "What is TDD?" has ever made any practical > difference to my code. ... > I think Robert makes valid observations. If you ask anyone on this list what BDD is you will get different answers even though we are a very homogeneous bunch when it comes to the tools we use. ( I think Steve just illustrated this point. :) ) Now, if you ask people on the BDD Google Groups list you will get far different answers and people will have a hard time agreeing on terminology. I think this, more than anything, is what Robert is frustrated about. BDD has changed and evolved over the years and people are at different stages of understanding it. It is hard to pin down what an idea is when it is evolving and being fine tuned. Additionally, like Steve pointed out, it can mean different things in different contexts. Despite this being a valid observation he makes the wrong conclusion that this confusion over what IS BDD is a bad thing and therefore means "BDD isn't AN answer." I think this line points out his flawed logic the best: "So what is the output of BDD: User Acceptance Tests? Functional Tests? Unit Tests? System Tests? A system design? The design of individual units? It depends on who you talk to." Well.. guess what, this exact things applies to TDD: "So what is the output of TDD: User Acceptance Tests? Functional Tests? Unit Tests? System Tests? A system design? The design of individual units? It depends on who you talk to." You can ask people on the TDD list what TDD is and guess what- you will get different answers!! So, by Robert's logic TDD isn't AN answer either. This reminds me of the recent TDD tests are not unit tests debacle. I think Michael Feathers summed up the controversy pretty well[1]. In the end you have to realize, and accept, that people will have different ideas and terminology about the same practice. That doesn't invalidate the practice though. > I also don't understand his apparent assumption that using a > "structured textual format" for functional specs means it's the *only* > thing one uses. Sometimes I make diagrams to understand my design > thoughts better. Sometimes I do mind maps. Sometimes I write long > rambling blog posts (http://tinyurl.com/d6w4t8). And I still use > RSpec and Cucumber. They're not exclusive of each other. They're all > useful. They all shine different lights on the same cave wall. > I picked up on this as well, and this goes back to my statement about him making arguments against BDD with a poor definition of it. Robert seems to have the misconception that as BDD has evolved different ways of writing tests that these ways are mutually exclusive. From what I can gather he seems to think that one must phrase all of your tests as customer facing tests when using Cucumber, and you are not allowed to use RSpec or Test::Unit at all. From his post: "TDD, as a design methodology, forces you to write code that is used by two different clients: the tests and the final application. This is one of the ways that it helps promote flexibility. It gives you an early look at ?how exactly am I going to use this class/object?. BDD frameworks don?t look or work like the code that will be calling the final code, so there really is no benefit here. Take easyb as an example, it doesn?t even use the same language as the code you?re writing (assuming the common use case of using easyb as a BDD framework for Java development). TDD highlights pain points when writing tests, if it is hard to write a test for, your code probably needs a little work. BDD frameworks such as Cucumber, can quite happily support specs written in terms of ?the system? or ?the application? and you have to write grotesque code to make it work under the covers. This doesn?t make Cucumber a bad tool, just the wrong tool for the job of designing code." He has very good points about how TDD is a design methodology, but he is misinformed about the use of BDD tools in this regard. I view RSpec as my design tool to be used in the exact way he as described. Why do you think we are calling them "code examples"?!? I agree with him about Cucumber not being fit for a design tool on that kind of level. I don't see Cucumber providing me the same type of detailed design cues that I get from RSpec. However, Cucumber helps me make sure that I am only designing (with RSpec) code that actually needs to be designed. It helps me write software, not code or as Dan North likes to say "software that matters". Can you do the same thing with an xUnit framework with high level acceptance tests? Sure you can, but those tests won't be nearly as nice of a communication tool to the customers or, IMO, provide as good of application level documentation. Anyways.. that is my take on it. I would also recommend reading this post from Dan North on this list about his frustrations over misconceptions of what BDD is: http://rubyforge.org/pipermail/rspec-users/2008-February/005696.html I'm hoping that the publication of _The RSpec Book_ will help with these types of misconceptions. It has in it, IMO, the culmination of a lot of thinking behind what BDD is and will be a great reference to point people to who are grappling with understanding BDD regardless of programming language. Maybe we should send Robert a free copy to help educate him? :p -Ben 1. http://blog.objectmentor.com/articles/2009/04/13/x-tests-are-not-x-tests From zach.dennis at gmail.com Thu May 28 02:10:14 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 28 May 2009 02:10:14 -0400 Subject: [rspec-users] thoughts on this? In-Reply-To: <61AA9060-64E7-49E5-A57B-67595F4D22CB@mattwynne.net> References: <61AA9060-64E7-49E5-A57B-67595F4D22CB@mattwynne.net> Message-ID: <85d99afe0905272310m2e385c6fp8f0ca6b141469d83@mail.gmail.com> On Wed, May 27, 2009 at 8:19 PM, Matt Wynne wrote: > http://robertlally.com/post/bdd-not-so-much My response was too long, I just posted to my blog. http://www.continuousthinking.com/2009/5/28/bdd-not-so-much-really I'm serious about the book club though. -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From Jarmo.P at gmail.com Thu May 28 02:38:42 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Wed, 27 May 2009 23:38:42 -0700 (PDT) Subject: [rspec-users] [rspec] http://rspec.info examples are broken In-Reply-To: <8d961d900905251243n5b2c74c3ga7121695c9ff8e9a@mail.gmail.com> References: <05d51392-494b-4bd9-8a8a-c5a2a670dac5@o18g2000yqi.googlegroups.com> <8d961d900905251243n5b2c74c3ga7121695c9ff8e9a@mail.gmail.com> Message-ID: <3b637b60-ee62-4ebd-9eac-a16f27f3d811@o18g2000yqi.googlegroups.com> On May 25, 10:43?pm, aslak hellesoy wrote: > > It seems that some examples athttp://rspec.infoare broken with > > invalid html. > > > For example:http://rspec.info/documentation/before_and_after.html > > I assume you're referring to:http://validator.w3.org/check?uri=http%3A%2F%2Frspec.info%2Fdocumenta... I didn't mean validation errors per se, but just the fact that instead of account.balance.should == Money.new(0) there is this line account
.balance.should == Money.new (0) > > > All those spans there should not be visible, I think :) Isn't > >rspec.infoweb tested well enough? :P > > It's not tested at all. Any suggestions about how to improve it? I don't know if that's the suggestion you wanted to hear, but you could use Watir or Selenium maybe to have few integration tests if you have some extra time. David, nice explanation as of why this happened, lol. Anyway, why I even brought this topic up, was because I recommended friend to try RSpec and gave him this link, which now is quite hard to understand because of all this mess. Hopefully new web will be available soon! Jarmo From zach.dennis at gmail.com Thu May 28 02:39:52 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 28 May 2009 02:39:52 -0400 Subject: [rspec-users] create_ In-Reply-To: <4A1D373A.8050704@haskinferguson.net> References: <4A1D373A.8050704@haskinferguson.net> Message-ID: <85d99afe0905272339o2c2379b7vaa8637b997892c21@mail.gmail.com> On Wed, May 27, 2009 at 8:51 AM, Denis Haskin wrote: > Any know issues with the dynamic create_ method and > factory_girl? > > I have an object created by a factory: > > ??? @order = Factory.create :payable_order_with_line_items > > and then I do: > > ??? @order.create_ship_address( > then the ship_address object is persisted but the association is not made > (e.g. @order.ship_address_id is nil). > > If I instead create the Address object and then say > @order.update_attributes(:ship_address => address), everything is fine. > > Is this some issue with mixing factory-created objects with non?? I can't > imagine that's an issue... I don't think it's an issue w/FactoryGirl. A belongs_to association in Rails adds the create_xxxxx association method, which returns a new object of the associated type that has been instantiated and saved. It does NOT save the receiver. For example: @order.create_ship_address This creates a ShipAddress and it updates @order's in-memory ship_address_id, but it does not save @order. You have to do that. Here's the example the Rails docs gives: Post#create_author (similar to post.author = Author.new; post.author.save; post.author) Which in this example, the post is never saved, only it's in-memory association is set, so you still need to save @order in your example. HTH, > > Thanks, > > dwh > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From matt at mattwynne.net Thu May 28 03:41:04 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 28 May 2009 08:41:04 +0100 Subject: [rspec-users] thoughts on this? In-Reply-To: <4A1E21D9.5010207@benmabey.com> References: <61AA9060-64E7-49E5-A57B-67595F4D22CB@mattwynne.net> <1fb4df0905272003n2ec6a26g7850853966f7534a@mail.gmail.com> <4A1E21D9.5010207@benmabey.com> Message-ID: On 28 May 2009, at 06:32, Ben Mabey wrote: > Stephen Eley wrote: >> On Wed, May 27, 2009 at 8:19 PM, Matt Wynne >> wrote: >> >>> http://robertlally.com/post/bdd-not-so-much >>> >> >> *shrug* >> >> > I'll add a *sigh* as well... > > Robert says his "problem is with the definition of BDD itself". He > points out that no one can really agree on what BDD is exactly, > which is true to a certain extent. However, he then makes arguments > against BDD using his poor understanding of it. > > *snip* >> For that matter, I've never found that the semantic argument about >> "What is BDD?" vs. "What is TDD?" has ever made any practical >> difference to my code. ... >> > > I think Robert makes valid observations. If you ask anyone on this > list what BDD is you will get different answers even though we are a > very homogeneous bunch when it comes to the tools we use. ( I think > Steve just illustrated this point. :) ) Now, if you ask people on > the BDD Google Groups list you will get far different answers and > people will have a hard time agreeing on terminology. I think this, > more than anything, is what Robert is frustrated about. BDD has > changed and evolved over the years and people are at different > stages of understanding it. It is hard to pin down what an idea is > when it is evolving and being fine tuned. Additionally, like Steve > pointed out, it can mean different things in different contexts. > Despite this being a valid observation he makes the wrong conclusion > that this confusion over what IS BDD is a bad thing and therefore > means "BDD isn't AN answer." I think this line points out his flawed > logic the best: > > "So what is the output of BDD: User Acceptance Tests? Functional > Tests? Unit Tests? System Tests? A system design? The design of > individual units? It depends on who you talk to." > > Well.. guess what, this exact things applies to TDD: > > "So what is the output of TDD: User Acceptance Tests? Functional > Tests? Unit Tests? System Tests? A system design? The design of > individual units? It depends on who you talk to." > > You can ask people on the TDD list what TDD is and guess what- you > will get different answers!! So, by Robert's logic TDD isn't AN > answer either. This reminds me of the recent TDD tests are not unit > tests debacle. I think Michael Feathers summed up the controversy > pretty well[1]. In the end you have to realize, and accept, that > people will have different ideas and terminology about the same > practice. That doesn't invalidate the practice though. >> I also don't understand his apparent assumption that using a >> "structured textual format" for functional specs means it's the >> *only* >> thing one uses. Sometimes I make diagrams to understand my design >> thoughts better. Sometimes I do mind maps. Sometimes I write long >> rambling blog posts (http://tinyurl.com/d6w4t8). And I still use >> RSpec and Cucumber. They're not exclusive of each other. They're >> all >> useful. They all shine different lights on the same cave wall. >> > > I picked up on this as well, and this goes back to my statement > about him making arguments against BDD with a poor definition of it. > Robert seems to have the misconception that as BDD has evolved > different ways of writing tests that these ways are mutually > exclusive. From what I can gather he seems to think that one must > phrase all of your tests as customer facing tests when using > Cucumber, and you are not allowed to use RSpec or Test::Unit at all. > From his post: > > "TDD, as a design methodology, forces you to write code that is used > by two different clients: the tests and the final application. This > is one of the ways that it helps promote flexibility. It gives you > an early look at ?how exactly am I going to use this class/object?. > BDD frameworks don?t look or work like the code that will be calling > the final code, so there really is no benefit here. Take easyb as an > example, it doesn?t even use the same language as the code you?re > writing (assuming the common use case of using easyb as a BDD > framework for Java development). > > TDD highlights pain points when writing tests, if it is hard to > write a test for, your code probably needs a little work. BDD > frameworks such as Cucumber, can quite happily support specs written > in terms of ?the system? or ?the application? and you have to write > grotesque code to make it work under the covers. This doesn?t make > Cucumber a bad tool, just the wrong tool for the job of designing > code." > > > He has very good points about how TDD is a design methodology, but > he is misinformed about the use of BDD tools in this regard. I view > RSpec as my design tool to be used in the exact way he as described. > Why do you think we are calling them "code examples"?!? I agree with > him about Cucumber not being fit for a design tool on that kind of > level. I don't see Cucumber providing me the same type of detailed > design cues that I get from RSpec. However, Cucumber helps me make > sure that I am only designing (with RSpec) code that actually needs > to be designed. It helps me write software, not code or as Dan North > likes to say "software that matters". Can you do the same thing with > an xUnit framework with high level acceptance tests? Sure you can, > but those tests won't be nearly as nice of a communication tool to > the customers or, IMO, provide as good of application level > documentation. > > Anyways.. that is my take on it. I would also recommend reading this > post from Dan North on this list about his frustrations over > misconceptions of what BDD is: http://rubyforge.org/pipermail/rspec-users/2008-February/005696.html > > I'm hoping that the publication of _The RSpec Book_ will help with > these types of misconceptions. It has in it, IMO, the culmination of > a lot of thinking behind what BDD is and will be a great reference > to point people to who are grappling with understanding BDD > regardless of programming language. Maybe we should send Robert a > free copy to help educate him? :p > > -Ben This is brilliant, Ben. Please blog it for posterity. My response was a bit more practical: http://blog.mattwynne.net/2009/05/28/bdd-joy-in-10-easy-steps/ > 1. http://blog.objectmentor.com/articles/2009/04/13/x-tests-are-not-x-tests > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From scott at railsnewbie.com Thu May 28 05:16:33 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 28 May 2009 05:16:33 -0400 Subject: [rspec-users] DeepTest with 1.2.6? In-Reply-To: <8d18f1f80905280211k5f1ba25hd447797ec08974d@mail.gmail.com> References: <8d18f1f80905280211k5f1ba25hd447797ec08974d@mail.gmail.com> Message-ID: <4A1E5671.2080502@railsnewbie.com> Adam Anderson wrote: > Just curious if anyone is running DeepTest with rspec 1.2.6. I can't > even do a '$ rake -T' on the deep-test repo at > git://github.com/qxjit/deep-test.git > > > When I try to run deep_test using their provided rspec example at > http://github.com/qxjit/deep-test it blows up and produces the following: > Warning: DeepTest will run before(:all) and after(:all) blocks for > *every* test that is run. To remove this warning either convert all > before/after blocks to each blocks or set > $show_deep_test_all_block_warning to false > [DeepTest] Started DeepTest service at druby://0.0.0.0:6969 > My impression is that it was always sort of buggy and it was hard to reproduce certain bugs in certain configurations - so I'm not sure if it ever worked. I never got it to fully work on my own machine. You might try contacting David Vollbracht, who was the one who added in rspec support (this was probably 6 months ago or so now). I'd be interested in hearing if anyone is actually using it. Scott From ben at benmabey.com Thu May 28 10:03:38 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 28 May 2009 08:03:38 -0600 Subject: [rspec-users] DeepTest with 1.2.6? In-Reply-To: <4A1E5671.2080502@railsnewbie.com> References: <8d18f1f80905280211k5f1ba25hd447797ec08974d@mail.gmail.com> <4A1E5671.2080502@railsnewbie.com> Message-ID: <4A1E99BA.3070603@benmabey.com> Scott Taylor wrote: > Adam Anderson wrote: >> Just curious if anyone is running DeepTest with rspec 1.2.6. I can't >> even do a '$ rake -T' on the deep-test repo at >> git://github.com/qxjit/deep-test.git >> >> >> When I try to run deep_test using their provided rspec example at >> http://github.com/qxjit/deep-test it blows up and produces the >> following: >> Warning: DeepTest will run before(:all) and after(:all) blocks for >> *every* test that is run. To remove this warning either convert all >> before/after blocks to each blocks or set >> $show_deep_test_all_block_warning to false >> [DeepTest] Started DeepTest service at druby://0.0.0.0:6969 >> > > My impression is that it was always sort of buggy and it was hard to > reproduce certain bugs in certain configurations - so I'm not sure if > it ever worked. I never got it to fully work on my own machine. > > You might try contacting David Vollbracht, who was the one who added > in rspec support (this was probably 6 months ago or so now). > > I'd be interested in hearing if anyone is actually using it. > I tried using DeepTest but I never had success with it. I was able to get it to run but on a single machine with two workers (for it's two cores) and it ran considerably slower than just running rspec alone. I tried it on a brand new app and saw the same results. Support was added for RSpec but I highly doubt anyone really used it in real life. I would love to hear otherwise though. -Ben From nick at deadorange.com Thu May 28 08:15:20 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 28 May 2009 08:15:20 -0400 Subject: [rspec-users] Class method not being stubbed In-Reply-To: References: <16827fa20905240925j69b511c9re5b61b87883beed3@mail.gmail.com> <16827fa20905241025v761e56b7mcc49ea97c5f2a375@mail.gmail.com> <0ef0c40e5584fae7bb23624822567cf4@ruby-forum.com> <16827fa20905241124x34c95827w5ddaf40ee295824c@mail.gmail.com> Message-ID: <16827fa20905280515g7f73a463g8c3ea37c11b98083@mail.gmail.com> On Sun, May 24, 2009 at 3:25 PM, Rick DeNatale wrote: > One thing which strikes me is that if Rails naming conventions were > being followed: > > ?1) the file name be lib/ad_sense_heaven_parser not lib/adsense_heaven_parser > ?2) the require wouldn't be needed since it would be autoloaded. > > Perhaps the problem lies there somewhere. Hi Rick. I finally had some time to fix this problem, and you were spot on. I moved lib/adsense_heaven_parser.rb to app/models/ad_sense_heaven_parser.rb and everything's smooth now. Thanks for catching that! -Nick From nick at deadorange.com Thu May 28 08:32:03 2009 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 28 May 2009 08:32:03 -0400 Subject: [rspec-users] spec for authenticated user In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013F6AF9@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013F6AB7@awww.armis.com> <57c63afe0905270525n4d55269ap18681cd38a0f1f4@mail.gmail.com> <09CAF7492BB188429DDFABCD8218F283013F6AF9@awww.armis.com> Message-ID: <16827fa20905280532l28a59ea6se4550fd63e0accb4@mail.gmail.com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Wednesday, May 27, 2009 5:55 PM > To: rspec-users > Subject: Re: [rspec-users] spec for authenticated user >> ? before_filter :requires_user, >> ?????????????? :except => :create >> >> ?def show >> ? #------- >> >> ??? # the currently authenticated user >> ??? @user = user >> >> ? end >> >> How shall?we check the currently authenticated user using rspec? > > What's in requires_user? On Wed, May 27, 2009 at 8:40 AM, Diwakar, ANGLER - EIT wrote: > private; def requires_user > if user.nil? > > if request.format.html? > > session[ :redirected_from ] ||= request.env[ "REQUEST_URI" ] > > redirect_to( sign_in_url ) > else > render( :status => 403, :text => 'An authenticated user is required.' ) > end > end > > end What's setting the "user" variable before #requires_user is called? Or is "user" a method inside that controller? Ignoring that question for a moment, all you need to do is write out (on paper/in Vim/whatever) the behaviour of each scenario that can occur while traversing through this controller. For example, one [verbose] scenario is: "When a user who's not logged-in and whose session isn't being redirected requests HTML from FooBarsController#show , they should be redirected to the sign-up page." Once you have the behaviour of each scenario mapped out, write specs for each scenario. When that's all done, I recommend writing your specs before you write code. -Nick From bjohnson at binarylogic.com Wed May 27 12:14:12 2009 From: bjohnson at binarylogic.com (Ben Johnson) Date: Wed, 27 May 2009 12:14:12 -0400 Subject: [rspec-users] Disabling cucumber for autotest Message-ID: <3D233574-0E6A-48F9-AD9A-109A97694974@binarylogic.com> Hi, For some reason, no matter what, my entire cucumber suite is ran after every auto test. Is there a way to make auto test ignore cucumber all together? Thanks for your help. Ben Johnson Binary Logic W: www.binarylogic.com E: bjohnson at binarylogic.com 1430 Broadway 7th Floor - NECO New York, NY 10018 From lists at ruby-forum.com Thu May 28 11:38:44 2009 From: lists at ruby-forum.com (Shane Hayes) Date: Thu, 28 May 2009 17:38:44 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: <8d961d900905271303o6cb10c41o3f941ea30e641168@mail.gmail.com> References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> <2f73c57b3eb38e77bd4248bc88096ae4@ruby-forum.com> <8d961d900905271303o6cb10c41o3f941ea30e641168@mail.gmail.com> Message-ID: Aslak Helles?y wrote: >>> >>> regards, Trond >> >> I'm having the same problem as Raymond, but on Windoze. Is there another >> version? The only I can seem to find is the 0.0.1 on >> http://github.com/aslakhellesoy/cucumber_java/downloads >> > > No more recent versions have been released since 0.0.1. There are some > bugfixes on Github, but you have to build it yourself. I'll announce > here when there is a new release. Any help moving it forward is > appreciated. > > Aslak I have the latest from github, and there is still a dependency on pico-container, here is the error: no such file to load -- cucumber/pico_container after ?jruby -S cucumber features?. Any hints on installing pico-container? (gem vs jar)I'll guess the gem into JRuby, but I'm not sure. Shane -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Thu May 28 11:54:30 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 28 May 2009 17:54:30 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> <2f73c57b3eb38e77bd4248bc88096ae4@ruby-forum.com> <8d961d900905271303o6cb10c41o3f941ea30e641168@mail.gmail.com> Message-ID: <8d961d900905280854q3555be74n3bb22e4e4db09f94@mail.gmail.com> > Aslak Helles?y wrote: >>>> >>>> regards, Trond >>> >>> I'm having the same problem as Raymond, but on Windoze. Is there another >>> version? The only I can seem to find is the 0.0.1 on >>> http://github.com/aslakhellesoy/cucumber_java/downloads >>> >> >> No more recent versions have been released since 0.0.1. There are some >> bugfixes on Github, but you have to build it yourself. I'll announce >> here when there is a new release. Any help moving it forward is >> appreciated. >> >> Aslak > > I have the latest from github, and there is still a dependency on > pico-container, here is the error: no such file to load -- > cucumber/pico_container after ?jruby -S cucumber features?. Then you must be running a previous release. Get rid of it. Look higher up in this thread. > Any hints on installing pico-container? (gem vs jar)I'll guess the gem > into JRuby, but I'm not sure. > > Shane > -- > 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 Thu May 28 12:10:28 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 28 May 2009 10:10:28 -0600 Subject: [rspec-users] Disabling cucumber for autotest In-Reply-To: <3D233574-0E6A-48F9-AD9A-109A97694974@binarylogic.com> References: <3D233574-0E6A-48F9-AD9A-109A97694974@binarylogic.com> Message-ID: <4A1EB774.1050908@benmabey.com> Ben Johnson wrote: > Hi, > > For some reason, no matter what, my entire cucumber suite is ran after > every auto test. Is there a way to make auto test ignore cucumber all > together? > > Thanks for your help. Hi Ben, The default behaviour is for it to not run the features at all. In fact Cucumber will not even hook into autotest unless you have an environment variable called AUTOFEATURE set to true... Want to check to see if you have exported that variable? If that env var is not set then I'm at a loss on why autotest would be picking up cucumber's autotest plugin... BTW, cucumber has it's own mailing list now: http://groups.google.com/group/cukes -Ben From rick.denatale at gmail.com Thu May 28 13:05:09 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 28 May 2009 13:05:09 -0400 Subject: [rspec-users] Disabling cucumber for autotest In-Reply-To: <3D233574-0E6A-48F9-AD9A-109A97694974@binarylogic.com> References: <3D233574-0E6A-48F9-AD9A-109A97694974@binarylogic.com> Message-ID: On Wed, May 27, 2009 at 12:14 PM, Ben Johnson wrote: > Hi, > > For some reason, no matter what, my entire cucumber suite is ran after every > auto test. Is there a way to make auto test ignore cucumber all together? > > Thanks for your help. As Ben Mabey points out this is not normal RSpec behavior. Now you don't happen to be using the recently released autotest-mac gem are you? It does automatically run scenarios, and I'd like to be able to control that as well. BTW autotest-mac seems to have almost immediately split into two separate gems autotest-fsevent http://github.com/svoop/autotest-fsevent/tree and autotest-growl http://github.com/svoop/autotest-growl/tree I opened a ticket asking for some means to control whether or not it tries to run Cucumber scenarios https://forge.bitcetera.com/issues/show/18 -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From rick.denatale at gmail.com Thu May 28 14:47:03 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 28 May 2009 14:47:03 -0400 Subject: [rspec-users] Disabling cucumber for autotest In-Reply-To: <6ffb72010905281031g23d68a3fqfbb4273232ca2f88@mail.gmail.com> References: <3D233574-0E6A-48F9-AD9A-109A97694974@binarylogic.com> <6ffb72010905281031g23d68a3fqfbb4273232ca2f88@mail.gmail.com> Message-ID: On Thu, May 28, 2009 at 1:31 PM, Ben Lovell wrote: > On Thu, May 28, 2009 at 6:05 PM, Rick DeNatale > wrote: >> >> Now you don't happen to be using the recently released autotest-mac >> gem are you? It does automatically run scenarios, and I'd like to be >> able to control that as well. >> >> Rick DeNatale It seems to always try to run Cucumber scenarios but only after specs have passed. Looking at the code in the gem it seems to control whether or not to run scenarios under control of an instance variable named surprisingly enough @run_scenarios It initializes this to false with it first installs the :run_command hook, but then in the :ran_command hook it sets it to true as soon as the specs run with no failures -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From tom at experthuman.com Fri May 29 05:11:56 2009 From: tom at experthuman.com (Tom Stuart) Date: Fri, 29 May 2009 10:11:56 +0100 Subject: [rspec-users] Specifying mocks Message-ID: Hi, One of the problems with mocks, as far as I can tell, is that they might go out of sync with the real object they're mocking. Is it possible and sane to detect this by running each spec against its corresponding mock? Does anyone already do this? For example: your Account object has a particular behavioural specification; you perhaps have some convenient helper method for creating a mock Account which conforms to that specification with various stubbed responses; and the specifications of other objects use that mock Account when describing behaviours which involve interaction with Accounts. What happens when you want to change the behaviour of Account? Naively, you update the specification and implementation of Account, your specs all pass, and you think you're done, except you're not: the Account mock is now misrepresenting the behaviour of Account all over the system, with the result that you've got failures that the specs don't reveal. Of course you have integration tests that will show these failures at a higher level but it doesn't feel fundamentally like a problem that RSpec has no business solving. Why not establish a base case for RSpec's inductive demonstration of correctness by running the Account spec against the standard Account mock? That way you'll automatically be told, by RSpec, whenever the actual behaviour of your mock doesn't match the specified behaviour of the mocked object, and you can let your integration tests concentrate on the hard stuff (stateful interactions between many objects) instead of checking that you haven't forgotten to keep your specs up-to-date. This assumes a priori that it makes engineering sense to have a globally-available DRY mock helper for each object (i.e. class) rather than building up your mocks piecemeal in every spec; I've found that I always start off a project by doing the latter but end up refactoring into the former once I get sick of mocking the same stuff over and over again. Maybe that's the wrong way to do things altogether, or maybe this is a process issue that I've misunderstood (i.e. the answer is always to use integration tests to detect this kind of failure), so stop me if I'm being stupid. Cheers, -Tom From dchelimsky at gmail.com Fri May 29 07:10:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 May 2009 06:10:42 -0500 Subject: [rspec-users] Specifying mocks In-Reply-To: References: Message-ID: <57c63afe0905290410g322cbf36iabf5ecba07459bd9@mail.gmail.com> Hi Tom, On Fri, May 29, 2009 at 4:11 AM, Tom Stuart wrote: > Hi, > > One of the problems with mocks, as far as I can tell, is that they might go > out of sync with the real object they're mocking. Have you read "Mock Roles, not Objects"? http://mockobjects.com/files/mockrolesnotobjects.pdf > Is it possible and sane to > detect this by running each spec against its corresponding mock? Does anyone > already do this? "it's corresponding mock" suggests a single mock object for each real implementation. There's nothing stopping you from writing your own mock objects to play this role. IMO, this is not what a dynamic mock objects framework is for. > For example: your Account object has a particular behavioural specification; > you perhaps have some convenient helper method for creating a mock Account > which conforms to that specification with various stubbed responses; and the > specifications of other objects use that mock Account when describing > behaviours which involve interaction with Accounts. What happens when you > want to change the behaviour of Account? Naively, you update the > specification and implementation of Account, your specs all pass, and you > think you're done, except you're not: the Account mock is now > misrepresenting the behaviour of Account all over the system, with the > result that you've got failures that the specs don't reveal. First of all, let's make a distinction between behaviour and method signatures. Just because two objects sport the same methods doesn't mean they behave the same way. In order to verify that a mock Account honors the same contract as a real Account, you'd have to have some very general specs like "Account balance should be an instance of the Money class." This would not really get you very far in terms of specifying the real account, and it's exactly the opposite of what we're getting at with BDD - focus on what an object does (behaviour), not what it is (structure). So really, what we're talking about is concern over method signatures straying. Theoretically, this could be solved with some audit mechanism, but then we're tying mocks to specific objects. What about when we use mocks in their most powerful way, to specify an object's contract with polymorphic collaborators? Consider the case of an Account in a banking application. Checking accounts and savings accounts have some significant differences in terms of their behaviour, yet a Transfer will probably only use the parts that are common to both: def transfer(source_account, target_account, amount) source_account.debit(amount) target_account.credit(amount) end an admittedly naive implementation, but it demonstrates the point. The source account may be a checking account. It may be a savings account. It may be a checking account with overdraw privileges. It may be a checking account with overdraw privileges that draw on the target account. Etc, etc. What mocks/stubs let us do here is set up the context for each example exactly how we want it to be, with objects that respond how we program them to, but aren't necessarily of a specific class. > Of course you have integration tests that will show these failures at a > higher level but it doesn't feel fundamentally like a problem that RSpec has > no business solving. My personal opinion is that RSpec has no business solving this :) Personal opinion aside, let's say we set out to solve this. We'd need some auditing mechanism that says the object being mocked has all the same APIs as the mock object. For RSpec, or any other Ruby framework, we have a serious obstacle to being able to do this universally and reliably: Ruby We're dealing with a language that lets us modify an object's behaviour on the fly. This means that it is entirely possible (and quite common) for a given method not to exist after a class definition is loaded, but to be added later in the process via a dynamic method definition or a mixin. If the point at which we do the audit, that method has not yet been added to the object, we're screwed. Would that be a problem all the time? Certainly not. But it means we'd be depending on something that is not very reliable and/or restricting our use of Ruby's most powerful features. > Why not establish a base case for RSpec's inductive > demonstration of correctness by running the Account spec against the > standard Account mock? That way you'll automatically be told, by RSpec, > whenever the actual behaviour of your mock doesn't match the specified > behaviour of the mocked object, and you can let your integration tests > concentrate on the hard stuff (stateful interactions between many objects) > instead of checking that you haven't forgotten to keep your specs > up-to-date. > > This assumes a priori that it makes engineering sense to have a > globally-available DRY mock helper for each object (i.e. class) rather than > building up your mocks piecemeal in every spec; I've found that I always > start off a project by doing the latter but end up refactoring into the > former once I get sick of mocking the same stuff over and over again. Maybe > that's the wrong way to do things altogether, or maybe this is a process > issue that I've misunderstood (i.e. the answer is always to use integration > tests to detect this kind of failure), so stop me if I'm being stupid. The most powerful use of mocks is as a design tool, allowing you to focus on the object at hand and invent its collaborators as you go, without having to go out and develop them just yet. As you suggest above, even in your own process, you tend to build up mocks piecemeal and then refactor towards a single, global helper to create a mock Account (for example). This lets you keep focus on the task at hand, and refactor to eliminate duplication as the duplication appears. Seems like a perfectly viable approach to me. Of course that doesn't solve the auditing problem I describe above, and it also pushes you towards a one to one mapping between mocked object and mock object, which reduces the power of mocks in terms of polymorphism. So that's my 1.8 cents (recession, and all). Looking forward to some other opinions. Cheers, David > Cheers, > -Tom From dchelimsky at gmail.com Fri May 29 07:54:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 May 2009 06:54:16 -0500 Subject: [rspec-users] nil object error In-Reply-To: <09CAF7492BB188429DDFABCD8218F283013F7021@awww.armis.com> References: <09CAF7492BB188429DDFABCD8218F283013F7021@awww.armis.com> Message-ID: <57c63afe0905290454o5f140489h8901008595f1afe8@mail.gmail.com> On Fri, May 29, 2009 at 6:26 AM, Diwakar, ANGLER - EIT wrote: > -- Controller ---- > > def create > > ?@avatars = Avatar.find( :all, > ??????????????????????????? :conditions => { :user_id => 0 } > ????????????????????????? ) > > ??? @avatars.concat( user.avatars ) > > end > > > --- spec --- > > describe UserAvatarsController do > > describe :create do > > before(:each) do > > @avatar = mock_model(Avatar) > @user = mock_model(User) > controller.stub!(:requires_user).and_return(@user) > Avatar.stub!(:find).and_return(@avatar) > User.stub(:avatar).and_return(@user) > Avatar.stub!(:concat).and_return(@user) > > end > > it "should create a new user avatar" do > Avatar.should_receive(:find).and_return(@avatar) > User.should_receive(:avatar).and_return(@user) > post :create > end > end > > end > > I am getting the below error > > --- Error --- > > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.avatars > > How should I spec this? What is the behaviour you're trying to specify here? The docstring says "it should create a user avatar," but the example code expects find on the Avatar class and avatar on the User class. And I can't tell how the create() code is actually creating anything. That aside, the nil error is happening because the user() method is returning nil (in user.avatars). You can fix that by changing this: controller.stub!(:requires_user).and_return(@user) to this: controller.stub!(:user).and_return(@user) Though you may need to also stub requires_user if it's in a before filter (which I think I remember from another thread on this), so you'd actually want: controller.stub!(:requires_user) controller.stub!(:user).and_return(@user) This way requires_user() doesn't do anything, and the user() method returns the mock user. Of course, it's going to need to respond to the avatars() method: @user.stub!(:avatars).and_return([@avatar]) or something like that. HTH, David From tom at experthuman.com Fri May 29 08:51:51 2009 From: tom at experthuman.com (Tom Stuart) Date: Fri, 29 May 2009 13:51:51 +0100 Subject: [rspec-users] Specifying mocks In-Reply-To: <57c63afe0905290410g322cbf36iabf5ecba07459bd9@mail.gmail.com> References: <57c63afe0905290410g322cbf36iabf5ecba07459bd9@mail.gmail.com> Message-ID: Hi David, On 29 May 2009, at 12:10, David Chelimsky wrote: > Have you read "Mock Roles, not Objects"? > "its corresponding mock" suggests a single mock object for each real > implementation. There's nothing stopping you from writing your own > mock objects to play this role. IMO, this is not what a dynamic mock > objects framework is for. Agreed -- I entirely concur that the main benefit of such a framework is the ability to speculatively mock collaborators (while thinking in terms of their role) before you have implemented them or perhaps even know what they are -- but in practice I find that these collaborating roles end up falling into one-one correspondence with actual classes, which doesn't seem to contradict the core message of "Mock Roles, not Objects". Maybe that just indicates I'm not working on designs that are sufficiently sophisticated, sufficiently polymorphic or sufficiently aspect-oriented to feel the burn of the divergence of concepts. Ultimately I think I'm agreeing with you, but perhaps just using the wrong word: I might better have described Account as a role rather than necessarily an object/class. The original point applies, namely "how can I be sure that my mock (for a given role) is in sync with my specification (of that role in the object(s) which perform it)"; instead of suggesting a single mock object for each real implementation, I'm suggesting a single mock object for each role. And speaking of using the wrong words: maybe what I actually mean is "specifying stubs" instead of "specifying mocks", in as much as those global helpers I talked about don't really return a "mock" at all, just a stub which has been prepared for use as a mock in any spec which requires it (cf Spec::Rails' mock_model). But any such spec will exercise those stubbed methods which are important for the role's behaviour, assuming one expectation per example, so it's important that the stubbed behaviour accurately reflects reality, and unless you are rigorous about keeping the stubbed behaviour updated to reflect the specified behaviour they'll drift out of sync and the specs won't be making the right assumptions about collaborators any more. > Just because two objects sport the same methods doesn't > mean they behave the same way. In order to verify that a mock Account > honors the same contract as a real Account, you'd have to have some > very general specs like "Account balance should be an instance of the > Money class." Why? I can't quite get my head around the issues of stubbing stateful interactions, which is preventing me from thinking of a good example, but what's (abstractly) wrong with: class Account def credit(cents) self.balance = self.balance + cents return self.balance end end describe 'Account#credit' do before(:each) do @account = Account.new(:balance => 100) end specify { @account.credit(10).should == 110 } end def mock_account account = mock('Account') account.stub!(:credit).with(10).and_return(110) return account end It seems like there's nothing stopping you stubbing the detailed behaviour of Account in a way that will allow the stub to pass the specs -- it's just that the stub is only good for the canned responses, necessarily a strict subset of the real implementation's behaviour over all inputs. Given the above, I could easily change spec and implementation to class Account def credit(cents) self.balance = self.balance - cents return self.balance end end describe 'Account#credit' do before(:each) do @account = Account.new(:balance => 100) end specify { @account.credit(10).should == 90 } end and the spec will pass, and so will every spec that's using my Account stub for mocking Account behaviour, but the system as a whole is screwed, right? Because the behaviour's changed but the stub (plus the behaviour that is mocked on it by other specs) has stayed the same. > So really, what we're talking about is concern over method > signatures straying. Sorry, that's not what I meant at all: I intended to talk specifically about cases where the signature stays the same but the underlying behaviour changes. > What about when we use mocks in their most powerful way, to specify > an object's > contract with polymorphic collaborators? In that case there's a role (an object fulfilling that contract) for which you might end up creating a shared stub that's used in the specifications of all objects which act as the client in that specific collaboration. Individual examples in those specifications will set individual expectations on that stub in order to specify the interaction, presumably clobbering a stubbed method in the process, but the remaining stubbed methods will be exercised during each example, which gives you a way of knowing that the mocked behaviour lines up with what's been canned in the stub. You can't do much about the detailed, piecemeal mocking that happens inside such specs -- aside from the aforementioned reliance upon the parts of the stub's canned behaviour for which an expectation hasn't explicitly been set, there's no way to check that the expectations match up with the specification(s) of the object(s) which performs the role you're mocking, so you have to rely on integration specs -- but if all of these specs are starting with the same stub, you can at least run the role's spec over the stub to make sure it's accurate. Why wouldn't you? > Personal opinion aside, let's say we set out to solve this. We'd need > some auditing mechanism that says the object being mocked has all the > same APIs as the mock object. As I say, that's not what I meant, and it's probably my fault for saying "mock". What I meant is that a stub can provide a snapshot of all of the behaviour of an object (or role), and I often end up in the situation where the same stub is being used as a starting point for mocking interactions in lots of specs, but right now there's no mechanism for spotting when that stub is spreading misinformation because it's become desynchronised from the specification of the object (or role) which it represents. For example: Spec::Rails' mock_model. (Should be called stub_model but isn't.) It's very convenient because it stubs out a bunch of "behaviour" that you'd otherwise have to stub out yourself in all of your model specs before you started adding expectations. It conforms to a tiny subset of ActiveRecord::Base's notional specification: @record.should_receive(:new_record?).and_return(false) etc. If "the ActiveRecord::Base spec" changes, mock_model needs updating, but we can't discover that automatically because we never run "the ActiveRecord::Base spec" over the object that's returned by mock_model. (This is a stupid example because there is no ActiveRecord::Base spec, but you get the idea.) So is my fundamental mistake that I'm being lazy by trying to concentrate all of this stub setup in one helper method instead of doing piecemeal stubbing in every individual spec that might care? It seems superficially like good practice to concentrate all of the detail in one place like this, so that when a role's behaviour changes you just update one piece of stub setup to reflect the change rather than chase around the specs of every single collaborator, but maybe that's just serving to obscure the problem that all of the actual mocking has to happen in the individual specs and that this is the stuff you really care about, not the behaviour of the shared stub? Cheers, -Tom From lists at ruby-forum.com Fri May 29 21:13:37 2009 From: lists at ruby-forum.com (Shane Hayes) Date: Sat, 30 May 2009 03:13:37 +0200 Subject: [rspec-users] cucumber-java In-Reply-To: References: <8d961d900905161432v4405c8dr8f34415c1d58f2cf@mail.gmail.com> Message-ID: Raymond Barlow wrote: ... > > Oh, and another question, is the above command the correct thing to run > to > see the examples run? And if so, do I run it in examples/simple or > examples/simple/features? > > /Raymond > > 2009/5/18 Trond Marius ?vstetun Hi Raymond. Did you get it to run on your system? I have not had success yet, so I would get some hope if you got it to run on yours. Regards, Shane -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Sat May 30 04:10:02 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 30 May 2009 09:10:02 +0100 Subject: [rspec-users] Specifying mocks In-Reply-To: References: <57c63afe0905290410g322cbf36iabf5ecba07459bd9@mail.gmail.com> Message-ID: <1FD45317-5085-4762-ADE4-850AAF57EEE6@mattwynne.net> On 29 May 2009, at 13:51, Tom Stuart wrote: > Hi David, > > On 29 May 2009, at 12:10, David Chelimsky wrote: >> Have you read "Mock Roles, not Objects"? >> "its corresponding mock" suggests a single mock object for each real >> implementation. There's nothing stopping you from writing your own >> mock objects to play this role. IMO, this is not what a dynamic mock >> objects framework is for. > > Agreed -- I entirely concur that the main benefit of such a > framework is the ability to speculatively mock collaborators (while > thinking in terms of their role) before you have implemented them or > perhaps even know what they are -- but in practice I find that these > collaborating roles end up falling into one-one correspondence with > actual classes, which doesn't seem to contradict the core message of > "Mock Roles, not Objects". Maybe that just indicates I'm not working > on designs that are sufficiently sophisticated, sufficiently > polymorphic or sufficiently aspect-oriented to feel the burn of the > divergence of concepts. > > Ultimately I think I'm agreeing with you, but perhaps just using the > wrong word: I might better have described Account as a role rather > than necessarily an object/class. The original point applies, namely > "how can I be sure that my mock (for a given role) is in sync with > my specification (of that role in the object(s) which perform it)"; > instead of suggesting a single mock object for each real > implementation, I'm suggesting a single mock object for each role. > > And speaking of using the wrong words: maybe what I actually mean is > "specifying stubs" instead of "specifying mocks", in as much as > those global helpers I talked about don't really return a "mock" at > all, just a stub which has been prepared for use as a mock in any > spec which requires it (cf Spec::Rails' mock_model). But any such > spec will exercise those stubbed methods which are important for the > role's behaviour, assuming one expectation per example, so it's > important that the stubbed behaviour accurately reflects reality, > and unless you are rigorous about keeping the stubbed behaviour > updated to reflect the specified behaviour they'll drift out of sync > and the specs won't be making the right assumptions about > collaborators any more. > >> Just because two objects sport the same methods doesn't >> mean they behave the same way. In order to verify that a mock Account >> honors the same contract as a real Account, you'd have to have some >> very general specs like "Account balance should be an instance of the >> Money class." > > Why? I can't quite get my head around the issues of stubbing > stateful interactions, which is preventing me from thinking of a > good example, but what's (abstractly) wrong with: > > class Account > def credit(cents) > self.balance = self.balance + cents > return self.balance > end > end > > describe 'Account#credit' do > before(:each) do > @account = Account.new(:balance => 100) > end > specify { @account.credit(10).should == 110 } > end > > def mock_account > account = mock('Account') > account.stub!(:credit).with(10).and_return(110) > return account > end > > It seems like there's nothing stopping you stubbing the detailed > behaviour of Account in a way that will allow the stub to pass the > specs -- it's just that the stub is only good for the canned > responses, necessarily a strict subset of the real implementation's > behaviour over all inputs. > > Given the above, I could easily change spec and implementation to > > class Account > def credit(cents) > self.balance = self.balance - cents > return self.balance > end > end > > describe 'Account#credit' do > before(:each) do > @account = Account.new(:balance => 100) > end > specify { @account.credit(10).should == 90 } > end > > and the spec will pass, and so will every spec that's using my > Account stub for mocking Account behaviour, but the system as a > whole is screwed, right? Because the behaviour's changed but the > stub (plus the behaviour that is mocked on it by other specs) has > stayed the same. > >> So really, what we're talking about is concern over method >> signatures straying. > > Sorry, that's not what I meant at all: I intended to talk > specifically about cases where the signature stays the same but the > underlying behaviour changes. > >> What about when we use mocks in their most powerful way, to specify >> an object's >> contract with polymorphic collaborators? > > In that case there's a role (an object fulfilling that contract) for > which you might end up creating a shared stub that's used in the > specifications of all objects which act as the client in that > specific collaboration. Individual examples in those specifications > will set individual expectations on that stub in order to specify > the interaction, presumably clobbering a stubbed method in the > process, but the remaining stubbed methods will be exercised during > each example, which gives you a way of knowing that the mocked > behaviour lines up with what's been canned in the stub. > > You can't do much about the detailed, piecemeal mocking that happens > inside such specs -- aside from the aforementioned reliance upon the > parts of the stub's canned behaviour for which an expectation hasn't > explicitly been set, there's no way to check that the expectations > match up with the specification(s) of the object(s) which performs > the role you're mocking, so you have to rely on integration specs -- > but if all of these specs are starting with the same stub, you can > at least run the role's spec over the stub to make sure it's > accurate. Why wouldn't you? > >> Personal opinion aside, let's say we set out to solve this. We'd need >> some auditing mechanism that says the object being mocked has all the >> same APIs as the mock object. > > As I say, that's not what I meant, and it's probably my fault for > saying "mock". What I meant is that a stub can provide a snapshot of > all of the behaviour of an object (or role), and I often end up in > the situation where the same stub is being used as a starting point > for mocking interactions in lots of specs, but right now there's no > mechanism for spotting when that stub is spreading misinformation > because it's become desynchronised from the specification of the > object (or role) which it represents. > > For example: Spec::Rails' mock_model. (Should be called stub_model > but isn't.) It's very convenient because it stubs out a bunch of > "behaviour" that you'd otherwise have to stub out yourself in all of > your model specs before you started adding expectations. It conforms > to a tiny subset of ActiveRecord::Base's notional specification: > @record.should_receive(:new_record?).and_return(false) etc. If "the > ActiveRecord::Base spec" changes, mock_model needs updating, but we > can't discover that automatically because we never run "the > ActiveRecord::Base spec" over the object that's returned by > mock_model. (This is a stupid example because there is no > ActiveRecord::Base spec, but you get the idea.) > > So is my fundamental mistake that I'm being lazy by trying to > concentrate all of this stub setup in one helper method instead of > doing piecemeal stubbing in every individual spec that might care? > It seems superficially like good practice to concentrate all of the > detail in one place like this, so that when a role's behaviour > changes you just update one piece of stub setup to reflect the > change rather than chase around the specs of every single > collaborator, but maybe that's just serving to obscure the problem > that all of the actual mocking has to happen in the individual specs > and that this is the stuff you really care about, not the behaviour > of the shared stub? On my team, we've built up a StubFactory which works a lot like the FactoryGirl plug-in and creates 'stock' stubbed objects which we use when we need a generic stub of a given role. This is a useful tool, and it saves a lot of noise in our tests when we just need something that quacks enough like an Account or whatever in order to let a test run through, so that you can focus on the detail of the *specific* collaboration behaviour you're concerned about in that test. So that's one part of this - I definitely think it's pragmatic and valuable to factor out common mocking setup into a single place if that's what you seem to be duplicating a lot in your tests. The auditing though... I've been around the loop with this one myself - before I really discovered the value of acceptance tests I was really keen on the idea, but to be honest this just isn't a problem I come across very often now. By the time my acceptance tests have pointed me down to the unit tests / classes I need to work on, I'm (especially with a pair to work with) sufficiently focussed to remember enough the of collaborations between objects and keep them in step with the mocks / stubs. If I do forget something, I get pretty rapid feedback when I step back up a level and run the acceptance tests. I appreciate that the argument 'I can keep all the collaboration in my head' is a bit wooly - but equally if the collaborations you're mocking are so complex that you can't, then perhaps that in itself is a whiff that something is wrong with your design? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From zach.dennis at gmail.com Sat May 30 21:07:14 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 30 May 2009 21:07:14 -0400 Subject: [rspec-users] Any way to continue on Assertion Failure In-Reply-To: <294057C5-CACC-4DE2-BDD2-C8C134A9977F@mattwynne.net> References: <4A1C7C40.2020501@employees.org> <6747A39A-4B9D-455C-B6DB-92814A906AA8@leviston.net> <294057C5-CACC-4DE2-BDD2-C8C134A9977F@mattwynne.net> Message-ID: <85d99afe0905301807l6355a1bbwd6748ef8b5e1af16@mail.gmail.com> On Wed, May 27, 2009 at 4:07 AM, Matt Wynne wrote: > > On 27 May 2009, at 03:38, Julian Leviston wrote: > >> On 27/05/2009, at 9:33 AM, Gary Lin wrote: >> >>> Hi, >>> >>> I wonder if there is any way to tell the test script to continue even >>> when encountering an assertion failure? ?The reason I am asking this is >>> because I have a test flow that can take a long time to run and it would be >>> very useful if I can perform all verification at the end of test flow in one >>> shot rather than fail one and exit immediately. ?Of course, I could break >>> each verification point into separate test case, but then it will double or >>> triple the overall execution time. ?Does RSpec support this? >>> >> >> Isn't this usual behaviour? >> >> Julian. > > Yeah I'm a little confused by the question (and David's response) so maybe > I've misunderstood something. Normal RSpec test runs will catch all the test > failures and report them at the end of the run. I wonder whether the OP is > talking about a situation where the interaction with the system takes a long > time, so that using lots of examples of the desired behaviour causes that > interaction to be run several times making the whole run very slow. > > I also wonder whether he's just thinking in the test/unit mindset, which I > see a lot, where you have examples like this > > > it "should do foo and bar" do > ?set_up_state > ?do_something_to_system_under_test > > ?assert_that_foo_was_done > ?assert_that_bar_was_done > end > I don't know that I would call this an antipattern unless set_up_state is duplicated across examples. I usually don't factor things out of an example unless it's duplicated in another example (then I extract to a before) or I'm working in a specific context (which I always give a before since it provides meaning of the context in an explicit way). > > Here's my normal RSpec flow: > > before(:each) do > ?set_up_state > ?do_something_to_system_under_test > end > > it "should have done foo" do > ?assert_that_foo_was_done > end > > it "should have done bar" do > ?assert_that_bar_was_done > end Most of the time I would leave the "do_something_to_system_under_test" inside each example. I find it easier to read, and a more useful example (since you don't have to go look else where to see how the method is called), and it becomes easier to maintain should the object change in a way that requires a specific pre-condition to be introduced that aren't needed by the other examples (you don't have to modify every other example). another 2 cents to throw in the water fountain, > > if set_up_state and/or do_something_to_system_under_test take ages, you > could use a before(:all) block instead, but that comes with obvious leaky > state disadvantages. > > Matt Wynne > http://beta.songkick.com > http://blog.mattwynne.net > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From Jarmo.P at gmail.com Sun May 31 16:59:25 2009 From: Jarmo.P at gmail.com (Jarmo Pertman) Date: Sun, 31 May 2009 13:59:25 -0700 (PDT) Subject: [rspec-users] autospec runs failing specs forever in endless loop Message-ID: <323c176b-321f-4197-ba30-2f6c02112ed1@t21g2000yqi.googlegroups.com> I wanted to start using autospec on my little (non-Rails) project. I'm on Windows XP and have used it some time ago successfully (on the same PC), although I've updated many gems in the meantime (RSpec for example among others). In short, everything is fine when all specs pass, but if some fails, then autospec won't stop running failing specs again even if no files are changed. I expect it to run specs again only if some file gets modified. It's kinda irritating when it doesn't stop and is by no means helping any development :/ Also, when I fix the failing spec then it will run it only once and then run whole suit once and stops as expected. Any ideas what might cause this distracting behaviour? BR, Jarmo From dchelimsky at gmail.com Sun May 31 17:56:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 31 May 2009 16:56:48 -0500 Subject: [rspec-users] autospec runs failing specs forever in endless loop In-Reply-To: <323c176b-321f-4197-ba30-2f6c02112ed1@t21g2000yqi.googlegroups.com> References: <323c176b-321f-4197-ba30-2f6c02112ed1@t21g2000yqi.googlegroups.com> Message-ID: <57c63afe0905311456m28f97a25tb3f915aa21a57f9e@mail.gmail.com> On Sun, May 31, 2009 at 3:59 PM, Jarmo Pertman wrote: > I wanted to start using autospec on my little (non-Rails) project. I'm > on Windows XP and have used it some time ago successfully (on the same > PC), although I've updated many gems in the meantime (RSpec for > example among others). > > In short, everything is fine when all specs pass, but if some fails, > then autospec won't stop running failing specs again even if no files > are changed. I expect it to run specs again only if some file gets > modified. It's kinda irritating when it doesn't stop and is by no > means helping any development :/ > > Also, when I fix the failing spec then it will run it only once and > then run whole suit once and stops as expected. > > Any ideas what might cause this distracting behaviour? Do you have "--format failing_examples" in spec/spec.opts? If so, rspec saves a file with a list of the failing examples in it, which would trigger autotest to run again unless that file is explicitly ignored. HTH, David > > BR, > Jarmo