From dchelimsky at gmail.com Sun May 1 08:59:35 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 1 May 2011 08:59:35 -0400 Subject: [rspec-users] rspec-2.6.0.rc4 is released! [was rspec-2.6.0.rc3 is released] References: <6031EA46-C266-49F6-A56E-823E8BDC20D4@gmail.com> Message-ID: <2B3CDBB4-ECC8-406A-A30F-597B80D64853@gmail.com> There was a problem with the way the rc3 release was built that made it uninstallable, so I released rc4 this morning and all seems to work correctly. This release addresses issues that were raised in the rspec-core-2.6.0.rc2 release. ### rspec-core-2.6.0.rc4 full changelog: http://github.com/rspec/rspec-core/compare/v2.6.0.rc2...v2.6.0.rc4 Enhancements * Clean up messages for filters/tags. ### rspec-mocks-2.6.0.rc4 full changelog: http://github.com/rspec/rspec-mocks/compare/v2.6.0.rc2...v2.6.0.rc4 Bug fixes * Support multiple calls to any_instance in the same example (Sidu Ponnappa) ### rspec-rails-2.6.0.rc4 full changelog: http://github.com/rspec/rspec-rails/compare/v2.6.0.rc2...v2.6.0.rc4 Enhancements * Update the controller spec generated by the rails scaffold generator: - Add documentation to the generated spec - Use `any_instance` to avoid stubbing finders - Use real objects instead of `mock_model` * Update capybara integration to work with capy 0.4 and 1.0.0.beta * Decorate paths passed to `[append|prepend]_view_paths` with empty templates unless rendering views. (Mark Turner) From pablolmiranda at gmail.com Sun May 1 13:29:29 2011 From: pablolmiranda at gmail.com (Pablo L. de Miranda) Date: Sun, 1 May 2011 14:29:29 -0300 Subject: [rspec-users] Rails helper problem Message-ID: Hi guys, I'm building a application using subdomains feature like basecamp. To create the correct link reference I use a with_subdomain function whch take the subdmain name and create a subdomain name like subdomain.mydomain.com. So to teste that a account information view have the link to right domain I wrote the test above: describe SubdomainController do render_views it "should have a link to subdomain" do post :create, :subdomain => @attr response.should have_selector('a', :href => with_subdomain('test'), :content => with_subdomain('test')) end end But I get the error message below: NoMethodError: undefined method `with_subdomain' for # And I included the url_helper that has the function on my ApplicationController like this: class ApplicationController < ActionController::Base include UrlHelper end So, if you have any idea what is wrong, where I miss, please help me. Thanks, Pablo Lacerda de Miranda pablolmiranda at gmail.com +55 11 8701-1086 From chrismear at gmail.com Sun May 1 14:40:50 2011 From: chrismear at gmail.com (Chris Mear) Date: Sun, 1 May 2011 19:40:50 +0100 Subject: [rspec-users] Rails helper problem In-Reply-To: References: Message-ID: <700A5108-3BBE-46FC-A6B5-0242C6B3BA12@gmail.com> On 1 May 2011, at 18:29, Pablo L. de Miranda wrote: > I'm building a application using subdomains feature like basecamp. To > create the correct link reference I use a with_subdomain function whch > take the subdmain name and create a subdomain name like > subdomain.mydomain.com. > So to teste that a account information view have the link to right > domain I wrote the test above: > describe SubdomainController do > render_views > it "should have a link to subdomain" do > post :create, :subdomain => @attr > response.should have_selector('a', :href => > with_subdomain('test'), :content => with_subdomain('test')) > end > end > > But I get the error message below: > > NoMethodError: > undefined method `with_subdomain' for > # > > And I included the url_helper that has the function on my > ApplicationController like this: > > class ApplicationController < ActionController::Base > include UrlHelper > > end > > So, if you have any idea what is wrong, where I miss, please help me. You're calling the 'with_subdomain' method from within your spec file, but you haven't included the module it's defined in (UrlHelper) in your spec file. So, in the context of that spec, 'with_subdomain' is not defined -- the fact that you've included it in your ApplicationController class doesn't affect the code in the spec. As an aside, is this example intended to test that the 'with_subdomain' method is working correctly? Because it looks like you're specifying that "the output of with_subdomain should equal the output of with_subdomain", which will always pass, even if with_subdomain is actually outputting the wrong thing. That's fine if you're speccing with_subdomain elsewhere (i.e. in a helper spec), but I thought it was worth pointing out. Chris From pablolmiranda at gmail.com Sun May 1 15:00:19 2011 From: pablolmiranda at gmail.com (Pablo L. de Miranda) Date: Sun, 1 May 2011 16:00:19 -0300 Subject: [rspec-users] Rails helper problem In-Reply-To: <700A5108-3BBE-46FC-A6B5-0242C6B3BA12@gmail.com> References: <700A5108-3BBE-46FC-A6B5-0242C6B3BA12@gmail.com> Message-ID: Hi Chris, Thank you for your help, i inclued the UrlHelper on my spec_helper file and it worked. Yes the intent is just check with the link is created. I have other test to asset that with_subdomain build the correct path to subdomain. Thanks, Pablo Lacerda de Miranda pablolmiranda at gmail.com +55 11 8701-1086 On Sun, May 1, 2011 at 3:40 PM, Chris Mear wrote: > On 1 May 2011, at 18:29, Pablo L. de Miranda wrote: > >> I'm building a application using subdomains feature like basecamp. To >> create the correct link reference I use a with_subdomain function whch >> take the subdmain name and create a subdomain name like >> subdomain.mydomain.com. >> So to teste that a account information view have the link to right >> domain I wrote the test above: >> describe SubdomainController do >> ?render_views >> ?it "should have a link to subdomain" do >> ? ? ? ?post :create, :subdomain => @attr >> ? ? ? ?response.should have_selector('a', :href => >> with_subdomain('test'), :content => with_subdomain('test')) >> ? ? ?end >> end >> >> But I get the error message below: >> >> NoMethodError: >> ? ? ? undefined method `with_subdomain' for >> # >> >> And I included the url_helper that has the function on my >> ApplicationController like this: >> >> class ApplicationController < ActionController::Base >> ?include UrlHelper >> >> end >> >> So, if you have any idea what is wrong, where I miss, please help me. > > You're calling the 'with_subdomain' method from within your spec file, but you haven't included the module it's defined in (UrlHelper) in your spec file. So, in the context of that spec, 'with_subdomain' is not defined -- the fact that you've included it in your ApplicationController class doesn't affect the code in the spec. > > As an aside, is this example intended to test that the 'with_subdomain' method is working correctly? Because it looks like you're specifying that "the output of with_subdomain should equal the output of with_subdomain", which will always pass, even if with_subdomain is actually outputting the wrong thing. That's fine if you're speccing with_subdomain elsewhere (i.e. in a helper spec), but I thought it was worth pointing out. > > Chris > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sun May 1 19:58:25 2011 From: lists at ruby-forum.com (Matt S.) Date: Mon, 02 May 2011 01:58:25 +0200 Subject: [rspec-users] fields_for view spec In-Reply-To: <0ce10793933e6583810c4c9f3c9eb576@ruby-forum.com> References: <0ce10793933e6583810c4c9f3c9eb576@ruby-forum.com> Message-ID: <5ece8b4cf3ad74537eee6581592c336e@ruby-forum.com> 1) Is there a way to make this trivial example spec to pass? (If so, how?) 2) Advice: I would like to write more view specs, especially on views for models with more complex relationships. Is it worth it? (The reason I ask this somewhat rhetorical question is because I cannot find any examples of this on the web and have tried about everything I can think of, but I still can't get view specs containing nested model forms to pass, using fields_for on models with accepts_nested_attributes_for.) Much thanks!!! Matt Smith #spec/views/assets/new.html.erb_spec.rb describe "assets/new.html.erb" do let(:asset) { mock_model("Asset").as_new_record.as_null_object } let(:owner) { mock_model("Owner").as_new_record.as_null_object } before(:each) do asset.stub(:owner => owner) assign(:asset, asset) end it "renders new asset form with owner attributes" do render assert_select "form[method=post][action=?]", assets_path do assert_select "input[type=text][name='asset[owner_attributes][name]']" end end end #app/views/assets/new.html.erb <%= form_for(@asset) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.fields_for :owner do |owner_fields| %>
<%= owner_fields.label :name %> <%= owner_fields.text_field :name %>
<% end %>
<%= f.submit %>
<% end %> # Where the relationship will be the following.... class Asset < ActiveRecord::Base has_one :owner accepts_nested_attributes_for :owner end class Owner < ActiveRecord::Base belongs_to :asset end class AssetController < ApplicationController def new @asset = Asset.new @asset.build_owner end end -- Posted via http://www.ruby-forum.com/. From antsmailinglist at gmail.com Mon May 2 07:51:24 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Mon, 2 May 2011 13:51:24 +0200 Subject: [rspec-users] HTTP Status 406 When Testing :json Message-ID: Hello all, My first question, in my controllers, do I need to test respond_to is returning the correct data for its mime-type? In my controller spec I have it "creates a list of available types for that category" do xhr :get, :index_available, :category_id => 1, :format => :json assigns[:types].should have(1).record end and in my logs I see (406 Not acceptable....) Processing TypesController#index_available to json (for 0.0.0.0 at 2011-05-02 13:20:01) [GET] Parameters: {"category_id"=>"1"} Completed in 1ms (View: 0, DB: 0) | *406* Not Acceptable [ http://test.host/categories/1/types/index_available.json] SQL (0.1ms) ROLLBACK SQL (0.0ms) BEGIN But I get a green pass. If I change :format => :json to 'json', I get a load of errors (which I have mentioned before on this list but haven't had time to address the situation) /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in `each' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in `map' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in `to_json' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in `encode' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in `__send__' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in `encode' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/object.rb:4:in `to_json' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in `encode' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in `__send__' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in `encode' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in `to_json' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in `map' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in `to_json' /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:30:in `index_available' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in `call' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in `custom' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in `call' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in `respond' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in `each' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in `respond' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:107:in `respond_to' /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:29:in `index_available' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in `send' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in `perform_action_without_filters' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:617:in `call_filters' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in `ms' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in `ms' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/rescue.rb:160:in `perform_action_without_flash' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/flash.rb:151:in `perform_action' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in `send' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in `process_without_filters' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:606:in `process' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:567:in `process_with_test' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:447:in `process' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:398:in `get' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in `__send__' /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in `xhr' ./spec/controllers/types_controller_spec.rb:34: So, two pronged question, do I need to test :json (seeing as I'm not testing the contents) and can anyone shed any light on my 406 and/or the errors when changing the format to 'json' Many thanks -ants -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckponnappa at gmail.com Mon May 2 08:30:23 2011 From: ckponnappa at gmail.com (Sidu Ponnappa) Date: Mon, 2 May 2011 18:00:23 +0530 Subject: [rspec-users] HTTP Status 406 When Testing :json In-Reply-To: References: Message-ID: Hi, When testing Rails APIs, always assert on response codes and where relevant, the Location, Content-Type and other headers. We wound up doing this on every single project and so extracted it into a gem that you might find useful: https://github.com/c42/rspec-http Best, Sidu. http://c42.in http://about.me/ponnappa On 2 May 2011 17:21, Ants Pants wrote: > Hello all, > > My first question, in my controllers, do I need to test respond_to is > returning the correct data for its mime-type? > > In my controller spec I have > > it "creates a list of available types for that category" do > ????? xhr :get, :index_available, :category_id => 1, :format => :json > ????? assigns[:types].should have(1).record > end > > and in my logs I see (406 Not acceptable....) > > Processing TypesController#index_available to json (for 0.0.0.0 at > 2011-05-02 13:20:01) [GET] > ? Parameters: {"category_id"=>"1"} > Completed in 1ms (View: 0, DB: 0) | 406 Not Acceptable > [http://test.host/categories/1/types/index_available.json] > ? SQL (0.1ms)?? ROLLBACK > ? SQL (0.0ms)?? BEGIN > > But I get a green pass. > > If I change :format => :json to 'json', I get a load of errors (which I have > mentioned before on this list but haven't had time to address the situation) > > > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in > `each' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in > `map' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in > `to_json' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in > `encode' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > `__send__' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > `encode' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/object.rb:4:in > `to_json' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in > `encode' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > `__send__' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > `encode' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in > `to_json' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in > `map' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in > `to_json' > /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:30:in > `index_available' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in > `call' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in > `custom' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in > `call' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in > `respond' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in > `each' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in > `respond' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:107:in > `respond_to' > /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:29:in > `index_available' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in > `send' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in > `perform_action_without_filters' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:617:in > `call_filters' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:610:in > `perform_action_without_benchmark' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in > `ms' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in > `ms' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/rescue.rb:160:in > `perform_action_without_flash' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/flash.rb:151:in > `perform_action' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in > `send' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in > `process_without_filters' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:606:in > `process' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:567:in > `process_with_test' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:447:in > `process' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:398:in > `get' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in > `__send__' > /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in > `xhr' > ./spec/controllers/types_controller_spec.rb:34: > > So, two pronged question, do I need to test :json (seeing as I'm not testing > the contents) and can anyone shed any light on my 406 and/or the errors when > changing the format to 'json' > > Many thanks > > -ants > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ckponnappa at gmail.com Mon May 2 08:35:15 2011 From: ckponnappa at gmail.com (Sidu Ponnappa) Date: Mon, 2 May 2011 18:05:15 +0530 Subject: [rspec-users] HTTP Status 406 When Testing :json In-Reply-To: References: Message-ID: By the way, asserting on the response code will only help ensure that you don't get green specs even though you're request fails with a 406 (or something similar). You're getting a 406 because whatever the Accepts header is on that request ('application/json' I'd presume) does not have a responds_to clause that matches it. Not sure about :json vs 'json.' On 2 May 2011 18:00, Sidu Ponnappa wrote: > Hi, > > When testing Rails APIs, always assert on response codes and where > relevant, the Location, Content-Type and other headers. We wound up > doing this on every single project and so extracted it into a gem that > you might find useful: https://github.com/c42/rspec-http > > Best, > Sidu. > http://c42.in > http://about.me/ponnappa > > > On 2 May 2011 17:21, Ants Pants wrote: >> Hello all, >> >> My first question, in my controllers, do I need to test respond_to is >> returning the correct data for its mime-type? >> >> In my controller spec I have >> >> it "creates a list of available types for that category" do >> ????? xhr :get, :index_available, :category_id => 1, :format => :json >> ????? assigns[:types].should have(1).record >> end >> >> and in my logs I see (406 Not acceptable....) >> >> Processing TypesController#index_available to json (for 0.0.0.0 at >> 2011-05-02 13:20:01) [GET] >> ? Parameters: {"category_id"=>"1"} >> Completed in 1ms (View: 0, DB: 0) | 406 Not Acceptable >> [http://test.host/categories/1/types/index_available.json] >> ? SQL (0.1ms)?? ROLLBACK >> ? SQL (0.0ms)?? BEGIN >> >> But I get a green pass. >> >> If I change :format => :json to 'json', I get a load of errors (which I have >> mentioned before on this list but haven't had time to address the situation) >> >> >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in >> `each' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in >> `map' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in >> `to_json' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in >> `encode' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in >> `__send__' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in >> `encode' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/object.rb:4:in >> `to_json' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in >> `encode' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in >> `__send__' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in >> `encode' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in >> `to_json' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in >> `map' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in >> `to_json' >> /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:30:in >> `index_available' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in >> `call' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in >> `custom' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in >> `call' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in >> `respond' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in >> `each' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in >> `respond' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:107:in >> `respond_to' >> /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:29:in >> `index_available' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in >> `send' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in >> `perform_action_without_filters' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:617:in >> `call_filters' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:610:in >> `perform_action_without_benchmark' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in >> `perform_action_without_rescue' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in >> `ms' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in >> `ms' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in >> `perform_action_without_rescue' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/rescue.rb:160:in >> `perform_action_without_flash' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/flash.rb:151:in >> `perform_action' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in >> `send' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in >> `process_without_filters' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/filters.rb:606:in >> `process' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:567:in >> `process_with_test' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:447:in >> `process' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:398:in >> `get' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in >> `__send__' >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311/gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in >> `xhr' >> ./spec/controllers/types_controller_spec.rb:34: >> >> So, two pronged question, do I need to test :json (seeing as I'm not testing >> the contents) and can anyone shed any light on my 406 and/or the errors when >> changing the format to 'json' >> >> Many thanks >> >> -ants >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From pablolmiranda at gmail.com Mon May 2 08:53:35 2011 From: pablolmiranda at gmail.com (Pablo L. de Miranda) Date: Mon, 2 May 2011 09:53:35 -0300 Subject: [rspec-users] Problems with integration test Message-ID: Hi guys, I'm writing a integration test and i'm still have problems with a form field. The RSpec continues to show me a message bellow: Failure/Error: fill_in :password_confirmation, :with => @attr[:password_confirmation] Webrat::NotFoundError: Could not find field: :password_confirmation But the field is there, look the field code:
<%= f.label :password_confirmation %> <%= f.password_field :password_confirmation %>
This field create the follow HTML code for me:
And it works fine when I use the browser. Please, Has anybody idea of what's happening? Att, Pablo Lacerda de Miranda pablolmiranda at gmail.com +55 11 8701-1086 From dchelimsky at gmail.com Mon May 2 09:26:02 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 May 2011 08:26:02 -0500 Subject: [rspec-users] rspec contribution at railsconf? In-Reply-To: References: Message-ID: <637E81B9-9DA4-402E-8360-D9690B89E856@gmail.com> On Apr 28, 2011, at 8:41 PM, Jed Schneider wrote: > Hi, > > I was curious if there was any interest in organizing a 'bugmash', if you will, of any outstanding rspec features or issues during railsconf. (maybe there is something planned that i missed?) > > I'm not sure how much there is to be done, but if there is interest, and in particular if there is some guidance on getting going towards contributing, I would personally be interested in both participating and working with BohConf to organize a time and space for it. > > -- > Jed Schneider Hey Jed - thanks for the offer. I'd love to see something like this happen, but I'm seriously overcommitted for the next couple of weeks so I won't be able to help assist. I've put out some feelers and get back to you. Cheers, David From chrismear at gmail.com Mon May 2 12:13:27 2011 From: chrismear at gmail.com (Chris Mear) Date: Mon, 2 May 2011 17:13:27 +0100 Subject: [rspec-users] Problems with integration test In-Reply-To: References: Message-ID: On 2 May 2011 13:53, Pablo L. de Miranda wrote: > Hi guys, > > I'm writing a integration test and i'm still have problems with a form field. > The RSpec continues to show me a message bellow: > > Failure/Error: fill_in :password_confirmation, :with => > @attr[:password_confirmation] > ? ? Webrat::NotFoundError: > ? ? ? Could not find field: :password_confirmation > > But the field is there, look the field code: > >
> ? ?<%= f.label :password_confirmation %> > ? ?<%= f.password_field :password_confirmation %> > ?
> > This field create the follow HTML code for me: > >
> ? ? > ? ? name="subdomain[password_confirmation]" size="30" type="password" /> > ?
> > And it works fine when I use the browser. > > Please, Has anybody idea of what's happening? Webrat only sees the generated HTML, not the view code. In particular, it finds the field based on either the text of an associated label, or the 'name' attribute of the field: http://rdoc.info/github/brynary/webrat/master/Webrat/Scope:fill_in In your case, the text of the associated label is "Password confirmation" and the 'name' attribute of the field is "subdomain[password_confirmation]" (which you can check by looking at the generated HTML). So you need to pass one of those to the 'fill_in' method. Chris From chrismear at gmail.com Mon May 2 12:22:00 2011 From: chrismear at gmail.com (Chris Mear) Date: Mon, 2 May 2011 17:22:00 +0100 Subject: [rspec-users] fields_for view spec In-Reply-To: <5ece8b4cf3ad74537eee6581592c336e@ruby-forum.com> References: <0ce10793933e6583810c4c9f3c9eb576@ruby-forum.com> <5ece8b4cf3ad74537eee6581592c336e@ruby-forum.com> Message-ID: On 2 May 2011 00:58, Matt S. wrote: > 1) Is there a way to make this trivial example spec to pass? (If so, > how?) > > 2) Advice: I would like to write more view specs, especially on views > for models with more complex relationships. Is it worth it? > > (The reason I ask this somewhat rhetorical question is because I cannot > find any examples of this on the web and have tried about everything I > can think of, but I still can't get view specs containing nested model > forms to pass, using fields_for on models with > accepts_nested_attributes_for.) > > Much thanks!!! > > Matt Smith > > #spec/views/assets/new.html.erb_spec.rb > describe "assets/new.html.erb" do > ?let(:asset) { mock_model("Asset").as_new_record.as_null_object } > ?let(:owner) { mock_model("Owner").as_new_record.as_null_object } > > ?before(:each) do > ? ?asset.stub(:owner => owner) > ? ?assign(:asset, asset) > ?end > > ?it "renders new asset form with owner attributes" do > ? ?render > ? ?assert_select "form[method=post][action=?]", assets_path do > ? ? ?assert_select > "input[type=text][name='asset[owner_attributes][name]']" > ? ?end > ?end > end > > #app/views/assets/new.html.erb > <%= form_for(@asset) do |f| %> > > ?
> ? ?<%= f.label :name %>
> ? ?<%= f.text_field :name %> > ?
> > ?<%= f.fields_for :owner do |owner_fields| %> > ? ?
> ? ? ?<%= owner_fields.label :name %> > ? ? ?<%= owner_fields.text_field :name %> > ? ?
> ?<% end %> > > ?
> ? ?<%= f.submit %> > ?
> <% end %> > > # Where the relationship will be the following.... > class Asset < ActiveRecord::Base > ?has_one :owner > ?accepts_nested_attributes_for :owner > end > > class Owner < ActiveRecord::Base > ?belongs_to :asset > end > > class AssetController < ApplicationController > ?def new > ? ?@asset = Asset.new > ? ?@asset.build_owner > ?end > end Can you get the contents of 'response.body' from inside that spec example, so we can see what's being rendered when the spec is run? Chris From dmcinnes at attinteractive.com Mon May 2 13:02:52 2011 From: dmcinnes at attinteractive.com (Doug McInnes) Date: Mon, 2 May 2011 10:02:52 -0700 Subject: [rspec-users] Stubbing corner case In-Reply-To: References: <51D117D7-671B-49AE-BD7B-4ED3B52D9BBA@attinteractive.com> <3F591AAE-E1F2-4F88-B532-8AC03C392EA5@gmail.com> Message-ID: <17C00908-3462-46E4-BC03-14AE66AAC7A2@attinteractive.com> On Apr 25, 2011, at 10:51 AM, Doug McInnes wrote: > Sure! > Here's the Gist: > > https://gist.github.com/940868 > > It's works in Rspec 2.5.1, but not in Rspec 1.3.2 > > Doug > > > On Apr 23, 2011, at 3:00 PM, David Chelimsky wrote: > >> On Apr 22, 2011, at 4:58 PM, Doug McInnes wrote: >> >>> Hi! >>> >>> I was just talking to @dchelimsky over Twitter about a weird corner case we've run into on 1.3.1 (I've also been able to reproduce it in 1.3.2) >>> >>> So we're using this gem called ClassyStruct that's a higher performing OpenStruct: >>> https://github.com/amikula/classy_struct >>> >>> Basically it acts the same as OpenStruct but defines methods on the object's class instead of the object itself on the fly. >>> When it receives a call that hits method_missing it calls attr_accessor on the method name then passes the call on to the object. >>> >>> Our problem comes from having one spec that stubs out a call to the object: >>> foo.stub! :bar => 'test' >>> >>> and later in another spec file trying to set the same method with a value then having our code use that value: >>> # spec >>> foo.bar = 'other test' >>> # code >>> puts "#{foo.bar} baz" >>> >>> So our expectation is that foo.bar will return 'other test'. Instead it hits the old stub on foo which calls method_missing which is picked up again by ClassyStruct causing it to fire off attr_accessor again then passing the method through causing the stub to call method_missing and on and on finally giving us a "stack level too deep" error. >>> >>> The crux of the problem is that ClassyStruct is adding a method to the class after Rspec has added the same method to the instance. >>> >>> As I said it's a very weird corner case because we're calling attr_accessor on a class that already has objects floating around. The easiest way to fix this is to use stub! in both places. >>> >>> Regardless we were surprised that the proxy sticks around after a test run. What is the reason for keeping it around? >> >> There's no intent to keep it around, so there is a bug at play here, but let's see if we can narrow it down. >> >> Can you post (gist or pastie) an example that I can just run as/is to see the behavior you're seeing? > Any ideas on this issue? Here's the code: class TestClass end # our use case is with a stub on a constant TEST = TestClass.new describe TestClass do it "works before the stub" do TestClass.send(:attr_accessor, :foo) TEST.foo = :baz TEST.foo.should == :baz TestClass.send(:remove_method, 'foo') TestClass.send(:remove_method, 'foo=') end it "has a stubbed method" do TEST.stub! :foo => :bar TEST.foo.should == :bar end it "fails after the stub" do TestClass.send(:attr_accessor, :foo) TEST.foo = :baz TEST.foo.should == :baz end end And the console output: ~/tmp $ ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0] ~/tmp $ spec -v rspec 1.3.2 ~/tmp $ spec test.rb ..F 1) NoMethodError in 'TestClass fails after the stub' undefined method `foo' for # test.rb:28:in `block (2 levels) in ' Finished in 0.046678 seconds 3 examples, 1 failure ~/tmp $ rspec -v 2.5.1 ~/tmp $ rspec test.rb ... Finished in 0.00154 seconds 3 examples, 0 failures As I said this is a weird corner case :) Thanks, Doug From pablolmiranda at gmail.com Mon May 2 13:04:00 2011 From: pablolmiranda at gmail.com (Pablo L. de Miranda) Date: Mon, 2 May 2011 14:04:00 -0300 Subject: [rspec-users] Problems with integration test In-Reply-To: References: Message-ID: Hi Chris, Thank your for your explanation, but I have a doubt about this. I'm printing the method test bellow: it "should create a new account" do lambda do visit new_subdomain_path response.should render_template('subdomains/new') fill_in :nome, :with => @attr[:name] fill_in :responsavel, :with => @attr[:responsable] fill_in :email, :with => @attr[:email] fill_in :password, :with => @attr[:password] fill_in :password_confirmation, :with => @attr[:password_confirmation] click_button end.should change(Subdomain, :count).by(1) end My test recognize all the field except the password confirmation field, why? This is why I can't sleep, why just this field in particular? Thanks, Pablo From chrismear at gmail.com Mon May 2 13:19:02 2011 From: chrismear at gmail.com (Chris Mear) Date: Mon, 2 May 2011 18:19:02 +0100 Subject: [rspec-users] Problems with integration test In-Reply-To: References: Message-ID: <1B48014A-DDF4-44CF-B294-7BECB528E1F1@gmail.com> On 2 May 2011, at 18:04, "Pablo L. de Miranda" wrote: > Hi Chris, > > Thank your for your explanation, but I have a doubt about this. I'm > printing the method test bellow: > it "should create a new account" do > lambda do > visit new_subdomain_path > response.should render_template('subdomains/new') > fill_in :nome, :with => @attr[:name] > fill_in :responsavel, :with => @attr[:responsable] > fill_in :email, :with => @attr[:email] > fill_in :password, :with => @attr[:password] > fill_in :password_confirmation, :with => @attr[:password_confirmation] > click_button > end.should change(Subdomain, :count).by(1) > end > > My test recognize all the field except the password confirmation > field, why? This is why I can't sleep, why just this field in > particular? Probably because that's the only attribute with a two-word name. Webrat is matching the others based on their label (because 'email' and 'Email' match case-insensitively), but 'password_confirmation' and 'Password confirmation' do not match, because '_' != ' '. Chris > > Thanks, > > Pablo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pablolmiranda at gmail.com Mon May 2 14:47:15 2011 From: pablolmiranda at gmail.com (Pablo L. de Miranda) Date: Mon, 2 May 2011 15:47:15 -0300 Subject: [rspec-users] Problems with integration test In-Reply-To: <1B48014A-DDF4-44CF-B294-7BECB528E1F1@gmail.com> References: <1B48014A-DDF4-44CF-B294-7BECB528E1F1@gmail.com> Message-ID: Chris, Thank you man, I replaced all my symbol for field name references, and worked fine. Pablo From jeffdeville at gmail.com Sun May 1 21:29:17 2011 From: jeffdeville at gmail.com (JDeville) Date: Sun, 1 May 2011 18:29:17 -0700 (PDT) Subject: [rspec-users] rspec-rails not making routes accessible since I *think* 2.2.1 (Currently using 2.5) Message-ID: <14395555.4097.1304299757639.JavaMail.geo-discussion-forums@yqhc1> I'm trying to use: get path_to_route which had been working previously. Was this an intentional change? Can I get this behavior back, or was there a reason it was removed. Thanks all. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon May 2 23:45:48 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 May 2011 22:45:48 -0500 Subject: [rspec-users] How can I execute rspec directly from ruby code? In-Reply-To: References: Message-ID: <542CA902-34E1-426A-AA98-99231C6216DD@gmail.com> On Apr 28, 2011, at 1:33 PM, Pablo Cantero wrote: > Hi > > Can I execute rspec directly from ruby code? I would like to do it > similar I can do using Test::Unit > > Test::Unit::UI::Console::TestRunner.run(MySuite.new(MyTestCase)) > > I was looking on internet how to execute it, but I wasn't found it > > Is it possible? Not today. There are some hax you can do, but there is nothing supported. Please file a feature request at http://github.com/rspec/rspec-core/issues if you'd like to see it considered for a future release. Cheers, David From dchelimsky at gmail.com Mon May 2 23:55:04 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 May 2011 22:55:04 -0500 Subject: [rspec-users] rspec-rails not making routes accessible since I *think* 2.2.1 (Currently using 2.5) In-Reply-To: <14395555.4097.1304299757639.JavaMail.geo-discussion-forums@yqhc1> References: <14395555.4097.1304299757639.JavaMail.geo-discussion-forums@yqhc1> Message-ID: <196C171A-68DC-4614-975E-32194ADD734C@gmail.com> On May 1, 2011, at 8:29 PM, JDeville wrote: > I'm trying to use: > get path_to_route What kind of spec? Controller? Request? View? > which had been working previously. Was this an intentional change? Nope. > Can I get this behavior back, Assuming it's actually missing, yes, but we've got named routes in the generated request, controller, and view specs, and they all pass. Please post a more complete example (gist or pastie is fine) and the full backtrace (run rspec spec --backtrace). Cheers, David From antsmailinglist at gmail.com Tue May 3 01:27:21 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Tue, 3 May 2011 07:27:21 +0200 Subject: [rspec-users] HTTP Status 406 When Testing :json In-Reply-To: References: Message-ID: On 2 May 2011 14:35, Sidu Ponnappa wrote: > By the way, asserting on the response code will only help ensure that > you don't get green specs > even though you're request fails with a 406 (or something similar). > You're getting a 406 > because whatever the Accepts header is on that request > ('application/json' I'd presume) does not have a responds_to clause > that matches it. Not sure about :json vs 'json.' > > On 2 May 2011 18:00, Sidu Ponnappa wrote: > > Hi, > > > > When testing Rails APIs, always assert on response codes and where > > relevant, the Location, Content-Type and other headers. We wound up > > doing this on every single project and so extracted it into a gem that > > you might find useful: https://github.com/c42/rspec-http > > > > Best, > > Sidu. > > http://c42.in > > http://about.me/ponnappa > > > > > > On 2 May 2011 17:21, Ants Pants wrote: > >> Hello all, > >> > >> My first question, in my controllers, do I need to test respond_to is > >> returning the correct data for its mime-type? > >> > >> In my controller spec I have > >> > >> it "creates a list of available types for that category" do > >> xhr :get, :index_available, :category_id => 1, :format => :json > >> assigns[:types].should have(1).record > >> end > >> > >> and in my logs I see (406 Not acceptable....) > >> > >> Processing TypesController#index_available to json (for 0.0.0.0 at > >> 2011-05-02 13:20:01) [GET] > >> Parameters: {"category_id"=>"1"} > >> Completed in 1ms (View: 0, DB: 0) | 406 Not Acceptable > >> [http://test.host/categories/1/types/index_available.json] > >> SQL (0.1ms) ROLLBACK > >> SQL (0.0ms) BEGIN > >> > >> But I get a green pass. > >> > >> If I change :format => :json to 'json', I get a load of errors (which I > have > >> mentioned before on this list but haven't had time to address the > situation) > >> > >> > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in > >> `each' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in > >> `map' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoders/hash.rb:37:in > >> `to_json' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in > >> `encode' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > >> `__send__' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > >> `encode' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoders/object.rb:4:in > >> `to_json' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:79:in > >> `encode' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > >> `__send__' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoding.rb:18:in > >> `encode' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in > >> `to_json' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in > >> `map' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/json/encoders/enumerable.rb:11:in > >> `to_json' > >> > /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:30:in > >> `index_available' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in > >> `call' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:135:in > >> `custom' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in > >> `call' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:179:in > >> `respond' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in > >> `each' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:173:in > >> `respond' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/mime_responds.rb:107:in > >> `respond_to' > >> > /home/anthony/Development/websites/ruby/GMFT/trunk/app/controllers/types_controller.rb:29:in > >> `index_available' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in > >> `send' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in > >> `perform_action_without_filters' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/filters.rb:617:in > >> `call_filters' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/filters.rb:610:in > >> `perform_action_without_benchmark' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in > >> `perform_action_without_rescue' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in > >> `ms' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/activesupport-2.3.11/lib/active_support/core_ext/benchmark.rb:17:in > >> `ms' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/benchmarking.rb:68:in > >> `perform_action_without_rescue' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/rescue.rb:160:in > >> `perform_action_without_flash' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/flash.rb:151:in > >> `perform_action' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in > >> `send' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/base.rb:532:in > >> `process_without_filters' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/filters.rb:606:in > >> `process' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/test_process.rb:567:in > >> `process_with_test' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/test_process.rb:447:in > >> `process' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/test_process.rb:398:in > >> `get' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in > >> `__send__' > >> /home/anthony/.rvm/gems/ruby-1.8.7-p302 at rails2311 > /gems/actionpack-2.3.11/lib/action_controller/test_process.rb:453:in > >> `xhr' > >> ./spec/controllers/types_controller_spec.rb:34: > >> > >> So, two pronged question, do I need to test :json (seeing as I'm not > testing > >> the contents) and can anyone shed any light on my 406 and/or the errors > when > >> changing the format to 'json' > >> > >> Many thanks > >> > >> -ants > >> > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I forgot to add my controller as I render the json inline and not in a template. I wonder if this has a bearing?! def index_available @types = @category.types.available respond_to do |format| format.json { render :json => @types.to_json(:only => [:id, :name]) } format.html end end -ants -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue May 3 10:05:25 2011 From: lists at ruby-forum.com (Matt S.) Date: Tue, 03 May 2011 16:05:25 +0200 Subject: [rspec-users] fields_for view spec In-Reply-To: References: <0ce10793933e6583810c4c9f3c9eb576@ruby-forum.com> <5ece8b4cf3ad74537eee6581592c336e@ruby-forum.com> Message-ID: <465aac15acb8ae7309c651853d5fa863@ruby-forum.com> Chris Mear wrote in post #996234: > On 2 May 2011 00:58, Matt S. wrote: >> accepts_nested_attributes_for.) >> before(:each) do >> end >> <%= f.fields_for :owner do |owner_fields| %> >> >> class AssetController < ApplicationController >> def new >> @asset = Asset.new >> @asset.build_owner >> end >> end > > Can you get the contents of 'response.body' from inside that spec > example, so we can see what's being rendered when the spec is run? > > Chris Thanks Chis, Here is the rendered content:

