rspec-mocks 2.0.0.beta.15 → 2.0.0.beta.16
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/cucumber.yml +2 -7
- data/features/README.markdown +12 -0
- data/features/configuration.feature +82 -0
- data/features/mocks/block_local_expectations.feature +2 -2
- data/features/mocks/warn_when_expectation_is_set_on_nil.feature +4 -4
- data/features/stubs/stub_implementation.feature +1 -1
- data/lib/rspec/mocks.rb +22 -3
- data/lib/rspec/mocks/extensions.rb +0 -1
- data/lib/rspec/mocks/framework.rb +1 -1
- data/lib/rspec/mocks/message_expectation.rb +0 -1
- data/lib/rspec/mocks/method_double.rb +6 -8
- data/lib/rspec/mocks/proxy.rb +1 -1
- data/rspec-mocks.gemspec +14 -11
- data/spec/rspec/mocks/bug_report_957_spec.rb +1 -1
- data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +77 -49
- data/spec/rspec/mocks_spec.rb +51 -0
- metadata +16 -13
- data/features/mocks/mix_stubs_and_mocks.feature +0 -28
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.16
|
data/cucumber.yml
CHANGED
@@ -1,7 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
-
std_opts = "#{rerun_opts} --require features --format rerun --out rerun.txt --strict --tags ~@wip"
|
5
|
-
%>
|
6
|
-
default: <%= std_opts %>
|
7
|
-
wip: --tags @wip:3 --wip features
|
1
|
+
default: --require features --tags ~@wip features
|
2
|
+
wip: --require features --tags @wip:3 --wip features
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Cucumber features
|
2
|
+
|
3
|
+
RSpec is specified using both RSpec and
|
4
|
+
[Cucumber](http://github.com/aslakhellesoy/cucumber). Cucumber provides
|
5
|
+
_executable documentation_. This means that the _.feature_ files below this
|
6
|
+
directory serve as specification, documentation _and_ regression tests of the
|
7
|
+
behaviour.
|
8
|
+
|
9
|
+
## Issues
|
10
|
+
|
11
|
+
If you find this documentation incomplete or confusing, please [submit an
|
12
|
+
issue](http://github.com/rspec/rspec-mocks/issues).
|
@@ -0,0 +1,82 @@
|
|
1
|
+
Feature: configure a test frawework to use rspec-mocks
|
2
|
+
|
3
|
+
Test frameworks that want to use rspec-mocks can use
|
4
|
+
RSpec::Mocks::setup(self) to hook into rspec-mocks. Doing so adds the
|
5
|
+
following:
|
6
|
+
|
7
|
+
To the object passed to setup:
|
8
|
+
|
9
|
+
double # creates a test double
|
10
|
+
mock # creates a test double
|
11
|
+
stub # creates a test double
|
12
|
+
|
13
|
+
To every object in the system:
|
14
|
+
|
15
|
+
should_receive
|
16
|
+
should_not_receive
|
17
|
+
stub
|
18
|
+
|
19
|
+
In order to give control to the consuming framework, none of these facilities
|
20
|
+
are added until RSpec::Mocks::setup(self) is called. Simply requiring
|
21
|
+
'rspec/mocks' is not sufficient.
|
22
|
+
|
23
|
+
NOTICE: the stub() method that is added to the object passed to setup is not
|
24
|
+
the same stub() method that is added to every other object.
|
25
|
+
|
26
|
+
Scenario: RSpec::Mocks::setup(object) adds double, mock, and stub methods to the submitted object
|
27
|
+
Given a file named "foo.rb" with:
|
28
|
+
"""
|
29
|
+
require 'rspec/mocks'
|
30
|
+
|
31
|
+
class CodeExample
|
32
|
+
def init
|
33
|
+
RSpec::Mocks::setup(self)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
example = CodeExample.new
|
38
|
+
example.init
|
39
|
+
|
40
|
+
puts example.respond_to?(:double)
|
41
|
+
puts example.respond_to?(:mock)
|
42
|
+
puts example.respond_to?(:stub)
|
43
|
+
"""
|
44
|
+
|
45
|
+
When I run "ruby foo.rb"
|
46
|
+
Then the output should contain "true"
|
47
|
+
But the output should not contain "false"
|
48
|
+
|
49
|
+
Scenario: RSpec::Mocks::setup(anything) adds methods to Object
|
50
|
+
Given a file named "foo.rb" with:
|
51
|
+
"""
|
52
|
+
require 'rspec/mocks'
|
53
|
+
|
54
|
+
RSpec::Mocks::setup(Object.new)
|
55
|
+
|
56
|
+
obj = Object.new
|
57
|
+
|
58
|
+
puts obj.respond_to?(:should_receive)
|
59
|
+
puts obj.respond_to?(:should_not_receive)
|
60
|
+
puts obj.respond_to?(:stub)
|
61
|
+
"""
|
62
|
+
|
63
|
+
When I run "ruby foo.rb"
|
64
|
+
Then the output should contain "true"
|
65
|
+
But the output should not contain "false"
|
66
|
+
|
67
|
+
Scenario: require "rspec/mocks" does not add methods to Object
|
68
|
+
Given a file named "foo.rb" with:
|
69
|
+
"""
|
70
|
+
require 'rspec/mocks'
|
71
|
+
|
72
|
+
obj = Object.new
|
73
|
+
|
74
|
+
puts obj.respond_to?(:should_receive)
|
75
|
+
puts obj.respond_to?(:should_not_receive)
|
76
|
+
puts obj.respond_to?(:stub)
|
77
|
+
"""
|
78
|
+
|
79
|
+
When I run "ruby foo.rb"
|
80
|
+
Then the output should contain "false"
|
81
|
+
But the output should not contain "true"
|
82
|
+
|
@@ -30,7 +30,7 @@ Feature: block local expectations
|
|
30
30
|
end
|
31
31
|
"""
|
32
32
|
When I run "rspec ./spec/account_passing_spec.rb"
|
33
|
-
Then
|
33
|
+
Then the output should contain "1 example, 0 failures"
|
34
34
|
|
35
35
|
Scenario: failing example
|
36
36
|
|
@@ -51,4 +51,4 @@ Feature: block local expectations
|
|
51
51
|
"""
|
52
52
|
|
53
53
|
When I run "rspec ./spec/account_failing_spec.rb"
|
54
|
-
Then
|
54
|
+
Then the output should contain "1 example, 1 failure"
|
@@ -12,7 +12,7 @@ Feature: warn when expectation is set on nil
|
|
12
12
|
end
|
13
13
|
"""
|
14
14
|
When I run "rspec ./example_spec.rb"
|
15
|
-
Then
|
15
|
+
Then the output should contain "An expectation of :foo was set on nil"
|
16
16
|
|
17
17
|
Scenario: allow
|
18
18
|
Given a file named "example_spec.rb" with:
|
@@ -27,7 +27,7 @@ Feature: warn when expectation is set on nil
|
|
27
27
|
end
|
28
28
|
"""
|
29
29
|
When I run "rspec ./example_spec.rb"
|
30
|
-
Then
|
30
|
+
Then the output should not contain "An expectation"
|
31
31
|
|
32
32
|
Scenario: allow in one example, but not on another
|
33
33
|
Given a file named "example_spec.rb" with:
|
@@ -46,5 +46,5 @@ Feature: warn when expectation is set on nil
|
|
46
46
|
end
|
47
47
|
"""
|
48
48
|
When I run "rspec ./example_spec.rb"
|
49
|
-
Then
|
50
|
-
And
|
49
|
+
Then the output should contain "An expectation of :bar"
|
50
|
+
And the output should not contain "An expectation of :foo"
|
data/lib/rspec/mocks.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rspec/mocks/framework'
|
2
|
-
require 'rspec/mocks/extensions/object'
|
3
2
|
require 'rspec/mocks/version'
|
4
3
|
|
5
4
|
module RSpec
|
@@ -19,7 +18,7 @@ module RSpec
|
|
19
18
|
# double.stub(:title) { "The RSpec Book" }
|
20
19
|
# double.title => "The RSpec Book"
|
21
20
|
#
|
22
|
-
# When we declare a stub, we
|
21
|
+
# When we declare a stub, we say we are "stubbing" a method.
|
23
22
|
#
|
24
23
|
# == Message Expectations
|
25
24
|
#
|
@@ -32,7 +31,7 @@ module RSpec
|
|
32
31
|
# zipcode = Zipcode.new("02134", validator)
|
33
32
|
# zipcode.valid?
|
34
33
|
#
|
35
|
-
# When we declare a message expectation, we
|
34
|
+
# When we declare a message expectation, we say we are "mocking" a method.
|
36
35
|
#
|
37
36
|
# == Mock Objects and Test Stubs
|
38
37
|
#
|
@@ -173,5 +172,25 @@ module RSpec
|
|
173
172
|
# * Test Double Patterns: http://xunitpatterns.com/Test%20Double%20Patterns.html
|
174
173
|
# * Mocks aren't stubs: http://www.martinfowler.com/articles/mocksArentStubs.html
|
175
174
|
module Mocks
|
175
|
+
class << self
|
176
|
+
attr_accessor :space
|
177
|
+
|
178
|
+
def setup(includer)
|
179
|
+
require 'rspec/mocks/extensions/object'
|
180
|
+
require 'rspec/mocks/spec_methods'
|
181
|
+
(class << includer; self; end).class_eval do
|
182
|
+
include RSpec::Mocks::ExampleMethods
|
183
|
+
end
|
184
|
+
self.space ||= RSpec::Mocks::Space.new
|
185
|
+
end
|
186
|
+
|
187
|
+
def verify
|
188
|
+
space.verify_all
|
189
|
+
end
|
190
|
+
|
191
|
+
def teardown
|
192
|
+
space.reset_all
|
193
|
+
end
|
194
|
+
end
|
176
195
|
end
|
177
196
|
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'rspec/mocks/extensions/object'
|
@@ -2,10 +2,10 @@
|
|
2
2
|
# supports wrapping rspec's mocking functionality without invading every
|
3
3
|
# object in the system.
|
4
4
|
|
5
|
+
require 'rspec/mocks/extensions/instance_exec'
|
5
6
|
require 'rspec/mocks/method_double'
|
6
7
|
require 'rspec/mocks/methods'
|
7
8
|
require 'rspec/mocks/argument_matchers'
|
8
|
-
require 'rspec/mocks/spec_methods'
|
9
9
|
require 'rspec/mocks/proxy'
|
10
10
|
require 'rspec/mocks/mock'
|
11
11
|
require 'rspec/mocks/argument_expectation'
|
@@ -55,7 +55,7 @@ module RSpec
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def configure_method
|
58
|
-
|
58
|
+
RSpec::Mocks::space.add(@object) if RSpec::Mocks::space
|
59
59
|
warn_if_nil_class
|
60
60
|
unless @stashed
|
61
61
|
stash_original_method
|
@@ -64,14 +64,12 @@ module RSpec
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def stash_original_method
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
alias_method(stashed, orig) if method_defined?(orig) || private_method_defined?(orig)
|
72
|
-
end
|
73
|
-
@stashed = true
|
67
|
+
stashed = stashed_method_name
|
68
|
+
orig = @method_name
|
69
|
+
object_singleton_class.class_eval do
|
70
|
+
alias_method(stashed, orig) if method_defined?(orig) || private_method_defined?(orig)
|
74
71
|
end
|
72
|
+
@stashed = true
|
75
73
|
end
|
76
74
|
|
77
75
|
def define_proxy_method
|
data/lib/rspec/mocks/proxy.rb
CHANGED
@@ -15,7 +15,7 @@ module RSpec
|
|
15
15
|
|
16
16
|
# ensure nil.rspec_verify is called even if an expectation is not set in the example
|
17
17
|
# otherwise the allowance would effect subsequent examples
|
18
|
-
|
18
|
+
RSpec::Mocks::space.add(nil) unless RSpec::Mocks::space.nil?
|
19
19
|
end
|
20
20
|
|
21
21
|
def allow_message_expectations_on_nil?
|
data/rspec-mocks.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-mocks}
|
8
|
-
s.version = "2.0.0.beta.
|
8
|
+
s.version = "2.0.0.beta.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Chelimsky", "Chad Humphries"]
|
12
|
-
s.date = %q{2010-06
|
12
|
+
s.date = %q{2010-07-06}
|
13
13
|
s.description = %q{RSpec's 'test double' framework, with support for stubbing and mocking}
|
14
14
|
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,8 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION",
|
27
27
|
"autotest/discover.rb",
|
28
28
|
"cucumber.yml",
|
29
|
+
"features/README.markdown",
|
30
|
+
"features/configuration.feature",
|
29
31
|
"features/mocks/block_local_expectations.feature",
|
30
|
-
"features/mocks/mix_stubs_and_mocks.feature",
|
31
32
|
"features/mocks/warn_when_expectation_is_set_on_nil.feature",
|
32
33
|
"features/stubs/stub_implementation.feature",
|
33
34
|
"features/support/env.rb",
|
@@ -92,6 +93,7 @@ Gem::Specification.new do |s|
|
|
92
93
|
"spec/rspec/mocks/stub_spec.rb",
|
93
94
|
"spec/rspec/mocks/stubbed_message_expectations_spec.rb",
|
94
95
|
"spec/rspec/mocks/twice_counts_spec.rb",
|
96
|
+
"spec/rspec/mocks_spec.rb",
|
95
97
|
"spec/spec_helper.rb",
|
96
98
|
"spec/support/macros.rb",
|
97
99
|
"specs.watchr"
|
@@ -99,7 +101,7 @@ Gem::Specification.new do |s|
|
|
99
101
|
s.homepage = %q{http://github.com/rspec/mocks}
|
100
102
|
s.post_install_message = %q{**************************************************
|
101
103
|
|
102
|
-
Thank you for installing rspec-mocks-2.0.0.beta.
|
104
|
+
Thank you for installing rspec-mocks-2.0.0.beta.16
|
103
105
|
|
104
106
|
**************************************************
|
105
107
|
}
|
@@ -107,7 +109,7 @@ Gem::Specification.new do |s|
|
|
107
109
|
s.require_paths = ["lib"]
|
108
110
|
s.rubyforge_project = %q{rspec}
|
109
111
|
s.rubygems_version = %q{1.3.7}
|
110
|
-
s.summary = %q{rspec-mocks-2.0.0.beta.
|
112
|
+
s.summary = %q{rspec-mocks-2.0.0.beta.16}
|
111
113
|
s.test_files = [
|
112
114
|
"spec/rspec/mocks/and_yield_spec.rb",
|
113
115
|
"spec/rspec/mocks/any_number_of_times_spec.rb",
|
@@ -150,6 +152,7 @@ Gem::Specification.new do |s|
|
|
150
152
|
"spec/rspec/mocks/stub_spec.rb",
|
151
153
|
"spec/rspec/mocks/stubbed_message_expectations_spec.rb",
|
152
154
|
"spec/rspec/mocks/twice_counts_spec.rb",
|
155
|
+
"spec/rspec/mocks_spec.rb",
|
153
156
|
"spec/spec_helper.rb",
|
154
157
|
"spec/support/macros.rb"
|
155
158
|
]
|
@@ -159,15 +162,15 @@ Gem::Specification.new do |s|
|
|
159
162
|
s.specification_version = 3
|
160
163
|
|
161
164
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
162
|
-
s.add_development_dependency(%q<rspec-core>, ["= 2.0.0.beta.
|
163
|
-
s.add_development_dependency(%q<rspec-expectations>, ["= 2.0.0.beta.
|
165
|
+
s.add_development_dependency(%q<rspec-core>, ["= 2.0.0.beta.16"])
|
166
|
+
s.add_development_dependency(%q<rspec-expectations>, ["= 2.0.0.beta.16"])
|
164
167
|
else
|
165
|
-
s.add_dependency(%q<rspec-core>, ["= 2.0.0.beta.
|
166
|
-
s.add_dependency(%q<rspec-expectations>, ["= 2.0.0.beta.
|
168
|
+
s.add_dependency(%q<rspec-core>, ["= 2.0.0.beta.16"])
|
169
|
+
s.add_dependency(%q<rspec-expectations>, ["= 2.0.0.beta.16"])
|
167
170
|
end
|
168
171
|
else
|
169
|
-
s.add_dependency(%q<rspec-core>, ["= 2.0.0.beta.
|
170
|
-
s.add_dependency(%q<rspec-expectations>, ["= 2.0.0.beta.
|
172
|
+
s.add_dependency(%q<rspec-core>, ["= 2.0.0.beta.16"])
|
173
|
+
s.add_dependency(%q<rspec-expectations>, ["= 2.0.0.beta.16"])
|
171
174
|
end
|
172
175
|
end
|
173
176
|
|
@@ -1,66 +1,94 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module RSpec
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
module RSpec::Mocks
|
4
|
+
describe "PartialMockUsingMocksDirectly" do
|
5
|
+
let(:klass) do
|
6
|
+
Class.new do
|
7
|
+
module MethodMissing
|
8
|
+
def method_missing(m, *a, &b)
|
9
|
+
if m == :captured_by_method_missing
|
10
|
+
"response generated by method missing"
|
11
|
+
else
|
12
|
+
super(m, *a, &b)
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
|
-
|
15
|
-
|
16
|
+
|
17
|
+
extend MethodMissing
|
18
|
+
include MethodMissing
|
19
|
+
|
20
|
+
def existing_method
|
21
|
+
:original_value
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
16
25
|
end
|
17
|
-
|
26
|
+
|
27
|
+
let(:obj) { klass.new }
|
28
|
+
|
18
29
|
# See http://rubyforge.org/tracker/index.php?func=detail&aid=10263&group_id=797&atid=3149
|
19
30
|
# specify "should clear expectations on verify" do
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
31
|
+
# obj.should_receive(:msg)
|
32
|
+
# obj.msg
|
33
|
+
# obj.rspec_verify
|
23
34
|
# lambda do
|
24
|
-
#
|
35
|
+
# obj.msg
|
25
36
|
# end.should raise_error(NoMethodError)
|
26
37
|
#
|
27
38
|
# end
|
28
|
-
it "
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
39
|
+
it "fails when expected message is not received" do
|
40
|
+
obj.should_receive(:msg)
|
41
|
+
lambda do
|
42
|
+
obj.rspec_verify
|
43
|
+
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "fails when message is received with incorrect args" do
|
47
|
+
obj.should_receive(:msg).with(:correct_arg)
|
48
|
+
lambda do
|
49
|
+
obj.msg(:incorrect_arg)
|
50
|
+
end.should raise_error(RSpec::Mocks::MockExpectationError)
|
51
|
+
obj.msg(:correct_arg)
|
34
52
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
53
|
+
|
54
|
+
it "passes when expected message is received" do
|
55
|
+
obj.should_receive(:msg)
|
56
|
+
obj.msg
|
57
|
+
obj.rspec_verify
|
58
|
+
end
|
59
|
+
|
60
|
+
it "passes when message is received with correct args" do
|
61
|
+
obj.should_receive(:msg).with(:correct_arg)
|
62
|
+
obj.msg(:correct_arg)
|
63
|
+
obj.rspec_verify
|
42
64
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
65
|
+
|
66
|
+
it "should restore original method if existed" do
|
67
|
+
obj.existing_method.should equal(:original_value)
|
68
|
+
obj.should_receive(:existing_method).and_return(:mock_value)
|
69
|
+
obj.existing_method.should equal(:mock_value)
|
70
|
+
obj.rspec_verify
|
71
|
+
obj.existing_method.should equal(:original_value)
|
48
72
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
73
|
+
|
74
|
+
context "with an instance method handled by method_missing" do
|
75
|
+
it "restores the original behavior" do
|
76
|
+
obj.captured_by_method_missing.should eq("response generated by method missing")
|
77
|
+
obj.stub(:captured_by_method_missing) { "foo" }
|
78
|
+
obj.captured_by_method_missing.should eq("foo")
|
79
|
+
obj.rspec_reset
|
80
|
+
obj.captured_by_method_missing.should eq("response generated by method missing")
|
81
|
+
end
|
54
82
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
83
|
+
|
84
|
+
context "with a class method handled by method_missing" do
|
85
|
+
it "restores the original behavior" do
|
86
|
+
klass.captured_by_method_missing.should eq("response generated by method missing")
|
87
|
+
klass.stub(:captured_by_method_missing) { "foo" }
|
88
|
+
klass.captured_by_method_missing.should eq("foo")
|
89
|
+
klass.rspec_reset
|
90
|
+
klass.captured_by_method_missing.should eq("response generated by method missing")
|
91
|
+
end
|
62
92
|
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
93
|
+
end
|
66
94
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RSpec::Mocks do
|
4
|
+
describe "::setup" do
|
5
|
+
context "with an existing Mock::Space" do
|
6
|
+
before do
|
7
|
+
@orig_space = RSpec::Mocks::space
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
RSpec::Mocks::space = @orig_space
|
12
|
+
end
|
13
|
+
|
14
|
+
it "memoizes the space" do
|
15
|
+
RSpec::Mocks::setup(Object.new)
|
16
|
+
space = RSpec::Mocks::space
|
17
|
+
RSpec::Mocks::setup(Object.new)
|
18
|
+
RSpec::Mocks::space.should equal(space)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with no pre-existing Mock::Space" do
|
23
|
+
it "initializes a Mock::Space" do
|
24
|
+
RSpec::Mocks::space = nil
|
25
|
+
RSpec::Mocks::setup(Object.new)
|
26
|
+
RSpec::Mocks::space.should_not be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "::verify" do
|
32
|
+
it "delegates to the space" do
|
33
|
+
foo = double
|
34
|
+
foo.should_receive(:bar)
|
35
|
+
expect do
|
36
|
+
RSpec::Mocks::verify
|
37
|
+
end.to raise_error(RSpec::Mocks::MockExpectationError)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "::teardown" do
|
42
|
+
it "delegates to the space" do
|
43
|
+
foo = double
|
44
|
+
foo.should_receive(:bar)
|
45
|
+
RSpec::Mocks::teardown
|
46
|
+
expect do
|
47
|
+
foo.bar
|
48
|
+
end.to raise_error(/received unexpected message/)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-mocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196419
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 2.0.0.beta.
|
11
|
+
- 16
|
12
|
+
version: 2.0.0.beta.16
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- David Chelimsky
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-06
|
21
|
+
date: 2010-07-06 00:00:00 -05:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
hash:
|
33
|
+
hash: 62196419
|
34
34
|
segments:
|
35
35
|
- 2
|
36
36
|
- 0
|
37
37
|
- 0
|
38
38
|
- beta
|
39
|
-
-
|
40
|
-
version: 2.0.0.beta.
|
39
|
+
- 16
|
40
|
+
version: 2.0.0.beta.16
|
41
41
|
requirement: *id001
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
type: :development
|
@@ -48,14 +48,14 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - "="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
hash:
|
51
|
+
hash: 62196419
|
52
52
|
segments:
|
53
53
|
- 2
|
54
54
|
- 0
|
55
55
|
- 0
|
56
56
|
- beta
|
57
|
-
-
|
58
|
-
version: 2.0.0.beta.
|
57
|
+
- 16
|
58
|
+
version: 2.0.0.beta.16
|
59
59
|
requirement: *id002
|
60
60
|
description: RSpec's 'test double' framework, with support for stubbing and mocking
|
61
61
|
email: dchelimsky@gmail.com;chad.humphries@gmail.com
|
@@ -76,8 +76,9 @@ files:
|
|
76
76
|
- VERSION
|
77
77
|
- autotest/discover.rb
|
78
78
|
- cucumber.yml
|
79
|
+
- features/README.markdown
|
80
|
+
- features/configuration.feature
|
79
81
|
- features/mocks/block_local_expectations.feature
|
80
|
-
- features/mocks/mix_stubs_and_mocks.feature
|
81
82
|
- features/mocks/warn_when_expectation_is_set_on_nil.feature
|
82
83
|
- features/stubs/stub_implementation.feature
|
83
84
|
- features/support/env.rb
|
@@ -142,6 +143,7 @@ files:
|
|
142
143
|
- spec/rspec/mocks/stub_spec.rb
|
143
144
|
- spec/rspec/mocks/stubbed_message_expectations_spec.rb
|
144
145
|
- spec/rspec/mocks/twice_counts_spec.rb
|
146
|
+
- spec/rspec/mocks_spec.rb
|
145
147
|
- spec/spec_helper.rb
|
146
148
|
- spec/support/macros.rb
|
147
149
|
- specs.watchr
|
@@ -152,7 +154,7 @@ licenses: []
|
|
152
154
|
post_install_message: |
|
153
155
|
**************************************************
|
154
156
|
|
155
|
-
Thank you for installing rspec-mocks-2.0.0.beta.
|
157
|
+
Thank you for installing rspec-mocks-2.0.0.beta.16
|
156
158
|
|
157
159
|
**************************************************
|
158
160
|
|
@@ -186,7 +188,7 @@ rubyforge_project: rspec
|
|
186
188
|
rubygems_version: 1.3.7
|
187
189
|
signing_key:
|
188
190
|
specification_version: 3
|
189
|
-
summary: rspec-mocks-2.0.0.beta.
|
191
|
+
summary: rspec-mocks-2.0.0.beta.16
|
190
192
|
test_files:
|
191
193
|
- spec/rspec/mocks/and_yield_spec.rb
|
192
194
|
- spec/rspec/mocks/any_number_of_times_spec.rb
|
@@ -229,5 +231,6 @@ test_files:
|
|
229
231
|
- spec/rspec/mocks/stub_spec.rb
|
230
232
|
- spec/rspec/mocks/stubbed_message_expectations_spec.rb
|
231
233
|
- spec/rspec/mocks/twice_counts_spec.rb
|
234
|
+
- spec/rspec/mocks_spec.rb
|
232
235
|
- spec/spec_helper.rb
|
233
236
|
- spec/support/macros.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
Feature: Spec and test together
|
2
|
-
|
3
|
-
As an RSpec user
|
4
|
-
I want to use stubs and mocks together
|
5
|
-
|
6
|
-
Scenario: stub in before
|
7
|
-
Given a file named "stub_and_mocks_spec.rb" with:
|
8
|
-
"""
|
9
|
-
require 'rspec/expectations'
|
10
|
-
|
11
|
-
RSpec.configure do |config|
|
12
|
-
config.mock_framework = :rspec
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "a stub in before" do
|
16
|
-
before(:each) do
|
17
|
-
@messenger = double('messenger').as_null_object
|
18
|
-
end
|
19
|
-
|
20
|
-
it "a" do
|
21
|
-
@messenger.should_receive(:foo).with('first')
|
22
|
-
@messenger.foo('second')
|
23
|
-
@messenger.foo('third')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
"""
|
27
|
-
When I run "rspec ./stub_and_mocks_spec.rb -fs"
|
28
|
-
Then I should see "received :foo with unexpected arguments"
|