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
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.
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
Ahh, thanks. That fixed things. Most disconcerting to have ones tests
pass and the application die.
`method_missing’
17 end
checking method: entity_common_name
I am lost… Help?
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.
metaclass
print @entity.methods.sort.to_yaml
2.3 tests have lots of ‘require mocha’ dotted around the place:
It’s not just in Rails’ own tests. It’s actually in
ActiveSupport::TestCase, which means that if you have mocha installed,
it’s getting loaded whether you use it or not.
Generally speaking, this should really not be a problem. But there are
those odd cases where a conflict may arise because both rspec-mocks
and mocha add methods to object to support partial mocking/stubbing on
any object. It happens that they use different method names. But, for
example, if we wanted to alias :should_receive with :expects in RSpec
to give it more of mocha’s flavor, we’d be definitely be risking some
unpleasant behaviour.
Cheers,
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.