expectations 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,9 +2,7 @@ module Expectations::DelegateRecorder
|
|
2
2
|
attr_accessor :delegation_result
|
3
3
|
|
4
4
|
def delegate!(meth)
|
5
|
-
@subject_mock = Mocha::Mock.new
|
6
5
|
@meth = meth
|
7
|
-
@subject_mock.expects(meth).returns(:a_delegated_return_value)
|
8
6
|
recorder = self
|
9
7
|
mod = Module.new do
|
10
8
|
define_method meth do |*args|
|
@@ -20,21 +18,22 @@ module Expectations::DelegateRecorder
|
|
20
18
|
end
|
21
19
|
|
22
20
|
def subject!
|
21
|
+
@subject_mock = Object.new
|
22
|
+
@subject_mock.expects(@meth).returns(:a_delegated_return_value)
|
23
23
|
subject.stubs(@receiver).returns(@subject_mock)
|
24
24
|
subject
|
25
25
|
end
|
26
26
|
|
27
27
|
def verify
|
28
|
-
@subject_mock.verify
|
29
28
|
:a_delegated_return_value == delegation_result
|
30
29
|
end
|
31
30
|
|
32
31
|
def failure_message
|
33
|
-
"expected #{subject}.#{@meth} to return the value of #{subject}.#{@receiver}.#{@meth}; however, #{subject}.#{@meth} returned #{delegation_result}"
|
32
|
+
"expected #{subject}.#{@meth} to return the value of #{subject}.#{@receiver}.#{@meth}; however, #{subject}.#{@meth} returned #{delegation_result.inspect}"
|
34
33
|
end
|
35
34
|
|
36
35
|
def mocha_error_message(ex)
|
37
|
-
"expected #{subject} to delegate #{@meth} to #{@receiver}; however, #{subject}.#{@meth} was never called"
|
36
|
+
"expected #{subject} to delegate #{@meth} to #{@receiver}; however, #{subject}.#{@meth} was never called -- #{ex}"
|
38
37
|
end
|
39
38
|
|
40
39
|
end
|
@@ -6,7 +6,7 @@ module Expectations::RecordedExpectation
|
|
6
6
|
warn_for_expects do
|
7
7
|
instance_exec(expected.subject, &block) if block
|
8
8
|
end
|
9
|
-
if mocha_verify
|
9
|
+
if expected.verify! && mocha_verify
|
10
10
|
self.extend(Expectations::Results::Fulfilled)
|
11
11
|
else
|
12
12
|
self.extend(Expectations::Results::StateBasedFailure)
|
data/rakefile.rb
CHANGED
@@ -46,7 +46,7 @@ specification = Gem::Specification.new do |s|
|
|
46
46
|
expect NoMethodError do
|
47
47
|
Object.invalid_method_call
|
48
48
|
end."
|
49
|
-
s.version = "1.
|
49
|
+
s.version = "1.2.0"
|
50
50
|
s.author = 'Jay Fields'
|
51
51
|
s.description = "A lightweight unit testing framework. Tests (expectations) will be written as follows
|
52
52
|
expect 2 do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expectations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Fields
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-07-
|
12
|
+
date: 2008-07-28 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|