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
@@ -6,7 +6,7 @@ module Spec
|
|
6
6
|
describe "#get" do
|
7
7
|
attr_reader :example_group
|
8
8
|
before(:each) do
|
9
|
-
@example_group_class = Class.new(
|
9
|
+
@example_group_class = Class.new(ExampleGroupDouble)
|
10
10
|
ExampleGroupFactory.register(:registered_type, @example_group_class)
|
11
11
|
end
|
12
12
|
|
@@ -15,32 +15,28 @@ module Spec
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return the default ExampleGroup type for nil" do
|
18
|
-
ExampleGroupFactory
|
18
|
+
ExampleGroupFactory[nil].should == ExampleGroup
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return the default ExampleGroup for an unregistered non-nil value" do
|
22
|
-
ExampleGroupFactory
|
22
|
+
ExampleGroupFactory[:does_not_exist].should == ExampleGroup
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should return custom type if registered" do
|
26
|
-
ExampleGroupFactory
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return the actual type when that is what is submitted" do
|
30
|
-
ExampleGroupFactory.get(@example_group_class).should == @example_group_class
|
26
|
+
ExampleGroupFactory[:registered_type].should == @example_group_class
|
31
27
|
end
|
32
28
|
|
33
29
|
it "should get the custom type after setting the default" do
|
34
|
-
@alternate_example_group_class = Class.new(
|
30
|
+
@alternate_example_group_class = Class.new(ExampleGroupDouble)
|
35
31
|
ExampleGroupFactory.default(@alternate_example_group_class)
|
36
|
-
ExampleGroupFactory
|
32
|
+
ExampleGroupFactory[:registered_type].should == @example_group_class
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
36
|
describe "#create_example_group" do
|
41
37
|
attr_reader :parent_example_group
|
42
38
|
before do
|
43
|
-
@parent_example_group = Class.new(
|
39
|
+
@parent_example_group = Class.new(ExampleGroupDouble) do
|
44
40
|
def initialize(*args, &block)
|
45
41
|
;
|
46
42
|
end
|
@@ -62,7 +58,7 @@ module Spec
|
|
62
58
|
Spec::Example::ExampleGroupFactory.create_example_group do; end
|
63
59
|
}.should raise_error(ArgumentError)
|
64
60
|
end
|
65
|
-
|
61
|
+
|
66
62
|
it "should raise when no block is given" do
|
67
63
|
lambda { Spec::Example::ExampleGroupFactory.create_example_group "foo" }.should raise_error(ArgumentError)
|
68
64
|
end
|
@@ -112,7 +108,26 @@ module Spec
|
|
112
108
|
) {}
|
113
109
|
custom_example_group.superclass.should == parent_example_group
|
114
110
|
end
|
115
|
-
|
111
|
+
|
112
|
+
it "should create a type indicated by spec_path for a path-like key" do
|
113
|
+
Spec::Example::ExampleGroupFactory.register('path/to/custom/', parent_example_group)
|
114
|
+
custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
|
115
|
+
"example_group", :spec_path => "./spec/path/to/custom/some_spec.rb"
|
116
|
+
) {}
|
117
|
+
custom_example_group.superclass.should == parent_example_group
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should use the longest key that matches when creating a type indicated by spec_path" do
|
121
|
+
longer = Class.new parent_example_group
|
122
|
+
Spec::Example::ExampleGroupFactory.register(:longer, longer)
|
123
|
+
long = Class.new parent_example_group
|
124
|
+
Spec::Example::ExampleGroupFactory.register(:long, long)
|
125
|
+
custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
|
126
|
+
"example_group", :spec_path => "./spec/longer/some_spec.rb"
|
127
|
+
) {}
|
128
|
+
custom_example_group.superclass.should == longer
|
129
|
+
end
|
130
|
+
|
116
131
|
it "sets the spec_path from the caller" do
|
117
132
|
options = {}
|
118
133
|
shared_example_group = Spec::Example::ExampleGroupFactory.create_example_group("foo", options) {}
|
@@ -152,19 +167,19 @@ module Spec
|
|
152
167
|
end
|
153
168
|
Spec::Runner.options.example_groups.should_not include(example_group)
|
154
169
|
end
|
155
|
-
|
170
|
+
|
156
171
|
after(:each) do
|
157
172
|
Spec::Example::ExampleGroupFactory.reset
|
158
173
|
end
|
159
174
|
end
|
160
|
-
|
175
|
+
|
161
176
|
describe "#create_shared_example_group" do
|
162
177
|
it "registers a new shared example group" do
|
163
178
|
shared_example_group = Spec::Example::ExampleGroupFactory.create_shared_example_group("something shared") {}
|
164
179
|
shared_example_group.should be_an_instance_of(Spec::Example::SharedExampleGroup)
|
165
180
|
SharedExampleGroup.should include(shared_example_group)
|
166
181
|
end
|
167
|
-
|
182
|
+
|
168
183
|
it "sets the spec_path from the caller" do
|
169
184
|
options = {}
|
170
185
|
shared_example_group = Spec::Example::ExampleGroupFactory.create_shared_example_group("foo", options) {}
|
@@ -172,34 +187,6 @@ module Spec
|
|
172
187
|
end
|
173
188
|
end
|
174
189
|
|
175
|
-
describe "#registered_or_ancestor_of_registered?" do
|
176
|
-
before(:each) do
|
177
|
-
@unregistered_parent = Class.new(ExampleGroup)
|
178
|
-
@registered_child = Class.new(@unregistered_parent)
|
179
|
-
@unregistered_grandchild = Class.new(@registered_child)
|
180
|
-
Spec::Example::ExampleGroupFactory.register :registered_child, @registered_child
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should return true for empty list" do
|
184
|
-
Spec::Example::ExampleGroupFactory.registered_or_ancestor_of_registered?([]).should be_true
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should return true for a registered example group class" do
|
188
|
-
Spec::Example::ExampleGroupFactory.registered_or_ancestor_of_registered?([@registered_child]).should be_true
|
189
|
-
end
|
190
|
-
|
191
|
-
it "should return true for an ancestor of a registered example_group_classes" do
|
192
|
-
Spec::Example::ExampleGroupFactory.registered_or_ancestor_of_registered?([@unregistered_parent]).should be_true
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should return false for a subclass of a registered example_group_class" do
|
196
|
-
Spec::Example::ExampleGroupFactory.registered_or_ancestor_of_registered?([@unregistered_grandchild]).should be_false
|
197
|
-
end
|
198
|
-
|
199
|
-
after(:each) do
|
200
|
-
Spec::Example::ExampleGroupFactory.reset
|
201
|
-
end
|
202
|
-
end
|
203
190
|
end
|
204
191
|
end
|
205
192
|
end
|
@@ -12,21 +12,21 @@ module Spec
|
|
12
12
|
options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
|
13
13
|
@reporter = FakeReporter.new(@options)
|
14
14
|
options.reporter = reporter
|
15
|
-
@example_group = Class.new(
|
15
|
+
@example_group = Class.new(ExampleGroupDouble) do
|
16
16
|
describe("ExampleGroup")
|
17
17
|
it "does nothing"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
after(:each) do
|
22
|
-
|
22
|
+
ExampleGroupDouble.reset
|
23
23
|
end
|
24
24
|
|
25
25
|
["describe","context"].each do |method|
|
26
26
|
describe "##{method}" do
|
27
27
|
describe "when creating an ExampleGroup" do
|
28
28
|
before(:each) do
|
29
|
-
@parent_example_group = Class.new(
|
29
|
+
@parent_example_group = Class.new(ExampleGroupDouble) do
|
30
30
|
example "first example" do; end
|
31
31
|
end
|
32
32
|
@child_example_group = @parent_example_group.__send__ method, "Child" do
|
@@ -66,17 +66,36 @@ module Spec
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
[:specify, :it].each do |method|
|
69
|
+
[:example, :specify, :it].each do |method|
|
70
70
|
describe "##{method.to_s}" do
|
71
|
-
it "should
|
71
|
+
it "should add an example" do
|
72
72
|
lambda {
|
73
73
|
@example_group.__send__(method, "")
|
74
74
|
}.should change { @example_group.examples.length }.by(1)
|
75
75
|
end
|
76
|
+
|
77
|
+
describe "creates an ExampleDescription" do
|
78
|
+
before(:all) do
|
79
|
+
@example_group = Class.new(ExampleGroupDouble).describe("bar")
|
80
|
+
@example_description = @example_group.__send__(method, "foo", {:this => :that}, "the backtrace") {}
|
81
|
+
end
|
82
|
+
|
83
|
+
specify "with a description" do
|
84
|
+
@example_description.description.should == "foo"
|
85
|
+
end
|
86
|
+
|
87
|
+
specify "with options" do
|
88
|
+
@example_description.options.should == {:this => :that}
|
89
|
+
end
|
90
|
+
|
91
|
+
specify "with a backtrace" do
|
92
|
+
@example_description.backtrace.should == "the backtrace"
|
93
|
+
end
|
94
|
+
end
|
76
95
|
end
|
77
96
|
end
|
78
97
|
|
79
|
-
[:xit, :xspecify].each do |method|
|
98
|
+
[:xexample, :xit, :xspecify].each do |method|
|
80
99
|
describe "##{method.to_s}" do
|
81
100
|
before(:each) do
|
82
101
|
Kernel.stub!(:warn)
|
@@ -95,10 +114,9 @@ module Spec
|
|
95
114
|
end
|
96
115
|
end
|
97
116
|
|
98
|
-
|
99
117
|
describe "#examples" do
|
100
118
|
it "should have Examples" do
|
101
|
-
example_group = Class.new(
|
119
|
+
example_group = Class.new(ExampleGroupDouble) do
|
102
120
|
it "should exist" do; end
|
103
121
|
end
|
104
122
|
example_group.examples.length.should == 1
|
@@ -106,7 +124,7 @@ module Spec
|
|
106
124
|
end
|
107
125
|
|
108
126
|
it "should not include methods that begin with test (only when TU interop is loaded)" do
|
109
|
-
example_group = Class.new(
|
127
|
+
example_group = Class.new(ExampleGroupDouble) do
|
110
128
|
def test_any_args(*args)
|
111
129
|
true.should be_true
|
112
130
|
end
|
@@ -123,12 +141,13 @@ module Spec
|
|
123
141
|
# forces the run
|
124
142
|
end
|
125
143
|
end
|
144
|
+
|
126
145
|
example_group.examples.length.should == 1
|
127
146
|
example_group.run(options).should be_true
|
128
147
|
end
|
129
148
|
|
130
149
|
it "should include methods that begin with should and has an arity of 0 in suite" do
|
131
|
-
example_group = Class.new(
|
150
|
+
example_group = Class.new(ExampleGroupDouble) do
|
132
151
|
def shouldCamelCase
|
133
152
|
true.should be_true
|
134
153
|
end
|
@@ -149,7 +168,7 @@ module Spec
|
|
149
168
|
end
|
150
169
|
end
|
151
170
|
example_group.should have(4).examples
|
152
|
-
descriptions = example_group.examples.collect {|
|
171
|
+
descriptions = example_group.examples.collect {|e| e.description}
|
153
172
|
descriptions.should include(
|
154
173
|
"shouldCamelCase",
|
155
174
|
"should_any_args",
|
@@ -162,7 +181,7 @@ module Spec
|
|
162
181
|
end
|
163
182
|
|
164
183
|
it "should not include methods that begin with test_ and has an arity > 0 in suite" do
|
165
|
-
example_group = Class.new(
|
184
|
+
example_group = Class.new(ExampleGroupDouble) do
|
166
185
|
def test_invalid(foo)
|
167
186
|
1.should == 1
|
168
187
|
end
|
@@ -174,7 +193,7 @@ module Spec
|
|
174
193
|
end
|
175
194
|
|
176
195
|
it "should not include methods that begin with should_ and has an arity > 0 in suite" do
|
177
|
-
example_group = Class.new(
|
196
|
+
example_group = Class.new(ExampleGroupDouble) do
|
178
197
|
def should_invalid(foo)
|
179
198
|
1.should == 2
|
180
199
|
end
|
@@ -193,7 +212,7 @@ module Spec
|
|
193
212
|
end
|
194
213
|
|
195
214
|
it "should run should_methods" do
|
196
|
-
example_group = Class.new(
|
215
|
+
example_group = Class.new(ExampleGroupDouble) do
|
197
216
|
def should_valid
|
198
217
|
1.should == 2
|
199
218
|
end
|
@@ -322,8 +341,8 @@ module Spec
|
|
322
341
|
example_group.spec_path.should == File.expand_path("blah")
|
323
342
|
end
|
324
343
|
|
325
|
-
it ".
|
326
|
-
example_group.
|
344
|
+
it ".options should return all the options passed in" do
|
345
|
+
example_group.options.should == {:a => "b", :spec_path => "blah"}
|
327
346
|
end
|
328
347
|
|
329
348
|
end
|
@@ -334,14 +353,14 @@ module Spec
|
|
334
353
|
example_group.description.should eql(example_group.description)
|
335
354
|
end
|
336
355
|
|
337
|
-
it "should not add a space when
|
356
|
+
it "should not add a space when description begins with #" do
|
338
357
|
child_example_group = Class.new(example_group) do
|
339
358
|
describe("#foobar", "Does something")
|
340
359
|
end
|
341
360
|
child_example_group.description.should == "ExampleGroup#foobar Does something"
|
342
361
|
end
|
343
362
|
|
344
|
-
it "should not add a space when
|
363
|
+
it "should not add a space when description begins with ." do
|
345
364
|
child_example_group = Class.new(example_group) do
|
346
365
|
describe(".foobar", "Does something")
|
347
366
|
end
|
@@ -357,6 +376,11 @@ module Spec
|
|
357
376
|
example_group.set_description("")
|
358
377
|
example_group.description.should =~ /Class:/
|
359
378
|
end
|
379
|
+
|
380
|
+
it "is cached" do
|
381
|
+
example_group.set_description("describe me")
|
382
|
+
example_group.description.should be(example_group.description)
|
383
|
+
end
|
360
384
|
end
|
361
385
|
|
362
386
|
describe "#description_parts" do
|
@@ -365,7 +389,7 @@ module Spec
|
|
365
389
|
end
|
366
390
|
|
367
391
|
it "should return an Array of the description args from each class in the hierarchy" do
|
368
|
-
parent_example_group = Class.new(
|
392
|
+
parent_example_group = Class.new(ExampleGroupDouble) do
|
369
393
|
describe("Parent")
|
370
394
|
end
|
371
395
|
|
@@ -385,6 +409,10 @@ module Spec
|
|
385
409
|
Spec::Example::ExampleGroup
|
386
410
|
]
|
387
411
|
end
|
412
|
+
|
413
|
+
it "caches the description parts" do
|
414
|
+
example_group.description_parts.should equal(example_group.description_parts)
|
415
|
+
end
|
388
416
|
end
|
389
417
|
|
390
418
|
describe "#described_type" do
|
@@ -396,7 +424,7 @@ module Spec
|
|
396
424
|
end
|
397
425
|
|
398
426
|
it "should return #described_type of superclass when no passed in type" do
|
399
|
-
parent_example_group = Class.new(
|
427
|
+
parent_example_group = Class.new(ExampleGroupDouble) do
|
400
428
|
describe Object, "#foobar"
|
401
429
|
end
|
402
430
|
child_example_group = Class.new(parent_example_group) do
|
@@ -404,25 +432,15 @@ module Spec
|
|
404
432
|
end
|
405
433
|
child_example_group.described_type.should == Object
|
406
434
|
end
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
proc = Proc.new { after_all_ran = true }
|
413
|
-
|
414
|
-
example_group = Class.new(ExampleGroup) do
|
415
|
-
specify("example") {}
|
416
|
-
after(:each, &proc)
|
435
|
+
|
436
|
+
it "is cached per example group" do
|
437
|
+
klass = Class.new
|
438
|
+
group = Class.new(ExampleGroupDouble) do
|
439
|
+
describe(klass)
|
417
440
|
end
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
after_all_ran = false
|
423
|
-
example_group.remove_after(:each, &proc)
|
424
|
-
example_group.run(options)
|
425
|
-
after_all_ran.should be_false
|
441
|
+
group.should_receive(:description_parts).once.and_return([klass])
|
442
|
+
group.described_type
|
443
|
+
group.described_type
|
426
444
|
end
|
427
445
|
end
|
428
446
|
|
@@ -463,7 +481,7 @@ module Spec
|
|
463
481
|
|
464
482
|
describe "#class_eval" do
|
465
483
|
it "should allow constants to be defined" do
|
466
|
-
example_group = Class.new(
|
484
|
+
example_group = Class.new(ExampleGroupDouble) do
|
467
485
|
FOO = 1
|
468
486
|
it "should reference FOO" do
|
469
487
|
FOO.should == 1
|
@@ -485,7 +503,7 @@ module Spec
|
|
485
503
|
end
|
486
504
|
end
|
487
505
|
|
488
|
-
describe '#
|
506
|
+
describe '#remove_example_group' do
|
489
507
|
before(:each) do
|
490
508
|
Spec::Runner.options.add_example_group example_group
|
491
509
|
end
|
@@ -498,7 +516,7 @@ module Spec
|
|
498
516
|
describe "#run" do
|
499
517
|
describe "given an example group with at least one example" do
|
500
518
|
it "should call add_example_group" do
|
501
|
-
example_group = Class.new(
|
519
|
+
example_group = Class.new(ExampleGroupDouble) do
|
502
520
|
example("anything") {}
|
503
521
|
end
|
504
522
|
reporter.should_receive(:add_example_group)
|
@@ -508,7 +526,7 @@ module Spec
|
|
508
526
|
|
509
527
|
describe "given an example group with no examples" do
|
510
528
|
it "should NOT call add_example_group" do
|
511
|
-
example_group = Class.new(
|
529
|
+
example_group = Class.new(ExampleGroupDouble) do end
|
512
530
|
reporter.should_not_receive(:add_example_group)
|
513
531
|
example_group.run(options)
|
514
532
|
end
|
@@ -517,7 +535,7 @@ module Spec
|
|
517
535
|
|
518
536
|
describe "#matcher_class=" do
|
519
537
|
it "should call new and matches? on the class used for matching examples" do
|
520
|
-
example_group = Class.new(
|
538
|
+
example_group = Class.new(ExampleGroupDouble) do
|
521
539
|
it "should do something" do end
|
522
540
|
def self.specified_examples
|
523
541
|
["something"]
|
@@ -552,7 +570,7 @@ module Spec
|
|
552
570
|
|
553
571
|
describe "#backtrace" do
|
554
572
|
it "returns the backtrace from where the example group was defined" do
|
555
|
-
example_group = Class.new(
|
573
|
+
example_group = Class.new(ExampleGroupDouble).describe("foo") do
|
556
574
|
example "bar" do; end
|
557
575
|
end
|
558
576
|
example_group.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
@@ -564,13 +582,13 @@ module Spec
|
|
564
582
|
Kernel.stub!(:warn)
|
565
583
|
end
|
566
584
|
it "sends a deprecation warning" do
|
567
|
-
example_group = Class.new(
|
585
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
568
586
|
Kernel.should_receive(:warn).with(/#example_group_backtrace.*deprecated.*#backtrace instead/m)
|
569
587
|
example_group.example_group_backtrace
|
570
588
|
end
|
571
589
|
|
572
590
|
it "returns the backtrace from where the example group was defined" do
|
573
|
-
example_group = Class.new(
|
591
|
+
example_group = Class.new(ExampleGroupDouble).describe("foo") do
|
574
592
|
example "bar" do; end
|
575
593
|
end
|
576
594
|
example_group.example_group_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
@@ -579,21 +597,21 @@ module Spec
|
|
579
597
|
|
580
598
|
describe "#before" do
|
581
599
|
it "stores before(:each) blocks" do
|
582
|
-
example_group = Class.new(
|
600
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
583
601
|
block = lambda {}
|
584
602
|
example_group.before(:each, &block)
|
585
603
|
example_group.before_each_parts.should include(block)
|
586
604
|
end
|
587
605
|
|
588
606
|
it "stores before(:all) blocks" do
|
589
|
-
example_group = Class.new(
|
607
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
590
608
|
block = lambda {}
|
591
609
|
example_group.before(:all, &block)
|
592
610
|
example_group.before_all_parts.should include(block)
|
593
611
|
end
|
594
612
|
|
595
613
|
it "stores before(:suite) blocks" do
|
596
|
-
example_group = Class.new(
|
614
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
597
615
|
parts = []
|
598
616
|
ExampleGroupMethods.stub!(:before_suite_parts).and_return(parts)
|
599
617
|
block = lambda {}
|
@@ -605,21 +623,21 @@ module Spec
|
|
605
623
|
|
606
624
|
describe "#after" do
|
607
625
|
it "stores after(:each) blocks" do
|
608
|
-
example_group = Class.new(
|
626
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
609
627
|
block = lambda {}
|
610
628
|
example_group.after(:each, &block)
|
611
629
|
example_group.after_each_parts.should include(block)
|
612
630
|
end
|
613
631
|
|
614
632
|
it "stores after(:all) blocks" do
|
615
|
-
example_group = Class.new(
|
633
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
616
634
|
block = lambda {}
|
617
635
|
example_group.after(:all, &block)
|
618
636
|
example_group.after_all_parts.should include(block)
|
619
637
|
end
|
620
638
|
|
621
639
|
it "stores after(:suite) blocks" do
|
622
|
-
example_group = Class.new(
|
640
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
623
641
|
parts = []
|
624
642
|
ExampleGroupMethods.stub!(:after_suite_parts).and_return(parts)
|
625
643
|
block = lambda {}
|
@@ -628,6 +646,22 @@ module Spec
|
|
628
646
|
end
|
629
647
|
end
|
630
648
|
|
649
|
+
describe "#run_before_all" do
|
650
|
+
it "does not create an instance if before_all_parts are empty" do
|
651
|
+
example_group = Class.new(ExampleGroupDouble) { example("one example") {} }
|
652
|
+
example_group.should_not_receive(:new)
|
653
|
+
example_group.__send__ :run_before_all, nil
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|
657
|
+
describe "#run_after_all" do
|
658
|
+
it "does not create an instance if after_all_parts are empty" do
|
659
|
+
example_group = Class.new(ExampleGroupDouble) { example("one example") {} }
|
660
|
+
example_group.should_not_receive(:new)
|
661
|
+
example_group.__send__ :run_after_all, true, {}, nil
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
631
665
|
end
|
632
666
|
end
|
633
667
|
end
|