public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
massive plugin update, piston++

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2726 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Tue Jan 30 08:25:30 -0800 2007
commit  f3c5b9e496fb0b9ccf630c33630c918f4d3d4b0f
tree    c14c6e259f145417a3e6296693496d1a7e69bd4a
parent  e589c07f94271a29e1893371ba8fa60ac2a8cc4c
...
51
52
53
54
 
55
56
57
...
376
377
378
 
 
379
380
381
...
404
405
406
407
408
409
410
411
...
51
52
53
 
54
55
56
57
...
376
377
378
379
380
381
382
383
...
406
407
408
 
 
409
410
411
0
@@ -51,7 +51,7 @@ module ActiveRecord #:nodoc:
0
     #
0
     # See ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned for configuration options
0
     module Versioned
0
- CALLBACKS = [:set_new_version, :save_version_on_create, :save_version, :clear_changed_attributes]
0
+ CALLBACKS = [:set_new_version, :save_version_on_create, :save_version?, :clear_changed_attributes]
0
       def self.included(base) # :nodoc:
0
         base.extend ClassMethods
0
       end
0
@@ -376,6 +376,8 @@ module ActiveRecord #:nodoc:
0
           self.class.without_locking(&block)
0
         end
0
 
0
+ def empty_callback() end #:nodoc:
0
+
0
         protected
0
           # sets the new version before saving, unless you're using optimistic locking. In that case, let it take care of the version.
0
           def set_new_version
0
@@ -404,8 +406,6 @@ module ActiveRecord #:nodoc:
0
           CALLBACKS.each do |attr_name|
0
             alias_method "orig_#{attr_name}".to_sym, attr_name
0
           end
0
-
0
- def empty_callback() end #:nodoc:
0
 
0
         module ClassMethods
0
           # Finds a specific version of a specific row of this model
...
312
313
314
315
316
317
318
319
320
321
 
322
323
324
 
325
326
327
...
312
313
314
 
 
315
316
317
318
 
319
320
321
 
322
323
324
325
0
@@ -312,16 +312,14 @@ module Technoweenie # :nodoc:
0
           "#{rand Time.now.to_i}#{filename || 'attachment'}"
0
         end
0
 
0
- @@filename_basename_regex = /^.*(\\|\/)/
0
- @@filename_character_regex = /[^\w\.\-]/
0
         def sanitize_filename(filename)
0
           returning filename.strip do |name|
0
             # NOTE: File.basename doesn't work right with Windows paths on Unix
0
             # get only the filename, not the whole path
0
- name.gsub! @@filename_basename_regex, ''
0
+ name.gsub! /^.*(\\|\/)/, ''
0
             
0
             # Finally, replace all non alphanumeric, underscore or periods with underscore
0
- name.gsub! @@filename_character_regex, '_'
0
+ name.gsub! /[^\w\.\-]/, '_'
0
           end
0
         end
0
 
...
 
1
2
3
...
69
70
71
72
 
 
73
74
75
...
1
2
3
4
...
70
71
72
 
73
74
75
76
77
0
@@ -1,3 +1,4 @@
0
+require 'ftools'
0
 module Technoweenie # :nodoc:
0
   module AttachmentFu # :nodoc:
0
     module Backends
0
@@ -69,7 +70,8 @@ module Technoweenie # :nodoc:
0
             if save_attachment?
0
               # TODO: This overwrites the file if it exists, maybe have an allow_overwrite option?
0
               FileUtils.mkdir_p(File.dirname(full_filename))
0
- FileUtils.mv temp_path, full_filename
0
+ File.cp(temp_path, full_filename)
0
+ File.chmod(attachment_options[:chmod] || 0644, full_filename)
0
             end
0
             @old_filename = nil
0
             true
...
1
2
3
 
4
5
 
6
7
 
8
9
 
10
11
12
...
1
2
 
3
4
 
5
6
 
7
8
 
9
10
11
12
0
@@ -1,12 +1,12 @@
0
 = Mocha
0
 
