From lists at ruby-forum.com Thu Jan 1 06:31:17 2009 From: lists at ruby-forum.com (Jesse Crockett) Date: Thu, 1 Jan 2009 12:31:17 +0100 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> Message-ID: Jesse Crockett wrote: > I hope to be on my feet after a few more basic questions.. I'm sorry, but this is beginning to feel like kicking myself in the head. === here is what I'm working with http://github.com/fudgestudios/bort/tree/master === Errors FF 1) NoMethodError in 'bidding on an item should be allowed with a credit' You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.new_record? spec/controllers/auction_controller_spec.rb:23: spec/controllers/auction_controller_spec.rb:6: 2) NoMethodError in 'bidding on an item should require a credit' You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.new_record? spec/controllers/auction_controller_spec.rb:17: spec/controllers/auction_controller_spec.rb:6: Finished in 0.074996 seconds 2 examples, 2 failures === here is my controller action def bid @bid = Bid.new(params[:bid]) @bid.save end === here is my test require File.dirname(__FILE__) + '/../spec_helper' include ApplicationHelper include UsersHelper include AuthenticatedTestHelper describe "bidding on an item" do controller_name :items before(:each) do @user = mock_user stub!(:current_user).and_return(@user) end it "should require a credit" do @user.stub!(:credits).and_return(0) post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point => 1 } assigns[:bid].should_not be_new_record end it "should be allowed with a credit" do @user.stub!(:credits).and_return(1) post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point => 1 } assigns[:bid].should be_new_record end end === spec_helper http://github.com/fudgestudios/bort/tree/master/spec/spec_helper.rb It's very disheartening to wake for work at 3 a.m. and accomplish nothing for the day. Please understand. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Jan 1 12:24:27 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Jan 2009 11:24:27 -0600 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> Message-ID: <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> On Thu, Jan 1, 2009 at 5:31 AM, Jesse Crockett wrote: > Jesse Crockett wrote: >> I hope to be on my feet after a few more basic questions.. > > I'm sorry, but this is beginning to feel like kicking myself in the > head. > > === here is what I'm working with > http://github.com/fudgestudios/bort/tree/master > > === Errors > FF > > 1) > NoMethodError in 'bidding on an item should be allowed with a credit' > You have a nil object when you didn't expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.new_record? > spec/controllers/auction_controller_spec.rb:23: > spec/controllers/auction_controller_spec.rb:6: > > 2) > NoMethodError in 'bidding on an item should require a credit' > You have a nil object when you didn't expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.new_record? > spec/controllers/auction_controller_spec.rb:17: > spec/controllers/auction_controller_spec.rb:6: > > Finished in 0.074996 seconds > > 2 examples, 2 failures > > > === here is my controller action > > def bid > > @bid = Bid.new(params[:bid]) > @bid.save > > end > > === here is my test > > require File.dirname(__FILE__) + '/../spec_helper' > include ApplicationHelper > include UsersHelper > include AuthenticatedTestHelper > > describe "bidding on an item" do > controller_name :items > > before(:each) do > @user = mock_user > stub!(:current_user).and_return(@user) Calling stub! with no receiver means it's being called on the example itself. Assuming you're using RestfulAuth, you'll want this to be on the controller itself: controller.stub!(:current_user).and_return(@user) Although, looking at the 'bid' action, it doesn't appear to be doing anything with the user yet, so I'm not sure why this is here at this point. > end > > it "should require a credit" do > @user.stub!(:credits).and_return(0) > post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point > => 1 } If you're using the mock_user, which uses mock_model (I'm assuming here, since you're not posting complete files), > assigns[:bid].should_not be_new_record I'm guessing this is line 17 and the "assigns[:bid] line below is 23. What this means is that assigns[:bid] is nil, which means that somehow the action is failing to generate the bit object. I'm at a bit of a loss as to why that might be, but that's what is indicated. HTH, David > end > > it "should be allowed with a credit" do > @user.stub!(:credits).and_return(1) > post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point > => 1 } > assigns[:bid].should be_new_record > end > > end > > === spec_helper > http://github.com/fudgestudios/bort/tree/master/spec/spec_helper.rb > > It's very disheartening to wake for work at 3 a.m. and accomplish > nothing for the day. Please understand. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Jan 1 12:32:30 2009 From: lists at ruby-forum.com (Jesse Crockett) Date: Thu, 1 Jan 2009 18:32:30 +0100 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> Message-ID: I've finally made some progress thanks to Otto at stackoverflow. I'm very exited. Thanks so much for trying to help. If you've got a minute, please browse my question and Otto's answer, and correct me if I seem to be going in the wrong direction. http://stackoverflow.com/questions/404887 Yee haw, my first passing spec! -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Jan 1 12:48:22 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Jan 2009 11:48:22 -0600 Subject: [rspec-users] My first tests, backwards. Please help In-Reply-To: References: <1ebf5a4d0812301643t356fb558rcc1ab2385b621797@mail.gmail.com> <57c63afe0812310718t2b4c85bx310e517be4bf1e54@mail.gmail.com> <57c63afe0901010924y106590b4v34395ee8fe285083@mail.gmail.com> Message-ID: <57c63afe0901010948s4f0d551fl1a735a6abbcfba82@mail.gmail.com> On Thu, Jan 1, 2009 at 11:32 AM, Jesse Crockett wrote: > I've finally made some progress thanks to Otto at stackoverflow. I'm > very exited. Thanks so much for trying to help. If you've got a > minute, please browse my question and Otto's answer, and correct me if I > seem to be going in the wrong direction. > > http://stackoverflow.com/questions/404887 I responded there to keep things in context. Cheers, David > > Yee haw, my first passing spec! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at markrichman.com Thu Jan 1 14:40:34 2009 From: mark at markrichman.com (Mark A. Richman) Date: Thu, 1 Jan 2009 14:40:34 -0500 Subject: [rspec-users] MockExpectationError with restful-authentication In-Reply-To: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> References: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> Message-ID: Thanks that helped! Now I'm getting these errors...any ideas? Looks like something cookie related? http://pastie.org/350148 On Wed, Dec 31, 2008 at 2:43 PM, Pat Maddox wrote: > You didn't tell your mock object about the enabled? method. You need > to stub it out (prob set it to true) > > Pat > > > On 12/31/08, Mark A. Richman wrote: > > Hi there...this is my first time using rspec and rspec-rails. When I run > > `rake spec`, I get this type of error over and over...what does it mean, > and > > how can I correct it? > > > > Thanks, > > Mark > > > > 9) > > Spec::Mocks::MockExpectationError in 'SessionController on successful > login, > > my request cookie token is valid, and ask not to be remembered sets an > auth > > cookie' > > Mock 'User_1' received unexpected message :enabled? with (no args) > > > /Users/mark/rails_apps/ExamRoom/app/controllers/session_controller.rb:14:in > > `create' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > > `send' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > > `perform_action_without_filters' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in > > `call_filters' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in > > `perform_action_without_benchmark' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in > > `perform_action_without_caching' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in > > `perform_action' > > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in > > `cache' > > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in > > `cache' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in > > `perform_action' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > > `send' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > > `process_without_filters' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in > > `process_without_session_management_support' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in > > `process_without_test' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in > > `process' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in > > `process' > > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in > > `post' > > ./spec/controllers/session_controller_spec.rb:15:in `do_create' > > ./spec/controllers/session_controller_spec.rb:55: > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jan 2 05:00:52 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Jan 2009 04:00:52 -0600 Subject: [rspec-users] MockExpectationError with restful-authentication In-Reply-To: References: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> Message-ID: <57c63afe0901020200m2602cf0fm27a661bf27ecf6d1@mail.gmail.com> On Thu, Jan 1, 2009 at 1:40 PM, Mark A. Richman wrote: > Thanks that helped! Now I'm getting these errors...any ideas? Looks like > something cookie related? > > http://pastie.org/350148 Only the first 2 look cookie related to me. The rest seem like typos - either things that you changed after generating the restful auth material (like redirecting to "/dashboard" instead of "/") or perhaps there are typos in the generated specs ("session" vs "sessions"). In most of these cases, you should be able to see from the failure messages what the discrepancies are and you just need to choose whether the specs are correct or the code is correct and adjust appropriately. HTH, David > > On Wed, Dec 31, 2008 at 2:43 PM, Pat Maddox wrote: >> >> You didn't tell your mock object about the enabled? method. You need >> to stub it out (prob set it to true) >> >> Pat >> >> >> On 12/31/08, Mark A. Richman wrote: >> > Hi there...this is my first time using rspec and rspec-rails. When I run >> > `rake spec`, I get this type of error over and over...what does it mean, >> > and >> > how can I correct it? >> > >> > Thanks, >> > Mark >> > >> > 9) >> > Spec::Mocks::MockExpectationError in 'SessionController on successful >> > login, >> > my request cookie token is valid, and ask not to be remembered sets an >> > auth >> > cookie' >> > Mock 'User_1' received unexpected message :enabled? with (no args) >> > >> > /Users/mark/rails_apps/ExamRoom/app/controllers/session_controller.rb:14:in >> > `create' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in >> > `send' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in >> > `perform_action_without_filters' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in >> > `call_filters' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in >> > `perform_action_without_benchmark' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in >> > `perform_action_without_rescue' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in >> > `perform_action_without_rescue' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in >> > `perform_action_without_caching' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in >> > `perform_action' >> > >> > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in >> > `cache' >> > >> > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in >> > `cache' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in >> > `perform_action' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in >> > `send' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in >> > `process_without_filters' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in >> > `process_without_session_management_support' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in >> > `process_without_test' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in >> > `process' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in >> > `process' >> > >> > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in >> > `post' >> > ./spec/controllers/session_controller_spec.rb:15:in `do_create' >> > ./spec/controllers/session_controller_spec.rb:55: >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 mark at markrichman.com Fri Jan 2 06:52:20 2009 From: mark at markrichman.com (Mark A. Richman) Date: Fri, 2 Jan 2009 06:52:20 -0500 Subject: [rspec-users] MockExpectationError with restful-authentication In-Reply-To: <57c63afe0901020200m2602cf0fm27a661bf27ecf6d1@mail.gmail.com> References: <810a540e0812311143u174d6526t7b36fae9e47fb369@mail.gmail.com> <57c63afe0901020200m2602cf0fm27a661bf27ecf6d1@mail.gmail.com> Message-ID: Thanks! That seems to have knocked out all but 4 errors. I'll keep banging away...this is fun! :) Best, Mark On Fri, Jan 2, 2009 at 5:00 AM, David Chelimsky wrote: > On Thu, Jan 1, 2009 at 1:40 PM, Mark A. Richman > wrote: > > Thanks that helped! Now I'm getting these errors...any ideas? Looks like > > something cookie related? > > > > http://pastie.org/350148 > > Only the first 2 look cookie related to me. The rest seem like typos - > either things that you changed after generating the restful auth > material (like redirecting to "/dashboard" instead of "/") or perhaps > there are typos in the generated specs ("session" vs "sessions"). > > In most of these cases, you should be able to see from the failure > messages what the discrepancies are and you just need to choose > whether the specs are correct or the code is correct and adjust > appropriately. > > HTH, > David > > > > > On Wed, Dec 31, 2008 at 2:43 PM, Pat Maddox wrote: > >> > >> You didn't tell your mock object about the enabled? method. You need > >> to stub it out (prob set it to true) > >> > >> Pat > >> > >> > >> On 12/31/08, Mark A. Richman wrote: > >> > Hi there...this is my first time using rspec and rspec-rails. When I > run > >> > `rake spec`, I get this type of error over and over...what does it > mean, > >> > and > >> > how can I correct it? > >> > > >> > Thanks, > >> > Mark > >> > > >> > 9) > >> > Spec::Mocks::MockExpectationError in 'SessionController on successful > >> > login, > >> > my request cookie token is valid, and ask not to be remembered sets an > >> > auth > >> > cookie' > >> > Mock 'User_1' received unexpected message :enabled? with (no args) > >> > > >> > > /Users/mark/rails_apps/ExamRoom/app/controllers/session_controller.rb:14:in > >> > `create' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > >> > `send' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in > >> > `perform_action_without_filters' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in > >> > `call_filters' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in > >> > `perform_action_without_benchmark' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > >> > `perform_action_without_rescue' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in > >> > `perform_action_without_rescue' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in > >> > `perform_action_without_caching' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in > >> > `perform_action' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in > >> > `cache' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in > >> > `cache' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in > >> > `perform_action' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > >> > `send' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in > >> > `process_without_filters' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in > >> > `process_without_session_management_support' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in > >> > `process_without_test' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in > >> > `process' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in > >> > `process' > >> > > >> > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in > >> > `post' > >> > ./spec/controllers/session_controller_spec.rb:15:in `do_create' > >> > ./spec/controllers/session_controller_spec.rb:55: > >> > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rubyphunk at googlemail.com Fri Jan 2 09:54:06 2009 From: rubyphunk at googlemail.com (rubyphunk) Date: Fri, 2 Jan 2009 06:54:06 -0800 (PST) Subject: [rspec-users] [ANN] RSpactor 1.0.1 Message-ID: <122b3d65-2454-4139-81db-30e2b9eabb9d@u18g2000pro.googlegroups.com> Hi all, I'm happy to announce the first public RSpactor release 1.0.1. RSpactor is an autotest/autospec like Mac OS X 10.5 gui application that takes care of your rspec examples. It watches for changes and runs these files. You can download 1.0.1 here: http://rspactorapp.com/assets/downloads/rspactor-1_0_1.dmg Read the blog post for more information: http://rubyphunk.com/articles/2009/01/02/happy-new-year-rspactor-1-0-1 lg // andreas From nas35_in at yahoo.com Fri Jan 2 11:01:29 2009 From: nas35_in at yahoo.com (Nasir Jamal) Date: Fri, 2 Jan 2009 08:01:29 -0800 (PST) Subject: [rspec-users] How to spec a controller method that involves an rjs redirect Message-ID: <190728.50003.qm@web38004.mail.mud.yahoo.com> Hi everyone, What is the best way to spec a controller method that involves an rjs redirect? Something like this def index ? url_to = @parent ? auction_bids_path(@parent)? : auctions_path ? render :update do |page| ??? page.redirect_to(url_to) ? end end I tried ?response.should have_rjs for the redirect but it didnt work. Any help would be appreciated. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From cougar2149 at gmail.com Fri Jan 2 12:54:11 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Fri, 2 Jan 2009 23:24:11 +0530 Subject: [rspec-users] How to write specs for already written parts of an application? Message-ID: Hi, What should be my approach to write specs for the parts of an applications which are already written? How should I start writing tests for those models, controllers which were not generated using rspec_controller or rspec_model? Would you please point me to some tutorials for writing RSpec tests? Is there any IRC channel for RSpec users? -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jan 2 13:02:57 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Jan 2009 12:02:57 -0600 Subject: [rspec-users] How to write specs for already written parts of an application? In-Reply-To: References: Message-ID: <57c63afe0901021002p62db2450w411c13b2ddf542a5@mail.gmail.com> On Fri, Jan 2, 2009 at 11:54 AM, waseem ahmad wrote: > Hi, > What should be my approach to write specs for the parts of an applications > which are already written? How should I start writing tests for those > models, controllers which were not generated using rspec_controller or > rspec_model? Would you please point me to some tutorials for writing RSpec > tests? Is there any IRC channel for RSpec users? #rspec on freenode Check out Michael Feathers' Working Effectively with Legacy Code for learning how to get untested apps under test. General idea is to do it gradually over time. When you have a new requirement, figure out what code needs to change to add that requirement, and write characterization tests (high level tests using a tool like Cucumber) that characterize what the application already does. The WELC book provides strategies for determining which tests to add, but the idea is to add the least number of tests to cover the code you want to change, so when you start changing it you have confidence you're not breaking things. Once you have the characterization tests in place, then you drive out the new code using TDD. HTH, David > > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From seatmanu at gmail.com Fri Jan 2 13:20:12 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 2 Jan 2009 10:20:12 -0800 Subject: [rspec-users] Cucumber namespace problem Message-ID: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> Hi I am having an issue with Cucumber where I am writing in one files some steps where rspec matcher do not seem to be accessible. So I have a file with my steps written like this require 'steputils' Given "some step description 1 " do SomeClass.post(args) end Given "some step description 2 that is slighty different for better readability " do SomeClass.post(args) end and in steputils I have class Steputils def self.post(args) args.should_not be_empty end end But the code breaks when trying to run args.should_not be_empty that are valid rspec matchers.. Seems like it is not recognizing it. I tried to include Cucumber and Spec as part of my class but still not working. Any idea what I need to do to make it work? This will help refactoring some of the steps that may have similar code Also, is there a way to see all the existing step using the cucumber methods? because when you have a lot it would be nice to have a way to describe them for documentation purpose (like Rake does for task) Thanks Emmanuel From aslak.hellesoy at gmail.com Fri Jan 2 13:34:58 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 2 Jan 2009 19:34:58 +0100 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> Message-ID: <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> On Fri, Jan 2, 2009 at 7:20 PM, Emmanuel Pinault wrote: > Hi > > I am having an issue with Cucumber where I am writing in one files some > steps where rspec matcher do not seem to be accessible. > > So I have a file with my steps written like this > > require 'steputils' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end > > > But the code breaks when trying to run args.should_not be_empty that are > valid rspec matchers.. Seems like it is not recognizing it. I tried to > include Cucumber and Spec as part of my class Please post the full error message and backtrace. Did you require 'spec' in your support/env.rb file? Aslak > > but still not working. Any idea what I need to do to make it work? This > will help refactoring some of the steps that may have similar code > > Also, is there a way to see all the existing step using the cucumber > methods? because when you have a lot it would be nice to have a way to > describe them for documentation purpose (like Rake does for task) > > Thanks > > Emmanuel > > > > > > _______________________________________________ > 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 peter.a.jaros at gmail.com Fri Jan 2 13:45:28 2009 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Fri, 2 Jan 2009 13:45:28 -0500 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> Message-ID: <937d9d810901021045h1ebe10c4i9925ff7215975917@mail.gmail.com> On Fri, Jan 2, 2009 at 1:20 PM, Emmanuel Pinault wrote: > So I have a file with my steps written like this > > require 'steputils' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end Is that code right? It looks to me like Steputils.post is never getting called. You're calling SomeClass.post instead. Peter From seatmanu at gmail.com Fri Jan 2 14:01:21 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 2 Jan 2009 11:01:21 -0800 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> Message-ID: <6816A2A0-8387-4209-93C4-0A54D44F2AD1@gmail.com> I think I found a solution to my problem. in the Steputils class, instead of including, I perform an extend on Spec::Matcher so my class look like > > class Steputils > extend Spec::Matchers > def self.post(args) > args.should_not be_empty > end > end Now all the Matcher are visible in my class and tests are running fine again Thanks Emmanuel On Jan 2, 2009, at 10:34 AM, aslak hellesoy wrote: > > > On Fri, Jan 2, 2009 at 7:20 PM, Emmanuel Pinault > wrote: > Hi > > I am having an issue with Cucumber where I am writing in one files > some steps where rspec matcher do not seem to be accessible. > > So I have a file with my steps written like this > > require 'steputils' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end > > > But the code breaks when trying to run args.should_not be_empty that > are valid rspec matchers.. Seems like it is not recognizing it. I > tried to include Cucumber and Spec as part of my class > > Please post the full error message and backtrace. > > Did you require 'spec' in your support/env.rb file? > > Aslak > > > but still not working. Any idea what I need to do to make it work? > This will help refactoring some of the steps that may have similar > code > > Also, is there a way to see all the existing step using the cucumber > methods? because when you have a lot it would be nice to have a way > to describe them for documentation purpose (like Rake does for task) > > Thanks > > Emmanuel > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.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 seatmanu at gmail.com Fri Jan 2 14:03:03 2009 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 2 Jan 2009 11:03:03 -0800 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <937d9d810901021045h1ebe10c4i9925ff7215975917@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <937d9d810901021045h1ebe10c4i9925ff7215975917@mail.gmail.com> Message-ID: Sorry, I made up the example to explain my problem but yes, it should be Steputils. post in each of the steps. But the problem was calling a spec matcher within that class. My solution to get it i to work is to extend my class with Spec::Matcher Thanks Emmanuel On Jan 2, 2009, at 10:45 AM, Peter Jaros wrote: > On Fri, Jan 2, 2009 at 1:20 PM, Emmanuel Pinault > wrote: > >> So I have a file with my steps written like this >> >> require 'steputils' >> >> Given "some step description 1 " do >> SomeClass.post(args) >> end >> >> Given "some step description 2 that is slighty different for better >> readability " do >> SomeClass.post(args) >> end >> >> >> and in steputils I have >> >> class Steputils >> >> def self.post(args) >> args.should_not be_empty >> end >> end > > Is that code right? It looks to me like Steputils.post is never > getting called. You're calling SomeClass.post instead. > > Peter > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From wycats at gmail.com Fri Jan 2 14:29:04 2009 From: wycats at gmail.com (Yehuda Katz) Date: Fri, 2 Jan 2009 11:29:04 -0800 (PST) Subject: [rspec-users] Testing Framework Survey Message-ID: <1b4105b6-5a3c-4879-80f0-f3efc8546c03@r37g2000prr.googlegroups.com> In the interest of collecting some demographic information on the Rails community, Matt (Aimonetti, Rails evangelist) put together a poll of testing framework usage. Please vote at http://twtpoll.com/zhh2fm. Thanks! From aidy.lewis at googlemail.com Fri Jan 2 15:04:57 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Fri, 2 Jan 2009 20:04:57 +0000 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> Message-ID: <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> Hi Aslak, 2009/1/2 aslak hellesoy : > Did you require 'spec' in your support/env.rb file? Is it now a standard to put the env.rb in the 'support' folder? Mine is in the 'steps' folder? Regards Aidy From dchelimsky at gmail.com Fri Jan 2 15:11:23 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Jan 2009 14:11:23 -0600 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> Message-ID: <57c63afe0901021211q248a0047ua121db3cd6da3f19@mail.gmail.com> On Fri, Jan 2, 2009 at 2:04 PM, aidy lewis wrote: > Hi Aslak, > > 2009/1/2 aslak hellesoy : > >> Did you require 'spec' in your support/env.rb file? > > Is it now a standard to put the env.rb in the 'support' folder? Mine > is in the 'steps' folder? That's the direction, yes. features/step_definitions #for step definitions features/support #for everything else > > Regards > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri Jan 2 15:19:18 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 2 Jan 2009 21:19:18 +0100 Subject: [rspec-users] Cucumber namespace problem In-Reply-To: <57c63afe0901021211q248a0047ua121db3cd6da3f19@mail.gmail.com> References: <3A058CB2-78FF-438A-9BBA-FD01376E118F@gmail.com> <8d961d900901021034i377970cdp68e7ed619749fd02@mail.gmail.com> <7ac2300c0901021204k567b9ab2gb2fa150e5e6f97ca@mail.gmail.com> <57c63afe0901021211q248a0047ua121db3cd6da3f19@mail.gmail.com> Message-ID: <8d961d900901021219x122c3898rabc6b1797905c233@mail.gmail.com> On Fri, Jan 2, 2009 at 9:11 PM, David Chelimsky wrote: > On Fri, Jan 2, 2009 at 2:04 PM, aidy lewis > wrote: > > Hi Aslak, > > > > 2009/1/2 aslak hellesoy : > > > >> Did you require 'spec' in your support/env.rb file? > > > > Is it now a standard to put the env.rb in the 'support' folder? Mine > > is in the 'steps' folder? > You can keep it wherever you want, but a recent new feature is that ruby files in the support dir get loaded before any other dir. This is needed in some cases. See History.txt on GitHub. > > That's the direction, yes. > > features/step_definitions #for step definitions > features/support #for everything else > > > > > > > Regards > > > > Aidy > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.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 lists at ruby-forum.com Sat Jan 3 02:07:45 2009 From: lists at ruby-forum.com (Sebastian W.) Date: Sat, 3 Jan 2009 08:07:45 +0100 Subject: [rspec-users] Getting heckled by Heckle? Message-ID: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> Hello RSpec folks, I'm not sure if I'm doing something wrong with the Heckle integration in RSpec? I go to heckle my spec, and everything seems to start out okay. But then something weird happens: 3 mutations remaining... 2 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... 1 mutations remaining... #repeat the above line forever... I've tried waiting to see if I just need to be patient, but Heckle never seems to exit. FWIW, I'm running my spec in the following manner: spec --heckle Seeker seeker_spec.rb And as you may guess, the name of my class is "Seeker". Any thoughts? -- Posted via http://www.ruby-forum.com/. From wycats at gmail.com Sat Jan 3 03:31:20 2009 From: wycats at gmail.com (Yehuda Katz) Date: Sat, 3 Jan 2009 00:31:20 -0800 Subject: [rspec-users] Getting heckled by Heckle? In-Reply-To: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> References: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> Message-ID: <245fb4700901030031o5ffdae18i8aeea59590bf41b@mail.gmail.com> There is more than 1 bug in Heckle that can produce this behavior. Tim Carey Smith (halorgium) has been working on a much saner replacement with effectively the same feature set called boo_hiss, but I'm not sure if it's quite ready yet. I've used it a bit but last I checked the user interface (not GUI, just command-line interface) was rough around the edges. -- Yehuda On Fri, Jan 2, 2009 at 11:07 PM, Sebastian W. wrote: > Hello RSpec folks, > I'm not sure if I'm doing something wrong with the Heckle integration in > RSpec? > > I go to heckle my spec, and everything seems to start out okay. But then > something weird happens: > > 3 mutations remaining... > 2 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > 1 mutations remaining... > #repeat the above line forever... > > I've tried waiting to see if I just need to be patient, but Heckle never > seems to exit. > > FWIW, I'm running my spec in the following manner: > > spec --heckle Seeker seeker_spec.rb > > And as you may guess, the name of my class is "Seeker". Any thoughts? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Sat Jan 3 07:25:24 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 3 Jan 2009 12:25:24 +0000 Subject: [rspec-users] newbie: need help to write the spec for helper In-Reply-To: <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> References: <460644.22468.qm@web38001.mail.mud.yahoo.com> <57c63afe0812310721o4a65a879v55b7e4f586f50f46@mail.gmail.com> <8d961d900812310749g5a4a3b5lf15722da3670547a@mail.gmail.com> <57c63afe0812310802h3f0cf030l1bf7a2626a492193@mail.gmail.com> <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> Message-ID: <01C25EB5-DD78-4B48-9DCA-2DA8BD72B76F@mattwynne.net> On 31 Dec 2008, at 16:11, aslak hellesoy wrote: > On Wed, Dec 31, 2008 at 5:02 PM, David Chelimsky > wrote: > > So do you recommend never doing helper specs? > > I never said never :-) Here is my manifesto styled take on this: > > "I favour testing directly accessible APIs over indirectly > accessible ones." > > In Rails, I usually try to write a spec against a controller or view > before I resort to a helper spec. > > Aslak Interesting. I've ended up going in the other direction. I started out writing tests for UI code at the view level, treating helper methods as implementation details, just as you're describing. This seemed to result in view specs that were fragile, with lots of mocks to set up, and duplicated spec logic where helper code was re-used in different views. I now prefer to put all the interesting stuff in the helpers, unit test that, use Cucumber to make sure the view doesn't blow up, and do very little testing of the view itself. I guess in the context of your little manifesto, I've started to think of the methods you put in helpers as being the API that's used by the designer who hacks on the views. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Sat Jan 3 08:19:50 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 3 Jan 2009 13:19:50 +0000 Subject: [rspec-users] Do people write specs for the code in their steps? How? In-Reply-To: References: Message-ID: On 30 Dec 2008, at 04:17, Erik Pukinskis wrote: >> The approach I like to take is to follow the guidance of the system >> (cucumber + rspec) every step of the way. Right now there are no >> passing steps, so I'd write the code for the 1st pending step, run >> the >> features and find the first thing that is missing or failing. > > This is one thing I don't get. I just started implementing steps, but > I feel like THAT code is all completely untested. I don't know if my > regular expression is correct, I don't know if it does what I think it > should do. What I really want to do is write something like this: > > describe "steps for withdrawing money" > > describe "Given user has a balance" > > before :each > cucumber "Given user has $50 dollars" > end > > it "should match a particular step" > > it "should create an account" > > it "should set the account balance to $50" > > end > > end > > > But is there such a "cucumber" method? And how do you check that your > regular expressions are going to the right place? > > Maybe the best thing to do is write your cucumber steps like this: > > user_has_a_balance = /user has $(.*) dollars/ > Given user_has_a_balance do |balance| > ... > end > > And then in your spec you can do: > > user_has_a_balance.match("user has $20 dollars").should_not == nil > > How do people write specs for their cucumber steps? And if you don't > write specs, how do you live with the uncertainty? > > Erik It seems like at least part of the uncertainty you're talking about is that the step matcher in your step definition ruby code won't match all the steps defined in your features files that you intended it to. I have also worried about this, particularly after refactoring steps in a codebase with a large number of features. A while back, I suggested a feature for cucumber, which would allow you to run it in a 'strict' mode, where the build would fail if any of the steps in features were not matched to a ruby step definition. I'm not sure whether this ticket has been implemented or not - I had a feeling it was, but I can't see anything in the help for 0.1.13, and the ticket hasn't been updated. Plus it's Christmas and my brain is pickled. Anyway, take a look at the ticket: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/52-unmatched-steps-should-less-tolerable-than-pending-steps#ticket-52-23 cheers, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Sat Jan 3 15:31:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 3 Jan 2009 14:31:38 -0600 Subject: [rspec-users] How to spec a controller method that involves an rjs redirect In-Reply-To: <190728.50003.qm@web38004.mail.mud.yahoo.com> References: <190728.50003.qm@web38004.mail.mud.yahoo.com> Message-ID: <57c63afe0901031231u7e5de199i4738cda8e1c95d37@mail.gmail.com> On Fri, Jan 2, 2009 at 10:01 AM, Nasir Jamal wrote: > Hi everyone, > > What is the best way to spec a controller method that involves an rjs > redirect? Something like this > > def index > url_to = @parent ? auction_bids_path(@parent) : auctions_path > render :update do |page| > page.redirect_to(url_to) > end > end > > I tried > response.should have_rjs > for the redirect but it didnt work. Any help would be appreciated. Please be more specific when you say "it didn't work." What precisely was the code in the spec and what precisely was the error you got. From luke at lukemelia.com Sat Jan 3 20:41:41 2009 From: luke at lukemelia.com (Luke Melia) Date: Sat, 3 Jan 2009 20:41:41 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: References: Message-ID: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> On Dec 27, 2008, at 3:08 AM, Mischa Fierer wrote: > You only need to test login for each login case, not for each time > you are testing some sort of logged in functionality. > In most cases you can just post to sessions/create rather than > filling in a login form. I also wanted to speed up the "Given I am a logged in user" type of thing, as you suggested, but took a different, faster approach which may also work for you. I set a cookie to auto-login the user on the next request. Implementation as a gist http://gist.github.com/42973 and below. -Luke features/steps/users_steps.rb: Given "I'm a logged in member" do @me = create_adult logged_in_as @me end features/support/env.rb: class Cucumber::Rails::World ... def logged_in_as(user) cookies['integration_test_user'] = user.id.to_s end ,,, end app/controllers/application.rb class ApplicationController < ActionController::Base ... before_filter :login_integration_test_user, :if => lambda { Rails.env == 'test' } ... def login_integration_test_user return true if cookies['integration_test_user'].blank? integration_test_user_id = cookies['integration_test_user'].to_i if integration_test_user_id != current_user.id reset_session self.current_user = User.find(integration_test_user_id) end cookies['integration_test_user'] = nil end -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From luke at lukemelia.com Sat Jan 3 20:51:32 2009 From: luke at lukemelia.com (Luke Melia) Date: Sat, 3 Jan 2009 20:51:32 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: References: <49566B61.9020201@benmabey.com> Message-ID: On Dec 28, 2008, at 11:30 AM, Josh Knowles wrote: > 4) Distribute your scenarios across multiple processes using TestJour > (http://github.com/brynary/testjour) To provide a little more info (Josh and I work with Bryan, who created testjour): we have a cucumber suite currently consisting of 5835 steps that takes a bit under 20 minutes to run without testjour. Running it via testjour with 2 local slaves and 6 remote slaves (2 mac minis and a Mac Pro), the run completes in about 4 minutes. testjour is still a little raw, but I already would not want to work on a large product without it. Luke -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From ben at benmabey.com Sat Jan 3 21:12:32 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 03 Jan 2009 19:12:32 -0700 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> Message-ID: <49601B10.8020902@benmabey.com> On 1/3/09 6:41 PM, Luke Melia wrote: > On Dec 27, 2008, at 3:08 AM, Mischa Fierer wrote: > >> You only need to test login for each login case, not for each time >> you are testing some sort of logged in functionality. >> In most cases you can just post to sessions/create rather than >> filling in a login form. > > I also wanted to speed up the "Given I am a logged in user" type of > thing, as you suggested, but took a different, faster approach which > may also work for you. I set a cookie to auto-login the user on the > next request. Implementation as a gist http://gist.github.com/42973 > and below. -Luke > > features/steps/users_steps.rb: > > Given "I'm a logged in member" do > @me = create_adult > logged_in_as @me > end > > features/support/env.rb: > > class Cucumber::Rails::World > ... > def logged_in_as(user) > cookies['integration_test_user'] = user.id.to_s > end > ,,, > end > > app/controllers/application.rb > > class ApplicationController < ActionController::Base > ... > before_filter :login_integration_test_user, :if => lambda { > Rails.env == 'test' } > ... > def login_integration_test_user > return true if cookies['integration_test_user'].blank? > integration_test_user_id = cookies['integration_test_user'].to_i > > if integration_test_user_id != current_user.id > reset_session > self.current_user = User.find(integration_test_user_id) > end > > cookies['integration_test_user'] = nil > end The downside with this approach is that it only works with the rails webrat adapter. One solution which I have been meaning to do is to create a UsersSessionManager. The manager would be responsible for logging in all the various roles you use in your app with different webrat sessions (and then caching them.) You could then swap out which session you would be using in your steps... So you could then do something like: logged_in_as 'Admin' do |session| session.click_link 'Foo' ... end Or.. Given /^I am logged in as an '(.+)'$/ |role| login_as role end The 'login_as' would swap out the session that the World object uses so the next steps would be using the appropriate session. WDYT? -Ben -Ben From reza.primardiansyah at gmail.com Sat Jan 3 21:58:26 2009 From: reza.primardiansyah at gmail.com (Reza Primardiansyah) Date: Sun, 4 Jan 2009 09:58:26 +0700 Subject: [rspec-users] Rspec Rails high overhead Message-ID: Greetings, I found out that running RSpec on Rails takes too much overhead. It takes more than 16s per run although the specs only take less than 6s, like seen below. That means almost 11s overhead. I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. $ time rake spec > (in /home/reza/system) > > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 5.493595 seconds > > 340 examples, 0 failures > > real 0m16.497s > user 0m14.059s > sys 0m2.266s > I know that Debian's ruby is slow. So I tried using enterprise ruby. Not much difference $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec > (in /home/reza/system) > > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 3.170093 seconds > > 340 examples, 0 failures > > real 0m12.033s > user 0m9.948s > sys 0m1.735s > The overhead is also felt when using autospec. Even using sqlite's in-memory-db doesn't change much. Can anyone give me hint about what happens and what to do to overcome it? Thanks all. -------------- next part -------------- An HTML attachment was scrubbed... URL: From luke at lukemelia.com Sat Jan 3 22:36:54 2009 From: luke at lukemelia.com (Luke Melia) Date: Sat, 3 Jan 2009 22:36:54 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <49601B10.8020902@benmabey.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> Message-ID: <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> On Jan 3, 2009, at 9:12 PM, Ben Mabey wrote: > The downside with this approach is that it only works with the rails > webrat adapter. One solution which I have been meaning to do is to > create a UsersSessionManager. The manager would be responsible for > logging in all the various roles you use in your app with different > webrat sessions (and then caching them.) You could then swap out > which session you would be using in your steps... > > So you could then do something like: > > logged_in_as 'Admin' do |session| > session.click_link 'Foo' > ... > end > > Or.. > > Given /^I am logged in as an '(.+)'$/ |role| > login_as role > end > > The 'login_as' would swap out the session that the World object uses > so the next steps would be using the appropriate session. > > WDYT? In general I like the idea, Ben. At weplay, we use webrat to drive rails and selenium, and logged_in_as method has the following implementation in the Selenium world: def logged_in_as(user) visit login_for_test_path(user) end where login_for_test_path is is a named route defined only for the selenium environment that provides a "quick" login of a given user. Would the solution you're thinking of help with this? I'm not sure how you would "cache" a selenium session. -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From sfeley at gmail.com Sat Jan 3 23:15:50 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sat, 3 Jan 2009 23:15:50 -0500 Subject: [rspec-users] How to spec a controller method that involves an rjs redirect In-Reply-To: <190728.50003.qm@web38004.mail.mud.yahoo.com> References: <190728.50003.qm@web38004.mail.mud.yahoo.com> Message-ID: <1fb4df0901032015s32af4727udfc1ab76bc8fbd42@mail.gmail.com> On Fri, Jan 2, 2009 at 11:01 AM, Nasir Jamal wrote: > > What is the best way to spec a controller method that involves an rjs > redirect? Something like this Consider: response.should =~ /window\.location\.href = '(whatever your expected path is)';/ I didn't confirm that regex, obviously. But the concept is pretty simple: if you know how the RJS redirect works and what Javascript is supposed to be generated, then test for its presence in the response. If it's there, your controller logic worked. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From mark at mwilden.com Sat Jan 3 23:17:12 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 3 Jan 2009 20:17:12 -0800 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: Message-ID: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> On Sat, Jan 3, 2009 at 6:58 PM, Reza Primardiansyah < reza.primardiansyah at gmail.com> wrote: > I found out that running RSpec on Rails takes too much overhead. It takes > more than 16s per run although the specs only take less than 6s, like seen > below. The killer is the time it takes to load environment.rb, which loads Rails, runs initializers, etc. The rake spec task also tears down and recreates the test database, but that's not as significant. The solution to the first situation is spec_server, which loads the environment once, then stays in memory as a DRb process. By passing --drb to the spec command, RSpec will have that process run specs. The solution to the second situation is to not run rake spec, but instead use spec or autospec. All that said, I haven't had as much joy from spec_server as I have in the past. Too often it seems to not load changed models. But this might be related to a patch I had to apply to even get it to run. Things seemed to have changed with Rails 2.2.2 and/or RSpec 1.1.11. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Jan 4 01:01:42 2009 From: lists at ruby-forum.com (Sebastian W.) Date: Sun, 4 Jan 2009 07:01:42 +0100 Subject: [rspec-users] Getting heckled by Heckle? In-Reply-To: <245fb4700901030031o5ffdae18i8aeea59590bf41b@mail.gmail.com> References: <4837fa5000068804cbdea858f10b6af5@ruby-forum.com> <245fb4700901030031o5ffdae18i8aeea59590bf41b@mail.gmail.com> Message-ID: Yehuda Katz wrote: > There is more than 1 bug in Heckle that can produce this behavior. Tim > Carey > Smith (halorgium) has been working on a much saner replacement with > effectively the same feature set called boo_hiss, but I'm not sure if > it's > quite ready yet. I've used it a bit but last I checked the user > interface > (not GUI, just command-line interface) was rough around the edges. > -- Yehuda Cool, thanks Yehuda! I'll hold on tight and wait for that. :) -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Sun Jan 4 09:43:52 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 4 Jan 2009 15:43:52 +0100 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: Message-ID: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah < reza.primardiansyah at gmail.com> wrote: > Greetings, > I found out that running RSpec on Rails takes too much overhead. It takes > more than 16s per run although the specs only take less than 6s, like seen > below. That means almost 11s overhead. > I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. > > $ time rake spec >> (in /home/reza/system) >> >> .................................................................................................................................................................................................................................................................................................................................................... >> >> Finished in 5.493595 seconds >> >> 340 examples, 0 failures >> >> real 0m16.497s >> user 0m14.059s >> sys 0m2.266s >> > > I know that Debian's ruby is slow. So I tried using enterprise ruby. Not > much difference > > $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec >> (in /home/reza/system) >> >> .................................................................................................................................................................................................................................................................................................................................................... >> >> Finished in 3.170093 seconds >> >> 340 examples, 0 failures >> >> real 0m12.033s >> user 0m9.948s >> sys 0m1.735s >> > > The overhead is also felt when using autospec. Even using sqlite's > in-memory-db doesn't change much. > > Can anyone give me hint about what happens and what to do to overcome it? > How long does ruby script/server take before the server is up? Aslak > > Thanks all. > > _______________________________________________ > 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 nick at deadorange.com Sun Jan 4 09:57:47 2009 From: nick at deadorange.com (Nick Hoffman) Date: Sun, 4 Jan 2009 09:57:47 -0500 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> Message-ID: On 2009-01-03, at 23:17, Mark Wilden wrote: >> On Sat, Jan 3, 2009 at 6:58 PM, Reza Primardiansyah > > wrote: >> >> I found out that running RSpec on Rails takes too much overhead. It >> takes more than 16s per run although the specs only take less than >> 6s, like seen below. > > The killer is the time it takes to load environment.rb, which loads > Rails, runs initializers, etc. The rake spec task also tears down > and recreates the test database, but that's not as significant. > > The solution to the first situation is spec_server, which loads the > environment once, then stays in memory as a DRb process. By passing > --drb to the spec command, RSpec will have that process run specs. > The solution to the second situation is to not run rake spec, but > instead use spec or autospec. > > All that said, I haven't had as much joy from spec_server as I have > in the past. Too often it seems to not load changed models. But this > might be related to a patch I had to apply to even get it to run. > Things seemed to have changed with Rails 2.2.2 and/or RSpec 1.1.11. > > ///ark Mark, would you mind explicitly telling us/me how you get the ``spec'' command to run within DRb, please? This is what happens I try [and fail] to do so: http://gist.github.com/43070 Cheers, Nick From dchelimsky at gmail.com Sun Jan 4 11:41:21 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 10:41:21 -0600 Subject: [rspec-users] [ANN] RSpec-1.1.12 - RC1 Message-ID: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> Hey all, I'm getting ready to do a 1.1.12 release of rspec and rspec-rails. Given the history of release-related compatibility problems, I offer you release candidate gems, which you can acquire thusly: [sudo] gem install dchelimsky-rspec -v 1.1.11.5 --source http://gems.github.com [sudo] gem install dchelimsky-rspec-rails -v 1.1.11.5 --source http://gems.github.com Release notes can be seen under Maintenance at: http://github.com/dchelimsky/rspec/tree/master/History.txt http://github.com/dchelimsky/rspec-rails/tree/master/History.txt NOTE: This will be the last release of rspec-rails that supports rails < 2.0 If you are so inclined, please grab these gems, use them, and let me know if everything is AOK. Cheers, David From dchelimsky at gmail.com Sun Jan 4 13:22:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 12:22:42 -0600 Subject: [rspec-users] [ANN] RSpec-1.1.12 - RC1 In-Reply-To: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> References: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> Message-ID: <57c63afe0901041022m7f1c324fm7049b93bf6f20210@mail.gmail.com> On Sun, Jan 4, 2009 at 10:41 AM, David Chelimsky wrote: > Hey all, > > I'm getting ready to do a 1.1.12 release of rspec and rspec-rails. > Given the history of release-related compatibility problems, I offer > you release candidate gems, which you can acquire thusly: > > [sudo] gem install dchelimsky-rspec -v 1.1.11.5 --source http://gems.github.com > [sudo] gem install dchelimsky-rspec-rails -v 1.1.11.5 --source > http://gems.github.com Fixed gem dependency issue related to github-generated gems (prefixed w/ usernames). Try 1.1.11.6 instead: gem sources -a http://gems.github.com gem install dchelimsky-rspec -v 1.1.11.6 gem install dchelimsky-rspec-rails -v 1.1.11.6 Cheers, David > > Release notes can be seen under Maintenance at: > > http://github.com/dchelimsky/rspec/tree/master/History.txt > http://github.com/dchelimsky/rspec-rails/tree/master/History.txt > > NOTE: This will be the last release of rspec-rails that supports rails < 2.0 > > If you are so inclined, please grab these gems, use them, and let me > know if everything is AOK. > > Cheers, > David > From joahking at gmail.com Sun Jan 4 13:31:30 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Sun, 4 Jan 2009 19:31:30 +0100 Subject: [rspec-users] rack app to browse specs Message-ID: <8277b7f40901041031l3a1fe8d4v6c6150bfee3cb944@mail.gmail.com> hello there, Sometimes I find easier to browse my specs directly on the browser to have an overall idea of the logic. To do it I have put up a simple rack app to: - browse the contents of /spec directory on rails root - run each spec and view the html formatted output (it does spec FILE -f h) It is only a .rb file to put on spec/ directory. If you will like to give it a try: http://gist.github.com/43149 I hope it helps somebody ;-) joaquin -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sun Jan 4 13:50:11 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 4 Jan 2009 19:50:11 +0100 Subject: [rspec-users] [ANN] Cucumber 0.1.14 Message-ID: <8d961d900901041050pd052a6dgd0d4c671d130bc66@mail.gmail.com> Now with Ruby 1.9 support! Full changelog: http://github.com/aslakhellesoy/cucumber/tree/v0.1.14/History.txt The gem will be available in an hour or two. Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 4 13:55:06 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 12:55:06 -0600 Subject: [rspec-users] [rspec-devel] [ANN] Cucumber 0.1.14 In-Reply-To: <8d961d900901041050pd052a6dgd0d4c671d130bc66@mail.gmail.com> References: <8d961d900901041050pd052a6dgd0d4c671d130bc66@mail.gmail.com> Message-ID: <57c63afe0901041055s4ac8b36fpebe3c299541e3be9@mail.gmail.com> Rock on!!!!! Thanks for this this. It's going to make getting rspec ruby 1.9 compliant much easier (since now I'll be able to run rspec's features!). Cheers, David On Sun, Jan 4, 2009 at 12:50 PM, aslak hellesoy wrote: > Now with Ruby 1.9 support! > > Full changelog: > http://github.com/aslakhellesoy/cucumber/tree/v0.1.14/History.txt > > The gem will be available in an hour or two. > > Aslak > > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > From lists at ruby-forum.com Sun Jan 4 14:13:57 2009 From: lists at ruby-forum.com (Hubert Lepicki) Date: Sun, 4 Jan 2009 20:13:57 +0100 Subject: [rspec-users] Cucumber model expectations fail to find newly created users Message-ID: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> Hi guys, I have strange problem with getting model expectations to work with Cucumber. My setup is that I use Cucumber + Webrat (Selenium backend). Story I test is registering user on site. Cucumber runs story perfectly fine, and I see it fills in form, sends it, I even see proper "You have successfully registered" message at the end. However, as a last element of story I want to make sure the user was really created in database - and this fails. I have definition of following step: Then /^should exist exactly "(.*)" users$/ do |cnt, state| User.count.should == cnt.to_i end However, it always complains that there are 0 users, when expected X. What is even more stranger, when I log into console, and do User.count, I get proper number of users - they were actually created during running a story! Any ideas? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sun Jan 4 14:15:43 2009 From: lists at ruby-forum.com (Hubert Lepicki) Date: Sun, 4 Jan 2009 20:15:43 +0100 Subject: [rspec-users] Cucumber model expectations fail to find newly created users In-Reply-To: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> References: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> Message-ID: <70166be6233dc4d4aac84e049a46acae@ruby-forum.com> The step definition is actually: Then /^should exist exactly "(.*)" users$/ do |cnt| User.count.should == cnt.to_i end but that doesn't change anything, please help! -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Sun Jan 4 14:46:54 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 04 Jan 2009 12:46:54 -0700 Subject: [rspec-users] Cucumber model expectations fail to find newly created users In-Reply-To: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> References: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> Message-ID: <4961122E.2090607@benmabey.com> On 1/4/09 12:13 PM, Hubert Lepicki wrote: > Hi guys, > > I have strange problem with getting model expectations to work with > Cucumber. My setup is that I use Cucumber + Webrat (Selenium backend). > My guess is that you are using Selenium in conjuction with rails transactional fixtures turned on. In your env.rb file do you have the following? Cucumber::Rails.use_transactional_fixtures If so that is your problem. What is happending is that you two separate processes and two separate DB connections going. One is running the server for selenium, and the other is for your features. With transactional_fixtures turned on all of your DB calls for each scenario are wrapped in into a transaction that is rolled back at the end. Be default MySQL, and most other DBs I would imagine, don't let the data in a transaction appear to any other queries until that transaction is actually committed. That is why you can see the correct count in the process running the features but not the selenium process. How do you get around this? You could change your settings on MySQL, but I wouldn't suggest that. What I do is turn off transactional_fixtures and then manage the DB cleanup myself in After blocks. The quick and dirty way to do this is to truncate your tables.. There have been some threads on this list explaining how to do this. There are some other ways to accomplish this without resorting to truncating everytime too, but I will let you google and find those threads. This problem seems to come up quite a bit.. we should probably add this to the Troubleshooting page on Cucumber's wiki.... Anyways, I hope that helps. -Ben > Story I test is registering user on site. Cucumber runs story perfectly > fine, and I see it fills in form, sends it, I even see proper "You have > successfully registered" message at the end. However, as a last element > of story I want to make sure the user was really created in database - > and this fails. > > I have definition of following step: > > Then /^should exist exactly "(.*)" users$/ do |cnt, state| > User.count.should == cnt.to_i > end > > However, it always complains that there are 0 users, when expected X. > > What is even more stranger, when I log into console, and do User.count, > I get proper number of users - they were actually created during running > a story! > > Any ideas? > From lists at ruby-forum.com Sun Jan 4 15:16:00 2009 From: lists at ruby-forum.com (Hubert Lepicki) Date: Sun, 4 Jan 2009 21:16:00 +0100 Subject: [rspec-users] Cucumber model expectations fail to find newly created users In-Reply-To: <4961122E.2090607@benmabey.com> References: <9fed933fb90eda32e8d056bb16460a98@ruby-forum.com> <4961122E.2090607@benmabey.com> Message-ID: <95e80809d0a68fab3c1a666a74d93295@ruby-forum.com> Ben Mabey wrote: > My guess is that you are using Selenium in conjuction with rails > transactional fixtures turned on. In your env.rb file do you have the > following? > Cucumber::Rails.use_transactional_fixtures That was a perfect guess! Thank you, Ben, a lot! I have updated Troubleshooting page in Github wiki like you suggested so that other people might find solution quicker than me :). One more time - thanks! -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sun Jan 4 15:52:59 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 4 Jan 2009 12:52:59 -0800 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> Message-ID: <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> On Sun, Jan 4, 2009 at 6:57 AM, Nick Hoffman wrote: > > Mark, would you mind explicitly telling us/me how you get the ``spec'' > command to run within DRb, please? > I use spec rather than script/spec to run specs. script/spec runs my specs twice. I also use rake spec:server:start rather than script/spec_server, but both commands do work for me. The problem now is that if I change a model or lib file, it's not reloaded by spec_server. I have to stop and restart spec_server for the change to be picked up. This means I can't really use it. (To the powers that be, I apologize for not filing a proper bug report.) This is what happens I try [and fail] to do so: > http://gist.github.com/43070 > That sequence "works for me," I'm afraid. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 4 16:03:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Jan 2009 15:03:38 -0600 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> Message-ID: <57c63afe0901041303uacc7b41sb589cd48289740e8@mail.gmail.com> On Sun, Jan 4, 2009 at 2:52 PM, Mark Wilden wrote: > On Sun, Jan 4, 2009 at 6:57 AM, Nick Hoffman wrote: >> >> Mark, would you mind explicitly telling us/me how you get the ``spec'' >> command to run within DRb, please? > > I use spec rather than script/spec to run specs. script/spec runs my specs > twice. That's fixed, so I'm guessing you've got a mixture of old and new generated files. > I also use rake spec:server:start rather than script/spec_server, but > both commands do work for me. > > The problem now is that if I change a model or lib file, it's not reloaded > by spec_server. I have to stop and restart spec_server for the change to be > picked up. This means I can't really use it. (To the powers that be, I > apologize for not filing a proper bug report.) Apology accepted as soon as you do :) > >> This is what happens I try [and fail] to do so: >> http://gist.github.com/43070 > > That sequence "works for me," I'm afraid. > > ///ark From mark at mwilden.com Sun Jan 4 16:19:45 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 4 Jan 2009 13:19:45 -0800 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <57c63afe0901041303uacc7b41sb589cd48289740e8@mail.gmail.com> References: <3c30da400901032017u62e0a063hfaa5ca8e7bbbb97d@mail.gmail.com> <3c30da400901041252n42d8aebeuaaeed800aca9dae0@mail.gmail.com> <57c63afe0901041303uacc7b41sb589cd48289740e8@mail.gmail.com> Message-ID: <3c30da400901041319k1f475266nc0d643edbfeae7d5@mail.gmail.com> On Sun, Jan 4, 2009 at 1:03 PM, David Chelimsky wrote: > > I use spec rather than script/spec to run specs. script/spec runs my > specs > > twice. > > That's fixed, so I'm guessing you've got a mixture of old and new > generated files. > I did re-gen with .16, but still got that result. > The problem now is that if I change a model or lib file, it's not reloaded > > by spec_server. I have to stop and restart spec_server for the change to > be > > picked up. This means I can't really use it. (To the powers that be, I > > apologize for not filing a proper bug report.) > > Apology accepted as soon as you do :) > The problem, of course, is the "proper" part. But I will try to get at it - I love spec_server! ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Sun Jan 4 19:08:27 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 04 Jan 2009 17:08:27 -0700 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> Message-ID: <49614F7B.4010803@benmabey.com> On 1/3/09 8:36 PM, Luke Melia wrote: > On Jan 3, 2009, at 9:12 PM, Ben Mabey wrote: > >> The downside with this approach is that it only works with the rails >> webrat adapter. One solution which I have been meaning to do is to >> create a UsersSessionManager. The manager would be responsible for >> logging in all the various roles you use in your app with different >> webrat sessions (and then caching them.) You could then swap out >> which session you would be using in your steps... >> >> So you could then do something like: >> >> logged_in_as 'Admin' do |session| >> session.click_link 'Foo' >> ... >> end >> >> Or.. >> >> Given /^I am logged in as an '(.+)'$/ |role| >> login_as role >> end >> >> The 'login_as' would swap out the session that the World object uses >> so the next steps would be using the appropriate session. >> >> WDYT? > > In general I like the idea, Ben. At weplay, we use webrat to drive > rails and selenium, and logged_in_as method has the following > implementation in the Selenium world: > > def logged_in_as(user) > visit login_for_test_path(user) > end > > where login_for_test_path is is a named route defined only for the > selenium environment that provides a "quick" login of a given user. > > Would the solution you're thinking of help with this? I'm not sure how > you would "cache" a selenium session. I'm by no means a Selenium expert so I may be making some incorrect assumptions. I thought that it was possible with Selenium to have different sessions open concurrently for the same selenium server. (i.e. have more than one SeleniumDriver/browser instance running against the same server but with different session ids.) Is that not possible? -Ben > > -- > 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 aslak.hellesoy at gmail.com Sun Jan 4 20:55:40 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 02:55:40 +0100 Subject: [rspec-users] [rspec-devel] [ANN] RSpec-1.1.12 - RC1 In-Reply-To: <57c63afe0901041022m7f1c324fm7049b93bf6f20210@mail.gmail.com> References: <57c63afe0901040841m655f4eb2i835833d5ee581778@mail.gmail.com> <57c63afe0901041022m7f1c324fm7049b93bf6f20210@mail.gmail.com> Message-ID: <8d961d900901041755g699aa0bcx71110493511005ef@mail.gmail.com> On Sun, Jan 4, 2009 at 7:22 PM, David Chelimsky wrote: > On Sun, Jan 4, 2009 at 10:41 AM, David Chelimsky > wrote: > > Hey all, > > > > I'm getting ready to do a 1.1.12 release of rspec and rspec-rails. > > Given the history of release-related compatibility problems, I offer > > you release candidate gems, which you can acquire thusly: > > > > [sudo] gem install dchelimsky-rspec -v 1.1.11.5 --source > http://gems.github.com > > [sudo] gem install dchelimsky-rspec-rails -v 1.1.11.5 --source > > http://gems.github.com > > Fixed gem dependency issue related to github-generated gems (prefixed > w/ usernames). Try 1.1.11.6 instead: > > gem sources -a http://gems.github.com > gem install dchelimsky-rspec -v 1.1.11.6 > gem install dchelimsky-rspec-rails -v 1.1.11.6 > Awesome - now get that 1.9 baby rolling! Aslak > > Cheers, > David > > > > > Release notes can be seen under Maintenance at: > > > > http://github.com/dchelimsky/rspec/tree/master/History.txt > > http://github.com/dchelimsky/rspec-rails/tree/master/History.txt > > > > NOTE: This will be the last release of rspec-rails that supports rails < > 2.0 > > > > If you are so inclined, please grab these gems, use them, and let me > > know if everything is AOK. > > > > Cheers, > > David > > > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sun Jan 4 20:58:26 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 02:58:26 +0100 Subject: [rspec-users] Voted for Cucumber logo yet? Message-ID: <8d961d900901041758o18fd4a44s10a0e4093d7f851e@mail.gmail.com> If not - please do! http://cukes.info Announcing winner tomorrow. No rallying friends please. Just vote for the best one. Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From aidy.lewis at googlemail.com Mon Jan 5 08:33:53 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 5 Jan 2009 13:33:53 +0000 Subject: [rspec-users] [Cucumber] after feature hook? Message-ID: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> Hi, Is there a hook or a method to execute some code after a whole feature has run or will I need to embed that in a 'Then'? Regards Aidy From aslak.hellesoy at gmail.com Mon Jan 5 08:49:48 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 14:49:48 +0100 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> Message-ID: <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis wrote: > Hi, > > Is there a hook or a method to execute some code after a whole feature > has run or will I need to embed that in a 'Then'? > May I ask what you're planning to use it for? Aslak > > Regards > > Aidy > _______________________________________________ > 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 aidy.lewis at googlemail.com Mon Jan 5 09:12:24 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 5 Jan 2009 14:12:24 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> Message-ID: <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> Hi Alsak, I am finding it difficult to separate my Acceptance Tests unless I have lengthy scenarios. One scenario would be one sequence of action etc - until a goal is reached. At the end of the feature, I would like the browser to close: If the browser closes on each scenario - they I have to get back to the previous state. This is expensive with browser based tests. Aidy On 05/01/2009, aslak hellesoy wrote: > > > > On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis > wrote: > > Hi, > > > > Is there a hook or a method to execute some code after a whole feature > > has run or will I need to embed that in a 'Then'? > > > > May I ask what you're planning to use it for? > > Aslak > > > > Regards > > > > Aidy > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.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 joe at josephwilk.net Mon Jan 5 09:15:27 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Mon, 05 Jan 2009 14:15:27 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> Message-ID: <496215FF.9090901@josephwilk.net> aidy lewis wrote: > Hi, > > Is there a hook or a method to execute some code after a whole feature > has run or will I need to embed that in a 'Then'? > > There are currently no before/after feature hooks. http://github.com/aslakhellesoy/cucumber/wikis/hooks Also if you want something to happen before/after everything you can use World and at_exit respectively. -- Joseph Wilk http://blog.josephwilk.net > Regards > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From aslak.hellesoy at gmail.com Mon Jan 5 10:09:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 5 Jan 2009 16:09:08 +0100 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> Message-ID: <8d961d900901050709lcd2ff11r11055d18c3ee39b2@mail.gmail.com> On Mon, Jan 5, 2009 at 3:12 PM, aidy lewis wrote: > Hi Alsak, > > I am finding it difficult to separate my Acceptance Tests unless I > have lengthy scenarios. > > One scenario would be one sequence of action etc - until a goal is reached. > > At the end of the feature, I would like the browser to close: If the > browser closes on each scenario - they I have to get back to the > previous state. This is expensive with browser based tests. > And only closing the browser after all the features (at_exit) does not work? Aslak > > Aidy > > > > On 05/01/2009, aslak hellesoy wrote: > > > > > > > > On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis > > wrote: > > > Hi, > > > > > > Is there a hook or a method to execute some code after a whole feature > > > has run or will I need to embed that in a 'Then'? > > > > > > > May I ask what you're planning to use it for? > > > > Aslak > > > > > > Regards > > > > > > Aidy > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at josephwilk.net Mon Jan 5 10:13:24 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Mon, 05 Jan 2009 15:13:24 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> Message-ID: <49622394.9070409@josephwilk.net> aidy lewis wrote: > Hi Alsak, > > I am finding it difficult to separate my Acceptance Tests unless I > have lengthy scenarios. > > One scenario would be one sequence of action etc - until a goal is reached. > > At the end of the feature, I would like the browser to close: So you are using scenarios to get the browser into a certain state and then the next scenario relies on continuing work on that state? I guess this must mean one scenario failing breaks all following scenarios in the feature? > If the > browser closes on each scenario - they I have to get back to the > previous state. This is expensive with browser based tests. > > Aidy > > A bit of a side note but can I ask why you need the browser to close after a scenario or feature? In Selenium (not sure if Watir is the same) the time expense of starting a new browser instances per scenario or per feature is too high (It can take 7/8 seconds for selenium to start a browser). So rather than closing and opening new browsers we use a single browser instance open throughout the test run. We terminate the session before each scenario (By accessing logout). @@@ruby World do ... browser.open '/logout' ... end @@@ -- Joseph Wilk http://blog.josephwilk.net > > On 05/01/2009, aslak hellesoy wrote: > >> >> On Mon, Jan 5, 2009 at 2:33 PM, aidy lewis >> wrote: >> >>> Hi, >>> >>> Is there a hook or a method to execute some code after a whole feature >>> has run or will I need to embed that in a 'Then'? >>> >>> >> May I ask what you're planning to use it for? >> >> Aslak >> >>> Regards >>> >>> Aidy >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.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 aidy.lewis at googlemail.com Mon Jan 5 11:08:03 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 5 Jan 2009 16:08:03 +0000 Subject: [rspec-users] [Cucumber] after feature hook? In-Reply-To: <49622394.9070409@josephwilk.net> References: <7ac2300c0901050533v362261d3r56f3087fd7e883d@mail.gmail.com> <8d961d900901050549t732f2e59k3dd1cd336497bb6d@mail.gmail.com> <7ac2300c0901050612g5329a6a0tadedf7c9917ba82c@mail.gmail.com> <49622394.9070409@josephwilk.net> Message-ID: <7ac2300c0901050808h2b169bceoe7e5ee5c81e9c973@mail.gmail.com> Hi Joe, Aslak 2009/1/5 Joseph Wilk : > aidy lewis wrote: >> >> Hi Alsak, >> >> I am finding it difficult to separate my Acceptance Tests unless I >> have lengthy scenarios. >> >> One scenario would be one sequence of action etc - until a goal is >> reached. >> >> At the end of the feature, I would like the browser to close: > > So you are using scenarios to get the browser into a certain state and then > the next scenario relies on continuing work on that state? > I guess this must mean one scenario failing breaks all following scenarios > in the feature? >> >> If the >> browser closes on each scenario - they I have to get back to the >> previous state. This is expensive with browser based tests. >> >> Aidy >> >> > > A bit of a side note but can I ask why you need the browser to close after a > scenario or feature? > > In Selenium (not sure if Watir is the same) the time expense of starting a > new browser instances per scenario or per feature is too high (It can take > 7/8 seconds for selenium to start a browser). So rather than closing and > opening new browsers we use a single browser instance open throughout the > test run. We terminate the session before each scenario (By accessing > logout). > > @@@ruby > World do > ... > browser.open '/logout' > ... > end > @@@ > at_exit {browser.close} works fine and I should have thought of that. Thanks Maybe Selenium RC is slow on starting the browser by going through the HTTP proxy - but I am not sure. Watir\Firewatir does not take that long. I am closing the browser because if the test or A-U-T totally bombs; I can get rid of that session and run the next test. So if one test fails, all my tests don't. Aidy From lists at ruby-forum.com Mon Jan 5 16:18:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 5 Jan 2009 22:18:20 +0100 Subject: [rspec-users] cucumber, finding a row in a table Message-ID: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> I generate the following html on the page in question Just An Entity CORP 000001 Show Entity Edit Entity Destroy Entity I have this step definition: When /I delete the "(.*)" entity/ do |row| visits entities_url my_entity = Entity.find_by_entity_name( "my entity number #{row.hll_words_to_i}") within("table > tr#entity_id_" + my_entity.id.to_s) do puts "table > tr#entity_id_" + my_entity.id.to_s click_link "Destroy Entity" end end The puts statement displays this: table > tr#entity_id_1 after wich I see this: When I delete the "first" entity # features/app/models/entities #/step_definitions/entity_steps.rb:128 You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_html (NoMethodError) /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in `scoped_dom' ... The table entries exist. The find_by_name returns a valid instance. I do not know what the nil object is. Can someone point out to me what I am missing? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Mon Jan 5 18:07:13 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 5 Jan 2009 18:07:13 -0500 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> Message-ID: <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> On Mon, Jan 5, 2009 at 4:18 PM, James Byrne wrote: > I generate the following html on the page in question > > > Just An Entity > > CORP > 000001 > Show Entity > Edit Entity > Destroy Entity > > > > I have this step definition: > > When /I delete the "(.*)" entity/ do |row| > visits entities_url > my_entity = Entity.find_by_entity_name( > "my entity number #{row.hll_words_to_i}") > within("table > tr#entity_id_" + my_entity.id.to_s) do > puts "table > tr#entity_id_" + my_entity.id.to_s > click_link "Destroy Entity" > end > end > > The puts statement displays this: > > table > tr#entity_id_1 > > after wich I see this: > > When I delete the "first" entity # features/app/models/entities > #/step_definitions/entity_steps.rb:128 > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.to_html (NoMethodError) > /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in > `scoped_dom' > ... > > The table entries exist. The find_by_name returns a valid instance. I > do not know what the nil object is. Can someone point out to me what I > am missing? Does your outputted HTML properly include a tbody in the table? If so the selector you are using won't work. You would need to make match any descendant rather than any direct child, ie: "table tr#entity_id_1" On a related note (although not specific your problem at hand) to generate an id on an ActiveRecord model you can use the dom_id helper method provided by Rails. ie: "dom_id(entity)". You can use this both in your template and your steps/specs. And rather than hardcoding "table tr" CSS selectors why not just give your table an id like "entities" and then use dom_id to give your rows ids? Should you change the display to a ul or ol you wouldn't have to go back and change your CSS selectors, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From reza.primardiansyah at gmail.com Mon Jan 5 22:29:46 2009 From: reza.primardiansyah at gmail.com (Reza Primardiansyah) Date: Tue, 6 Jan 2009 10:29:46 +0700 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> References: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> Message-ID: Aslak, The best time I get is 6.3 seconds. I'm using "time script/server" command and hitting Ctrl-C immediately after I see "** Use CTRL-C to stop." On Sun, Jan 4, 2009 at 9:43 PM, aslak hellesoy wrote: > > > On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah < > reza.primardiansyah at gmail.com> wrote: > >> Greetings, >> I found out that running RSpec on Rails takes too much overhead. It takes >> more than 16s per run although the specs only take less than 6s, like seen >> below. That means almost 11s overhead. >> I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. >> >> $ time rake spec >>> (in /home/reza/system) >>> >>> .................................................................................................................................................................................................................................................................................................................................................... >>> >>> Finished in 5.493595 seconds >>> >>> 340 examples, 0 failures >>> >>> real 0m16.497s >>> user 0m14.059s >>> sys 0m2.266s >>> >> >> I know that Debian's ruby is slow. So I tried using enterprise ruby. Not >> much difference >> >> $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec >>> (in /home/reza/system) >>> >>> .................................................................................................................................................................................................................................................................................................................................................... >>> >>> Finished in 3.170093 seconds >>> >>> 340 examples, 0 failures >>> >>> real 0m12.033s >>> user 0m9.948s >>> sys 0m1.735s >>> >> >> The overhead is also felt when using autospec. Even using sqlite's >> in-memory-db doesn't change much. >> >> Can anyone give me hint about what happens and what to do to overcome it? >> > > How long does ruby script/server take before the server is up? > > Aslak > > >> >> Thanks all. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 luke at lukemelia.com Mon Jan 5 23:38:01 2009 From: luke at lukemelia.com (Luke Melia) Date: Mon, 5 Jan 2009 23:38:01 -0500 Subject: [rspec-users] Cucumber speed tips In-Reply-To: <49614F7B.4010803@benmabey.com> References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> <49614F7B.4010803@benmabey.com> Message-ID: On Jan 4, 2009, at 7:08 PM, Ben Mabey wrote: > I'm by no means a Selenium expert so I may be making some incorrect > assumptions. I thought that it was possible with Selenium to have > different sessions open concurrently for the same selenium server. > (i.e. have more than one SeleniumDriver/browser instance running > against the same server but with different session ids.) Is that > not possible? Not that I know of, but now that you mention it, seems like it would be pretty cool. Anyone else on the list done this? -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From f.mischa at gmail.com Tue Jan 6 01:24:35 2009 From: f.mischa at gmail.com (Mischa Fierer) Date: Tue, 6 Jan 2009 00:24:35 -0600 Subject: [rspec-users] Cucumber speed tips In-Reply-To: References: <8E28160D-A681-48DE-A983-E9D36007027C@lukemelia.com> <49601B10.8020902@benmabey.com> <2F917216-123A-467B-A35E-1FA5BF8CBC79@lukemelia.com> <49614F7B.4010803@benmabey.com> Message-ID: Josh, Ben & Luke -- This is great stuff, thanks a bunch. Over at CaptainU we are probably going to get into the thousands in the next few weeks or so, so speed is a serious issue. I'm going to work on a longer blog post about this, will let you guys know when finished. Best, M On Mon, Jan 5, 2009 at 10:38 PM, Luke Melia wrote: > On Jan 4, 2009, at 7:08 PM, Ben Mabey wrote: > > I'm by no means a Selenium expert so I may be making some incorrect >> assumptions. I thought that it was possible with Selenium to have different >> sessions open concurrently for the same selenium server. (i.e. have more >> than one SeleniumDriver/browser instance running against the same server but >> with different session ids.) Is that not possible? >> > > > Not that I know of, but now that you mention it, seems like it would be > pretty cool. Anyone else on the list done this? > -- > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivorpaul at gmail.com Tue Jan 6 03:47:45 2009 From: ivorpaul at gmail.com (Ivor Paul) Date: Tue, 6 Jan 2009 10:47:45 +0200 Subject: [rspec-users] options:229 error Message-ID: Hi Guys I am really having incredible issues with this error ivor at TheLuggage:~/workspace/talkies$ rake db:migrate (in /home/ivor/workspace/talkies) /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in `files_to_load': File or directory not found: db:migrate (RuntimeError) from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in `each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in `files_to_load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in `run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in `register_at_exit_hook' from /usr/bin/rake:19 Is there a reliable fix, what is causing the issue and, is anyone else getting this? The comments, questions and related posts seem to have dried up. The problem seems to be very intermittent in my case. I was wondering if there is a failsafe solution. One thing that strikes me as odd is that we have rspec and rspec-rails in vendor/gems yet this error is being thrown in my /usr/lib... gems directory. Also, if I gem uninstall rspec I get an error saying that spec cannot be found. Any pointers would be appreciated. Regards Ivor -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott at railsnewbie.com Tue Jan 6 04:05:34 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 06 Jan 2009 04:05:34 -0500 Subject: [rspec-users] options:229 error In-Reply-To: References: Message-ID: <49631EDE.3050908@railsnewbie.com> Ivor Paul wrote: > Hi Guys > > I am really having incredible issues with this error > > ivor at TheLuggage:~/workspace/talkies$ rake db:migrate > (in /home/ivor/workspace/talkies) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > `files_to_load': File or directory not found: db:migrate (RuntimeError) > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `files_to_load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > `register_at_exit_hook' > from /usr/bin/rake:19 > > Is there a reliable fix, what is causing the issue and, is anyone else > getting this? The comments, questions and related posts seem to have > dried up. > > The problem seems to be very intermittent in my case. I was wondering > if there is a failsafe solution. > One thing that strikes me as odd is that we have rspec and rspec-rails > in vendor/gems yet this error is being thrown in my /usr/lib... gems > directory. Also, if I gem uninstall rspec I get an error saying that > spec cannot be found. > > Any pointers would be appreciated. > > Regards > Ivor Here's a pointer: Don't use rails' broken gem system. Use the tried and true method of putting rspec & rspec on rails in vendor/plugins. Scott From scott at railsnewbie.com Tue Jan 6 04:06:14 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 06 Jan 2009 04:06:14 -0500 Subject: [rspec-users] options:229 error In-Reply-To: References: Message-ID: <49631F06.8020300@railsnewbie.com> Ivor Paul wrote: > Hi Guys > > I am really having incredible issues with this error > > ivor at TheLuggage:~/workspace/talkies$ rake db:migrate > (in /home/ivor/workspace/talkies) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > `files_to_load': File or directory not found: db:migrate (RuntimeError) > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `files_to_load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > `register_at_exit_hook' > from /usr/bin/rake:19 > > Is there a reliable fix, what is causing the issue and, is anyone else > getting this? The comments, questions and related posts seem to have > dried up. > > The problem seems to be very intermittent in my case. I was wondering > if there is a failsafe solution. > One thing that strikes me as odd is that we have rspec and rspec-rails > in vendor/gems yet this error is being thrown in my /usr/lib... gems > directory. Also, if I gem uninstall rspec I get an error saying that > spec cannot be found. I guess you don't have the gem unpacked? Scott From dchelimsky at gmail.com Tue Jan 6 07:43:23 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 06:43:23 -0600 Subject: [rspec-users] options:229 error In-Reply-To: References: Message-ID: <57c63afe0901060443q28e75e68x1bac84b2f97b06ad@mail.gmail.com> On Tue, Jan 6, 2009 at 2:47 AM, Ivor Paul wrote: > Hi Guys > > I am really having incredible issues with this error > > ivor at TheLuggage:~/workspace/talkies$ rake db:migrate > (in /home/ivor/workspace/talkies) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > `files_to_load': File or directory not found: db:migrate (RuntimeError) > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `files_to_load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in > `run' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > `register_at_exit_hook' > from /usr/bin/rake:19 > > Is there a reliable fix, what is causing the issue and, is anyone else > getting this? The comments, questions and related posts seem to have dried > up. If you've got rspec and rspec-rails configured as gems, try moving that configuration to config/environments/test.rb. > > The problem seems to be very intermittent in my case. I was wondering if > there is a failsafe solution. > One thing that strikes me as odd is that we have rspec and rspec-rails in > vendor/gems yet this error is being thrown in my /usr/lib... gems directory. > Also, if I gem uninstall rspec I get an error saying that spec cannot be > found. > > Any pointers would be appreciated. > > Regards > Ivor > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Jan 6 08:02:02 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 6 Jan 2009 14:02:02 +0100 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: References: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> Message-ID: <8d961d900901060502k347747b4if7f8a4e5f2382d33@mail.gmail.com> On Tue, Jan 6, 2009 at 4:29 AM, Reza Primardiansyah < reza.primardiansyah at gmail.com> wrote: > Aslak, > The best time I get is 6.3 seconds. I'm using "time script/server" command > and hitting Ctrl-C immediately after I see "** Use CTRL-C to stop." > Ok, so you have 5 seconds of additional overhead. I'm guessing that RSpec takes maybe 0.5-1 seconds of the remaining 6 seconds overhead, and that plugins, gems and other code the rest. Maybe you'll find out more with http://ruby-prof.rubyforge.org/ Aslak > > > On Sun, Jan 4, 2009 at 9:43 PM, aslak hellesoy wrote: > >> >> >> On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah < >> reza.primardiansyah at gmail.com> wrote: >> >>> Greetings, >>> I found out that running RSpec on Rails takes too much overhead. It takes >>> more than 16s per run although the specs only take less than 6s, like seen >>> below. That means almost 11s overhead. >>> I can't find the bottleneck. I use latest rspec, and rails 2.2 on Debian. >>> >>> $ time rake spec >>>> (in /home/reza/system) >>>> >>>> .................................................................................................................................................................................................................................................................................................................................................... >>>> >>>> Finished in 5.493595 seconds >>>> >>>> 340 examples, 0 failures >>>> >>>> real 0m16.497s >>>> user 0m14.059s >>>> sys 0m2.266s >>>> >>> >>> I know that Debian's ruby is slow. So I tried using enterprise ruby. Not >>> much difference >>> >>> $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec >>>> (in /home/reza/system) >>>> >>>> .................................................................................................................................................................................................................................................................................................................................................... >>>> >>>> Finished in 3.170093 seconds >>>> >>>> 340 examples, 0 failures >>>> >>>> real 0m12.033s >>>> user 0m9.948s >>>> sys 0m1.735s >>>> >>> >>> The overhead is also felt when using autospec. Even using sqlite's >>> in-memory-db doesn't change much. >>> >>> Can anyone give me hint about what happens and what to do to overcome it? >>> >> >> How long does ruby script/server take before the server is up? >> >> Aslak >> >> >>> >>> Thanks all. >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Tue Jan 6 08:52:31 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 6 Jan 2009 13:52:31 +0000 Subject: [rspec-users] Rspec Rails high overhead In-Reply-To: <8d961d900901060502k347747b4if7f8a4e5f2382d33@mail.gmail.com> References: <8d961d900901040643k6d8e2967je6ec475bbc0db9ac@mail.gmail.com> <8d961d900901060502k347747b4if7f8a4e5f2382d33@mail.gmail.com> Message-ID: On 6 Jan 2009, at 13:02, aslak hellesoy wrote: > > > On Tue, Jan 6, 2009 at 4:29 AM, Reza Primardiansyah > wrote: > Aslak, > The best time I get is 6.3 seconds. I'm using "time script/server" > command and hitting Ctrl-C immediately after I see "** Use CTRL-C to > stop." > > Ok, so you have 5 seconds of additional overhead. I'm guessing that > RSpec takes maybe 0.5-1 seconds of the remaining 6 seconds overhead, > and that plugins, gems and other code the rest. Maybe you'll find > out more with http://ruby-prof.rubyforge.org/ > > Aslak Worth mentioning that I went down a huge rabbit hole with a similar problem (slow load of rails environment) a few weeks ago, and it turned out that all I needed was a reboot. (Mac OSX Leopard). Boy, did I feel like a chump! > > > > > > On Sun, Jan 4, 2009 at 9:43 PM, aslak hellesoy > wrote: > > > On Sun, Jan 4, 2009 at 3:58 AM, Reza Primardiansyah > wrote: > Greetings, > I found out that running RSpec on Rails takes too much overhead. It > takes more than 16s per run although the specs only take less than > 6s, like seen below. That means almost 11s overhead. > I can't find the bottleneck. I use latest rspec, and rails 2.2 on > Debian. > > $ time rake spec > (in /home/reza/system) > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 5.493595 seconds > > 340 examples, 0 failures > > real 0m16.497s > user 0m14.059s > sys 0m2.266s > > I know that Debian's ruby is slow. So I tried using enterprise ruby. > Not much difference > > $ time /opt/ruby-enterprise/bin/ruby /var/lib/gems/1.8/bin/rake spec > (in /home/reza/system) > .................................................................................................................................................................................................................................................................................................................................................... > > Finished in 3.170093 seconds > > 340 examples, 0 failures > > real 0m12.033s > user 0m9.948s > sys 0m1.735s > > The overhead is also felt when using autospec. Even using sqlite's > in-memory-db doesn't change much. > > Can anyone give me hint about what happens and what to do to > overcome it? > > How long does ruby script/server take before the server is up? > > Aslak > > > Thanks all. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.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 Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at matt-darby.com Tue Jan 6 10:53:12 2009 From: matt at matt-darby.com (Matt Darby) Date: Tue, 6 Jan 2009 10:53:12 -0500 Subject: [rspec-users] Help with controller spec? Message-ID: I'm stumped. How would I go about specing the "update_sandbox" method? # bids_controller: def new @bid = Bid.new respond_to do |wants| wants.html { redirect_to job_bids_path(@job) } wants.js { update_sandbox do render_to_string :partial => 'new', :locals => {:bid => @bid, :job => @job} end } end end Here is my 4789th stab at it: # bids_controller_spec.rb it "should render new template" do sandbox = mock("Sandbox") controller.stub!(:update_sandbox).and_return(sandbox) sandbox.stub!(:render_to_string).with(:partial => 'new', :locals => {:bid => @bid, :job => @job}) sandbox.should_receive(:render_to_string).with(:partial => 'new', :locals => {:bid => @bid, :job => @job}) controller.should_receive(:update_sandbox) xhr :get, :new end # => Mock 'Sandbox' expected :render_to_string with ({:partial=>"new", :locals=>{:job=>#, :bid=>#}}) once, but received it 0 times Any pointers would be greatly appreciated! Thanks! Matt Darby, M.S. Rails | PHP | Linux | MySQL | IT Email: matt /\at/\ matt-darby.com Skype: matt-darby Web: http://blog.matt-darby.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jan 6 11:27:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 10:27:42 -0600 Subject: [rspec-users] Help with controller spec? In-Reply-To: References: Message-ID: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> On Tue, Jan 6, 2009 at 9:53 AM, Matt Darby wrote: > I'm stumped. How would I go about specing the "update_sandbox" method? > # bids_controller: > def new > @bid = Bid.new > > respond_to do |wants| > wants.html { redirect_to job_bids_path(@job) } > wants.js { > update_sandbox do > render_to_string :partial => 'new', :locals => {:bid => @bid, :job > => @job} > end > } > end > end > > Here is my 4789th stab at it: > # bids_controller_spec.rb > it "should render new template" do > sandbox = mock("Sandbox") > controller.stub!(:update_sandbox).and_return(sandbox) > sandbox.stub!(:render_to_string).with(:partial => 'new', :locals => > {:bid => @bid, :job => @job}) > > sandbox.should_receive(:render_to_string).with(:partial => 'new', > :locals => {:bid => @bid, :job => @job}) > controller.should_receive(:update_sandbox) I'm just guessing here, because I don't know what #update_sandbox does, but you probably want this to yield the sandbox: controller.should_receive(:update_sandbox).and_yield(sandbox) Let us know if that works. Cheers, David > > xhr :get, :new > end > # => Mock 'Sandbox' expected :render_to_string with ({:partial=>"new", > :locals=>{:job=>#, :bid=># @name="Bid_1015">}}) once, but received it 0 times > Any pointers would be greatly appreciated! > > > Thanks! > Matt Darby, M.S. > Rails | PHP | Linux | MySQL | IT > Email: matt /\at/\ matt-darby.com > Skype: matt-darby > Web: http://blog.matt-darby.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at matt-darby.com Tue Jan 6 11:41:48 2009 From: matt at matt-darby.com (Matt Darby) Date: Tue, 6 Jan 2009 11:41:48 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> References: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> Message-ID: <46EAD556-8462-4FFD-A3AB-CF7F62F5082D@matt-darby.com> On Jan 6, 2009, at 11:27 AM, David Chelimsky wrote: > On Tue, Jan 6, 2009 at 9:53 AM, Matt Darby > wrote: >> I'm stumped. How would I go about specing the "update_sandbox" >> method? >> # bids_controller: >> def new >> @bid = Bid.new >> >> respond_to do |wants| >> wants.html { redirect_to job_bids_path(@job) } >> wants.js { >> update_sandbox do >> render_to_string :partial => 'new', :locals => {:bid => >> @bid, :job >> => @job} >> end >> } >> end >> end >> >> Here is my 4789th stab at it: >> # bids_controller_spec.rb >> it "should render new template" do >> sandbox = mock("Sandbox") >> controller.stub!(:update_sandbox).and_return(sandbox) >> sandbox.stub!(:render_to_string).with(:partial => >> 'new', :locals => >> {:bid => @bid, :job => @job}) >> >> sandbox.should_receive(:render_to_string).with(:partial => >> 'new', >> :locals => {:bid => @bid, :job => @job}) >> controller.should_receive(:update_sandbox) > > I'm just guessing here, because I don't know what #update_sandbox > does, but you probably want this to yield the sandbox: > > controller.should_receive(:update_sandbox).and_yield(sandbox) > > Let us know if that works. > > Cheers, > David > Unfortunately, I get the same result. Here is the #update_sandbox method: # application.rb # RJS method to show new / edit partials def update_sandbox(obj = nil, &block) highlight_this_div = obj ? dom_id(obj) : :sandbox render :update do |page| page[:error_div].hide page.replace_html :sandbox, capture(&block) page.visual_effect :scroll_to, :sandbox page.visual_effect :highlight, highlight_this_div end end Thanks for your help David! >> >> xhr :get, :new >> end >> # => Mock 'Sandbox' expected :render_to_string with >> ({:partial=>"new", >> :locals=>{:job=>#, :bid=>#> 0x2b46f0c >> @name="Bid_1015">}}) once, but received it 0 times >> Any pointers would be greatly appreciated! >> >> >> Thanks! >> Matt Darby, M.S. >> Rails | PHP | Linux | MySQL | IT >> Email: matt /\at/\ matt-darby.com >> Skype: matt-darby >> Web: http://blog.matt-darby.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 joahking at gmail.com Tue Jan 6 11:47:23 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Tue, 6 Jan 2009 17:47:23 +0100 Subject: [rspec-users] rack app to browse specs In-Reply-To: <8277b7f40901041031l3a1fe8d4v6c6150bfee3cb944@mail.gmail.com> References: <8277b7f40901041031l3a1fe8d4v6c6150bfee3cb944@mail.gmail.com> Message-ID: <8277b7f40901060847n6d04b656w7ee4dd5069318357@mail.gmail.com> hello there, I've added support to browse/run cucumber features to the app, check it out in gist: http://gist.github.com/43149 right now you can: browse your spec/ and features/ directory run specs and feature files living there. it is only a .rb script to put into spec (or features) directory I've also moved the gists to a normal repo at: http://github.com/joahking/rack-rspec-html/tree/master I hope it helps somebody ;-) joaquin -- www.least-significant-bit.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jan 6 11:48:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 10:48:08 -0600 Subject: [rspec-users] Help with controller spec? In-Reply-To: <46EAD556-8462-4FFD-A3AB-CF7F62F5082D@matt-darby.com> References: <57c63afe0901060827u123ae68do2bb993ae901584f5@mail.gmail.com> <46EAD556-8462-4FFD-A3AB-CF7F62F5082D@matt-darby.com> Message-ID: <57c63afe0901060848l2a373acbi40cdc15a4cddb219@mail.gmail.com> On Tue, Jan 6, 2009 at 10:41 AM, Matt Darby wrote: > On Jan 6, 2009, at 11:27 AM, David Chelimsky wrote: > >> On Tue, Jan 6, 2009 at 9:53 AM, Matt Darby wrote: >>> >>> I'm stumped. How would I go about specing the "update_sandbox" method? >>> # bids_controller: >>> def new >>> @bid = Bid.new >>> >>> respond_to do |wants| >>> wants.html { redirect_to job_bids_path(@job) } >>> wants.js { >>> update_sandbox do >>> render_to_string :partial => 'new', :locals => {:bid => @bid, >>> :job >>> => @job} >>> end >>> } >>> end >>> end >>> >>> Here is my 4789th stab at it: >>> # bids_controller_spec.rb >>> it "should render new template" do >>> sandbox = mock("Sandbox") >>> controller.stub!(:update_sandbox).and_return(sandbox) >>> sandbox.stub!(:render_to_string).with(:partial => 'new', :locals => >>> {:bid => @bid, :job => @job}) >>> >>> sandbox.should_receive(:render_to_string).with(:partial => 'new', >>> :locals => {:bid => @bid, :job => @job}) >>> controller.should_receive(:update_sandbox) >> >> I'm just guessing here, because I don't know what #update_sandbox >> does, but you probably want this to yield the sandbox: >> >> controller.should_receive(:update_sandbox).and_yield(sandbox) >> >> Let us know if that works. >> >> Cheers, >> David >> > > Unfortunately, I get the same result. Here is the #update_sandbox method: > > # application.rb > # RJS method to show new / edit partials > def update_sandbox(obj = nil, &block) > highlight_this_div = obj ? dom_id(obj) : :sandbox > > render :update do |page| > page[:error_div].hide > page.replace_html :sandbox, capture(&block) This call to capture(&block) is what's going to result in eval'ing the block w/ render_to_string in it. Since update_sandbox is being stubbed, it is never actually called, so it makes perfect sense that this call to capture which evals the &block is never called. I'd go for a higher level expectation here instead of specifying the internal behaviour of update_sandbox. Something like setting an expectation that specific stuff shows up in the output. HTH, David > page.visual_effect :scroll_to, :sandbox > page.visual_effect :highlight, highlight_this_div > end > end > > > Thanks for your help David! > > > >>> >>> xhr :get, :new >>> end >>> # => Mock 'Sandbox' expected :render_to_string with ({:partial=>"new", >>> :locals=>{:job=>#, :bid=>#>> @name="Bid_1015">}}) once, but received it 0 times >>> Any pointers would be greatly appreciated! >>> >>> >>> Thanks! >>> Matt Darby, M.S. >>> Rails | PHP | Linux | MySQL | IT >>> Email: matt /\at/\ matt-darby.com >>> Skype: matt-darby >>> Web: http://blog.matt-darby.com >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Tue Jan 6 13:16:08 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 6 Jan 2009 13:16:08 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: References: Message-ID: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> On Tue, Jan 6, 2009 at 10:53 AM, Matt Darby wrote: > I'm stumped. How would I go about specing the "update_sandbox" method? I couldn't hope to compete with David's answer when it comes to specifics, but more generally, it occurs to me that your question is a little imprecise and that could point to part of the cognitive disconnect. You ask how to spec the method, but you're NOT specing the "update_sandbox" method in the example you posted. You're specing a controller's "new" action. Creating a stub or mock for a method isn't the same as specing it. A spec tests something to see if it does what it's supposed to. Mocking or stubbing is the opposite: instead of testing the method, you're pretending the method doesn't exist and replacing it with a cardboard cutout. Other things I noticed: 1.) There's really no point in putting identical stub!() and should_receive() declarations in the same example. should_receive() does everything stub!() does and slightly more. It replaces the method AND says "Complain if this doesn't get called." When you see them used in the same spec file, what you're usually seeing is stub!() in the "before" blocks just to replace external interfaces and make sure nothing breaks, and then should_receive() in multiple individual examples to prove that things called when they should. 2.) On that note, it's becoming more and more the accepted practice to have only one "should" per example. (Including "should_receives" or other mocks.) That way, if one of the expectations breaks, you'll know which one from the "it should..." text and won't have to look at individual lines. 3.) You _could_ probably make this spec work as it stands by changing the "update_sandbox" call to expect a Proc with the "render_to_string ..." block included; that's what actually happens when you call a method with a "do" block, you're passing it an anonymous Proc as a parameter. Tweak it enough and I'll bet you could get this to work. 4.) BUT, I agree with David, there's probably no point. At this level your spec becomes sort of trivial; you're not even testing behavior any more, you're testing for the existence of certain lines of code. Think big picture: WHY are you testing? What is it you want to prove? Your users don't care whether render_to_string() ever gets called with certain parameters, and tomorrow you won't care either. You DO care whether the controller's "new" method responds with an appropriate block of Javascript when accessed via AJAX. You can find that out by making the request and checking the response, but if you stub out the part that actually generates the Javascript, all you'll learn is "the controller get called and it responded." If that's all you want to know, you could mock update_sandbox to return "neener neener" and test for THAT. (And make sure to spec the update_sandbox() method thoroughly elsewhere.) 5.) OR... You might gain some good food for thought by going to the MerbCamp videos (http://merbcamp.com/video) and watching Yehuda Katz's video on testing (http://merbcamp.com/video/katz1.mp4). Don't worry about the Merb stuff; what he's describing is a general approach and it's just as applicable to Rails. The philosophy is somewhat contrary to the "unit test everything in isolation" philosophy that many others espouse, but it doesn't hurt to learn both and decide which style suits you best. I personally found Yehuda's approach to be a slap of cold water and then a breath of fresh air; since I started it, I've almost entirely stopped mocking things, and I no longer have the frustrating feeling that I'm spending 10x longer on tests (and testing my tests, and debugging my tests) than I am on my application features. But again: think for yourself, and decide what suits your goals and learning path. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From dchelimsky at gmail.com Tue Jan 6 13:24:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 Jan 2009 12:24:02 -0600 Subject: [rspec-users] Help with controller spec? In-Reply-To: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> References: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> Message-ID: <57c63afe0901061024n744d92f1h72ad696c23239fec@mail.gmail.com> On Tue, Jan 6, 2009 at 12:16 PM, Stephen Eley wrote: > On Tue, Jan 6, 2009 at 10:53 AM, Matt Darby wrote: >> I'm stumped. How would I go about specing the "update_sandbox" method? > > I couldn't hope to compete with David's answer when it comes to > specifics, but more generally, it occurs to me that your question is a > little imprecise and that could point to part of the cognitive > disconnect. You ask how to spec the method, but you're NOT specing > the "update_sandbox" method in the example you posted. You're specing > a controller's "new" action. Creating a stub or mock for a method > isn't the same as specing it. A spec tests something to see if it > does what it's supposed to. Mocking or stubbing is the opposite: > instead of testing the method, you're pretending the method doesn't > exist and replacing it with a cardboard cutout. > > Other things I noticed: > > 1.) There's really no point in putting identical stub!() and > should_receive() declarations in the same example. should_receive() > does everything stub!() does and slightly more. It replaces the > method AND says "Complain if this doesn't get called." When you see > them used in the same spec file, what you're usually seeing is stub!() > in the "before" blocks just to replace external interfaces and make > sure nothing breaks, and then should_receive() in multiple individual > examples to prove that things called when they should. > > 2.) On that note, it's becoming more and more the accepted practice to > have only one "should" per example. (Including "should_receives" or > other mocks.) That way, if one of the expectations breaks, you'll > know which one from the "it should..." text and won't have to look at > individual lines. > > 3.) You _could_ probably make this spec work as it stands by changing > the "update_sandbox" call to expect a Proc with the "render_to_string > ..." block included; that's what actually happens when you call a > method with a "do" block, you're passing it an anonymous Proc as a > parameter. Tweak it enough and I'll bet you could get this to work. > > 4.) BUT, I agree with David, there's probably no point. At this level > your spec becomes sort of trivial; you're not even testing behavior > any more, you're testing for the existence of certain lines of code. > Think big picture: WHY are you testing? What is it you want to prove? > Your users don't care whether render_to_string() ever gets called > with certain parameters, and tomorrow you won't care either. You DO > care whether the controller's "new" method responds with an > appropriate block of Javascript when accessed via AJAX. You can find > that out by making the request and checking the response, but if you > stub out the part that actually generates the Javascript, all you'll > learn is "the controller get called and it responded." If that's all > you want to know, you could mock update_sandbox to return "neener > neener" and test for THAT. (And make sure to spec the > update_sandbox() method thoroughly elsewhere.) > > 5.) OR... You might gain some good food for thought by going to the > MerbCamp videos (http://merbcamp.com/video) and watching Yehuda Katz's > video on testing (http://merbcamp.com/video/katz1.mp4). Don't worry > about the Merb stuff; what he's describing is a general approach and > it's just as applicable to Rails. The philosophy is somewhat contrary > to the "unit test everything in isolation" philosophy that many others > espouse, but it doesn't hurt to learn both and decide which style > suits you best. I'd refine that a bit: learn both and decide *when to apply each*. Choosing one style over the other limits your toolbox and consequently your ability to operate in different contexts. FWiW, David > > I personally found Yehuda's approach to be a slap of cold water and > then a breath of fresh air; since I started it, I've almost entirely > stopped mocking things, and I no longer have the frustrating feeling > that I'm spending 10x longer on tests (and testing my tests, and > debugging my tests) than I am on my application features. But again: > think for yourself, and decide what suits your goals and learning > path. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Tue Jan 6 13:50:28 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 6 Jan 2009 13:50:28 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: <57c63afe0901061024n744d92f1h72ad696c23239fec@mail.gmail.com> References: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> <57c63afe0901061024n744d92f1h72ad696c23239fec@mail.gmail.com> Message-ID: <1fb4df0901061050v56b4c7d1xc399d39307449ad6@mail.gmail.com> On Tue, Jan 6, 2009 at 1:24 PM, David Chelimsky wrote: > > I'd refine that a bit: learn both and decide *when to apply each*. > > Choosing one style over the other limits your toolbox and consequently > your ability to operate in different contexts. True, and good point. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From matt at matt-darby.com Tue Jan 6 13:53:28 2009 From: matt at matt-darby.com (Matt Darby) Date: Tue, 6 Jan 2009 13:53:28 -0500 Subject: [rspec-users] Help with controller spec? In-Reply-To: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> References: <1fb4df0901061016k68cb32aar79e1a46e2d77fae6@mail.gmail.com> Message-ID: <3ECF52E4-93DE-47A1-BA0A-02992E0294C4@matt-darby.com> On Jan 6, 2009, at 1:16 PM, Stephen Eley wrote: > On Tue, Jan 6, 2009 at 10:53 AM, Matt Darby > wrote: >> I'm stumped. How would I go about specing the "update_sandbox" >> method? > > I couldn't hope to compete with David's answer when it comes to > specifics, but more generally, it occurs to me that your question is a > little imprecise and that could point to part of the cognitive > disconnect. You ask how to spec the method, but you're NOT specing > the "update_sandbox" method in the example you posted. You're specing > a controller's "new" action. Creating a stub or mock for a method > isn't the same as specing it. A spec tests something to see if it > does what it's supposed to. Mocking or stubbing is the opposite: > instead of testing the method, you're pretending the method doesn't > exist and replacing it with a cardboard cutout. > Hi Stephen! My aim is to spec the Bid::new action; all it really does is call the #update_sandbox method with a particular block. If I am to test strictly the behavior of the action, I would really just be testing the View as it's based on RJS. The View is spec'd, but I need to simulate the actual updating of the View via the returned Javascript. > Other things I noticed: > > 1.) There's really no point in putting identical stub!() and > should_receive() declarations in the same example. should_receive() > does everything stub!() does and slightly more. It replaces the > method AND says "Complain if this doesn't get called." When you see > them used in the same spec file, what you're usually seeing is stub!() > in the "before" blocks just to replace external interfaces and make > sure nothing breaks, and then should_receive() in multiple individual > examples to prove that things called when they should. > Good to know! That will really clean up my specs (and save me a ton of typing!) > 2.) On that note, it's becoming more and more the accepted practice to > have only one "should" per example. (Including "should_receives" or > other mocks.) That way, if one of the expectations breaks, you'll > know which one from the "it should..." text and won't have to look at > individual lines. > Agreed, however, I wasn't sure how to approach this case as I'm testing a method and a block at the same time. By the time I'd arrived at the spec I originally posted I was well into the "Grasping At Straws" phase. > 3.) You _could_ probably make this spec work as it stands by changing > the "update_sandbox" call to expect a Proc with the "render_to_string > ..." block included; that's what actually happens when you call a > method with a "do" block, you're passing it an anonymous Proc as a > parameter. Tweak it enough and I'll bet you could get this to work. > Duly noted. > 4.) BUT, I agree with David, there's probably no point. At this level > your spec becomes sort of trivial; you're not even testing behavior > any more, you're testing for the existence of certain lines of code. > Think big picture: WHY are you testing? What is it you want to prove? > Your users don't care whether render_to_string() ever gets called > with certain parameters, and tomorrow you won't care either. You DO > care whether the controller's "new" method responds with an > appropriate block of Javascript when accessed via AJAX. You can find > that out by making the request and checking the response, but if you > stub out the part that actually generates the Javascript, all you'll > learn is "the controller get called and it responded." If that's all > you want to know, you could mock update_sandbox to return "neener > neener" and test for THAT. (And make sure to spec the > update_sandbox() method thoroughly elsewhere.) > I don't necessarily care what #update_sandbox actually produces, I just want to make sure that it is called with the expected "render_to_string" call. Can you clarify "making the request and checking the response"? Is it possible to just check the "xhr :get, :index" call for a standard hunk of Javascript? If so, problem solved -- again, I don't yet have a super firm grip on controller specing when AJAX/RJS is concerned. I'm eagerly awaiting David's book! > 5.) OR... You might gain some good food for thought by going to the > MerbCamp videos (http://merbcamp.com/video) and watching Yehuda Katz's > video on testing (http://merbcamp.com/video/katz1.mp4). Don't worry > about the Merb stuff; what he's describing is a general approach and > it's just as applicable to Rails. The philosophy is somewhat contrary > to the "unit test everything in isolation" philosophy that many others > espouse, but it doesn't hurt to learn both and decide which style > suits you best. > I shall, thanks for the pointer. > I personally found Yehuda's approach to be a slap of cold water and > then a breath of fresh air; since I started it, I've almost entirely > stopped mocking things, and I no longer have the frustrating feeling > that I'm spending 10x longer on tests (and testing my tests, and > debugging my tests) than I am on my application features. But again: > think for yourself, and decide what suits your goals and learning > path. > Thank you for your reply, it was really very insightful and I'm sure others will learn from it as well! > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Tue Jan 6 16:08:33 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 6 Jan 2009 22:08:33 +0100 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> Message-ID: <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> Zach Dennis wrote: > > Does your outputted HTML properly include a tbody in the table? If so > the selector you are using won't work. You would need to make match > any descendant rather than any direct child, ie: "table > tr#entity_id_1" > I cannot find one if there is. > On a related note (although not specific your problem at hand) to > generate an id on an ActiveRecord model you can use the dom_id helper > method provided by Rails. ie: "dom_id(entity)". You can use this both > in your template and your steps/specs. And rather than hardcoding > "table tr" CSS selectors why not just give your table an id like > "entities" and then use dom_id to give your rows ids? Should you > change the display to a ul or ol you wouldn't have to go back and > change your CSS selectors, Could you provide a reference to an example of how this is done? I am afraid that the API was insufficient to clarify this for me. Thank you for your help. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue Jan 6 18:08:11 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 6 Jan 2009 23:08:11 +0000 Subject: [rspec-users] Cucumber: acceptance testing OAuth Message-ID: Hi, We're adding OAuth support for our API, and I paired with the guy who's spiked it today to try and write some features to drive out the behaviour we need. It ended up getting quite tricky, so if you don't mind I'd like to bounce my ideas of this list and see what you think. The spike uses the OAuth Provider plugin[1] which is what we're planning to integrate. This adds a ClientApplication model to your database. A ClientApplication represents, for example, the flickr uploader application that I've downlaoded. One User has many ClientApplications. A ClientApplication instance has a #key and a #secret which are stored on the server, and also known by the application on the client side which it represents. Anyway, so back to my Cucumber scenario. In the Given step, I create a User and a ClientApplication. Now I have to pretend to be the actual API client making a request to my rails app. At this point, I need to make some special magic OAuth parameters for the HTTP request, called 'signature' and 'signature_method'. These signify some magic munging of the key and secret for the ClientApplication which will (hopefully) be understood and processed by the SUT. In the real world, you would delegate the work of talking to an OAuth provider like this to the oauth gem[2]. I had a crack, for an hour or so, to use the gem in my When step, injecting a fake replacement for the Net::HTTP which it uses and instead forwarding calls to rails IntegrationSession post / get methods. This wasn't easy. Net::HTTPResponse objects don't look much like ActionController::CgiResponse objects, for example, so you have to do a lot of bridging. So I feel like it's time to pull back and have a re-think. Has anyone else tried to do something similar, and has some code to bridge from Net::HTTP objects to the ones used by Rails' Test::IntegrationSession? Am we barking up the wrong tree? Should we perhaps just spin up a web server for the test session and just go ahead and call the app through the gem? Any other ideas? Am I missing anything else obvious? All thoughts greatly appreciated guys! cheers, Matt Wynne http://blog.mattwynne.net http://www.songkick.com [1] http://github.com/pelle/oauth-plugin/tree/master [2] http://github.com/pelle/oauth/tree/master From ben at benmabey.com Tue Jan 6 18:29:53 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 06 Jan 2009 16:29:53 -0700 Subject: [rspec-users] Cucumber: acceptance testing OAuth In-Reply-To: References: Message-ID: <4963E971.2050507@benmabey.com> On 1/6/09 4:08 PM, Matt Wynne wrote: > Hi, > > We're adding OAuth support for our API, and I paired with the guy > who's spiked it today to try and write some features to drive out the > behaviour we need. > > It ended up getting quite tricky, so if you don't mind I'd like to > bounce my ideas of this list and see what you think. > > The spike uses the OAuth Provider plugin[1] which is what we're > planning to integrate. This adds a ClientApplication model to your > database. A ClientApplication represents, for example, the flickr > uploader application that I've downlaoded. One User has many > ClientApplications. > > A ClientApplication instance has a #key and a #secret which are stored > on the server, and also known by the application on the client side > which it represents. > > > Anyway, so back to my Cucumber scenario. > > In the Given step, I create a User and a ClientApplication. Now I have > to pretend to be the actual API client making a request to my rails app. > > At this point, I need to make some special magic OAuth parameters for > the HTTP request, called 'signature' and 'signature_method'. These > signify some magic munging of the key and secret for the > ClientApplication which will (hopefully) be understood and processed > by the SUT. > > In the real world, you would delegate the work of talking to an OAuth > provider like this to the oauth gem[2]. I had a crack, for an hour or > so, to use the gem in my When step, injecting a fake replacement for > the Net::HTTP which it uses and instead forwarding calls to rails > IntegrationSession post / get methods. > > This wasn't easy. Net::HTTPResponse objects don't look much like > ActionController::CgiResponse objects, for example, so you have to do > a lot of bridging. > > > So I feel like it's time to pull back and have a re-think. Has anyone > else tried to do something similar, and has some code to bridge from > Net::HTTP objects to the ones used by Rails' Test::IntegrationSession? > > Am we barking up the wrong tree? Should we perhaps just spin up a web > server for the test session and just go ahead and call the app through > the gem? > > Any other ideas? Am I missing anything else obvious? > > All thoughts greatly appreciated guys! > > cheers, > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > [1] http://github.com/pelle/oauth-plugin/tree/master > [2] http://github.com/pelle/oauth/tree/master > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hey Matt, I don't know the first thing about OAuth and what integrating it into an app entails. Is it too much of a simplification in saying that it is a third-party webservice that you need to stub out the Net::HTTP requests for? If not, then this post may give you some ideas: http://technicalpickles.com/posts/stop-net-http-dead-in-its-tracks-with-fakeweb Sorry if this wasn't too much help.. I guess I don't understand what sort of "bridge from Net::HTTP objects to the ones used by Rails' Test::IntegrationSession" really means. -Ben From matt at mattwynne.net Tue Jan 6 19:33:20 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 00:33:20 +0000 Subject: [rspec-users] Cucumber: acceptance testing OAuth In-Reply-To: <4963E971.2050507@benmabey.com> References: <4963E971.2050507@benmabey.com> Message-ID: <29787CC6-FAB9-4A95-B6D6-B30F4DF46B69@mattwynne.net> On 6 Jan 2009, at 23:29, Ben Mabey wrote: > On 1/6/09 4:08 PM, Matt Wynne wrote: >> Hi, >> >> We're adding OAuth support for our API, and I paired with the guy >> who's spiked it today to try and write some features to drive out >> the behaviour we need. >> >> It ended up getting quite tricky, so if you don't mind I'd like to >> bounce my ideas of this list and see what you think. >> >> The spike uses the OAuth Provider plugin[1] which is what we're >> planning to integrate. This adds a ClientApplication model to your >> database. A ClientApplication represents, for example, the flickr >> uploader application that I've downlaoded. One User has many >> ClientApplications. >> >> A ClientApplication instance has a #key and a #secret which are >> stored on the server, and also known by the application on the >> client side which it represents. >> >> >> Anyway, so back to my Cucumber scenario. >> >> In the Given step, I create a User and a ClientApplication. Now I >> have to pretend to be the actual API client making a request to my >> rails app. >> >> At this point, I need to make some special magic OAuth parameters >> for the HTTP request, called 'signature' and 'signature_method'. >> These signify some magic munging of the key and secret for the >> ClientApplication which will (hopefully) be understood and >> processed by the SUT. >> >> In the real world, you would delegate the work of talking to an >> OAuth provider like this to the oauth gem[2]. I had a crack, for an >> hour or so, to use the gem in my When step, injecting a fake >> replacement for the Net::HTTP which it uses and instead forwarding >> calls to rails IntegrationSession post / get methods. >> >> This wasn't easy. Net::HTTPResponse objects don't look much like >> ActionController::CgiResponse objects, for example, so you have to >> do a lot of bridging. >> >> >> So I feel like it's time to pull back and have a re-think. Has >> anyone else tried to do something similar, and has some code to >> bridge from Net::HTTP objects to the ones used by Rails' >> Test::IntegrationSession? >> >> Am we barking up the wrong tree? Should we perhaps just spin up a >> web server for the test session and just go ahead and call the app >> through the gem? >> >> Any other ideas? Am I missing anything else obvious? >> >> All thoughts greatly appreciated guys! >> >> cheers, >> >> Matt Wynne >> http://blog.mattwynne.net >> http://www.songkick.com >> >> [1] http://github.com/pelle/oauth-plugin/tree/master >> [2] http://github.com/pelle/oauth/tree/master >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > Hey Matt, > I don't know the first thing about OAuth and what integrating it > into an app entails. Is it too much of a simplification in saying > that it is a third-party webservice that you need to stub out the > Net::HTTP requests for? If not, then this post may give you some > ideas: > http://technicalpickles.com/posts/stop-net-http-dead-in-its-tracks-with-fakeweb > > Sorry if this wasn't too much help.. I guess I don't understand what > sort of "bridge from Net::HTTP objects to the ones used by Rails' > Test::IntegrationSession" really means. Yeah I know that was pretty rambling. Let me have another go at explaining what I'm trying to do, for the benefit of anyone else who might be wondering what I'm on about. Real world: API Client -> OAuth Gem -> Net::HTTP -> (The Internet) -> My Rails App So in order to acceptance-test my Rails app's OAuth features, I need to make requests that look a lot like the ones made by the OAuth gem when the API client asks it to call my Rails app and authenticate itself. So it's not so much that Net::HTTP is a dependency I want to stub out, as it's a test-driver I want to leverage. I had figured I might be able to do something like this: Cucumber Steps -> OAuth Gem -> Patched Net::HTTP -> Test::IntegrationSession -> My Rails App The 'bridge' I'm talking about is something that looks enough like Net::HTTP for the OAuth gem to be happy to talk to it, but that will actually pass on it's calls to the Rails Test::IntegrationSession get / post methods, and pass back the response. Does that make any more sense? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From zach.dennis at gmail.com Tue Jan 6 19:53:55 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 6 Jan 2009 19:53:55 -0500 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> Message-ID: <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> On Tue, Jan 6, 2009 at 4:08 PM, James Byrne wrote: > Zach Dennis wrote: >> >> Does your outputted HTML properly include a tbody in the table? If so >> the selector you are using won't work. You would need to make match >> any descendant rather than any direct child, ie: "table >> tr#entity_id_1" >> > > I cannot find one if there is. > >> On a related note (although not specific your problem at hand) to >> generate an id on an ActiveRecord model you can use the dom_id helper >> method provided by Rails. ie: "dom_id(entity)". You can use this both >> in your template and your steps/specs. And rather than hardcoding >> "table tr" CSS selectors why not just give your table an id like >> "entities" and then use dom_id to give your rows ids? Should you >> change the display to a ul or ol you wouldn't have to go back and >> change your CSS selectors, > > Could you provide a reference to an example of how this is done? I am > afraid that the API was insufficient to clarify this for me. > When constructing HTML ids you can avoid concatenating strings, ie: "entity_id_" + my_entity.to_s Instead you can use this: dom_id(entity) You can also pass in additional identifiers: dom_id(entity, "show") If you use this in your steps and in your views themselves it cleans generating html ids up. In my cucumber env.rb I have added so the dom helpers are available throughout my steps Cucumber::Rails::World.class_eval do include ActionView::Helpers::RecordIdentificationHelper end Hope this helps, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From mark at markrichman.com Tue Jan 6 20:25:09 2009 From: mark at markrichman.com (Mark A. Richman) Date: Tue, 6 Jan 2009 20:25:09 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" Message-ID: I am trying to get the following test to pass, and get this error. Since I'm only on day 4 of rspec, I'm sure I'm missing something simple. Any ideas? ## rake spec 'PatientsController GET 'new' should be successful' FAILED expected success? to return true, got false ./spec/controllers/patients_controller_spec.rb:27: ## patients_controller_spec.rb require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe PatientsController do integrate_views fixtures :all before(:each) do @user = mock_user @login_params = { :login => 'quentin', :password => 'monkey' } User.stub!(:authenticate).with(@login_params[:login], @login_params[:password]).and_return(@user) @user.stub!(:enabled?).and_return(true) @user.stub!(:account_id).and_return(1) @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') @user.stub!(:role).and_return('Normal') controller_bypass_authentication(@user) end #Delete these examples and add some real ones it "should use PatientsController" do controller.should be_an_instance_of(PatientsController) end describe "GET 'new'" do it "should be successful" do get 'new' response.should be_success # this is the offending line 27 end end end # Allows a spec to bypass auth for controllers that filter for logged_in user def controller_bypass_authentication(user=nil) controller.stub!(:logged_in).and_return(true) controller.stub!(:authorized?).and_return(true) controller.stub!(:current_user).and_return(user) end ## patients_controller.rb ... def new @patient = Patient.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @patient } end end ... http://www.pastie.org/354313 -------------- next part -------------- An HTML attachment was scrubbed... URL: From cougar2149 at gmail.com Wed Jan 7 01:29:50 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Wed, 7 Jan 2009 11:59:50 +0530 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures Message-ID: Hi, I get this error when I do $spec /spec/any_spec /home/waseem/app/spec/spec_helper.rb:14: undefined method `use_transactional_fixtures=' for # (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:184:in `configure' from /home/waseem/app/spec/spec_helper.rb:10 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ./spec/controllers/user_sessions_controller_spec.rb:1 from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in `load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in `run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 from /usr/bin/spec:19:in `load' from /usr/bin/spec:19 I googled it and got http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-moresee Maxim's comment What could be possibly wrong? -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Wed Jan 7 02:23:42 2009 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 7 Jan 2009 01:23:42 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: Message-ID: this may help: http://themomorohoax.com/2008/12/17/rails-2-3-tests On Wed, Jan 7, 2009 at 12:29 AM, waseem ahmad wrote: > Hi, > > I get this error when I do > > $spec /spec/any_spec > > /home/waseem/app/spec/spec_helper.rb:14: undefined method > `use_transactional_fixtures=' for # > (NoMethodError) > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:184:in > `configure' > from /home/waseem/app/spec/spec_helper.rb:10 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > from ./spec/controllers/user_sessions_controller_spec.rb:1 > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in > `run' > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 > from /usr/bin/spec:19:in `load' > from /usr/bin/spec:19 > > I googled it and got > http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-moresee Maxim's comment > > What could be possibly wrong? > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.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 dchelimsky at gmail.com Wed Jan 7 04:25:57 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Jan 2009 03:25:57 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: Message-ID: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> On Wed, Jan 7, 2009 at 12:29 AM, waseem ahmad wrote: > Hi, > > I get this error when I do > > $spec /spec/any_spec > > /home/waseem/app/spec/spec_helper.rb:14: undefined method > `use_transactional_fixtures=' for # > (NoMethodError) > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:184:in > `configure' > from /home/waseem/app/spec/spec_helper.rb:10 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require' > from ./spec/controllers/user_sessions_controller_spec.rb:1 > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `each' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in > `load_files' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in > `run' > from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 > from /usr/bin/spec:19:in `load' > from /usr/bin/spec:19 > > I googled it and got > http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-more > see Maxim's comment > > What could be possibly wrong? Seems like it's not loading up rspec-rails' Configuration object. In order for that to happen implicitly, the specs need to be in any of spec/models, spec/controllers, spec/views, spec/helpers. Is your file in one of those? > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.com From colinjack at hotmail.com Wed Jan 7 04:31:46 2009 From: colinjack at hotmail.com (Colin Jack) Date: Wed, 7 Jan 2009 09:31:46 +0000 Subject: [rspec-users] Cucumber - Performance Message-ID: Hi, Small question on performance. I've just run the CS example provided with Cucumber and it took about 45-50 seconds before the first output appeared in the console, but once this first output had appeared the tests completed quickly. I'm wondering whether this is the expected performance or whether the plan is to optimize it at some time in the future? Ta, Colin _________________________________________________________________ Are you a PC?? Upload your PC story and show the world http://clk.atdmt.com/UKM/go/122465942/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From cougar2149 at gmail.com Wed Jan 7 04:49:27 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Wed, 7 Jan 2009 15:19:27 +0530 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> Message-ID: On Wed, Jan 7, 2009 at 2:55 PM, David Chelimsky wrote: > Seems like it's not loading up rspec-rails' Configuration object. In > order for that to happen implicitly, the specs need to be in any of > spec/models, spec/controllers, spec/views, spec/helpers. Is your file > in one of those? > > Yeah the file is spec/controllers/user_sessions_controller.rb @Mischa: The pointer you gave talks about rails edge. Right now I am on rails 2.1 -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Wed Jan 7 06:36:45 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 11:36:45 +0000 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: References: Message-ID: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> On 7 Jan 2009, at 01:25, Mark A. Richman wrote: > I am trying to get the following test to pass, and get this error. > Since I'm only on day 4 of rspec, I'm sure I'm missing something > simple. Any ideas? > ## rake spec > > 'PatientsController GET 'new' should be successful' FAILED > > expected success? to return true, got false > ./spec/controllers/patients_controller_spec.rb:27: > > ## patients_controller_spec.rb > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > > describe PatientsController do > > integrate_views > fixtures :all > > before(:each) do > @user = mock_user > @login_params = { :login => 'quentin', :password => 'monkey' } > > User.stub!(:authenticate).with(@login_params[:login], > @login_params[:password]).and_return(@user) > @user.stub!(:enabled?).and_return(true) > @user.stub!(:account_id).and_return(1) > @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') > > @user.stub!(:role).and_return('Normal') > controller_bypass_authentication(@user) > end > > #Delete these examples and add some real ones > it "should use PatientsController" do > > controller.should be_an_instance_of(PatientsController) > end > > describe "GET 'new'" do > it "should be successful" do > get 'new' > response.should be_success # this is the offending line 27 > > end > end > end > > # Allows a spec to bypass auth for controllers that filter for > logged_in user > def controller_bypass_authentication(user=nil) > controller.stub!(:logged_in).and_return(true) > controller.stub!(:authorized?).and_return(true) > > controller.stub!(:current_user).and_return(user) > end > > ## patients_controller.rb > > ... > def new > @patient = Patient.new > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @patient } > > end > end > ... > http://www.pastie.org/354313 I don't think there's enough to go on here. We need to know why the request failed, and it could be for any number of reasons. You've shown us a load of test setup code for stubbing out your authentication mechanism, but you haven't shown us the actual authentication mechanism in your controller, so we have no way of knowing whether your stubs are good. I would start your debugging by adding a puts statement between lines 26 and 27 to show more of the (unexpected) response. Looking at response.code or response.body should give you some clues. By the way, did you know you can pass hashes of stubs to the mock() method? You could clean up your setup code quite a bit by doing this: @user = mock(User, :enabled? => true, :account_id => 1, :time_zone => 'Eastern Time (US & Canada)', :role => 'Normal') HTH, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Wed Jan 7 06:46:14 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 7 Jan 2009 12:46:14 +0100 Subject: [rspec-users] Cucumber - Performance In-Reply-To: References: Message-ID: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> On Wed, Jan 7, 2009 at 10:31 AM, Colin Jack wrote: > Hi, > > Small question on performance. I've just run the CS example provided with > Cucumber and it took about 45-50 seconds before the first output appeared in > the console, but once this first output had appeared the tests completed > quickly. > > I'm wondering whether this is the expected performance or whether the plan > is to optimize it at some time in the future? > > The reason it's so slow is that IronRuby is slow. That's where the optimisation will have to happen. It runs "fast" on JRuby, MRI and YARV. Aslak > > Ta, > > Colin > > ------------------------------ > Are you a PC? Upload your PC story and show the world > > _______________________________________________ > 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 matt at mattwynne.net Wed Jan 7 06:52:11 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 11:52:11 +0000 Subject: [rspec-users] Cucumber - Performance In-Reply-To: References: Message-ID: <2A03B818-5EF1-42F6-A7FD-9FE8D176AC6F@mattwynne.net> On 7 Jan 2009, at 09:31, Colin Jack wrote: > Hi, > > Small question on performance. I've just run the CS example provided > with Cucumber and it took about 45-50 seconds before the first > output appeared in the console, but once this first output had > appeared the tests completed quickly. > > I'm wondering whether this is the expected performance or whether > the plan is to optimize it at some time in the future? I normally just use MRI to run Cucumber, but I have tried JRuby a couple of times and noticed that was a bit slower to start up. I'd guess it's something similar with IronRuby - .NET apps are often slow to start up the first time in my experience, as the JIT compilation kicks in or whatever magic it is these days. Have you tried running any other Ruby tools through IronRuby? How do they perform? If you think it's a bug in Cucumber (even if one specific to running on the IronRuby platform) please raise a ticket at lighthouse[1]. Obviously the more you can do to diagnose the fault, the faster it's likely to be fixed. [1]http://rspec.lighthouseapp.com/projects/16211-cucumber/overview Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Wed Jan 7 06:55:27 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 11:55:27 +0000 Subject: [rspec-users] Cucumber - Performance In-Reply-To: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> References: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> Message-ID: <22FA105F-8A20-4CDB-B4EA-22C1BF506397@mattwynne.net> On 7 Jan 2009, at 11:46, aslak hellesoy wrote: > > > On Wed, Jan 7, 2009 at 10:31 AM, Colin Jack > wrote: > Hi, > > Small question on performance. I've just run the CS example provided > with Cucumber and it took about 45-50 seconds before the first > output appeared in the console, but once this first output had > appeared the tests completed quickly. > > I'm wondering whether this is the expected performance or whether > the plan is to optimize it at some time in the future? > > > The reason it's so slow is that IronRuby is slow. That's where the > optimisation will have to happen. It runs "fast" on JRuby, MRI and > YARV. My guess is that it's the initial start-up that's slow. This is a great reason to use something like autotest, which will keep the process loaded up. I wonder how that hell you could make that work with C# code though! Watch the DLLs?! Matt Wynne http://blog.mattwynne.net http://www.songkick.com From mark at markrichman.com Wed Jan 7 07:55:38 2009 From: mark at markrichman.com (Mark A. Richman) Date: Wed, 7 Jan 2009 07:55:38 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> References: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> Message-ID: Matt, Thank you very much. It turns out that a pair of authentication/authorization before_filters were interfering with the test. I got past it now by doing this: before(:each) do @user = mock_user @login_params = { :login => 'quentin', :password => 'monkey' } User.stub!(:authenticate).with(@login_params[:login], @login_params[:password]).and_return(@user) @user.stub!(:enabled?).and_return(true) @user.stub!(:account_id).and_return(1) @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') @user.stub!(:role).and_return('normal') User.stub!(:in_role?).with('limited').and_return(false) controller_bypass_authentication(@user) end I've got 3 roles in my app (admin, normal, and limited), in case you were curious about that. I didn't know about the hash trick. Thanks! - Mark On Wed, Jan 7, 2009 at 6:36 AM, Matt Wynne wrote: > On 7 Jan 2009, at 01:25, Mark A. Richman wrote: > > I am trying to get the following test to pass, and get this error. Since >> I'm only on day 4 of rspec, I'm sure I'm missing something simple. Any >> ideas? >> ## rake spec >> >> 'PatientsController GET 'new' should be successful' FAILED >> >> expected success? to return true, got false >> ./spec/controllers/patients_controller_spec.rb:27: >> >> ## patients_controller_spec.rb >> >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> >> >> describe PatientsController do >> >> integrate_views >> fixtures :all >> >> before(:each) do >> @user = mock_user >> @login_params = { :login => 'quentin', :password => 'monkey' } >> >> User.stub!(:authenticate).with(@login_params[:login], >> @login_params[:password]).and_return(@user) >> @user.stub!(:enabled?).and_return(true) >> @user.stub!(:account_id).and_return(1) >> @user.stub!(:time_zone).and_return('Eastern Time (US & Canada)') >> >> @user.stub!(:role).and_return('Normal') >> controller_bypass_authentication(@user) >> end >> >> #Delete these examples and add some real ones >> it "should use PatientsController" do >> >> controller.should be_an_instance_of(PatientsController) >> end >> >> describe "GET 'new'" do >> it "should be successful" do >> get 'new' >> response.should be_success # this is the offending line 27 >> >> end >> end >> end >> >> # Allows a spec to bypass auth for controllers that filter for logged_in >> user >> def controller_bypass_authentication(user=nil) >> controller.stub!(:logged_in).and_return(true) >> controller.stub!(:authorized?).and_return(true) >> >> controller.stub!(:current_user).and_return(user) >> end >> >> ## patients_controller.rb >> >> ... >> def new >> @patient = Patient.new >> >> respond_to do |format| >> format.html # new.html.erb >> format.xml { render :xml => @patient } >> >> end >> end >> ... >> http://www.pastie.org/354313 >> > > I don't think there's enough to go on here. We need to know why the request > failed, and it could be for any number of reasons. You've shown us a load of > test setup code for stubbing out your authentication mechanism, but you > haven't shown us the actual authentication mechanism in your controller, so > we have no way of knowing whether your stubs are good. > > I would start your debugging by adding a puts statement between lines 26 > and 27 to show more of the (unexpected) response. Looking at response.code > or response.body should give you some clues. > > By the way, did you know you can pass hashes of stubs to the mock() method? > > You could clean up your setup code quite a bit by doing this: > > @user = mock(User, > :enabled? => true, > :account_id => 1, > :time_zone => 'Eastern Time (US & Canada)', > :role => 'Normal') > > HTH, > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tero at tilus.net Wed Jan 7 09:11:48 2009 From: tero at tilus.net (Tero Tilus) Date: Wed, 7 Jan 2009 16:11:48 +0200 Subject: [rspec-users] Examples not getting rolled back... Message-ID: <20090107141148.GA15510@uivelo.tilus.net> I assume there's now something I'm totally missing here. I'm creating stuff in examples, just plain Foo.create, and the results aren't getting rolled back. I'm keep getting the following kind of pattern in my logs ... log from example starts here ... SQL (0.0ms) BEGIN SQL (0.0ms) BEGIN ClassFoo Create (0.2ms) INSERT ... Group Load (0.4ms) SELECT ... Contains Create (0.2ms) INSERT ... ... other stuff from example, no transaction stuff ... SQL (1.9ms) COMMIT SQL (0.1ms) ROLLBACK ... log from example ends here ... all examples of the following form produce it describe ClassFoo do ... it "plim-ploms" do foo = ClassFoo.create ... end ... end I'm just wondering if this is caused by those nested transactions. MySQL (which I happen to use) doesn't support nested transactions and is documented to just silently commit open transaction on new BEGIN. Taken that I'd expect last ROLLBACK not to have any effect. Where do those transactions come from? I'd guess outer transaction to be from RSpec and inner from ActiveRecord (oh, I'm on Rails). And of course, what can I do about this... A bit more stuff in pastie http://pastie.org/354521 -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From scott at railsnewbie.com Wed Jan 7 10:19:37 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 07 Jan 2009 10:19:37 -0500 Subject: [rspec-users] Cucumber - Performance In-Reply-To: <22FA105F-8A20-4CDB-B4EA-22C1BF506397@mattwynne.net> References: <8d961d900901070346k4e452dcfva2edd0123e2ef7c0@mail.gmail.com> <22FA105F-8A20-4CDB-B4EA-22C1BF506397@mattwynne.net> Message-ID: <4964C809.1020604@railsnewbie.com> Matt Wynne wrote: > > On 7 Jan 2009, at 11:46, aslak hellesoy wrote: > >> >> >> On Wed, Jan 7, 2009 at 10:31 AM, Colin Jack >> wrote: >> Hi, >> >> Small question on performance. I've just run the CS example provided >> with Cucumber and it took about 45-50 seconds before the first output >> appeared in the console, but once this first output had appeared the >> tests completed quickly. >> >> I'm wondering whether this is the expected performance or whether the >> plan is to optimize it at some time in the future? >> >> >> The reason it's so slow is that IronRuby is slow. That's where the >> optimisation will have to happen. It runs "fast" on JRuby, MRI and YARV. > > My guess is that it's the initial start-up that's slow. This is a > great reason to use something like autotest, which will keep the > process loaded up. I wonder how that hell you could make that work > with C# code though! Watch the DLLs?! Autotest doesn't keep the process running - it invokes a new process by shelling out (Kernel#`) Scott From stevemolitor at gmail.com Wed Jan 7 12:23:17 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 11:23:17 -0600 Subject: [rspec-users] Constraints / Global requirements Message-ID: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> I have two related questions: What is the best way to express global requirements, and how does one do it in Cucumber. The first question is the one I'm most interested in right now. By a global requirement I'm talking about requirements like 'all emails must be formatted like this...' Some people call them constraints, but I'm focusing on UI or business rules, not technical things. I can think of two approaches: put the global constraints in one place and reference these features in other features. The other point of view is that no, we want to see these rules in every feature that uses them, so we (customers, BAs, developers, testers) can see everything in one place. For example I can reference the different valid and invalid email scenarios in both the 'add new patient' and the 'add new doctor' features. Or I can copy and paste the email scenarios directly into the 'add new patient' and the 'add new doctor' features. As a DRY infected developer I prefer the first approach. However I have not found a simple way to have one cucumber feature reference or 'include' another, and have both features get executed. Perhaps partially for that reason, other people on my project want to use the second approach as it seems more straight forward. I realize I can reuse steps. But I want to reference the actual feature in another. To pick a more important example, in my past life I worked on a big leasing application with lots of formulas: to compute the cost of a lease, the cost of fuel cards, the cost of different levels of insurance, etc. I'm going to simply a lot, but say the formula for computing the sales tax is 'subtotal + subtotal * 0.5'. Calculating the sales tax is one feature. Two other features are 'compute lease cost' and 'compute fuel card cost'. They both need to add sales tax. This was before cumber and stories, but some of us preferred the specifications to look like this: LEASE COST FORMULA: a + b + sales tax. Others, especially the testers, preferred: a + b + (a + b * 0.5) In real life the sales (and use) tax calculation was quite complex and changed. When it changed this broke many manual test plan and invalidated many use cases. If we were using cucumber with the second approach it would break many features. Sorry for rambling on so long but I've found this is a hard question to articulate. Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfeley at gmail.com Wed Jan 7 12:40:12 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 12:40:12 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> References: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> Message-ID: <1fb4df0901070940s46d8eedfu3273039271769ac8@mail.gmail.com> On Wed, Jan 7, 2009 at 6:36 AM, Matt Wynne wrote: > > I would start your debugging by adding a puts statement between lines 26 and > 27 to show more of the (unexpected) response. Looking at response.code or > response.body should give you some clues. You can also check the logfiles. I often keep two terminals running in the background whenever I'm doing BDD coding; one's running autospec, and the other one has 'tail -f log/test.log'. I don't have to look at that all the time, but when something breaks and I can't figure out why it's a huge time saver. I also found this post of Ben Mabey's to be very useful for figuring out which chunk of log goes with which spec: http://www.benmabey.com/2008/07/04/global-setup-in-rspec-or-how-to-add-logging-for-specs/ -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Wed Jan 7 13:04:52 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 13:04:52 -0500 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107141148.GA15510@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> Message-ID: <1fb4df0901071004v6e0b5f99y44096ba412829b46@mail.gmail.com> On Wed, Jan 7, 2009 at 9:11 AM, Tero Tilus wrote: > > I'm creating stuff in examples, just plain Foo.create, and the results > aren't getting rolled back. I'm keep getting the following kind of > pattern in my logs You probably thought about this already, but did you check the setting of config.use_transactional_fixtures in config.spec_helper.rb? -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From mark at markrichman.com Wed Jan 7 13:05:56 2009 From: mark at markrichman.com (Mark A. Richman) Date: Wed, 7 Jan 2009 13:05:56 -0500 Subject: [rspec-users] Fixing "expected success? to return true, got false" In-Reply-To: <1fb4df0901070940s46d8eedfu3273039271769ac8@mail.gmail.com> References: <79185472-8D9D-4759-9820-49641E9D58F2@mattwynne.net> <1fb4df0901070940s46d8eedfu3273039271769ac8@mail.gmail.com> Message-ID: Steve, That's really useful! Thank you. - Mark On Wed, Jan 7, 2009 at 12:40 PM, Stephen Eley wrote: > On Wed, Jan 7, 2009 at 6:36 AM, Matt Wynne wrote: > > > > I would start your debugging by adding a puts statement between lines 26 > and > > 27 to show more of the (unexpected) response. Looking at response.code or > > response.body should give you some clues. > > You can also check the logfiles. I often keep two terminals running > in the background whenever I'm doing BDD coding; one's running > autospec, and the other one has 'tail -f log/test.log'. I don't have > to look at that all the time, but when something breaks and I can't > figure out why it's a huge time saver. I also found this post of Ben > Mabey's to be very useful for figuring out which chunk of log goes > with which spec: > > > http://www.benmabey.com/2008/07/04/global-setup-in-rspec-or-how-to-add-logging-for-specs/ > > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > 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 mark at mwilden.com Wed Jan 7 13:20:25 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 7 Jan 2009 10:20:25 -0800 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> Message-ID: <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> FWIW, I was getting this error yesterday. I completely uninstalled rspec and rspec-rails (including David's code from GitHub) and reinstalled, and it "went away." ///ark On Wed, Jan 7, 2009 at 1:49 AM, waseem ahmad wrote: > > > On Wed, Jan 7, 2009 at 2:55 PM, David Chelimsky wrote: > >> Seems like it's not loading up rspec-rails' Configuration object. In >> order for that to happen implicitly, the specs need to be in any of >> spec/models, spec/controllers, spec/views, spec/helpers. Is your file >> in one of those? >> >> > Yeah the file is spec/controllers/user_sessions_controller.rb > > @Mischa: The pointer you gave talks about rails edge. Right now I am on > rails 2.1 > > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.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 dchelimsky at gmail.com Wed Jan 7 13:26:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Jan 2009 12:26:32 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> Message-ID: <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> On Wed, Jan 7, 2009 at 12:20 PM, Mark Wilden wrote: > FWIW, I was getting this error yesterday. I completely uninstalled rspec and > rspec-rails (including David's code from GitHub) and reinstalled, and it > "went away." Which version did you install after removing everything? > > ///ark > > On Wed, Jan 7, 2009 at 1:49 AM, waseem ahmad wrote: >> >> >> On Wed, Jan 7, 2009 at 2:55 PM, David Chelimsky >> wrote: >>> >>> Seems like it's not loading up rspec-rails' Configuration object. In >>> order for that to happen implicitly, the specs need to be in any of >>> spec/models, spec/controllers, spec/views, spec/helpers. Is your file >>> in one of those? >>> >> >> Yeah the file is spec/controllers/user_sessions_controller.rb >> >> @Mischa: The pointer you gave talks about rails edge. Right now I am on >> rails 2.1 >> >> -- >> Waseem >> RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ >> Blog: http://babygnu.blogspot.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 tero at tilus.net Wed Jan 7 13:26:44 2009 From: tero at tilus.net (Tero Tilus) Date: Wed, 7 Jan 2009 20:26:44 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <1fb4df0901071004v6e0b5f99y44096ba412829b46@mail.gmail.com> References: <20090107141148.GA15510@uivelo.tilus.net> <1fb4df0901071004v6e0b5f99y44096ba412829b46@mail.gmail.com> Message-ID: <20090107182644.GA5784@uivelo.tilus.net> 2009-01-07 13:04, Stephen Eley: > config.use_transactional_fixtures in config.spec_helper.rb? Tried true, false and commenting out. I could not see any difference. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Wed Jan 7 14:08:44 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Jan 2009 13:08:44 -0600 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107141148.GA15510@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> Message-ID: <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> On Wed, Jan 7, 2009 at 8:11 AM, Tero Tilus wrote: > I assume there's now something I'm totally missing here. > > I'm creating stuff in examples, just plain Foo.create, and the results > aren't getting rolled back. I'm keep getting the following kind of > pattern in my logs > > ... log from example starts here ... > SQL (0.0ms) BEGIN > SQL (0.0ms) BEGIN > ClassFoo Create (0.2ms) INSERT ... > Group Load (0.4ms) SELECT ... > Contains Create (0.2ms) INSERT ... > ... other stuff from example, no transaction stuff ... > SQL (1.9ms) COMMIT > SQL (0.1ms) ROLLBACK > ... log from example ends here ... > > all examples of the following form produce it > > describe ClassFoo do > ... > it "plim-ploms" do > foo = ClassFoo.create > ... > end > ... > end > > I'm just wondering if this is caused by those nested transactions. > MySQL (which I happen to use) doesn't support nested transactions and > is documented to just silently commit open transaction on new BEGIN. > Taken that I'd expect last ROLLBACK not to have any effect. > > Where do those transactions come from? I'd guess outer transaction > to be from RSpec and inner from ActiveRecord (oh, I'm on Rails). Is the app code opening transactions? > > And of course, what can I do about this... > > A bit more stuff in pastie http://pastie.org/354521 > > -- > Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Wed Jan 7 14:00:22 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 7 Jan 2009 11:00:22 -0800 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> Message-ID: <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> On Wed, Jan 7, 2009 at 10:26 AM, David Chelimsky wrote: > On Wed, Jan 7, 2009 at 12:20 PM, Mark Wilden wrote: > > FWIW, I was getting this error yesterday. I completely uninstalled rspec > and > > rspec-rails (including David's code from GitHub) and reinstalled, and it > > "went away." > > Which version did you install after removing everything? > > 1.1.16, of course. Kidding - 1.1.11. :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Wed Jan 7 14:57:29 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 11:57:29 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> Message-ID: <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> On Wed, Jan 7, 2009 at 9:23 AM, Steve Molitor wrote: > I have two related questions: What is the best way to express global > requirements, and how does one do it in Cucumber. The first question is the > one I'm most interested in right now. > By a global requirement I'm talking about requirements like 'all emails must > be formatted like this...' Some people call them constraints, but I'm > focusing on UI or business rules, not technical things. My take on this situation is at http://rubyforge.org/pipermail/rspec-users/2008-December/011033.html Pat From matt at mattwynne.net Wed Jan 7 15:46:59 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 7 Jan 2009 20:46:59 +0000 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> Message-ID: <09CEC587-8C1D-4F19-A04E-24C37AF73165@mattwynne.net> On 7 Jan 2009, at 17:23, Steve Molitor wrote: > I have two related questions: What is the best way to express > global requirements, and how does one do it in Cucumber. The first > question is the one I'm most interested in right now. > > By a global requirement I'm talking about requirements like 'all > emails must be formatted like this...' Some people call them > constraints, but I'm focusing on UI or business rules, not technical > things. I can think of two approaches: put the global constraints > in one place and reference these features in other features. The > other point of view is that no, we want to see these rules in every > feature that uses them, so we (customers, BAs, developers, testers) > can see everything in one place. For example I can reference the > different valid and invalid email scenarios in both the 'add new > patient' and the 'add new doctor' features. Or I can copy and paste > the email scenarios directly into the 'add new patient' and the 'add > new doctor' features. > > As a DRY infected developer I prefer the first approach. However I > have not found a simple way to have one cucumber feature reference > or 'include' another, and have both features get executed. Perhaps > partially for that reason, other people on my project want to use > the second approach as it seems more straight forward. > > I realize I can reuse steps. But I want to reference the actual > feature in another. To pick a more important example, in my past > life I worked on a big leasing application with lots of formulas: > to compute the cost of a lease, the cost of fuel cards, the cost of > different levels of insurance, etc. I'm going to simply a lot, but > say the formula for computing the sales tax is 'subtotal + subtotal > * 0.5'. Calculating the sales tax is one feature. Two other > features are 'compute lease cost' and 'compute fuel card cost'. > They both need to add sales tax. This was before cumber and > stories, but some of us preferred the specifications to look like > this: > > LEASE COST FORMULA: > a + b + sales tax. > > Others, especially the testers, preferred: > > a + b + (a + b * 0.5) > > In real life the sales (and use) tax calculation was quite complex > and changed. When it changed this broke many manual test plan and > invalidated many use cases. If we were using cucumber with the > second approach it would break many features. > > Sorry for rambling on so long but I've found this is a hard question > to articulate. > > Steve I think you might need to try and let go of the idea that your Cucumber acceptance tests should be a *complete specification* and instead focus on making sure that there is *just enough* specification so that you can be sure to be alerted by the tests if something is wrong. Any more is likely to do more harm than good. I noticed you called yourself a 'DRY infected developer'. Duplication is undoubtedly the root of all evil in production code, but there are times when it pays to allow a little slack in. Check out this article from Dan North: http://dannorth.net/index.php?s=examples+flow Matt Wynne http://blog.mattwynne.net http://www.songkick.com From tero at tilus.net Wed Jan 7 16:23:37 2009 From: tero at tilus.net (Tero Tilus) Date: Wed, 7 Jan 2009 23:23:37 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> References: <20090107141148.GA15510@uivelo.tilus.net> <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> Message-ID: <20090107212336.GC5784@uivelo.tilus.net> 2009-01-07 13:08, David Chelimsky: > Is the app code opening transactions? Yes, but only one spot (iirc) which is not anywhere near the model whose test is failing here. I'll verify tomorrow that the failing test really doesn't run the app code in question. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From sfeley at gmail.com Wed Jan 7 17:22:25 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 17:22:25 -0500 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> Message-ID: <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> On Wed, Jan 7, 2009 at 12:23 PM, Steve Molitor wrote: > By a global requirement I'm talking about requirements like 'all emails must > be formatted like this...' Some people call them constraints, but I'm > focusing on UI or business rules, not technical things. You say "must." That's a programmer's synonym for "should." And to me that feels like a level of detail better handled with RSpec examples, where "should" is central to the domain language, than Cucumber features (which are more about stimulus and response). I know you said "business rules" and that tends to imply Cucumber in a lot of minds, but a SpecDoc formatted output that lists all the "it should" text works pretty well for business process description too. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From stevemolitor at gmail.com Wed Jan 7 17:24:09 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 16:24:09 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> Message-ID: <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> Pat, Thanks -- I misunderstood your original response you sent below. For some reason I read it as 'use rspec specs to validate the date logic' and missed the bit in the second paragraph where you suggested creating an explicit date feature. Doh! Sorry for not reading carefully. This sounds like a good approach. We would have to trust that the developer did indeed call the date validator object. On a large project developers might not read / remember all the feature docs so this could happen. Or the customer might have forgotten about the date validation feature, and this could be an exception where the standard date validation should not apply for some reason. But this is probably fixable via a '# see date_validation.feature' comment. >From a testing perspective it would be nice if cucumber could actually run the date validation feature everywhere it applies. But there are technical issues as then the date feature would have to be parameterized by uri, or whatever varies. More important perhaps this is putting too much emphasis on using cucumber as a testing tool when it is primarily a communication tool. But still if it could be done in a way that was easy to read it might be nice. Anyway you've showed me a very workable approach. Thanks! Steve P.S. Date validation really isn't that important in my application; that's just an example. A real example would be the sales tax calculation in the leasing app I worked on. That was very important, it was a global requirement with some important exceptions. But I think your approach would have worked there as well. On Wed, Jan 7, 2009 at 1:57 PM, Pat Maddox wrote: > On Wed, Jan 7, 2009 at 9:23 AM, Steve Molitor > wrote: > > I have two related questions: What is the best way to express global > > requirements, and how does one do it in Cucumber. The first question is > the > > one I'm most interested in right now. > > By a global requirement I'm talking about requirements like 'all emails > must > > be formatted like this...' Some people call them constraints, but I'm > > focusing on UI or business rules, not technical things. > > My take on this situation is at > http://rubyforge.org/pipermail/rspec-users/2008-December/011033.html > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Wed Jan 7 17:37:00 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 16:37:00 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <09CEC587-8C1D-4F19-A04E-24C37AF73165@mattwynne.net> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <09CEC587-8C1D-4F19-A04E-24C37AF73165@mattwynne.net> Message-ID: <3e21ad60901071437v373c0b3bu9c14aef59df10935@mail.gmail.com> Thanks Matt I think you're right. Ironically on a past project customers wanted a little drying up in the use cases because that helped their flow, and QA wanted more inline expansion because that helped their testing flow. The customers wanted to read about the new features, and didn't care to see a regurgitation of all the previously explained features that applied. A reference or reminder note was just fine. But anyway, yes focus on clarity and flow for the reader. Sometimes that will mean getting a little DRYer, in other cases it would me getting a little moister. Thanks! Steve On Wed, Jan 7, 2009 at 2:46 PM, Matt Wynne wrote: > > On 7 Jan 2009, at 17:23, Steve Molitor wrote: > > I have two related questions: What is the best way to express global >> requirements, and how does one do it in Cucumber. The first question is the >> one I'm most interested in right now. >> >> By a global requirement I'm talking about requirements like 'all emails >> must be formatted like this...' Some people call them constraints, but I'm >> focusing on UI or business rules, not technical things. I can think of two >> approaches: put the global constraints in one place and reference these >> features in other features. The other point of view is that no, we want to >> see these rules in every feature that uses them, so we (customers, BAs, >> developers, testers) can see everything in one place. For example I can >> reference the different valid and invalid email scenarios in both the 'add >> new patient' and the 'add new doctor' features. Or I can copy and paste the >> email scenarios directly into the 'add new patient' and the 'add new doctor' >> features. >> >> As a DRY infected developer I prefer the first approach. However I have >> not found a simple way to have one cucumber feature reference or 'include' >> another, and have both features get executed. Perhaps partially for that >> reason, other people on my project want to use the second approach as it >> seems more straight forward. >> >> I realize I can reuse steps. But I want to reference the actual feature >> in another. To pick a more important example, in my past life I worked on a >> big leasing application with lots of formulas: to compute the cost of a >> lease, the cost of fuel cards, the cost of different levels of insurance, >> etc. I'm going to simply a lot, but say the formula for computing the sales >> tax is 'subtotal + subtotal * 0.5'. Calculating the sales tax is one >> feature. Two other features are 'compute lease cost' and 'compute fuel card >> cost'. They both need to add sales tax. This was before cumber and >> stories, but some of us preferred the specifications to look like this: >> >> LEASE COST FORMULA: >> a + b + sales tax. >> >> Others, especially the testers, preferred: >> >> a + b + (a + b * 0.5) >> >> In real life the sales (and use) tax calculation was quite complex and >> changed. When it changed this broke many manual test plan and invalidated >> many use cases. If we were using cucumber with the second approach it would >> break many features. >> >> Sorry for rambling on so long but I've found this is a hard question to >> articulate. >> >> Steve >> > > I think you might need to try and let go of the idea that your Cucumber > acceptance tests should be a *complete specification* and instead focus on > making sure that there is *just enough* specification so that you can be > sure to be alerted by the tests if something is wrong. Any more is likely to > do more harm than good. > > I noticed you called yourself a 'DRY infected developer'. Duplication is > undoubtedly the root of all evil in production code, but there are times > when it pays to allow a little slack in. Check out this article from Dan > North: > > http://dannorth.net/index.php?s=examples+flow > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Wed Jan 7 19:00:18 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 18:00:18 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> Message-ID: <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> Perhaps. But I'm not sure then what the difference is between requirements that should (no pun intended) be expressed via RSpec examples versus features. Lots of features use the word "should" in their then clauses. Take this example from the 'Feature Introduction' of the cucumber wiki: Scenario: Buy last coffee Given there are 1 coffees left in the machine And I have deposited 1$ When I press the coffee button Then I should be served a coffee Should this be an rspec example instead? It certainly could be, but I don't think an rspec example would communicate as well with the customer as the feature would. And that's the primary goal here (as Pat and Matt have reminded me!). Which is not to say that the developers wouldn't get benefit out of a spec example as well -- you could do both -- just that at least in this case a feature is clearer to the customer than a spec example. Steve On Wed, Jan 7, 2009 at 4:22 PM, Stephen Eley wrote: > On Wed, Jan 7, 2009 at 12:23 PM, Steve Molitor > wrote: > > By a global requirement I'm talking about requirements like 'all emails > must > > be formatted like this...' Some people call them constraints, but I'm > > focusing on UI or business rules, not technical things. > > You say "must." That's a programmer's synonym for "should." And to > me that feels like a level of detail better handled with RSpec > examples, where "should" is central to the domain language, than > Cucumber features (which are more about stimulus and response). I > know you said "business rules" and that tends to imply Cucumber in a > lot of minds, but a SpecDoc formatted output that lists all the "it > should" text works pretty well for business process description too. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > 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 pergesu at gmail.com Wed Jan 7 20:26:25 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 17:26:25 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> Message-ID: <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> > From a testing perspective it would be nice if cucumber could actually run > the date validation feature everywhere it applies. Sure, and you can have a step like Given birth date is valid Given /(.*) date is valid/ do |field| TestData.valid_dates.each do |date| @it.send "#{field}_date=", date @it.should be_valid end TestData.invalid_dates.each do |date| @it.send "#{field}_date=", date @it.should_not be_valid end end That gets you technical validation everywhere you need it. Then you have another individual feature file that describes date formats. > P.S. Date validation really isn't that important in my application; that's > just an example. A real example would be the sales tax calculation in the > leasing app I worked on. That was very important, it was a global > requirement with some important exceptions. But I think your approach would > have worked there as well. Same ideas apply. Pat p.s. I didn't realize you were also the author of the other thread I linked to :) From stevemolitor at gmail.com Wed Jan 7 20:58:25 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 7 Jan 2009 19:58:25 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> Message-ID: <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> Yeah I thought of something like that. Actually we do something like that in one step now that I think about it. But I really wanted to execute the same exact date feature (for example) doc that the user verified to make sure nothing got lost in translation. Which I could do if I programmatically ran the date feature file inside the Given /(.*) date is vaild/ step. But all those results would clutter up the report output. I like your approach best: simple and doesn't require a funky technical solution. Steve On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: > > From a testing perspective it would be nice if cucumber could actually > run > > the date validation feature everywhere it applies. > > Sure, and you can have a step like > > Given birth date is valid > > Given /(.*) date is valid/ do |field| > TestData.valid_dates.each do |date| > @it.send "#{field}_date=", date > @it.should be_valid > end > > TestData.invalid_dates.each do |date| > @it.send "#{field}_date=", date > @it.should_not be_valid > end > end > > That gets you technical validation everywhere you need it. Then you > have another individual feature file that describes date formats. > > > > P.S. Date validation really isn't that important in my application; > that's > > just an example. A real example would be the sales tax calculation in > the > > leasing app I worked on. That was very important, it was a global > > requirement with some important exceptions. But I think your approach > would > > have worked there as well. > > Same ideas apply. > > Pat > > p.s. I didn't realize you were also the author of the other thread I > linked to :) > _______________________________________________ > 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 pergesu at gmail.com Wed Jan 7 21:09:02 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 18:09:02 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> Message-ID: <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> Another idea I had is to potentially introduce a ValidatedDate class, and then your "should be a valid date" step checks that the field is an instance of ValidatedDate. That has the affect of ensuring that people use your validation code in those spots where you want them to. How does that sound? Pat On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor wrote: > Yeah I thought of something like that. Actually we do something like that > in one step now that I think about it. But I really wanted to execute the > same exact date feature (for example) doc that the user verified to make > sure nothing got lost in translation. Which I could do if I > programmatically ran the date feature file inside the Given /(.*) date is > vaild/ step. But all those results would clutter up the report output. I > like your approach best: simple and doesn't require a funky technical > solution. > Steve > > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: >> >> > From a testing perspective it would be nice if cucumber could actually >> > run >> > the date validation feature everywhere it applies. >> >> Sure, and you can have a step like >> >> Given birth date is valid >> >> Given /(.*) date is valid/ do |field| >> TestData.valid_dates.each do |date| >> @it.send "#{field}_date=", date >> @it.should be_valid >> end >> >> TestData.invalid_dates.each do |date| >> @it.send "#{field}_date=", date >> @it.should_not be_valid >> end >> end >> >> That gets you technical validation everywhere you need it. Then you >> have another individual feature file that describes date formats. >> >> >> > P.S. Date validation really isn't that important in my application; >> > that's >> > just an example. A real example would be the sales tax calculation in >> > the >> > leasing app I worked on. That was very important, it was a global >> > requirement with some important exceptions. But I think your approach >> > would >> > have worked there as well. >> >> Same ideas apply. >> >> Pat >> >> p.s. I didn't realize you were also the author of the other thread I >> linked to :) >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 sfeley at gmail.com Wed Jan 7 21:22:26 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 7 Jan 2009 21:22:26 -0500 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> Message-ID: <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor wrote: > Lots of features use the word "should" in their then clauses. > Take this example from the 'Feature Introduction' of the cucumber wiki: > > Scenario: Buy last coffee > Given there are 1 coffees left in the machine > And I have deposited 1$ > When I press the coffee button > Then I should be served a coffee Maybe I'm overly audacious, but I'd call that imprecise wording. A better clause would be "Then I am served a coffee." (Actually, that feature has more than one thing wrong with it. The "depositing $1" part really ought to be a When, not a Given, since it's an action integral to the scenario rather than a starting state. Unfortunately, this often happens when people make up theoretical examples instead of presenting real tests for real code. I'll be this feature was never actually part of designing a coffee machine...) > Should this be an rspec example instead? It certainly could be, but I don't > think an rspec example would communicate as well with the customer as the > feature would. And that's the primary goal here (as Pat and Matt have > reminded me!). I agree. This is a flawed feature, but it really ought to be a feature: it describes a stimulus (an action) and a response. But this example doesn't have much in common with your original e-mail validation example. In that case, what's the action and what's the response? And is a feature clearer to the customer to explain e-mail validation than a spec? -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From pergesu at gmail.com Wed Jan 7 22:00:49 2009 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Jan 2009 19:00:49 -0800 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> Message-ID: <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> On Wed, Jan 7, 2009 at 6:22 PM, Stephen Eley wrote: > On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor wrote: >> Lots of features use the word "should" in their then clauses. >> Take this example from the 'Feature Introduction' of the cucumber wiki: >> >> Scenario: Buy last coffee >> Given there are 1 coffees left in the machine >> And I have deposited 1$ >> When I press the coffee button >> Then I should be served a coffee > > Maybe I'm overly audacious, but I'd call that imprecise wording. A > better clause would be "Then I am served a coffee." meh. I use "should" all over the place in my features. >> Should this be an rspec example instead? It certainly could be, but I don't >> think an rspec example would communicate as well with the customer as the >> feature would. And that's the primary goal here (as Pat and Matt have >> reminded me!). > > I agree. This is a flawed feature, but it really ought to be a > feature: it describes a stimulus (an action) and a response. But this > example doesn't have much in common with your original e-mail > validation example. In that case, what's the action and what's the > response? And is a feature clearer to the customer to explain e-mail > validation than a spec? hrm... "pat.maddox at gmail.com".should be_valid_email "pat.maddox+foo at gmail.com".should be_valid_email "pat.maddox at gmail".should_not be_valid_email Seems pretty clear to me. Email validation and the lease cost formula are examples of acceptance tests that are probably best handled with FIT. I know that cucumber has FIT-inspired tables, but those are still coupled to scenarios, aren't they? Actually, I'd still prefer to write these tests with prose. But it'd be super simple: pat.maddox at gmail.com is a valid email address pat.maddox at gmail is an invalid email address You can achieve this with cucumber already... Then pat.maddox at gmail.com is a valid email address Then pat.maddox at gmail is an invalid email address but it looks stupid. Pat From zach.dennis at gmail.com Wed Jan 7 22:41:37 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 7 Jan 2009 22:41:37 -0500 Subject: [rspec-users] newbie: need help to write the spec for helper In-Reply-To: <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> References: <460644.22468.qm@web38001.mail.mud.yahoo.com> <57c63afe0812310721o4a65a879v55b7e4f586f50f46@mail.gmail.com> <8d961d900812310749g5a4a3b5lf15722da3670547a@mail.gmail.com> <57c63afe0812310802h3f0cf030l1bf7a2626a492193@mail.gmail.com> <8d961d900812310811k7d4a0b74s89a6e84e81338ec9@mail.gmail.com> Message-ID: <85d99afe0901071941i3d2dee1bj3ae3726ff97276da@mail.gmail.com> On Wed, Dec 31, 2008 at 11:11 AM, aslak hellesoy wrote: > > > On Wed, Dec 31, 2008 at 5:02 PM, David Chelimsky > wrote: >> >> On Wed, Dec 31, 2008 at 9:49 AM, aslak hellesoy >> wrote: >> > >> > >> > On Wed, Dec 31, 2008 at 4:21 PM, David Chelimsky >> > wrote: >> >> >> >> On Wed, Dec 31, 2008 at 8:00 AM, Nasir Jamal >> >> wrote: >> >> > Hi, >> >> > >> >> > I am a rspec newbie, can anyone guide me on how to write a spec for >> >> > the >> >> > below helper. >> >> > >> >> > module MyHelper >> >> > def test >> >> > link_to('MyLink', resources_path) if @categories || >> >> > @sub_categories >> >> > end >> >> > end >> >> > >> >> > @categories is an instance of Category model >> >> > @sub_categories is an instance of SubCategory model >> >> >> >> Take a look at >> >> http://rspec.info/documentation/rails/writing/helpers.html. >> >> You can use assigns[:categories] and assigns[:sub_categories] to make >> >> the necessary data available to the helper. >> > >> > Technically you can do it that way, but personally I don't recommend >> > that >> > approach in most cases. Testing modules is similar to testing private >> > methods, and the general advice is: Don't do it. >> > >> > Instead, test module methods and private methods indirectly via the >> > class/object that uses them. For modules this means: Write a spec for a >> > class that includes the module (in Rails this is a controller or view). >> >> So do you recommend never doing helper specs? > > I never said never :-) Here is my manifesto styled take on this: > > "I favour testing directly accessible APIs over indirectly accessible ones." > > In Rails, I usually try to write a spec against a controller or view before > I resort to a helper spec. Keeping inappropriate logic out of the view helpers goes a long way to allow for this IMO. My personal rule of thumb of Rails view helpers is that they should only be concerned with what is built, and not with the how or why. Relying on instance variables is a no-no. When conditional checks come into play there is usually something that can be abstracted. This is where presenters excel. Granted, not everything is always so black and white. When in doubt there tend to be three ways to categorize presentation logic IMO: 1. Is it site-wide? (ie: rounded_button_helper, date_format, money_format) 2. Is it resource specific? (ie: order, line_item) 3. Is it UI component/widget specific? (ie: scoreboard which is compromised of multiple resources/models) Site-wide things should go in Rails helper modules so they are easily accessible. For the most part you can write implement these through requirements imposed by scenarios and view specs. In other cases it makes sense to write helper specs. Logic that is resource specific or UI component/widget specific should go inside of presenters. Rather than having (@category || @subcategory) conditionals floating around disorganized view helpers you should be posing that question to something that cares. This makes adding, extending, changing the logic surrounding the concept in question easier because there is a concrete representation that is organized and exists in a single spot -- the presenter. When you find you have multiple concepts sharing logic (but it's not site-wide) than extract out modules and include them in each presenter. I don't want to go to far off-topic from this thread, but needing to directly test view helpers is much less frequent when you are putting presentation logic where it belongs and writing examples for an appropriate object and its public interface. BTW, I agree with Aslak's manifesto on this. :) -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From cougar2149 at gmail.com Thu Jan 8 00:26:13 2009 From: cougar2149 at gmail.com (waseem ahmad) Date: Thu, 8 Jan 2009 10:56:13 +0530 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> Message-ID: I have both the rspec 1.1.11 and rspec-rails 1.1.11 as gems. I had them plugged in my application too. When I removed them from my application the problem was solved. The version of both the gems and plugins are same. Why did this happen? -- Waseem RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ Blog: http://babygnu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tero at tilus.net Thu Jan 8 04:56:12 2009 From: tero at tilus.net (Tero Tilus) Date: Thu, 8 Jan 2009 11:56:12 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107141148.GA15510@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> Message-ID: <20090108095611.GA8340@uivelo.tilus.net> Forgot to mention before. I'm on Rails 2.2.2 and RSpec 1.1.4. Inspired by older discussion touching this issue (see http://www.nabble.com/Database-clearing-td19572270.html) I've now got Spec::Runner.configure do |config| config.use_transactional_fixtures = false ... tables_to_truncate = ActiveRecord::Base.connection.tables - ["schema_migrations"] config.before(:all) do tables_to_truncate.each do |table_name| ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name};") end end ... end And if I run rake spec all specs pass. But if I run script/spec spec/models/class_foo_spec.rb then it "finds no ghost foos" do ClassFoo.should have(:no).records end fails. That is the first example of describe ClassFoo. Looks like script/spec runs examples (see pastie http://pastie.org/354521) in the order they are defined and rake spec in reverse order. And that of course makes ClassFoo.should have(:no).records fail when run _after_ examples that create ClassFoo instances (befause ive got transactions off and the db state "bleeds" within one describe. 2009-01-07 16:11, Tero Tilus: > I'm keep getting the following kind of pattern in my logs > > ... log from example starts here ... > SQL (0.0ms) BEGIN > SQL (0.0ms) BEGIN > ClassFoo Create (0.2ms) INSERT ... > Group Load (0.4ms) SELECT ... > Contains Create (0.2ms) INSERT ... > ... other stuff from example, no transaction stuff ... > SQL (1.9ms) COMMIT > SQL (0.1ms) ROLLBACK > ... log from example ends here ... If I turn use_transactional_fixtures off, the outer transaction is gone. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From tero at tilus.net Thu Jan 8 05:00:19 2009 From: tero at tilus.net (Tero Tilus) Date: Thu, 8 Jan 2009 12:00:19 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090107212336.GC5784@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> <57c63afe0901071108p1e217f7ah3d2f4dd0a94cf7dc@mail.gmail.com> <20090107212336.GC5784@uivelo.tilus.net> Message-ID: <20090108100019.GB8340@uivelo.tilus.net> 2009-01-07 23:23, Tero Tilus: > 2009-01-07 13:08, David Chelimsky: > > Is the app code opening transactions? > > Yes, but only one spot (iirc) which is not anywhere near the model > whose test is failing here. I'll verify tomorrow that the failing > test really doesn't run the app code in question. Verified, and it didn't. Transactions I see on the log when running the spec in question come from ActiveRecord (and RSpec if I have use_transactional_fixtures = true). -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Thu Jan 8 08:31:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 07:31:58 -0600 Subject: [rspec-users] Error: undefined method `use_transactional_fixtures In-Reply-To: References: <57c63afe0901070125o5d8f2e73wcca3dfc63ae7728c@mail.gmail.com> <3c30da400901071020v50e39a00kab08b608ac4400d7@mail.gmail.com> <57c63afe0901071026n2207e5e9h630b996639070431@mail.gmail.com> <3c30da400901071100xbaf83e1mbc7f4abed35086bd@mail.gmail.com> Message-ID: <57c63afe0901080531k32975914y653ce877e056a71@mail.gmail.com> On Wed, Jan 7, 2009 at 11:26 PM, waseem ahmad wrote: > I have both the rspec 1.1.11 and rspec-rails 1.1.11 as gems. I had them > plugged in my application too. When I removed them from my application the > problem was solved. The version of both the gems and plugins are same. > > Why did this happen? I haven't seen the problem of use_transactional_fixtures before, but there were some problems with installing rspec/rspec-rails as gems w/ 1.1.11. This will be fixed in the 1.1.12 release coming shortly. Cheers, David > -- > Waseem > RwrWrwRwrWrwRwrWrwRwrWrwRwwwwwwww............ > Blog: http://babygnu.blogspot.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Jan 8 08:37:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 07:37:38 -0600 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090108095611.GA8340@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> <20090108095611.GA8340@uivelo.tilus.net> Message-ID: <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> On Thu, Jan 8, 2009 at 3:56 AM, Tero Tilus wrote: > Forgot to mention before. I'm on Rails 2.2.2 and RSpec 1.1.4. Aha! There's the problem. RSpec-1.1.4 was released in May and Rails 2.2.2 was released AFTER in November. I'd grab the 1.1.12 release candidates from github: gem sources -a http://gems.github.com [sudo] gem install dchelimsky-rspec [sudo] gem install dchelimsky-rspec-rails Cheers, David > > Inspired by older discussion touching this issue (see > http://www.nabble.com/Database-clearing-td19572270.html) I've now got > > Spec::Runner.configure do |config| > config.use_transactional_fixtures = false > ... > tables_to_truncate = > ActiveRecord::Base.connection.tables - ["schema_migrations"] > config.before(:all) do > tables_to_truncate.each do |table_name| > ActiveRecord::Base.connection.execute("TRUNCATE TABLE > #{table_name};") > end > end > ... > end > > And if I run rake spec all specs pass. But if I run script/spec > spec/models/class_foo_spec.rb then > > it "finds no ghost foos" do > ClassFoo.should have(:no).records > end > > fails. That is the first example of describe ClassFoo. Looks like > script/spec runs examples (see pastie http://pastie.org/354521) in the > order they are defined and rake spec in reverse order. And that of > course makes ClassFoo.should have(:no).records fail when run _after_ > examples that create ClassFoo instances (befause ive got transactions > off and the db state "bleeds" within one describe. > > 2009-01-07 16:11, Tero Tilus: >> I'm keep getting the following kind of pattern in my logs >> >> ... log from example starts here ... >> SQL (0.0ms) BEGIN >> SQL (0.0ms) BEGIN >> ClassFoo Create (0.2ms) INSERT ... >> Group Load (0.4ms) SELECT ... >> Contains Create (0.2ms) INSERT ... >> ... other stuff from example, no transaction stuff ... >> SQL (1.9ms) COMMIT >> SQL (0.1ms) ROLLBACK >> ... log from example ends here ... > > If I turn use_transactional_fixtures off, the outer transaction is > gone. > > -- > Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From stevemolitor at gmail.com Thu Jan 8 09:56:36 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 08:56:36 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> Message-ID: <3e21ad60901080656s1496e77aw3db1ced35282418c@mail.gmail.com> For a more realistic example lets take the leasing application I worked on. There were lots of rules and formulas, and exceptions to those rules and formulas, and the different pieces were (sometimes) part of larger calculations. We specified the requirements in the normal declarative fashion On Wed, Jan 7, 2009 at 9:00 PM, Pat Maddox wrote: > On Wed, Jan 7, 2009 at 6:22 PM, Stephen Eley wrote: > > On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor > wrote: > >> Lots of features use the word "should" in their then clauses. > >> Take this example from the 'Feature Introduction' of the cucumber wiki: > >> > >> Scenario: Buy last coffee > >> Given there are 1 coffees left in the machine > >> And I have deposited 1$ > >> When I press the coffee button > >> Then I should be served a coffee > > > > Maybe I'm overly audacious, but I'd call that imprecise wording. A > > better clause would be "Then I am served a coffee." > > meh. I use "should" all over the place in my features. > > > >> Should this be an rspec example instead? It certainly could be, but I > don't > >> think an rspec example would communicate as well with the customer as > the > >> feature would. And that's the primary goal here (as Pat and Matt have > >> reminded me!). > > > > I agree. This is a flawed feature, but it really ought to be a > > feature: it describes a stimulus (an action) and a response. But this > > example doesn't have much in common with your original e-mail > > validation example. In that case, what's the action and what's the > > response? And is a feature clearer to the customer to explain e-mail > > validation than a spec? > > hrm... > "pat.maddox at gmail.com".should be_valid_email > "pat.maddox+foo at gmail.com ".should > be_valid_email > "pat.maddox at gmail".should_not be_valid_email > > Seems pretty clear to me. > > Email validation and the lease cost formula are examples of acceptance > tests that are probably best handled with FIT. I know that cucumber > has FIT-inspired tables, but those are still coupled to scenarios, > aren't they? > > Actually, I'd still prefer to write these tests with prose. But it'd > be super simple: > > pat.maddox at gmail.com is a valid email address > pat.maddox at gmail is an invalid email address > > You can achieve this with cucumber already... > Then pat.maddox at gmail.com is a valid email address > Then pat.maddox at gmail is an invalid email address > > but it looks stupid. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Thu Jan 8 11:32:52 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 10:32:52 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> Message-ID: <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> I guess that would work. But a method would probably work too, if I'm understanding correctly (often a bad assumption!). I.e. /"(.*)" should be a valid date/ would call valid_date?(date), or something. Anyway, yes that sounds promising. Steve On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: > Another idea I had is to potentially introduce a ValidatedDate class, > and then your "should be a valid date" step checks that the field is > an instance of ValidatedDate. That has the affect of ensuring that > people use your validation code in those spots where you want them to. > How does that sound? > > Pat > > On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor > wrote: > > Yeah I thought of something like that. Actually we do something like > that > > in one step now that I think about it. But I really wanted to execute > the > > same exact date feature (for example) doc that the user verified to make > > sure nothing got lost in translation. Which I could do if I > > programmatically ran the date feature file inside the Given /(.*) date is > > vaild/ step. But all those results would clutter up the report output. > I > > like your approach best: simple and doesn't require a funky technical > > solution. > > Steve > > > > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: > >> > >> > From a testing perspective it would be nice if cucumber could actually > >> > run > >> > the date validation feature everywhere it applies. > >> > >> Sure, and you can have a step like > >> > >> Given birth date is valid > >> > >> Given /(.*) date is valid/ do |field| > >> TestData.valid_dates.each do |date| > >> @it.send "#{field}_date=", date > >> @it.should be_valid > >> end > >> > >> TestData.invalid_dates.each do |date| > >> @it.send "#{field}_date=", date > >> @it.should_not be_valid > >> end > >> end > >> > >> That gets you technical validation everywhere you need it. Then you > >> have another individual feature file that describes date formats. > >> > >> > >> > P.S. Date validation really isn't that important in my application; > >> > that's > >> > just an example. A real example would be the sales tax calculation in > >> > the > >> > leasing app I worked on. That was very important, it was a global > >> > requirement with some important exceptions. But I think your approach > >> > would > >> > have worked there as well. > >> > >> Same ideas apply. > >> > >> Pat > >> > >> p.s. I didn't realize you were also the author of the other thread I > >> linked to :) > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Thu Jan 8 11:45:58 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 10:45:58 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <1fb4df0901071422u34d9e1b9ld83dcb81fc64262e@mail.gmail.com> <3e21ad60901071600l6bf80c36g8f4a42121e5e58df@mail.gmail.com> <1fb4df0901071822g1bdfdce2q9949a4e494d8b2b6@mail.gmail.com> <810a540e0901071900q56f95aefo571e0c290dd98131@mail.gmail.com> Message-ID: <3e21ad60901080845v6f4171d8p7ad0fa18a393ffa8@mail.gmail.com> I hid send to early on a previous email; please ignore it. I think you could do this with cucumber: Then should be a email address | date | result | | "sam at foo.com | valid | | "tom@" | invalid | Or: Then should be a valid email address | email | | sam at foo.com | | tom at bar.com | Then should be an invalid email address | email | | sam@ | | @bar.com | I don't think you need all three steps. Instead of the tables you could And them all together if you prefer. OK, "Then" is a little awkward. Perhaps you could monkey patch cucumber with your own step name. I may have picked bad examples, but fundamentally I don't think this is an rspec vs. cucumber issue. In the leasing app I worked on we had lots of testing scenarios like 'setup the lease with values x, y, z..., then press the calculate button. The result should be xxx'. Obviously these translate directly into cucumber scenarios. And then some tests would include other tests, as caculcations were often composites of other calculations. I could see where sometimes inlining would make sense, other times where that would be too much noise and you want a reference. Steve Steve I don't think you need all 3 steps. OK. "Then" is awkward On Wed, Jan 7, 2009 at 9:00 PM, Pat Maddox wrote: > On Wed, Jan 7, 2009 at 6:22 PM, Stephen Eley wrote: > > On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor > wrote: > >> Lots of features use the word "should" in their then clauses. > >> Take this example from the 'Feature Introduction' of the cucumber wiki: > >> > >> Scenario: Buy last coffee > >> Given there are 1 coffees left in the machine > >> And I have deposited 1$ > >> When I press the coffee button > >> Then I should be served a coffee > > > > Maybe I'm overly audacious, but I'd call that imprecise wording. A > > better clause would be "Then I am served a coffee." > > meh. I use "should" all over the place in my features. > > > >> Should this be an rspec example instead? It certainly could be, but I > don't > >> think an rspec example would communicate as well with the customer as > the > >> feature would. And that's the primary goal here (as Pat and Matt have > >> reminded me!). > > > > I agree. This is a flawed feature, but it really ought to be a > > feature: it describes a stimulus (an action) and a response. But this > > example doesn't have much in common with your original e-mail > > validation example. In that case, what's the action and what's the > > response? And is a feature clearer to the customer to explain e-mail > > validation than a spec? > > hrm... > "pat.maddox at gmail.com".should be_valid_email > "pat.maddox+foo at gmail.com ".should > be_valid_email > "pat.maddox at gmail".should_not be_valid_email > > Seems pretty clear to me. > > Email validation and the lease cost formula are examples of acceptance > tests that are probably best handled with FIT. I know that cucumber > has FIT-inspired tables, but those are still coupled to scenarios, > aren't they? > > Actually, I'd still prefer to write these tests with prose. But it'd > be super simple: > > pat.maddox at gmail.com is a valid email address > pat.maddox at gmail is an invalid email address > > You can achieve this with cucumber already... > Then pat.maddox at gmail.com is a valid email address > Then pat.maddox at gmail is an invalid email address > > but it looks stupid. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Thu Jan 8 12:05:40 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 11:05:40 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> Message-ID: <3e21ad60901080905m306da5e8lb07e45e31e629be5@mail.gmail.com> Whoops I misunderstood again. You'd validate that it was an instance ValidDate to make sure the date validation code was executed. Got it now. Maybe you could mock out the date validation part of the code and set an expectation that it should be called: mock_date_validator.should_receive?(:validate).with(the_date).return(true) You're completely mocking out the date validation result, but you're testing that the date validation routine was indeed called, and if you've tested that routine elsewhere you should be good. Or something like that. Good ideas, thanks. Steve On Thu, Jan 8, 2009 at 10:32 AM, Steve Molitor wrote: > I guess that would work. But a method would probably work too, if I'm > understanding correctly (often a bad assumption!). I.e. /"(.*)" should be > a valid date/ would call valid_date?(date), or something. Anyway, yes that > sounds promising. > Steve > > > > On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: > >> Another idea I had is to potentially introduce a ValidatedDate class, >> and then your "should be a valid date" step checks that the field is >> an instance of ValidatedDate. That has the affect of ensuring that >> people use your validation code in those spots where you want them to. >> How does that sound? >> >> Pat >> >> On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor >> wrote: >> > Yeah I thought of something like that. Actually we do something like >> that >> > in one step now that I think about it. But I really wanted to execute >> the >> > same exact date feature (for example) doc that the user verified to make >> > sure nothing got lost in translation. Which I could do if I >> > programmatically ran the date feature file inside the Given /(.*) date >> is >> > vaild/ step. But all those results would clutter up the report output. >> I >> > like your approach best: simple and doesn't require a funky technical >> > solution. >> > Steve >> > >> > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: >> >> >> >> > From a testing perspective it would be nice if cucumber could >> actually >> >> > run >> >> > the date validation feature everywhere it applies. >> >> >> >> Sure, and you can have a step like >> >> >> >> Given birth date is valid >> >> >> >> Given /(.*) date is valid/ do |field| >> >> TestData.valid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should be_valid >> >> end >> >> >> >> TestData.invalid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should_not be_valid >> >> end >> >> end >> >> >> >> That gets you technical validation everywhere you need it. Then you >> >> have another individual feature file that describes date formats. >> >> >> >> >> >> > P.S. Date validation really isn't that important in my application; >> >> > that's >> >> > just an example. A real example would be the sales tax calculation >> in >> >> > the >> >> > leasing app I worked on. That was very important, it was a global >> >> > requirement with some important exceptions. But I think your >> approach >> >> > would >> >> > have worked there as well. >> >> >> >> Same ideas apply. >> >> >> >> Pat >> >> >> >> p.s. I didn't realize you were also the author of the other thread I >> >> linked to :) >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Jan 8 13:13:54 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 8 Jan 2009 19:13:54 +0100 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> Message-ID: <1176ad0c77805270cb1c4e71bbb230ac@ruby-forum.com> I am still not getting this to work. Here is what I have done: In index.html.erb ... ... <% for entity in @entities %> ... ... In the step definition file: When /I delete the "(.*)" entity/ do |row| visits entities_url puts entities_url my_entity = Entity.find_by_entity_name( "my entity number #{row.hll_words_to_i}") puts "selector found" if have_selector( "table > tbody > tr#" + dom_id(my_entity) + " > td > a") within("table > tbody > tr#" + dom_id(my_entity) + " > td > a") do click_link "Destroy Entity" end end The results: Scenario: Delete entity # features/app/models/entities/entity.feature:32 Given I have "4" valid entities # features/app/models/entities/step_definitions/entity_steps.rb:115 http://www.example.com/entities selector found When I delete the "first" entity # features/app/models/entities/step_definitions/entity_steps.rb:128 You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_html (NoMethodError) /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in `scoped_dom' The selector is found so what is my error? I have backed off the selector element by element to "table > tbody > tr#" + dom_id(myentity) with no change in the result. I always get a nil object error. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu Jan 8 13:52:00 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 8 Jan 2009 13:52:00 -0500 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> Message-ID: <85d99afe0901081052h2f0a685fye78121736a9843f0@mail.gmail.com> On Thu, Jan 8, 2009 at 11:32 AM, Steve Molitor wrote: > I guess that would work. What would work? You top-posted, any way you can inline post to the spot you're responding to? Sorry to be an email nazi, but you're making me do all of the work for wanting to hopefully participate in this thread, Zach > But a method would probably work too, if I'm > understanding correctly (often a bad assumption!). I.e. /"(.*)" should be > a valid date/ would call valid_date?(date), or something. Anyway, yes that > sounds promising. > Steve > > > On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: >> >> Another idea I had is to potentially introduce a ValidatedDate class, >> and then your "should be a valid date" step checks that the field is >> an instance of ValidatedDate. That has the affect of ensuring that >> people use your validation code in those spots where you want them to. >> How does that sound? >> >> Pat >> >> On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor >> wrote: >> > Yeah I thought of something like that. Actually we do something like >> > that >> > in one step now that I think about it. But I really wanted to execute >> > the >> > same exact date feature (for example) doc that the user verified to make >> > sure nothing got lost in translation. Which I could do if I >> > programmatically ran the date feature file inside the Given /(.*) date >> > is >> > vaild/ step. But all those results would clutter up the report output. >> > I >> > like your approach best: simple and doesn't require a funky technical >> > solution. >> > Steve >> > >> > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: >> >> >> >> > From a testing perspective it would be nice if cucumber could >> >> > actually >> >> > run >> >> > the date validation feature everywhere it applies. >> >> >> >> Sure, and you can have a step like >> >> >> >> Given birth date is valid >> >> >> >> Given /(.*) date is valid/ do |field| >> >> TestData.valid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should be_valid >> >> end >> >> >> >> TestData.invalid_dates.each do |date| >> >> @it.send "#{field}_date=", date >> >> @it.should_not be_valid >> >> end >> >> end >> >> >> >> That gets you technical validation everywhere you need it. Then you >> >> have another individual feature file that describes date formats. >> >> >> >> >> >> > P.S. Date validation really isn't that important in my application; >> >> > that's >> >> > just an example. A real example would be the sales tax calculation >> >> > in >> >> > the >> >> > leasing app I worked on. That was very important, it was a global >> >> > requirement with some important exceptions. But I think your >> >> > approach >> >> > would >> >> > have worked there as well. >> >> >> >> Same ideas apply. >> >> >> >> Pat >> >> >> >> p.s. I didn't realize you were also the author of the other thread I >> >> linked to :) >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.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 > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From walketim at gmail.com Thu Jan 8 14:51:52 2009 From: walketim at gmail.com (Tim Walker) Date: Thu, 8 Jan 2009 12:51:52 -0700 Subject: [rspec-users] any eta on the rspec book? Message-ID: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> Subject says it all... Thanks in advance, T From lists at ruby-forum.com Thu Jan 8 14:55:25 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 8 Jan 2009 20:55:25 +0100 Subject: [rspec-users] cucumber, finding a row in a table In-Reply-To: <1176ad0c77805270cb1c4e71bbb230ac@ruby-forum.com> References: <84f730e41b1773b44b0fd8a6dfd49cf8@ruby-forum.com> <85d99afe0901051507pd187422w2bf618459f0bf597@mail.gmail.com> <1e43aeb33748c276ad770eb033cf1fb7@ruby-forum.com> <85d99afe0901061653m3ffdbb77ma1d36aebf64ef59f@mail.gmail.com> <1176ad0c77805270cb1c4e71bbb230ac@ruby-forum.com> Message-ID: <07b430446d480d1655cacdb2ea08a79b@ruby-forum.com> I have tried to simplify this as much as possible. To the best of my ability to determine when one selects an html element via id then one obtains the entire element contents to the termination tag. So, I did this: Now, when I check for either of the selector ids using webrat's within method they both work. within("tr#"+dom_id(my_entity, :list)) do puts "within method executed for tr#dom_id selector" end within("td#"+dom_id(my_entity, :delete)) do puts "within method executed for td#dom_id selector" end produces: within method executed for tr#dom_id selector within method executed for td#dom_id selector But, any call to the click_link("Destroy Entity") method from a successful within match gives a nil object exception. So, what is happening here? -- Posted via http://www.ruby-forum.com/. From stevemolitor at gmail.com Thu Jan 8 15:15:23 2009 From: stevemolitor at gmail.com (Steve Molitor) Date: Thu, 8 Jan 2009 14:15:23 -0600 Subject: [rspec-users] Constraints / Global requirements In-Reply-To: <85d99afe0901081052h2f0a685fye78121736a9843f0@mail.gmail.com> References: <3e21ad60901070923h302fce8eh5ac8a699c0593b74@mail.gmail.com> <810a540e0901071157i3b8df25arcf77972e7b8b6818@mail.gmail.com> <3e21ad60901071424m9f271b5r4c2113d63b7c4b2f@mail.gmail.com> <810a540e0901071726u103038e4r3b560995d0b0435@mail.gmail.com> <3e21ad60901071758i21469d47ne0acb0b2689b6ae4@mail.gmail.com> <810a540e0901071809ibaf3472k96d05e12dcf8d246@mail.gmail.com> <3e21ad60901080832h19f1883ey80ab4d23751a58de@mail.gmail.com> <85d99afe0901081052h2f0a685fye78121736a9843f0@mail.gmail.com> Message-ID: <3e21ad60901081215h962e8aetf36ddfbf8fe3b525@mail.gmail.com> Sorry. I was responding to this from Pat Maddox: >> Another idea I had is to potentially introduce a ValidatedDate class, >> and then your "should be a valid date" step checks that the field is >> an instance of ValidatedDate. That has the affect of ensuring that >> people use your validation code in those spots where you want them to. >> How does that sound? Steve On Thu, Jan 8, 2009 at 12:52 PM, Zach Dennis wrote: > On Thu, Jan 8, 2009 at 11:32 AM, Steve Molitor > wrote: > > I guess that would work. > > What would work? You top-posted, any way you can inline post to the > spot you're responding to? Sorry to be an email nazi, but you're > making me do all of the work for wanting to hopefully participate in > this thread, > > Zach > > > But a method would probably work too, if I'm > > understanding correctly (often a bad assumption!). I.e. /"(.*)" should > be > > a valid date/ would call valid_date?(date), or something. Anyway, yes > that > > sounds promising. > > Steve > > > > > > On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox wrote: > >> > >> Another idea I had is to potentially introduce a ValidatedDate class, > >> and then your "should be a valid date" step checks that the field is > >> an instance of ValidatedDate. That has the affect of ensuring that > >> people use your validation code in those spots where you want them to. > >> How does that sound? > >> > >> Pat > >> > >> On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor > >> wrote: > >> > Yeah I thought of something like that. Actually we do something like > >> > that > >> > in one step now that I think about it. But I really wanted to execute > >> > the > >> > same exact date feature (for example) doc that the user verified to > make > >> > sure nothing got lost in translation. Which I could do if I > >> > programmatically ran the date feature file inside the Given /(.*) date > >> > is > >> > vaild/ step. But all those results would clutter up the report > output. > >> > I > >> > like your approach best: simple and doesn't require a funky technical > >> > solution. > >> > Steve > >> > > >> > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox wrote: > >> >> > >> >> > From a testing perspective it would be nice if cucumber could > >> >> > actually > >> >> > run > >> >> > the date validation feature everywhere it applies. > >> >> > >> >> Sure, and you can have a step like > >> >> > >> >> Given birth date is valid > >> >> > >> >> Given /(.*) date is valid/ do |field| > >> >> TestData.valid_dates.each do |date| > >> >> @it.send "#{field}_date=", date > >> >> @it.should be_valid > >> >> end > >> >> > >> >> TestData.invalid_dates.each do |date| > >> >> @it.send "#{field}_date=", date > >> >> @it.should_not be_valid > >> >> end > >> >> end > >> >> > >> >> That gets you technical validation everywhere you need it. Then you > >> >> have another individual feature file that describes date formats. > >> >> > >> >> > >> >> > P.S. Date validation really isn't that important in my application; > >> >> > that's > >> >> > just an example. A real example would be the sales tax calculation > >> >> > in > >> >> > the > >> >> > leasing app I worked on. That was very important, it was a global > >> >> > requirement with some important exceptions. But I think your > >> >> > approach > >> >> > would > >> >> > have worked there as well. > >> >> > >> >> Same ideas apply. > >> >> > >> >> Pat > >> >> > >> >> p.s. I didn't realize you were also the author of the other thread I > >> >> linked to :) > >> >> _______________________________________________ > >> >> rspec-users mailing list > >> >> rspec-users at rubyforge.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 > > > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.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 cdemyanovich at gmail.com Thu Jan 8 16:27:58 2009 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Thu, 8 Jan 2009 16:27:58 -0500 Subject: [rspec-users] any eta on the rspec book? In-Reply-To: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> References: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> Message-ID: <61c885db0901081327i668fe895qb466dc7f26c4d3b4@mail.gmail.com> Information on the book is always available here: http://pragprog.com/titles/achbd/the-rspec-book Currently, the ETA is April 2009. I'm sure that the authors will let us know if anything changes. Regards, Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jan 8 16:30:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 15:30:09 -0600 Subject: [rspec-users] any eta on the rspec book? In-Reply-To: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> References: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> Message-ID: <57c63afe0901081330h5b0a45fco8de3f851e6e096ef@mail.gmail.com> On Thu, Jan 8, 2009 at 1:51 PM, Tim Walker wrote: > Subject says it all... > > Thanks in advance, We've got a lot of momentum now. We had planned to do the beta release in December, but with holiday schedules (planned and otherwise) getting in everybody's way, that just couldn't happen. My hope is that we'll have the beta out on either the 21st or 28th of January (prag beta's typically come out on Wednesdays, and I'm quite sure that it won't be the 14th), and as soon as I have something concrete I'll post about it. Thanks for the continued interest! Cheers, David From dchelimsky at gmail.com Thu Jan 8 16:51:45 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 Jan 2009 15:51:45 -0600 Subject: [rspec-users] any eta on the rspec book? In-Reply-To: <61c885db0901081327i668fe895qb466dc7f26c4d3b4@mail.gmail.com> References: <1ebf5a4d0901081151s31e662d8q129f5413ec032db2@mail.gmail.com> <61c885db0901081327i668fe895qb466dc7f26c4d3b4@mail.gmail.com> Message-ID: <57c63afe0901081351n217169eay76036740f03fe1fc@mail.gmail.com> On Thu, Jan 8, 2009 at 3:27 PM, Craig Demyanovich wrote: > Information on the book is always available here: > > http://pragprog.com/titles/achbd/the-rspec-book > > Currently, the ETA is April 2009. I'm sure that the authors will let us know > if anything changes. To be clear: that's for the print book. Beta will be very soon. > > Regards, > Craig > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Fri Jan 9 07:37:29 2009 From: tero at tilus.net (Tero Tilus) Date: Fri, 9 Jan 2009 14:37:29 +0200 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> References: <20090107141148.GA15510@uivelo.tilus.net> <20090108095611.GA8340@uivelo.tilus.net> <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> Message-ID: <20090109123729.GB12671@uivelo.tilus.net> 2009-01-08 07:37, David Chelimsky: > I'd grab the 1.1.12 release candidates from github: > > gem sources -a http://gems.github.com > [sudo] gem install dchelimsky-rspec > [sudo] gem install dchelimsky-rspec-rails It gives me 1.1.11.6. Is that a "1.1.12 release candidate"? Could I git clone 1.1.12 somewhere? I'd love to do that. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From dchelimsky at gmail.com Fri Jan 9 09:14:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 9 Jan 2009 08:14:26 -0600 Subject: [rspec-users] Examples not getting rolled back... In-Reply-To: <20090109123729.GB12671@uivelo.tilus.net> References: <20090107141148.GA15510@uivelo.tilus.net> <20090108095611.GA8340@uivelo.tilus.net> <57c63afe0901080537k62110ed7h26b1461f75f84b13@mail.gmail.com> <20090109123729.GB12671@uivelo.tilus.net> Message-ID: <57c63afe0901090614s5461984fwb1c24e3630e588a5@mail.gmail.com> On Fri, Jan 9, 2009 at 6:37 AM, Tero Tilus wrote: > 2009-01-08 07:37, David Chelimsky: >> I'd grab the 1.1.12 release candidates from github: >> >> gem sources -a http://gems.github.com >> [sudo] gem install dchelimsky-rspec >> [sudo] gem install dchelimsky-rspec-rails > > It gives me 1.1.11.6. Is that a "1.1.12 release candidate"? > Could I git clone 1.1.12 somewhere? I'd love to do that. Sure. Take a look at http://github.com/dchelimsky/rspec/wikis > > -- > Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Jan 9 11:08:11 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 9 Jan 2009 17:08:11 +0100 Subject: [rspec-users] Is there a problem with webrat? Message-ID: webrat (0.3.4) I have this in the view:
<\div> I have this in my test: my_entity = Entity.find_by_entity_name( "my entity number #{row.hll_words_to_i}") within("div#" + dom_id(my_entity, :list)) do puts "within method executed for div" end within("div#" + dom_id(my_entity, :list)) do click_link "Destroy Entity" end The first within method prints the trace message The second within method call blows up with: within method executed for div When I delete the "first" entity # features/app/models/entities/step_definitions/entity_steps.rb:128 You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_html (NoMethodError) /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in `scoped_dom' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:158:in `dom' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:194:in `links' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/locators.rb:80:in `find_link' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:134:in `click_link' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/rails.rb:88:in `send' /usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/rails.rb:88:in `method_missing' Now, I am reasonably sure that the div selector is working as expected. It is the click_link method that is failing for some reason. Is this failure caused by something I have done or is it some problem with webrat? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 9 11:34:06 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 9 Jan 2009 17:34:06 +0100 Subject: [rspec-users] Is there a problem with webrat? In-Reply-To: References: Message-ID: <5c91da003de4e50dafc7e4431d2a2fe5@ruby-forum.com> James Byrne wrote: > webrat (0.3.4) > > Now, I am reasonably sure that the div selector is working as expected. > It is the click_link method that is failing for some reason. Is this > failure caused by something I have done or is it some problem with > webrat? It was something I did that was very, very wrong.... -- Posted via http://www.ruby-forum.com/. From mark.thomson at ieee.org Sat Jan 10 18:44:32 2009 From: mark.thomson at ieee.org (MarkMT) Date: Sat, 10 Jan 2009 15:44:32 -0800 (PST) Subject: [rspec-users] Is the Fit Table documentation correct? Message-ID: I've been looking at the authentication feature example contained in merb_cucumber and not having used features with tabulated input before I had to go and look for an explanation of the syntax. However when I looked at the wiki page on github that deals with this - http://wiki.github.com/aslakhellesoy/cucumber/using-fit-tables-in-a-feature I had some difficulty mapping the description there into what I was seeing in the example, which is shown here - http://github.com/david/merb_cucumber/tree/master/lib/generators/cucumber/templates/features/authentication/login.feature After some searching I found a discussion on lighthouse that seems to bear on this issue - http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/57-scenario-templates-to-allow-for-terse-scenario-tables This describes a syntax change that (if I understand correctly) involves putting variable placeholders in angle brackets and matching these to the column headings in the table. This seems to be consistent with the merb-cucumber example. However if I'm understanding this correctly, it looks like the change has not yet been reflected in the github documentation. Can someone confirm for me that this is the case, because it's possible that I'm just plain confused. Also, does the approach currently shown in the documentation still work? And is the idea there that table columns map sequentially onto the strings that correspond to the regexp match groups in the step definitions? Are the column headings then essentially redundant in that case? Mark. From matt at mattwynne.net Sat Jan 10 19:08:09 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 11 Jan 2009 00:08:09 +0000 Subject: [rspec-users] Is the Fit Table documentation correct? In-Reply-To: References: Message-ID: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> On 10 Jan 2009, at 23:44, MarkMT wrote: > I've been looking at the authentication feature example contained in > merb_cucumber and not having used features with tabulated input before > I had to go and look for an explanation of the syntax. However when I > looked at the wiki page on github that deals with this - > > http://wiki.github.com/aslakhellesoy/cucumber/using-fit-tables-in-a-feature > > I had some difficulty mapping the description there into what I was > seeing in the example, which is shown here - > > http://github.com/david/merb_cucumber/tree/master/lib/generators/cucumber/templates/features/authentication/login.feature > > After some searching I found a discussion on lighthouse that seems to > bear on this issue - > > http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/57-scenario-templates-to-allow-for-terse-scenario-tables > > This describes a syntax change that (if I understand correctly) > involves putting variable placeholders in angle brackets and matching > these to the column headings in the table. This seems to be consistent > with the merb-cucumber example. > > However if I'm understanding this correctly, it looks like the change > has not yet been reflected in the github documentation. Can someone > confirm for me that this is the case, because it's possible that I'm > just plain confused. > > Also, does the approach currently shown in the documentation still > work? And is the idea there that table columns map sequentially onto > the strings that correspond to the regexp match groups in the step > definitions? Are the column headings then essentially redundant in > that case? > > Mark. Hi Mark, I can't check the github wiki right now, because GH is down, but I'm sure I saw Scenario Outline documented on there today. There are three ways of doing tabulated data in Cucumber, and as far as I know they're all still supported. The basic way, shown on the homepage for cucumber, works in Given and Then steps (but not When), and looks like Then there should be the following people: | name | age | | Matt | 33 | | Anna | 31 | The next way extends a single Scenario with a More Examples table. The third, and newest way uses a Scenario Outline to define a template, followed by an Examples table to define the value substitutions to make the scenario actually run. HTH, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From mark.thomson at ieee.org Sat Jan 10 20:22:17 2009 From: mark.thomson at ieee.org (MarkMT) Date: Sat, 10 Jan 2009 17:22:17 -0800 (PST) Subject: [rspec-users] Is the Fit Table documentation correct? In-Reply-To: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> References: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> Message-ID: <9a447563-6e33-4710-8392-1c0e48c8f9c7@f40g2000pri.googlegroups.com> Thanks Matt. I have now found the page that deals with scenario outlines (GH is back up) - http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines so that is now pretty clear. Might be worth a note in the fit table page referring to that. On Jan 10, 6:08?pm, Matt Wynne wrote: > On 10 Jan 2009, at 23:44, MarkMT wrote: > > > > > I've been looking at the authentication feature example contained in > > merb_cucumber and not having used features with tabulated input before > > I had to go and look for an explanation of the syntax. However when I > > looked at the wiki page on github that deals with this - > > >http://wiki.github.com/aslakhellesoy/cucumber/using-fit-tables-in-a-f... > > > I had some difficulty mapping the description there into what I was > > seeing in the example, which is shown here - > > >http://github.com/david/merb_cucumber/tree/master/lib/generators/cucu... > > > After some searching I found a discussion on lighthouse that seems to > > bear on this issue - > > >http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/57-sce... > > > This describes a syntax change that (if I understand correctly) > > involves putting variable placeholders in angle brackets and matching > > these to the column headings in the table. This seems to be consistent > > with the merb-cucumber example. > > > However if I'm understanding this correctly, it looks like the change > > has not yet been reflected in the github documentation. Can someone > > confirm for me that this is the case, because it's possible that I'm > > just plain confused. > > > Also, does the approach currently shown in the documentation still > > work? And is the idea there that table columns map sequentially onto > > the strings that correspond to the regexp match groups in the step > > definitions? Are the column headings then essentially redundant in > > that case? > > > Mark. > > Hi Mark, > > I can't check the github wiki right now, because GH is down, but I'm ? > sure I saw Scenario Outline documented on there today. > > There are three ways of doing tabulated data in Cucumber, and as far ? > as I know they're all still supported. > > The basic way, shown on the homepage for cucumber, works in Given and ? > Then steps (but not When), and looks like > > ? ? ?Then there should be the following people: > ? ? ? ?| name ?| age | > ? ? ? ?| Matt ?| 33 ?| > ? ? ? ?| Anna ?| 31 ?| > > The next way extends a single Scenario with a More Examples table. > > The third, and newest way uses a Scenario Outline to define a ? > template, followed by an Examples table to define the value ? > substitutions to make the scenario actually run. > > HTH, > > Matt Wynnehttp://blog.mattwynne.nethttp://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From greg.hauptmann.ruby at gmail.com Sun Jan 11 03:17:15 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Sun, 11 Jan 2009 18:17:15 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? Message-ID: Hi, Any suggestions on how to write an rspec expectation for equality when you get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" doesn't work as the ruby BigDecimal comparison (via ==) to the same Float value gives false (not true as you'd expect). For background / as an example see below: ?> bd => # >> f => -323.03 >> f.class => Float >> bd.should == f Spec::Expectations::ExpectationNotMetError: expected: -323.03, got: # (using ==) from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/expectations.rb:52:in `fail_with' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:46:in `fail_with_message' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:61:in `__delegate_method_missing_to_given' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:12:in `==' from (irb):73 >> bd == f => false >> f == bd => false thanks Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Sun Jan 11 04:23:02 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 11 Jan 2009 01:23:02 -0800 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: Message-ID: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann < greg.hauptmann.ruby at gmail.com> wrote: > > Any suggestions on how to write an rspec expectation for equality when you > get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" > doesn't work as the ruby BigDecimal comparison (via ==) to the same Float > value gives false (not true as you'd expect). > How about bd.to_s.should == 123.23.to_s ? ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.hauptmann.ruby at gmail.com Sun Jan 11 05:05:36 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Sun, 11 Jan 2009 20:05:36 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> Message-ID: I've gone with the following ai.amount.should == BigDecimal('-323.03') However I'm still a bit surprised that Ruby itself does allow a good "==" test between a Float and a BigDecimal. Perhaps there's a reason that I'm missing? On Sun, Jan 11, 2009 at 7:23 PM, Mark Wilden wrote: > On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann < > greg.hauptmann.ruby at gmail.com> wrote: > >> >> Any suggestions on how to write an rspec expectation for equality when you >> get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" >> doesn't work as the ruby BigDecimal comparison (via ==) to the same Float >> value gives false (not true as you'd expect). >> > > How about bd.to_s.should == 123.23.to_s ? > > ///ark > > _______________________________________________ > 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 tomcloyd at comcast.net Sun Jan 11 07:26:04 2009 From: tomcloyd at comcast.net (Tom Cloyd) Date: Sun, 11 Jan 2009 04:26:04 -0800 Subject: [rspec-users] getting started - very much a beginner Message-ID: <4969E55C.3000004@comcast.net> A hope my ignorance is acceptable here. I have, to this point, programmed in Ruby mostly using my awareness of procedural programming; I've written a small number of very useful programs for myself. I'm starting to use classes now - just starting. I have a small project I'm working on - setting up a database based on the directed acyclic graph (DAG) model (using Ruby only). I'm been studying test-directed development, which led me to BDD, at which point I got really excited. I truly want to go forward with learning cucumber, and rspec. So here I am trying to started using cucumber, and I'm having a little trouble. The documentation in the cucumber wiki isn't, to my poverty stricken perception, at all procedural, although individual pages seem quite lucid and accessible. After reading and rereading (I've looked at every page, and most several times), it appears that the "start" page is "Cucumber Backgrounder". The problem is that this assumes you are working with Rails, about which I know little and desire to know less. I get stuck, on that page, at the phrase... ==When you run "script/generate cucumber" == Huh? Is this something you do in Rails? Then there's this -- ----- Running script/generate cucumber adds this layout to the existing structure: ||-- features | |-- step_definitions | | `-- webrat_steps.rb | `-- support | `-- env.rb | We are now ready to begin testing with cucumber. ----- Well, maybe for some people...but not for me. I simply cannot see what to do first. Do I manually create some kind of directory structure and fill it with...well, with what? Feature description files? And then what do I do? I'm guessing that this is covered by the "Running features" page. Am I right? Is there documentation somewhere that talks about using cucumber to launch BDD using a non-Rails Ruby program? I think that's what I really need. I cannot quite get past this stuck place, so any help at all would be much appreciated. I'm sorry to bother folks with this - I'm sure it's all quite obvious to you; I wish it were to me, and hope that it soon will be. Hopefully, Tom -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc at tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From tomcloyd at comcast.net Sun Jan 11 07:56:35 2009 From: tomcloyd at comcast.net (Tom Cloyd) Date: Sun, 11 Jan 2009 04:56:35 -0800 Subject: [rspec-users] maybe I 'get it' after all Message-ID: <4969EC83.8070708@comcast.net> I hope I'm not the only one in the world who posts to a discussion list only to (maybe) get the answer to a question moments after hitting posting. Sigh. Looking again, in the cucumber wiki page "Running Features", I had a sense that I maybe I DID know what to do, went to /examples/dos_line_endings in the cucumber gems installation on my machine, and entered to the CLI - ~$ cucumber features/dos_line_endings.feature After I stopped laughing at the feature description text (I too love Linux), I have to admit that this output simply works for me. Whew. So...my sense of "what to do" now, is to write *.feature files, with corresponding step definition files, then...well, there's lots of what-to-do info very lucidly written in the wiki. I much enjoy reading it - although I wish the Rails stuff was factored out, because it's of no use if you're not doing Rails, and I think I'm going to have to try to translate some of it, and will likely do it badly... If someone wants to redirect me in any way, I'll give very close attention to their advice. Meanwhile, I'm feeling like I can go forward with this and I'll be learning a great deal. This sure looks like fun...and very very useful, in the long run. I'm endlessly grateful for the hard work of others in the Ruby world, from which I benefit so much. t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc at tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From aslak.hellesoy at gmail.com Sun Jan 11 08:09:03 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 11 Jan 2009 14:09:03 +0100 Subject: [rspec-users] getting started - very much a beginner In-Reply-To: <4969E55C.3000004@comcast.net> References: <4969E55C.3000004@comcast.net> Message-ID: <8d961d900901110509y4c2c95c0l97f929ef984ed4c@mail.gmail.com> On Sun, Jan 11, 2009 at 1:26 PM, Tom Cloyd wrote: > A hope my ignorance is acceptable here. I have, to this point, > programmed in Ruby mostly using my awareness of procedural programming; > I've written a small number of very useful programs for myself. I'm starting > to use classes now - just starting. > > I have a small project I'm working on - setting up a database based on the > directed acyclic graph (DAG) model (using Ruby only). I'm been studying > test-directed development, which led me to BDD, at which point I got really > excited. I truly want to go forward with learning cucumber, and rspec. > > So here I am trying to started using cucumber, and I'm having a little > trouble. The documentation in the cucumber wiki isn't, to my poverty > stricken perception, at all procedural, although individual pages seem > quite lucid and accessible. After reading and rereading (I've looked at > every page, and most several times), it appears that the "start" page is > "Cucumber Backgrounder". The problem is that this assumes you are working > with Rails, about which I know little and desire to know less. I get stuck, > on that page, at the phrase... > > ==When you run "script/generate cucumber" == > > Huh? Is this something you do in Rails? > Yes, this is Rails only. I recommend you take a look at the examples/i18n folder. You'll find some really simplistic Cucumber code that is simple Ruby. No Rails or other complex material. Aslak > Then there's this -- > > ----- > > Running script/generate cucumber adds this layout to the existing > structure: > > ||-- features > | |-- step_definitions > | | `-- webrat_steps.rb > | `-- support > | `-- env.rb > | > > We are now ready to begin testing with cucumber. > > ----- > > Well, maybe for some people...but not for me. > > I simply cannot see what to do first. Do I manually create some kind of > directory structure and fill it with...well, with what? Feature > description files? And then what do I do? I'm guessing that this is > covered by the "Running features" page. Am I right? > > Is there documentation somewhere that talks about using cucumber to > launch BDD using a non-Rails Ruby program? I think that's what I really > need. I cannot quite get past this stuck place, so any help at all would > be much appreciated. I'm sorry to bother folks with this - I'm sure it's > all quite obvious to you; I wish it were to me, and hope that it soon > will be. > > Hopefully, > > Tom > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc at tomcloyd.com >> (email) > << TomCloyd.com >> (website) > << sleightmind.wordpress.com >> (mental health weblog) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > _______________________________________________ > 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 aslak.hellesoy at gmail.com Sun Jan 11 08:12:46 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 11 Jan 2009 14:12:46 +0100 Subject: [rspec-users] maybe I 'get it' after all In-Reply-To: <4969EC83.8070708@comcast.net> References: <4969EC83.8070708@comcast.net> Message-ID: <8d961d900901110512m7d6cffc6qbd5d01418b1be0ee@mail.gmail.com> On Sun, Jan 11, 2009 at 1:56 PM, Tom Cloyd wrote: > I hope I'm not the only one in the world who posts to a discussion list > only to (maybe) get the answer to a question moments after hitting > posting. Sigh. > > Looking again, in the cucumber wiki page "Running Features", I had a > sense that I maybe I DID know what to do, went to > /examples/dos_line_endings in the cucumber gems installation on my > machine, and entered to the CLI - > > ~$ cucumber features/dos_line_endings.feature > > After I stopped laughing at the feature description text (I too love > Linux), I have to admit that this output simply works for me. Whew. > > So...my sense of "what to do" now, is to write *.feature files, with > corresponding step definition files, then...well, there's lots of > what-to-do info very lucidly written in the wiki. I much enjoy reading > it - although I wish the Rails stuff was factored out, because it's of > no use if you're not doing Rails, and I think I'm going to have to try > to translate some of it, and will likely do it badly... > Good point. Keeping Rails-related content apart from the more general Cucumber docs has been my goal since I started. However, several contributors to the Wiki are using Rails and it seems they often think that everybody is using Rails. Or maybe they are so ingrained in the Rails way of doing things that it's hard to describe non-Rails environments. Keep this in mind folks! Aslak > > If someone wants to redirect me in any way, I'll give very close > attention to their advice. Meanwhile, I'm feeling like I can go > forward with this and I'll be learning a great deal. This sure looks > like fun...and very very useful, in the long run. > > I'm endlessly grateful for the hard work of others in the Ruby world, > from which I benefit so much. > > t. > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc at tomcloyd.com >> (email) > << TomCloyd.com >> (website) > << sleightmind.wordpress.com >> (mental health weblog) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > _______________________________________________ > 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 biot023 at gmail.com Sun Jan 11 08:16:06 2009 From: biot023 at gmail.com (doug livesey) Date: Sun, 11 Jan 2009 13:16:06 +0000 Subject: [rspec-users] maybe I 'get it' after all In-Reply-To: <4969EC83.8070708@comcast.net> References: <4969EC83.8070708@comcast.net> Message-ID: <50873a360901110516o778a10es864e1e6e9f20759e@mail.gmail.com> > I hope I'm not the only one in the world who posts to a discussion list > only to (maybe) get the answer to a question moments after hitting > posting. Sigh. Hey, that's my trick! Get your own! 2009/1/11 Tom Cloyd > I hope I'm not the only one in the world who posts to a discussion list > only to (maybe) get the answer to a question moments after hitting > posting. Sigh. > > Looking again, in the cucumber wiki page "Running Features", I had a > sense that I maybe I DID know what to do, went to > /examples/dos_line_endings in the cucumber gems installation on my > machine, and entered to the CLI - > > ~$ cucumber features/dos_line_endings.feature > > After I stopped laughing at the feature description text (I too love > Linux), I have to admit that this output simply works for me. Whew. > > So...my sense of "what to do" now, is to write *.feature files, with > corresponding step definition files, then...well, there's lots of > what-to-do info very lucidly written in the wiki. I much enjoy reading > it - although I wish the Rails stuff was factored out, because it's of > no use if you're not doing Rails, and I think I'm going to have to try > to translate some of it, and will likely do it badly... > > If someone wants to redirect me in any way, I'll give very close > attention to their advice. Meanwhile, I'm feeling like I can go > forward with this and I'll be learning a great deal. This sure looks > like fun...and very very useful, in the long run. > > I'm endlessly grateful for the hard work of others in the Ruby world, > from which I benefit so much. > > t. > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc at tomcloyd.com >> (email) > << TomCloyd.com >> (website) > << sleightmind.wordpress.com >> (mental health weblog) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 11 09:21:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 Jan 2009 08:21:07 -0600 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> Message-ID: <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann wrote: > I've gone with the following > ai.amount.should == BigDecimal('-323.03') > However I'm still a bit surprised that Ruby itself does allow a good "==" > test between a Float and a BigDecimal. Perhaps there's a reason that I'm > missing? Very telling is this: >> require 'bigdecimal' => true >> BigDecimal.new(3333333.0) == 3333333.0 TypeError: can't convert Float into String from (irb):4:in `new' from (irb):4 As for why, I think you'll get some good insights if you post the ruby-lang mailing list, but I can take shot. BigDecimal has explicit precision. Float does not. Imagine the developer at the bank explaining that the thousands of dollars discrepancy last year was due to an average miscalculation of 0.00005 per transaction because sometimes the code used BigDecimal, and sometimes it used Float. Personally, I think this seeming annoyance is actually a good thing. FWIW, David > > On Sun, Jan 11, 2009 at 7:23 PM, Mark Wilden wrote: >> >> On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann >> wrote: >>> >>> Any suggestions on how to write an rspec expectation for equality when >>> you get a BigDecimal back. I see that "big_decimal_variable.should == >>> 123.23" doesn't work as the ruby BigDecimal comparison (via ==) to the same >>> Float value gives false (not true as you'd expect). >> >> How about bd.to_s.should == 123.23.to_s ? >> >> ///ark From matt at mattwynne.net Sun Jan 11 09:28:29 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 11 Jan 2009 14:28:29 +0000 Subject: [rspec-users] Is the Fit Table documentation correct? In-Reply-To: <9a447563-6e33-4710-8392-1c0e48c8f9c7@f40g2000pri.googlegroups.com> References: <0216EBFF-686E-4085-AB3A-8D972F19E0FA@mattwynne.net> <9a447563-6e33-4710-8392-1c0e48c8f9c7@f40g2000pri.googlegroups.com> Message-ID: <232C8D95-A694-47E9-9EB9-B385184BA514@mattwynne.net> On 11 Jan 2009, at 01:22, MarkMT wrote: > Thanks Matt. I have now found the page that deals with scenario > outlines (GH is back up) - > > http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines > > so that is now pretty clear. Might be worth a note in the fit table > page referring to that. The wiki is open to all... be our guest! Seriously it's terrific if first-timers can polish these pages, as they're often written by those of us who are quite immersed in the product and consequently find it harder to put on the 'newbie hat' to proof-read documentation. cheers, Matt Wynne http://blog.mattwynne.net http://www.songkick.com From rick.denatale at gmail.com Sun Jan 11 13:53:05 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 11 Jan 2009 13:53:05 -0500 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky wrote: > On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann > wrote: > > I've gone with the following > > ai.amount.should == BigDecimal('-323.03') > > However I'm still a bit surprised that Ruby itself does allow a good "==" > > test between a Float and a BigDecimal. Perhaps there's a reason that I'm > > missing? > > Very telling is this: > > >> require 'bigdecimal' > => true > >> BigDecimal.new(3333333.0) == 3333333.0 > TypeError: can't convert Float into String > from (irb):4:in `new' > from (irb):4 > > As for why, I think you'll get some good insights if you post the > ruby-lang mailing list, but I can take shot. > > BigDecimal has explicit precision. Float does not. Imagine the > developer at the bank explaining that the thousands of dollars > discrepancy last year was due to an average miscalculation of 0.00005 > per transaction because sometimes the code used BigDecimal, and > sometimes it used Float. > Even more telling is this: irb(main):001:0> 1.0 / 3.0 => 0.333333333333333 irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 => false This has little to do with rspec or Ruby, and everything to do with floats. Floats are approximations, it's a mistake to thing of them as equivalent to the mathematical concept of real numbers, or even rational numbers. There are several issues here including 1. Floats are not infinite precision, they have a fixed number of bits or digits, this means that in-between any two consecutive real number which CAN be represented by a float, there are an infinite number of reals which cannot. 2. As is the case in decimal fractions, where some rational numbers such as 1/3 cannot be represented without an infinite number of decimal digits, there are similar values dependent on the base used for the float representation. There's a whole branch of computer science, Numerical Analysis, comprised in large part of understanding how Floats differ from the mathematical ideal. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.hauptmann.ruby at gmail.com Sun Jan 11 15:33:34 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Mon, 12 Jan 2009 06:33:34 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: it would be nice in one's project if you could basically say "use BigDecimal wherever you normally would have used a float", just to get the benefit but maintain ease of coding/readability etc - anyone know if this is possible? Would it be enough to override Float's initializer and return a BigDecimal instead? On Mon, Jan 12, 2009 at 4:53 AM, Rick DeNatale wrote: > On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky wrote: > >> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann >> wrote: >> > I've gone with the following >> > ai.amount.should == BigDecimal('-323.03') >> > However I'm still a bit surprised that Ruby itself does allow a good >> "==" >> > test between a Float and a BigDecimal. Perhaps there's a reason that >> I'm >> > missing? >> >> Very telling is this: >> >> >> require 'bigdecimal' >> => true >> >> BigDecimal.new(3333333.0) == 3333333.0 >> TypeError: can't convert Float into String >> from (irb):4:in `new' >> from (irb):4 >> >> As for why, I think you'll get some good insights if you post the >> ruby-lang mailing list, but I can take shot. >> >> BigDecimal has explicit precision. Float does not. Imagine the >> developer at the bank explaining that the thousands of dollars >> discrepancy last year was due to an average miscalculation of 0.00005 >> per transaction because sometimes the code used BigDecimal, and >> sometimes it used Float. >> > > Even more telling is this: > irb(main):001:0> 1.0 / 3.0 > => 0.333333333333333 > irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 > => false > > This has little to do with rspec or Ruby, and everything to do with floats. > > Floats are approximations, it's a mistake to thing of them as equivalent to > the mathematical concept of real numbers, or even rational numbers. There > are several issues here including > > 1. Floats are not infinite precision, they have a fixed number of bits or > digits, this means that in-between any two consecutive real number which CAN > be represented by a float, there are an infinite number of reals which > cannot. > > 2. As is the case in decimal fractions, where some rational numbers such as > 1/3 cannot be represented without an infinite number of decimal digits, > there are similar values dependent on the base used for the float > representation. > > There's a whole branch of computer science, Numerical Analysis, comprised > in large part of understanding how Floats differ from the mathematical > ideal. > > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Greg http://blog.gregnet.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mauricio.linhares at gmail.com Sun Jan 11 15:45:28 2009 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Sun, 11 Jan 2009 18:45:28 -0200 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: This is a very bad idea, as you can break the whole runtime by doing this, as many internal classes use floating point math. You would also slow the world down, as operations using BigDecimals are some order of magnitude slower than pure floating point math. - Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Sun, Jan 11, 2009 at 6:33 PM, Greg Hauptmann wrote: > it would be nice in one's project if you could basically say "use > BigDecimal wherever you normally would have used a float", just to get the > benefit but maintain ease of coding/readability etc - anyone know if this is > possible? Would it be enough to override Float's initializer and return a > BigDecimal instead? > > > On Mon, Jan 12, 2009 at 4:53 AM, Rick DeNatale > wrote: >> >> On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky >> wrote: >>> >>> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann >>> wrote: >>> > I've gone with the following >>> > ai.amount.should == BigDecimal('-323.03') >>> > However I'm still a bit surprised that Ruby itself does allow a good >>> > "==" >>> > test between a Float and a BigDecimal. Perhaps there's a reason that >>> > I'm >>> > missing? >>> >>> Very telling is this: >>> >>> >> require 'bigdecimal' >>> => true >>> >> BigDecimal.new(3333333.0) == 3333333.0 >>> TypeError: can't convert Float into String >>> from (irb):4:in `new' >>> from (irb):4 >>> >>> As for why, I think you'll get some good insights if you post the >>> ruby-lang mailing list, but I can take shot. >>> >>> BigDecimal has explicit precision. Float does not. Imagine the >>> developer at the bank explaining that the thousands of dollars >>> discrepancy last year was due to an average miscalculation of 0.00005 >>> per transaction because sometimes the code used BigDecimal, and >>> sometimes it used Float. >> >> Even more telling is this: >> irb(main):001:0> 1.0 / 3.0 >> => 0.333333333333333 >> irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 >> => false >> >> This has little to do with rspec or Ruby, and everything to do with >> floats. >> >> Floats are approximations, it's a mistake to thing of them as equivalent >> to the mathematical concept of real numbers, or even rational numbers. There >> are several issues here including >> >> 1. Floats are not infinite precision, they have a fixed number of bits or >> digits, this means that in-between any two consecutive real number which CAN >> be represented by a float, there are an infinite number of reals which >> cannot. >> >> 2. As is the case in decimal fractions, where some rational numbers such >> as 1/3 cannot be represented without an infinite number of decimal digits, >> there are similar values dependent on the base used for the float >> representation. >> >> There's a whole branch of computer science, Numerical Analysis, comprised >> in large part of understanding how Floats differ from the mathematical >> ideal. >> >> >> -- >> Rick DeNatale >> >> Blog: http://talklikeaduck.denhaven2.com/ >> Twitter: http://twitter.com/RickDeNatale >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Greg > http://blog.gregnet.org/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Sun Jan 11 16:31:20 2009 From: tero at tilus.net (Tero Tilus) Date: Sun, 11 Jan 2009 23:31:20 +0200 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: Message-ID: <20090111213119.GE18105@uivelo.tilus.net> 2009-01-11 18:17, Greg Hauptmann: > Any suggestions on how to write an rspec expectation for equality when you > get a BigDecimal back. I see that "big_decimal_variable.should == > 123.23" If you register keywords "comparison" and "float", you should train yourself to cry out "delta" without even thinking. ;) Would this work for you? big_decimal_variable.should be_close(123.23, 0.005) -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From mark at mwilden.com Sun Jan 11 17:06:42 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 11 Jan 2009 14:06:42 -0800 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: Message-ID: <3c30da400901111406v1c652585x79a63f86cadd531e@mail.gmail.com> On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann < greg.hauptmann.ruby at gmail.com> wrote: > Any suggestions on how to write an rspec expectation for equality when you > get a BigDecimal back. I see that "big_decimal_variable.should == 123.23" > doesn't work as the ruby BigDecimal comparison (via ==) to the same Float > value gives false (not true as you'd expect). > Noting there are two decimal places in your data, I might suggest using the Money plugin. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.hauptmann.ruby at gmail.com Sun Jan 11 17:36:42 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Mon, 12 Jan 2009 08:36:42 +1000 Subject: [rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this??? In-Reply-To: References: <3c30da400901110123p2669f2e4xbda03ca27daa6a20@mail.gmail.com> <57c63afe0901110621p774a15dp86e78028e79cef92@mail.gmail.com> Message-ID: ok - thanks - seems like if one remembers to use "BigDecimal('10.1')", then instead of 10.1 in your code you should be ok then. On Mon, Jan 12, 2009 at 6:45 AM, Maur?cio Linhares < mauricio.linhares at gmail.com> wrote: > This is a very bad idea, as you can break the whole runtime by doing > this, as many internal classes use floating point math. You would also > slow the world down, as operations using BigDecimals are some order of > magnitude slower than pure floating point math. > > - > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) > > > > On Sun, Jan 11, 2009 at 6:33 PM, Greg Hauptmann > wrote: > > it would be nice in one's project if you could basically say "use > > BigDecimal wherever you normally would have used a float", just to get > the > > benefit but maintain ease of coding/readability etc - anyone know if this > is > > possible? Would it be enough to override Float's initializer and return > a > > BigDecimal instead? > > > > > > On Mon, Jan 12, 2009 at 4:53 AM, Rick DeNatale > > wrote: > >> > >> On Sun, Jan 11, 2009 at 9:21 AM, David Chelimsky > >> wrote: > >>> > >>> On Sun, Jan 11, 2009 at 4:05 AM, Greg Hauptmann > >>> wrote: > >>> > I've gone with the following > >>> > ai.amount.should == BigDecimal('-323.03') > >>> > However I'm still a bit surprised that Ruby itself does allow a good > >>> > "==" > >>> > test between a Float and a BigDecimal. Perhaps there's a reason that > >>> > I'm > >>> > missing? > >>> > >>> Very telling is this: > >>> > >>> >> require 'bigdecimal' > >>> => true > >>> >> BigDecimal.new(3333333.0) == 3333333.0 > >>> TypeError: can't convert Float into String > >>> from (irb):4:in `new' > >>> from (irb):4 > >>> > >>> As for why, I think you'll get some good insights if you post the > >>> ruby-lang mailing list, but I can take shot. > >>> > >>> BigDecimal has explicit precision. Float does not. Imagine the > >>> developer at the bank explaining that the thousands of dollars > >>> discrepancy last year was due to an average miscalculation of 0.00005 > >>> per transaction because sometimes the code used BigDecimal, and > >>> sometimes it used Float. > >> > >> Even more telling is this: > >> irb(main):001:0> 1.0 / 3.0 > >> => 0.333333333333333 > >> irb(main):002:0> (1.0 / 3.00) == 0.333333333333333 > >> => false > >> > >> This has little to do with rspec or Ruby, and everything to do with > >> floats. > >> > >> Floats are approximations, it's a mistake to thing of them as equivalent > >> to the mathematical concept of real numbers, or even rational numbers. > There > >> are several issues here including > >> > >> 1. Floats are not infinite precision, they have a fixed number of bits > or > >> digits, this means that in-between any two consecutive real number which > CAN > >> be represented by a float, there are an infinite number of reals which > >> cannot. > >> > >> 2. As is the case in decimal fractions, where some rational numbers such > >> as 1/3 cannot be represented without an infinite number of decimal > digits, > >> there are similar values dependent on the base used for the float > >> representation. > >> > >> There's a whole branch of computer science, Numerical Analysis, > comprised > >> in large part of understanding how Floats differ from the mathematical > >> ideal. > >> > >> > >> -- > >> Rick DeNatale > >> > >> Blog: http://talklikeaduck.denhaven2.com/ > >> Twitter: http://twitter.com/RickDeNatale > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -- > > Greg > > http://blog.gregnet.org/ > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Greg http://blog.gregnet.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Jan 12 09:09:33 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 12 Jan 2009 14:09:33 +0000 Subject: [rspec-users] NullDb makes rake spec take (much) longer Message-ID: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> Hi all, We did a spike last week to de-couple our view and controller tests from the database, using NullDb. It didn't go too well. I realise that this plugin isn't part of RSpec, but I thought others on this list might have experiences to share. Here's a summary of my colleague's investigations: > I installed the plugin from http://github.com/jakehow/nulldb/tree/master > > Changed spec/spec_helper to set > "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by > default. > > The specs that complained of the lack of db, I included a before(all) > that changed the connection to the test database (include > NeedsDatabase - copied from Ben Mabey's Functional module) > By default, I also included the db for all models (config.include > NeedsDatabase, :type => :model) > > Running spec spec/views with or without nulldb takes about the same > time (a couple of seconds less with nulldb). However, running "rake > spec" with nulldb takes 10 times longer!! > > Another weird thing was that three tests failed in the controllers > (venues and concerts) in a very strange way, even when I included the > NeedsDatabase in the tests that needed it. The weird bit is, when I > run: "spec spec/controllers/venues_controller_spec.rb" it doesn't > fail. But when I run: "spec spec/controllers/users_controller_spec.rb > spec/controllers/venues_controller_spec.rb" It does fail... That is, > the user_controller test is influencing the results of the > venue_controller test! > The same weird behaviour happens in lib/sk/find > > This made me had to include NeedsDatabase for all lib and controllers > tests as well. The barrier for us was the shockingly poor performance of 'rake spec' on the view specs - it really means we just can't use it, and actually only barely improved the performance of the specs at all. I was disappointed that the view specs didn't get any faster. My guess is that stub_model is the problem - as it has to do quite a bit of work to set up the attributes on the models. So, can anyone tell us what we might have been doing wrong? Or did I just have unrealistic expectations of how this might help? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Jan 12 10:20:35 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 16:20:35 +0100 Subject: [rspec-users] getting started - very much a beginner In-Reply-To: <4969E55C.3000004@comcast.net> References: <4969E55C.3000004@comcast.net> Message-ID: <66a39943877200ba3e6bb3ac5ff4d898@ruby-forum.com> Tom Cloyd wrote: > > The problem is that this assumes you are working with Rails, about > which I know little and desire to know less. I get stuck, on that page, > at the phrase... > > ==When you run "script/generate cucumber" == > > Huh? Is this something you do in Rails? > > Then there's this -- > > ----- > > Running script/generate cucumber adds this layout to the existing > structure: > > ||-- features > | |-- step_definitions > | | `-- webrat_steps.rb > | `-- support > | `-- env.rb > | > > We are now ready to begin testing with cucumber. > > ----- > > Well, maybe for some people...but not for me. > > I simply cannot see what to do first. First, let me a assure you that ignorance, or at least the admission to it, is a de facto requirement here. If we all knew everything then there would be precious little to write about. Second, as the author of the Cucumber Backgrounder, I apologize for my evident bias in creating a solely Rails Centric guide. This article was, in fact, my first attempt at such a thing and I completely overlooked that others might not approach testing with cucumber from outside the Rails Framework. Over the next little while I will endeavour to correct that defect. Third, that article was intended as a guide on how to get cucumber working inside a Rails project rather than a guide on how to actually construct tests/features. In other words, it deals primarily with the mechanics of setting up the environment rather than with exercising the capabilities. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Jan 12 11:45:07 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 17:45:07 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios Message-ID: I have an authentication filter on my application controller. I have the following feature statements: Scenario: I should be logged in to do any of this Given we have a user named "myuser" And the user named "myuser" logs in When they visit the "entities" page Then they should see the "entities" page Scenario: Entity should have essential identification information Given I do not have any entities And I am on the add a new entity page When I enter "My Business Relation" in the "Common Name" field And I enter "My B.R. Legal Name" in the "Legal Name" field And I choose "Corporation" as the "Legal Form" And I press "Create" Then I should save the entity information successfully In scenario 1, the user is logged in successfully and the response body after the 'see the "entities" page' is indeed the entities/index page. When /should see the "(entities)" page/ do |resource| response.body.should =~ /All Entities/m end When /on the add a new entity page/ do visits new_entity_path response.body.should =~ /Add a New Entity/m end However, in Scenario 2, I am assuming that a.) the same user (myuser) and their associated login session is employed. Since the response body from this is the login page then evidently this assumption is wrong and something else is going on. Can some inform me as to how test logins are managed/maintained/reused within cucumber/webrat? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Jan 12 12:21:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Jan 2009 11:21:49 -0600 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: References: Message-ID: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> On Mon, Jan 12, 2009 at 10:45 AM, James Byrne wrote: > I have an authentication filter on my application controller. I have the > following feature statements: > > > Scenario: I should be logged in to do any of this > Given we have a user named "myuser" > And the user named "myuser" logs in > When they visit the "entities" page > Then they should see the "entities" page > > > Scenario: Entity should have essential identification information > > Given I do not have any entities > And I am on the add a new entity page > When I enter "My Business Relation" in the "Common Name" field > And I enter "My B.R. Legal Name" in the "Legal Name" field > And I choose "Corporation" as the "Legal Form" > And I press "Create" > Then I should save the entity information successfully > > In scenario 1, the user is logged in successfully and the response body > after the 'see the "entities" page' is indeed the entities/index page. > > When /should see the "(entities)" page/ do |resource| > response.body.should =~ /All Entities/m > end > > When /on the add a new entity page/ do > visits new_entity_path > response.body.should =~ /Add a New Entity/m > end > > > However, in Scenario 2, I am assuming that a.) the same user (myuser) > and their associated login session is employed. Since the response body > from this is the login page then evidently this assumption is wrong and > something else is going on. Can some inform me as to how test logins > are managed/maintained/reused within cucumber/webrat? Each scenario operates in a new session. I usually have a step that aggregates the login process: Given /^I am logged in as "(.*)"/ do |role| #create a user whose name and role are based on the role #log in that user end This lets me say: Given I am logged in as "admin" When I visit the super-secret page Then I see it and learn about all its mystery HTH, David From ben at benmabey.com Mon Jan 12 12:36:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 10:36:16 -0700 Subject: [rspec-users] NullDb makes rake spec take (much) longer In-Reply-To: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> References: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> Message-ID: <496B7F90.3040007@benmabey.com> On 1/12/09 7:09 AM, Matt Wynne wrote: > Hi all, > > We did a spike last week to de-couple our view and controller tests > from the database, using NullDb. It didn't go too well. I realise that > this plugin isn't part of RSpec, but I thought others on this list > might have experiences to share. > > Here's a summary of my colleague's investigations: > >> I installed the plugin from http://github.com/jakehow/nulldb/tree/master >> >> Changed spec/spec_helper to set >> "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by >> default. >> >> The specs that complained of the lack of db, I included a before(all) >> that changed the connection to the test database (include >> NeedsDatabase - copied from Ben Mabey's Functional module) >> By default, I also included the db for all models (config.include >> NeedsDatabase, :type => :model) >> >> Running spec spec/views with or without nulldb takes about the same >> time (a couple of seconds less with nulldb). However, running "rake >> spec" with nulldb takes 10 times longer!! >> >> Another weird thing was that three tests failed in the controllers >> (venues and concerts) in a very strange way, even when I included the >> NeedsDatabase in the tests that needed it. The weird bit is, when I >> run: "spec spec/controllers/venues_controller_spec.rb" it doesn't >> fail. But when I run: "spec spec/controllers/users_controller_spec.rb >> spec/controllers/venues_controller_spec.rb" It does fail... That is, >> the user_controller test is influencing the results of the >> venue_controller test! >> The same weird behaviour happens in lib/sk/find >> >> This made me had to include NeedsDatabase for all lib and controllers >> tests as well. > > The barrier for us was the shockingly poor performance of 'rake spec' > on the view specs - it really means we just can't use it, and actually > only barely improved the performance of the specs at all. > > I was disappointed that the view specs didn't get any faster. My guess > is that stub_model is the problem - as it has to do quite a bit of > work to set up the attributes on the models. > > So, can anyone tell us what we might have been doing wrong? Or did I > just have unrealistic expectations of how this might help? > > 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 Hey Matt, I had similar experiences when I started using NullDB. I think that the reason why the overall spec suite runs slow is AR is switching from one adapter to another, and in the case of the mysql one it probably is relatively expensive to set up a new connection. Switching over to using NullDB on an existing project of any sizable size is going to be large task IMO. On my last project we started using NullDB by default and the result has been very worthwhile and noticeable. In this project DB connectivity was the exception, not the norm (even on our model specs) and so that is why I created a module that would turn on the DB temporarily. In your case the opposite approach may be needed. Going back to the problem at hand... Based on the email you are using a module like this: unless Object.const_defined?(:NeedsDatabase) share_as :NeedsDatabase do before :all do ActiveRecord::Base.establish_connection(:test) end after :all do ActiveRecord::Base.establish_connection(:adapter => :nulldb) end end end Since you are including this on all of your model specs (and more) you are incurring the setup and teardown cost of the DB connection repeatedly. Like I said, you may want to adopt the opposite policy of turning it off temporarily... You could also make the the changing smarter by only changing it when you need to.. something like: share_as :NeedsDatabase do before :all do ActiveRecord::Base.establish_connection(:test) if ActiveRecord::Base.connection.class.to_s =~ /NullDB/ end end share_as :DontNeedDatabase do before :all do ActiveRecord::Base.establish_connection(:adapter => :nulldb) unless ActiveRecord::Base.connection.class.to_s =~ /NullDB/ end end With this approach you would need to specify whether or not to use the DB for each example group... just a thought. Of course, an even better solution would be to somehow modify AR to maintain an active connection to the real DB even when it isn't the active adapter. re: the view specs I wouldn't expect to see too much gain here. The big win for nullDB is in models IMO. Of course, having it on the view and controller specs helps prevent accidental DB calls. re: the random controller spec failures I only guess is that you are somehow relying on the DB in your controller specs. I did this too in my controllers when I called class methods on models that would get a list from the DB... I can't really help without seeing any specs though. I hope this helps and you can find a suitable policy on how to manage the connections/adapters. Just ask if you have any other questions. -Ben From lists at ruby-forum.com Mon Jan 12 12:46:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 18:46:23 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> Message-ID: David Chelimsky wrote: > > Each scenario operates in a new session. > > I usually have a step that aggregates the login process: > > Given /^I am logged in as "(.*)"/ do |role| > #create a user whose name and role are based on the role > #log in that user > end > > This lets me say: > > Given I am logged in as "admin" > When I visit the super-secret page > Then I see it and learn about all its mystery > > HTH, > David Thanks David, I have something like that: When /user named "(.*)" logs in/ do |name| # assumes that the user given exists of course visits root_path UserSession.find.destroy if UserSession.find Then "enter the username \"#{name}\"" Then "enter the password \"#{name}-password\"" Then "press the login button" Then "welcome message" end But this seems needlessly expensive given that the entire application is secured. Is there no way of preserving a login session for any arbitrary period across both features and scenario? Is there a technical or philosophical reason why this is not so? -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Jan 12 13:10:14 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 12 Jan 2009 19:10:14 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> Message-ID: <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> On Mon, Jan 12, 2009 at 6:21 PM, David Chelimsky wrote: > On Mon, Jan 12, 2009 at 10:45 AM, James Byrne > wrote: > > I have an authentication filter on my application controller. I have the > > following feature statements: > > > > > > Scenario: I should be logged in to do any of this > > Given we have a user named "myuser" > > And the user named "myuser" logs in > > When they visit the "entities" page > > Then they should see the "entities" page > > > > > > Scenario: Entity should have essential identification information > > > > Given I do not have any entities > > And I am on the add a new entity page > > When I enter "My Business Relation" in the "Common Name" field > > And I enter "My B.R. Legal Name" in the "Legal Name" field > > And I choose "Corporation" as the "Legal Form" > > And I press "Create" > > Then I should save the entity information successfully > > > > In scenario 1, the user is logged in successfully and the response body > > after the 'see the "entities" page' is indeed the entities/index page. > > > > When /should see the "(entities)" page/ do |resource| > > response.body.should =~ /All Entities/m > > end > > > > When /on the add a new entity page/ do > > visits new_entity_path > > response.body.should =~ /Add a New Entity/m > > end > > > > > > However, in Scenario 2, I am assuming that a.) the same user (myuser) > > and their associated login session is employed. Since the response body > > from this is the login page then evidently this assumption is wrong and > > something else is going on. Can some inform me as to how test logins > > are managed/maintained/reused within cucumber/webrat? > > Each scenario operates in a new session. > And coupling scenarios (or any kind of automated test - regardless of framework) is a very bad idea. Aslak > > I usually have a step that aggregates the login process: > > Given /^I am logged in as "(.*)"/ do |role| > #create a user whose name and role are based on the role > #log in that user > end > > This lets me say: > > Given I am logged in as "admin" > When I visit the super-secret page > Then I see it and learn about all its mystery > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Jan 12 13:47:07 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 19:47:07 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> Message-ID: Aslak Helles?y wrote: > On Mon, Jan 12, 2009 at 6:21 PM, David Chelimsky > wrote: > >> > Then they should see the "entities" page >> > Then I should save the entity information successfully >> > response.body.should =~ /Add a New Entity/m >> > And coupling scenarios (or any kind of automated test - regardless of > framework) is a very bad idea. > > Aslak I do not have a problem with putting : Given I am logged in as "myuser" At the start of every scenario, but is there no way of performing the actual log in once, place the session info into an instance variable and then use that rather than actually starting up a new session each and every time? -- Posted via http://www.ruby-forum.com/. From sfeley at gmail.com Mon Jan 12 14:29:55 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 12 Jan 2009 14:29:55 -0500 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> Message-ID: <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> On Mon, Jan 12, 2009 at 1:47 PM, James Byrne wrote: > > At the start of every scenario, but is there no way of performing the > actual log in once, place the session info into an instance variable and > then use that rather than actually starting up a new session each and > every time? Sure. You could mock out your session or deserialize a saved session object in a Cucumber Before block on every feature except the one that tests login. Or put the "Given" call that does the real session initiation inside a Before so you don't have to look at it every time. If you want it to happen _everywhere_, you can also have a Before in the env.rb file. You can't chain the results from one scenario to another, however, because the order scenarios run in (or whether they run at all) is not guaranteed. So you'd have to put it in your setup code. On acceptance testing, I'd favor going through the actual session creation logic instead of mocking it, even if you don't put an explicit "Given" every time. Yeah, it's slower. But acceptance tests aren't _supposed_ to be fast; they're supposed to demonstrate real usage, and be the last line of defense between your app and the big bad world. They're going to be slow with or without login each time. And if there is some unseen routing or filtering bug in some controller's session access that doesn't show up in your test because you skipped past all that, and you lose a day and some hair trying to figure it out, you're going to wonder whether the seconds you saved were worth it. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lists at ruby-forum.com Mon Jan 12 14:49:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 20:49:23 +0100 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> Message-ID: <72115b99c30008ef9d8237d9fbd48db9@ruby-forum.com> Stephen Eley wrote: > > On acceptance testing, I'd favor going through the actual session > creation logic instead of mocking it, even if you don't put an > explicit "Given" every time. Yeah, it's slower. But acceptance tests > aren't _supposed_ to be fast; they're supposed to demonstrate real > usage, and be the last line of defense between your app and the big > bad world. They're going to be slow with or without login each time. > And if there is some unseen routing or filtering bug in some > controller's session access that doesn't show up in your test because > you skipped past all that, and you lose a day and some hair trying to > figure it out, you're going to wonder whether the seconds you saved > were worth it. Ok, Ok, Ok... It is no big deal to login in every time. If that is the way it should be done in general then I have learned enough these past weeks that I will go with the flow and save myself some headaches. Thanks for the pointers and the explanations. I feel much more comfortable about doing the login in each scenario now that I understand the reasons. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Mon Jan 12 15:05:28 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 12 Jan 2009 20:05:28 +0000 Subject: [rspec-users] NullDb makes rake spec take (much) longer In-Reply-To: <496B7F90.3040007@benmabey.com> References: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> <496B7F90.3040007@benmabey.com> Message-ID: <616BACD6-0EB0-4A92-8937-8D9C34B6E743@mattwynne.net> On 12 Jan 2009, at 17:36, Ben Mabey wrote: > On 1/12/09 7:09 AM, Matt Wynne wrote: >> Hi all, >> >> We did a spike last week to de-couple our view and controller tests >> from the database, using NullDb. It didn't go too well. I realise >> that this plugin isn't part of RSpec, but I thought others on this >> list might have experiences to share. >> >> Here's a summary of my colleague's investigations: >> >>> I installed the plugin from http://github.com/jakehow/nulldb/tree/master >>> >>> Changed spec/spec_helper to set >>> "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by >>> default. >>> >>> The specs that complained of the lack of db, I included a >>> before(all) >>> that changed the connection to the test database (include >>> NeedsDatabase - copied from Ben Mabey's Functional module) >>> By default, I also included the db for all models (config.include >>> NeedsDatabase, :type => :model) >>> >>> Running spec spec/views with or without nulldb takes about the same >>> time (a couple of seconds less with nulldb). However, running "rake >>> spec" with nulldb takes 10 times longer!! >>> >>> Another weird thing was that three tests failed in the controllers >>> (venues and concerts) in a very strange way, even when I included >>> the >>> NeedsDatabase in the tests that needed it. The weird bit is, when I >>> run: "spec spec/controllers/venues_controller_spec.rb" it doesn't >>> fail. But when I run: "spec spec/controllers/ >>> users_controller_spec.rb >>> spec/controllers/venues_controller_spec.rb" It does fail... That is, >>> the user_controller test is influencing the results of the >>> venue_controller test! >>> The same weird behaviour happens in lib/sk/find >>> >>> This made me had to include NeedsDatabase for all lib and >>> controllers >>> tests as well. >> >> The barrier for us was the shockingly poor performance of 'rake >> spec' on the view specs - it really means we just can't use it, and >> actually only barely improved the performance of the specs at all. >> >> I was disappointed that the view specs didn't get any faster. My >> guess is that stub_model is the problem - as it has to do quite a >> bit of work to set up the attributes on the models. >> >> So, can anyone tell us what we might have been doing wrong? Or did >> I just have unrealistic expectations of how this might help? >> >> 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 > > Hey Matt, > I had similar experiences when I started using NullDB. I think that > the reason why the overall spec suite runs slow is AR is switching > from one adapter to another, and in the case of the mysql one it > probably is relatively expensive to set up a new connection. > Switching over to using NullDB on an existing project of any sizable > size is going to be large task IMO. On my last project we started > using NullDB by default and the result has been very worthwhile and > noticeable. In this project DB connectivity was the exception, not > the norm (even on our model specs) and so that is why I created a > module that would turn on the DB temporarily. In your case the > opposite approach may be needed. > > Going back to the problem at hand... Based on the email you are > using a module like this: > unless Object.const_defined?(:NeedsDatabase) > share_as :NeedsDatabase do > > before :all do > ActiveRecord::Base.establish_connection(:test) > end > > after :all do > ActiveRecord::Base.establish_connection(:adapter => :nulldb) > end > end > end > > Since you are including this on all of your model specs (and more) > you are incurring the setup and teardown cost of the DB connection > repeatedly. Like I said, you may want to adopt the opposite policy > of turning it off temporarily... You could also make the the > changing smarter by only changing it when you need to.. something > like: > > share_as :NeedsDatabase do > before :all do > ActiveRecord::Base.establish_connection(:test) if > ActiveRecord::Base.connection.class.to_s =~ /NullDB/ > end > end > share_as :DontNeedDatabase do > before :all do > ActiveRecord::Base.establish_connection(:adapter => :nulldb) > unless ActiveRecord::Base.connection.class.to_s =~ /NullDB/ > end > end > > With this approach you would need to specify whether or not to use > the DB for each example group... just a thought. Of course, an even > better solution would be to somehow modify AR to maintain an active > connection to the real DB even when it isn't the active adapter. > > re: the view specs > I wouldn't expect to see too much gain here. The big win for > nullDB is in models IMO. Of course, having it on the view and > controller specs helps prevent accidental DB calls. > > re: the random controller spec failures > I only guess is that you are somehow relying on the DB in your > controller specs. I did this too in my controllers when I called > class methods on models that would get a list from the DB... I can't > really help without seeing any specs though. > > I hope this helps and you can find a suitable policy on how to > manage the connections/adapters. Just ask if you have any other > questions. > > -Ben Thanks Ben. I had a brief look at the AR code and it did appear to be caching the adapters so I'd assumed the changeover wasn't expensive, but it did feel like something like that, so that's probably it. Ho hum. No quick wins for speeding up our specs then! Matt Wynne http://blog.mattwynne.net http://www.songkick.com From ben at benmabey.com Mon Jan 12 16:07:19 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 14:07:19 -0700 Subject: [rspec-users] NullDb makes rake spec take (much) longer In-Reply-To: <616BACD6-0EB0-4A92-8937-8D9C34B6E743@mattwynne.net> References: <3CF2B3E2-176F-4F69-B613-580D4ADBD277@mattwynne.net> <496B7F90.3040007@benmabey.com> <616BACD6-0EB0-4A92-8937-8D9C34B6E743@mattwynne.net> Message-ID: <496BB107.2000604@benmabey.com> On 1/12/09 1:05 PM, Matt Wynne wrote: > > On 12 Jan 2009, at 17:36, Ben Mabey wrote: > >> On 1/12/09 7:09 AM, Matt Wynne wrote: >>> Hi all, >>> >>> We did a spike last week to de-couple our view and controller tests >>> from the database, using NullDb. It didn't go too well. I realise >>> that this plugin isn't part of RSpec, but I thought others on this >>> list might have experiences to share. >>> >>> Here's a summary of my colleague's investigations: >>> >>>> I installed the plugin from >>>> http://github.com/jakehow/nulldb/tree/master >>>> >>>> Changed spec/spec_helper to set >>>> "ActiveRecord::Base.establish_connection(:adapter => :nulldb)" by >>>> default. >>>> >>>> The specs that complained of the lack of db, I included a before(all) >>>> that changed the connection to the test database (include >>>> NeedsDatabase - copied from Ben Mabey's Functional module) >>>> By default, I also included the db for all models (config.include >>>> NeedsDatabase, :type => :model) >>>> >>>> Running spec spec/views with or without nulldb takes about the same >>>> time (a couple of seconds less with nulldb). However, running "rake >>>> spec" with nulldb takes 10 times longer!! >>>> >>>> Another weird thing was that three tests failed in the controllers >>>> (venues and concerts) in a very strange way, even when I included the >>>> NeedsDatabase in the tests that needed it. The weird bit is, when I >>>> run: "spec spec/controllers/venues_controller_spec.rb" it doesn't >>>> fail. But when I run: "spec spec/controllers/users_controller_spec.rb >>>> spec/controllers/venues_controller_spec.rb" It does fail... That is, >>>> the user_controller test is influencing the results of the >>>> venue_controller test! >>>> The same weird behaviour happens in lib/sk/find >>>> >>>> This made me had to include NeedsDatabase for all lib and controllers >>>> tests as well. >>> >>> The barrier for us was the shockingly poor performance of 'rake >>> spec' on the view specs - it really means we just can't use it, and >>> actually only barely improved the performance of the specs at all. >>> >>> I was disappointed that the view specs didn't get any faster. My >>> guess is that stub_model is the problem - as it has to do quite a >>> bit of work to set up the attributes on the models. >>> >>> So, can anyone tell us what we might have been doing wrong? Or did I >>> just have unrealistic expectations of how this might help? >>> >>> 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 >> >> Hey Matt, >> I had similar experiences when I started using NullDB. I think that >> the reason why the overall spec suite runs slow is AR is switching >> from one adapter to another, and in the case of the mysql one it >> probably is relatively expensive to set up a new connection. >> Switching over to using NullDB on an existing project of any sizable >> size is going to be large task IMO. On my last project we started >> using NullDB by default and the result has been very worthwhile and >> noticeable. In this project DB connectivity was the exception, not >> the norm (even on our model specs) and so that is why I created a >> module that would turn on the DB temporarily. In your case the >> opposite approach may be needed. >> >> Going back to the problem at hand... Based on the email you are using >> a module like this: >> unless Object.const_defined?(:NeedsDatabase) >> share_as :NeedsDatabase do >> >> before :all do >> ActiveRecord::Base.establish_connection(:test) >> end >> >> after :all do >> ActiveRecord::Base.establish_connection(:adapter => :nulldb) >> end >> end >> end >> >> Since you are including this on all of your model specs (and more) >> you are incurring the setup and teardown cost of the DB connection >> repeatedly. Like I said, you may want to adopt the opposite policy >> of turning it off temporarily... You could also make the the changing >> smarter by only changing it when you need to.. something like: >> >> share_as :NeedsDatabase do >> before :all do >> ActiveRecord::Base.establish_connection(:test) if >> ActiveRecord::Base.connection.class.to_s =~ /NullDB/ >> end >> end >> share_as :DontNeedDatabase do >> before :all do >> ActiveRecord::Base.establish_connection(:adapter => :nulldb) >> unless ActiveRecord::Base.connection.class.to_s =~ /NullDB/ >> end >> end >> >> With this approach you would need to specify whether or not to use >> the DB for each example group... just a thought. Of course, an even >> better solution would be to somehow modify AR to maintain an active >> connection to the real DB even when it isn't the active adapter. >> >> re: the view specs >> I wouldn't expect to see too much gain here. The big win for nullDB >> is in models IMO. Of course, having it on the view and controller >> specs helps prevent accidental DB calls. >> >> re: the random controller spec failures >> I only guess is that you are somehow relying on the DB in your >> controller specs. I did this too in my controllers when I called >> class methods on models that would get a list from the DB... I can't >> really help without seeing any specs though. >> >> I hope this helps and you can find a suitable policy on how to manage >> the connections/adapters. Just ask if you have any other questions. >> >> -Ben > > Thanks Ben. I had a brief look at the AR code and it did appear to be > caching the adapters so I'd assumed the changeover wasn't expensive, > but it did feel like something like that, so that's probably it. Oh really? Hmm.. well, I never did any real testing to verify my assumption about the the changeover. I just noticed that suites that had to switch adapters a lot ran very slowly. > > Ho hum. No quick wins for speeding up our specs then! Unfortunately not. :( > > > 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 lists at ruby-forum.com Mon Jan 12 16:50:49 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 12 Jan 2009 22:50:49 +0100 Subject: [rspec-users] Help with regexp in matcher Message-ID: This is giving me an error: When /?:(log|sign)?:(i|o)n success message/ do Then "welcome message" end To the effect that: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': ./features/components/login/step_definitions/login_steps.rb:21: invalid regular expression; there's no previous pattern, to which '?' would define cardinality at 1: /?:(am|is) not ?:(logg|sign)ed ?:(i|o)n/ (SyntaxError) ./features/components/login/step_definitions/login_steps.rb:25: invalid regular expression; there's no previous pattern, to which '?' would define cardinality at 1: /?:(log|sign) ??:(i|o)n request message/ ./features/components/login/step_definitions/login_steps.rb:41: invalid regular expression; there's no previous pattern, to which '?' would define cardinality at 1: /?:(log|sign)?:(i|o)n success message/ from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' I would appreciate it very much if someone could tell me what i am doing wrong here. -- Posted via http://www.ruby-forum.com/. From tim at pivotib.com Mon Jan 12 17:35:51 2009 From: tim at pivotib.com (Tim Glen) Date: Mon, 12 Jan 2009 17:35:51 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: > > This is giving me an error: > > When /?:(log|sign)?:(i|o)n success message/ do > Then "welcome message" > end I could be wrong, but I believe you're looking for this instead? When /(?:log|sign)(?:i|o)n success message/ do hope that helps, timg From ben at benmabey.com Mon Jan 12 18:00:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 16:00:16 -0700 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: <496BCB80.1030008@benmabey.com> On 1/12/09 2:50 PM, James Byrne wrote: > This is giving me an error: > > When /?:(log|sign)?:(i|o)n success message/ do > Then "welcome message" > end > The ?: needs to be inside your group if you don't want to capture it... so: When /(?:log|sign)(?:i|o)n success message/ do FWIW, I have found http://www.rubular.com an excellent resource when creating my steps. -Ben > To the effect that: > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require': > ./features/components/login/step_definitions/login_steps.rb:21: invalid > regular expression; there's no previous pattern, to which '?' would > define cardinality at 1: /?:(am|is) not ?:(logg|sign)ed ?:(i|o)n/ > (SyntaxError) > ./features/components/login/step_definitions/login_steps.rb:25: invalid > regular expression; there's no previous pattern, to which '?' would > define cardinality at 1: /?:(log|sign) ??:(i|o)n request message/ > ./features/components/login/step_definitions/login_steps.rb:41: invalid > regular expression; there's no previous pattern, to which '?' would > define cardinality at 1: /?:(log|sign)?:(i|o)n success message/ from > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > > > I would appreciate it very much if someone could tell me what i am doing > wrong here. > From sfeley at gmail.com Mon Jan 12 18:00:33 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 12 Jan 2009 18:00:33 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: <1fb4df0901121500y60862f22h3b31a71352c53329@mail.gmail.com> On Mon, Jan 12, 2009 at 4:50 PM, James Byrne wrote: > > When /?:(log|sign)?:(i|o)n success message/ do > Then "welcome message" > end It's a syntax error on that first question mark, the one right after the slash. A ? in a regex signifies that whatever came just before it may appear 0 or 1 times. Just like a + signifies that whatever came before it _must_ appear 1 or more times, and a * signifies that whatever came before it can appear any number of times. There are a few other things a ? can mean (non-greedy matching, etc.) but they all come *after* something. Not at the beginning of your expression. That's the bug. Beyond that, what you're trying to do with the regex itself seems just a little too clever; do your features or your app messages really vary randomly between the terms "login," "logon," "signin" and "signon," all meaning the same thing? If so, jumping hoops to account for it in the tests might be a hint to change your app language just for clarity. But if you have to have them all, just writing /(login|logon|signin|signon) success message/ would be a lot easier to read and understand. (Final nit, because I'm a smellfungus: what is this step supposed to do, anyway? Do you really have scenarios that include the line "When login success message?" 'When' steps imply action taken by the imaginary user. What's the action here? What's the verb?) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From aslak.hellesoy at gmail.com Mon Jan 12 18:13:22 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 00:13:22 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: Message-ID: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> On Mon, Jan 12, 2009 at 11:35 PM, Tim Glen wrote: > >> This is giving me an error: >> >> When /?:(log|sign)?:(i|o)n success message/ do >> Then "welcome message" >> end >> > > > I could be wrong, but I believe you're looking for this instead? > When /(?:log|sign)(?:i|o)n success message/ do > Actually - it should be: /(?:log|sign) (?:i|o)n success message/ (a space was missing too) http://www.rubular.com Aslak > hope that helps, > timg > > _______________________________________________ > 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 avdi at avdi.org Mon Jan 12 18:20:16 2009 From: avdi at avdi.org (Avdi Grimm) Date: Mon, 12 Jan 2009 18:20:16 -0500 Subject: [rspec-users] Who is using NullDB? Message-ID: I gather from some recent posts that some people are actually using NullDB in their projects. As the creator of NullDB, I'm pleased and a little surprised to hear this. Since NullDB is has received exactly zero attention from me since it's initial release, I'm curious how it's working out for people. Do you use NullDB? If so, do you use my baseline version (http://svn.avdi.org/nulldb/trunk), or are you using a fork? If a fork, which fork, and why? Are there any bugs or feature requests you'd like to see addressed? Thanks, -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com From ben at benmabey.com Mon Jan 12 19:22:29 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 Jan 2009 17:22:29 -0700 Subject: [rspec-users] Who is using NullDB? In-Reply-To: References: Message-ID: <496BDEC5.6010700@benmabey.com> On 1/12/09 4:20 PM, Avdi Grimm wrote: > I gather from some recent posts that some people are actually using > NullDB in their projects. As the creator of NullDB, I'm pleased and a > little surprised to hear this. > > Since NullDB is has received exactly zero attention from me since > it's initial release, I'm curious how it's working out for people. > > Do you use NullDB? > > If so, do you use my baseline version > (http://svn.avdi.org/nulldb/trunk), or are you using a fork? > > If a fork, which fork, and why? > > Are there any bugs or feature requests you'd like to see addressed? > > Thanks, > > Hey Avdi, I love nullDB, so thank you very much for making it! After looking into the various libs that disconnect AR from the DB I decided on nullDB due to it's design decisions. I have been using your SVN version I believe. Although, I may of grabbed it off of github a couple of times since that is easier for me. So my first request would be for you to add it to github so your fork can be the official one. :) GitHub has an import from SVN feature which is really nice and makes it painless to convert a SVN repo. If you do that I would be much more likely to fork it and submit patches. There is one bug I have found that is quite annoying but I haven't looked into fixing it yet. If I remember correctly the bug is something like this: class Band < AR::Base has_many :members end #with nulldb: band = Band.create!(:name => "Foo") bar = Member.create!(:name => "Mr. Bar") band.members << bar band.members # => [] I understand the limitations of nullDB so I don't expect the above call to update the member's band_id. I do however, expect the newly added member to appear in the AR association. What I have found is that for some reason the above will not work when that is the first time the association is being used, but it will otherwise. For example, this workaround works: band = Band.create!(:name => "Foo") bar = Member.create!(:name => "Mr. Bar") band.members.inspect # workaround for odd nullDB bug band.members << bar band.members # => [bar] Does that make sense? Other than that bug, and the problem with the adapter changing slowing things down nullDB has been great. We are getting a lot of benefit from it on our current project. So once again, thanks! -Ben From pergesu at gmail.com Mon Jan 12 19:48:26 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Jan 2009 16:48:26 -0800 Subject: [rspec-users] Persisting Logins and Sessions across scenarios In-Reply-To: <72115b99c30008ef9d8237d9fbd48db9@ruby-forum.com> References: <57c63afe0901120921j71a49306i2d7af4509357589e@mail.gmail.com> <8d961d900901121010k7805ce6fg602a111280477407@mail.gmail.com> <1fb4df0901121129p5e634d05v48e290781abdec6a@mail.gmail.com> <72115b99c30008ef9d8237d9fbd48db9@ruby-forum.com> Message-ID: <810a540e0901121648k5e612b8ar7b56f20a0caeb0c5@mail.gmail.com> On Mon, Jan 12, 2009 at 11:49 AM, James Byrne wrote: > Stephen Eley wrote: > >> >> On acceptance testing, I'd favor going through the actual session >> creation logic instead of mocking it, even if you don't put an >> explicit "Given" every time. Yeah, it's slower. But acceptance tests >> aren't _supposed_ to be fast; they're supposed to demonstrate real >> usage, and be the last line of defense between your app and the big >> bad world. They're going to be slow with or without login each time. >> And if there is some unseen routing or filtering bug in some >> controller's session access that doesn't show up in your test because >> you skipped past all that, and you lose a day and some hair trying to >> figure it out, you're going to wonder whether the seconds you saved >> were worth it. > > Ok, Ok, Ok... It is no big deal to login in every time. If that is the > way it should be done in general then I have learned enough these past > weeks that I will go with the flow and save myself some headaches. > > Thanks for the pointers and the explanations. I feel much more > comfortable about doing the login in each scenario now that I understand > the reasons. Well you can inject it right into the session instead of doing the full webrat thing. That'll definitely cut down on the time it takes. btw, I know it seems like you want this stuff to persist between scenarios, but you really don't. You want to ensure that the world is in a known state before the test run, so that your tests are repeatable and reliable. Getting it into a known state requires two steps, basically (1) get to a base state that works for EVERY SINGLE TEST. This basically means an empty database, potentially populated with some seed data (like if you store references to zip codes in the db) (2) at the beginning of each test, modify the state to suit that test. You should be changing only the state that you need to write an expressive test, and no more If you need to reuse logic, take advantage of one of the existing reuse patterns. In cucumber's case, that means extracting code to a step and calling that in the scenarios. With RSpec, you've got a bit more stuff like nested groups with a before block (which imo is NOT a good idea for cucumber, nesting scenarios would be insane). What you're asking about is implicit coupling, and that's not an effective reuse pattern :) Pat From pergesu at gmail.com Mon Jan 12 19:52:33 2009 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 12 Jan 2009 16:52:33 -0800 Subject: [rspec-users] Who is using NullDB? In-Reply-To: References: Message-ID: <810a540e0901121652o3dec150doc1cea9650a024332@mail.gmail.com> On Mon, Jan 12, 2009 at 3:20 PM, Avdi Grimm wrote: > I gather from some recent posts that some people are actually using > NullDB in their projects. As the creator of NullDB, I'm pleased and a > little surprised to hear this. > > Since NullDB is has received exactly zero attention from me since > it's initial release, I'm curious how it's working out for people. > > Do you use NullDB? > > If so, do you use my baseline version > (http://svn.avdi.org/nulldb/trunk), or are you using a fork? > > If a fork, which fork, and why? > > Are there any bugs or feature requests you'd like to see addressed? Out of curiosity, how much faster is nulldb than using sqlite in-memory? Pat From lists at ruby-forum.com Tue Jan 13 10:41:47 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 16:41:47 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> Message-ID: Thanks for all the advise and corrections. I ended up with this: When /\bsee a (?:log|sign)(?: ?)[io]n success message/ do # login | log in | logon | log on | signin ... Then "see the login ok message" end As to the issue of whether this is being too clever by half: Perhaps. I have to consider though, that various people are going to be working on features relating to this project under a wide range of circumstances and that features will develop over a long period of time. While it might appear attractive to simply insist that a session is always a login the fact is that language is not so precise; login, logon, log in, log on, signin, signon, sign in and sign on are all common synonyms for the same action. Internally, the action is just login. Logins are a pervasive feature of this application and so, rather than waste effort on policing the feature syntax, I thought it best just to accommodate the likely variations from the start. Admittedly, I also availed myself of this opportunity to gain additional knowledge regarding regexp and so this example is perhaps overwrought for the actual purpose at hand. Finally, thank you Ben very much for the reference to http://www.rubular.com -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 11:58:57 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Tue, 13 Jan 2009 17:58:57 +0100 Subject: [rspec-users] Cucumber newbie gets Webrat::Se ssion (LoadError) Message-ID: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> Just trying to get cucumber/webrat going and so after following the installation process here http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails i wrote a quick feature and when I rake features, I get the following in the console: c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/acti ve_support/dependencies.rb:262:in `load_missing_constant': Expected c:/projects/ classroomparent/vendor/plugins/webrat/lib/webrat/session.rb to define Webrat::Se ssion (LoadError) Failed to load features/support/env.rb from c:/InstantRails-2.0-win/ruby/lib/ru by/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:468:in ` const_missing' from c:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/aslakhellesoy-w ebrat-0.3.2.2/lib/webrat/rails.rb:7 I have the following related gems installed: aslakhellesoy-webrat (0.3.2.2) cucumber (0.1.14) webrat (0.3.4) Any advice you can give would be greatly appreciated. Tom -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Tue Jan 13 12:14:48 2009 From: mark at mwilden.com (Mark Wilden) Date: Tue, 13 Jan 2009 09:14:48 -0800 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> Message-ID: <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> On Tue, Jan 13, 2009 at 7:41 AM, James Byrne wrote: > > Logins are a pervasive feature of this application and so, rather than > waste effort on policing the feature syntax, I thought it best just to > accommodate the likely variations from the start. Premature flexibility is one of the roots of all evil. :) Seriously, your code has two types of users. Yes, you should make writing features easier for biz, but you should also make reading steps easier for dev. Given that, I like the suggestion of explicitly enumerating the choices of verbiage. A clear pointer toward that choice is the comment. A comment is an apology for unclear code. All unclear code should be commented, but unclear code should be avoided whenever possible. All IMO, of course. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Jan 13 12:22:36 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 18:22:36 +0100 Subject: [rspec-users] Cucumber newbie gets Webrat::Se ssion (LoadError) In-Reply-To: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> References: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> Message-ID: <11c89e4023b965fe962259bcf89fd64e@ruby-forum.com> Tom Hoen wrote: > > Any advice you can give would be greatly appreciated. > > Tom What are the contents of features/support/env.rb? Do you have something like this in there? # If webrat is a gem then uncomment this require 'webrat' if !defined?(Webrat) # If webrat is a plugin then uncomment this #require 'webrat/rails' -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 12:36:46 2009 From: lists at ruby-forum.com (Tom Hoen) Date: Tue, 13 Jan 2009 18:36:46 +0100 Subject: [rspec-users] Cucumber newbie gets Webrat::Se ssion (LoadError) In-Reply-To: <11c89e4023b965fe962259bcf89fd64e@ruby-forum.com> References: <8e9d69e10a4689bf4f4145ef2eeeeb41@ruby-forum.com> <11c89e4023b965fe962259bcf89fd64e@ruby-forum.com> Message-ID: James Byrne wrote: > > What are the contents of features/support/env.rb? Do you have something > like this in there? > > # If webrat is a gem then uncomment this > require 'webrat' if !defined?(Webrat) > > # If webrat is a plugin then uncomment this > #require 'webrat/rails' Though there isn't the comment, I do have the line: require 'webrat/rails' I changed it to the other require statement and now I get 0 scenarios. So I am getting closer. Thanks for your help. Tom -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue Jan 13 12:55:07 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 13 Jan 2009 17:55:07 +0000 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> Message-ID: <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> On 13 Jan 2009, at 17:14, Mark Wilden wrote: > On Tue, Jan 13, 2009 at 7:41 AM, James Byrne > wrote: > > Logins are a pervasive feature of this application and so, rather than > waste effort on policing the feature syntax, I thought it best just to > accommodate the likely variations from the start. > > Premature flexibility is one of the roots of all evil. :) > > Seriously, your code has two types of users. Yes, you should make > writing features easier for biz, but you should also make reading > steps easier for dev. Given that, I like the suggestion of > explicitly enumerating the choices of verbiage. A clear pointer > toward that choice is the comment. A comment is an apology for > unclear code. All unclear code should be commented, but unclear code > should be avoided whenever possible. > > All IMO, of course. +1 to all that. I feel like you get lectured quite a bit by this list James, but you'd do well to heed the advice of some battle-hardened journeymen, IMO. Read Eric Evans' excellent book 'Domain Driven Design', which actually inspired a lot of this BDD stuff you're using, to hear how keeping faithful to a 'Ubiquitous Language' can make a big difference to the success or failure of a project. You're not just policing syntax when you encourage people to use the same words for things, you're actually protecting the integrity of your system by reducing the opportunities for misunderstanding. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Tue Jan 13 12:57:03 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 18:57:03 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> Message-ID: <8d961d900901130957t507d260dm4821ebd09565dd12@mail.gmail.com> On Tue, Jan 13, 2009 at 6:14 PM, Mark Wilden wrote: > On Tue, Jan 13, 2009 at 7:41 AM, James Byrne wrote: > >> >> Logins are a pervasive feature of this application and so, rather than >> waste effort on policing the feature syntax, I thought it best just to >> accommodate the likely variations from the start. > > > Premature flexibility is one of the roots of all evil. :) > > Seriously, your code has two types of users. Yes, you should make writing > features easier for biz, but you should also make reading steps easier for > dev. Given that, I like the suggestion of explicitly enumerating the choices > of verbiage. A clear pointer toward that choice is the comment. A comment is > an apology for unclear code. All unclear code should be commented, but > unclear code should be avoided whenever possible. > Another principle that calls for a more rigid Regex: http://domaindrivendesign.org/discussion/messageboardarchive/UbiquitousLanguage.html. Everybody should speak the same language and know what it means. Having 4 different ways of saying the same thing will just add to confusion. Aslak > > All IMO, of course. > > ///ark > > > > _______________________________________________ > 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 aidy.lewis at googlemail.com Tue Jan 13 13:02:45 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 13 Jan 2009 18:02:45 +0000 Subject: [rspec-users] [Cucumber] - default rake task Message-ID: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> Hi, I have a Rake problem. I would like the default task to run after :features. Curently it doesn't when :features fails. Could you please help? require 'cucumber/rake/task' def send_dcs_email_report(path_to_story_results) ### end Cucumber::Rake::Task.new("features", "All features in IE") do |t| t.cucumber_opts = "--format html --out story-results.html" end task :default => :features do path_to_story_results = File.expand_path(File.dirname(".")).gsub("/", "\\") + "\\story-results.html" send_dcs_email_report(path_to_story_results) end Thanks Aidy From matt at mattwynne.net Tue Jan 13 13:09:37 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 13 Jan 2009 18:09:37 +0000 Subject: [rspec-users] [Cucumber] - default rake task In-Reply-To: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> References: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> Message-ID: <4AFD416C-6ED7-4A24-9272-9915D5FE7A11@mattwynne.net> On 13 Jan 2009, at 18:02, aidy lewis wrote: > Hi, > > I have a Rake problem. > > I would like the default task to run after :features. > > Curently it doesn't when :features fails. Could you please help? > > > > require 'cucumber/rake/task' > > def send_dcs_email_report(path_to_story_results) > ### > end > > Cucumber::Rake::Task.new("features", "All features in IE") do |t| > t.cucumber_opts = "--format html --out story-results.html" > end > > task :default => :features do > path_to_story_results = > File.expand_path(File.dirname(".")).gsub("/", "\\") + > "\\story-results.html" > send_dcs_email_report(path_to_story_results) > end > > > Thanks > > Aidy You could do something like this: task :default do begin Rake::Task[:features].invoke ensure path_to_story_results = File.expand_path(File.dirname(".")).gsub("/", "\\") + "\\story- results.html" send_dcs_email_report(path_to_story_results) end end does that work? > > _______________________________________________ > 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 sfeley at gmail.com Tue Jan 13 13:18:13 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 13 Jan 2009 13:18:13 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> Message-ID: <1fb4df0901131018y75c8e0b0gd14022ce0c35f295@mail.gmail.com> On Tue, Jan 13, 2009 at 10:41 AM, James Byrne wrote: > > Logins are a pervasive feature of this application Which is exactly why you should standardize. If you try to be accommodating toward unclear communication, you're just going to create confusion when people need to get things done. Someone won't remember whether the action is named "login" or "signin" or "sign_on" and will waste time looking for the wrong thing -- or worse, write the same function over again under a different name. That's not the fault of the feature, but it doesn't _help._ This step doesn't do as much as it could to accurately document your application. > and so, rather than > waste effort on policing the feature syntax, I thought it best just to > accommodate the likely variations from the start. Well, first, if that was _really_ your goal you're not going nearly far enough. If a teammate isn't going to take the trouble to review existing steps, he's probably more likely to screw up the "success message" part than the "login" part. How many variations on the concept of "success message" do you think you can fit in a regex? ("acknowledgement" and "acceptance" both start with "ac," so I guess you could start your conditional branching logic there... Just remember that the number of e's in "acknowledgment" can vary...) Beyond that, though... It's really not a problem. Issues like this tend to be self-correcting. Most developers (well, most competent and properly lazy ones) will read the existing features before writing their own. They'll know that if they saw a clause already that does something they want, they should use it again. And if they misremember and type something else, they'll get a failure and think, "Whathuh? James got his features to work yesterday and HE needs to log in!" And *then* they'll think to look back at the step code, see one called 'When "I see a success message"," and figure out what they really ought to say. In looking it up, they'll come to understand the existing functionality better. And they'd certainly be able to look it up in less time than it takes to figure out all the regexes. (Or me to be a smartass about them. Hmm.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From aslak.hellesoy at gmail.com Tue Jan 13 13:28:44 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 19:28:44 +0100 Subject: [rspec-users] [Cucumber] - default rake task In-Reply-To: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> References: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> Message-ID: <8d961d900901131028u42526c3t138ac1625bddb69f@mail.gmail.com> On Tue, Jan 13, 2009 at 7:02 PM, aidy lewis wrote: > Hi, > > I have a Rake problem. > > I would like the default task to run after :features. > > Curently it doesn't when :features fails. Could you please help? > > > > require 'cucumber/rake/task' > > def send_dcs_email_report(path_to_story_results) > ### > end > > Cucumber::Rake::Task.new("features", "All features in IE") do |t| > t.cucumber_opts = "--format html --out story-results.html" > end > > task :default => :features do > path_to_story_results = > File.expand_path(File.dirname(".")).gsub("/", "\\") + > "\\story-results.html" > send_dcs_email_report(path_to_story_results) > end > > Rake immediately stops when a task fails. I'm assuming you're using some sort of CI since you're sending emails. I'd make the CI send email instead of Rake. Aslak > Thanks > > Aidy > _______________________________________________ > 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 aidy.lewis at googlemail.com Tue Jan 13 13:43:50 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 13 Jan 2009 18:43:50 +0000 Subject: [rspec-users] [Cucumber] - default rake task In-Reply-To: <4AFD416C-6ED7-4A24-9272-9915D5FE7A11@mattwynne.net> References: <7ac2300c0901131002r48a77635nf5daababc7e77415@mail.gmail.com> <4AFD416C-6ED7-4A24-9272-9915D5FE7A11@mattwynne.net> Message-ID: <7ac2300c0901131043v49d20fd8idef238d92103766@mail.gmail.com> On 13/01/2009, Matt Wynne wrote: > > On 13 Jan 2009, at 18:02, aidy lewis wrote: > > > > Hi, > > > > I have a Rake problem. > > > > I would like the default task to run after :features. > > > > Curently it doesn't when :features fails. Could you please help? > > > > > > > > require 'cucumber/rake/task' > > > > def send_dcs_email_report(path_to_story_results) > > ### > > end > > > > Cucumber::Rake::Task.new("features", "All features in > IE") do |t| > > t.cucumber_opts = "--format html --out story-results.html" > > end > > > > task :default => :features do > > path_to_story_results = > > File.expand_path(File.dirname(".")).gsub("/", "\\") + > > "\\story-results.html" > > send_dcs_email_report(path_to_story_results) > > end > > > > > > Thanks > > > > Aidy > > > > You could do something like this: > > task :default do > begin > Rake::Task[:features].invoke > ensure > path_to_story_results = > File.expand_path(File.dirname(".")).gsub("/", "\\") + > "\\story-results.html" > send_dcs_email_report(path_to_story_results) > end > end > > does that work? > Like a dream Matt. Thanks Aidy From zach.dennis at gmail.com Tue Jan 13 14:57:33 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 13 Jan 2009 14:57:33 -0500 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> Message-ID: <85d99afe0901131157l3972a2dfsdd019dbf8f4caa05@mail.gmail.com> On Tue, Jan 13, 2009 at 12:55 PM, Matt Wynne wrote: > > On 13 Jan 2009, at 17:14, Mark Wilden wrote: > >> On Tue, Jan 13, 2009 at 7:41 AM, James Byrne wrote: >> >> Logins are a pervasive feature of this application and so, rather than >> waste effort on policing the feature syntax, I thought it best just to >> accommodate the likely variations from the start. >> >> Premature flexibility is one of the roots of all evil. :) >> >> Seriously, your code has two types of users. Yes, you should make writing >> features easier for biz, but you should also make reading steps easier for >> dev. Given that, I like the suggestion of explicitly enumerating the choices >> of verbiage. A clear pointer toward that choice is the comment. A comment is >> an apology for unclear code. All unclear code should be commented, but >> unclear code should be avoided whenever possible. >> >> All IMO, of course. > > +1 to all that. I feel like you get lectured quite a bit by this list James, > but you'd do well to heed the advice of some battle-hardened journeymen, > IMO. > > Read Eric Evans' excellent book 'Domain Driven Design', which actually > inspired a lot of this BDD stuff you're using, to hear how keeping faithful > to a 'Ubiquitous Language' can make a big difference to the success or > failure of a project. > > You're not just policing syntax when you encourage people to use the same > words for things, you're actually protecting the integrity of your system by > reducing the opportunities for misunderstanding. This last paragraph was beautifully said Matt. I am going to steal it (and give you credit of course). :) -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Tue Jan 13 15:10:38 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 21:10:38 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <1fb4df0901131018y75c8e0b0gd14022ce0c35f295@mail.gmail.com> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <1fb4df0901131018y75c8e0b0gd14022ce0c35f295@mail.gmail.com> Message-ID: <52d4f64441439d3a88eabb5f3097a72a@ruby-forum.com> Stephen Eley wrote: > On Tue, Jan 13, 2009 at 10:41 AM, James Byrne > wrote: >> >> Logins are a pervasive feature of this application > > Which is exactly why you should standardize. If you try to be > accommodating toward unclear communication, you're just going to > create confusion when people need to get things done. I appreciate the advice and accept the wisdom that it contains. I have no intention of handling with a regexp every situation where there might be more than one English expression available to express a concept. Nor do I intend to otherwise permit multiplicities of expression to exist. However, on the matter of log in versus log on and its common variations, I think I will stick with my initial instinct. Initially I provided the different variants of login matchers along the lines shown below: When /see a login success message/ do have_selector("#login_current") end When /see a log in success message/ do Then "see a login success message" end When /see a sign on success message/ do ... The revised regexp version simply puts all of these together in one place for me. As for forcing people to remember that it is login and not logon; well this project does not exist in a vacuum. The people involved deal with at least three different operating systems every day, each one of which has its own dialect with respect to what constitutes an authenticated user. I will accept a little flexibility of expression here in the service of user comfort. In any case the term login, in the context of a web application environment, seems a bit of a misnomer from the outset. I cannot get too worked up over the idea of unclear communication when one is dealing with as muddy a concept as that represented by login. Really, what I should be saying is: Given user "myuser" has a current authenticated session And I see the session authenticated message When I terminate my current session Then the current session is destroyed And I should see the user authentication request message However, current authenticated session tends to be a little unwieldy in casual speech. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 15:14:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 21:14:59 +0100 Subject: [rspec-users] Help with regexp in matcher In-Reply-To: <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> References: <8d961d900901121513j53c9fde6y543b67da15461551@mail.gmail.com> <3c30da400901130914j2cad5037v4ba20a4ce63c45e@mail.gmail.com> <334671B0-6515-40A1-BF05-50216FCFFC80@mattwynne.net> Message-ID: <28a4671751bfc33aa81ce945dd1cbb6e@ruby-forum.com> Matt Wynne wrote: . > > +1 to all that. I feel like you get lectured quite a bit by this list > James, but you'd do well to heed the advice of some battle-hardened > journeymen, IMO. > > I do hope that I do not give the impression that I resent anything that anyone has written in response to my many inquiries. I have been enlightened on a number of things that I was either unaware of or only dimly perceived. I am transitioning from a completely different environment and need all the help and guidance I can obtain. I value this and the ruby-on-rails list very much for that reason. Regards, -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Jan 13 16:11:32 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 13 Jan 2009 22:11:32 +0100 Subject: [rspec-users] Using has_selector to identify responses. Message-ID: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> This is more of a "best practices" question. Earlier, when I was trying to understand what it was I was supposed to be testing with cucumber, I was advised that I should test for text elements contained in the response body of the expected output. Now, what I am wondering is how one accounts for multilingual implementation. I have hit upon the idea of simply adding special css id selectors to the templates that identify their use. So, for example, instead of looking for the word "Registration" I would look for a css selector id=user_registration. I know that this will work but, is there another, preferred, way of handling this situation? Regards, -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Jan 13 16:50:10 2009 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 13 Jan 2009 13:50:10 -0800 Subject: [rspec-users] Using has_selector to identify responses. In-Reply-To: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> References: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> Message-ID: <810a540e0901131350i762e6519o10f11a063aa7684e@mail.gmail.com> On Tue, Jan 13, 2009 at 1:11 PM, James Byrne wrote: > This is more of a "best practices" question. > > Earlier, when I was trying to understand what it was I was supposed to > be testing with cucumber, I was advised that I should test for text > elements contained in the response body of the expected output. Now, > what I am wondering is how one accounts for multilingual implementation. > > I have hit upon the idea of simply adding special css id selectors to > the templates that identify their use. So, for example, instead of > looking for the word "Registration" I would look for a css selector > id=user_registration. > > I know that this will work but, is there another, preferred, way of > handling this situation? > > Regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > semantic markup ftw (so, yes, your way :) From aslak.hellesoy at gmail.com Tue Jan 13 16:58:15 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Jan 2009 22:58:15 +0100 Subject: [rspec-users] Using has_selector to identify responses. In-Reply-To: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> References: <658ff9594560a0d5fa8526b54b024da5@ruby-forum.com> Message-ID: <8d961d900901131358r3ac7ef6fya4b79e8f76b37dbf@mail.gmail.com> On Tue, Jan 13, 2009 at 10:11 PM, James Byrne wrote: > This is more of a "best practices" question. > I'll describe a practice that has worked well for me. (I stopped believing in best practices several years ago :-)) > Earlier, when I was trying to understand what it was I was supposed to > be testing with cucumber, I was advised that I should test for text > elements contained in the response body of the expected output. Now, > what I am wondering is how one accounts for multilingual implementation. > > I have hit upon the idea of simply adding special css id selectors to > the templates that identify their use. So, for example, instead of > looking for the word "Registration" I would look for a css selector > id=user_registration. > > I know that this will work but, is there another, preferred, way of > handling this situation? > I'm developing a multilingual app now. Based on the user's preferences it will display UI elements (text, links etc) in either Norwegian, Nynorsk (Neo Norwegian) or** S?mi (the 3 official languages in Norway). We use Webrat, and for the Cucumber Scenarios we have chosen one arbitrary language - Norwegian. (Actually, it's not that arbitrary - it's what all the developers speak and write). In order to make the scenarios readable for the stakeholders we prefer to refer to use the visible text instead of the DOM id or names. (This also verifies that the
Short Name
<%=h entity.entity_name.titlecase -%><%= "%06d" % entity.id -%> <%= link_to 'Show Entity', entity -%> <%= link_to 'Edit Entity', edit_entity_path(entity) -%> <%= link_to 'Destroy Entity', entity, :confirm => 'Are you sure?', :method => :delete -%>
<%=h entity.entity_name.titlecase -%> <%=h entity.entity_legal_form -%> <%= "%06d" % entity.id -%> <%= link_to 'Show Entity', entity -%> <%= link_to 'Edit Entity', edit_entity_path(entity) -%> <%= link_to 'Destroy Entity', entity, :confirm => 'Are you sure?', :method => :delete -%>
Just An Entity 000001 Show Entity Edit Entity Destroy Entity
This Is a Bare Entity
\n\n
\n\n
New user\n\n\n\r\n\r\n ... So, I am nonplussed by the report that it did not find what was present. -- Posted via http://www.ruby-forum.com/. From jim at saturnflyer.com Mon Jan 19 14:22:32 2009 From: jim at saturnflyer.com (Jim Gay) Date: Mon, 19 Jan 2009 14:22:32 -0500 Subject: [rspec-users] [RSpec] matcher for href In-Reply-To: References: Message-ID: <9D008F8E-6B3F-40C8-9A84-B8E3A2DB4ACD@saturnflyer.com> On Jan 19, 2009, at 2:11 PM, James Byrne wrote: > Of the several ways available to test for this, what would be the > preferred way to see if the following is present in an html document > WITHOUT actually following the link? > > response.should have_tag('a[href=?]','/users/new') > I tried this: > > response.body.should have_text('href="/users/new"') Or response.should include_text('href="/users/new"') have_text should be used "when you want to match the whole string or whole body" include_text should be used "when you either don?t know or don?t care where on the page this text appears." http://rspec.rubyforge.org/rspec-rails/1.1.12/ > > > But this test fails, even though the rake features report is this: > > expected "href=\"/users/new\"", got ... > > ... \n\n\n\n
\n\n
New > user\n\n\n\r\n\r\n ... > > So, I am nonplussed by the report that it did not find what was > present. From jarkko at jlaine.net Mon Jan 19 14:26:51 2009 From: jarkko at jlaine.net (Jarkko Laine) Date: Mon, 19 Jan 2009 21:26:51 +0200 Subject: [rspec-users] [RSpec] matcher for href In-Reply-To: References: Message-ID: <126B70EA-9ADE-4B47-BB02-58C13E721FE0@jlaine.net> On 19.1.2009, at 21.11, James Byrne wrote: > Of the several ways available to test for this, what would be the > preferred way to see if the following is present in an html document > WITHOUT actually following the link? > > > > I tried this: > > response.body.should have_text('href="/users/new"') response.should have_tag("a[href=/users/new]") http://rspec.rubyforge.org/rspec-rails/1.1.12/classes/Spec/Rails/Matchers.html#M000071 //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://odesign.fi Check out my latest book, Unobtrusive Prototype, fresh off the Peepcode oven: http://peepcode.com/products/unobtrusive-prototype-js From matt at mattwynne.net Mon Jan 19 14:45:07 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 19 Jan 2009 19:45:07 +0000 Subject: [rspec-users] [Rails, RSpec] The config.gem rake task chicken and egg thing Message-ID: <4C6D6798-DB86-46AD-90EB-E4A8D17777F0@mattwynne.net> Sorry folks, because I know this has been asked before but I don't remember anyone giving enough detail for me to sort this out the way I want to. How do I change my rake tasks to silently fail if they can't require rspec? I can do this: begin require 'spec/rake/spectask' ... the whole Rake task ... rescue LoadError puts "Unable to load RSpec - do you need to install the gem?" end ... but that seems insane to have to indent all the code inside that big begin / rescue block. I'm sure there's a way to exit the script without causing the whole rake loading chain to fail, but what is it? I tried 'exit 0' but that seems to exit the whole process. So I guess this is more a Ruby question than an RSpec question really, but I'm sure a good answer will help a few other people out too. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Jan 19 14:46:12 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 19 Jan 2009 20:46:12 +0100 Subject: [rspec-users] [RSpec] matcher for href In-Reply-To: References: Message-ID: James Byrne wrote: > Of the several ways available to test for this, what would be the > preferred way to see if the following is present in an html document > WITHOUT actually following the link? Apparently this is the correct form: response.body.should have_tag("a[href=/users/new]") -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Mon Jan 19 15:03:06 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 19 Jan 2009 15:03:06 -0500 Subject: [rspec-users] [Rails, RSpec] The config.gem rake task chicken and egg thing In-Reply-To: <4C6D6798-DB86-46AD-90EB-E4A8D17777F0@mattwynne.net> References: <4C6D6798-DB86-46AD-90EB-E4A8D17777F0@mattwynne.net> Message-ID: <4974DC7A.20406@railsnewbie.com> Matt Wynne wrote: > Sorry folks, because I know this has been asked before but I don't > remember anyone giving enough detail for me to sort this out the way I > want to. > > How do I change my rake tasks to silently fail if they can't require > rspec? > > I can do this: > > begin > require 'spec/rake/spectask' > > ... the whole Rake task ... > > rescue LoadError > puts "Unable to load RSpec - do you need to install the gem?" > end > > > ... but that seems insane to have to indent all the code inside that > big begin / rescue block. I'm sure there's a way to exit the script > without causing the whole rake loading chain to fail, but what is it? > I tried 'exit 0' but that seems to exit the whole process. > > So I guess this is more a Ruby question than an RSpec question really, > but I'm sure a good answer will help a few other people out too. > I suppose you could override describe: begin require 'spec/rake/spectask' rescue LoadError Kernel.warn "Unable to load RSpec - do you need to install the gem?" class << self def describe(*args) # do nothing end end end Scott From scott at railsnewbie.com Mon Jan 19 15:05:14 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 19 Jan 2009 15:05:14 -0500 Subject: [rspec-users] gem installation issues Message-ID: <4974DCFA.1020606@railsnewbie.com> I'm getting the following error when trying to install rspec: scott-taylors-macbook-pro:dl_forms(specs) smt$ sudo gem install rspec Password: ERROR: Error installing rspec: invalid gem format for /usr/local/ruby_versions/1_8_6/lib/ruby/gems/1.8/cache/rspec-1.1.12.gem Are the gems no longer hosted at rubyforge? Scott From matt at mattwynne.net Mon Jan 19 15:38:16 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 19 Jan 2009 20:38:16 +0000 Subject: [rspec-users] Rake features:rcov question In-Reply-To: <36f9f6ee64f54277dc64efd8926857de@ruby-forum.com> References: <36f9f6ee64f54277dc64efd8926857de@ruby-forum.com> Message-ID: On 19 Jan 2009, at 15:49, James Byrne wrote: > I have reached a point where I thought that it might be useful to see > how must test coverage I have for the code I have written. However, > running rake features:rcov produces some unexpected output. I see > this > in the index file: > > > /usr/lib/ruby/1.8/base64.rb ... > /usr/lib/ruby/1.8/benchmark.rb ... > ... > /usr/lib/ruby/1.8/uri/mailto.rb > > Then my files are reported > > app/controllers/application_controller.rb > app/controllers/clients_controller.rb > ... > and so forth. Now, I have checked the spec and test directory trees > and there does not seem to be anything in there that I recognize as > having anything to do with the ruby libraries. My questions are: 1. > Is > this normal behaviour for rcov? 2. If not, then what might I have done > to cause this? > > Regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Take a look at the --exclude option for rcov - that's what you need to do. Otherwise by default it will tell you about coverage for every ruby file that was touched during the test run, including things that the testing framework called, and the things they called, etc. I would have assumed this was in the default rake task that was generated, but anyway you should be able to figure it out if you look at rcov's options. Running rcov yourself really isn't such a black art - from the command line you can get coverage from a single feature using this: rcov --exclude 'gems/*.rb' /usr/local/bin/cucumber -- path/to/ the.feature Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Jan 19 15:38:27 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 19 Jan 2009 21:38:27 +0100 Subject: [rspec-users] [Cucumber] code stats Message-ID: Rspec provides a stats task for rake. However, it does not reference cucumber step definitions, possibly because these are not easily categorized into the MVC etc. test classifications that the rspec task uses. Is extending the rake stats task to encompass cucumber step definitions possible? If so, is it worth doing? -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Mon Jan 19 16:31:13 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 19 Jan 2009 21:31:13 +0000 Subject: [rspec-users] [Cucumber] Scenario Outlines Output Insufficient In-Reply-To: <8b05c7eb1196f3a832b1da5c95bc9e5f@ruby-forum.com> References: <88fd8ddc0901162008r2f89997co1844f258c52bb5fe@mail.gmail.com> <8d961d900901170520y3d8e2913r2e96a35781fe96f6@mail.gmail.com> <88fd8ddc0901180801k1612eb48m1cb77894530494fe@mail.gmail.com> <49736E96.40408@josephwilk.net> <88fd8ddc0901181136t55509a31mbbecab481676b9cc@mail.gmail.com> <8b05c7eb1196f3a832b1da5c95bc9e5f@ruby-forum.com> Message-ID: <88fd8ddc0901191331h45bdc64dr53ab25d2adac058a@mail.gmail.com> Comments below 2009/1/19 Joseph Wilk > Andrew Premdas wrote: > > You misunderstood I bit of my post, I've nested a comment. Its towards > > the > > end of the post. > > > > 2009/1/18 Joseph Wilk > > > >> Scenario Outline: viewing resources # > >> features/admin/poop.feature:11 > >> > >> -- > >> features/step_definitions/general.rb:1 > >> When I follow resource # > >> |product | > >> > http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/163-hidden-pending-status-with-output-when-using-scenario-outlines > >> And there are 4 > >> > >> > >> keen on this solution as I would like to preserve the way the scenarios > are > >> defined (in the feature file) with the way that they are outputted. > >> > >> > >> > >> And there are 4 category # > >> features/admin/poop.feature:8 > >> And there are 4 product # > >> features/step_definitions/product.rb:1 > >> > > > > No you've misunderstood me. I meant the outline step is colored with the > > worst result. Then the details of each run of the step are nested inside > > the > > outline step showing the output for each resource (entry in the table) > > Would you expect to still see the scenario table with status colours? > Yes it feels that the table would still be useful in this situation to guide you back to the nested output to look for things > Do you think it might become difficult to workout which steps are for > which run? > i.e the 5th indented Step broke so lets read through and find each 5th > step to see what the run did. > Hopefully because the nested output contains the expanded template variable the navigation will be OK. The idea was that the nesting would only happen when there was variation i.e. a different matcher in the first example or a different result in the second. If you showed the nesting for every step regardless then yes I think things could get pretty confusing. I haven't really thought about what happens with errors yet. For example if you have five things in your table and they all fail generating a massive output stack. Would you really want to see five output stacks? > It does sound like an interesting idea. Would you mind adding the full > output you would expect with this indentation in the ticket please? (If > you want colour as a html attachment). > I will do this, but let me think about it a little more > > Thanks, > Your welcome > -- > Joseph Wilk > http://blog.josephwilk.net > > -- > 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 aslak.hellesoy at gmail.com Mon Jan 19 16:31:44 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 19 Jan 2009 22:31:44 +0100 Subject: [rspec-users] [Cucumber] code stats In-Reply-To: References: Message-ID: <8d961d900901191331j1411f8bem23a17fa9665ca081@mail.gmail.com> On Mon, Jan 19, 2009 at 9:38 PM, James Byrne wrote: > Rspec provides a stats task for rake. However, it does not reference > cucumber step definitions, possibly because these are not easily > categorized into the MVC etc. test classifications that the rspec task > uses. > > Is extending the rake stats task to encompass cucumber step definitions > possible? If so, is it worth doing? I haven't thought about it. I can't think of any valuable knowledge I'd get from 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 > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Mon Jan 19 17:14:18 2009 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 19 Jan 2009 17:14:18 -0500 Subject: [rspec-users] [RSpec] Message expectations and #dup / #clone Message-ID: <3B5C2E75-64E9-4A45-A5A7-2657A460E645@deadorange.com> Can anyone confirm that message expectations are not copied/duplicated to the new object when using Object#dup or #clone ? Thanks! Nick From zuperinfinite at gmail.com Tue Jan 20 08:44:02 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Tue, 20 Jan 2009 14:44:02 +0100 Subject: [rspec-users] [rspec] Stubbing partials in view specs Message-ID: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> Hey list, As a good BDDer I want to test my views in isolation. And as a good rails programmer, I separate views into partials when needed. So, when testing my views, I want to stub out rendering of partials in my views. I'm working on upgrading an app from rails 2.1.2 to 2.2.2, using the latest rspec and rspec-rails. I used to throw template.stub!(:render) in a before(:each) block and be done with it, but that doesn't work anymore. I can understand why, but now I have to do something like template.stub!(:render).with (hash_including(:partial => anything)). Except for when I'm testing a partial, then I need to replace the anything with every partial I'm rendering in my partial. Is this the correct way, or is there perhaps something like template.stub_partials :only => [], :except => [] ? thanks, bartz From dchelimsky at gmail.com Tue Jan 20 09:29:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 20 Jan 2009 08:29:53 -0600 Subject: [rspec-users] [rspec] Stubbing partials in view specs In-Reply-To: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> References: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> Message-ID: <57c63afe0901200629y1bb6b1e8vf0acaf2f2c7d5a2@mail.gmail.com> On Tue, Jan 20, 2009 at 7:44 AM, Bart Zonneveld wrote: > Hey list, > > As a good BDDer I want to test my views in isolation. Sort of. A *good* BDDer wants to *specify* views in isolation. Testing is for testers :) > And as a good rails > programmer, I separate views into partials when needed. So, when testing my > views, I want to stub out rendering of partials in my views. I'm working on > upgrading an app from rails 2.1.2 to 2.2.2, using the latest rspec and > rspec-rails. > > I used to throw template.stub!(:render) in a before(:each) block and be done > with it That sounds kinda risky because you could be ignoring partials that get rendered that you don't want to be rendered. >, but that doesn't work anymore. I can understand why, but now I have > to do something like template.stub!(:render).with(hash_including(:partial => > anything)). Except for when I'm testing a partial, then I need to replace > the anything with every partial I'm rendering in my partial. > > Is this the correct way, Seems like the only way at the moment. Wouldn't call it correct or incorrect. > or is there perhaps something like > template.stub_partials :only => [], :except => [] ? Nothing like this exists. Seems like a reasonable idea. Feel free to submit a feature request, or better yet, a patch to http://rspec.lighthouseapp.com Cheers, David > > thanks, > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From daniel.vartanov at gmail.com Tue Jan 20 09:45:14 2009 From: daniel.vartanov at gmail.com (Daniel Vartanov) Date: Tue, 20 Jan 2009 14:45:14 +0000 Subject: [rspec-users] [Cucumber, Merb, Webrat] undefined method 'response' for Merb::Test::World::Webrat Message-ID: Hello! I get the following error everytime I try to check the result of previous step (by the way, I use default result_steps.rb): undefined local variable or method `response' for # (NameError) ./features/steps/result_steps.rb:14:in ` /^the (.*) ?request should fail/' features/authentication/login.feature:17:in `/^the (.*) ?request should fail/' It is raised even in a freshly generated merb application (merb-gen app) and freshly generated cucumber files (merb-gen cucumber --session-type webrat). Here are the versions of the installed gems: cucumber (0.1.15) merb (1.0.8) webrat (0.4.0) david-merb_cucumber (0.5.1.2) Where should I search for the source of the problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From zuperinfinite at gmail.com Tue Jan 20 11:35:15 2009 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Tue, 20 Jan 2009 17:35:15 +0100 Subject: [rspec-users] [rspec] Stubbing partials in view specs In-Reply-To: <57c63afe0901200629y1bb6b1e8vf0acaf2f2c7d5a2@mail.gmail.com> References: <71C878F7-574B-4287-8D5B-FAD56FD8AFB5@gmail.com> <57c63afe0901200629y1bb6b1e8vf0acaf2f2c7d5a2@mail.gmail.com> Message-ID: <6E3760F3-15A0-4E25-9E70-7DF948A4C8B2@gmail.com> On 20-jan-2009, at 15:29, David Chelimsky wrote: > On Tue, Jan 20, 2009 at 7:44 AM, Bart Zonneveld > wrote: >> Hey list, >> >> As a good BDDer I want to test my views in isolation. > > Sort of. A *good* BDDer wants to *specify* views in isolation. Testing > is for testers :) You're right! I tend to talk a lot to non-programmers, and they get that glaze-in-the-distance look in their eyes, whenever I mention specifiy, spec'ing, or what have you :). >> And as a good rails >> programmer, I separate views into partials when needed. So, when >> testing my >> views, I want to stub out rendering of partials in my views. I'm >> working on >> upgrading an app from rails 2.1.2 to 2.2.2, using the latest rspec >> and >> rspec-rails. >> >> I used to throw template.stub!(:render) in a before(:each) block >> and be done >> with it > > That sounds kinda risky because you could be ignoring partials that > get rendered that you don't want to be rendered. It is, most definately. >> , but that doesn't work anymore. I can understand why, but now I have >> to do something like template.stub!(:render).with(hash_including >> (:partial => >> anything)). Except for when I'm testing a partial, then I need to >> replace >> the anything with every partial I'm rendering in my partial. >> >> Is this the correct way, > > Seems like the only way at the moment. Wouldn't call it correct or > incorrect. I would call it ugly :). Not only do I have to remember the hash_including part, but also the anything (and not :anything). Conceptually, I like the template.stub!(:render). I render a template, on which I stub all the renders. Whether that's risky or not is a different discussion. >> or is there perhaps something like >> template.stub_partials :only => [], :except => [] ? > > Nothing like this exists. Seems like a reasonable idea. Feel free to > submit a feature request, or better yet, a patch to > http://rspec.lighthouseapp.com Will do! cheers, bartz From lists at ruby-forum.com Wed Jan 21 02:57:14 2009 From: lists at ruby-forum.com (Giuseppe Bertini) Date: Wed, 21 Jan 2009 08:57:14 +0100 Subject: [rspec-users] fixture_scenarios problem Message-ID: Hello there, is anyone still using fixture_scenarios with RSpec these days? They don't seem to coexist peacefully anymore. I just created a new rails (2.2.2) app, generated an rspec_scaffold (with v. 1.1.12), and verified that all specs pass. But if I then install the fixture_scenarios plugin: script/plugin install http://fixture-scenarios.googlecode.com/svn/trunk/fixture_scenarios all specs break, with the first error line being: /Users/giuseppe/trails/witest/vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:37 :in `create_fixtures' (more details upon request) On the other hand, the same plugin used to work with RSpec 1.1.4 Has anyone encountered/solved this problem? Thanks in advance, Giuseppe -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Wed Jan 21 03:09:32 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 21 Jan 2009 03:09:32 -0500 Subject: [rspec-users] fixture_scenarios problem In-Reply-To: References: Message-ID: <4976D83C.9080306@railsnewbie.com> Giuseppe Bertini wrote: > Hello there, > > is anyone still using fixture_scenarios with RSpec these days? They > don't seem to coexist peacefully anymore. > > I just created a new rails (2.2.2) app, generated an rspec_scaffold > (with v. 1.1.12), and verified that all specs pass. > > But if I then install the fixture_scenarios plugin: > > script/plugin install > http://fixture-scenarios.googlecode.com/svn/trunk/fixture_scenarios > > all specs break, with the first error line being: > > /Users/giuseppe/trails/witest/vendor/plugins/fixture_scenarios/lib/fixture_scenarios.rb:37 > :in `create_fixtures' > > (more details upon request) > Is the git tree any different than the svn one? http://github.com/mojombo/fixture-scenarios/tree/master Scott From lists at ruby-forum.com Wed Jan 21 07:49:18 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Wed, 21 Jan 2009 13:49:18 +0100 Subject: [rspec-users] =?utf-8?q?=5Bcucumber=5D_Features_with_multiple_use?= =?utf-8?q?r_iterations_=C2=BF=3F?= Message-ID: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> I am specing a feature, maybe at more high level of what it should be, and this makes scenarios that involves more that one rails controller. Is it possible or convenient? I have scenarios like this (although it's only an unreal example): Feature: Making a reservation for a service. Scenario: Making the reservation Given I want to make a reservation for a service When I choose the service Then I see the page 'service1/1/options' When I select option 1 And I click on "submit" Then I will be asked for a confirmation When I answer 'Yes' Then I see "Ok" And I go to "/services/1" Is this ok or I should define the features with only one single iteration? Juanma Cervera. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Jan 21 08:40:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Jan 2009 07:40:05 -0600 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> Message-ID: <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> On Wed, Jan 21, 2009 at 6:49 AM, Juanma Cervera wrote: > I am specing a feature, maybe at more high level of what it should be, > and this makes scenarios that involves more that one rails controller. > > Is it possible or convenient? > > I have scenarios like this (although it's only an unreal example): > > Feature: Making a reservation for a service. > Scenario: Making the reservation > Given I want to make a reservation for a service > When I choose the service > Then I see the page 'service1/1/options' > When I select option 1 > And I click on "submit" > Then I will be asked for a confirmation > When I answer 'Yes' > Then I see "Ok" > And I go to "/services/1" > > > Is this ok or I should define the features with only one single > iteration? It's OK to have more than one series of When/Then as long as they make for a cohesive scenario, which you've done here. I'd recommend avoiding URLs in the steps though. For example (I don't know what service and option mean in your case, but this should give you an idea): Scenario: Make a new reservation Given a 'Foo' service And the 'Foo' service includes a 'Bar' option When I choose the 'Foo' service Then I see the 'Foo Service' detail When I select the 'Bar' option And I submit my request Then I am be asked for a confirmation When I answer 'Yes' Then I see 'OK' And I see the 'Foo' service in the 'My Services' Note the lack of references to URLS and even pages. I might have taken it too far, depending on your situation. For example, "And I submit my request" instead of "And I click 'submit'" - If there is particular text on the button that is deemed to have business value, then you might say "And I click 'Request Service'" - but if you're referencing DOM IDs or HTML element names like 'submit', I'd hide those. HTH, David > > Juanma Cervera. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Wed Jan 21 08:57:14 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 21 Jan 2009 13:57:14 +0000 Subject: [rspec-users] 'Then' after a 'When' and then a 'Then'? Message-ID: <7ac2300c0901210557u62a632e6vd5f5b91c872ebaa2@mail.gmail.com> Hi, Is it bad form to use a 'Then' after a 'When' and then a 'Then'? When the CiP ingest checkbox is clicked Then '1 Spool(s) in Cart' should appear When the Add button is clicked Then an ingest user is on the BBC Cart page Or should I create a new scenario and use a 'Given'? Or can I have a Given after a 'Then' in the same scenario? Or should each scenerio follow 'Given'...'When'...'Then'? Cheers Aidy From aidy.lewis at googlemail.com Wed Jan 21 09:16:24 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 21 Jan 2009 14:16:24 +0000 Subject: [rspec-users] 'Then' after a 'When' and then a 'Then'? In-Reply-To: <7ac2300c0901210557u62a632e6vd5f5b91c872ebaa2@mail.gmail.com> References: <7ac2300c0901210557u62a632e6vd5f5b91c872ebaa2@mail.gmail.com> Message-ID: <7ac2300c0901210616x3e3401edi609c44acff7a5baa@mail.gmail.com> Hi, Apologies only just read the last post re: multiple iterations: please ignore. Aidy On 21/01/2009, aidy lewis wrote: > Hi, > > Is it bad form to use a 'Then' after a 'When' and then a 'Then'? > > When the CiP ingest checkbox is clicked > Then '1 Spool(s) in Cart' should appear > When the Add button is clicked > Then an ingest user is on the BBC Cart page > > Or should I create a new scenario and use a 'Given'? > > Or can I have a Given after a 'Then' in the same scenario? > > Or should each scenerio follow 'Given'...'When'...'Then'? > > Cheers > > > Aidy > From lists at ruby-forum.com Wed Jan 21 09:34:57 2009 From: lists at ruby-forum.com (Juanma Cervera) Date: Wed, 21 Jan 2009 15:34:57 +0100 Subject: [rspec-users] =?utf-8?q?=5Bcucumber=5D_Features_with_multipl_e_us?= =?utf-8?q?er_iterations_=C2=BF=3F?= In-Reply-To: <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> Message-ID: <417a9b024aa6a81656f67791e9cb513f@ruby-forum.com> Thank you David. All make a lot of sense. With the urls I only was trying to clarify that the scenario spans across multiple controllers, but I am making the specs as you recommend. Juanma -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Wed Jan 21 09:35:47 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Wed, 21 Jan 2009 14:35:47 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> Message-ID: <497732C3.3000401@josephwilk.net> Juanma Cervera wrote: > I am specing a feature, maybe at more high level of what it should be, > and this makes scenarios that involves more that one rails controller. > > Is it possible or convenient? > > I do not think its a problem touching multiple controllers if that's what is required for the user to achieve some specific value from the system. The value is king. > I have scenarios like this (although it's only an unreal example): > > Feature: Making a reservation for a service. > Scenario: Making the reservation > Given I want to make a reservation for a service > When I choose the service > Then I see the page 'service1/1/options' > When I select option 1 > And I click on "submit" > Then I will be asked for a confirmation > When I answer 'Yes' > Then I see "Ok" > And I go to "/services/1" > > > Is this ok or I should define the features with only one single > iteration? > > I find deviating from the ordering of Given/When/Then can sometimes produce scenarios that are hard to read and conceptualise. So I personally avoid multiple iterations in a single scenario. This however does not mean you should not touch multiple controllers. I would suggest perhaps something like this for your example scenario: -- Scenario: Making a successful reservation for massage service Given I have gone to the reservation page And I selected the service "massage" When I choose the option "extra oil" And I press the "make reservation" button And I confirm my reservation Then I will see "Ok, your reservation has been made for blah. Thanks!" And I will see the total price And I will be redirected to the service. Scenario: Making a reservation but cancelling at confirmation -- My scenario would still fail based on the 'thens' you mention. For example if I don't see the page 'service1/1/options' then I can never click the option for extra oil. So your thens have become implied. They are part of the journey, the destination (and value) is seeing I've made a reservation. Looking at your initial steps this one jumps out at me: Given I want to make a reservation for a service While it gives intent and a goal it does not explain the start state so I would question its usefulness. It feels more like the scenario name. -- Joseph Wilk http://blog.josephwilk.net > Juanma Cervera. > From zach.dennis at gmail.com Wed Jan 21 09:57:17 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 21 Jan 2009 09:57:17 -0500 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <497732C3.3000401@josephwilk.net> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <497732C3.3000401@josephwilk.net> Message-ID: <85d99afe0901210657n277f3fc0s9f7fe0e86e9fb796@mail.gmail.com> On Wed, Jan 21, 2009 at 9:35 AM, Joseph Wilk wrote: > Juanma Cervera wrote: >> >> I am specing a feature, maybe at more high level of what it should be, >> and this makes scenarios that involves more that one rails controller. >> >> Is it possible or convenient? >> >> > > I do not think its a problem touching multiple controllers if that's what is > required for the user to achieve some specific value from the system. The > value is king. To add this Joseph's comment, a general rule of thumb I follow is that I don't think about what controllers (if any) my scenarios are going to use. Since the scenario communicates value and behaviour provided by the app it's up to me as the developer to determine a good implementation. This may involve multiple controllers, one controller, or no controllers. This doesn't mean that I don't have a general idea of how I'm going to implement something because I usually do. But that's just because I'm a developer and as soon as I see a behaviour wanting implementation my brain goes in problem solving mode and starts to determining possible paths to a solution. The trick is to not to let this influence how you write (or encourage customers if you're working with them) scenarios. Here's a quick example. Let's say that you start by thinking one controller will suffice so you write your scenario for one controller. As you implement the scenario you may determine you really want to have two controllers because it helps keep your controller implementations clean. At this point you shouldn't have to change your scenario because you didn't change what the app is doing -- you just changed how it is doing it. So, changes should be limited to step definitions and actual implementation and not the scenario text itself. > >> I have scenarios like this (although it's only an unreal example): >> >> Feature: Making a reservation for a service. >> Scenario: Making the reservation >> Given I want to make a reservation for a service >> When I choose the service >> Then I see the page 'service1/1/options' >> When I select option 1 >> And I click on "submit" >> Then I will be asked for a confirmation >> When I answer 'Yes' >> Then I see "Ok" >> And I go to "/services/1" >> >> Is this ok or I should define the features with only one single >> iteration? >> >> > > I find deviating from the ordering of Given/When/Then can sometimes produce > scenarios that are hard to read and conceptualise. So I personally avoid > multiple iterations in a single scenario. This however does not mean you > should not touch multiple controllers. > > I would suggest perhaps something like this for your example scenario: > > -- > Scenario: Making a successful reservation for massage service > Given I have gone to the reservation page > And I selected the service "massage" > When I choose the option "extra oil" > And I press the "make reservation" button > And I confirm my reservation > Then I will see "Ok, your reservation has been made for blah. Thanks!" > And I will see the total price > And I will be redirected to the service. > Scenario: Making a reservation but cancelling at confirmation > > -- > My scenario would still fail based on the 'thens' you mention. For example > if I don't see the page 'service1/1/options' then I can never click the > option for extra oil. So your thens have become implied. They are part of > the journey, the destination (and value) is seeing I've made a reservation. > > > Looking at your initial steps this one jumps out at me: > > Given I want to make a reservation for a service > > While it gives intent and a goal it does not explain the start state so I > would question its usefulness. It feels more like the scenario name. > > > -- > Joseph Wilk > http://blog.josephwilk.net >> >> Juanma Cervera. >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aidy.lewis at googlemail.com Wed Jan 21 10:27:54 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 21 Jan 2009 15:27:54 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> Message-ID: <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> Hi David, On 21/01/2009, David Chelimsky wrote: > text on the button that is deemed to have business value, then you > might say "And I click 'Request Service'" - but if you're referencing > DOM IDs or HTML element names like 'submit', I'd hide those. However we could get a lot of re-use in the user steps if we have step definitions like these: When /^clicks '(+)' link$/ do |text| browser.link(:text, Regexp.new(value)).click end When /^clicks '(+)' button$/ do |text| browser.button(:value, Regexp.new(value)).click end When clicks 'Submit' link When clicks 'Submit' button When clicks 'New' link When clicks 'New' button I personally don't think it is a crime for the tester to change the acceptance steps as long as the 'user' can easily follow the narrative. A lot of the other user-steps could be wrapped-up in a more 'declarative' fashion. Aidy From dchelimsky at gmail.com Wed Jan 21 10:50:50 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 Jan 2009 09:50:50 -0600 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> Message-ID: <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> On Wed, Jan 21, 2009 at 9:27 AM, aidy lewis wrote: > Hi David, > On 21/01/2009, David Chelimsky wrote: > >> text on the button that is deemed to have business value, then you >> might say "And I click 'Request Service'" - but if you're referencing >> DOM IDs or HTML element names like 'submit', I'd hide those. > > However we could get a lot of re-use in the user steps if we have > step definitions like these: > > When /^clicks '(+)' link$/ do |text| > browser.link(:text, Regexp.new(value)).click > end > > When /^clicks '(+)' button$/ do |text| > browser.button(:value, Regexp.new(value)).click > end > > > When clicks 'Submit' link > When clicks 'Submit' button > When clicks 'New' link > When clicks 'New' button The important part of what I was saying was to avoid hidden elements (DOM IDs and element names). If the label that is visible in the browser says "Submit", then this is OK IMO. > I personally don't think it is a crime for the tester to change the > acceptance steps as long as the 'user' can easily follow the > narrative. Don't worry, you're not under arrest. At least not for this transgression :) > A lot of the other user-steps could be wrapped-up in a more > 'declarative' fashion. > > Aidy From apremdas at gmail.com Thu Jan 22 00:06:50 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 22 Jan 2009 05:06:50 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> Message-ID: <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> Assuming that your steps are focused on using DOM Id's what sort of convention would you use to translate from the narrative of the step to the DOM id. Would you avoid the brittleness that "clicks submit link|button" has over "I submit". Thats me arguing that whether its a link or a button, and whether the user submits by clicking, pressing enter or barking is not relevant to the scenario. 2009/1/21 David Chelimsky > On Wed, Jan 21, 2009 at 9:27 AM, aidy lewis > wrote: > > Hi David, > > On 21/01/2009, David Chelimsky wrote: > > > >> text on the button that is deemed to have business value, then you > >> might say "And I click 'Request Service'" - but if you're referencing > >> DOM IDs or HTML element names like 'submit', I'd hide those. > > > > However we could get a lot of re-use in the user steps if we have > > step definitions like these: > > > > When /^clicks '(+)' link$/ do |text| > > browser.link(:text, Regexp.new(value)).click > > end > > > > When /^clicks '(+)' button$/ do |text| > > browser.button(:value, Regexp.new(value)).click > > end > > > > > > When clicks 'Submit' link > > When clicks 'Submit' button > > When clicks 'New' link > > When clicks 'New' button > > The important part of what I was saying was to avoid hidden elements > (DOM IDs and element names). If the label that is visible in the > browser says "Submit", then this is OK IMO. > > > I personally don't think it is a crime for the tester to change the > > acceptance steps as long as the 'user' can easily follow the > > narrative. > > Don't worry, you're not under arrest. At least not for this transgression > :) > > > A lot of the other user-steps could be wrapped-up in a more > > 'declarative' fashion. > > > > Aidy > _______________________________________________ > 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 joshuachisholm at gmail.com Thu Jan 22 05:41:21 2009 From: joshuachisholm at gmail.com (Josh Chisholm) Date: Thu, 22 Jan 2009 10:41:21 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> Message-ID: <1126d7ae0901220241l2825b12bq505c190ac68e2488@mail.gmail.com> > Would you avoid the brittleness that "clicks submit link|button" has over "I submit". There are often many ways of submitting on the same page. So to avoid tying "I submit" to a particular scenario, I tend to use "I click 'submit'", which doesn't correspond to a link or button specifically, but to "a link, button, or label with the text 'submit' -- and raise an error if it's ambiguous". Is that too vague? As a human, if I were told to "click 'submit'" I think I would apply the same reasoning. On Thu, Jan 22, 2009 at 5:06 AM, Andrew Premdas wrote: > Assuming that your steps are focused on using DOM Id's what sort of > convention would you use to translate from the narrative of the step to the > DOM id. > > Would you avoid the brittleness that "clicks submit link|button" has over "I > submit". Thats me arguing that whether its a link or a button, and whether > the user submits by clicking, pressing enter or barking is not relevant to > the scenario. > > 2009/1/21 David Chelimsky >> >> On Wed, Jan 21, 2009 at 9:27 AM, aidy lewis >> wrote: >> > Hi David, >> > On 21/01/2009, David Chelimsky wrote: >> > >> >> text on the button that is deemed to have business value, then you >> >> might say "And I click 'Request Service'" - but if you're referencing >> >> DOM IDs or HTML element names like 'submit', I'd hide those. >> > >> > However we could get a lot of re-use in the user steps if we have >> > step definitions like these: >> > >> > When /^clicks '(+)' link$/ do |text| >> > browser.link(:text, Regexp.new(value)).click >> > end >> > >> > When /^clicks '(+)' button$/ do |text| >> > browser.button(:value, Regexp.new(value)).click >> > end >> > >> > >> > When clicks 'Submit' link >> > When clicks 'Submit' button >> > When clicks 'New' link >> > When clicks 'New' button >> >> The important part of what I was saying was to avoid hidden elements >> (DOM IDs and element names). If the label that is visible in the >> browser says "Submit", then this is OK IMO. >> >> > I personally don't think it is a crime for the tester to change the >> > acceptance steps as long as the 'user' can easily follow the >> > narrative. >> >> Don't worry, you're not under arrest. At least not for this transgression >> :) >> >> > A lot of the other user-steps could be wrapped-up in a more >> > 'declarative' fashion. >> > >> > Aidy >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.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 Thu Jan 22 06:32:46 2009 From: lists at ruby-forum.com (Zac Zheng) Date: Thu, 22 Jan 2009 12:32:46 +0100 Subject: [rspec-users] How best to write repetitive specs Message-ID: I wanted to test that my mailer models all had the correct headers: subject, to and from fields. I had done this by creating this in my spec_helper.rb: module TestMailerHelpers module ClassMethods def test_basic_headers it "subject" do @email.subject.should_not be_blank end it "to email address(es)" do @email.to.should_not be_blank end it "from email address(es)" do @email.from.should_not be_blank end end end def self.included(receiver) receiver.extend ClassMethods receiver.fixtures :users receiver.fixtures :roles receiver.fixtures :roles_users receiver.fixtures :ports end end I included the above in all my mailer specs, for which there are four, and called the method 'test_basic_headers'. This used to work, even though it looks terribly unDRY. An example of a mailer spec: require File.dirname(__FILE__) + '/../spec_helper' describe UserMailer do include TestMailerHelpers before(:each) do @user = users(:normal) @port = ports(:Alexandria) end describe "activation" do before(:each) do @email = UserMailer.create_activation(@user) end test_basic_headers end # ... end I have two problems. One, I am now receiving 'test_basic_headers' method not found error after upgrading rspec to 1.1.12. UserMailer is not including TestMailerHelpers correctly. Can anyone see why? Problem number two is that I have realised this is do doubt in inefficient way of doing what I want. Can anyone recommend a better way? Much thanks, Zac -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 22 06:40:24 2009 From: lists at ruby-forum.com (Zac Zheng) Date: Thu, 22 Jan 2009 12:40:24 +0100 Subject: [rspec-users] How best to write repetitive specs In-Reply-To: References: Message-ID: <71b330722d83695a04a2911bdb058a0b@ruby-forum.com> How stupid of me! I was looking at the wrong spec file. My 1st problem with no method found has now been solved. If anyone can still recommend a better way of spec'ing these tests, that'd be great. Zac Zheng wrote: > One, I am now receiving 'test_basic_headers' method not found error > after upgrading rspec to 1.1.12. UserMailer is not including > TestMailerHelpers correctly. Can anyone see why? -- Posted via http://www.ruby-forum.com/. From aidy.lewis at googlemail.com Thu Jan 22 06:40:39 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 22 Jan 2009 11:40:39 +0000 Subject: [rspec-users] =?iso-8859-1?q?=5Bcucumber=5D_Features_with_multipl?= =?iso-8859-1?q?e_user_iterations_=BF=3F?= In-Reply-To: <1126d7ae0901220241l2825b12bq505c190ac68e2488@mail.gmail.com> References: <7f55da16d37565794bff4dc61ecf86c8@ruby-forum.com> <57c63afe0901210540x4f8141eah1eeb89aac34f1f3f@mail.gmail.com> <7ac2300c0901210727x8072331nc3612517f3cc1de0@mail.gmail.com> <57c63afe0901210750t7e4038b1h8d306ecc9df9dcaa@mail.gmail.com> <88fd8ddc0901212106u41f5da00mf7ce21478a46cc70@mail.gmail.com> <1126d7ae0901220241l2825b12bq505c190ac68e2488@mail.gmail.com> Message-ID: <7ac2300c0901220340t53899608kbf8eb7037d16af76@mail.gmail.com> Josh, On 22/01/2009, Josh Chisholm wrote: > > Would you avoid the brittleness that "clicks submit link|button" has over "I submit". > > There are often many ways of submitting on the same page. So to avoid > tying "I submit" to a particular scenario, I tend to use "I click > 'submit'", which doesn't correspond to a link or button specifically, > but to "a link, button, or label with the text 'submit' -- and raise > an error if it's ambiguous". Is that too vague? As a human, if I were > told to "click 'submit'" I think I would apply the same reasoning. > Yes, and in a lot of cases we do choose 'I click submit' with the step implementation searching for a button value or text link: however, the user may specify a link; so I would write 'I click the 'submit' link'. Aidy From zach.dennis at gmail.com Thu Jan 22 07:47:44 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 22 Jan 2009 07:47:44 -0500 Subject: [rspec-users] How best to write repetitive specs In-Reply-To: References: Message-ID: <85d99afe0901220447m7e535c68h273283b424a46db0@mail.gmail.com> On Thu, Jan 22, 2009 at 6:32 AM, Zac Zheng wrote: > I wanted to test that my mailer models all had the correct headers: > subject, to and from fields. > > I had done this by creating this in my spec_helper.rb: > > module TestMailerHelpers > module ClassMethods > def test_basic_headers > it "subject" do > @email.subject.should_not be_blank > end > > it "to email address(es)" do > @email.to.should_not be_blank > end > > it "from email address(es)" do > @email.from.should_not be_blank > end > end > end > > def self.included(receiver) > receiver.extend ClassMethods > receiver.fixtures :users > receiver.fixtures :roles > receiver.fixtures :roles_users > receiver.fixtures :ports > end > end > Check out shared_examples_for: http://rspec.rubyforge.org/rspec/1.1.12/classes/Spec/DSL/Main.html#M000505 shared_examples_for "a standard mailer model" do # ... end I usually put my shared examples in spec/shared_examples/ and then in your actual mailer models you'd add the below line... describe YourMailerModel do it_should_behave_like "a standard mailer model" end > > I included the above in all my mailer specs, for which there are four, > and called the method 'test_basic_headers'. This used to work, even > though it looks terribly unDRY. > > An example of a mailer spec: > > require File.dirname(__FILE__) + '/../spec_helper' > describe UserMailer do > include TestMailerHelpers > > before(:each) do > @user = users(:normal) > @port = ports(:Alexandria) > end > > describe "activation" do > before(:each) do > @email = UserMailer.create_activation(@user) > end > > test_basic_headers > end > # ... > end > > I have two problems. > > One, I am now receiving 'test_basic_headers' method not found error > after upgrading rspec to 1.1.12. UserMailer is not including > TestMailerHelpers correctly. Can anyone see why? > > Problem number two is that I have realised this is do doubt in > inefficient way of doing what I want. Can anyone recommend a better way? > > Much thanks, > Zac > -- > 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 http://www.mutuallyhuman.com From lists at ruby-forum.com Thu Jan 22 08:37:33 2009 From: lists at ruby-forum.com (Zac Zheng) Date: Thu, 22 Jan 2009 14:37:33 +0100 Subject: [rspec-users] How best to write repetitive specs In-Reply-To: <85d99afe0901220447m7e535c68h273283b424a46db0@mail.gmail.com> References: <85d99afe0901220447m7e535c68h273283b424a46db0@mail.gmail.com> Message-ID: <9c21c3b72ef00fb795e7a69598bf1b9e@ruby-forum.com> Thanks Zach(great name btw)! I am using it now and it works great. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 22 10:38:31 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 22 Jan 2009 16:38:31 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb Message-ID: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> I develop in a heterogeneous environment. When I am working with Ruby on Rails on my laptop then I am inside the bash shell of cygwin running under MS-WinXPpro. I also happen to favour a light green on dark green default terminal display. This renders portions of cucumber's output, under its default colour scheme, invisible on both Linux and cygwin. So, I have set up a custom ENV setting in support/env.rb. Thus: ENV["CUCUMBER_COLORS"] = 'passed=white,bold:passed_param=white,bold,underscore' When I run rake features this works exactly as I intended under Linux, but seems to have no effect whatsoever under cygwin. I am working around this by manually setting the session environment variable and I could make this solution permanent by altering my .bashrc script. I nonetheless would like to know why this Ruby setting does not seem to work in all cases. Is there a special syntax for cygwin/windows? Have I missed a step and the fact that Linux turns out as expected simply a coincidence? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 22 14:21:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 22 Jan 2009 20:21:59 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> Message-ID: <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> James Byrne wrote: > > When I run rake features this works exactly as I intended under Linux, Evidently not. Setting the ENV inside env.rb does not influence the rake task display at all. It seems that I must set it externally to cucumber to have effect. -- Posted via http://www.ruby-forum.com/. From luislavena at gmail.com Thu Jan 22 14:29:02 2009 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 22 Jan 2009 17:29:02 -0200 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> Message-ID: <71166b3b0901221129jbc91935n2e4c0d08a445b4bd@mail.gmail.com> On Thu, Jan 22, 2009 at 1:38 PM, James Byrne wrote: > I develop in a heterogeneous environment. When I am working with Ruby > on Rails on my laptop then I am inside the bash shell of cygwin running > under MS-WinXPpro. > > I also happen to favour a light green on dark green default terminal > display. This renders portions of cucumber's output, under its default > colour scheme, invisible on both Linux and cygwin. So, I have set up a > custom ENV setting in support/env.rb. Thus: > > ENV["CUCUMBER_COLORS"] = > 'passed=white,bold:passed_param=white,bold,underscore' > > When I run rake features this works exactly as I intended under Linux, > but seems to have no effect whatsoever under cygwin. I am working > around this by manually setting the session environment variable and I > could make this solution permanent by altering my .bashrc script. I > nonetheless would like to know why this Ruby setting does not seem to > work in all cases. Is there a special syntax for cygwin/windows? Have > I missed a step and the fact that Linux turns out as expected simply a > coincidence? Cucumber is already initialized when support/env.rb is loaded. On Windows, cucumber uses win32console to output colors. I cannot comment on cygwin since I'm not a user of the environment. You're mixing cygwin ruby or is native ruby? -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From apremdas at gmail.com Thu Jan 22 15:09:47 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 22 Jan 2009 20:09:47 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> Message-ID: <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> I never could get Cygwin to display terminal colors in a consistent way. You'd probably find it easier to install OSX on your laptop! One thing you could do is try and run an XTerm in cygwin perhaps using a minimal window manager like ratpoison. This was the best I was able to manage in getting a decent terminal on windows (Cygwin Ratpoison and Screen), but in the end I gave up it was just to hard :) and inconsistent. 2009/1/22 James Byrne > I develop in a heterogeneous environment. When I am working with Ruby > on Rails on my laptop then I am inside the bash shell of cygwin running > under MS-WinXPpro. > > I also happen to favour a light green on dark green default terminal > display. This renders portions of cucumber's output, under its default > colour scheme, invisible on both Linux and cygwin. So, I have set up a > custom ENV setting in support/env.rb. Thus: > > ENV["CUCUMBER_COLORS"] = > 'passed=white,bold:passed_param=white,bold,underscore' > > When I run rake features this works exactly as I intended under Linux, > but seems to have no effect whatsoever under cygwin. I am working > around this by manually setting the session environment variable and I > could make this solution permanent by altering my .bashrc script. I > nonetheless would like to know why this Ruby setting does not seem to > work in all cases. Is there a special syntax for cygwin/windows? Have > I missed a step and the fact that Linux turns out as expected simply a > coincidence? > -- > 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 luislavena at gmail.com Thu Jan 22 15:34:16 2009 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 22 Jan 2009 18:34:16 -0200 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> Message-ID: <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> On Thu, Jan 22, 2009 at 6:09 PM, Andrew Premdas wrote: > I never could get Cygwin to display terminal colors in a consistent way. > You'd probably find it easier to install OSX on your laptop! > http://rubyonwindows.blogspot.com/2009/01/amen-brother.html > One thing you could do is try and run an XTerm in cygwin perhaps using a > minimal window manager like ratpoison. This was the best I was able to > manage in getting a decent terminal on windows (Cygwin Ratpoison and > Screen), but in the end I gave up it was just to hard :) and inconsistent. > That needs to run a x server to be able to use Xterm... that is way more complicated... James: can you tell us if you're using cygwin ruby or native one? -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From lists at ruby-forum.com Thu Jan 22 16:15:17 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 22 Jan 2009 22:15:17 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> Message-ID: <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> Luis Lavena wrote: > > James: can you tell us if you're using cygwin ruby or native one? > I am not sure. I installed cygwin after I had Ruby on that box. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Thu Jan 22 17:06:47 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 22 Jan 2009 23:06:47 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> Message-ID: <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> On Thu, Jan 22, 2009 at 10:15 PM, James Byrne wrote: > Luis Lavena wrote: > > > > > James: can you tell us if you're using cygwin ruby or native one? > > > > I am not sure. I installed cygwin after I had Ruby on that box. > Than you have a native one. Run ruby --version to be sure. What does it say? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From cwdinfo at gmail.com Thu Jan 22 17:51:31 2009 From: cwdinfo at gmail.com (s.ross) Date: Thu, 22 Jan 2009 14:51:31 -0800 Subject: [rspec-users] [Cucumber] Directory Layout Message-ID: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> I had a relatively flat layout and wanted to group like features together so I made it more hierarchical: features/ messaging/ main_screen.feature message_page.feature steps/ main_screen.rb messaging_steps.rb This may be just my boneheadedness, but when I do: cucumber features/messaging -r features/support/env.rb These run, but none of the steps are matched. It seems the step matchers are not expected to be where I put them. Questions: - Is there a more sensible layout? - Is there an easier way than -r features/support/env.rb to get the machinist plugin to load? Thanks From dchelimsky at gmail.com Thu Jan 22 18:38:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 Jan 2009 17:38:25 -0600 Subject: [rspec-users] [Cucumber] Directory Layout In-Reply-To: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> References: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> Message-ID: <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> On Thu, Jan 22, 2009 at 4:51 PM, s.ross wrote: > I had a relatively flat layout and wanted to group like features together so > I made it more hierarchical: > > features/ > messaging/ > main_screen.feature > message_page.feature > steps/ > main_screen.rb > messaging_steps.rb > > This may be just my boneheadedness, but when I do: > > cucumber features/messaging -r features/support/env.rb That ONLY loads features/support/env.rb and not any of the step definition files. Try this: cucumber features/messaging -r features > > These run, but none of the steps are matched. It seems the step matchers are > not expected to be where I put them. > > Questions: > > - Is there a more sensible layout? > - Is there an easier way than -r features/support/env.rb to get the > machinist plugin to load? > > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Thu Jan 22 19:05:43 2009 From: cwdinfo at gmail.com (s.ross) Date: Thu, 22 Jan 2009 16:05:43 -0800 Subject: [rspec-users] [Cucumber] Directory Layout In-Reply-To: <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> References: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> Message-ID: <8861DEAC-8E67-4861-8D59-34AE89409DE2@gmail.com> On Jan 22, 2009, at 3:38 PM, David Chelimsky wrote: > On Thu, Jan 22, 2009 at 4:51 PM, s.ross wrote: >> I had a relatively flat layout and wanted to group like features >> together so >> I made it more hierarchical: >> >> features/ >> messaging/ >> main_screen.feature >> message_page.feature >> steps/ >> main_screen.rb >> messaging_steps.rb >> >> This may be just my boneheadedness, but when I do: >> >> cucumber features/messaging -r features/support/env.rb > > That ONLY loads features/support/env.rb and not any of the step > definition files. Try this: > > cucumber features/messaging -r features > >> >> These run, but none of the steps are matched. It seems the step >> matchers are >> not expected to be where I put them. >> >> Questions: >> >> - Is there a more sensible layout? >> - Is there an easier way than -r features/support/env.rb to get the >> machinist plugin to load? >> >> Thanks >> Yup. That was it. Thanks! From aslak.hellesoy at gmail.com Thu Jan 22 19:57:54 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 01:57:54 +0100 Subject: [rspec-users] [Cucumber] Directory Layout In-Reply-To: <8861DEAC-8E67-4861-8D59-34AE89409DE2@gmail.com> References: <0BBB1863-0228-4D93-BEB5-76E48942744E@gmail.com> <57c63afe0901221538v6e9ff352wae84ca3a18bb7beb@mail.gmail.com> <8861DEAC-8E67-4861-8D59-34AE89409DE2@gmail.com> Message-ID: <8d961d900901221657q1724aef3h931b3a0c0978700f@mail.gmail.com> On Fri, Jan 23, 2009 at 1:05 AM, s.ross wrote: > On Jan 22, 2009, at 3:38 PM, David Chelimsky wrote: > > On Thu, Jan 22, 2009 at 4:51 PM, s.ross wrote: >> >>> I had a relatively flat layout and wanted to group like features together >>> so >>> I made it more hierarchical: >>> >>> features/ >>> messaging/ >>> main_screen.feature >>> message_page.feature >>> steps/ >>> main_screen.rb >>> messaging_steps.rb >>> >>> This may be just my boneheadedness, but when I do: >>> >>> cucumber features/messaging -r features/support/env.rb >>> >> >> That ONLY loads features/support/env.rb and not any of the step >> definition files. Try this: >> >> cucumber features/messaging -r features >> >> >>> These run, but none of the steps are matched. It seems the step matchers >>> are >>> not expected to be where I put them. >>> >>> Questions: >>> >>> - Is there a more sensible layout? >>> - Is there an easier way than -r features/support/env.rb to get the >>> machinist plugin to load? >>> >>> Thanks >>> >>> > Yup. That was it. Thanks! > Just to clarify.. If you pass *no* --require switches to cucumber, it will guess where to find .rb files to load If you pass one or more it will stop guessing Aslak > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at pinkpucker.net Thu Jan 22 21:46:27 2009 From: joe at pinkpucker.net (Joe Van Dyk) Date: Thu, 22 Jan 2009 18:46:27 -0800 Subject: [rspec-users] testing javascript-heavy websites Message-ID: We're starting to work on some javascript-heavy websites, and even some flash/flex based ones as well. What's the current hotness in automatically testing those types of websites? Does cucumber hook up to selenium now? I thought I saw that webrat did. Any recommended resources? Joe From ben at benmabey.com Thu Jan 22 22:06:40 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 22 Jan 2009 20:06:40 -0700 Subject: [rspec-users] testing javascript-heavy websites In-Reply-To: References: Message-ID: <49793440.8040400@benmabey.com> On 1/22/09 7:46 PM, Joe Van Dyk wrote: > We're starting to work on some javascript-heavy websites, and even > some flash/flex based ones as well. > For flex see: http://wiki.github.com/aslakhellesoy/cucumber/funfx-and-flex > What's the current hotness in automatically testing those types of > websites? Does cucumber hook up to selenium now? I thought I saw > that webrat did. > For JS you can use webrat with Cucumber to drive selenium. See the webrat docs for more info. You can use Watir or Celerity with Cucumber. There is a screencast on using Cucumber with Watir on cukes.info. HTH, Ben From pergesu at gmail.com Thu Jan 22 22:19:23 2009 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 22 Jan 2009 19:19:23 -0800 Subject: [rspec-users] testing javascript-heavy websites In-Reply-To: References: Message-ID: <810a540e0901221919t5e2f8f04heffd217ee4f668c5@mail.gmail.com> On Thu, Jan 22, 2009 at 6:46 PM, Joe Van Dyk wrote: > We're starting to work on some javascript-heavy websites, and even > some flash/flex based ones as well. > > What's the current hotness in automatically testing those types of > websites? Does cucumber hook up to selenium now? I thought I saw > that webrat did. > > Any recommended resources? Yes you can use cucumber/webrat/selenium. I have had some trouble with ajax-heavy stuff but never took the time to sort it out. For testing JS directly, I use Screw.Unit Pat From lists at ruby-forum.com Thu Jan 22 22:26:46 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 04:26:46 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> Message-ID: <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> Aslak Helles?y wrote: > On Thu, Jan 22, 2009 at 10:15 PM, > >> Luis Lavena wrote: >> >> > >> > James: can you tell us if you're using cygwin ruby or native one? >> > >> >> I am not sure. I installed cygwin after I had Ruby on that box. >> > > Than you have a native one. Run ruby --version to be sure. What does it > say? byrnejb at HAL-M13 ~ $ruby --version ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] Sorry for the delay in my reply. JBB -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Fri Jan 23 03:49:05 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 09:49:05 +0100 Subject: [rspec-users] Reorganize documentation for Cucumber at Github In-Reply-To: <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> References: <4972493F.5000408@comcast.net> <8d961d900901171634s5500e7f5oec8347a4816e432d@mail.gmail.com> <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> Message-ID: <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> On Sun, Jan 18, 2009 at 2:24 AM, aslak hellesoy wrote: > > > On Sun, Jan 18, 2009 at 1:34 AM, aslak hellesoy wrote: > >> >> >> On Sat, Jan 17, 2009 at 10:10 PM, Tom Cloyd wrote: >> >>> Fernando Perez wrote: >>> >>>> Hi, >>>> >>>> I actually just noticed that Cucumber has plenty good documentation on >>>> its wiki at github. But the problems are: >>>> >>>> - The homepage is badly designed as it doesn't really outline an order >>>> to read other pages >>>> - It is impossible to make the difference between internal links to the >>>> wiki and links that will bring us some where else unless we hover over >>>> the link >>>> - Pages don't link to each other such as: read next page or previous >>>> page, or related pages >>>> - Pages are just sorted alphabetically which is not a proper way of >>>> sorting >>>> >>>> Would it be possible to at least number the pages in the order in which >>>> we should read as if we were reading a book about cucumber? >>>> >>>> The documentation seems excellent but is definitely not well marketed >>>> for new comers :) >>>> >>>> >>> Oh, I totally agree. Add in the fact that the Rails stuff is just a mess >>> for non-Rails people to read, and we really have two problems to solve. >>> That's how I, at least, have been experiencing it. >>> >>> My own solution is to build my own procedural outline. I'm working on it >>> today, in fact - sort of a "Cucumber for dummies" document. In my >>> conception, liberal use will be made of links to existing pages, or to >>> sections thereof, as there's no need to attempt to redo what the experts >>> have already done well. I figure if I write what I wish I'd encountered when >>> I went to the wiki, and then see if I can get it there, it might help other >>> folks. >>> >>> Your final sentence says it all - great documentation, but not for >>> newbies. Where's the starting point? Etc. >>> >> >> Where is the starting point! There is none! Haha. And the GitHub Wiki Home >> page is probably the worst page in the whole Wiki. >> >> Honestly - I think what's needed is: >> >> 1) Move a lot of the random stuff from Home to separate pages >> 2) Make the Home page really short - with links to a few new pages: >> >> * General Five Minute Introduction (Pure Cucumber/Ruby stuff - no Rails) - >> Narrative, sequential style, link to other specific pages - ideally most of >> them. >> * Rails-specific Five Minute Introduction (to be read after the other 5 >> minute one). Cucumber Backgrounder is a very good start for this, but I >> think it's a little rambling :-) >> >> I'd like to write these intros myself, so please don't start doing massive >> edits. Instead, I'd love to get input of an outline for these Introduction >> pages. >> >> How does that sound? >> > > Ok, I'll give a stab at what a 5 minute introduction might contain. Please > comment. > > 1) Who should use Cucumber, and what benefits can you get from it? > 2) How Cucumber works (high level explanation without getting too > technical). > 3) Learn the nomenclature - features, scenarios, steps (step definitions > later). Some style guidlines. > 4) What does a Cucumber feature look like (plain - no outlines or tables). > Learn how to write one in a simple text editor. > 5) How to install and run Cucumber (using the one from 3 as example. No > Rake yet - just the cucumber command) > 6) What does the output from Cucumber mean? (Learn to read the deafault > console output. Colours and error messages. Mention other formatters) > 7) Learn to write step definitions (they are similar to defining methods in > most imperative languages like Ruby, Java, C, Pascal....). Mention Regexps, > Rubular.com. > 8) How to implement the body of a step definition. Learn about RSpec's > #should and #should_not - and matchers > 9) How to fix a failing (red) step definition by writing some code (in lib > for now since we're not doing any Rails) > 10) Mention DTSTTCPW and refactoring - with some external links. TDD > basics. > 11) Learn how to use Rake (useful when you have more than one feature > file). Mention RCov. > 12) Learn about the various command-line switches > 13) Learn about more advanced Gherkin (Cucumber language) features such as > Tables, PyString, Scenario Outlines and Background (coming soon) > 13.5) Learn about how to substitute in steps and multiline args (table, pystring) from examples tables. > > 14) Learn about hooks (Before, After etc) > 15) Various other features (CUCUMBER_COLORS, AutoTest, cucumber.yml > (profiles) > 16) IDE support > 17) How to use other assertion tools like Test::Unit, Shoulda, etc. > 18) How to use Cukes with non-Ruby platforms (Watir family, JRuby, > IronRuby, FunFX/Flex) > 18.5) Pure Java via JBehave > > The reader will gradually learn about the recommended file layout > structure. > > Maybe this is more like a 10-15 minute intro. I'll try to keep it as short > as possible without skipping important concepts. > > What's missing? What's in the wrong order? What should I remove? > > Aslak > > >> Aslak >> >> >>> I'm working on this thing right now, and maybe it'll be far enough along >>> for some kind of review this weekend. Or...I could put it up, say on a >>> Google Sites wiki, and several of us could work on it. Any thoughts? I >>> actually prefer to work in a group, but have already started on my own. >>> >>> Yeah, I like that idea - a temporary Google Sites wiki. >>> >>> Tom >>> >>> >>> >>> >>> -- >>> >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist >>> Bellingham, Washington, U.S.A: (360) 920-1226 >>> << tc at tomcloyd.com >> (email) >>> << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental >>> health weblog) >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> Aslak (::) >> > > > > -- > Aslak (::) > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Jan 23 05:47:15 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 23 Jan 2009 10:47:15 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> Message-ID: <88fd8ddc0901230247p2fe65beh3a5805094a6bad@mail.gmail.com> Luis Not quite sure that your criticism is of my post is justified. At no point did I say that James should give up on Windows nor give up on Cygwin, only that it is very difficult to get the terminal colors to work exactly how you want in that environment. This is based on considerable experience trying to do precisely this. Nor am I saying that people should not use Windows for Rails or that you cannot have an effective Rails setup with Windows. What I am saying is that having an effective Unix command prompt in Windows that you can control with as much precision as in linux or OSX is very difficult under Windows. If you want to do this (and I really did want to do this) then the XTerm approach was more effective at trying to control terminal colors consistently in comparison to manipulating the standard cygwin terminal. But whatever you do you will probably have to compromise somewhat your terminal experience in comparison to a proper nix. Andrew 2009/1/22 Luis Lavena > On Thu, Jan 22, 2009 at 6:09 PM, Andrew Premdas > wrote: > > I never could get Cygwin to display terminal colors in a consistent way. > > You'd probably find it easier to install OSX on your laptop! > > > > http://rubyonwindows.blogspot.com/2009/01/amen-brother.html > > > One thing you could do is try and run an XTerm in cygwin perhaps using a > > minimal window manager like ratpoison. This was the best I was able to > > manage in getting a decent terminal on windows (Cygwin Ratpoison and > > Screen), but in the end I gave up it was just to hard :) and > inconsistent. > > > > That needs to run a x server to be able to use Xterm... that is way > more complicated... > > James: can you tell us if you're using cygwin ruby or native one? > > -- > Luis Lavena > AREA 17 > - > Perfection in design is achieved not when there is nothing more to add, > but rather when there is nothing more to take away. > Antoine de Saint-Exup?ry > _______________________________________________ > 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 aidy.lewis at googlemail.com Fri Jan 23 06:14:11 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Fri, 23 Jan 2009 11:14:11 +0000 Subject: [rspec-users] Reorganize documentation for Cucumber at Github In-Reply-To: <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> References: <4972493F.5000408@comcast.net> <8d961d900901171634s5500e7f5oec8347a4816e432d@mail.gmail.com> <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> Message-ID: <7ac2300c0901230314l61b5d3far1f05067a74787939@mail.gmail.com> Hi On 23/01/2009, aslak hellesoy wrote: > > 18) How to use Cukes with non-Ruby platforms (Watir family, .... I will gladly put something together on Cucumber and Watir. Aidy From aslak.hellesoy at gmail.com Fri Jan 23 06:23:50 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 12:23:50 +0100 Subject: [rspec-users] Reorganize documentation for Cucumber at Github In-Reply-To: <7ac2300c0901230314l61b5d3far1f05067a74787939@mail.gmail.com> References: <4972493F.5000408@comcast.net> <8d961d900901171634s5500e7f5oec8347a4816e432d@mail.gmail.com> <8d961d900901171724w5f339fedn110f9431bb6dc722@mail.gmail.com> <8d961d900901230049m1a33e159m17b0e3c33449fb5@mail.gmail.com> <7ac2300c0901230314l61b5d3far1f05067a74787939@mail.gmail.com> Message-ID: <8d961d900901230323w22552e90y3970960be1362fc6@mail.gmail.com> On Fri, Jan 23, 2009 at 12:14 PM, aidy lewis wrote: > Hi > On 23/01/2009, aslak hellesoy wrote: > > > > 18) How to use Cukes with non-Ruby platforms (Watir family, .... > > I will gladly put something together on Cucumber and Watir. > Be my guest! Please also link to the Watir examples in the sources at GitHub Aslak > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From joshuachisholm at gmail.com Fri Jan 23 08:55:27 2009 From: joshuachisholm at gmail.com (Josh Chisholm) Date: Fri, 23 Jan 2009 13:55:27 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> Message-ID: <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> We are setting environment variables in our Rakefile. We have various tasks that set up environment variables, then call the cucumber task. That's working for us under windows. On Thu, Jan 22, 2009 at 7:21 PM, James Byrne wrote: > James Byrne wrote: > >> >> When I run rake features this works exactly as I intended under Linux, > > Evidently not. Setting the ENV inside env.rb does not influence the > rake task display at all. It seems that I must set it externally to > cucumber to have effect. > > > > -- > 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 Jan 23 09:20:42 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 15:20:42 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> Message-ID: <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> My original observation wrt this problem was inaccurate. The same behaviour is evidenced in both my Linux and cygwin environments. Setting the environment variable "CUCUMBER_COLORS" in support/env.rb run does not alter the behaviour of that run. As one expects, any environment variable set within a process will not persist after that process terminates. I lack the experience in either OS to say whether or not doing so should affect the setting process itself or only those processes spawned by that parent after the setting of the variable. I gathered from the cucumber documentation that the writer expected that setting the environment in env.rb SHOULD have some effect. However, I cannot say if that expectation was valid or not. I am not experiencing any problems with displaying colours or text enhancements (within the limited ANSI palette) in either environment. -- Posted via http://www.ruby-forum.com/. From luislavena at gmail.com Fri Jan 23 09:25:14 2009 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 23 Jan 2009 12:25:14 -0200 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <88fd8ddc0901230247p2fe65beh3a5805094a6bad@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <88fd8ddc0901230247p2fe65beh3a5805094a6bad@mail.gmail.com> Message-ID: <71166b3b0901230625s48954f40l837e28b19ada5539@mail.gmail.com> On Fri, Jan 23, 2009 at 8:47 AM, Andrew Premdas wrote: > Luis > > Not quite sure that your criticism is of my post is justified. At no point > did I say that James should give up on Windows nor give up on Cygwin, only > that it is very difficult to get the terminal colors to work exactly how you > want in that environment. This is based on considerable experience trying to > do precisely this. Nor am I saying that people should not use Windows for > Rails or that you cannot have an effective Rails setup with Windows. You forgot to put a smiley icon along your statement that install OSX ;-) > What I am saying is that having an effective Unix command prompt in Windows > that you can control with as much precision as in linux or OSX is very > difficult under Windows. If you want to do this (and I really did want to do > this) then the XTerm approach was more effective at trying to control > terminal colors consistently in comparison to manipulating the standard > cygwin terminal. But whatever you do you will probably have to compromise > somewhat your terminal experience in comparison to a proper nix. I cannot comment too much on cygwin experince, since only used it for short amount of time and with rxvt. In my experience, I've only used bash directly which provided syntax coloring without issues. Now, the thing is that I'm talking about MSYS bash, no cygwin, so dunno how that will work. XTerm, while it provided a workaround to the problem, and worked as solution, imposes another requirement for users to use it (you need to adapt to something different can also not work with other tools). The nature of console in Windows is far from ideal, but that applies to native Ruby on Windows Cygwin Ruby should behave much like *nix, with ansi colors and all that. As other users commented, setting environment variables is not a problem on native Windows (I use and abuse of that in a daily basis). But again, dunno what happens in cygwin island. > > Andrew > > > > > 2009/1/22 Luis Lavena >> >> On Thu, Jan 22, 2009 at 6:09 PM, Andrew Premdas >> wrote: >> > I never could get Cygwin to display terminal colors in a consistent way. >> > You'd probably find it easier to install OSX on your laptop! >> > >> >> http://rubyonwindows.blogspot.com/2009/01/amen-brother.html >> >> > One thing you could do is try and run an XTerm in cygwin perhaps using a >> > minimal window manager like ratpoison. This was the best I was able to >> > manage in getting a decent terminal on windows (Cygwin Ratpoison and >> > Screen), but in the end I gave up it was just to hard :) and >> > inconsistent. >> > >> >> That needs to run a x server to be able to use Xterm... that is way >> more complicated... >> >> James: can you tell us if you're using cygwin ruby or native one? >> >> -- >> Luis Lavena >> AREA 17 >> - >> Perfection in design is achieved not when there is nothing more to add, >> but rather when there is nothing more to take away. >> Antoine de Saint-Exup?ry >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From aslak.hellesoy at gmail.com Fri Jan 23 09:34:08 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 15:34:08 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> Message-ID: <8d961d900901230634o5a862be4u1577c4a1313265a7@mail.gmail.com> On Fri, Jan 23, 2009 at 3:20 PM, James Byrne wrote: > My original observation wrt this problem was inaccurate. The same > behaviour is evidenced in both my Linux and cygwin environments. > Setting the environment variable "CUCUMBER_COLORS" in support/env.rb run > does not alter the behaviour of that run. > Updated docs: http://wiki.github.com/aslakhellesoy/cucumber/console-colours > > As one expects, any environment variable set within a process will not > persist after that process terminates. I lack the experience in either > OS to say whether or not doing so should affect the setting process > itself or only those processes spawned by that parent after the setting > of the variable. > > I gathered from the cucumber documentation that the writer expected that > setting the environment in env.rb SHOULD have some effect. However, I > cannot say if that expectation was valid or not. > > I am not experiencing any problems with displaying colours or text > enhancements (within the limited ANSI palette) in either environment. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jan 23 09:40:27 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 15:40:27 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> Message-ID: <7d868051da352d18aab23041949143c9@ruby-forum.com> Josh Chisholm wrote: > We are setting environment variables in our Rakefile. We have various > tasks that set up environment variables, then call the cucumber task. > That's working for us under windows. Yes that makes sense. Referring to the Pickaxe book one reads that: "A Ruby program may write to the ENV object, which on most systems changes the values of the corresponding environment variables. However, this change is local to the process that makes it and to any subsequently spawned child processes. This inheritance of environment variables is illustrated in the code that follows. A subprocess changes an environment variable and this change is seen in a process that it then starts. However, the change is not visible to the original parent. (This just goes to prove that parents never really know what their children are doing.)" This does seem to indicate that the ENV setting made in in env.rb is visible to the cucumber process. The inference that I draw from this is that env.rb is processed after the ENV setting for "CUCUMBER_COLORS" has already been used by cucumber and thus has no further effect on its behaviour. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Fri Jan 23 10:16:18 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 23 Jan 2009 16:16:18 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <7d868051da352d18aab23041949143c9@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <735bd5aa60c4e5cae8af6ba0c48abe28@ruby-forum.com> <1126d7ae0901230555u5b3fd639q7b5edd4634874631@mail.gmail.com> <7d868051da352d18aab23041949143c9@ruby-forum.com> Message-ID: <8d961d900901230716x1b9e4f3br225468a5e33c9a2c@mail.gmail.com> On Fri, Jan 23, 2009 at 3:40 PM, James Byrne wrote: > Josh Chisholm wrote: > > We are setting environment variables in our Rakefile. We have various > > tasks that set up environment variables, then call the cucumber task. > > That's working for us under windows. > > Yes that makes sense. Referring to the Pickaxe book one reads that: > > "A Ruby program may write to the ENV object, which on most systems > changes the values of the corresponding environment variables. However, > this change is local to the process that makes it and to any > subsequently spawned child processes. This inheritance of environment > variables is illustrated in the code that follows. A subprocess changes > an environment variable and this change is seen in a process that it > then starts. However, the change is not visible to the original parent. > (This just goes to prove that parents never really know what their > children are doing.)" > > This does seem to indicate that the ENV setting made in in env.rb is > visible to the cucumber process. The inference that I draw from this is > that env.rb is processed after the ENV setting for "CUCUMBER_COLORS" has > already been used by cucumber and thus has no further effect on its > behaviour. That is correct: http://github.com/aslakhellesoy/cucumber/blob/cee08ca63fd2d234aacc231d5be342bb6fba06bc/lib/cucumber/formatters/ansicolor.rb (BTW, this is the ugliest code in Cucumber) Aslak > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Jan 23 12:04:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 23 Jan 2009 10:04:16 -0700 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? Message-ID: <4979F890.8000608@benmabey.com> Hi all, Just wanted to get some feedback and opinions on something... I have been using Cucumber/Story Runner since plaintext support was introduced. (So, since October/November of 2007.) Throughout this time I have used it on various projects. Some projects had customer involvement in help writing the scenarios, some I mostly wrote the scenarios after gathering requirements and then got verification from the customer, and others involved no customer at all (i.e. I was the customer). In all three cases I have gotten a lot of benefit from the upfront analysis that writing the feature forces you to do and the outside-in development that follows. That said, the business analysis and outside-in development can be accomplished with any tool (i.e. rspec with webrat for webapps). In the past I have always defaulted on using the GWT (Given, When, Then) syntax for most of my acceptance tests, but that may be because I am so accustomed to that workflow by now. So... I'm curious what people's thoughts are. When writing acceptance tests how do you choose which tool is best for the job? I often hear people complaining about the GWT syntax and they see no benefit of it over the frameworks that provide contexts (i.e rspec, shoulda, etc).[1] In what cases, if any, do you think the GWT gets in the way and how? In particular, if you are writing an app or lib whose customers/users are all developers do you still think there is value in the GWT syntax that Cucumber provides? I have my own thoughts on the matter, but in playing devil's advocate I want to get other people's thoughts before I skew you with mine. :) Thanks, Ben [1] http://www.dcmanges.com/blog/practicality-of-the-rspec-story-runner From lists at ruby-forum.com Fri Jan 23 12:15:49 2009 From: lists at ruby-forum.com (Pau Cor) Date: Fri, 23 Jan 2009 18:15:49 +0100 Subject: [rspec-users] testing javascript-heavy websites In-Reply-To: <810a540e0901221919t5e2f8f04heffd217ee4f668c5@mail.gmail.com> References: <810a540e0901221919t5e2f8f04heffd217ee4f668c5@mail.gmail.com> Message-ID: <080ecafd6e56311809ba500097bb4717@ruby-forum.com> > I have had some trouble > with ajax-heavy stuff but never took the time to sort it out. I had some trouble too at first. Some things that seem like they _should_ work just don't. But I seem to have gotten past it. If anyone has a specific problem post here, and I'll give it a try :) Or you can email me directly: paul (at) thoughtless --I hate spam-- (dot) ca -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Fri Jan 23 13:29:26 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 23 Jan 2009 18:29:26 +0000 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> Message-ID: <88fd8ddc0901231029k41f535cv89b877fa77d28901@mail.gmail.com> Have you tried setting the CUCUMBER_COLORS environment variable in your bash config on cygwin? 2009/1/23 James Byrne > My original observation wrt this problem was inaccurate. The same > behaviour is evidenced in both my Linux and cygwin environments. > Setting the environment variable "CUCUMBER_COLORS" in support/env.rb run > does not alter the behaviour of that run. > > As one expects, any environment variable set within a process will not > persist after that process terminates. I lack the experience in either > OS to say whether or not doing so should affect the setting process > itself or only those processes spawned by that parent after the setting > of the variable. > > I gathered from the cucumber documentation that the writer expected that > setting the environment in env.rb SHOULD have some effect. However, I > cannot say if that expectation was valid or not. > > I am not experiencing any problems with displaying colours or text > enhancements (within the limited ANSI palette) in either environment. > -- > 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 lists at ruby-forum.com Fri Jan 23 15:07:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 21:07:20 +0100 Subject: [rspec-users] Cucumber ENV setting in env.rb In-Reply-To: <88fd8ddc0901231029k41f535cv89b877fa77d28901@mail.gmail.com> References: <349b6602ad294c1c4c3000cbf67913c6@ruby-forum.com> <88fd8ddc0901221209m3498840do26b1a5a6689e1d1c@mail.gmail.com> <71166b3b0901221234m6137087chaa01d7a53692920c@mail.gmail.com> <31423f0b48c8520950af4a95957cdf1e@ruby-forum.com> <8d961d900901221406m199c24c3q7a622f223279011c@mail.gmail.com> <587af765943665bd9ef26b1ae67dede6@ruby-forum.com> <6c08411215424ef9a2fd442c66a5ebe9@ruby-forum.com> <88fd8ddc0901231029k41f535cv89b877fa77d28901@mail.gmail.com> Message-ID: <1644b8bcb8fc26a52c3afec443b2e039@ruby-forum.com> Andrew Premdas wrote: > Have you tried setting the CUCUMBER_COLORS environment variable in your > bash config on cygwin? James Byrne wrote: > I am working around this by manually setting the session environment > variable and I could make this solution permanent by altering > my .bashrc script. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 23 15:46:05 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 21:46:05 +0100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <4979F890.8000608@benmabey.com> References: <4979F890.8000608@benmabey.com> Message-ID: <6f81634f599b13345ced41074daceaa9@ruby-forum.com> Ben Mabey wrote: > > So... I'm curious what people's thoughts are. When writing acceptance > tests how do you choose which tool is best for the job? I often hear > people complaining about the GWT syntax and they see no benefit of it > over the frameworks that provide contexts (i.e rspec, shoulda, etc).[1] > In what cases, if any, do you think the GWT gets in the way and how? In > particular, if you are writing an app or lib whose customers/users are > all developers do you still think there is value in the GWT syntax that > Cucumber provides? > My own experience is quite limited, but I did start out trying to get what I desired done through TestUnit, then RSpec, then RSpec Story Runner and finally Cucumber. In the end it was Cucumber that clarified my approach for me, mainly by clearing away all (or at least most) of the nitty gritty details of configuring and using the tool itself. I found that, coming from a non OO programming background, that the degree of mastery required of the other tools mentioned, together with the effort I had to make to get the tool to behave as I wished (desires that were often malformed by lack of understanding in any case), distracted considerably from the task at hand, programming the application. I have progressed on my current project far, far more since discovering Cucumber this past November than in all the time before. The bifurcation between what and how seems far more natural to me with the Cucumber features/step definitions file split than with the unified expectation method/test steps of RSpec and the test method/assert statements of TestUnit. Cucumber feature files just seem to permit one to concentrate solely on "what" in the one case and then, with the separate step definitions file, deal with the "how" in the other, without crossing the line between the two. Given, When and Then seemed contrived and far too stiff to me to begin with. However, I discovered that much of my initial discomfort arose from too vague a conception of what is was that was desired. The benefit of GWT stylistic conventions is that it really does make one consider deeply where one is starting from, what one is actually trying to accomplish, and how, exactly, does one tell if it has been accomplished. If this sort of self-analysis is so ingrained that one need not think of it then GWT probably does not provide a measurable benefit. So, perhaps deeply experienced developers and programmers might not get as much from it as I have. On the other hand, I have frequently discovered in myself a lamentable tendency to believe that I understood what a problem was simply because I wanted to believe and not because of any demonstrable evidence to that effect. Sitting down and writing out what you believe to be the truth often reveals the flaws in ones assumptions. The GWT litany seems to provide a very useful, if formulaic, examination of exactly what one is setting out to accomplish thereby sometimes raising the question of why it needs to be done at all. I find that it thereby clears away much that is irrelevant to the question at hand. I also hold to the opinion that when writing an end user application the only testing that can be consider definitive is what is described as integration or acceptance testing. I accept that there are pragmatic reasons why, because of limited time and equipment resources, unit and functional tests are viewed as attractive alternatives. But, that should not blind one the the fact that they really are alternatives, chosen because of environmental considerations and not because of inherent superiority. The only test that means anything to an end user is one that shows the application works as intended in the environment it is deployed to. Libraries and utilities have a different audience and their testing is perhaps better handled solely in unit and functional tests, but I cannot say so with any conviction. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 23 17:24:49 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Fri, 23 Jan 2009 23:24:49 +0100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <6f81634f599b13345ced41074daceaa9@ruby-forum.com> References: <4979F890.8000608@benmabey.com> <6f81634f599b13345ced41074daceaa9@ruby-forum.com> Message-ID: <85d749698fd100ede5b31391ecf43be7@ruby-forum.com> > My own experience is quite limited, [...] Hi James, are you saying that you only use Cucumber and not RSpec at all? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jan 23 17:45:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 23 Jan 2009 23:45:23 +0100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <85d749698fd100ede5b31391ecf43be7@ruby-forum.com> References: <4979F890.8000608@benmabey.com> <6f81634f599b13345ced41074daceaa9@ruby-forum.com> <85d749698fd100ede5b31391ecf43be7@ruby-forum.com> Message-ID: <0e4dc8620551b0e11d50ef1cbb18827b@ruby-forum.com> Fernando Perez wrote: >> My own experience is quite limited, [...] > > Hi James, are you saying that you only use Cucumber and not RSpec at > all? No, I do use RSpec and TestUnit for that matter, but not to any extent at the present time. I find that cucumber features are much more conducive to driving out the design than RSpec expectations. Once the essence of the application is laid out and working then, if necessary, I will consider adding more technical type expectations via RSpec. Frankly, at the moment, I do not see a compelling case to move from step definitions into formal RSpec expectations. Again, my experience in these matters is limited and perhaps as it grows my appreciations will change as well. I do note however, that once one finds a tool that suits ones needs then it is somewhat inefficient to use another without some compelling advantage to be gained. What advantage does formal RSpec constructions provide over cucumber step definitions using RSpec and RSpec-Rails methods? -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Fri Jan 23 18:03:12 2009 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 23 Jan 2009 18:03:12 -0500 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <4979F890.8000608@benmabey.com> References: <4979F890.8000608@benmabey.com> Message-ID: <8373493B-A693-4797-8F71-6F75A9B6F419@deadorange.com> On 23/01/2009, at 12:04 PM, Ben Mabey wrote: > So... I'm curious what people's thoughts are. When writing > acceptance tests how do you choose which tool is best for the job? > I often hear people complaining about the GWT syntax and they see no > benefit of it over the frameworks that provide contexts (i.e rspec, > shoulda, etc).[1] In what cases, if any, do you think the GWT gets > in the way and how? In particular, if you are writing an app or lib > whose customers/users are all developers do you still think there is > value in the GWT syntax that Cucumber provides? I've been using RSpec since July, and love it. For the last few months, I've been reading most of the Cucumber posts on this list. Last week, I thought I'd give Cucumber a try. It feels like a really fantastic tool for determining business requirements, functionality, etc. From what I can tell though, there seems to be a lot of overlap between RSpec specs, and Cucumber features and stories. For that reason, I haven't delved much further into Cucumber, because I don't want to be repeating myself, and having to update two sets of files whenever I make a change. However, if that's not the case, please correct me! Nick From brent at fuglylogic.com Sat Jan 24 00:04:00 2009 From: brent at fuglylogic.com (Brent Snook) Date: Sat, 24 Jan 2009 16:04:00 +1100 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <4979F890.8000608@benmabey.com> References: <4979F890.8000608@benmabey.com> Message-ID: <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> I've been using story runner for the first time over the past 4 months or so and I've found the invaluable part to be the plain text support. Having a shared artifact that can be used by the customer, developers and testers is a huge boost towards achieving ubiquitous language. We use the story kickoff discussion to refine the language used in each scenario together, ensuring that the language makes sense to everyone and is consistent with other stories. In the sense that we want a way to store the feature/story in an executable format that we can all understand, a tool that supports plain text stories is the best choice for us. You can implement a scenario just as easily using plain rspec but then it becomes less accessible to other people in the team. If I was choosing a testing approach for a project that had technical people as customers I would still use the GWT format. I think it helps you continually focus on what you are really trying to achieve, otherwise it can be too easy to burrow down into the technical details and lose sight of that. No matter what the nature of project, every thing that you do is driven by the goal of adding some sort of value. Continually keeping that goal in mind helps you make better choices along the way. I agree with James that having that separation between the "what" and "how" is very useful. This approach is amenable to a more black box style of testing appropriate for acceptance tests. You should theoretically be able to completely change how your system works without touching the story/feature text. Your mileage would of course vary with this depending on whether or not you use a more declarative or imperative approach (as Ben describes in http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ ). My current recipe for testing spread is to automate the acceptance scenarios using a tool like story runner/cucumber and then use specs for targeted integration and unit level testing. The automated acceptance scenarios cover the main scenarios that the customer cares about while more specialised cases (or more technical aspects) are covered at the spec level. The specs will typically gravitate towards the white box end of the scale (describing the internals in more detail). - Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: From jonathan at parkerhill.com Sat Jan 24 00:05:40 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sat, 24 Jan 2009 00:05:40 -0500 Subject: [rspec-users] nokogiri selector help Message-ID: <51054F01-B154-4D21-9B11-96AEF17F7B15@parkerhill.com> hiya, i want the selector that would return a of a table if any td contains some text, so i can use it in click_link_within e.g. When I click the "show" link within the row containing "user at example.com" When /^I click the "(.+)" link within the row containing "(.+)"$/ do | link, text| selector = ?? click_link_within selector, link end ----------- and lets say the response contains ...
......
show foo bar user at example.com baz
... From voodoorai2000 at gmail.com Sat Jan 24 07:02:33 2009 From: voodoorai2000 at gmail.com (voodoorai2000) Date: Sat, 24 Jan 2009 04:02:33 -0800 (PST) Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> References: <4979F890.8000608@benmabey.com> <1e177fd10901232104q4f417e67gb8125d2cac3b24cf@mail.gmail.com> Message-ID: <21639914.post@talk.nabble.com> Brent Snook wrote: > > My current recipe for testing spread is to automate the acceptance > scenarios > using a tool like story runner/cucumber and then use specs for targeted > integration and unit level testing. The automated acceptance scenarios > cover > the main scenarios that the customer cares about while more specialised > cases (or more technical aspects) are covered at the spec level. The specs > will typically gravitate towards the white box end of the scale > (describing > the internals in more detail). > Hi, I think this is the most used approach nowadays, high level testing with features and more specific testing, that end users don't care about at the spec level. However, I prefer the distinction between, declarative stories and imperative stories, which I think can be applied to these two levels also. For example, the end user or the business person, most probably gets bored of reading a very long imperative story of clicking links and filling out forms, plus other setup steps that might seem unnecessary to him, but are needed sometimes due to a not fully correct design. Whilst a developer will appreciate an imperative story as it tells him/her exactly what to do. In my opinion, even at the spec level we can use the philosophy behind steps (re-usability) to reduce the redundancies inherent to spec definitions. Trivial cases of you should see this in the page (view specs), or this object should have this attribute set to true (model specs), happen all the time, and seem like a great place to use variables inside step definitions. Other cases are more complex and the use of regular expressions to encapsulate them all, can certainly be very difficult, maybe the type of an attribute is a datetime and needs to be parsed, thus not being completely re-usable to say a boolean field. Still we could account for this variations by checking the type of the attribute, at the expense of increasing the complexity of the step. This is where the argument continues, people support the view of writing repetitive specs considering that they are clearer. I still have doubts about this. In my opinion this will certainly be a complex problem to solve, but once we tackle it a number of times, it will become trivial, we'll figure out an elegant step_helper to deal with this situations, and move on to the next hard problem. The hardest problem seems to be agreeing on a language to write the stories including minimal variations in the syntax and grammar of our steps, to be able to come up with a re-usable set of step definitions out-of-the-box, a set of steps that will allow us to write stories and jump straight to the failing nature of a step, due to it not being implemented, once its implemented the step will be passing, without further need to write trivial step definitions. This would be a great time saver and allow us to concentrate on harder problems very specific to our application that are not accounted for in the general step definitions. In conclusion, when not to use cucumber? never. Always use cucumber, everyone always use cucumber, lets find this hard problems to re-use steps and tackle them together, find a solution and move on to the next road-blocker. Use Rspec but as the underlying language to make cucumber work, not to divide your application into model view controller specs, separate your tests into user and developer features/steps. Distributed testing is a must to use cucumber effectively, and the use of mocks is also unrefutable[1], but only as an alternative to an inability to test something in a classical way[2] Rai [1]http://rubyconf2008.confreaks.com/testing-heresies.html [2]http://martinfowler.com/articles/mocksArentStubs.html -- View this message in context: http://www.nabble.com/-Cucumber%2C-BDD--When-not-to-use-Cucumber--tp21628693p21639914.html Sent from the rspec-users mailing list archive at Nabble.com. From ben at benmabey.com Sat Jan 24 12:12:20 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 24 Jan 2009 10:12:20 -0700 Subject: [rspec-users] [Cucumber, BDD] When not to use Cucumber? In-Reply-To: <6f81634f599b13345ced41074daceaa9@ruby-forum.com> References: <4979F890.8000608@benmabey.com> <6f81634f599b13345ced41074daceaa9@ruby-forum.com> Message-ID: <497B4BF4.9020109@benmabey.com> See comments inline... On 1/23/09 1:46 PM, James Byrne wrote: > Ben Mabey wrote: > > >> So... I'm curious what people's thoughts are. When writing acceptance >> tests how do you choose which tool is best for the job? I often hear >> people complaining about the GWT syntax and they see no benefit of it >> over the frameworks that provide contexts (i.e rspec, shoulda, etc).[1] >> In what cases, if any, do you think the GWT gets in the way and how? In >> particular, if you are writing an app or lib whose customers/users are >> all developers do you still think there is value in the GWT syntax that >> Cucumber provides? >> >> > > My own experience is quite limited, but I did start out trying to get > what I desired done through TestUnit, then RSpec, then RSpec Story > Runner and finally Cucumber. In the end it was Cucumber that clarified > my approach for me, mainly by clearing away all (or at least most) of > the nitty gritty details of configuring and using the tool itself. I > found that, coming from a non OO programming background, that the degree > of mastery required of the other tools mentioned, together with the > effort I had to make to get the tool to behave as I wished (desires that > were often malformed by lack of understanding in any case), distracted > considerably from the task at hand, programming the application. > Interesting, thanks for sharing what your background is. I have seen other developers who don't have a strong OO background struggle with the concepts of isolation have a really hard time understanding how and why to use rspec. However, they seem to love Cucumber and it makes total sense to them. > I have progressed on my current project far, far more since discovering > Cucumber this past November than in all the time before. The > bifurcation between what and how seems far more natural to me with the > Cucumber features/step definitions file split than with the unified > expectation method/test steps of RSpec and the test method/assert > statements of TestUnit. Cucumber feature files just seem to permit one > to concentrate solely on "what" in the one case and then, with the > separate step definitions file, deal with the "how" in the other, > without crossing the line between the two. > Ahh.. that is a very good observation. When I write examples in rspec I start out with the example description first (obviously) but then I like to jump straight to my expectation. Meaning, I will say something like "dog.should be_happy" before I have even created the dog object. I like to do this for the same reason- I first write what I want and then I go a line above and create the how/given. A lot of people complain about the separation of code form story in plaintext features, but as you have pointed out that separation can be a very good thing. > Given, When and Then seemed contrived and far too stiff to me to begin > with. However, I discovered that much of my initial discomfort arose > from too vague a conception of what is was that was desired. The > benefit of GWT stylistic conventions is that it really does make one > consider deeply where one is starting from, what one is actually trying > to accomplish, and how, exactly, does one tell if it has been > accomplished. > > If this sort of self-analysis is so ingrained that one need not think of > it then GWT probably does not provide a measurable benefit. So, perhaps > deeply experienced developers and programmers might not get as much from > it as I have. > > On the other hand, I have frequently discovered in myself a lamentable > tendency to believe that I understood what a problem was simply because > I wanted to believe and not because of any demonstrable evidence to that > effect. Sitting down and writing out what you believe to be the truth > often reveals the flaws in ones assumptions. The GWT litany seems to > provide a very useful, if formulaic, examination of exactly what one is > setting out to accomplish thereby sometimes raising the question of why > it needs to be done at all. I find that it thereby clears away much > that is irrelevant to the question at hand. > +1. I totally agree with this. When it is difficult for me to write scenarios I find that the reason is that I fail to really understand what I am trying to accomplish. By flushing the acceptance criteria out in the GWT language I come out with a much better understanding of the problem and know exactly where to begin. > I also hold to the opinion that when writing an end user application the > only testing that can be consider definitive is what is described as > integration or acceptance testing. I accept that there are pragmatic > reasons why, because of limited time and equipment resources, unit and > functional tests are viewed as attractive alternatives. But, that > should not blind one the the fact that they really are alternatives, > chosen because of environmental considerations and not because of > inherent superiority. The only test that means anything to an end user > is one that shows the application works as intended in the environment > it is deployed to. > So here is where I disagree with you. :) I do agree that all the user cares about in the end is that the desired outcome is reached and the business value is provided. So with that mindset features are the only kind of tests a customer really cares about. Unit tests however are more for the developer. They aid in design and provide much more detailed documentation than the customer testes (acceptance tests). I don't think that cucumber features help me design my objects that much better unless I have focused object level examples telling me where the pain points are in my design. Eventually the customer will be greatful that you have unit tests (even if they don't know about them) because they will help lower the maintenace of the project by encouraging better design and providing tighter and more focused feedback on the smaller parts of the system. IMHO, of course. Thanks for the feedback, Ben From ben at benmabey.com Sat Jan 24 12:27:57 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 24 Jan 2009 10: