rspec 1.1.11 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +4 -0
- data/History.txt +55 -0
- data/Manifest.txt +102 -122
- data/README.txt +30 -12
- data/Rakefile +10 -10
- data/TODO.txt +10 -2
- data/{failing_examples → examples/failing}/README.txt +0 -0
- data/{failing_examples → examples/failing}/diffing_spec.rb +0 -0
- data/{failing_examples → examples/failing}/failing_autogenerated_docstrings_example.rb +0 -0
- data/{failing_examples/failure_in_teardown.rb → examples/failing/failure_in_after.rb} +1 -1
- data/{failing_examples/failure_in_setup.rb → examples/failing/failure_in_before.rb} +1 -1
- data/{failing_examples → examples/failing}/mocking_example.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_flexmock.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_mocha.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_rr.rb +0 -0
- data/{failing_examples → examples/failing}/partial_mock_example.rb +0 -0
- data/{failing_examples → examples/failing}/predicate_example.rb +5 -0
- data/{failing_examples → examples/failing}/raising_example.rb +0 -0
- data/{failing_examples → examples/failing}/spec_helper.rb +1 -1
- data/{failing_examples → examples/failing}/syntax_error_example.rb +0 -0
- data/{failing_examples → examples/failing}/team_spec.rb +0 -0
- data/{failing_examples → examples/failing}/timeout_behaviour.rb +0 -0
- data/examples/{pure → passing}/autogenerated_docstrings_example.rb +6 -0
- data/examples/{pure → passing}/before_and_after_example.rb +0 -0
- data/examples/{pure → passing}/behave_as_example.rb +0 -0
- data/examples/{pure → passing}/custom_expectation_matchers.rb +0 -0
- data/examples/{pure → passing}/custom_formatter.rb +1 -1
- data/examples/{pure → passing}/dynamic_spec.rb +2 -2
- data/examples/{pure → passing}/file_accessor.rb +0 -0
- data/examples/{pure → passing}/file_accessor_spec.rb +0 -0
- data/examples/{pure → passing}/greeter_spec.rb +0 -0
- data/examples/{pure → passing}/helper_method_example.rb +0 -0
- data/examples/{pure → passing}/io_processor.rb +0 -0
- data/examples/{pure → passing}/io_processor_spec.rb +0 -0
- data/examples/{pure → passing}/legacy_spec.rb +0 -0
- data/examples/{pure → passing}/mocking_example.rb +0 -0
- data/examples/{pure/multi_threaded_behaviour_runner.rb → passing/multi_threaded_example_group_runner.rb} +1 -3
- data/examples/{pure → passing}/nested_classes_example.rb +0 -0
- data/examples/{pure → passing}/partial_mock_example.rb +0 -0
- data/examples/{pure → passing}/pending_example.rb +0 -0
- data/examples/{pure → passing}/predicate_example.rb +0 -0
- data/examples/{pure → passing}/priority.txt +0 -0
- data/examples/{pure → passing}/shared_example_group_example.rb +0 -0
- data/examples/{pure → passing}/shared_stack_examples.rb +1 -3
- data/examples/passing/simple_matcher_example.rb +31 -0
- data/examples/{pure → passing}/spec_helper.rb +0 -0
- data/examples/{pure → passing}/stack.rb +0 -0
- data/examples/{pure → passing}/stack_spec.rb +3 -2
- data/examples/{pure → passing}/stack_spec_with_nested_example_groups.rb +0 -0
- data/examples/{pure → passing}/stubbing_example.rb +0 -0
- data/examples/{pure → passing}/yielding_example.rb +0 -0
- data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +86 -0
- data/features/before_and_after_blocks/before_and_after_blocks.feature +168 -0
- data/{stories/example_groups/autogenerated_docstrings → features/example_groups/autogenerated_docstrings.feature} +5 -5
- data/{stories/example_groups/example_group_with_should_methods → features/example_groups/example_group_with_should_methods.feature} +3 -3
- data/{stories/example_groups/nested_groups → features/example_groups/nested_groups.feature} +4 -4
- data/{stories/example_groups/output → features/example_groups/output.feature} +3 -8
- data/{stories/interop/examples_and_tests_together → features/interop/examples_and_tests_together.feature} +5 -4
- data/features/interop/test_but_not_test_unit.feature +14 -0
- data/{stories/interop/test_case_with_should_methods → features/interop/test_case_with_should_methods.feature} +2 -2
- data/{stories/mock_framework_integration/use_flexmock.story → features/mock_framework_integration/use_flexmock.feature} +1 -1
- data/features/step_definitions/running_rspec.rb +54 -0
- data/features/support/env.rb +26 -0
- data/{stories/resources → features/support}/helpers/cmdline.rb +0 -0
- data/{stories/resources → features/support}/helpers/story_helper.rb +1 -1
- data/{stories/resources → features/support}/matchers/smart_match.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/flexmock.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/mocha.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rr.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rspec.rb +2 -2
- data/lib/autotest/rspec.rb +4 -3
- data/lib/spec.rb +2 -27
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/{extensions → dsl}/main.rb +10 -10
- data/lib/spec/example.rb +175 -1
- data/lib/spec/example/before_and_after_hooks.rb +30 -24
- data/lib/spec/example/example_group.rb +1 -0
- data/lib/spec/example/example_group_factory.rb +26 -9
- data/lib/spec/example/example_group_methods.rb +138 -113
- data/lib/spec/example/example_methods.rb +88 -25
- data/lib/spec/example/shared_example_group.rb +28 -21
- data/lib/spec/expectations.rb +22 -18
- data/lib/spec/expectations/handler.rb +16 -36
- data/lib/spec/interop/test/unit/testcase.rb +19 -17
- data/lib/spec/interop/test/unit/testresult.rb +1 -1
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +1 -1
- data/lib/spec/matchers.rb +7 -28
- data/lib/spec/matchers/be.rb +103 -116
- data/lib/spec/matchers/be_close.rb +6 -22
- data/lib/spec/matchers/eql.rb +7 -25
- data/lib/spec/matchers/equal.rb +7 -25
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +8 -14
- data/lib/spec/matchers/generated_descriptions.rb +48 -0
- data/lib/spec/matchers/has.rb +12 -28
- data/lib/spec/matchers/include.rb +12 -9
- data/lib/spec/matchers/match.rb +8 -27
- data/lib/spec/matchers/match_array.rb +79 -0
- data/lib/spec/matchers/method_missing.rb +9 -0
- data/lib/spec/matchers/operator_matcher.rb +39 -48
- data/lib/spec/matchers/raise_error.rb +4 -8
- data/lib/spec/matchers/respond_to.rb +33 -8
- data/lib/spec/matchers/throw_symbol.rb +49 -17
- data/lib/spec/matchers/wrap_expectation.rb +55 -0
- data/lib/spec/mocks/argument_constraints.rb +77 -5
- data/lib/spec/mocks/message_expectation.rb +7 -7
- data/lib/spec/mocks/proxy.rb +14 -12
- data/lib/spec/rake/spectask.rb +4 -6
- data/lib/spec/ruby.rb +9 -0
- data/lib/spec/runner.rb +37 -162
- data/lib/spec/runner/backtrace_tweaker.rb +5 -3
- data/lib/spec/runner/class_and_arguments_parser.rb +7 -9
- data/lib/spec/runner/command_line.rb +6 -8
- data/lib/spec/{example → runner}/configuration.rb +46 -47
- data/lib/spec/runner/example_group_runner.rb +15 -4
- data/lib/spec/runner/formatter/base_text_formatter.rb +4 -3
- data/lib/spec/runner/formatter/html_formatter.rb +14 -11
- data/lib/spec/runner/formatter/nested_text_formatter.rb +2 -2
- data/lib/spec/runner/heckle_runner.rb +58 -56
- data/lib/spec/runner/option_parser.rb +8 -4
- data/lib/spec/runner/options.rb +29 -14
- data/lib/spec/runner/reporter.rb +1 -1
- data/lib/spec/runner/spec_parser.rb +11 -9
- data/lib/spec/story/runner.rb +40 -42
- data/lib/spec/story/runner/story_runner.rb +10 -6
- data/lib/spec/story/world.rb +66 -70
- data/lib/spec/version.rb +4 -2
- data/{rake_tasks → resources/rake}/examples.rake +0 -0
- data/{rake_tasks → resources/rake}/examples_with_rcov.rake +0 -0
- data/{rake_tasks → resources/rake}/failing_examples_with_html.rake +0 -0
- data/{rake_tasks → resources/rake}/verify_rcov.rake +0 -0
- data/{stories/resources → resources}/spec/example_group_with_should_methods.rb +1 -1
- data/{stories/resources → resources}/spec/simple_spec.rb +1 -1
- data/resources/spec/spec_with_flexmock.rb +19 -0
- data/{stories/resources → resources}/test/spec_and_test_together.rb +1 -1
- data/resources/test/spec_including_test_but_not_unit.rb +11 -0
- data/{stories/resources → resources}/test/test_case_with_should_methods.rb +2 -2
- data/rspec.gemspec +16 -6
- data/spec/autotest/autotest_helper.rb +2 -2
- data/spec/autotest/discover_spec.rb +4 -15
- data/spec/autotest/failed_results_re_spec.rb +24 -0
- data/spec/autotest/rspec_spec.rb +2 -38
- data/spec/spec/dsl/main_spec.rb +88 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +6 -2
- data/spec/spec/example/example_group_factory_spec.rb +50 -10
- data/spec/spec/example/example_group_methods_spec.rb +210 -160
- data/spec/spec/example/example_group_spec.rb +44 -52
- data/spec/spec/example/example_matcher_spec.rb +6 -23
- data/spec/spec/example/example_methods_spec.rb +176 -54
- data/spec/spec/example/helper_method_spec.rb +24 -0
- data/spec/spec/example/pending_module_spec.rb +2 -8
- data/spec/spec/example/shared_example_group_spec.rb +56 -80
- data/spec/spec/expectations/extensions/object_spec.rb +0 -50
- data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +1 -5
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +4 -0
- data/spec/spec/matchers/be_close_spec.rb +12 -10
- data/spec/spec/matchers/be_spec.rb +62 -7
- data/spec/spec/matchers/description_generation_spec.rb +19 -0
- data/spec/spec/matchers/eql_spec.rb +7 -6
- data/spec/spec/matchers/equal_spec.rb +7 -6
- data/spec/spec/matchers/handler_spec.rb +4 -43
- data/spec/spec/matchers/has_spec.rb +1 -1
- data/spec/spec/matchers/have_spec.rb +23 -18
- data/spec/spec/matchers/include_spec.rb +24 -0
- data/spec/spec/matchers/match_array_spec.rb +83 -0
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -13
- data/spec/spec/matchers/raise_error_spec.rb +18 -0
- data/spec/spec/matchers/respond_to_spec.rb +71 -9
- data/spec/spec/matchers/throw_symbol_spec.rb +85 -43
- data/spec/spec/mocks/bug_report_11545_spec.rb +4 -5
- data/spec/spec/mocks/bug_report_496.rb +11 -9
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +39 -2
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
- data/spec/spec/mocks/mock_spec.rb +5 -6
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +2 -2
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +18 -3
- data/spec/spec/mocks/stub_spec.rb +6 -0
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +14 -0
- data/spec/spec/runner/command_line_spec.rb +4 -4
- data/spec/spec/runner/configuration_spec.rb +301 -0
- data/spec/spec/runner/drb_command_line_spec.rb +4 -4
- data/spec/spec/runner/example_group_runner_spec.rb +33 -0
- data/spec/spec/runner/formatter/base_formatter_spec.rb +13 -102
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +23 -0
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +9 -9
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +10 -10
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +39 -30
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +379 -0
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +379 -0
- data/spec/spec/runner/formatter/html_formatter_spec.rb +14 -13
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +7 -17
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +18 -17
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -30
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +373 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +373 -0
- data/spec/spec/runner/heckler_spec.rb +16 -9
- data/spec/spec/runner/option_parser_spec.rb +3 -18
- data/spec/spec/runner/options_spec.rb +27 -8
- data/spec/spec/runner/reporter_spec.rb +5 -5
- data/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
- data/spec/spec/runner/resources/utf8_encoded.rb +7 -0
- data/spec/spec/runner/spec_parser_spec.rb +85 -79
- data/spec/spec/spec_spec.rb +21 -0
- data/spec/spec_helper.rb +9 -1
- data/story_server/prototype/javascripts/prototype.js +1 -1
- metadata +119 -131
- data/examples/stories/adder.rb +0 -13
- data/examples/stories/addition +0 -34
- data/examples/stories/addition.rb +0 -9
- data/examples/stories/calculator.rb +0 -65
- data/examples/stories/game-of-life/.loadpath +0 -5
- data/examples/stories/game-of-life/README.txt +0 -21
- data/examples/stories/game-of-life/behaviour/everything.rb +0 -6
- data/examples/stories/game-of-life/behaviour/examples/examples.rb +0 -3
- data/examples/stories/game-of-life/behaviour/examples/game_behaviour.rb +0 -35
- data/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb +0 -66
- data/examples/stories/game-of-life/behaviour/stories/CellsWithLessThanTwoNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/EmptySpacesWithThreeNeighboursCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanKillACell.story +0 -17
- data/examples/stories/game-of-life/behaviour/stories/TheGridWraps.story +0 -53
- data/examples/stories/game-of-life/behaviour/stories/create_a_cell.rb +0 -52
- data/examples/stories/game-of-life/behaviour/stories/helper.rb +0 -6
- data/examples/stories/game-of-life/behaviour/stories/kill_a_cell.rb +0 -26
- data/examples/stories/game-of-life/behaviour/stories/steps.rb +0 -5
- data/examples/stories/game-of-life/behaviour/stories/stories.rb +0 -3
- data/examples/stories/game-of-life/behaviour/stories/stories.txt +0 -22
- data/examples/stories/game-of-life/life.rb +0 -3
- data/examples/stories/game-of-life/life/game.rb +0 -23
- data/examples/stories/game-of-life/life/grid.rb +0 -43
- data/examples/stories/helper.rb +0 -9
- data/examples/stories/steps/addition_steps.rb +0 -18
- data/lib/spec/adapters.rb +0 -1
- data/lib/spec/adapters/ruby_engine.rb +0 -26
- data/lib/spec/adapters/ruby_engine/mri.rb +0 -8
- data/lib/spec/adapters/ruby_engine/rubinius.rb +0 -8
- data/lib/spec/extensions.rb +0 -4
- data/lib/spec/extensions/class.rb +0 -24
- data/lib/spec/extensions/metaclass.rb +0 -7
- data/lib/spec/extensions/object.rb +0 -6
- data/spec/spec/adapters/ruby_engine_spec.rb +0 -16
- data/spec/spec/example/configuration_spec.rb +0 -296
- data/spec/spec/example/example_runner_spec.rb +0 -194
- data/spec/spec/extensions/main_spec.rb +0 -71
- data/stories/all.rb +0 -5
- data/stories/configuration/before_blocks.story +0 -21
- data/stories/configuration/stories.rb +0 -7
- data/stories/example_groups/stories.rb +0 -7
- data/stories/helper.rb +0 -6
- data/stories/interop/stories.rb +0 -7
- data/stories/mock_framework_integration/stories.rb +0 -7
- data/stories/pending_stories/README +0 -3
- data/stories/resources/spec/before_blocks_example.rb +0 -32
- data/stories/resources/spec/spec_with_flexmock.rb +0 -18
- data/stories/resources/steps/running_rspec.rb +0 -50
- data/stories/resources/stories/failing_story.rb +0 -15
- data/stories/stories/multiline_steps.story +0 -23
- data/stories/stories/steps/multiline_steps.rb +0 -13
- data/stories/stories/stories.rb +0 -6
@@ -60,7 +60,7 @@ module Spec
|
|
60
60
|
|
61
61
|
describe ExampleGroup, "#run with failure in example", :shared => true do
|
62
62
|
it "should add an example failure to the TestResult" do
|
63
|
-
example_group.run.should be_false
|
63
|
+
example_group.run(options).should be_false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -96,7 +96,7 @@ module Spec
|
|
96
96
|
|
97
97
|
reporter = mock("Reporter")
|
98
98
|
reporter.should_not_receive(:add_example_group)
|
99
|
-
example_group.run
|
99
|
+
example_group.run(options)
|
100
100
|
end
|
101
101
|
|
102
102
|
describe "when before_each fails" do
|
@@ -114,12 +114,12 @@ module Spec
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should not run example block" do
|
117
|
-
example_group.run
|
117
|
+
example_group.run(options)
|
118
118
|
$example_ran.should be_false
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should run after_each" do
|
122
|
-
example_group.run
|
122
|
+
example_group.run(options)
|
123
123
|
$after_each_ran.should be_true
|
124
124
|
end
|
125
125
|
|
@@ -127,7 +127,7 @@ module Spec
|
|
127
127
|
reporter.should_receive(:example_finished) do |example_group, error|
|
128
128
|
error.message.should eql("in before_each")
|
129
129
|
end
|
130
|
-
example_group.run
|
130
|
+
example_group.run(options)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
@@ -142,7 +142,7 @@ module Spec
|
|
142
142
|
ExampleGroup.before(:all) { before_all_ran = true }
|
143
143
|
ExampleGroup.after(:all) { after_all_ran = true }
|
144
144
|
example_group.it("should") {}
|
145
|
-
example_group.run
|
145
|
+
example_group.run(options)
|
146
146
|
before_all_ran.should be_false
|
147
147
|
after_all_ran.should be_false
|
148
148
|
end
|
@@ -150,7 +150,7 @@ module Spec
|
|
150
150
|
it "should not run example" do
|
151
151
|
example_ran = false
|
152
152
|
example_group.it("should") {example_ran = true}
|
153
|
-
example_group.run
|
153
|
+
example_group.run(options)
|
154
154
|
example_ran.should be_false
|
155
155
|
end
|
156
156
|
end
|
@@ -174,11 +174,11 @@ module Spec
|
|
174
174
|
examples_that_were_run << 'should also be run'
|
175
175
|
end
|
176
176
|
end
|
177
|
-
options.
|
177
|
+
options.parse_example "the ExampleGroup"
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should not run the Examples in the ExampleGroup" do
|
181
|
-
example_group.run
|
181
|
+
example_group.run(options)
|
182
182
|
examples_that_were_run.should == ['should be run', 'should also be run']
|
183
183
|
end
|
184
184
|
end
|
@@ -192,11 +192,11 @@ module Spec
|
|
192
192
|
examples_that_were_run << 'should be run'
|
193
193
|
end
|
194
194
|
end
|
195
|
-
options.
|
195
|
+
options.parse_example "should be run"
|
196
196
|
end
|
197
197
|
|
198
198
|
it "should not run the example" do
|
199
|
-
example_group.run
|
199
|
+
example_group.run(options)
|
200
200
|
examples_that_were_run.should == ['should be run']
|
201
201
|
end
|
202
202
|
end
|
@@ -210,11 +210,11 @@ module Spec
|
|
210
210
|
examples_that_were_run << 'should be something else'
|
211
211
|
end
|
212
212
|
end
|
213
|
-
options.
|
213
|
+
options.parse_example "does not match anything"
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should not run the example" do
|
217
|
-
example_group.run
|
217
|
+
example_group.run(options)
|
218
218
|
examples_that_were_run.should == []
|
219
219
|
end
|
220
220
|
end
|
@@ -231,16 +231,16 @@ module Spec
|
|
231
231
|
examples_that_were_run << 'should not be run'
|
232
232
|
end
|
233
233
|
end
|
234
|
-
options.
|
234
|
+
options.parse_example "should be run"
|
235
235
|
end
|
236
236
|
|
237
237
|
it "should run only the example, when there is only one" do
|
238
|
-
example_group.run
|
238
|
+
example_group.run(options)
|
239
239
|
examples_that_were_run.should == ["should be run"]
|
240
240
|
end
|
241
241
|
|
242
242
|
it "should run only the one example" do
|
243
|
-
example_group.run
|
243
|
+
example_group.run(options)
|
244
244
|
examples_that_were_run.should == ["should be run"] end
|
245
245
|
end
|
246
246
|
end
|
@@ -258,14 +258,14 @@ module Spec
|
|
258
258
|
end
|
259
259
|
|
260
260
|
it "should send reporter add_example_group" do
|
261
|
-
example_group.run
|
261
|
+
example_group.run(options)
|
262
262
|
reporter.example_groups.should == [example_group]
|
263
263
|
end
|
264
264
|
|
265
265
|
it "should run example on run" do
|
266
266
|
example_ran = false
|
267
267
|
example_group.it("should") {example_ran = true}
|
268
|
-
example_group.run
|
268
|
+
example_group.run(options)
|
269
269
|
example_ran.should be_true
|
270
270
|
end
|
271
271
|
|
@@ -274,7 +274,7 @@ module Spec
|
|
274
274
|
example_group.before(:all) {before_all_run_count_run_count += 1}
|
275
275
|
example_group.it("test") {true}
|
276
276
|
example_group.it("test2") {true}
|
277
|
-
example_group.run
|
277
|
+
example_group.run(options)
|
278
278
|
before_all_run_count_run_count.should == 1
|
279
279
|
end
|
280
280
|
|
@@ -283,7 +283,7 @@ module Spec
|
|
283
283
|
example_group.after(:all) {after_all_run_count += 1}
|
284
284
|
example_group.it("test") {true}
|
285
285
|
example_group.it("test2") {true}
|
286
|
-
example_group.run
|
286
|
+
example_group.run(options)
|
287
287
|
after_all_run_count.should == 1
|
288
288
|
@reporter.rspec_verify
|
289
289
|
end
|
@@ -294,7 +294,7 @@ module Spec
|
|
294
294
|
example_group.before(:all) { @instance_var = context_instance_value_in }
|
295
295
|
example_group.after(:all) { context_instance_value_out = @instance_var }
|
296
296
|
example_group.it("test") {true}
|
297
|
-
example_group.run
|
297
|
+
example_group.run(options)
|
298
298
|
context_instance_value_in.should == context_instance_value_out
|
299
299
|
end
|
300
300
|
|
@@ -303,7 +303,7 @@ module Spec
|
|
303
303
|
context_instance_value_out = ""
|
304
304
|
example_group.before(:all) { @instance_var = context_instance_value_in }
|
305
305
|
example_group.it("test") {context_instance_value_out = @instance_var}
|
306
|
-
example_group.run
|
306
|
+
example_group.run(options)
|
307
307
|
context_instance_value_in.should == context_instance_value_out
|
308
308
|
end
|
309
309
|
|
@@ -321,7 +321,7 @@ module Spec
|
|
321
321
|
describe("I'm not special", :type => :not_special)
|
322
322
|
it "does nothing"
|
323
323
|
end
|
324
|
-
example_group.run
|
324
|
+
example_group.run(options)
|
325
325
|
fiddle.should == [
|
326
326
|
'Example.prepend_before(:all)',
|
327
327
|
'Example.before(:all)',
|
@@ -341,7 +341,7 @@ module Spec
|
|
341
341
|
|
342
342
|
example_group = Class.new(@special_example_group).describe("I'm a special example_group") {}
|
343
343
|
example_group.it("test") {true}
|
344
|
-
example_group.run
|
344
|
+
example_group.run(options)
|
345
345
|
fiddle.should == [
|
346
346
|
'Example.prepend_before(:all)',
|
347
347
|
'Example.before(:all)',
|
@@ -361,7 +361,7 @@ module Spec
|
|
361
361
|
example_group.before(:all) { fiddle << "before(:all)" }
|
362
362
|
example_group.prepend_before(:each) { fiddle << "prepend_before(:each)" }
|
363
363
|
example_group.before(:each) { fiddle << "before(:each)" }
|
364
|
-
example_group.run
|
364
|
+
example_group.run(options)
|
365
365
|
fiddle.should == [
|
366
366
|
'Example.prepend_before(:all)',
|
367
367
|
'Example.before(:all)',
|
@@ -380,7 +380,7 @@ module Spec
|
|
380
380
|
example_group.append_after(:all) { fiddle << "append_after(:all)" }
|
381
381
|
ExampleGroup.after(:all) { fiddle << "Example.after(:all)" }
|
382
382
|
ExampleGroup.append_after(:all) { fiddle << "Example.append_after(:all)" }
|
383
|
-
example_group.run
|
383
|
+
example_group.run(options)
|
384
384
|
fiddle.should == [
|
385
385
|
'after(:each)',
|
386
386
|
'append_after(:each)',
|
@@ -412,7 +412,7 @@ module Spec
|
|
412
412
|
mod1_method
|
413
413
|
mod2_method
|
414
414
|
end
|
415
|
-
example_group.run
|
415
|
+
example_group.run(options)
|
416
416
|
mod1_method_called.should be_true
|
417
417
|
mod2_method_called.should be_true
|
418
418
|
end
|
@@ -427,7 +427,7 @@ module Spec
|
|
427
427
|
example_group = Class.new(@special_example_group).describe("I'm special", :type => :special) do
|
428
428
|
it "does nothing"
|
429
429
|
end
|
430
|
-
example_group.run
|
430
|
+
example_group.run(options)
|
431
431
|
|
432
432
|
example_group.included_modules.should include(mod1)
|
433
433
|
example_group.included_modules.should include(mod2)
|
@@ -443,16 +443,14 @@ module Spec
|
|
443
443
|
$included_predicate_matcher_found = respond_to?(:do_something)
|
444
444
|
end
|
445
445
|
end
|
446
|
-
example_group.run
|
446
|
+
example_group.run(options)
|
447
447
|
$included_predicate_matcher_found.should be(true)
|
448
448
|
end
|
449
449
|
|
450
450
|
it "should use a mock framework set up in config" do
|
451
451
|
mod = Module.new do
|
452
|
-
|
453
|
-
|
454
|
-
$included_module = mod
|
455
|
-
end
|
452
|
+
def self.included(mod)
|
453
|
+
$included_module = mod
|
456
454
|
end
|
457
455
|
|
458
456
|
def teardown_mocks_for_rspec
|
@@ -469,7 +467,7 @@ module Spec
|
|
469
467
|
describe('example')
|
470
468
|
it "does nothing"
|
471
469
|
end
|
472
|
-
example_group.run
|
470
|
+
example_group.run(options)
|
473
471
|
|
474
472
|
$included_module.should_not be_nil
|
475
473
|
$torn_down.should == true
|
@@ -488,7 +486,7 @@ module Spec
|
|
488
486
|
|
489
487
|
it "should send example_pending to formatter" do
|
490
488
|
@formatter.should_receive(:example_pending).with("example", "should be pending", "Example fails")
|
491
|
-
example_group.run
|
489
|
+
example_group.run(options)
|
492
490
|
end
|
493
491
|
end
|
494
492
|
|
@@ -503,7 +501,7 @@ module Spec
|
|
503
501
|
|
504
502
|
it "should send example_pending to formatter" do
|
505
503
|
@formatter.should_receive(:example_pending).with("example", "should be pending", "Example passes")
|
506
|
-
example_group.run
|
504
|
+
example_group.run(options)
|
507
505
|
end
|
508
506
|
end
|
509
507
|
|
@@ -517,21 +515,21 @@ module Spec
|
|
517
515
|
it "should not run any example" do
|
518
516
|
spec_ran = false
|
519
517
|
example_group.it("test") {spec_ran = true}
|
520
|
-
example_group.run
|
518
|
+
example_group.run(options)
|
521
519
|
spec_ran.should be_false
|
522
520
|
end
|
523
521
|
|
524
522
|
it "should run ExampleGroup after(:all)" do
|
525
523
|
after_all_ran = false
|
526
524
|
ExampleGroup.after(:all) { after_all_ran = true }
|
527
|
-
example_group.run
|
525
|
+
example_group.run(options)
|
528
526
|
after_all_ran.should be_true
|
529
527
|
end
|
530
528
|
|
531
529
|
it "should run example_group after(:all)" do
|
532
530
|
after_all_ran = false
|
533
531
|
example_group.after(:all) { after_all_ran = true }
|
534
|
-
example_group.run
|
532
|
+
example_group.run(options)
|
535
533
|
after_all_ran.should be_true
|
536
534
|
end
|
537
535
|
|
@@ -542,7 +540,7 @@ module Spec
|
|
542
540
|
end
|
543
541
|
|
544
542
|
example_group.it("test") {true}
|
545
|
-
example_group.run
|
543
|
+
example_group.run(options)
|
546
544
|
end
|
547
545
|
end
|
548
546
|
|
@@ -556,7 +554,7 @@ module Spec
|
|
556
554
|
it "should run after(:all)" do
|
557
555
|
after_all_ran = false
|
558
556
|
ExampleGroup.after(:all) { after_all_ran = true }
|
559
|
-
example_group.run
|
557
|
+
example_group.run(options)
|
560
558
|
after_all_ran.should be_true
|
561
559
|
end
|
562
560
|
end
|
@@ -571,7 +569,7 @@ module Spec
|
|
571
569
|
it "should run after(:all)" do
|
572
570
|
after_all_ran = false
|
573
571
|
ExampleGroup.after(:all) { after_all_ran = true }
|
574
|
-
example_group.run
|
572
|
+
example_group.run(options)
|
575
573
|
after_all_ran.should be_true
|
576
574
|
end
|
577
575
|
end
|
@@ -600,7 +598,7 @@ module Spec
|
|
600
598
|
example.should equal(example)
|
601
599
|
error.message.should eql("first")
|
602
600
|
end
|
603
|
-
example_group.run
|
601
|
+
example_group.run(options)
|
604
602
|
example_group.first_after_ran.should be_true
|
605
603
|
example_group.second_after_ran.should be_true
|
606
604
|
end
|
@@ -629,7 +627,7 @@ module Spec
|
|
629
627
|
reporter.should_receive(:example_finished) do |name, error|
|
630
628
|
error.message.should eql("first")
|
631
629
|
end
|
632
|
-
example_group.run
|
630
|
+
example_group.run(options)
|
633
631
|
example_group.first_before_ran.should be_true
|
634
632
|
example_group.second_before_ran.should be_false
|
635
633
|
end
|
@@ -643,7 +641,7 @@ module Spec
|
|
643
641
|
end
|
644
642
|
|
645
643
|
it "should return false" do
|
646
|
-
example_group.run.should be_false
|
644
|
+
example_group.run(options).should be_false
|
647
645
|
end
|
648
646
|
end
|
649
647
|
end
|
@@ -661,7 +659,7 @@ module Spec
|
|
661
659
|
example_group = Class.new(ExampleSubclass) do
|
662
660
|
describe(Array)
|
663
661
|
end
|
664
|
-
example_group.
|
662
|
+
example_group.__send__(:described_type).should == Array
|
665
663
|
end
|
666
664
|
|
667
665
|
it "should concat descriptions when nested" do
|
@@ -673,11 +671,5 @@ module Spec
|
|
673
671
|
$nested_group.description.to_s.should == "Array when empty"
|
674
672
|
end
|
675
673
|
end
|
676
|
-
|
677
|
-
describe String do
|
678
|
-
it "should not be included in examples because it is not a module" do
|
679
|
-
lambda{self.map}.should raise_error(NoMethodError, /undefined method `map' for/)
|
680
|
-
end
|
681
|
-
end
|
682
674
|
end
|
683
675
|
end
|
@@ -2,31 +2,14 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
|
-
|
6
|
-
class MatchDescription
|
7
|
-
def initialize(description)
|
8
|
-
@description = description
|
9
|
-
end
|
10
|
-
|
11
|
-
def matches?(matcher)
|
12
|
-
matcher.matches?(@description)
|
13
|
-
end
|
14
|
-
|
15
|
-
def failure_message
|
16
|
-
"expected matcher.matches?(#{@description.inspect}) to return true, got false"
|
17
|
-
end
|
18
|
-
|
19
|
-
def negative_failure_message
|
20
|
-
"expected matcher.matches?(#{@description.inspect}) to return false, got true"
|
21
|
-
end
|
22
|
-
end
|
5
|
+
describe ExampleMatcher, "#matches?" do
|
23
6
|
def match_description(description)
|
24
|
-
|
7
|
+
simple_matcher do |actual, matcher|
|
8
|
+
matcher.failure_message = "expected matcher.matches?(#{description.inspect}) to return true, got false"
|
9
|
+
matcher.negative_failure_message = "expected matcher.matches?(#{description.inspect}) to return false, got true"
|
10
|
+
actual.matches?(description)
|
11
|
+
end
|
25
12
|
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe ExampleMatcher, "#matches?" do
|
29
|
-
include ExampleMatcherSpecHelper
|
30
13
|
|
31
14
|
it "should match correct example_group and example" do
|
32
15
|
matcher = ExampleMatcher.new("example_group", "example")
|
@@ -23,20 +23,22 @@ module Spec
|
|
23
23
|
|
24
24
|
describe "lifecycle" do
|
25
25
|
with_sandboxed_options do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
with_sandboxed_config do
|
27
|
+
before do
|
28
|
+
@options.formatters << mock("formatter", :null_object => true)
|
29
|
+
@options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
|
30
|
+
@reporter = FakeReporter.new(@options)
|
31
|
+
@options.reporter = @reporter
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
ExampleGroup.before_all_parts.should == []
|
34
|
+
ExampleGroup.before_each_parts.should == []
|
35
|
+
ExampleGroup.after_each_parts.should == []
|
36
|
+
ExampleGroup.after_all_parts.should == []
|
37
|
+
def ExampleGroup.count
|
38
|
+
@count ||= 0
|
39
|
+
@count = @count + 1
|
40
|
+
@count
|
41
|
+
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -47,38 +49,6 @@ module Spec
|
|
47
49
|
ExampleGroup.instance_variable_set("@after_all_parts", [])
|
48
50
|
end
|
49
51
|
|
50
|
-
it "should pass before and after callbacks to all ExampleGroup subclasses" do
|
51
|
-
ExampleGroup.before(:suite) do
|
52
|
-
ExampleGroup.count.should == 1
|
53
|
-
end
|
54
|
-
|
55
|
-
ExampleGroup.before(:all) do
|
56
|
-
ExampleGroup.count.should == 2
|
57
|
-
end
|
58
|
-
|
59
|
-
ExampleGroup.before(:each) do
|
60
|
-
ExampleGroup.count.should == 3
|
61
|
-
end
|
62
|
-
|
63
|
-
ExampleGroup.after(:each) do
|
64
|
-
ExampleGroup.count.should == 4
|
65
|
-
end
|
66
|
-
|
67
|
-
ExampleGroup.after(:all) do
|
68
|
-
ExampleGroup.count.should == 5
|
69
|
-
end
|
70
|
-
|
71
|
-
ExampleGroup.after(:suite) do
|
72
|
-
ExampleGroup.count.should == 6
|
73
|
-
end
|
74
|
-
|
75
|
-
Class.new(ExampleGroup) do
|
76
|
-
it "should use ExampleMethods callbacks" do end
|
77
|
-
end
|
78
|
-
@options.run_examples
|
79
|
-
ExampleGroup.count.should == 7
|
80
|
-
end
|
81
|
-
|
82
52
|
describe "eval_block" do
|
83
53
|
before(:each) do
|
84
54
|
@example_group = Class.new(ExampleGroup)
|
@@ -127,32 +97,184 @@ module Spec
|
|
127
97
|
@example.eval_block
|
128
98
|
end
|
129
99
|
|
130
|
-
error.pending_caller.should
|
100
|
+
error.pending_caller.should =~ /#{file}:#{line_number}/
|
131
101
|
end
|
132
102
|
end
|
133
103
|
end
|
134
104
|
end
|
135
105
|
end
|
136
106
|
|
137
|
-
describe "#
|
138
|
-
|
139
|
-
|
140
|
-
|
107
|
+
describe "#backtrace" do
|
108
|
+
with_sandboxed_options do
|
109
|
+
it "returns the backtrace from where the example was defined" do
|
110
|
+
example_group = Class.new(ExampleGroup) do
|
111
|
+
example "of something" do; end
|
141
112
|
end
|
113
|
+
|
114
|
+
example = example_group.examples.first
|
115
|
+
example.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
|
142
116
|
end
|
143
|
-
example = example_group.examples.first
|
144
|
-
example.implementation_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
|
145
117
|
end
|
146
118
|
end
|
119
|
+
|
120
|
+
describe "#implementation_backtrace (deprecated)" do
|
121
|
+
with_sandboxed_options do
|
122
|
+
before(:each) do
|
123
|
+
Kernel.stub!(:warn)
|
124
|
+
end
|
147
125
|
|
148
|
-
|
126
|
+
it "sends a deprecation warning" do
|
127
|
+
example_group = Class.new(ExampleGroup) {}
|
128
|
+
example = example_group.example("") {}
|
129
|
+
Kernel.should_receive(:warn).with(/#implementation_backtrace.*deprecated.*#backtrace instead/m)
|
130
|
+
example.implementation_backtrace
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns the backtrace from where the example was defined" do
|
134
|
+
example_group = Class.new(ExampleGroup) do
|
135
|
+
example "of something" do; end
|
136
|
+
end
|
137
|
+
|
138
|
+
example = example_group.examples.first
|
139
|
+
example.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#full_description" do
|
149
145
|
it "should return the full description of the ExampleGroup and Example" do
|
150
146
|
example_group = Class.new(ExampleGroup).describe("An ExampleGroup") do
|
151
147
|
it "should do something" do
|
152
148
|
end
|
153
149
|
end
|
154
150
|
example = example_group.examples.first
|
155
|
-
example.
|
151
|
+
example.full_description.should == "An ExampleGroup should do something"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#subject" do
|
156
|
+
with_sandboxed_options do
|
157
|
+
it "should return an instance variable named after the described type" do
|
158
|
+
example_group = Class.new(ExampleGroup).describe(Array) do
|
159
|
+
example {}
|
160
|
+
end
|
161
|
+
example = example_group.examples.first
|
162
|
+
example.subject.should == []
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should not barf on a module (as opposed to a class)" do
|
166
|
+
example_group = Class.new(ExampleGroup).describe(ObjectSpace) do
|
167
|
+
example {}
|
168
|
+
end
|
169
|
+
example_group.examples.first.subject.should be_nil
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should not barf on a string" do
|
173
|
+
example_group = Class.new(ExampleGroup).describe('foo') do
|
174
|
+
example {}
|
175
|
+
end
|
176
|
+
example_group.examples.first.subject.should be_nil
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should interact with the same scope as the before block" do
|
180
|
+
example_group = Class.new(ExampleGroup) do
|
181
|
+
subject { @foo = 'foo'}
|
182
|
+
example { should == @foo}
|
183
|
+
it { should == 'foo'}
|
184
|
+
end
|
185
|
+
example_group.run(options).should be_true
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "#should" do
|
191
|
+
with_sandboxed_options do
|
192
|
+
class Thing
|
193
|
+
def ==(other)
|
194
|
+
true
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "in an ExampleGroup with the ivar defined in before" do
|
199
|
+
attr_reader :example, :success
|
200
|
+
|
201
|
+
before(:each) do
|
202
|
+
example_group = describe(Thing, "1") do
|
203
|
+
before(:each) { @spec_example_thing = 'expected' }
|
204
|
+
it { should eql('expected') }
|
205
|
+
end
|
206
|
+
@example = example_group.examples.first
|
207
|
+
@success = example_group.run(options)
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should create an example using the description from the matcher" do
|
211
|
+
example.description.should == 'should eql "expected"'
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should test the matcher returned from the block" do
|
215
|
+
success.should be_true
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "in an ExampleGroup with the subject defined using #subject" do
|
220
|
+
it "should create an example using the description from the matcher" do
|
221
|
+
example_group = describe(Thing, "2") do
|
222
|
+
subject {'this is the subject'}
|
223
|
+
it { should eql('this is the subject') }
|
224
|
+
end
|
225
|
+
example = example_group.examples.first
|
226
|
+
example_group.run(options)
|
227
|
+
example.description.should =~ /should eql "this is the subject"/
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "in an ExampleGroup using an implicit ivar" do
|
232
|
+
it "should create an example using the description from the matcher" do
|
233
|
+
example_group = describe(Thing, "3") do
|
234
|
+
it { should == Thing.new }
|
235
|
+
end
|
236
|
+
example = example_group.examples.first
|
237
|
+
success = example_group.run(options)
|
238
|
+
example.description.should =~ /should == #<Spec::Example::Thing/
|
239
|
+
success.should be_true
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
after(:each) do
|
244
|
+
ExampleGroup.reset
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe "#should_not" do
|
251
|
+
with_sandboxed_options do
|
252
|
+
|
253
|
+
attr_reader :example_group, :example, :success
|
254
|
+
|
255
|
+
before do
|
256
|
+
@example_group = Class.new(ExampleGroup) do
|
257
|
+
def subject; @actual; end
|
258
|
+
before(:each) { @actual = 'expected' }
|
259
|
+
it { should_not eql('unexpected') }
|
260
|
+
end
|
261
|
+
@example = @example_group.examples.first
|
262
|
+
|
263
|
+
@success = example_group.run(options)
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should create an example using the description from the matcher" do
|
267
|
+
example.description.should == 'should not eql "unexpected"'
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should test the matcher returned from the block" do
|
271
|
+
success.should be_true
|
272
|
+
end
|
273
|
+
|
274
|
+
after do
|
275
|
+
ExampleGroup.reset
|
276
|
+
end
|
277
|
+
|
156
278
|
end
|
157
279
|
end
|
158
280
|
end
|