rr 1.1.1 → 1.1.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +46 -0
- data/CHANGES.md +21 -1
- data/Gemfile +19 -0
- data/README.md +91 -106
- data/Rakefile +55 -0
- data/gemfiles/ruby_18_rspec_1.gemfile +14 -0
- data/gemfiles/ruby_18_rspec_1.gemfile.lock +38 -0
- data/gemfiles/ruby_18_rspec_1_rails_2.gemfile +18 -0
- data/gemfiles/ruby_18_rspec_1_rails_2.gemfile.lock +64 -0
- data/gemfiles/ruby_19_rspec_2.gemfile +14 -0
- data/gemfiles/ruby_19_rspec_2.gemfile.lock +49 -0
- data/gemfiles/ruby_19_rspec_2_rails_3.gemfile +15 -0
- data/gemfiles/ruby_19_rspec_2_rails_3.gemfile.lock +123 -0
- data/gemfiles/ruby_19_rspec_2_rails_4.gemfile +15 -0
- data/gemfiles/ruby_19_rspec_2_rails_4.gemfile.lock +119 -0
- data/lib/rr/adapters.rb +4 -14
- data/lib/rr/integrations.rb +13 -12
- data/lib/rr/integrations/decorator.rb +4 -1
- data/lib/rr/integrations/rspec_2.rb +6 -1
- data/lib/rr/integrations/test_unit_1.rb +2 -2
- data/lib/rr/integrations/test_unit_2.rb +3 -1
- data/lib/rr/version.rb +1 -2
- data/lib/rr/without_autohook.rb +1 -1
- data/rr.gemspec +6 -2
- data/spec/custom_formatter_for_rspec.rb +18 -0
- data/spec/custom_formatter_for_rspec_2.rb +40 -0
- data/spec/defines_spec_suite_tasks.rb +45 -0
- data/spec/fixtures/rubygems_patch_for_187.rb +598 -0
- data/spec/global_helper.rb +33 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_suite_configuration.rb +132 -0
- data/spec/spec_suite_runner.rb +47 -0
- data/spec/suites.yml +24 -0
- data/spec/suites/rspec_1/helper.rb +24 -0
- data/spec/suites/rspec_1/integration/rspec_1_spec.rb +93 -0
- data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +102 -0
- data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +109 -0
- data/spec/suites/rspec_1/spec_helper.rb +3 -0
- data/spec/suites/rspec_1_rails_2/integration/astc_rails_2_spec.rb +141 -0
- data/spec/suites/rspec_1_rails_2/integration/rspec_1_rails_2_spec.rb +132 -0
- data/spec/suites/rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb +141 -0
- data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +148 -0
- data/spec/suites/rspec_1_rails_2/spec_helper.rb +3 -0
- data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +47 -0
- data/spec/suites/rspec_2/functional/dont_allow_spec.rb +12 -0
- data/spec/suites/rspec_2/functional/dsl_spec.rb +13 -0
- data/spec/suites/rspec_2/functional/instance_of_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/mock_spec.rb +241 -0
- data/spec/suites/rspec_2/functional/proxy_spec.rb +136 -0
- data/spec/suites/rspec_2/functional/spy_spec.rb +41 -0
- data/spec/suites/rspec_2/functional/strong_spec.rb +79 -0
- data/spec/suites/rspec_2/functional/stub_spec.rb +190 -0
- data/spec/suites/rspec_2/functional/wildcard_matchers_spec.rb +128 -0
- data/spec/suites/rspec_2/helper.rb +28 -0
- data/spec/suites/rspec_2/integration/minitest_4_spec.rb +109 -0
- data/spec/suites/rspec_2/integration/minitest_spec.rb +109 -0
- data/spec/suites/rspec_2/integration/rspec_2_spec.rb +133 -0
- data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +102 -0
- data/spec/suites/rspec_2/integration/test_unit_2_spec.rb +109 -0
- data/spec/suites/rspec_2/spec_helper.rb +3 -0
- data/spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb +32 -0
- data/spec/suites/rspec_2/support/shared_examples/space.rb +13 -0
- data/spec/suites/rspec_2/support/shared_examples/times_called_expectation.rb +9 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +135 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +101 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/core_ext/array_spec.rb +39 -0
- data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +81 -0
- data/spec/suites/rspec_2/unit/core_ext/hash_spec.rb +55 -0
- data/spec/suites/rspec_2/unit/core_ext/range_spec.rb +41 -0
- data/spec/suites/rspec_2/unit/core_ext/regexp_spec.rb +41 -0
- data/spec/suites/rspec_2/unit/double_definitions/child_double_definition_create_spec.rb +114 -0
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_blank_slate_spec.rb +93 -0
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +446 -0
- data/spec/suites/rspec_2/unit/errors/rr_error_spec.rb +67 -0
- data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +48 -0
- data/spec/suites/rspec_2/unit/expectations/anything_argument_equality_expectation_spec.rb +14 -0
- data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +135 -0
- data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +30 -0
- data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +82 -0
- data/spec/suites/rspec_2/unit/expectations/satisfy_argument_equality_expectation_spec.rb +61 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/any_times_matcher_spec.rb +22 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_least_matcher_spec.rb +37 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb +43 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/integer_matcher_spec.rb +58 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/proc_matcher_spec.rb +35 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/range_matcher_spec.rb +39 -0
- data/spec/suites/rspec_2/unit/hash_with_object_id_key_spec.rb +88 -0
- data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb +545 -0
- data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb +32 -0
- data/spec/suites/rspec_2/unit/integrations/rspec/invocation_matcher_spec.rb +297 -0
- data/spec/suites/rspec_2/unit/integrations/rspec_spec.rb +85 -0
- data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +14 -0
- data/spec/suites/rspec_2/unit/rr_spec.rb +28 -0
- data/spec/suites/rspec_2/unit/space_spec.rb +595 -0
- data/spec/suites/rspec_2/unit/spy_verification_spec.rb +133 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/any_times_matcher_spec.rb +46 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/at_least_matcher_spec.rb +54 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/at_most_matcher_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/integer_matcher_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/proc_matcher_spec.rb +54 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/range_matcher_spec.rb +75 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/times_called_matcher_spec.rb +117 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/anything_spec.rb +33 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/boolean_spec.rb +45 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/duck_type_spec.rb +64 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/hash_including_spec.rb +64 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/is_a_spec.rb +55 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/numeric_spec.rb +46 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/satisfy_spec.rb +57 -0
- data/spec/suites/rspec_2_rails_3/integration/astc_rails_3_spec.rb +141 -0
- data/spec/suites/rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb +148 -0
- data/spec/suites/rspec_2_rails_3/integration/rspec_2_rails_3_spec.rb +172 -0
- data/spec/suites/rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb +141 -0
- data/spec/suites/rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb +148 -0
- data/spec/suites/rspec_2_rails_3/spec_helper.rb +3 -0
- data/spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb +142 -0
- data/spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb +149 -0
- data/spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb +173 -0
- data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +142 -0
- data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +149 -0
- data/spec/suites/rspec_2_rails_4/spec_helper.rb +3 -0
- data/spec/support/adapter.rb +22 -0
- data/spec/support/adapter_tests/base.rb +45 -0
- data/spec/support/adapter_tests/minitest.rb +7 -0
- data/spec/support/adapter_tests/rspec.rb +66 -0
- data/spec/support/adapter_tests/test_unit.rb +47 -0
- data/spec/support/command_runner.rb +105 -0
- data/spec/support/generator.rb +56 -0
- data/spec/support/integration_tests/base.rb +64 -0
- data/spec/support/integration_tests/rails.rb +60 -0
- data/spec/support/integration_tests/rails_minitest.rb +13 -0
- data/spec/support/integration_tests/rails_rspec.rb +13 -0
- data/spec/support/integration_tests/rails_test_unit.rb +13 -0
- data/spec/support/integration_tests/rails_test_unit_like.rb +13 -0
- data/spec/support/integration_tests/ruby.rb +7 -0
- data/spec/support/integration_tests/ruby_minitest.rb +13 -0
- data/spec/support/integration_tests/ruby_rspec.rb +13 -0
- data/spec/support/integration_tests/ruby_test_unit.rb +13 -0
- data/spec/support/matchers/be_a_subset_of_matcher.rb +24 -0
- data/spec/support/project/cucumber.rb +50 -0
- data/spec/support/project/generator.rb +352 -0
- data/spec/support/project/minitest.rb +39 -0
- data/spec/support/project/rails.rb +199 -0
- data/spec/support/project/rails_minitest.rb +17 -0
- data/spec/support/project/rails_rspec.rb +50 -0
- data/spec/support/project/rails_test_unit.rb +17 -0
- data/spec/support/project/rails_test_unit_like.rb +17 -0
- data/spec/support/project/rspec.rb +69 -0
- data/spec/support/project/ruby.rb +34 -0
- data/spec/support/project/ruby_minitest.rb +11 -0
- data/spec/support/project/ruby_rspec.rb +29 -0
- data/spec/support/project/ruby_test_unit.rb +11 -0
- data/spec/support/project/ruby_test_unit_like.rb +21 -0
- data/spec/support/project/test_unit.rb +29 -0
- data/spec/support/project/test_unit_like.rb +7 -0
- data/spec/support/project/tests_runner.rb +22 -0
- data/spec/support/test.sqlite3 +0 -0
- data/spec/support/test_case/generator.rb +53 -0
- data/spec/support/test_case/minitest.rb +13 -0
- data/spec/support/test_case/rspec.rb +19 -0
- data/spec/support/test_case/test_unit.rb +21 -0
- data/spec/support/test_file/generator.rb +120 -0
- data/spec/support/test_file/minitest.rb +19 -0
- data/spec/support/test_file/rails_minitest.rb +7 -0
- data/spec/support/test_file/rails_rspec.rb +12 -0
- data/spec/support/test_file/rails_test_unit.rb +25 -0
- data/spec/support/test_file/rspec.rb +33 -0
- data/spec/support/test_file/test_unit.rb +36 -0
- data/spec/support/test_helper/generator.rb +27 -0
- data/spec/support/test_helper/minitest.rb +7 -0
- data/spec/support/test_helper/rails.rb +31 -0
- data/spec/support/test_helper/rails_minitest.rb +7 -0
- data/spec/support/test_helper/rails_rspec.rb +25 -0
- data/spec/support/test_helper/rails_test_unit.rb +23 -0
- data/spec/support/test_helper/rspec.rb +7 -0
- data/spec/support/test_helper/ruby.rb +31 -0
- data/spec/support/test_helper/test_unit.rb +7 -0
- metadata +172 -6
- data/VERSION +0 -1
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module Injections
|
5
|
+
describe DoubleInjection, "#verify" do
|
6
|
+
subject { Object.new }
|
7
|
+
|
8
|
+
include_examples "Swapped Space"
|
9
|
+
|
10
|
+
attr_reader :method_name, :double_injection
|
11
|
+
|
12
|
+
before do
|
13
|
+
@method_name = :foobar
|
14
|
+
subject.methods.should_not include(method_name.to_s)
|
15
|
+
@double_injection = ::RR::Injections::DoubleInjection.find_or_create_by_subject(subject, method_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "verifies each double was met" do
|
19
|
+
double = RR::Double.new(
|
20
|
+
double_injection,
|
21
|
+
RR::DoubleDefinitions::DoubleDefinition.new(RR::DoubleDefinitions::DoubleDefinitionCreate.new)
|
22
|
+
)
|
23
|
+
double_injection.register_double double
|
24
|
+
|
25
|
+
double.definition.with(1).once.returns {nil}
|
26
|
+
expect { double_injection.verify }.to raise_error(RR::Errors::TimesCalledError)
|
27
|
+
subject.foobar(1)
|
28
|
+
expect { double_injection.verify }.to_not raise_error
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,297 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module Integrations
|
5
|
+
module RSpec
|
6
|
+
describe InvocationMatcher do
|
7
|
+
describe "matching against a method with no doubles" do
|
8
|
+
before do
|
9
|
+
@matcher = InvocationMatcher.new(:foobar)
|
10
|
+
@result = @matcher.matches?(Object.new)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "does not match" do
|
14
|
+
@result.should_not be
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "defining an expectation using a method invocation" do
|
19
|
+
subject { Object.new }
|
20
|
+
|
21
|
+
before do
|
22
|
+
stub(subject).foobar
|
23
|
+
subject.foobar(:args)
|
24
|
+
@result = InvocationMatcher.new.foobar(:args).matches?(subject)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "uses the invoked method as the expected method" do
|
28
|
+
expect(@result).to be
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "matching against a stubbed method that was never called" do
|
33
|
+
subject { Object.new }
|
34
|
+
|
35
|
+
before do
|
36
|
+
stub(subject).foobar
|
37
|
+
@matcher = InvocationMatcher.new(:foobar)
|
38
|
+
@result = @matcher.matches?(subject)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "does not match" do
|
42
|
+
@result.should_not be
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "matching against a stubbed method that was called once" do
|
47
|
+
subject { Object.new }
|
48
|
+
|
49
|
+
before do
|
50
|
+
stub(subject).foobar
|
51
|
+
subject.foobar
|
52
|
+
@result = InvocationMatcher.new(:foobar).matches?(subject)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "does match" do
|
56
|
+
expect(@result).to be
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "matching against a stubbed method that was called with unexpected arguments" do
|
61
|
+
subject { Object.new }
|
62
|
+
|
63
|
+
before do
|
64
|
+
@args = %w(one two)
|
65
|
+
stub(subject).foobar
|
66
|
+
subject.foobar(:other)
|
67
|
+
@result = InvocationMatcher.new(:foobar).with(*@args).matches?(subject)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "does not match" do
|
71
|
+
@result.should_not be
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "matching against a stubbed method that was called with expected arguments" do
|
76
|
+
subject { Object.new }
|
77
|
+
|
78
|
+
before do
|
79
|
+
@args = %w(one two)
|
80
|
+
stub(subject).foobar
|
81
|
+
subject.foobar(*@args)
|
82
|
+
@result = InvocationMatcher.new(:foobar).with(*@args).matches?(subject)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "does match" do
|
86
|
+
expect(@result).to be
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "defining a fulfilled argument expectation using a method invocation" do
|
91
|
+
subject { Object.new }
|
92
|
+
|
93
|
+
before do
|
94
|
+
@args = %w(one two)
|
95
|
+
stub(subject).foobar
|
96
|
+
subject.foobar(*@args)
|
97
|
+
@result = InvocationMatcher.new.foobar(*@args).matches?(subject)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "does match" do
|
101
|
+
expect(@result).to be
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "defining an unfulfilled argument expectation using a method invocation" do
|
106
|
+
subject { Object.new }
|
107
|
+
|
108
|
+
before do
|
109
|
+
@args = %w(one two)
|
110
|
+
stub(subject).foobar
|
111
|
+
subject.foobar(:other)
|
112
|
+
@result = InvocationMatcher.new.foobar(*@args).matches?(subject)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "does not match" do
|
116
|
+
@result.should_not be
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "matching against a stubbed method that was called more than once" do
|
121
|
+
subject { Object.new }
|
122
|
+
|
123
|
+
before do
|
124
|
+
stub(subject).foobar
|
125
|
+
2.times { subject.foobar }
|
126
|
+
@result = InvocationMatcher.new(:foobar).twice.matches?(subject)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "does match" do
|
130
|
+
expect(@result).to be
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "matching a stubbed method with any arguments" do
|
135
|
+
subject { Object.new }
|
136
|
+
|
137
|
+
before do
|
138
|
+
stub(subject).foobar
|
139
|
+
subject.foobar(:args)
|
140
|
+
@result = InvocationMatcher.new(:foobar).with_any_args.matches?(subject)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "does match" do
|
144
|
+
expect(@result).to be
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "matching a stubbed method with no arguments when arguments are not provided" do
|
149
|
+
subject { Object.new }
|
150
|
+
|
151
|
+
before do
|
152
|
+
stub(subject).foobar
|
153
|
+
subject.foobar
|
154
|
+
@result = InvocationMatcher.new(:foobar).with_no_args.matches?(subject)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "does match" do
|
158
|
+
expect(@result).to be
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "matching a stubbed method with no arguments when arguments are provided" do
|
163
|
+
subject { Object.new }
|
164
|
+
|
165
|
+
before do
|
166
|
+
stub(subject).foobar
|
167
|
+
subject.foobar(:args)
|
168
|
+
@result = InvocationMatcher.new(:foobar).with_no_args.matches?(subject)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "does not match" do
|
172
|
+
@result.should_not be
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "matching a method that was called twice when expected once" do
|
177
|
+
subject { Object.new }
|
178
|
+
|
179
|
+
before do
|
180
|
+
stub(subject).foobar
|
181
|
+
2.times { subject.foobar }
|
182
|
+
@matcher = InvocationMatcher.new(:foobar).times(1)
|
183
|
+
@result = @matcher.matches?(subject)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "does not match" do
|
187
|
+
@result.should_not be
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "matching a method that was called twice when expected twice" do
|
192
|
+
subject { Object.new }
|
193
|
+
|
194
|
+
before do
|
195
|
+
stub(subject).foobar
|
196
|
+
2.times { subject.foobar }
|
197
|
+
@result = InvocationMatcher.new(:foobar).times(2).matches?(subject)
|
198
|
+
end
|
199
|
+
|
200
|
+
it "does match" do
|
201
|
+
expect(@result).to be
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "matching a method that was called twice when any number of times" do
|
206
|
+
subject { Object.new }
|
207
|
+
|
208
|
+
before do
|
209
|
+
stub(subject).foobar
|
210
|
+
2.times { subject.foobar }
|
211
|
+
@result = InvocationMatcher.new(:foobar).any_number_of_times.matches?(subject)
|
212
|
+
end
|
213
|
+
|
214
|
+
it "does match" do
|
215
|
+
expect(@result).to be
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "matching a method that was called three times when expected at most twice" do
|
220
|
+
subject { Object.new }
|
221
|
+
|
222
|
+
before do
|
223
|
+
stub(subject).foobar
|
224
|
+
3.times { subject.foobar }
|
225
|
+
@result = InvocationMatcher.new(:foobar).at_most(2).matches?(subject)
|
226
|
+
end
|
227
|
+
|
228
|
+
it "does not match" do
|
229
|
+
@result.should_not be
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "matching a method that was called once when expected at most twice" do
|
234
|
+
subject { Object.new }
|
235
|
+
|
236
|
+
before do
|
237
|
+
stub(subject).foobar
|
238
|
+
subject.foobar
|
239
|
+
@result = InvocationMatcher.new(:foobar).at_most(2).matches?(subject)
|
240
|
+
end
|
241
|
+
|
242
|
+
it "does match" do
|
243
|
+
expect(@result).to be
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe "matching a method that was called once when expected at least twice" do
|
248
|
+
subject { Object.new }
|
249
|
+
|
250
|
+
before do
|
251
|
+
stub(subject).foobar
|
252
|
+
subject.foobar
|
253
|
+
@result = InvocationMatcher.new(:foobar).at_least(2).matches?(subject)
|
254
|
+
end
|
255
|
+
|
256
|
+
it "does not match" do
|
257
|
+
@result.should_not be
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe "matching a method that was called three times when expected at least twice" do
|
262
|
+
subject { Object.new }
|
263
|
+
|
264
|
+
before do
|
265
|
+
stub(subject).foobar
|
266
|
+
3.times { subject.foobar }
|
267
|
+
@result = InvocationMatcher.new(:foobar).at_least(2).matches?(subject)
|
268
|
+
end
|
269
|
+
|
270
|
+
it "does match" do
|
271
|
+
expect(@result).to be
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe "that does not match" do
|
276
|
+
before do
|
277
|
+
@error = Object.new
|
278
|
+
@message = 'Verification error message'
|
279
|
+
stub(RR::Space.instance.recorded_calls).match_error { @error }
|
280
|
+
stub(@error).message { @message }
|
281
|
+
|
282
|
+
@matcher = InvocationMatcher.new(:foobar)
|
283
|
+
@result = @matcher.matches?(Object.new)
|
284
|
+
end
|
285
|
+
|
286
|
+
it "returns false when matching" do
|
287
|
+
@result.should_not be
|
288
|
+
end
|
289
|
+
|
290
|
+
it "returns a failure messsage" do
|
291
|
+
expect(@matcher.failure_message).to eq @message
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
module Integrations
|
5
|
+
describe RSpec1 do
|
6
|
+
attr_reader :fixture, :method_name
|
7
|
+
|
8
|
+
describe "#setup_mocks_for_rspec" do
|
9
|
+
subject { Object.new }
|
10
|
+
|
11
|
+
before do
|
12
|
+
@fixture = Object.new
|
13
|
+
fixture.extend RSpec1::Mixin
|
14
|
+
@method_name = :foobar
|
15
|
+
end
|
16
|
+
|
17
|
+
it "resets the double_injections" do
|
18
|
+
stub(subject).foobar
|
19
|
+
::RR::Injections::DoubleInjection.instances.should_not be_empty
|
20
|
+
|
21
|
+
fixture.setup_mocks_for_rspec
|
22
|
+
expect(::RR::Injections::DoubleInjection.instances).to be_empty
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#verify_mocks_for_rspec" do
|
27
|
+
subject { Object.new }
|
28
|
+
|
29
|
+
before do
|
30
|
+
@fixture = Object.new
|
31
|
+
fixture.extend RSpec1::Mixin
|
32
|
+
@method_name = :foobar
|
33
|
+
end
|
34
|
+
|
35
|
+
it "verifies the double_injections" do
|
36
|
+
mock(subject).foobar
|
37
|
+
|
38
|
+
expect {
|
39
|
+
fixture.verify_mocks_for_rspec
|
40
|
+
}.to raise_error(::RR::Errors::TimesCalledError)
|
41
|
+
expect(::RR::Injections::DoubleInjection.instances).to be_empty
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#teardown_mocks_for_rspec" do
|
46
|
+
subject { Object.new }
|
47
|
+
|
48
|
+
before do
|
49
|
+
@fixture = Object.new
|
50
|
+
fixture.extend RSpec1::Mixin
|
51
|
+
@method_name = :foobar
|
52
|
+
end
|
53
|
+
|
54
|
+
it "resets the double_injections" do
|
55
|
+
stub(subject).foobar
|
56
|
+
::RR::Injections::DoubleInjection.instances.should_not be_empty
|
57
|
+
|
58
|
+
fixture.teardown_mocks_for_rspec
|
59
|
+
expect(::RR::Injections::DoubleInjection.instances).to be_empty
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#trim_backtrace" do
|
64
|
+
it "does not set trim_backtrace" do
|
65
|
+
expect(RR.trim_backtrace).to eq false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#have_received' do
|
70
|
+
it "creates an invocation matcher with a method name" do
|
71
|
+
method = :test
|
72
|
+
matcher = 'fake'
|
73
|
+
mock(RR::Integrations::RSpec::InvocationMatcher).new(method) { matcher }
|
74
|
+
expect(have_received(method)).to eq matcher
|
75
|
+
end
|
76
|
+
|
77
|
+
it "creates an invocation matcher without a method name" do
|
78
|
+
matcher = 'fake'
|
79
|
+
mock(RR::Integrations::RSpec::InvocationMatcher).new(nil) { matcher }
|
80
|
+
expect(have_received).to eq matcher
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
|
2
|
+
|
3
|
+
module RR
|
4
|
+
describe ProcFromBlock do
|
5
|
+
describe "#==" do
|
6
|
+
it "acts the same as #== on a Proc" do
|
7
|
+
original_proc = lambda {}
|
8
|
+
expect(Proc.new(&original_proc)).to eq original_proc
|
9
|
+
|
10
|
+
expect(ProcFromBlock.new(&original_proc)).to eq original_proc
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
|
2
|
+
|
3
|
+
describe "RR" do
|
4
|
+
before do
|
5
|
+
Object.class_eval do
|
6
|
+
def verify
|
7
|
+
raise "Dont call me"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
Object.class_eval do
|
14
|
+
remove_method :verify
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has proxy methods for each method defined directly on Space" do
|
19
|
+
space_instance_methods = RR::Space.instance_methods(false)
|
20
|
+
space_instance_methods.should_not be_empty
|
21
|
+
|
22
|
+
rr_instance_methods = RR.methods(false)
|
23
|
+
space_instance_methods.each do |space_instance_method|
|
24
|
+
expect(rr_instance_methods).to include(space_instance_method)
|
25
|
+
end
|
26
|
+
RR.verify
|
27
|
+
end
|
28
|
+
end
|