New asset


Owner

Back As you can see nothing comes up for the fields_for :owner block. I have tried stubbing owner_attributes and owner_attributes=, as your previously suggested, but I saw no change. It does seem that I need to mock something else on the assets model to get this to work. I have started combing through the the action_view source code but have not run into anything to get me on the right trail yet, although I have learned a lot about other things! If you want to see everything you can do a 'git clone git://github.com/matthewcalebsmith/asset_owner.git' to get the whole mock project, in case I have left out any pertinent details. Thank you! Matt Smith -- Posted via http://www.ruby-forum.com/. From chrismear at gmail.com Tue May 3 14:43:49 2011 From: chrismear at gmail.com (Chris Mear) Date: Tue, 3 May 2011 19:43:49 +0100 Subject: [rspec-users] fields_for view spec In-Reply-To: <465aac15acb8ae7309c651853d5fa863@ruby-forum.com> References: <0ce10793933e6583810c4c9f3c9eb576@ruby-forum.com> <5ece8b4cf3ad74537eee6581592c336e@ruby-forum.com> <465aac15acb8ae7309c651853d5fa863@ruby-forum.com> Message-ID: <995242B3-A7E4-4F20-B17E-9689F00D1ECB@gmail.com> On 3 May 2011, at 15:05, Matt S. wrote: > Chris Mear wrote in post #996234: >> On 2 May 2011 00:58, Matt S. wrote: >>> accepts_nested_attributes_for.) >>> before(:each) do >>> end >>> <%= f.fields_for :owner do |owner_fields| %> >>> >>> class AssetController < ApplicationController >>> def new >>> @asset = Asset.new >>> @asset.build_owner >>> end >>> end >> >> Can you get the contents of 'response.body' from inside that spec >> example, so we can see what's being rendered when the spec is run? >> >> Chris > > Thanks Chis, > > Here is the rendered content: > >

