[rspec-users] [cucumber] Tests pass, application does not.

Pat Maddox pat.maddox at gmail.com
Thu Apr 9 12:55:46 EDT 2009


On Thu, Apr 9, 2009 at 9:46 AM, James Byrne <lists at ruby-forum.com> wrote:
> This has just cropped up this morning and I have no clue as to what is
> causing it.
>
> Here is the error when running the application through the web browser
> in development:
>
>  undefined method `method_exists?' for #<Entity:0x2b7214243bd0>
>
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:255:in
> `method_missing'
> /home/byrnejb/Software/Development/Projects/proforma.git/lib/hll_attr_set_by_names.rb:16:in
> `attr_set_by_names'
> ...
>
> Here is the code:
>
> 14  an.each do |f|
> 15     puts "checking method: #{f}"
> 16    self.send("#{f}=", "#{param_hash[f]}") if
> self.method_exists?("#{f}=")
> 17  end
>
> But, when I run the cucumber test for the same controller and view this
> is what I see:
> ...
>    And they enter the entity legal name "MyUser  LEGAL  NAME"
>       #
> features/app/models/entities/step_definitions/entity_steps.rb:66
> entity_common_name
> entity_legal_name
> entity_legal_form
> checking method: entity_common_name
> checking method: entity_legal_name
> checking method: entity_legal_form
>    And I press "Create"
>       # features/support/step_definitions/local_webrat_steps.rb:14
>    Then they should see a save error message
>       # features/app/step_definitions/crud_response_steps.rb:24
>
> 12 scenarios
> 78 passed steps
>
> I am lost...  Help?
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

I just did a github search and the only place I found method_exists?
referenced was in mocha.  So my guess is that in test mode, mocha is
being loaded and so it's passing for you.  Try using respond_to?
instead of method_exists?  I've never even heard of method_exists?
until just now.

Pat


More information about the rspec-users mailing list