flexmock 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +44 -2
- data/doc/releases/flexmock-1.0.3.rdoc +159 -0
- data/lib/flexmock/core.rb +8 -5
- data/lib/flexmock/core_class_methods.rb +9 -3
- data/lib/flexmock/expectation.rb +17 -1
- data/lib/flexmock/expectation_director.rb +3 -2
- data/lib/flexmock/spy_describers.rb +7 -5
- data/lib/flexmock/validators.rb +33 -3
- data/lib/flexmock/version.rb +1 -1
- data/test/assert_spy_called_test.rb +14 -1
- data/test/deprecated_methods_test.rb +1 -1
- data/test/expectation_description_test.rb +80 -0
- data/test/should_ignore_missing_test.rb +1 -1
- metadata +30 -32
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.
|
6
|
+
Version :: 1.0.4
|
7
7
|
|
8
8
|
= Links
|
9
9
|
|
@@ -254,6 +254,48 @@ constraints to your expectation. Here are some examples:
|
|
254
254
|
at_least.twice.at_most.times(10).
|
255
255
|
and_return { rand }
|
256
256
|
|
257
|
+
Expectation are always matched in order of declaration. That means if
|
258
|
+
you have a general expectation before a more specific expectation, the
|
259
|
+
general expectation will have an opportunity to match first,
|
260
|
+
effectively hiding the second expectation.
|
261
|
+
|
262
|
+
For example:
|
263
|
+
|
264
|
+
mock.should_receive(:average) # Matches any call to average
|
265
|
+
mock.should_receive(:average).with(1).once # Fails because it never matches
|
266
|
+
|
267
|
+
In the example, the second expectation will never be triggered because
|
268
|
+
all calls to average will be handled by the first expectation. Since
|
269
|
+
the second expectation is require to match one time, this test will
|
270
|
+
fail.
|
271
|
+
|
272
|
+
Reversing the order of the expections so that the more specific
|
273
|
+
expectation comes first will fix that problem.
|
274
|
+
|
275
|
+
If an expectation has a count requirement (e.g. <code>once</code> or
|
276
|
+
<code>times</code>), then once it has matched its expected number of
|
277
|
+
times, it will let other expectations have a chance to match.
|
278
|
+
|
279
|
+
For example:
|
280
|
+
|
281
|
+
mock.should_receive(:average).once.and_return(1)
|
282
|
+
mock.should_receive(:average).once.and_return(2)
|
283
|
+
mock.should_receive(:average).and_return(3)
|
284
|
+
|
285
|
+
In the example, the first time average is called, the first
|
286
|
+
expectation is matched an average will return 1. The second time
|
287
|
+
average is called, the second expectation matches and 2 is returned.
|
288
|
+
For all calls to average after that, the third expectation returning 3
|
289
|
+
will be used.
|
290
|
+
|
291
|
+
Occasionally it is useful define a set of expecations in a setup
|
292
|
+
method of a test and override those expectations in specific tests. If
|
293
|
+
you mark an expectation with the <code>by_default</code> marker, that
|
294
|
+
expectation will be used only if there are no non-default expectations
|
295
|
+
on that method name. See "by_default" below.
|
296
|
+
|
297
|
+
=== Expectation Criteria
|
298
|
+
|
257
299
|
The following methods may be used to create and refine expectations on
|
258
300
|
a mock object. See theFlexMock::Expectation for more details.
|
259
301
|
|
@@ -0,0 +1,159 @@
|
|
1
|
+
= FlexMock 1.0.3 Released
|
2
|
+
|
3
|
+
FlexMock is a flexible mocking library for use in unit testing and
|
4
|
+
behavior specification in Ruby. Release 1.0.0 is a minor release with
|
5
|
+
a few bug fixes.
|
6
|
+
|
7
|
+
== Changes in 1.0.3
|
8
|
+
|
9
|
+
=== Features
|
10
|
+
|
11
|
+
* Better error messages when a mock is called the incorrect number of
|
12
|
+
times
|
13
|
+
|
14
|
+
* Better stack output when validations fail during teardown.
|
15
|
+
|
16
|
+
== Changes in 1.0.2
|
17
|
+
|
18
|
+
=== Bug Fixes
|
19
|
+
|
20
|
+
* Quick definitions now obey base class restrictions
|
21
|
+
|
22
|
+
== Changes in 1.0.1
|
23
|
+
|
24
|
+
=== Features
|
25
|
+
|
26
|
+
* Better Ruby 1.8 compatibility
|
27
|
+
|
28
|
+
== Changes in 1.0.0
|
29
|
+
|
30
|
+
=== Features
|
31
|
+
|
32
|
+
* Mocks may now have a base class that limits what methods may be
|
33
|
+
mocked. This allows early detection of outdated mock setups when the
|
34
|
+
methods in the class are refactored.
|
35
|
+
|
36
|
+
* Spy assertions are now allowed. The verification of the calling of
|
37
|
+
mocked methods may now be done in the "then" portion of the test,
|
38
|
+
after the code under test has been run. This allows for much more
|
39
|
+
natural Given/When/Then style testing.
|
40
|
+
|
41
|
+
* A custom assert method (assert_spy_called) has been added to make
|
42
|
+
spy assertions easy when using Test::Unit or MiniTest.
|
43
|
+
|
44
|
+
* An RSpec matcher (have_received) has been added to make spy
|
45
|
+
assertions easy when using RSpec.
|
46
|
+
|
47
|
+
=== Bug Fixes
|
48
|
+
|
49
|
+
* Now correctly handling the mocking of meta-programmed methods.
|
50
|
+
|
51
|
+
* Using the documented +singleton_methods+ method.
|
52
|
+
|
53
|
+
* Accidently trying to partial mock a regular mock is now a no-op.
|
54
|
+
|
55
|
+
== What is FlexMock?
|
56
|
+
|
57
|
+
FlexMock is a flexible framework for creating mock object for testing.
|
58
|
+
When running unit tests, it is often desirable to use isolate the
|
59
|
+
objects being tested from the "real world" by having them interact
|
60
|
+
with simplified test objects. Sometimes these test objects simply
|
61
|
+
return values when called, other times they verify that certain
|
62
|
+
methods were called with particular arguments in a particular order.
|
63
|
+
|
64
|
+
FlexMock makes creating these test objects easy.
|
65
|
+
|
66
|
+
=== Features
|
67
|
+
|
68
|
+
* Easy integration with both Test::Unit and RSpec. Mocks created with the
|
69
|
+
flexmock method are automatically verified at the end of the test or
|
70
|
+
example.
|
71
|
+
|
72
|
+
* A fluent interface that allows mock behavior to be specified very
|
73
|
+
easily.
|
74
|
+
|
75
|
+
* A "record mode" where an existing implementation can record its
|
76
|
+
interaction with a mock for later validation against a new
|
77
|
+
implementation.
|
78
|
+
|
79
|
+
* Easy mocking of individual methods in existing, non-mock objects.
|
80
|
+
|
81
|
+
* Easy mocking of chains of method calls.
|
82
|
+
|
83
|
+
* The ability to cause classes to instantiate test instances (instead of real
|
84
|
+
instances) for the duration of a test.
|
85
|
+
|
86
|
+
=== Example
|
87
|
+
|
88
|
+
Suppose you had a Dog object that wagged a tail when it was happy.
|
89
|
+
Something like this:
|
90
|
+
|
91
|
+
class Dog
|
92
|
+
def initialize(a_tail)
|
93
|
+
@tail = a_tail
|
94
|
+
end
|
95
|
+
def happy
|
96
|
+
@tail.wag
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
To test the +Dog+ class without a real +Tail+ object (perhaps because
|
101
|
+
real +Tail+ objects activate servos in some robotic equipment), you
|
102
|
+
can do something like this:
|
103
|
+
|
104
|
+
RSpec.configure do |config|
|
105
|
+
config.mock_with :flexmock
|
106
|
+
end
|
107
|
+
|
108
|
+
describe Dog do
|
109
|
+
it "wags its tail when happy" do
|
110
|
+
tail = flexmock("tail")
|
111
|
+
tail.should_receive(:wag).once
|
112
|
+
dog = Dog.new(tail)
|
113
|
+
dog.happy
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
FlexMock will automatically verify that the mocked tail object received the
|
118
|
+
message +wag+ exactly one time. If it doesn't, the test will not pass.
|
119
|
+
|
120
|
+
Here's the same thing using the new spy support:
|
121
|
+
|
122
|
+
describe Dog do
|
123
|
+
it "wags its tail when happy" do
|
124
|
+
tail = flexmock("tail")
|
125
|
+
dog = Dog.new(tail)
|
126
|
+
dog.happy
|
127
|
+
tail.should have_received(:wag)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
This style works particularly well with the rspec-given library.
|
132
|
+
|
133
|
+
require 'rspec/given'
|
134
|
+
|
135
|
+
describe Dog do
|
136
|
+
context "when the dog is happy" do
|
137
|
+
Given(:tail) { flexmock(:on, Tail) }
|
138
|
+
Given(:dog) { Dog.new(tail) }
|
139
|
+
|
140
|
+
When { dog.happy }
|
141
|
+
|
142
|
+
Then { tail.should have_received(:wag) }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
See the FlexMock documentation at http://flexmock.rubyforge.org for details on
|
147
|
+
specifying arguments and return values on mocked methods, as well as a simple
|
148
|
+
technique for mocking tail objects when the Dog class creates the tail objects
|
149
|
+
directly.
|
150
|
+
|
151
|
+
== Availability
|
152
|
+
|
153
|
+
You can make sure you have the latest version with a quick RubyGems command:
|
154
|
+
|
155
|
+
gem install flexmock (you may need root/admin privileges)
|
156
|
+
|
157
|
+
You will find documentation at: http://flexmock.rubyforge.org.
|
158
|
+
|
159
|
+
-- Jim Weirich
|
data/lib/flexmock/core.rb
CHANGED
@@ -99,13 +99,16 @@ class FlexMock
|
|
99
99
|
self
|
100
100
|
end
|
101
101
|
|
102
|
+
CallRecord = Struct.new(:method_name, :args, :expectation)
|
103
|
+
|
102
104
|
# Handle missing methods by attempting to look up a handler.
|
103
105
|
def method_missing(sym, *args, &block)
|
104
|
-
|
106
|
+
enhanced_args = block_given? ? args + [block] : args
|
107
|
+
call_record = CallRecord.new(sym, enhanced_args)
|
108
|
+
@calls << call_record
|
105
109
|
flexmock_wrap do
|
106
110
|
if handler = @expectations[sym]
|
107
|
-
|
108
|
-
handler.call(*args)
|
111
|
+
handler.call(enhanced_args, call_record)
|
109
112
|
elsif @base_class && @base_class.flexmock_defined?(sym)
|
110
113
|
FlexMock.undefined
|
111
114
|
elsif @ignore_missing
|
@@ -143,8 +146,8 @@ class FlexMock
|
|
143
146
|
# True if the mock received the given method and arguments.
|
144
147
|
def flexmock_received?(sym, args, options={})
|
145
148
|
count = 0
|
146
|
-
@calls.each { |
|
147
|
-
count += 1 if (
|
149
|
+
@calls.each { |call_record|
|
150
|
+
count += 1 if (call_record.method_name == sym) && ArgumentMatching.all_match?(args, call_record.args)
|
148
151
|
}
|
149
152
|
if options[:times]
|
150
153
|
result = count == options[:times]
|
@@ -50,11 +50,17 @@ class FlexMock
|
|
50
50
|
|
51
51
|
# Class method to format a method name and argument list as a nice
|
52
52
|
# looking string.
|
53
|
-
def
|
53
|
+
def format_call(sym, args) # :nodoc:
|
54
|
+
"#{sym}(#{format_args(args)})"
|
55
|
+
end
|
56
|
+
|
57
|
+
# Class method to format a list of args (the part between the
|
58
|
+
# parenthesis).
|
59
|
+
def format_args(args)
|
54
60
|
if args
|
55
|
-
|
61
|
+
args.collect { |a| a.inspect }.join(', ')
|
56
62
|
else
|
57
|
-
"
|
63
|
+
"*args"
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
data/lib/flexmock/expectation.rb
CHANGED
@@ -49,7 +49,23 @@ class FlexMock
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def to_s
|
52
|
-
FlexMock.
|
52
|
+
FlexMock.format_call(@sym, @expected_args)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Return a description of the matching features of the
|
56
|
+
# expectation. Matching features include:
|
57
|
+
#
|
58
|
+
# * name of the method
|
59
|
+
# * argument matchers
|
60
|
+
# * call count validators
|
61
|
+
#
|
62
|
+
def description
|
63
|
+
result = "should_receive(#{@sym.inspect})"
|
64
|
+
result << ".with(#{FlexMock.format_args(@expected_args)})" if @expected_args
|
65
|
+
@count_validators.each do |validator|
|
66
|
+
result << validator.describe
|
67
|
+
end
|
68
|
+
result
|
53
69
|
end
|
54
70
|
|
55
71
|
# Verify the current call with the given arguments matches the
|
@@ -35,10 +35,11 @@ class FlexMock
|
|
35
35
|
# but at least we will get a good failure message). Finally,
|
36
36
|
# check for expectations that don't have any argument matching
|
37
37
|
# criteria.
|
38
|
-
def call(
|
38
|
+
def call(args, call_record=nil)
|
39
39
|
exp = find_expectation(*args)
|
40
|
+
call_record.expectation = exp if call_record
|
40
41
|
FlexMock.check(
|
41
|
-
"no matching handler found for " + FlexMock.
|
42
|
+
"no matching handler found for " + FlexMock.format_call(@sym, args)) { ! exp.nil? }
|
42
43
|
exp.verify_call(*args)
|
43
44
|
end
|
44
45
|
|
@@ -2,16 +2,16 @@ class FlexMock
|
|
2
2
|
|
3
3
|
module SpyDescribers
|
4
4
|
def describe_spy_expectation(spy, sym, args, options={})
|
5
|
-
|
5
|
+
describe_spy(spy, sym, args, options)
|
6
6
|
end
|
7
7
|
|
8
8
|
def describe_spy_negative_expectation(spy, sym, args, options={})
|
9
|
-
|
9
|
+
describe_spy(spy, sym, args, options, " NOT")
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
def
|
14
|
+
def describe_spy(spy, sym, args, options, not_clause="")
|
15
15
|
result = "expected "
|
16
16
|
result << call_description(sym, args)
|
17
17
|
result << " to#{not_clause} be received by "
|
@@ -29,8 +29,10 @@ class FlexMock
|
|
29
29
|
result << "No messages have been received\n"
|
30
30
|
else
|
31
31
|
result << "The following messages have been received:\n"
|
32
|
-
spy.flexmock_calls.each do |
|
33
|
-
result << " " << call_description(
|
32
|
+
spy.flexmock_calls.each do |call_record|
|
33
|
+
result << " " << call_description(call_record.method_name, call_record.args)
|
34
|
+
result << " matched by " << call_record.expectation.description if call_record.expectation
|
35
|
+
result << "\n"
|
34
36
|
end
|
35
37
|
end
|
36
38
|
result
|
data/lib/flexmock/validators.rb
CHANGED
@@ -32,9 +32,24 @@ class FlexMock
|
|
32
32
|
n < @limit
|
33
33
|
end
|
34
34
|
|
35
|
+
# Pluralize "call"
|
35
36
|
def calls(n)
|
36
37
|
n == 1 ? "call" : "calls"
|
37
38
|
end
|
39
|
+
|
40
|
+
# Human readable description of the validator
|
41
|
+
def describe
|
42
|
+
case @limit
|
43
|
+
when 0
|
44
|
+
".never"
|
45
|
+
when 1
|
46
|
+
".once"
|
47
|
+
when 2
|
48
|
+
".twice"
|
49
|
+
else
|
50
|
+
".times(#{@limit})"
|
51
|
+
end
|
52
|
+
end
|
38
53
|
end
|
39
54
|
|
40
55
|
####################################################################
|
@@ -48,7 +63,7 @@ class FlexMock
|
|
48
63
|
FlexMock.framework_adapter.assert_block(
|
49
64
|
lambda {
|
50
65
|
"Method '#{@exp}' called incorrect number of times\n" +
|
51
|
-
"#{@limit} #{calls(@limit)} expected\n" +
|
66
|
+
"#{@limit} matching #{calls(@limit)} expected\n" +
|
52
67
|
"#{n} matching #{calls(n)} found\n" +
|
53
68
|
describe_calls(@exp.mock)
|
54
69
|
}
|
@@ -68,13 +83,22 @@ class FlexMock
|
|
68
83
|
FlexMock.framework_adapter.assert_block(
|
69
84
|
lambda {
|
70
85
|
"Method '#{@exp}' called incorrect number of times\n" +
|
71
|
-
"At least #{@limit} #{calls(@limit)} expected\n" +
|
86
|
+
"At least #{@limit} matching #{calls(@limit)} expected\n" +
|
72
87
|
"#{n} matching #{calls(n)} found\n" +
|
73
88
|
describe_calls(@exp.mock)
|
74
89
|
}) { n >= @limit }
|
75
90
|
end
|
76
91
|
end
|
77
92
|
|
93
|
+
# Human readable description of the validator.
|
94
|
+
def describe
|
95
|
+
if @limit == 0
|
96
|
+
".zero_or_more_times"
|
97
|
+
else
|
98
|
+
".at_least#{super}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
78
102
|
# If the expectation has been called +n+ times, is it still
|
79
103
|
# eligible to be called again? Since this validator only
|
80
104
|
# establishes a lower limit, not an upper limit, then the answer
|
@@ -94,11 +118,17 @@ class FlexMock
|
|
94
118
|
FlexMock.framework_adapter.assert_block(
|
95
119
|
lambda {
|
96
120
|
"Method '#{@exp}' called incorrect number of times\n" +
|
97
|
-
"At most #{@limit} #{calls(@limit)} expected\n" +
|
121
|
+
"At most #{@limit} matching #{calls(@limit)} expected\n" +
|
98
122
|
"#{n} matching #{calls(n)} found\n" +
|
99
123
|
describe_calls(@exp.mock)
|
100
124
|
}) { n <= @limit }
|
101
125
|
end
|
102
126
|
end
|
127
|
+
|
128
|
+
# Human readable description of the validator
|
129
|
+
def describe
|
130
|
+
".at_most#{super}"
|
131
|
+
end
|
132
|
+
|
103
133
|
end
|
104
134
|
end
|
data/lib/flexmock/version.rb
CHANGED
@@ -76,7 +76,7 @@ class AssertSpyCalledTest < Test::Unit::TestCase
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def test_assert_error_lists_calls_actually_made_without_handled_by
|
80
80
|
spy.foo
|
81
81
|
spy.bar(1)
|
82
82
|
ex = assert_fails(/The following messages have been received/) do
|
@@ -85,6 +85,19 @@ class AssertSpyCalledTest < Test::Unit::TestCase
|
|
85
85
|
assert_match(/ foo\(\)/, ex.message)
|
86
86
|
assert_match(/ bar\(1\)/, ex.message)
|
87
87
|
assert_no_match(/ baz\(\)/, ex.message)
|
88
|
+
assert_no_match(/handled by/, ex.message)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_assert_error_lists_calls_actually_made_with_handled_by
|
92
|
+
spy.should_receive(:foo).once
|
93
|
+
spy.foo
|
94
|
+
spy.bar(1)
|
95
|
+
ex = assert_fails(/The following messages have been received/) do
|
96
|
+
assert_spy_called spy, :baz
|
97
|
+
end
|
98
|
+
assert_match(/ foo\(\) matched by should_receive\(:foo\)/, ex.message)
|
99
|
+
assert_match(/ bar\(1\)/, ex.message)
|
100
|
+
assert_no_match(/ baz\(\)/, ex.message)
|
88
101
|
end
|
89
102
|
|
90
103
|
def test_assert_errors_say_no_calls_made
|
@@ -174,7 +174,7 @@ class TestFlexMock < Test::Unit::TestCase
|
|
174
174
|
s { @mock.mock_handle(:xyzzy) { got_it = true } }
|
175
175
|
method_proc = @mock.method(:xyzzy)
|
176
176
|
assert_not_nil method_proc
|
177
|
-
method_proc.call
|
177
|
+
method_proc.call([])
|
178
178
|
assert(got_it, "method proc should run")
|
179
179
|
end
|
180
180
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#---
|
4
|
+
# Copyright 2003-2012 by Jim Weirich (jim.weirich@gmail.com).
|
5
|
+
# All rights reserved.
|
6
|
+
|
7
|
+
# Permission is granted for use, copying, modification, distribution,
|
8
|
+
# and distribution of modified versions of this work as long as the
|
9
|
+
# above copyright notice is included.
|
10
|
+
#+++
|
11
|
+
|
12
|
+
require 'test/test_setup'
|
13
|
+
|
14
|
+
class ExpectationDescriptionTest < Test::Unit::TestCase
|
15
|
+
include FlexMock::TestCase
|
16
|
+
|
17
|
+
def setup
|
18
|
+
@mock = flexmock("mock")
|
19
|
+
@exp = FlexMock::Expectation.new(@mock, :foo, "file.rb:3")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_basic_description
|
23
|
+
assert_equal "should_receive(:foo)", @exp.description
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_with_no_args
|
27
|
+
@exp.with()
|
28
|
+
assert_equal "should_receive(:foo).with()", @exp.description
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_with_simple_args
|
32
|
+
@exp.with(1, "HI")
|
33
|
+
assert_equal "should_receive(:foo).with(1, \"HI\")", @exp.description
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_with_never
|
37
|
+
@exp.never
|
38
|
+
assert_equal "should_receive(:foo).never", @exp.description
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_with_once
|
42
|
+
@exp.once
|
43
|
+
assert_equal "should_receive(:foo).once", @exp.description
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_with_twice
|
47
|
+
@exp.twice
|
48
|
+
assert_equal "should_receive(:foo).twice", @exp.description
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_with_3
|
52
|
+
@exp.times(3)
|
53
|
+
assert_equal "should_receive(:foo).times(3)", @exp.description
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_with_at_least_once
|
57
|
+
@exp.at_least.once
|
58
|
+
assert_equal "should_receive(:foo).at_least.once", @exp.description
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_with_at_least_10
|
62
|
+
@exp.at_least.times(10)
|
63
|
+
assert_equal "should_receive(:foo).at_least.times(10)", @exp.description
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_with_at_most_once
|
67
|
+
@exp.at_most.once
|
68
|
+
assert_equal "should_receive(:foo).at_most.once", @exp.description
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_with_zero_or_more_times
|
72
|
+
@exp.at_most.zero_or_more_times
|
73
|
+
assert_equal "should_receive(:foo).zero_or_more_times", @exp.description
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_with_at_least_1_at_most_10
|
77
|
+
@exp.at_least.once.at_most.times(10)
|
78
|
+
assert_equal "should_receive(:foo).at_least.once.at_most.times(10)", @exp.description
|
79
|
+
end
|
80
|
+
end
|
@@ -63,7 +63,7 @@ class TestShouldIgnoreMissing < Test::Unit::TestCase
|
|
63
63
|
@mock.should_receive(:known_foo).once
|
64
64
|
method_proc = @mock.method(:known_foo)
|
65
65
|
assert_not_nil method_proc
|
66
|
-
method_proc.call
|
66
|
+
method_proc.call([])
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_not_calling_method_proc_will_fail_count_constraints
|
metadata
CHANGED
@@ -1,29 +1,25 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexmock
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
4
5
|
prerelease:
|
5
|
-
version: 1.0.3
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Jim Weirich
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2012-09-18 00:00:00 Z
|
12
|
+
date: 2012-10-12 00:00:00.000000000Z
|
14
13
|
dependencies: []
|
15
|
-
|
16
|
-
|
14
|
+
description: ! "\n FlexMock is a extremely simple mock object class compatible\n
|
15
|
+
\ with the Test::Unit framework. Although the FlexMock's\n interface is
|
16
|
+
simple, it is very flexible.\n "
|
17
17
|
email: jim.weirich@gmail.com
|
18
18
|
executables: []
|
19
|
-
|
20
19
|
extensions: []
|
21
|
-
|
22
|
-
extra_rdoc_files:
|
20
|
+
extra_rdoc_files:
|
23
21
|
- README.rdoc
|
24
22
|
- CHANGES
|
25
|
-
- doc/examples/rspec_examples_spec.rdoc
|
26
|
-
- doc/examples/test_unit_examples_test.rdoc
|
27
23
|
- doc/GoogleExample.rdoc
|
28
24
|
- doc/releases/flexmock-0.4.0.rdoc
|
29
25
|
- doc/releases/flexmock-0.4.1.rdoc
|
@@ -45,7 +41,10 @@ extra_rdoc_files:
|
|
45
41
|
- doc/releases/flexmock-0.8.5.rdoc
|
46
42
|
- doc/releases/flexmock-0.9.0.rdoc
|
47
43
|
- doc/releases/flexmock-1.0.0.rdoc
|
48
|
-
|
44
|
+
- doc/releases/flexmock-1.0.3.rdoc
|
45
|
+
- doc/examples/rspec_examples_spec.rdoc
|
46
|
+
- doc/examples/test_unit_examples_test.rdoc
|
47
|
+
files:
|
49
48
|
- CHANGES
|
50
49
|
- Gemfile
|
51
50
|
- Gemfile.lock
|
@@ -93,6 +92,7 @@ files:
|
|
93
92
|
- test/demeter_mocking_test.rb
|
94
93
|
- test/deprecated_methods_test.rb
|
95
94
|
- test/examples_from_readme_test.rb
|
95
|
+
- test/expectation_description_test.rb
|
96
96
|
- test/extended_should_receive_test.rb
|
97
97
|
- test/flexmodel_test.rb
|
98
98
|
- test/naming_test.rb
|
@@ -116,8 +116,6 @@ 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
|
121
119
|
- doc/GoogleExample.rdoc
|
122
120
|
- doc/releases/flexmock-0.4.0.rdoc
|
123
121
|
- doc/releases/flexmock-0.4.1.rdoc
|
@@ -139,36 +137,36 @@ files:
|
|
139
137
|
- doc/releases/flexmock-0.8.5.rdoc
|
140
138
|
- doc/releases/flexmock-0.9.0.rdoc
|
141
139
|
- doc/releases/flexmock-1.0.0.rdoc
|
140
|
+
- doc/releases/flexmock-1.0.3.rdoc
|
141
|
+
- doc/examples/rspec_examples_spec.rdoc
|
142
|
+
- doc/examples/test_unit_examples_test.rdoc
|
142
143
|
homepage: https://github.com/jimweirich/flexmock
|
143
144
|
licenses: []
|
144
|
-
|
145
145
|
post_install_message:
|
146
|
-
rdoc_options:
|
146
|
+
rdoc_options:
|
147
147
|
- --title
|
148
148
|
- FlexMock
|
149
149
|
- --main
|
150
150
|
- README.rdoc
|
151
151
|
- --line-numbers
|
152
|
-
require_paths:
|
152
|
+
require_paths:
|
153
153
|
- lib
|
154
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
155
|
none: false
|
156
|
-
requirements:
|
157
|
-
- -
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version:
|
160
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
|
-
requirements:
|
163
|
-
- -
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version:
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
166
|
requirements: []
|
167
|
-
|
168
167
|
rubyforge_project:
|
169
|
-
rubygems_version: 1.8.
|
168
|
+
rubygems_version: 1.8.10
|
170
169
|
signing_key:
|
171
170
|
specification_version: 3
|
172
171
|
summary: Simple and Flexible Mock Objects for Testing
|
173
172
|
test_files: []
|
174
|
-
|