New asset

> >
id="new_asset" method="post">
style="margin:0;padding:0;display:inline"> type="hidden" value="✓" />
> >
>
> value="Asset_#<RSpec::Core::ExampleGroup::Nested_2:0x00000004217d08>" > /> >
> >

Owner

> >
> >
>
> > Back > > > As you can see nothing comes up for the fields_for :owner block. I have > tried stubbing owner_attributes and owner_attributes=, as your > previously suggested, but I saw no change. It does seem that I need to > mock something else on the assets model to get this to work. I have > started combing through the the action_view source code but have not run > into anything to get me on the right trail yet, although I have learned > a lot about other things! > > If you want to see everything you can do a 'git clone > git://github.com/matthewcalebsmith/asset_owner.git' to get the whole > mock project, in case I have left out any pertinent details. The following patch makes the example pass for me. The key change was to take out the #as_null_object call on your mock models. That seems to be interfering with Action View's detection of nested attributes acceptance, but I'm not sure exactly why. Chris From 0829776dd45b3a0c57134f7af5d4f21feebe5fd7 Mon Sep 17 00:00:00 2001 From: Chris Mear Date: Tue, 3 May 2011 18:11:40 +0100 Subject: [PATCH] Fix stubbing for nested form in assets/new. --- spec/views/assets/new.html.erb_spec.rb | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/views/assets/new.html.erb_spec.rb b/spec/views/assets/new.html.erb_spec.rb index b8845fe..9bf3b26 100644 --- a/spec/views/assets/new.html.erb_spec.rb +++ b/spec/views/assets/new.html.erb_spec.rb @@ -1,13 +1,18 @@ require 'spec_helper' describe "assets/new.html.erb" do - let(:asset) { mock_model("Asset").as_new_record.as_null_object } - let(:owner) { mock_model("Owner").as_new_record.as_null_object } + let(:asset) { mock_model("Asset").as_new_record } + let(:owner) { mock_model("Owner").as_new_record } before(:each) do asset.stub(:owner => owner) - asset.accepts_nested_attributes_for :owner + asset.stub(:name) + asset.stub(:owner_attributes=) + + owner.stub(:name) + assign(:asset, asset) + end it "renders new asset form with owner attributes" do -- 1.7.4.4 From lists at ruby-forum.com Tue May 3 15:05:18 2011 From: lists at ruby-forum.com (Pablo Cantero) Date: Tue, 03 May 2011 21:05:18 +0200 Subject: [rspec-users] How can I execute rspec directly from ruby code? In-Reply-To: <542CA902-34E1-426A-AA98-99231C6216DD@gmail.com> References: <542CA902-34E1-426A-AA98-99231C6216DD@gmail.com> Message-ID: <38fb629b7fcfde552a0682bd9a7b3cf0@ruby-forum.com> Hi Thanks for the reply! I created the feature request ;) https://github.com/rspec/rspec-core/issues/359 >> There are some hax you can do There are way to execute? How can I do it? Best, Pablo Cantero -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue May 3 16:29:21 2011 From: lists at ruby-forum.com (Matt S.) Date: Tue, 03 May 2011 22:29:21 +0200 Subject: [rspec-users] fields_for view spec In-Reply-To: <995242B3-A7E4-4F20-B17E-9689F00D1ECB@gmail.com> References: <0ce10793933e6583810c4c9f3c9eb576@ruby-forum.com> <5ece8b4cf3ad74537eee6581592c336e@ruby-forum.com> <465aac15acb8ae7309c651853d5fa863@ruby-forum.com> <995242B3-A7E4-4F20-B17E-9689F00D1ECB@gmail.com> Message-ID: Chris Mear wrote in post #996461: > On 3 May 2011, at 15:05, Matt S. wrote: > >>>> @asset.build_owner >> Here is the rendered content: >> > >> a lot about other things! >> >> If you want to see everything you can do a 'git clone >> git://github.com/matthewcalebsmith/asset_owner.git' to get the whole >> mock project, in case I have left out any pertinent details. > > The following patch makes the example pass for me. The key change was to > take out the #as_null_object call on your mock models. That seems to be > interfering with Action View's detection of nested attributes > acceptance, but I'm not sure exactly why. > > Chris > >>From 0829776dd45b3a0c57134f7af5d4f21feebe5fd7 Mon Sep 17 00:00:00 2001 > From: Chris Mear > Date: Tue, 3 May 2011 18:11:40 +0100 > Subject: [PATCH] Fix stubbing for nested form in assets/new. > > --- > spec/views/assets/new.html.erb_spec.rb | 11 ++++++++--- > 1 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/spec/views/assets/new.html.erb_spec.rb > b/spec/views/assets/new.html.erb_spec.rb > index b8845fe..9bf3b26 100644 > --- a/spec/views/assets/new.html.erb_spec.rb > +++ b/spec/views/assets/new.html.erb_spec.rb > @@ -1,13 +1,18 @@ > require 'spec_helper' > > describe "assets/new.html.erb" do > - let(:asset) { mock_model("Asset").as_new_record.as_null_object } > - let(:owner) { mock_model("Owner").as_new_record.as_null_object } > + let(:asset) { mock_model("Asset").as_new_record } > + let(:owner) { mock_model("Owner").as_new_record } > > before(:each) do > asset.stub(:owner => owner) > - asset.accepts_nested_attributes_for :owner > + asset.stub(:name) > + asset.stub(:owner_attributes=) > + > + owner.stub(:name) > + > assign(:asset, asset) > + > end > > it "renders new asset form with owner attributes" do > -- > 1.7.4.4 Thanks Chris, I guess it ended up being like you said at the beginning. It is good to know about the as_null_object behavior, which seems a bit odd, but I have too much work to worry about it right now. Definitely reinforces the idea of writing as little code as possible to make it pass, and only then refactor. If I had truly done that I probably would have caught this. Thank you for your time. I hope this also saves someone else a headache in the future. Thanks again, Matt Smith -- Posted via http://www.ruby-forum.com/. From cdechauri at gmail.com Tue May 3 22:40:06 2011 From: cdechauri at gmail.com (=?ISO-8859-1?Q?Carmen_D=EDaz_Echauri?=) Date: Tue, 3 May 2011 19:40:06 -0700 Subject: [rspec-users] Cucumber in Spanish? Message-ID: Hi All I'm trying to write test scenarios in Spanish with cucumber. But all my test are passing :( I haven't really used cucumber that much. Is there any setting that I'm missing. Where do I need to set that it is "es" I cannot find an example beside https://github.com/aslakhellesoy/cucumber/tree/master/examples/i18n Appreciate any help Cheers, -- Carmen -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed May 4 06:22:14 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 May 2011 05:22:14 -0500 Subject: [rspec-users] Cucumber in Spanish? In-Reply-To: References: Message-ID: On May 3, 2011, at 9:40 PM, Carmen D?az Echauri wrote: > Hi All > > I'm trying to write test scenarios in Spanish with cucumber. But all my test are passing :( I haven't really used cucumber that much. > Is there any setting that I'm missing. Where do I need to set that it is "es" > I cannot find an example beside https://github.com/aslakhellesoy/cucumber/tree/master/examples/i18n > > Appreciate any help Hey Carmen - Cucumber has its own list: http://groups.google.com/group/cukes. RSpec questions, of course, are always welcome here. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From DataWraith at web.de Wed May 4 10:51:27 2011 From: DataWraith at web.de (Johannes =?utf-8?Q?Holzfu=C3=9F?=) Date: Wed, 4 May 2011 16:51:27 +0200 Subject: [rspec-users] Distinguishing failed specs from failing to run the specs Message-ID: <20110504145126.GA32576@Empyrion.Speedport_W_722V_Typ_B> Hi all, is it possible to find out if rspec failed to run the specs? I would like to add a notification to guard-rspec (an autospec replacement) that tells me something along the lines of "I could not run the specs because of a SyntaxError" in addition to the normal Passed/Pending/Failed notification. guard-rspec uses Kernel#system to run rspec. I tried looking at the exit code, but that does not distinguish between failed specs and failing to run the specs. This would also not tell me the reason for the failure (although that is secondary to knowing there was a problem running the specs). Parsing rspec's output is difficult, and I would prefer not having to do that. Another option would be to set a flag in a formatter ("rspec hasn't started to run the specs, so if $? == 1, it's not because of a failing spec"), but that is a fairly ugly kludge. Any other ideas on how to do this? Thanks, Johannes Holzfu? From sahmed1020 at gmail.com Thu May 5 14:28:54 2011 From: sahmed1020 at gmail.com (S Ahmed) Date: Thu, 5 May 2011 14:28:54 -0400 Subject: [rspec-users] api (class/method) renaming, will a simple controller test verify this? Message-ID: I want my tests to fail if I rename a method in my /lib folder in a rails app. Say I have a class like: /lib /lib/formatter.rb class Formatter def self.do_transforms(text) text end end And say I reference this in my HomeController's index action: def index text = params[:text] text = Formatter.do_transforms(text) end Now if I was to rename the method from do_transforms to perform_transforms, what is the minimum test I would neeed to do on my HomeController to get it to fail b/c of the rename? -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu May 5 14:51:21 2011 From: lists at ruby-forum.com (Jonatas Paganini) Date: Thu, 05 May 2011 20:51:21 +0200 Subject: [rspec-users] jruby PATH and RUBYOPTS integration Message-ID: <6954eb4804c9cbd8a162e876fcaa9fcb@ruby-forum.com> Hi, I download the last jruby version and install the rspec gem using jgem to install. After it, I export RUBYOPTS=rubygems to guarantee that the spec can be found. Trying to run the spec by normal mode I got: jonatas at branco:~/jruby-1.6.1$ jruby -S spec LoadError: no such file to load -- spec/autorun require at org/jruby/RubyKernel.java:1038 (root) at /usr/bin/spec:2 Trying to execute directly from the original binary: jonatas at branco:~/jruby-1.6.1$ echo $RUBYOPT rubygems jonatas at branco:~/jruby-1.6.1$ bin/jruby -S lib/ruby/gems/1.8/gems/rspec-core-2.5.1/bin/rspec ************************************************** Could not find 'rspec/autorun' This may happen if you're using rubygems as your package manager, but it is not being required through some mechanism before executing the rspec command. You may need to do one of the following in your shell: # for bash/zsh export RUBYOPT=rubygems # for csh, etc. set RUBYOPT=rubygems For background, please see http://gist.github.com/54177. ************************************************** How can I run rspec through jruby in this case? -- Posted via http://www.ruby-forum.com/. From cdechauri at gmail.com Thu May 5 17:37:24 2011 From: cdechauri at gmail.com (=?ISO-8859-1?Q?Carmen_D=EDaz_Echauri?=) Date: Thu, 5 May 2011 14:37:24 -0700 Subject: [rspec-users] Cucumber in Spanish? In-Reply-To: References: Message-ID: my mistake! Thanks :-) On Wed, May 4, 2011 at 3:22 AM, David Chelimsky wrote: > On May 3, 2011, at 9:40 PM, Carmen D?az Echauri wrote: > > Hi All > > I'm trying to write test scenarios in Spanish with cucumber. But all my > test are passing :( I haven't really used cucumber that much. > Is there any setting that I'm missing. Where do I need to set that it is > "es" > I cannot find an example beside > https://github.com/aslakhellesoy/cucumber/tree/master/examples/i18n > > Appreciate any help > > > Hey Carmen - Cucumber has its own list: > http://groups.google.com/group/cukes. > > RSpec questions, of course, are always welcome here. > > Cheers, > David > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Carmen -------------- next part -------------- An HTML attachment was scrubbed... URL: From mmazur at gmail.com Thu May 5 18:16:28 2011 From: mmazur at gmail.com (Mike Mazur) Date: Fri, 6 May 2011 06:16:28 +0800 Subject: [rspec-users] api (class/method) renaming, will a simple controller test verify this? In-Reply-To: References: Message-ID: Hi, On Fri, May 6, 2011 at 02:28, S Ahmed wrote: > I want my tests to fail if I rename a method in my /lib folder in a rails > app. > > Say I have a class like: > > /lib > /lib/formatter.rb > > class Formatter > ?? def self.do_transforms(text) > ????? text > ?? end > end > > > And say I reference this in my HomeController's index action: > > > def index > > ??? text = params[:text] > > ??? text = Formatter.do_transforms(text) > > > end > > > Now if I was to rename the method from do_transforms to perform_transforms, > what is the minimum test I would neeed to do on my HomeController to get it > to fail b/c of the rename? The simplest test that would cover your specific case would probably be: describe HomeController do describe "GET 'index'" do it "succeeds" do get :index response.should be_success end end end If the method has been renamed, the index action will throw a NoMethodError and that spec will fail. Mike From dchelimsky at gmail.com Fri May 6 08:01:20 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 6 May 2011 07:01:20 -0500 Subject: [rspec-users] rspec-2.6.0.rc6 is released! Message-ID: <045E4AC5-9804-4A23-915B-7A4391EF70D2@gmail.com> We're doing one more release candidate to update rspec-rails to work with rails-3.1.0.beta1. This will hopefully be the last release candidate, with a final release coming in just a few days. ### rspec-rails-2.6.0.rc6 full changelog: http://github.com/rspec/rspec-rails/compare/v2.6.0.rc4...v2.6.0.rc6 * Bug fixes * Fix load order issue w/ Capybara (oleg dashevskii) * Relax the dependencies on rails gems to >= 3.0 (Joel Moss) * Fix monkey patches that broke due to internal changes in rails-3.1.0.beta1 ### rspec-core-2.6.0.rc6 full changelog: http://github.com/rspec/rspec-core/compare/v2.6.0.rc4...v2.6.0.rc6 * Enhancements * Restore --pattern/-P command line option from rspec-1 * Support false as well as true in config.full_backtrace= (Andreas Tolf Tolfsen) From sahmed1020 at gmail.com Tue May 3 15:27:02 2011 From: sahmed1020 at gmail.com (S Ahmed) Date: Tue, 3 May 2011 15:27:02 -0400 Subject: [rspec-users] when mocking, does it scan the method being tested for outside calls? Message-ID: Say I want to test this method: def modify_user_status(user_id) .. .. user = User.find(user_id) .. .. end Now could I mock the call to User.find()? I'm just trying to understand, when I run the test, and say I mocked the call to User.find, then rspec realizes this and replaces it with the mocked call. Is this correct? -------------- next part -------------- An HTML attachment was scrubbed... URL: From szimek at gmail.com Wed May 4 12:15:15 2011 From: szimek at gmail.com (Szymon Nowak) Date: Wed, 4 May 2011 09:15:15 -0700 (PDT) Subject: [rspec-users] Has anything changed in config.include syntax in 2.6.0? Message-ID: <18670780.397.1304525715912.JavaMail.geo-discussion-forums@yqlq3> Hey, I've got Integration::AuthenticationHelpers module in /support/integration/authentication_helpers.rb file. It uses some Capybara methods like "visit" etc. I include it using config.include Integration::AuthenticationHelpers, :type => :request In 2.5.x it works fine, in 2.6.0.rc4 it causes the following error: Failure/Error: sign_in @user NoMethodError: undefined method `visit' for # Has something changed? I'm using Capybara 1.0.0.beta1. Cheers, Szymon -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik at baens.net Wed May 4 14:24:57 2011 From: erik at baens.net (Erik Lindblom) Date: Wed, 4 May 2011 12:24:57 -0600 Subject: [rspec-users] Best way to test validates_acceptance_of Message-ID: Hello, I am trying to write a test to make sure that the property validates_acceptance_of is present on a model. In my exploration, I can't seem to make a test that fails when this property is absent, then passes when added. Any guidance would be appreciated! ~Erik L. -------------- next part -------------- An HTML attachment was scrubbed... URL: From szimek at gmail.com Wed May 4 14:28:50 2011 From: szimek at gmail.com (Szymon Nowak) Date: Wed, 4 May 2011 11:28:50 -0700 (PDT) Subject: [rspec-users] Has anything changed in config.include syntax in 2.6.0? In-Reply-To: <18670780.397.1304525715912.JavaMail.geo-discussion-forums@yqlq3> Message-ID: <32293073.631.1304533730197.JavaMail.geo-discussion-forums@yqmi17> Looks like it's fixed on master. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathan.voxland at gmail.com Wed May 4 15:29:22 2011 From: nathan.voxland at gmail.com (Nathan Voxland) Date: Wed, 4 May 2011 12:29:22 -0700 (PDT) Subject: [rspec-users] Re-executing rspec tests in existing JRuby container Message-ID: I have a JRuby Servlet environment very much like the "Parse Once, Eval Many Times on Servlet" example at http://kenai.com/projects/jruby/pages/RedBridgeServletExamples. What I am trying to do is execute an rspec test by hitting a URL mapped to my JRuby servlet. I get an expected error the first time I access the URL, but for each URL access after that I get the error IOError: closed stream write at org/jruby/RubyIO.java:1322 write at org/jruby/RubyIO.java:2305 puts at org/jruby/RubyIO.java:2260 puts at org/jruby/RubyIO.java:2252 message at C:/jboss......gems/rspec-core-2.5.1/lib/rspec/core/ formatters/base_text_formatter.rb:15 send at org/jruby/RubyKernel.java:2056 notify at C:/jboss......gems/rspec-core-2.5.1/lib/rspec/core/ reporter.rb:75 each at org/jruby/RubyArray.java:1602 notify at C:/jboss......gems/rspec-core-2.5.1/lib/rspec/core/ reporter.rb:74 message at C:/jboss......gems/rspec-core-2.5.1/lib/rspec/core/ reporter.rb:38 announce_exclusion_filter at C:/jboss......gems/rspec-core-2.5.1/lib/ rspec/core/world.rb:77 (root) at