Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow mocha 0.14.* #30

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

dyfrgi commented Jun 21, 2013

Allows using mocha 0.14.*, which allows using minitest v5.

Contributor

dyfrgi commented Jun 21, 2013

Mocha 0.13.3 doesn't work with minitest 5.0.4, and presumably not earlier versions of minitest v5. It loads its methods into the wrong place.

@jferris jferris commented on the diff Jun 27, 2013

bourne.gemspec
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency('mocha', '~> 0.13.2') # follow instructions in mock.rb to update
+ s.add_dependency('mocha', '>= 0.13.2', '< 0.15') # follow instructions in mock.rb to update
@jferris

jferris Jun 27, 2013

Owner

Just to double check: did you go through the instructions in mock.rb?

Contributor

dyfrgi commented Jun 27, 2013

There are no instructions in mock.rb, so I suppose that yes, I have followed all the instructions in mock.rb to update.

Owner

jferris commented Jun 27, 2013

Ugh, sorry for the confusion. Looks like that stuff moved around with a recent refactoring. I updated that comment to refer to instructions that actually exist, and here they are:

to update:

We're monkey-patching a method in mocha directly, so we need to make sure the upstream tests continue to run with each release.

Contributor

dyfrgi commented Jun 27, 2013

Gotcha. It's not much changed:

< class MockTest < Test::Unit::TestCase
---
> class MockTest < Mocha::TestCase
52c48
<     OBJECT_METHODS = STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS.reject { |m| m =~ /^__.*__$/ }
---
>     OBJECT_METHODS = STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS.reject { |m| m =~ /^__.*__$/ || ["method_missing", "singleton_method_undefined", "initialize"].include?(m)}
54c50
<     OBJECT_METHODS = STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS.reject { |m| m =~ /^__.*__$/ || m == :object_id }
---
>     OBJECT_METHODS = STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS.reject { |m| m =~ /^__.*__$/ || [:object_id, :method_missing, :singleton_method_undefined, :initialize, :String, :singleton_method_added].include?(m) }

I'm not sure why they're removing more methods from ones which they want to test mocking. It clearly passes with Bourne now, as the tests still pass with Mocha 0.14.

The Mocha::TestCase class doesn't add much. https://github.com/freerange/mocha/blob/master/test/test_helper.rb#L26

It does make it harder to just copy and paste the upstream test, in particular the replacement test class which comes from a different file.

Owner

jferris commented Jun 27, 2013

I copied the OBJECT_METHODS changes over and ignored the test case superclass change; everything seems to be working fine. I merged this in and released as 1.5. Thanks!

@jferris jferris closed this Jun 27, 2013

Contributor

dyfrgi commented Jul 1, 2013

@jferris Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment