flexmock 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flexmock/core.rb +8 -1
- data/lib/flexmock/expectation.rb +7 -3
- data/lib/flexmock/ordering.rb +9 -4
- data/lib/flexmock/spy_describers.rb +1 -2
- data/lib/flexmock/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d8010b82bdccec43f2038e9b3698387e952027a
|
4
|
+
data.tar.gz: c034d8b46dec2354c06df15491213f1987d30309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3bde508002be38eced12ee24efe4ad0092556da26930bbec98b3aed7a631035d84c943d01da70411d60085f2eb48ba8ca98584be2617f8f7f6cbd1d858acab2
|
7
|
+
data.tar.gz: 69a04f543a8a55765c354e061a94f1234dbfe8dc3c3963e7beeeccba74c534226936a0a528e96793f1a0a2349a9ba9c86706085fe001a191a421dfe3ce2ef931
|
data/lib/flexmock/core.rb
CHANGED
@@ -85,6 +85,11 @@ class FlexMock
|
|
85
85
|
|
86
86
|
# Teardown and infrastructure setup for this mock.
|
87
87
|
def flexmock_teardown
|
88
|
+
@flexmock_closed = true
|
89
|
+
end
|
90
|
+
|
91
|
+
def flexmock_closed?
|
92
|
+
@flexmock_closed
|
88
93
|
end
|
89
94
|
|
90
95
|
# Ignore all undefined (missing) method calls.
|
@@ -105,7 +110,9 @@ class FlexMock
|
|
105
110
|
call_record = CallRecord.new(sym, enhanced_args, block_given?)
|
106
111
|
@calls << call_record
|
107
112
|
flexmock_wrap do
|
108
|
-
if
|
113
|
+
if flexmock_closed?
|
114
|
+
FlexMock.undefined
|
115
|
+
elsif handler = @expectations[sym]
|
109
116
|
handler.call(enhanced_args, call_record)
|
110
117
|
elsif @base_class && @base_class.flexmock_defined?(sym)
|
111
118
|
FlexMock.undefined
|
data/lib/flexmock/expectation.rb
CHANGED
@@ -82,8 +82,8 @@ class FlexMock
|
|
82
82
|
# Verify the current call with the given arguments matches the
|
83
83
|
# expectations recorded in this object.
|
84
84
|
def verify_call(*args)
|
85
|
-
validate_order
|
86
85
|
validate_eligible
|
86
|
+
validate_order
|
87
87
|
@actual_count += 1
|
88
88
|
perform_yielding(args)
|
89
89
|
return_value(args)
|
@@ -138,10 +138,14 @@ class FlexMock
|
|
138
138
|
# Validate that the order
|
139
139
|
def validate_order
|
140
140
|
if @order_number
|
141
|
-
@mock.flexmock_validate_order(
|
141
|
+
@mock.flexmock_validate_order(
|
142
|
+
to_s, @order_number,
|
143
|
+
SpyDescribers.describe_calls(@mock))
|
142
144
|
end
|
143
145
|
if @global_order_number
|
144
|
-
@mock.flexmock_container.flexmock_validate_order(
|
146
|
+
@mock.flexmock_container.flexmock_validate_order(
|
147
|
+
to_s, @global_order_number,
|
148
|
+
SpyDescribers.describe_calls(@mock))
|
145
149
|
end
|
146
150
|
end
|
147
151
|
private :validate_order
|
data/lib/flexmock/ordering.rb
CHANGED
@@ -39,11 +39,16 @@ class FlexMock
|
|
39
39
|
@flexmock_current_order = value
|
40
40
|
end
|
41
41
|
|
42
|
-
def flexmock_validate_order(method_name, order_number)
|
43
|
-
|
44
|
-
"(expected order #{order_number}, was #{flexmock_current_order})"
|
42
|
+
def flexmock_validate_order(method_name, order_number, calls_description = nil)
|
43
|
+
msg = "method #{method_name} called out of order " +
|
44
|
+
"(expected order #{order_number}, was #{flexmock_current_order})"
|
45
|
+
if calls_description
|
46
|
+
msg += "\n#{calls_description}"
|
47
|
+
end
|
48
|
+
|
49
|
+
FlexMock.check(msg) do
|
45
50
|
order_number >= self.flexmock_current_order
|
46
|
-
|
51
|
+
end
|
47
52
|
self.flexmock_current_order = order_number
|
48
53
|
end
|
49
54
|
end
|
@@ -17,8 +17,6 @@ class FlexMock
|
|
17
17
|
describe_spy(spy, sym, args, options, " NOT")
|
18
18
|
end
|
19
19
|
|
20
|
-
private
|
21
|
-
|
22
20
|
def describe_spy(spy, sym, args, options, not_clause="")
|
23
21
|
result = "expected "
|
24
22
|
result << call_description(sym, args)
|
@@ -88,6 +86,7 @@ class FlexMock
|
|
88
86
|
"#{sym}(...)"
|
89
87
|
end
|
90
88
|
end
|
89
|
+
extend SpyDescribers
|
91
90
|
end
|
92
91
|
|
93
92
|
end
|
data/lib/flexmock/version.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-09-
|
12
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -176,4 +176,3 @@ signing_key:
|
|
176
176
|
specification_version: 4
|
177
177
|
summary: Simple and Flexible Mock Objects for Testing
|
178
178
|
test_files: []
|
179
|
-
has_rdoc:
|