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

David Chelimsky dchelimsky at gmail.com
Thu Apr 9 14:12:04 EDT 2009


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
>


More information about the rspec-users mailing list