rspec 1.1.12 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +2 -1
- data/.document +7 -0
- data/History.txt +58 -0
- data/License.txt +1 -1
- data/Manifest.txt +45 -82
- data/README.txt +3 -6
- data/Rakefile +33 -13
- data/Ruby1.9.markdown +32 -0
- data/TODO.txt +10 -4
- data/Upgrade.markdown +63 -0
- data/bin/spec +1 -1
- data/cucumber.yml +3 -0
- data/examples/failing/{failing_autogenerated_docstrings_example.rb → failing_implicit_docstrings_example.rb} +0 -0
- data/examples/failing/pending_example.rb +9 -0
- data/examples/failing/spec_helper.rb +1 -1
- data/examples/passing/{custom_expectation_matchers.rb → custom_matchers.rb} +0 -0
- data/examples/passing/filtered_formatter.rb +18 -0
- data/examples/passing/filtered_formatter_example.rb +31 -0
- data/examples/passing/implicit_docstrings_example.rb +18 -0
- data/examples/passing/spec_helper.rb +1 -1
- data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +17 -18
- data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
- data/features/example_groups/example_group_with_should_methods.feature +1 -1
- data/features/example_groups/{autogenerated_docstrings.feature → implicit_docstrings.feature} +7 -9
- data/features/example_groups/nested_groups.feature +1 -1
- data/features/heckle/heckle.feature +56 -0
- data/features/interop/examples_and_tests_together.feature +1 -1
- data/features/interop/test_but_not_test_unit.feature +1 -1
- data/features/interop/test_case_with_should_methods.feature +1 -1
- data/features/matchers/create_matcher.feature +115 -0
- data/features/mock_framework_integration/use_flexmock.feature +22 -4
- data/features/mock_framework_integration/use_mocha.feature +27 -0
- data/features/mock_framework_integration/use_rr.feature +27 -0
- data/features/mocks/mix_stubs_and_mocks.feature +22 -0
- data/features/pending/pending_examples.feature +81 -0
- data/features/step_definitions/running_rspec.rb +5 -3
- data/features/support/env.rb +1 -1
- data/features/support/matchers/smart_match.rb +2 -2
- data/lib/autotest/rspec.rb +1 -1
- data/lib/spec.rb +1 -1
- data/lib/{adapters → spec/adapters}/mock_frameworks/flexmock.rb +0 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/mocha.rb +0 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/rr.rb +0 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/rspec.rb +0 -1
- data/lib/spec/autorun.rb +3 -0
- data/lib/spec/dsl.rb +3 -1
- data/lib/spec/dsl/matchers.rb +13 -0
- data/lib/spec/example.rb +4 -0
- data/lib/spec/example/before_and_after_hooks.rb +5 -20
- data/lib/spec/example/errors.rb +3 -3
- data/lib/spec/example/example_description.rb +15 -0
- data/lib/spec/example/example_group.rb +0 -15
- data/lib/spec/example/example_group_factory.rb +34 -46
- data/lib/spec/example/example_group_hierarchy.rb +53 -0
- data/lib/spec/example/example_group_methods.rb +101 -211
- data/lib/spec/example/example_methods.rb +61 -81
- data/lib/spec/example/module_reopening_fix.rb +23 -1
- data/lib/spec/example/pending.rb +3 -2
- data/lib/spec/example/predicate_matchers.rb +47 -0
- data/lib/spec/example/subject.rb +91 -0
- data/lib/spec/expectations.rb +1 -1
- data/lib/spec/expectations/differs/default.rb +0 -1
- data/lib/spec/expectations/extensions.rb +0 -1
- data/lib/spec/expectations/handler.rb +13 -6
- data/lib/spec/interop/test.rb +5 -0
- data/lib/spec/interop/test/unit/testcase.rb +5 -22
- data/lib/spec/matchers.rb +22 -8
- data/lib/spec/matchers/be.rb +4 -9
- data/lib/spec/matchers/be_close.rb +20 -5
- data/lib/spec/matchers/be_instance_of.rb +45 -0
- data/lib/spec/matchers/be_kind_of.rb +45 -0
- data/lib/spec/matchers/change.rb +8 -6
- data/lib/spec/matchers/compatibility.rb +14 -0
- data/lib/spec/matchers/eql.rb +24 -6
- data/lib/spec/matchers/equal.rb +24 -6
- data/lib/spec/matchers/exist.rb +21 -5
- data/lib/spec/matchers/extensions/instance_exec.rb +25 -0
- data/lib/spec/matchers/generated_descriptions.rb +2 -2
- data/lib/spec/matchers/has.rb +28 -11
- data/lib/spec/matchers/have.rb +2 -2
- data/lib/spec/matchers/include.rb +2 -2
- data/lib/spec/matchers/match.rb +25 -7
- data/lib/spec/matchers/match_array.rb +3 -3
- data/lib/spec/matchers/matcher.rb +51 -0
- data/lib/spec/matchers/method_missing.rb +2 -2
- data/lib/spec/matchers/operator_matcher.rb +12 -5
- data/lib/spec/matchers/raise_error.rb +3 -3
- data/lib/spec/matchers/respond_to.rb +3 -3
- data/lib/spec/matchers/satisfy.rb +7 -7
- data/lib/spec/matchers/throw_symbol.rb +3 -5
- data/lib/spec/mocks.rb +3 -3
- data/lib/spec/mocks/argument_expectation.rb +15 -15
- data/lib/spec/mocks/{argument_constraints.rb → argument_matchers.rb} +19 -23
- data/lib/spec/mocks/error_generator.rb +5 -8
- data/lib/spec/mocks/framework.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +5 -13
- data/lib/spec/mocks/mock.rb +4 -5
- data/lib/spec/mocks/proxy.rb +9 -5
- data/lib/spec/mocks/spec_methods.rb +10 -1
- data/lib/spec/rake/spectask.rb +0 -1
- data/lib/spec/runner.rb +6 -28
- data/lib/spec/runner/configuration.rb +3 -3
- data/lib/spec/runner/drb_command_line.rb +2 -1
- data/lib/spec/runner/example_group_runner.rb +3 -2
- data/lib/spec/runner/formatter/base_text_formatter.rb +34 -19
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +3 -5
- data/lib/spec/runner/formatter/html_formatter.rb +2 -3
- data/lib/spec/runner/formatter/nested_text_formatter.rb +7 -25
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
- data/lib/spec/runner/formatter/snippet_extractor.rb +1 -1
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -7
- data/lib/spec/runner/heckle_runner.rb +3 -6
- data/lib/spec/runner/heckle_runner_unsupported.rb +1 -1
- data/lib/spec/runner/option_parser.rb +19 -21
- data/lib/spec/runner/options.rb +32 -27
- data/lib/spec/runner/reporter.rb +8 -9
- data/lib/spec/test/unit.rb +10 -0
- data/lib/spec/version.rb +2 -2
- data/{features/support → resources}/helpers/cmdline.rb +2 -2
- data/resources/rake/verify_rcov.rake +1 -1
- data/resources/spec/example_group_with_should_methods.rb +1 -1
- data/resources/spec/simple_spec.rb +1 -1
- data/resources/test/spec_and_test_together.rb +2 -3
- data/resources/test/spec_including_test_but_not_unit.rb +1 -1
- data/resources/test/test_case_with_should_methods.rb +2 -3
- data/spec/autotest/autotest_helper.rb +0 -1
- data/spec/autotest/rspec_spec.rb +95 -98
- data/spec/spec/dsl/main_spec.rb +3 -3
- data/spec/spec/dsl/matchers_spec.rb +25 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +14 -15
- data/spec/spec/example/example_group_factory_spec.rb +31 -44
- data/spec/spec/example/example_group_methods_spec.rb +86 -52
- data/spec/spec/example/example_group_spec.rb +32 -79
- data/spec/spec/example/example_matcher_spec.rb +10 -10
- data/spec/spec/example/example_methods_spec.rb +108 -242
- data/spec/spec/example/nested_example_group_spec.rb +2 -2
- data/spec/spec/example/pending_module_spec.rb +66 -41
- data/spec/spec/example/shared_example_group_spec.rb +4 -4
- data/spec/spec/{matchers → expectations}/handler_spec.rb +52 -4
- data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +2 -2
- data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +2 -2
- data/spec/spec/interop/test/unit/testcase_spec.rb +0 -4
- data/spec/spec/matchers/be_close_spec.rb +1 -1
- data/spec/spec/matchers/be_instance_of_spec.rb +29 -0
- data/spec/spec/matchers/be_kind_of_spec.rb +29 -0
- data/spec/spec/matchers/change_spec.rb +20 -0
- data/spec/spec/matchers/compatibility_spec.rb +34 -0
- data/spec/spec/matchers/description_generation_spec.rb +0 -12
- data/spec/spec/matchers/eql_spec.rb +2 -2
- data/spec/spec/matchers/equal_spec.rb +2 -2
- data/spec/spec/matchers/exist_spec.rb +8 -4
- data/spec/spec/matchers/have_spec.rb +4 -4
- data/spec/spec/matchers/match_spec.rb +2 -2
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
- data/spec/spec/matchers/matcher_spec.rb +97 -0
- data/spec/spec/matchers/throw_symbol_spec.rb +8 -8
- data/spec/spec/mocks/{bug_report_496.rb → bug_report_496_spec.rb} +0 -0
- data/spec/spec/mocks/{failing_mock_argument_constraints_spec.rb → failing_argument_matchers_spec.rb} +2 -2
- data/spec/spec/mocks/hash_including_matcher_spec.rb +4 -4
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +3 -3
- data/spec/spec/mocks/mock_spec.rb +27 -2
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
- data/spec/spec/mocks/partial_mock_spec.rb +18 -3
- data/spec/spec/mocks/{passing_mock_argument_constraints_spec.rb → passing_argument_matchers_spec.rb} +6 -6
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +13 -1
- data/spec/spec/package/bin_spec_spec.rb +2 -2
- data/spec/spec/runner/configuration_spec.rb +12 -12
- data/spec/spec/runner/drb_command_line_spec.rb +71 -73
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +82 -1
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +8 -8
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +4 -4
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +8 -8
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +38 -26
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -53
- data/spec/spec/runner/formatter/html_formatter_spec.rb +100 -48
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -34
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +9 -6
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +20 -20
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +38 -26
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +55 -47
- data/spec/spec/runner/formatter/{spec_mate_formatter_spec.rb → text_mate_formatter_spec.rb} +11 -9
- data/spec/spec/runner/heckle_runner_spec.rb +1 -1
- data/spec/spec/runner/heckler_spec.rb +1 -1
- data/spec/spec/runner/option_parser_spec.rb +28 -11
- data/spec/spec/runner/options_spec.rb +34 -0
- data/spec/spec/runner/reporter_spec.rb +66 -62
- data/spec/spec/runner/resources/utf8_encoded.rb +1 -0
- data/spec/spec/runner/spec_drb.opts +1 -0
- data/spec/spec/runner_spec.rb +7 -5
- data/spec/spec_helper.rb +24 -2
- metadata +49 -90
- data/examples/passing/autogenerated_docstrings_example.rb +0 -25
- data/examples/passing/before_and_after_example.rb +0 -40
- data/examples/passing/behave_as_example.rb +0 -45
- data/examples/passing/legacy_spec.rb +0 -11
- data/examples/passing/priority.txt +0 -1
- data/features/support/helpers/story_helper.rb +0 -16
- data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
- data/lib/spec/runner/formatter/story/html_formatter.rb +0 -174
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +0 -194
- data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +0 -42
- data/lib/spec/story.rb +0 -10
- data/lib/spec/story/extensions.rb +0 -3
- data/lib/spec/story/extensions/main.rb +0 -86
- data/lib/spec/story/extensions/regexp.rb +0 -9
- data/lib/spec/story/extensions/string.rb +0 -9
- data/lib/spec/story/given_scenario.rb +0 -14
- data/lib/spec/story/runner.rb +0 -57
- data/lib/spec/story/runner/plain_text_story_runner.rb +0 -48
- data/lib/spec/story/runner/scenario_collector.rb +0 -18
- data/lib/spec/story/runner/scenario_runner.rb +0 -54
- data/lib/spec/story/runner/story_mediator.rb +0 -137
- data/lib/spec/story/runner/story_parser.rb +0 -247
- data/lib/spec/story/runner/story_runner.rb +0 -74
- data/lib/spec/story/scenario.rb +0 -14
- data/lib/spec/story/step.rb +0 -70
- data/lib/spec/story/step_group.rb +0 -89
- data/lib/spec/story/step_mother.rb +0 -38
- data/lib/spec/story/story.rb +0 -39
- data/lib/spec/story/world.rb +0 -124
- data/resources/spec/spec_with_flexmock.rb +0 -19
- data/rspec.gemspec +0 -32
- data/spec/spec/matchers/mock_constraint_matchers_spec.rb +0 -24
- data/spec/spec/runner/formatter/story/html_formatter_spec.rb +0 -135
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +0 -600
- data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +0 -82
- data/spec/spec/spec_spec.rb +0 -21
- data/spec/spec/story/builders.rb +0 -46
- data/spec/spec/story/extensions/main_spec.rb +0 -161
- data/spec/spec/story/extensions_spec.rb +0 -14
- data/spec/spec/story/given_scenario_spec.rb +0 -27
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +0 -90
- data/spec/spec/story/runner/scenario_collector_spec.rb +0 -27
- data/spec/spec/story/runner/scenario_runner_spec.rb +0 -214
- data/spec/spec/story/runner/story_mediator_spec.rb +0 -143
- data/spec/spec/story/runner/story_parser_spec.rb +0 -401
- data/spec/spec/story/runner/story_runner_spec.rb +0 -294
- data/spec/spec/story/runner_spec.rb +0 -93
- data/spec/spec/story/scenario_spec.rb +0 -18
- data/spec/spec/story/step_group_spec.rb +0 -157
- data/spec/spec/story/step_mother_spec.rb +0 -84
- data/spec/spec/story/step_spec.rb +0 -272
- data/spec/spec/story/story_helper.rb +0 -2
- data/spec/spec/story/story_spec.rb +0 -84
- data/spec/spec/story/world_spec.rb +0 -423
- data/story_server/prototype/javascripts/builder.js +0 -136
- data/story_server/prototype/javascripts/controls.js +0 -972
- data/story_server/prototype/javascripts/dragdrop.js +0 -976
- data/story_server/prototype/javascripts/effects.js +0 -1117
- data/story_server/prototype/javascripts/prototype.js +0 -4140
- data/story_server/prototype/javascripts/rspec.js +0 -149
- data/story_server/prototype/javascripts/scriptaculous.js +0 -58
- data/story_server/prototype/javascripts/slider.js +0 -276
- data/story_server/prototype/javascripts/sound.js +0 -55
- data/story_server/prototype/javascripts/unittest.js +0 -568
- data/story_server/prototype/lib/server.rb +0 -24
- data/story_server/prototype/stories.html +0 -176
- data/story_server/prototype/stylesheets/rspec.css +0 -136
- data/story_server/prototype/stylesheets/test.css +0 -90
@@ -1,21 +1,21 @@
|
|
1
1
|
module Spec
|
2
2
|
module Mocks
|
3
3
|
|
4
|
-
#
|
4
|
+
# ArgumentMatchers are messages that you can include in message
|
5
5
|
# expectations to match arguments against a broader check than simple
|
6
6
|
# equality.
|
7
7
|
#
|
8
|
-
# With the exception of any_args() and no_args(), the
|
8
|
+
# With the exception of any_args() and no_args(), the matchers
|
9
9
|
# are all positional - they match against the arg in the given position.
|
10
|
-
module
|
10
|
+
module ArgumentMatchers
|
11
11
|
|
12
|
-
class
|
12
|
+
class AnyArgsMatcher
|
13
13
|
def description
|
14
14
|
"any args"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
class
|
18
|
+
class AnyArgMatcher
|
19
19
|
def initialize(ignore)
|
20
20
|
end
|
21
21
|
|
@@ -24,17 +24,13 @@ module Spec
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
class
|
27
|
+
class NoArgsMatcher
|
28
28
|
def description
|
29
29
|
"no args"
|
30
30
|
end
|
31
|
-
|
32
|
-
def ==(args)
|
33
|
-
args == []
|
34
|
-
end
|
35
31
|
end
|
36
32
|
|
37
|
-
class
|
33
|
+
class RegexpMatcher
|
38
34
|
def initialize(regexp)
|
39
35
|
@regexp = regexp
|
40
36
|
end
|
@@ -45,7 +41,7 @@ module Spec
|
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
|
-
class
|
44
|
+
class BooleanMatcher
|
49
45
|
def initialize(ignore)
|
50
46
|
end
|
51
47
|
|
@@ -54,7 +50,7 @@ module Spec
|
|
54
50
|
end
|
55
51
|
end
|
56
52
|
|
57
|
-
class
|
53
|
+
class HashIncludingMatcher
|
58
54
|
def initialize(expected)
|
59
55
|
@expected = expected
|
60
56
|
end
|
@@ -73,7 +69,7 @@ module Spec
|
|
73
69
|
end
|
74
70
|
end
|
75
71
|
|
76
|
-
class
|
72
|
+
class HashNotIncludingMatcher
|
77
73
|
def initialize(expected)
|
78
74
|
@expected = expected
|
79
75
|
end
|
@@ -92,7 +88,7 @@ module Spec
|
|
92
88
|
end
|
93
89
|
end
|
94
90
|
|
95
|
-
class
|
91
|
+
class DuckTypeMatcher
|
96
92
|
def initialize(*methods_to_respond_to)
|
97
93
|
@methods_to_respond_to = methods_to_respond_to
|
98
94
|
end
|
@@ -102,7 +98,7 @@ module Spec
|
|
102
98
|
end
|
103
99
|
end
|
104
100
|
|
105
|
-
class
|
101
|
+
class MatcherMatcher
|
106
102
|
def initialize(matcher)
|
107
103
|
@matcher = matcher
|
108
104
|
end
|
@@ -148,7 +144,7 @@ module Spec
|
|
148
144
|
# Passes if object receives :message with any args at all. This is
|
149
145
|
# really a more explicit variation of object.should_receive(:message)
|
150
146
|
def any_args
|
151
|
-
|
147
|
+
AnyArgsMatcher.new
|
152
148
|
end
|
153
149
|
|
154
150
|
# :call-seq:
|
@@ -156,7 +152,7 @@ module Spec
|
|
156
152
|
#
|
157
153
|
# Passes as long as there is an argument.
|
158
154
|
def anything
|
159
|
-
|
155
|
+
AnyArgMatcher.new(nil)
|
160
156
|
end
|
161
157
|
|
162
158
|
# :call-seq:
|
@@ -164,7 +160,7 @@ module Spec
|
|
164
160
|
#
|
165
161
|
# Passes if no arguments are passed along with the message
|
166
162
|
def no_args
|
167
|
-
|
163
|
+
NoArgsMatcher.new
|
168
164
|
end
|
169
165
|
|
170
166
|
# :call-seq:
|
@@ -180,7 +176,7 @@ module Spec
|
|
180
176
|
# display.should_receive(:present_names).with(duck_type(:length, :each))
|
181
177
|
# => passes
|
182
178
|
def duck_type(*args)
|
183
|
-
|
179
|
+
DuckTypeMatcher.new(*args)
|
184
180
|
end
|
185
181
|
|
186
182
|
# :call-seq:
|
@@ -188,7 +184,7 @@ module Spec
|
|
188
184
|
#
|
189
185
|
# Passes if the argument is boolean.
|
190
186
|
def boolean
|
191
|
-
|
187
|
+
BooleanMatcher.new(nil)
|
192
188
|
end
|
193
189
|
|
194
190
|
# :call-seq:
|
@@ -198,7 +194,7 @@ module Spec
|
|
198
194
|
# Passes if the argument is a hash that includes the specified key(s) or key/value
|
199
195
|
# pairs. If the hash includes other keys, it will still pass.
|
200
196
|
def hash_including(*args)
|
201
|
-
|
197
|
+
HashIncludingMatcher.new(anythingize_lonely_keys(*args))
|
202
198
|
end
|
203
199
|
|
204
200
|
# :call-seq:
|
@@ -208,7 +204,7 @@ module Spec
|
|
208
204
|
#
|
209
205
|
# Passes if the argument is a hash that doesn't include the specified key(s) or key/value
|
210
206
|
def hash_not_including(*args)
|
211
|
-
|
207
|
+
HashNotIncludingMatcher.new(anythingize_lonely_keys(*args))
|
212
208
|
end
|
213
209
|
|
214
210
|
# Passes if arg.instance_of?(klass)
|
@@ -42,9 +42,10 @@ module Spec
|
|
42
42
|
__raise "#{intro} yielded |#{arg_list(*args_to_yield)}| to block with arity of #{arity}"
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
private
|
46
|
+
|
46
47
|
def intro
|
47
|
-
@name ? "Mock '#{@name}'" : @target.class == Class ? "<#{@target.inspect} (class)>" : (@target.nil? ? "nil" : @target
|
48
|
+
@name ? "Mock '#{@name}'" : @target.class == Class ? "<#{@target.inspect} (class)>" : (@target.nil? ? "nil" : @target)
|
48
49
|
end
|
49
50
|
|
50
51
|
def __raise(message)
|
@@ -57,15 +58,11 @@ module Spec
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def format_args(*args)
|
60
|
-
|
61
|
-
return "(any args)" if args == [:any_args]
|
62
|
-
"(" + arg_list(*args) + ")"
|
61
|
+
args.empty? ? "(no args)" : "(" + arg_list(*args) + ")"
|
63
62
|
end
|
64
63
|
|
65
64
|
def arg_list(*args)
|
66
|
-
args.collect
|
67
|
-
arg.respond_to?(:description) ? arg.description : arg.inspect
|
68
|
-
end.join(", ")
|
65
|
+
args.collect {|arg| arg.respond_to?(:description) ? arg.description : arg.inspect}.join(", ")
|
69
66
|
end
|
70
67
|
|
71
68
|
def count_message(count)
|
data/lib/spec/mocks/framework.rb
CHANGED
@@ -17,7 +17,7 @@ module Spec
|
|
17
17
|
@return_block = nil
|
18
18
|
@actual_received_count = 0
|
19
19
|
@expected_received_count = expected_received_count
|
20
|
-
@args_expectation = ArgumentExpectation.new([
|
20
|
+
@args_expectation = ArgumentExpectation.new([ArgumentMatchers::AnyArgsMatcher.new])
|
21
21
|
@consecutive = false
|
22
22
|
@exception_to_raise = nil
|
23
23
|
@symbol_to_throw = nil
|
@@ -56,8 +56,6 @@ module Spec
|
|
56
56
|
@expected_received_count < values.size
|
57
57
|
end
|
58
58
|
@return_block = block_given? ? return_block : lambda { value }
|
59
|
-
# Ruby 1.9 - see where this is used below
|
60
|
-
@ignore_args = !block_given?
|
61
59
|
end
|
62
60
|
|
63
61
|
# :call-seq:
|
@@ -157,9 +155,7 @@ module Spec
|
|
157
155
|
end
|
158
156
|
|
159
157
|
def invoke_consecutive_return_block(args, block)
|
160
|
-
|
161
|
-
value = @return_block.call(*args)
|
162
|
-
|
158
|
+
value = invoke_return_block(args, block)
|
163
159
|
index = [@actual_received_count, value.size-1].min
|
164
160
|
value[index]
|
165
161
|
end
|
@@ -169,13 +165,9 @@ module Spec
|
|
169
165
|
# Ruby 1.9 - when we set @return_block to return values
|
170
166
|
# regardless of arguments, any arguments will result in
|
171
167
|
# a "wrong number of arguments" error
|
172
|
-
|
173
|
-
@return_block.call()
|
174
|
-
else
|
175
|
-
@return_block.call(*args)
|
176
|
-
end
|
168
|
+
@return_block.arity > 0 ? @return_block.call(*args) : @return_block.call()
|
177
169
|
end
|
178
|
-
|
170
|
+
|
179
171
|
def clone_args_to_yield(args)
|
180
172
|
@args_to_yield = args.clone
|
181
173
|
@args_to_yield_were_cloned = true
|
@@ -234,7 +226,7 @@ module Spec
|
|
234
226
|
if similar_messages.empty?
|
235
227
|
@error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args)
|
236
228
|
else
|
237
|
-
@error_generator.raise_unexpected_message_args_error(self, *@similar_messages
|
229
|
+
@error_generator.raise_unexpected_message_args_error(self, *@similar_messages)
|
238
230
|
end
|
239
231
|
end
|
240
232
|
|
data/lib/spec/mocks/mock.rb
CHANGED
@@ -14,16 +14,15 @@ module Spec
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# This allows for comparing the mock to other objects that proxy such as
|
17
|
-
# ActiveRecords belongs_to proxy objects By making the other object run
|
18
|
-
# the comparison, we're sure the call gets delegated to the proxy
|
19
|
-
#
|
20
|
-
# be safe unless the RHS redefines == in a nonsensical manner
|
17
|
+
# ActiveRecords belongs_to proxy objects. By making the other object run
|
18
|
+
# the comparison, we're sure the call gets delegated to the proxy
|
19
|
+
# target.
|
21
20
|
def ==(other)
|
22
21
|
other == __mock_proxy
|
23
22
|
end
|
24
23
|
|
25
24
|
def method_missing(sym, *args, &block)
|
26
|
-
__mock_proxy.
|
25
|
+
__mock_proxy.record_message_received(sym, args, block)
|
27
26
|
begin
|
28
27
|
return self if __mock_proxy.null_object?
|
29
28
|
super(sym, *args, &block)
|
data/lib/spec/mocks/proxy.rb
CHANGED
@@ -82,6 +82,10 @@ module Spec
|
|
82
82
|
def has_negative_expectation?(sym)
|
83
83
|
@expectations.detect {|expectation| expectation.negative_expectation_for?(sym)}
|
84
84
|
end
|
85
|
+
|
86
|
+
def record_message_received(sym, args, block)
|
87
|
+
@messages_received << [sym, args, block]
|
88
|
+
end
|
85
89
|
|
86
90
|
def message_received(sym, *args, &block)
|
87
91
|
expectation = find_matching_expectation(sym, *args)
|
@@ -118,7 +122,7 @@ module Spec
|
|
118
122
|
end
|
119
123
|
|
120
124
|
def warn_if_nil_class(sym)
|
121
|
-
if proxy_for_nil_class?
|
125
|
+
if proxy_for_nil_class? & @@warn_about_expectations_on_nil
|
122
126
|
Kernel.warn("An expectation of :#{sym} was set on nil. Called from #{caller[2]}. Use allow_message_expectations_on_nil to disable warnings.")
|
123
127
|
end
|
124
128
|
end
|
@@ -129,7 +133,7 @@ module Spec
|
|
129
133
|
if target_responds_to?(sym)
|
130
134
|
munged_sym = munge(sym)
|
131
135
|
target_metaclass.instance_eval do
|
132
|
-
alias_method munged_sym, sym if method_defined?(sym
|
136
|
+
alias_method munged_sym, sym if method_defined?(sym)
|
133
137
|
end
|
134
138
|
@proxied_methods << sym
|
135
139
|
end
|
@@ -162,7 +166,7 @@ module Spec
|
|
162
166
|
end
|
163
167
|
|
164
168
|
def munge(sym)
|
165
|
-
"proxied_by_rspec__#{sym
|
169
|
+
"proxied_by_rspec__#{sym}"
|
166
170
|
end
|
167
171
|
|
168
172
|
def clear_expectations
|
@@ -191,9 +195,9 @@ module Spec
|
|
191
195
|
@proxied_methods.each do |sym|
|
192
196
|
munged_sym = munge(sym)
|
193
197
|
target_metaclass.instance_eval do
|
194
|
-
if method_defined?(munged_sym
|
198
|
+
if method_defined?(munged_sym)
|
195
199
|
alias_method sym, munged_sym
|
196
|
-
|
200
|
+
remove_method munged_sym
|
197
201
|
else
|
198
202
|
remove_method sym
|
199
203
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spec
|
2
2
|
module Mocks
|
3
3
|
module ExampleMethods
|
4
|
-
include Spec::Mocks::
|
4
|
+
include Spec::Mocks::ArgumentMatchers
|
5
5
|
|
6
6
|
# Shortcut for creating an instance of Spec::Mocks::Mock.
|
7
7
|
#
|
@@ -26,10 +26,19 @@ module Spec
|
|
26
26
|
|
27
27
|
alias :stub :mock
|
28
28
|
|
29
|
+
# DEPRECATED - use mock('name').as_null_object instead
|
30
|
+
#
|
29
31
|
# Shortcut for creating a mock object that will return itself in response
|
30
32
|
# to any message it receives that it hasn't been explicitly instructed
|
31
33
|
# to respond to.
|
32
34
|
def stub_everything(name = 'stub')
|
35
|
+
Kernel.warn(<<-WARNING)
|
36
|
+
|
37
|
+
DEPRECATION: stub_everything('#{name}') is deprecated and will be removed
|
38
|
+
from a future version of rspec. Please use mock('#{name}').as_null_object
|
39
|
+
or stub('#{name}').as_null_object instead.
|
40
|
+
|
41
|
+
WARNING
|
33
42
|
mock(name, :null_object => true)
|
34
43
|
end
|
35
44
|
|
data/lib/spec/rake/spectask.rb
CHANGED
data/lib/spec/runner.rb
CHANGED
@@ -15,11 +15,10 @@ module Spec
|
|
15
15
|
class ExampleGroupCreationListener
|
16
16
|
def register_example_group(klass)
|
17
17
|
Spec::Runner.options.add_example_group klass
|
18
|
-
Spec::Runner.register_at_exit_hook
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
Spec::Example::
|
21
|
+
Spec::Example::ExampleGroupFactory.example_group_creation_listeners << ExampleGroupCreationListener.new
|
23
22
|
|
24
23
|
class << self
|
25
24
|
def configuration # :nodoc:
|
@@ -40,17 +39,9 @@ module Spec
|
|
40
39
|
def configure
|
41
40
|
yield configuration
|
42
41
|
end
|
43
|
-
|
44
|
-
def
|
45
|
-
unless
|
46
|
-
at_exit do
|
47
|
-
unless $! || run? || Spec::Example::ExampleGroupFactory.registered_or_ancestor_of_registered?(options.example_groups)
|
48
|
-
success = run
|
49
|
-
exit success if exit?
|
50
|
-
end
|
51
|
-
end
|
52
|
-
@already_registered_at_exit_hook = true
|
53
|
-
end
|
42
|
+
|
43
|
+
def autorun # :nodoc:
|
44
|
+
at_exit {exit run unless $!}
|
54
45
|
end
|
55
46
|
|
56
47
|
def options # :nodoc:
|
@@ -65,24 +56,11 @@ module Spec
|
|
65
56
|
@options = options
|
66
57
|
end
|
67
58
|
|
68
|
-
def test_unit_defined?
|
69
|
-
Object.const_defined?(:Test) && Test.const_defined?(:Unit) && Test::Unit.respond_to?(:run?)
|
70
|
-
end
|
71
|
-
|
72
|
-
def run?
|
73
|
-
Runner.options.examples_run?
|
74
|
-
end
|
75
|
-
|
76
59
|
def run
|
77
|
-
return true if
|
60
|
+
return true if options.examples_run?
|
78
61
|
options.run_examples
|
79
62
|
end
|
80
63
|
|
81
|
-
def exit?
|
82
|
-
!test_unit_defined? || Test::Unit.run?
|
83
|
-
end
|
84
64
|
end
|
85
65
|
end
|
86
|
-
end
|
87
|
-
|
88
|
-
require 'spec/interop/test' if Spec::Runner::test_unit_defined?
|
66
|
+
end
|
@@ -143,14 +143,14 @@ module Spec
|
|
143
143
|
[get_type_from_options(options)].flatten.each do |required_example_group|
|
144
144
|
required_example_group = required_example_group.to_sym if required_example_group
|
145
145
|
modules.each do |mod|
|
146
|
-
Spec::Example::ExampleGroupFactory
|
146
|
+
Spec::Example::ExampleGroupFactory[required_example_group].__send__(action, mod)
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
151
|
def add_callback(sym, *args, &proc)
|
152
152
|
scope, options = Spec::Example.scope_and_options(*args)
|
153
|
-
example_group = Spec::Example::ExampleGroupFactory
|
153
|
+
example_group = Spec::Example::ExampleGroupFactory[get_type_from_options(options)]
|
154
154
|
example_group.__send__(sym, scope, &proc)
|
155
155
|
end
|
156
156
|
|
@@ -159,7 +159,7 @@ module Spec
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def mock_framework_path(framework_name)
|
162
|
-
File.expand_path(File.join(File.dirname(__FILE__), "
|
162
|
+
File.expand_path(File.join(File.dirname(__FILE__), "/../adapters/mock_frameworks/#{framework_name}"))
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -8,7 +8,8 @@ module Spec
|
|
8
8
|
# CommandLine - making it possible for clients to use both interchangeably.
|
9
9
|
def self.run(options)
|
10
10
|
begin
|
11
|
-
|
11
|
+
# See http://redmine.ruby-lang.org/issues/show/496 as to why we specify localhost:0
|
12
|
+
DRb.start_service("druby://localhost:0")
|
12
13
|
spec_server = DRbObject.new_with_uri("druby://127.0.0.1:8989")
|
13
14
|
spec_server.run(options.argv, options.error_stream, options.output_stream)
|
14
15
|
rescue DRb::DRbConnError => e
|
@@ -6,11 +6,11 @@ module Spec
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def load_files(files)
|
9
|
+
$KCODE = 'u' if RUBY_VERSION.to_f < 1.9
|
9
10
|
# It's important that loading files (or choosing not to) stays the
|
10
11
|
# responsibility of the ExampleGroupRunner. Some implementations (like)
|
11
12
|
# the one using DRb may choose *not* to load files, but instead tell
|
12
13
|
# someone else to do it over the wire.
|
13
|
-
$KCODE = 'u' if RUBY_VERSION < '1.9'
|
14
14
|
files.each do |file|
|
15
15
|
load file
|
16
16
|
end
|
@@ -27,7 +27,8 @@ module Spec
|
|
27
27
|
finish
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
protected
|
31
|
+
|
31
32
|
def prepare
|
32
33
|
reporter.start(number_of_examples)
|
33
34
|
example_groups.reverse! if reverse
|