flexmock 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@
3
3
  FlexMock is a simple, but flexible, mock object library for Ruby unit
4
4
  testing.
5
5
 
6
- Version :: 0.8.8
6
+ Version :: 0.8.9
7
7
 
8
8
  = Links
9
9
 
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ require 'rake/contrib/rubyforgepublisher'
19
19
  CLEAN.include('*.tmp')
20
20
  CLOBBER.include("html", 'pkg')
21
21
 
22
- PKG_VERSION = '0.8.8'
22
+ PKG_VERSION = '0.8.9'
23
23
 
24
24
  PKG_FILES = FileList[
25
25
  '[A-Z]*',
@@ -12,7 +12,7 @@
12
12
  require 'flexmock/noop'
13
13
 
14
14
  class FlexMock
15
-
15
+
16
16
  # #########################################################################
17
17
  # PartialMockProxy is used to mate the mock framework to an existing
18
18
  # object. The object is "enhanced" with a reference to a mock
@@ -30,9 +30,9 @@ class FlexMock
30
30
 
31
31
  # The following methods are added to partial mocks so that they
32
32
  # can act like a mock.
33
-
33
+
34
34
  MOCK_METHODS = [
35
- :should_receive, :new_instances,
35
+ :should_receive, :new_instances,
36
36
  :flexmock_get, :flexmock_teardown, :flexmock_verify
37
37
  ]
38
38
 
@@ -43,10 +43,10 @@ class FlexMock
43
43
  @method_definitions = {}
44
44
  @methods_proxied = []
45
45
  unless safe_mode
46
- add_mock_method(@obj, :should_receive)
46
+ add_mock_method(:should_receive)
47
47
  MOCK_METHODS.each do |sym|
48
48
  unless @obj.respond_to?(sym)
49
- add_mock_method(@obj, sym)
49
+ add_mock_method(sym)
50
50
  end
51
51
  end
52
52
  end
@@ -88,14 +88,18 @@ class FlexMock
88
88
  end
89
89
  end
90
90
 
91
- def add_mock_method(obj, method_name)
91
+ def add_mock_method(method_name)
92
92
  stow_existing_definition(method_name)
93
- eval_line = __LINE__ + 1
94
- eval %{
95
- def obj.#{method_name}(*args, &block)
96
- @flexmock_proxy.#{method_name}(*args, &block)
97
- end
98
- }, binding, __FILE__, eval_line
93
+ sclass.module_eval do
94
+ define_method(method_name) { |*args, &block|
95
+ proxy = instance_variable_get("@flexmock_proxy")
96
+ if proxy.nil?
97
+ fail "Missing FlexMock proxy " +
98
+ "(for method_name=#{method_name.inspect}, self=\#{self})"
99
+ end
100
+ proxy.send(method_name, *args, &block)
101
+ }
102
+ end
99
103
  end
100
104
 
101
105
  # :call-seq:
@@ -123,7 +127,7 @@ class FlexMock
123
127
  allocators.each do |allocate_method|
124
128
  # HACK: Without the following lambda, Ruby 1.9 will not bind
125
129
  # the allocate_method parameter correctly.
126
- lambda { }
130
+ lambda { }
127
131
  self.should_receive(allocate_method).and_return { |*args|
128
132
  new_obj = invoke_original(allocate_method, args)
129
133
  mock = flexmock_container.flexmock(new_obj)
@@ -245,14 +249,14 @@ class FlexMock
245
249
  eval_line = __LINE__ + 1
246
250
  sclass.class_eval %{
247
251
  def #{method_name}(*args, &block)
248
- @flexmock_proxy.mock.__send__(:#{method_name}, *args, &block)
252
+ @flexmock_proxy.mock.__send__(:#{method_name}, *args, &block)
249
253
  end
250
254
  }, __FILE__, eval_line
251
255
  else
252
256
  eval_line = __LINE__ + 1
253
257
  sclass.class_eval %{
254
258
  def #{method_name}(*args, &block)
255
- @flexmock_proxy.mock.#{method_name}(*args, &block)
259
+ @flexmock_proxy.mock.#{method_name}(*args, &block)
256
260
  end
257
261
  }, __FILE__, eval_line
258
262
  make_rcov_recognize_the_above_eval_is_covered = true
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexmock
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 45
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 8
10
- version: 0.8.8
9
+ - 9
10
+ version: 0.8.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jim Weirich
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-13 00:00:00 -04:00
18
+ date: 2010-10-15 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21