-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #404 from freerange/distinguish-object-methods-mod…
…ules Distinguish different ObjectMethods modules
- Loading branch information
Showing
11 changed files
with
55 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,57 @@ | ||
require 'date' | ||
|
||
module Mocha | ||
module ObjectMethods | ||
def mocha_inspect | ||
address = __id__ * 2 | ||
address += 0x100000000 if address < 0 | ||
inspect =~ /#</ ? "#<#{self.class}:0x#{Kernel.format('%x', address)}>" : inspect | ||
module Inspect | ||
module ObjectMethods | ||
def mocha_inspect | ||
address = __id__ * 2 | ||
address += 0x100000000 if address < 0 | ||
inspect =~ /#</ ? "#<#{self.class}:0x#{Kernel.format('%x', address)}>" : inspect | ||
end | ||
end | ||
end | ||
|
||
module ArrayMethods | ||
def mocha_inspect | ||
"[#{collect(&:mocha_inspect).join(', ')}]" | ||
module ArrayMethods | ||
def mocha_inspect | ||
"[#{collect(&:mocha_inspect).join(', ')}]" | ||
end | ||
end | ||
end | ||
|
||
module HashMethods | ||
def mocha_inspect | ||
"{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}" | ||
module HashMethods | ||
def mocha_inspect | ||
"{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}" | ||
end | ||
end | ||
end | ||
|
||
module TimeMethods | ||
def mocha_inspect | ||
"#{inspect} (#{to_f} secs)" | ||
module TimeMethods | ||
def mocha_inspect | ||
"#{inspect} (#{to_f} secs)" | ||
end | ||
end | ||
end | ||
|
||
module DateMethods | ||
def mocha_inspect | ||
to_s | ||
module DateMethods | ||
def mocha_inspect | ||
to_s | ||
end | ||
end | ||
end | ||
end | ||
|
||
class Object | ||
include Mocha::ObjectMethods | ||
include Mocha::Inspect::ObjectMethods | ||
end | ||
|
||
class Array | ||
include Mocha::ArrayMethods | ||
include Mocha::Inspect::ArrayMethods | ||
end | ||
|
||
class Hash | ||
include Mocha::HashMethods | ||
include Mocha::Inspect::HashMethods | ||
end | ||
|
||
class Time | ||
include Mocha::TimeMethods | ||
include Mocha::Inspect::TimeMethods | ||
end | ||
|
||
class Date | ||
include Mocha::DateMethods | ||
include Mocha::Inspect::DateMethods | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters