Skip to content

Commit

Permalink
Distinguish module defining to_matcher method
Browse files Browse the repository at this point in the history
Previously this Mocha::ObjectMethods module was re-opening the module
defined in `lib/mocha/object_methods.rb`. I think this was potentially
confusing and so I've moved the to_matcher method definition to a new
Mocha::ParameterMatchers::InstanceMethods module to make things clearer.
  • Loading branch information
floehopper committed Nov 3, 2019
1 parent 36adf88 commit ab619c8
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/mocha/parameter_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Mocha
module ParameterMatchers; end
end

require 'mocha/parameter_matchers/object'
require 'mocha/parameter_matchers/instance_methods'

require 'mocha/parameter_matchers/all_of'
require 'mocha/parameter_matchers/any_of'
Expand Down
18 changes: 18 additions & 0 deletions lib/mocha/parameter_matchers/instance_methods.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'mocha/parameter_matchers/equals'

module Mocha
module ParameterMatchers
# @private
module InstanceMethods
# @private
def to_matcher
Mocha::ParameterMatchers::Equals.new(self)
end
end
end
end

# @private
class Object
include Mocha::ParameterMatchers::InstanceMethods
end
15 changes: 0 additions & 15 deletions lib/mocha/parameter_matchers/object.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/unit/parameter_matchers/has_entries_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.expand_path('../../../test_helper', __FILE__)

require 'mocha/parameter_matchers/has_entries'
require 'mocha/parameter_matchers/object'
require 'mocha/parameter_matchers/instance_methods'
require 'mocha/inspect'

class HasEntriesTest < Mocha::TestCase
Expand Down
2 changes: 1 addition & 1 deletion test/unit/parameter_matchers/has_entry_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.expand_path('../../../test_helper', __FILE__)

require 'mocha/parameter_matchers/has_entry'
require 'mocha/parameter_matchers/object'
require 'mocha/parameter_matchers/instance_methods'
require 'mocha/parameter_matchers/equals'
require 'mocha/inspect'

Expand Down
2 changes: 1 addition & 1 deletion test/unit/parameter_matchers/has_key_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.expand_path('../../../test_helper', __FILE__)

require 'mocha/parameter_matchers/has_key'
require 'mocha/parameter_matchers/object'
require 'mocha/parameter_matchers/instance_methods'
require 'mocha/inspect'

class HasKeyTest < Mocha::TestCase
Expand Down
2 changes: 1 addition & 1 deletion test/unit/parameter_matchers/has_value_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.expand_path('../../../test_helper', __FILE__)

require 'mocha/parameter_matchers/has_value'
require 'mocha/parameter_matchers/object'
require 'mocha/parameter_matchers/instance_methods'
require 'mocha/parameter_matchers/equals'
require 'mocha/inspect'

Expand Down
2 changes: 1 addition & 1 deletion test/unit/parameter_matchers/includes_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.expand_path('../../../test_helper', __FILE__)

require 'mocha/parameter_matchers/includes'
require 'mocha/parameter_matchers/object'
require 'mocha/parameter_matchers/instance_methods'
require 'mocha/parameter_matchers/has_key'
require 'mocha/parameter_matchers/regexp_matches'
require 'mocha/inspect'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/parameter_matchers/responds_with_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.expand_path('../../../test_helper', __FILE__)

require 'mocha/parameter_matchers/responds_with'
require 'mocha/parameter_matchers/object'
require 'mocha/parameter_matchers/instance_methods'
require 'mocha/inspect'

class RespondsWithTest < Mocha::TestCase
Expand Down

0 comments on commit ab619c8

Please sign in to comment.