rspec 1.1.12 → 1.2.0
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 +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
@@ -128,19 +128,34 @@ module Spec
|
|
128
128
|
|
129
129
|
it 'should keep public methods public' do
|
130
130
|
@object.should_receive(:public_method)
|
131
|
-
|
131
|
+
with_ruby('1.9') do
|
132
|
+
@object.public_methods.should include(:public_method)
|
133
|
+
end
|
134
|
+
with_ruby('1.8') do
|
135
|
+
@object.public_methods.should include('public_method')
|
136
|
+
end
|
132
137
|
@object.public_method
|
133
138
|
end
|
134
139
|
|
135
140
|
it 'should keep private methods private' do
|
136
141
|
@object.should_receive(:private_method)
|
137
|
-
|
142
|
+
with_ruby('1.9') do
|
143
|
+
@object.private_methods.should include(:private_method)
|
144
|
+
end
|
145
|
+
with_ruby('1.8') do
|
146
|
+
@object.private_methods.should include('private_method')
|
147
|
+
end
|
138
148
|
@object.public_method
|
139
149
|
end
|
140
150
|
|
141
151
|
it 'should keep protected methods protected' do
|
142
152
|
@object.should_receive(:protected_method)
|
143
|
-
|
153
|
+
with_ruby('1.9') do
|
154
|
+
@object.protected_methods.should include(:protected_method)
|
155
|
+
end
|
156
|
+
with_ruby('1.8') do
|
157
|
+
@object.protected_methods.should include('protected_method')
|
158
|
+
end
|
144
159
|
@object.public_method
|
145
160
|
end
|
146
161
|
|
data/spec/spec/mocks/{passing_mock_argument_constraints_spec.rb → passing_argument_matchers_spec.rb}
RENAMED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Mocks
|
5
|
-
describe "mock argument
|
5
|
+
describe "mock argument matchers", :shared => true do
|
6
6
|
before(:each) do
|
7
7
|
@mock = Mock.new("test mock")
|
8
8
|
Kernel.stub!(:warn)
|
@@ -13,8 +13,8 @@ module Spec
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe Methods, "handling argument
|
17
|
-
it_should_behave_like "mock argument
|
16
|
+
describe Methods, "handling argument matchers" do
|
17
|
+
it_should_behave_like "mock argument matchers"
|
18
18
|
|
19
19
|
it "should accept true as boolean()" do
|
20
20
|
@mock.should_receive(:random_call).with(boolean())
|
@@ -88,8 +88,8 @@ module Spec
|
|
88
88
|
|
89
89
|
end
|
90
90
|
|
91
|
-
describe Methods, "handling block
|
92
|
-
it_should_behave_like "mock argument
|
91
|
+
describe Methods, "handling block matchers" do
|
92
|
+
it_should_behave_like "mock argument matchers"
|
93
93
|
|
94
94
|
it "should match arguments against RSpec expectations" do
|
95
95
|
@mock.should_receive(:random_call).with {|arg1, arg2, arr, *rest|
|
@@ -103,7 +103,7 @@ module Spec
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
describe Methods, "handling non-
|
106
|
+
describe Methods, "handling non-matcher arguments" do
|
107
107
|
|
108
108
|
before(:each) do
|
109
109
|
@mock = Mock.new("test mock")
|
@@ -3,12 +3,24 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
3
3
|
module Spec
|
4
4
|
module Mocks
|
5
5
|
describe "Example with stubbed and then called message" do
|
6
|
-
it "
|
6
|
+
it "fails if the message is expected and then subsequently not called again" do
|
7
7
|
mock_obj = mock("mock", :msg => nil)
|
8
8
|
mock_obj.msg
|
9
9
|
mock_obj.should_receive(:msg)
|
10
10
|
lambda { mock_obj.rspec_verify }.should raise_error(Spec::Mocks::MockExpectationError)
|
11
11
|
end
|
12
|
+
|
13
|
+
it "outputs arguments of all similar calls" do
|
14
|
+
m = mock('mock', :foo => true)
|
15
|
+
m.should_receive(:foo).with('first')
|
16
|
+
m.foo('second')
|
17
|
+
m.foo('third')
|
18
|
+
lambda do
|
19
|
+
m.rspec_verify
|
20
|
+
end.should raise_error(%q|Mock 'mock' expected :foo with ("first") but received it with (["second"], ["third"])|)
|
21
|
+
m.rspec_reset
|
22
|
+
end
|
12
23
|
end
|
24
|
+
|
13
25
|
end
|
14
26
|
end
|
@@ -5,7 +5,7 @@ describe "The bin/spec script" do
|
|
5
5
|
include RubyForker
|
6
6
|
|
7
7
|
it "should have no warnings" do
|
8
|
-
pending "Hangs on JRuby" if
|
8
|
+
pending "Hangs on JRuby" if RUBY_PLATFORM =~ /java/
|
9
9
|
spec_path = "#{File.dirname(__FILE__)}/../../../bin/spec"
|
10
10
|
|
11
11
|
output = ruby "-w #{spec_path} --help 2>&1"
|
@@ -13,7 +13,7 @@ describe "The bin/spec script" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should show the help w/ no args" do
|
16
|
-
pending "Hangs on JRuby" if
|
16
|
+
pending "Hangs on JRuby" if RUBY_PLATFORM =~ /java/
|
17
17
|
spec_path = "#{File.dirname(__FILE__)}/../../../bin/spec"
|
18
18
|
|
19
19
|
output = ruby "-w #{spec_path} 2>&1"
|
@@ -7,27 +7,27 @@ module Spec
|
|
7
7
|
with_sandboxed_config do
|
8
8
|
describe "#mock_with" do
|
9
9
|
it "should default mock framework to rspec" do
|
10
|
-
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rspec$/
|
10
|
+
config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/rspec$/
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should set rspec mocking explicitly" do
|
14
14
|
config.mock_with(:rspec)
|
15
|
-
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rspec$/
|
15
|
+
config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/rspec$/
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should set mocha" do
|
19
19
|
config.mock_with(:mocha)
|
20
|
-
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/mocha$/
|
20
|
+
config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/mocha$/
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should set flexmock" do
|
24
24
|
config.mock_with(:flexmock)
|
25
|
-
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/flexmock$/
|
25
|
+
config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/flexmock$/
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should set rr" do
|
29
29
|
config.mock_with(:rr)
|
30
|
-
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rr$/
|
30
|
+
config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/rr$/
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should set an arbitrary adapter module" do
|
@@ -40,7 +40,7 @@ module Spec
|
|
40
40
|
describe "#include" do
|
41
41
|
|
42
42
|
before(:each) do
|
43
|
-
@example_group_class = Class.new(
|
43
|
+
@example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) {}
|
44
44
|
Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class)
|
45
45
|
end
|
46
46
|
|
@@ -58,7 +58,7 @@ module Spec
|
|
58
58
|
|
59
59
|
it "should not include modules in a type they are not intended for" do
|
60
60
|
mod = Module.new
|
61
|
-
@other_example_group_class = Class.new(
|
61
|
+
@other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble)
|
62
62
|
Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
|
63
63
|
|
64
64
|
config.include mod, :type => :foobar
|
@@ -68,7 +68,7 @@ module Spec
|
|
68
68
|
|
69
69
|
it "accepts an Array of types" do
|
70
70
|
mod = Module.new
|
71
|
-
@other_example_group_class = Class.new(
|
71
|
+
@other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble)
|
72
72
|
Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
|
73
73
|
|
74
74
|
config.include mod, :type => [:foobar, :baz]
|
@@ -82,7 +82,7 @@ module Spec
|
|
82
82
|
describe "#extend" do
|
83
83
|
|
84
84
|
before(:each) do
|
85
|
-
@example_group_class = Class.new(
|
85
|
+
@example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) {}
|
86
86
|
Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class)
|
87
87
|
end
|
88
88
|
|
@@ -99,7 +99,7 @@ module Spec
|
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should not extend non-specified groups" do
|
102
|
-
@other_example_group_class = Class.new(
|
102
|
+
@other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble)
|
103
103
|
Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
|
104
104
|
|
105
105
|
mod = Module.new
|
@@ -114,9 +114,9 @@ module Spec
|
|
114
114
|
describe "ordering methods: " do
|
115
115
|
|
116
116
|
before(:each) do
|
117
|
-
@special_example_group = Class.new(
|
117
|
+
@special_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("special_example_group")
|
118
118
|
@special_child_example_group = Class.new(@special_example_group).describe("special_child_example_group")
|
119
|
-
@nonspecial_example_group = Class.new(
|
119
|
+
@nonspecial_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("nonspecial_example_group")
|
120
120
|
Spec::Example::ExampleGroupFactory.register(:special, @special_example_group)
|
121
121
|
Spec::Example::ExampleGroupFactory.register(:special_child, @special_child_example_group)
|
122
122
|
Spec::Example::ExampleGroupFactory.register(:non_special, @nonspecial_example_group)
|
@@ -2,96 +2,94 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Runner
|
5
|
-
|
6
|
-
|
7
|
-
it "should print error when there is no running local server" do
|
8
|
-
err = StringIO.new
|
9
|
-
out = StringIO.new
|
10
|
-
DrbCommandLine.run(OptionParser.parse(['--version'], err, out))
|
5
|
+
unless jruby?
|
6
|
+
describe DrbCommandLine do
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
8
|
+
context "without server running" do
|
9
|
+
it "should print error when there is no running local server" do
|
10
|
+
err = out = StringIO.new
|
11
|
+
DrbCommandLine.run(OptionParser.parse(['--version'], err, out))
|
17
12
|
|
18
|
-
|
13
|
+
err.rewind
|
14
|
+
err.read.should =~ /No server is running/
|
15
|
+
end
|
16
|
+
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
unless jruby?
|
32
|
-
before(:all) do
|
33
|
-
DRb.start_service("druby://127.0.0.1:8989", ::CommandLineForSpec)
|
34
|
-
@@drb_example_file_counter = 0
|
35
|
-
end
|
18
|
+
context "with server running" do
|
19
|
+
class ::CommandLineForDrbSpec
|
20
|
+
def self.run(argv, stderr, stdout)
|
21
|
+
orig_options = Spec::Runner.options
|
22
|
+
tmp_options = Spec::Runner::OptionParser.parse(argv, stderr, stdout)
|
23
|
+
Spec::Runner.use tmp_options
|
24
|
+
Spec::Runner::CommandLine.run(tmp_options)
|
25
|
+
ensure
|
26
|
+
Spec::Runner.use orig_options
|
27
|
+
end
|
28
|
+
end
|
36
29
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
before(:all) do
|
31
|
+
DRb.start_service("druby://127.0.0.1:8989", ::CommandLineForDrbSpec)
|
32
|
+
@@drb_example_file_counter = 0
|
33
|
+
end
|
41
34
|
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
before(:each) do
|
36
|
+
create_dummy_spec_file
|
37
|
+
@@drb_example_file_counter = @@drb_example_file_counter + 1
|
38
|
+
end
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
after(:each) do
|
41
|
+
File.delete(@dummy_spec_filename)
|
42
|
+
end
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
44
|
+
after(:all) do
|
45
|
+
DRb.stop_service
|
46
|
+
end
|
54
47
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
48
|
+
it "should run against local server" do
|
49
|
+
out = run_spec_via_druby(['--version'])
|
50
|
+
out.should =~ /rspec \d+\.\d+\.\d+.*/n
|
51
|
+
end
|
59
52
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
53
|
+
it "should output green colorized text when running with --colour option" do
|
54
|
+
out = run_spec_via_druby(["--colour", @dummy_spec_filename])
|
55
|
+
out.should =~ /\e\[32m/n
|
56
|
+
end
|
64
57
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
58
|
+
it "should output red colorized text when running with -c option" do
|
59
|
+
out = run_spec_via_druby(["-c", @dummy_spec_filename])
|
60
|
+
out.should =~ /\e\[31m/n
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_dummy_spec_file
|
64
|
+
@dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@@drb_example_file_counter}.rb"
|
65
|
+
File.open(@dummy_spec_filename, 'w') do |f|
|
66
|
+
f.write %{
|
67
|
+
describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
|
68
|
+
it "should be output with green bar" do
|
69
|
+
true.should be_true
|
70
|
+
end
|
73
71
|
|
74
|
-
|
75
|
-
|
72
|
+
it "should be output with red bar" do
|
73
|
+
violated("I want to see a red bar!")
|
74
|
+
end
|
76
75
|
end
|
77
|
-
|
78
|
-
|
76
|
+
}
|
77
|
+
end
|
79
78
|
end
|
80
|
-
end
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
def run_spec_via_druby(argv)
|
81
|
+
err, out = StringIO.new, StringIO.new
|
82
|
+
out.instance_eval do
|
83
|
+
def tty?; true end
|
84
|
+
end
|
85
|
+
options = ::Spec::Runner::Options.new(err, out)
|
86
|
+
options.argv = argv
|
87
|
+
Spec::Runner::DrbCommandLine.run(options)
|
88
|
+
out.rewind; out.read
|
86
89
|
end
|
87
|
-
options = ::Spec::Runner::Options.new(err, out)
|
88
|
-
options.argv = argv
|
89
|
-
Spec::Runner::DrbCommandLine.run(options)
|
90
|
-
out.rewind; out.read
|
91
90
|
end
|
91
|
+
|
92
92
|
end
|
93
|
-
|
94
93
|
end
|
95
|
-
|
96
94
|
end
|
97
95
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
2
|
require 'spec/runner/formatter/base_text_formatter'
|
3
|
-
require 'fileutils'
|
4
3
|
|
5
4
|
module Spec
|
6
5
|
module Runner
|
@@ -16,7 +15,89 @@ module Spec
|
|
16
15
|
File.stub!(:open)
|
17
16
|
BaseTextFormatter.new({},"#{@sandbox}/temp.rb")
|
18
17
|
end
|
18
|
+
|
19
|
+
context "(deprecations)" do
|
20
|
+
before(:each) do
|
21
|
+
Kernel.stub!(:warn)
|
22
|
+
@io = StringIO.new
|
23
|
+
@options = mock('options')
|
24
|
+
@options.stub!(:dry_run).and_return(false)
|
25
|
+
@options.stub!(:colour).and_return(false)
|
26
|
+
@options.stub!(:autospec).and_return(false)
|
27
|
+
@formatter = Class.new(BaseTextFormatter) do
|
28
|
+
def method_that_class_magenta(message)
|
29
|
+
magenta(message)
|
30
|
+
end
|
31
|
+
def method_that_class_colourise(message, failure)
|
32
|
+
colourise(message, failure)
|
33
|
+
end
|
34
|
+
end.new(@options, @io)
|
35
|
+
@failure = stub('failure', :pending_fixed? => false)
|
36
|
+
end
|
37
|
+
|
38
|
+
context "#colourise" do
|
39
|
+
it "warns when subclasses call colourise" do
|
40
|
+
Kernel.should_receive(:warn).with(/DEPRECATED/)
|
41
|
+
@formatter.method_that_class_colourise('this message', @failure)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "delegates to colorize_failure" do
|
45
|
+
@formatter.should_receive(:colorize_failure).with('this message', @failure)
|
46
|
+
@formatter.colourise('this message', @failure)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "#magenta" do
|
51
|
+
it "warns when subclasses call magenta" do
|
52
|
+
Kernel.should_receive(:warn).with(/DEPRECATED/)
|
53
|
+
@formatter.method_that_class_magenta('this message')
|
54
|
+
end
|
19
55
|
|
56
|
+
it "delegates to red" do
|
57
|
+
@formatter.should_receive(:red).with('this message')
|
58
|
+
@formatter.method_that_class_magenta('this message')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#colour (protected)" do
|
65
|
+
before(:each) do
|
66
|
+
@original_RSPEC_COLOR = ENV['RSPEC_COLOR']
|
67
|
+
end
|
68
|
+
|
69
|
+
it "colorizes when colour? and output_to_tty? return true" do
|
70
|
+
out = StringIO.new
|
71
|
+
options = stub('options', :colour => true, :autospec => false)
|
72
|
+
formatter = BaseTextFormatter.new(options,out)
|
73
|
+
formatter.stub!(:output_to_tty?).and_return(true)
|
74
|
+
formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m"
|
75
|
+
end
|
76
|
+
|
77
|
+
it "colorizes when ENV['RSPEC_COLOR'] is set even if colour? and output_to_tty? return false" do
|
78
|
+
out = StringIO.new
|
79
|
+
options = stub('options', :colour => false)
|
80
|
+
formatter = BaseTextFormatter.new(options,out)
|
81
|
+
formatter.stub!(:output_to_tty?).and_return(false)
|
82
|
+
|
83
|
+
ENV['RSPEC_COLOR'] = 'true'
|
84
|
+
|
85
|
+
formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "colorizes when autospec? is true even if colour? and output_to_tty? return false" do
|
89
|
+
out = StringIO.new
|
90
|
+
options = stub('options', :colour => true, :autospec => true)
|
91
|
+
formatter = BaseTextFormatter.new(options,out)
|
92
|
+
formatter.stub!(:output_to_tty?).and_return(false)
|
93
|
+
|
94
|
+
formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m"
|
95
|
+
end
|
96
|
+
|
97
|
+
after(:each) do
|
98
|
+
ENV['RSPEC_COLOR'] = @original_RSPEC_COLOR
|
99
|
+
end
|
100
|
+
end
|
20
101
|
end
|
21
102
|
end
|
22
103
|
end
|