0
-Mocha is a library for mocking and stubbing within a TestCase[http://www.ruby-doc.org/core/classes/Test/Unit.html] using a syntax like that of JMock[http://www.jmock.org], and SchMock[http://rubyforge.org/projects/schmock].
0
+Mocha is a library for mocking and stubbing using a syntax like that of JMock[http://www.jmock.org], and SchMock[http://rubyforge.org/projects/schmock]. Most commonly Mocha is used in conjunction with Test::Unit[http://www.ruby-doc.org/core/classes/Test/Unit.html], but it can be used in other contexts.
0
 
0
-One of its main advantages is that it allows you to mock and stub methods on _real_ (non-mock) classes and instances. You can for example stub ActiveRecord[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] instance methods like +create+, +save+, +destroy+ and even class methods like +find+ to avoid hitting the database in unit tests. This is a feature that is not currently offered by other Ruby[http://www.ruby-doc.org/] mocking libraries like FlexMock[http://onestepback.org/software/flexmock] and RSpec[http://rspec.rubyforge.org].
0
+One of its main advantages is that it allows you to mock and stub methods on _real_ (non-mock) classes and instances. You can for example stub ActiveRecord[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] instance methods like +create+, +save+, +destroy+ and even class methods like +find+ to avoid hitting the database in unit tests.
0
 
0
-Mocha provides a unified, simple and readable syntax for both traditional mocking and for mocking with non-mock objects.
0
+Mocha provides a unified, simple and readable syntax for both traditional mocking and for mocking with _real_ objects.
0
 
0
-Mocha has been harvested from projects at Reevoo[http://www.reevoo.com] by me (James[http://blog.floehopper.org]) and my colleagues Ben[http://www.reevoo.com/blogs/bengriffiths/], Chris[http://blog.seagul.co.uk] and Paul[http://po-ru.com]. Mocha is in use on real-world Rails[http://www.rubyonrails.org] projects.
0
+Mocha has been harvested from projects at Reevoo[http://www.reevoo.com] by me (James[http://blog.floehopper.org]) and my colleagues Ben[http://www.reevoo.com/blogs/bengriffiths], Chris[http://blog.seagul.co.uk] and Paul[http://po-ru.com]. Mocha is in use on real-world Rails[http://www.rubyonrails.org] projects.
0
 
0
 == Download and Installation
0
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -1,3 +1,35 @@
0
+= 0.4.0
0
+
0
+- Allow naming of mocks (patch from Chris Roos).
0
+- Specify multiple return values for consecutive calls.
0
+- Improved consistency of expectation error messages.
0
+- Allow mocking of Object instance methods e.g. kind_of?, type.
0
+- Provide aliased versions of #expects and #stubs to allow mocking of these methods.
0
+- Added at_least, at_most, at_most_once methods to expectation.
0
+- Allow expects and stubs to take a hash of method and return values.
0
+- Eliminate warning: "instance variable @yield not initialized" (patch from Xavier Shay).
0
+- Restore instance methods on partial mocks (patch from Chris Roos).
0
+- Allow stubbing of a method with non-word characters in its name (patch from Paul Battley).
0
+- Removed coupling to Test::Unit.
0
+- Allow specified exception instance to be raised (patch from Chris Roos).
0
+- Make mock object_id appear in hex like normal Ruby inspect (patch from Paul Battley).
0
+- Fix path to object.rb in rdoc rake task (patch from Tomas Pospisek).
0
+- Reverse order in which expectations are matched, so that last expectation is matched first. This allows e.g. a call to #stubs to be effectively overridden by a call to #expects (patch from Tobias Lutke).
0
+- Stubba & SmartTestCase modules incorporated into Mocha module so only need to require 'mocha' - no longer need to require 'stubba'.
0
+- AutoMocha removed.
0
+
0
+= 0.3.3
0
+
0
+- Quick bug fix to restore instance methods on partial mocks (for Kevin Clark).
0
+
0
+= 0.3.2
0
+
0
+- Examples added.
0
+
0
+= 0.3.1
0
+
0
+- Dual licensing with MIT license added.
0
+
0
 = 0.3.0
0
 
0
 * Rails plugin.
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
0
 require 'rake/contrib/sshpublisher'
0
 
0
 module Mocha
0
- VERSION = "0.3.2"
0
+ VERSION = "0.4.0"
0
 end
0
 
0
 desc "Default task is currently to run all tests"
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
4
5
6
7
8
9
 
 
 
 
 
10
11
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
16
17
18
 
 
19
20
21
22
23
24
25
26
27
 
 
 
 
28
29
30
31
 
 
 
32
...
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
21
22
 
 
 
 
23
24
25
26
27
28
29
 
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
 
 
 
46
47
48
 
 
 
 
49
 
 
 
50
51
52
53
54
 
 
55
56
57
58
59
0
@@ -1,30 +1,57 @@
0
-- provide test::unit agnostic api - mockery/context type objects on which the user must call setup/teardown?
0
+=> plugin
0
+- maybe remove redundant require 'test_help' from init.rb - see mocha mailing list thread with subject "SslRequirements plugin and mocha"
0
+
0
+=> release management
0
+- update RELEASE file for all releases after 0.3.0
0
+- why does gem rdoc include all source files? what about other package types?
0
+- why does zip include Rakefile? what about other package types?
0
+- tags for repos
0
+- automate releases cf rspec
0
+- continuous integration build
0
+- trac?
0
+
0
+=> restrict partial mocks to existing public methods?
0
+- allow specification of class to be mocked, so we can check for existence of methods
0
+- investigate where/why check for existence of stubbed method has gone.
0
+- allow stubbing of private/protected methods? - force_stub?
0
+
0
+=> multiple expectations for same method
0
+- look at JMock for examples of when multiple expectations match
0
 - increment actual count for ANY expectation that matches - see email from Bryan Helmkamp
0
-- add multiyield - see email from Jay Fields
0
 - think about allowing a stubbing expectation to be converted to an asserting expectation and vice versa
0
 - fail fast if expectation count exceeded during test...? c.f. JMock?
0
-- object methods needed for mocha itself should be aliased to __xx__ versions
0
-- maybe introduce blank_mock() and blank_stub() methods or make Stub include Object methods and Mock not...?
0
-- tags for repos
0
-- read and improve tutorial emailed by user
0
+- think about behaviour when more than one expectation/stubbed method match c.f. JMock?
0
+
0
+=> reduce footprint of mocha in terms of visible methods
0
+- do away with __is_a__ method if possible - Proc param may no longer be needed
0
+- add similar test to test_should_be_able_to_mock_standard_object_methods for partial mocks - rename non-public method with underscores e.g. mocha, reset_mocha, stubba_method, stubba_object, etc.
0
 - reduce number of methods added to Object, Class etc to bare minimum
0
 - reduce number of methods excluded from undef in mock_methods (maybe use blank_slate as mocha parent class to allow mocking of standard object methods?)
0
-- should we get two errors when unexpected method is called and similar expectation is not fulfilled? i.e. should we raise error in teardown if one has already been raised in test?
0
+- perhaps only add methods to particular class at point where expects or stubs gets called
0
+- provide some means to un-stubba an object - ideally should restore any methods with same names as stubba methods c.f. dealing with expectations for methods called :expects, :stubs, etc.
0
+- use Object#inspect(:mocha) or Object#__inspect__ instead of Object#mocha_inspect?
0
+
0
+=> improve design
0
+- use builder object c.f. JMock
0
+- possibly simplify by making mock the same as a partial mock of Object
0
+- provide test::unit agnostic api - mockery/context type objects on which the user must call setup/teardown?
0
+- allow stubs/expects methods to accept method names as strings and symbols to retain similarity to define_method() et al
0
+
0
+=> documentation
0
+- read and improve tutorial emailed by user
0
+
0
+=> naming
0
 - default mock names to mock1, mock2, etc or something similar
0
 - stubba mocks should named according to parent stubbee
0
-- allow specification of class to be mocked so we can check for existence of methods
0
-- oomatron type ideas
0
-- allow stubbing of private/protected methods? - force_stub?
0
-- allow hash parameter for stubs and expects methods particularly for stubba
0
+
0
+=> improve tests
0
 - use real activerecord as svn external to for testing instead of active_record_test_case
0
-- provide some means to un-stubba an object - ideally should restore any methods with same names as stubba methods c.f. dealing with expectations for methods called :expects, :stubs, etc.
0
-- automate releases cf rspec
0
-- think about behaviour when more than one expectation/stubbed method match c.f. JMock?
0
-- make verify method private (makes this unnecessary - fail if attempt to verify stub)
0
 - test for setting expectations on class methods (and instance methods?) from within TestCase#setup
0
-- use Object#inspect(:mocha) or Object#__inspect__ instead of Object#mocha_inspect?
0
-- should all instances share expectations for any_instance or should each instance have their own - in which case how do we provide access to the instances
0
-- detect existing or added definition of mocha methods e.g. expects and alias to __expects?
0
+
0
+=> possible extra functionality
0
+- add multiyield - see email from Jay Fields
0
+- allow hash parameter for stubs and expects methods particularly for stubba
0
 - more jmock style stuff - e.g. labels/required order, more sophisticated param matching?
0
-- stubs should only return a fixed value - no blocks allowed for return values and no parameter expectations allowed?
0
-- maybe allow unstubbing of a specific method from within a test...?
0
\ No newline at end of file
0
+- maybe allow unstubbing of a specific method from within a test...?
0
+- oomatron type ideas
0
+- should all instances share expectations for any_instance or should each instance have their own - in which case how do we provide access to the instances
0
\ No newline at end of file
...
94
95
96
97
 
98
99
100
...
94
95
96
 
97
98
99
100
0
@@ -94,7 +94,7 @@ module Mocha
0
       expectation_type = :stubs if expectation_type == :stub_everything
0
       mock = Mocha::Mock.new(stub_everything, name)
0
       expectations.each do |method, result|
0
- mock.send(expectation_type, method).returns(result)
0
+ mock.__send__(expectation_type, method).returns(result)
0
       end
0
       mocks << mock
0
       mock
...
20
21
22
23
 
24
25
26
...
20
21
22
 
23
24
25
26
0
@@ -20,7 +20,7 @@ module Mocha
0
     end
0
     
0
     def unique_mocks
0
- stubba_methods.collect { |method| method.mock }.uniq
0
+ stubba_methods.inject({}) { |mocks, method| mocks[method.mock.__id__] = method.mock; mocks }.values
0
     end
0
   
0
     def unstub_all
...
26
27
28
29
 
30
31
32
33
 
34
35
36
37
 
38
39
40
41
 
42
43
44
...
26
27
28
 
29
30
31
32
 
33
34
35
36
 
37
38
39
40
 
41
42
43
44
0
@@ -26,19 +26,19 @@ module Mocha
0
     end
0
   
0
     def hide_original_method
0
- stubbee.metaclass.class_eval "alias_method :#{hidden_method}, :#{method}" if stubbee.metaclass.method_defined?(method)
0
+ stubbee.__metaclass__.class_eval "alias_method :#{hidden_method}, :#{method}" if stubbee.__metaclass__.method_defined?(method)
0
     end
0
   
0
     def define_new_method
0
- stubbee.metaclass.class_eval "def #{method}(*args, &block); mocha.method_missing(:#{method}, *args, &block); end"
0
+ stubbee.__metaclass__.class_eval "def #{method}(*args, &block); mocha.method_missing(:#{method}, *args, &block); end"
0
     end
0
   
0
     def remove_new_method
0
- stubbee.metaclass.class_eval "remove_method :#{method}"
0
+ stubbee.__metaclass__.class_eval "remove_method :#{method}"
0
     end
0
   
0
     def restore_original_method
0
- stubbee.metaclass.class_eval "alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}" if stubbee.metaclass.method_defined?(hidden_method)
0
+ stubbee.__metaclass__.class_eval "alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}" if stubbee.__metaclass__.method_defined?(hidden_method)
0
     end
0
   
0
     def hidden_method
...
2
3
4
 
 
 
 
 
 
5
6
7
...
219
220
221
222
 
223
224
225
...
240
241
242
243
 
244
245
246
...
2
3
4
5
6
7
8
9
10
11
12
13
...
225
226
227
 
228
229
230
231
...
246
247
248
 
249
250
251
252
0
@@ -2,6 +2,12 @@ require 'mocha/infinite_range'
0
 require 'mocha/pretty_parameters'
0
 require 'mocha/expectation_error'
0
 
0
+class Object
0
+
0
+ alias_method :__is_a__, :is_a?
0
+
0
+end
0
+
0
 module Mocha
0
   # Methods on expectations returned from Mocha::MockMethods#expects and Mocha::MockMethods#stubs
0
   class Expectation
0
@@ -219,7 +225,7 @@ module Mocha
0
     def invoke
0
       @invoked += 1
0
       yield(*@parameters_to_yield) if yield? and block_given?
0
- @return_value.is_a?(Proc) ? @return_value.call : @return_value
0
+ @return_value.__is_a__(Proc) ? @return_value.call : @return_value
0
     end
0
 
0
     def verify
0
@@ -240,7 +246,7 @@ module Mocha
0
     end
0
   
0
     def method_signature
0
- return "#{method_name}" if @parameters.is_a?(AlwaysEqual)
0
+ return "#{method_name}" if @parameters.__is_a__(AlwaysEqual)
0
       "#{@method_name}(#{PrettyParameters.new(@parameters).pretty})"
0
     end
0
     
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@ require 'date'
0
 
0
 class Object
0
   def mocha_inspect
0
- inspect =~ /#</ ? "#<#{self.class}:0x#{self.object_id.to_s(16)}>" : inspect
0
+ inspect =~ /#</ ? "#<#{self.class}:0x#{self.__id__.to_s(16)}>" : inspect
0
   end
0
 end
0
 
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 class Object
0
   
0
- def metaclass
0
+ def __metaclass__
0
     class << self; self; end
0
   end
0
 
...
1
2
3
4
5
6
7
 
 
 
 
8
9
10
 
11
12
13
 
14
15
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
37
38
...
1
2
3
 
 
4
 
5
6
7
8
9
10
 
11
12
 
 
13
14
 
15
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
18
 
19
20
21
0
@@ -1,37 +1,20 @@
0
 require 'mocha/mock_methods'
0
 
0
 module Mocha
0
-
0
- module ExtraMethods
0
 
0
- attr_reader :__mock_name
0
+ class Mock
0
+
0
+ include MockMethods
0
+
0
     def initialize(stub_everything = false, name = nil)
0
       @stub_everything = stub_everything
0
- @__mock_name = name
0
+ @mock_name = name
0
     end
0
-
0
- alias :mocha_inspect_before_hijacked_by_named_mocks :mocha_inspect
0
+
0
     def mocha_inspect
0
- @__mock_name ? "#<Mock:#{@__mock_name}>" : mocha_inspect_before_hijacked_by_named_mocks
0
+ @mock_name ? "#<Mock:#{@mock_name}>" : "#<Mock:0x#{__id__.to_s(16)}>"
0
     end
0
-
0
- end
0
-
0
- class Mock
0
-
0
- include MockMethods
0
- include ExtraMethods
0
-
0
- end
0
-
0
- class BlankMock
0
-
0
- methods_to_keep = /^__.*__$|respond_to?|mocha_inspect|inspect|class|object_id|send|is_a\?|==|hash|nil\?|extend|eql\?/
0
- instance_methods.each { |method_to_remove| eval("undef :#{method_to_remove}") unless method_to_remove =~ methods_to_keep }
0
-
0
- include MockMethods
0
- include ExtraMethods
0
 
0
   end
0
-
0
+
0
 end
0
\ No newline at end of file
...
1
 
2
3
4
...
41
42
43
 
44
45
46
47
48
49
 
 
 
 
50
51
52
...
68
69
70
 
71
72
73
74
 
 
75
76
77
...
102
103
104
105
 
106
107
108
...
1
2
3
4
5
...
42
43
44
45
46
47
48
49
 
 
50
51
52
53
54
55
56
...
72
73
74
75
76
77
78
79
80
81
82
83
84
...
109
110
111
 
112
113
114
115
0
@@ -1,4 +1,5 @@
0
 require 'mocha/expectation'
0
+require 'mocha/metaclass'
0
 
0
 module Mocha
0
   # Methods added to mock objects.
0
@@ -41,12 +42,15 @@ module Mocha
0
       method_names = method_names.is_a?(Hash) ? method_names : { method_names => nil }
0
       method_names.each do |method_name, return_value|
0
         expectations << Expectation.new(self, method_name, backtrace).returns(return_value)
0
+ self.__metaclass__.send(:undef_method, method_name) if self.__metaclass__.method_defined?(method_name)
0
       end
0
       expectations.last
0
     end
0
 
0
- # :call-seq: expects(method_name) -> expectation
0
- # expects(method_names) -> last expectation
0
+ alias_method :__expects__, :expects
0
+
0
+ # :call-seq: stubs(method_name) -> expectation
0
+ # stubs(method_names) -> last expectation
0
     #
0
     # Adds an expectation that a method identified by +method_name+ symbol may be called any number of times with any parameters.
0
     # Returns the new expectation which can be further modified by methods on Mocha::Expectation.
0
@@ -68,10 +72,13 @@ module Mocha
0
       method_names = method_names.is_a?(Hash) ? method_names : { method_names => nil }
0
       method_names.each do |method_name, return_value|
0
         expectations << Stub.new(self, method_name, backtrace).returns(return_value)
0
+ self.__metaclass__.send(:undef_method, method_name) if self.__metaclass__.method_defined?(method_name)
0
       end
0
       expectations.last
0
     end
0
     
0
+ alias_method :__stubs__, :stubs
0
+
0
     # :stopdoc:
0
 
0
     def method_missing(symbol, *arguments, &block)
0
@@ -102,7 +109,7 @@ module Mocha
0
     end
0
   
0
     def matching_expectation(symbol, *arguments)
0
- expectations.detect { |expectation| expectation.match?(symbol, *arguments) }
0
+ expectations.reverse.detect { |expectation| expectation.match?(symbol, *arguments) }
0
     end
0
   
0
     def verify(&block)
...
13
14
15
 
16
17
18
...
30
31
32
 
33
34
35
...
13
14
15
16
17
18
19
...
31
32
33
34
35
36
37
0
@@ -13,6 +13,7 @@ require 'mocha/class_method_test'
0
 require 'mocha/any_instance_method_test'
0
 require 'mocha/setup_and_teardown_test'
0
 require 'mocha/object_test'
0
+require 'mocha/metaclass_test'
0
 
0
 class UnitTests
0
   
0
@@ -30,6 +31,7 @@ class UnitTests
0
     suite << AnyInstanceMethodTest.suite
0
     suite << SetupAndTeardownTest.suite
0
     suite << ObjectTest.suite
0
+ suite << MetaclassTest.suite
0
     suite
0
   end
0
   
...
3
4
5
6
 
7
8
9
...
12
13
14
15
 
16
17
18
19
...
3
4
5
 
6
7
8
9
...
12
13
14
 
15
16
17
18
19
0
@@ -3,7 +3,7 @@ require 'mocha/metaclass'
0
 class Object
0
   
0
   def define_instance_method(method_symbol, &block)
0
- metaclass.send(:define_method, method_symbol, block)
0
+ __metaclass__.send(:define_method, method_symbol, block)
0
   end
0
 
0
   def replace_instance_method(method_symbol, &block)
0
@@ -12,7 +12,7 @@ class Object
0
   end
0
 
0
   def define_instance_accessor(*symbols)
0
- symbols.each { |symbol| metaclass.send(:attr_accessor, symbol) }
0
+ symbols.each { |symbol| __metaclass__.send(:attr_accessor, symbol) }
0
   end
0
 
0
 end
0
\ No newline at end of file
...
147
148
149
150
 
151
152
153
154
155
 
156
157
158
159
160
 
161
162
163
164
...
147
148
149
 
150
151
152
153
154
 
155
156
157
158
159
 
160
161
162
163
164
0
@@ -147,17 +147,17 @@ class AutoVerifyTest < Test::Unit::TestCase
0
   
0
   def test_should_create_mock_with_name
0
     mock = test_case.mock('named_mock')
0
- assert_equal 'named_mock', mock.__mock_name
0
+ assert_equal '#<Mock:named_mock>', mock.mocha_inspect
0
   end
0
   
0
   def test_should_create_stub_with_name
0
     stub = test_case.stub('named_stub')
0
- assert_equal 'named_stub', stub.__mock_name
0
+ assert_equal '#<Mock:named_stub>', stub.mocha_inspect
0
   end
0
   
0
   def test_should_create_greedy_stub_with_name
0
     greedy_stub = test_case.stub_everything('named_greedy_stub')
0
- assert_equal 'named_greedy_stub', greedy_stub.__mock_name
0
+ assert_equal '#<Mock:named_greedy_stub>', greedy_stub.mocha_inspect
0
   end
0
   
0
 end
0
\ No newline at end of file
...
62
63
64
65
 
66
67
68
...
72
73
74
75
 
 
 
76
77
78
...
62
63
64
 
65
66
67
68
...
72
73
74
 
75
76
77
78
79
80
0
@@ -62,7 +62,7 @@ class CentralTest < Test::Unit::TestCase
0
     method_2.verify
0
   end
0
   
0
- def test_should_collect_mock_from_all_methods
0
+ def test_should_collect_mocks_from_all_methods
0
     method_1 = Mock.new
0
     method_1.stubs(:mock).returns(:mock_1)
0
 
0
@@ -72,7 +72,9 @@ class CentralTest < Test::Unit::TestCase
0
     stubba = Central.new
0
     stubba.stubba_methods = [method_1, method_2]
0
     
0
- assert_equal [:mock_1, :mock_2], stubba.unique_mocks
0
+ assert_equal 2, stubba.unique_mocks.size
0
+ assert stubba.unique_mocks.include?(:mock_1)
0
+ assert stubba.unique_mocks.include?(:mock_2)
0
   end
0
 
0
   def test_should_return_unique_mochas
...
128
129
130
131
 
 
132
133
134
 
 
 
 
 
 
 
 
 
 
135
136
137
...
128
129
130
 
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
0
@@ -128,10 +128,21 @@ class ExpectationTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_should_return_evaluated_proc
0
- expectation = new_expectation.returns(lambda { 99 })
0
+ proc = lambda { 99 }
0
+ expectation = new_expectation.returns(proc)
0
     assert_equal 99, expectation.invoke
0
   end
0
   
0
+ def test_should_return_evaluated_proc_without_using_is_a_method
0
+ proc = lambda { 99 }
0
+ proc.define_instance_accessor(:called)
0
+ proc.called = false
0
+ proc.replace_instance_method(:is_a?) { self.called = true; true}
0
+ expectation = new_expectation.returns(proc)
0
+ expectation.invoke
0
+ assert_equal false, proc.called
0
+ end
0
+
0
   def test_should_raise_runtime_exception
0
     expectation = new_expectation.raises
0
     assert_raise(RuntimeError) { expectation.invoke }
...
1
2
 
3
4
5
...
17
18
19
20
 
 
 
 
 
 
 
 
 
 
 
21
22
23
...
1
2
3
4
5
6
...
18
19
20
 
21
22
23
24
25
26
27
28
29
30
31
32
33
34
0
@@ -1,5 +1,6 @@
0
 require File.join(File.dirname(__FILE__), "..", "test_helper")
0
 require 'mocha/inspect'
0
+require 'method_definer'
0
 
0
 class InspectTest
0
   def self.suite
0
@@ -17,7 +18,17 @@ class ObjectInspectTest < Test::Unit::TestCase
0
   
0
   def test_should_provide_custom_representation_of_object
0
     object = Object.new
0