flexmock 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source :rubygems
2
2
 
3
3
  gem 'rspec', ">= 2.0"
4
- gem 'rake', ">= 0.9.2.2"
4
+ gem 'rake', ">= 0.9.2.2"
5
+
6
+ group 'dev' do
7
+ gem 'rdoc'
8
+ end
data/Gemfile.lock CHANGED
@@ -2,7 +2,10 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  diff-lcs (1.1.3)
5
+ json (1.7.5)
5
6
  rake (0.9.2.2)
7
+ rdoc (3.12)
8
+ json (~> 1.4)
6
9
  rspec (2.11.0)
7
10
  rspec-core (~> 2.11.0)
8
11
  rspec-expectations (~> 2.11.0)
@@ -17,4 +20,5 @@ PLATFORMS
17
20
 
18
21
  DEPENDENCIES
19
22
  rake (>= 0.9.2.2)
23
+ rdoc
20
24
  rspec (>= 2.0)
data/README.rdoc CHANGED
@@ -1,9 +1,9 @@
1
- = Flex Mock -- Making Mocking Easy
1
+ = Flex Mock -- Making Mocking Easy
2
2
 
3
3
  FlexMock is a simple, but flexible, mock object library for Ruby unit
4
4
  testing.
5
5
 
6
- Version :: 1.0.4
6
+ Version :: 1.1.0
7
7
 
8
8
  = Links
9
9
 
@@ -522,6 +522,7 @@ not.
522
522
  Alias for <code>and_yield( ... )</code>.
523
523
 
524
524
  * <b>pass_thru</b>
525
+ * <b>pass_thru { |value| .... }</b>
525
526
 
526
527
  Declares that the expected message will allow the method to be
527
528
  passed to the original method definition in the partial mock object.
@@ -529,6 +530,15 @@ not.
529
530
  there is no original method to be called, pass_thru will always
530
531
  return the undefined object.
531
532
 
533
+ If a block is supplied to pass_thru, the value returned from the
534
+ original method will be passed to the block and the value of the
535
+ block will be returned. This allows you to mock methods on the
536
+ returned value.
537
+
538
+ Dog.should_receive(:new).pass_thru { |dog|
539
+ flexmock(dog, :wag => true)
540
+ }
541
+
532
542
  === Other Expectation Methods
533
543
 
534
544
  * <b>mock</b>
@@ -275,9 +275,10 @@ class FlexMock
275
275
  end
276
276
  alias :throws :and_throw
277
277
 
278
- def pass_thru
278
+ def pass_thru(&block)
279
+ block ||= lambda { |value| value }
279
280
  and_return { |*args|
280
- @mock.flexmock_invoke_original(@sym, args)
281
+ block.call(@mock.flexmock_invoke_original(@sym, args))
281
282
  }
282
283
  end
283
284
 
@@ -2,8 +2,8 @@ class FlexMock
2
2
  module Version
3
3
  NUMBERS = [
4
4
  MAJOR = 1,
5
- MINOR = 0,
6
- BUILD = 4,
5
+ MINOR = 1,
6
+ BUILD = 0,
7
7
  ]
8
8
  end
9
9
 
@@ -67,12 +67,27 @@ class TestStubbing < Test::Unit::TestCase
67
67
  assert_equal flexmock(obj), flexmock(obj)
68
68
  end
69
69
 
70
- def test_stubbed_methods_can_invoke_original_behavior
70
+ def test_stubbed_methods_can_invoke_original_behavior_directly
71
71
  dog = Dog.new
72
72
  flexmock(dog).should_receive(:bark).pass_thru.once
73
73
  assert_equal :woof, dog.bark
74
74
  end
75
75
 
76
+ def test_stubbed_methods_can_invoke_original_behavior_with_modification
77
+ dog = Dog.new
78
+ flexmock(dog).should_receive(:bark).pass_thru { |result| result.to_s.upcase }.once
79
+ assert_equal "WOOF", dog.bark
80
+ end
81
+
82
+ def test_stubbed_methods_returning_partial_mocks
83
+ flexmock(Dog).should_receive(:new).pass_thru { |dog|
84
+ flexmock(dog, :beg => "Please")
85
+ }.once
86
+ dog = Dog.new
87
+ assert_equal "Please", dog.beg
88
+ assert_equal :woof, dog.bark
89
+ end
90
+
76
91
  def test_multiple_methods_can_be_stubbed
77
92
  dog = Dog.new
78
93
  flexmock(dog).should_receive(:bark).and_return(:grrrr)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000Z
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! "\n FlexMock is a extremely simple mock object class compatible\n
15
15
  \ with the Test::Unit framework. Although the FlexMock's\n interface is
@@ -20,6 +20,8 @@ extensions: []
20
20
  extra_rdoc_files:
21
21
  - README.rdoc
22
22
  - CHANGES
23
+ - doc/examples/rspec_examples_spec.rdoc
24
+ - doc/examples/test_unit_examples_test.rdoc
23
25
  - doc/GoogleExample.rdoc
24
26
  - doc/releases/flexmock-0.4.0.rdoc
25
27
  - doc/releases/flexmock-0.4.1.rdoc
@@ -42,8 +44,6 @@ extra_rdoc_files:
42
44
  - doc/releases/flexmock-0.9.0.rdoc
43
45
  - doc/releases/flexmock-1.0.0.rdoc
44
46
  - doc/releases/flexmock-1.0.3.rdoc
45
- - doc/examples/rspec_examples_spec.rdoc
46
- - doc/examples/test_unit_examples_test.rdoc
47
47
  files:
48
48
  - CHANGES
49
49
  - Gemfile
@@ -116,6 +116,8 @@ files:
116
116
  - test/undefined_test.rb
117
117
  - flexmock.blurb
118
118
  - install.rb
119
+ - doc/examples/rspec_examples_spec.rdoc
120
+ - doc/examples/test_unit_examples_test.rdoc
119
121
  - doc/GoogleExample.rdoc
120
122
  - doc/releases/flexmock-0.4.0.rdoc
121
123
  - doc/releases/flexmock-0.4.1.rdoc
@@ -138,8 +140,6 @@ files:
138
140
  - doc/releases/flexmock-0.9.0.rdoc
139
141
  - doc/releases/flexmock-1.0.0.rdoc
140
142
  - doc/releases/flexmock-1.0.3.rdoc
141
- - doc/examples/rspec_examples_spec.rdoc
142
- - doc/examples/test_unit_examples_test.rdoc
143
143
  homepage: https://github.com/jimweirich/flexmock
144
144
  licenses: []
145
145
  post_install_message:
@@ -157,6 +157,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
157
  - - ! '>='
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
+ segments:
161
+ - 0
162
+ hash: 575343022424832079
160
163
  required_rubygems_version: !ruby/object:Gem::Requirement
161
164
  none: false
162
165
  requirements:
@@ -165,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
168
  version: '0'
166
169
  requirements: []
167
170
  rubyforge_project:
168
- rubygems_version: 1.8.10
171
+ rubygems_version: 1.8.24
169
172
  signing_key:
170
173
  specification_version: 3
171
174
  summary: Simple and Flexible Mock Objects for Testing