James Byrne
2009-Apr-09 16:46 UTC
[rspec-users] [cucumber] Tests pass, application does not.
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/.
Pat Maddox
2009-Apr-09 16:55 UTC
[rspec-users] [cucumber] Tests pass, application does not.
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
James Byrne
2009-Apr-09 17:04 UTC
[rspec-users] [cucumber] Tests pass, application does not.
James Byrne 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>I put in a print self.methods.sort.to_yaml and, sure enough, when I do this through the browser this is what I see: ... - mark_for_destruction - marked_for_destruction? - metaclass - method - method_missing - methods - new_record? - nil? - object_id ... I put the same check in the controller @entity = Entity.new print @entity.methods.sort.to_yaml and it is missing there as well. No method_exists?, So, where is it going? However, -- Posted via http://www.ruby-forum.com/.
James Byrne
2009-Apr-09 17:44 UTC
[rspec-users] [cucumber] Tests pass, application does not.
Pat Maddox wrote:> > > 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. > > PatAhh, thanks. That fixed things. Most disconcerting to have ones tests pass and the application die. -- Posted via http://www.ruby-forum.com/.
Joseph Wilk
2009-Apr-09 17:48 UTC
[rspec-users] [cucumber] Tests pass, application does not.
James Byrne wrote:> James Byrne 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> >> > > I put in a print self.methods.sort.to_yaml and, sure enough, when I do > this through the browser this is what I see: > > ... > - mark_for_destruction > - marked_for_destruction? > - metaclass > - method > - method_missing > - methods > - new_record? > - nil? > - object_id > ... > > I put the same check in the controller > @entity = Entity.new > print @entity.methods.sort.to_yaml > > and it is missing there as well. > > > > No method_exists?, So, where is it going? > >Could be completely off track, Pats mention of Mocha reminded me that Rails 2.3 tests have lots of ''require mocha'' dotted around the place: David raised a ticket on this: https://rails.lighthouseapp.com/projects/8994/tickets/2240-let-users-decide-what-mock-framework-to-use Could this be causing some conflict? -- Joseph Wilk http://blog.josephwilk.net> However, >
David Chelimsky
2009-Apr-09 17:51 UTC
[rspec-users] [cucumber] Tests pass, application does not.
On Thu, Apr 9, 2009 at 1:55 PM, Pat Maddox <pat.maddox at gmail.com> wrote:> 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.Yes - Rails now requires ''mocha'' in ActiveSupport::TestCase if you have it on your system. I''ve filed a ticket about this here: https://rails.lighthouseapp.com/projects/8994/tickets/2240 Cheers, David> > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2009-Apr-09 18:12 UTC
[rspec-users] [cucumber] Tests pass, application does not.
On Thu, Apr 9, 2009 at 2:48 PM, Joseph Wilk <joe at josephwilk.net> wrote:> > James Byrne wrote: >> >> James Byrne 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> >>> >> >> I put in a print self.methods.sort.to_yaml and, sure enough, when I do >> this through the browser this is what I see: >> >> ... >> - mark_for_destruction >> - marked_for_destruction? >> - metaclass >> - method >> - method_missing >> - methods >> - new_record? >> - nil? >> - object_id >> ... >> >> I put the same check in the controller >> ?@entity = Entity.new >> ?print @entity.methods.sort.to_yaml >> >> and it is missing there as well. >> >> >> >> No method_exists?, So, where is it going? >> >> > > Could be completely off track, Pats mention of Mocha reminded me that Rails > 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. http://github.com/rails/rails/blob/660fc93942697b74a8093d4d5338d1ced25cbe7f/activesupport/lib/active_support/test_case.rb 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> > David raised a ticket on this: > > https://rails.lighthouseapp.com/projects/8994/tickets/2240-let-users-decide-what-mock-framework-to-use > > Could this be causing some conflict? > > -- > Joseph Wilk > http://blog.josephwilk.net > >> However, >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >