newbamboo-evented-rspec 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -0
- data/History.txt +1263 -0
- data/License.txt +22 -0
- data/Manifest.txt +327 -0
- data/README.txt +57 -0
- data/Rakefile +104 -0
- data/TODO.txt +18 -0
- data/bin/autospec +4 -0
- data/bin/spec +4 -0
- data/examples/failing/README.txt +7 -0
- data/examples/failing/diffing_spec.rb +36 -0
- data/examples/failing/failing_autogenerated_docstrings_example.rb +19 -0
- data/examples/failing/failure_in_after.rb +10 -0
- data/examples/failing/failure_in_before.rb +10 -0
- data/examples/failing/mocking_example.rb +40 -0
- data/examples/failing/mocking_with_flexmock.rb +26 -0
- data/examples/failing/mocking_with_mocha.rb +25 -0
- data/examples/failing/mocking_with_rr.rb +27 -0
- data/examples/failing/partial_mock_example.rb +20 -0
- data/examples/failing/predicate_example.rb +34 -0
- data/examples/failing/raising_example.rb +47 -0
- data/examples/failing/spec_helper.rb +3 -0
- data/examples/failing/syntax_error_example.rb +7 -0
- data/examples/failing/team_spec.rb +44 -0
- data/examples/failing/timeout_behaviour.rb +7 -0
- data/examples/passing/autogenerated_docstrings_example.rb +25 -0
- data/examples/passing/before_and_after_example.rb +40 -0
- data/examples/passing/behave_as_example.rb +45 -0
- data/examples/passing/custom_expectation_matchers.rb +54 -0
- data/examples/passing/custom_formatter.rb +12 -0
- data/examples/passing/dynamic_spec.rb +9 -0
- data/examples/passing/file_accessor.rb +19 -0
- data/examples/passing/file_accessor_spec.rb +38 -0
- data/examples/passing/greeter_spec.rb +31 -0
- data/examples/passing/helper_method_example.rb +14 -0
- data/examples/passing/io_processor.rb +8 -0
- data/examples/passing/io_processor_spec.rb +21 -0
- data/examples/passing/legacy_spec.rb +11 -0
- data/examples/passing/mocking_example.rb +27 -0
- data/examples/passing/multi_threaded_example_group_runner.rb +26 -0
- data/examples/passing/nested_classes_example.rb +36 -0
- data/examples/passing/partial_mock_example.rb +29 -0
- data/examples/passing/pending_example.rb +20 -0
- data/examples/passing/predicate_example.rb +27 -0
- data/examples/passing/priority.txt +1 -0
- data/examples/passing/shared_example_group_example.rb +81 -0
- data/examples/passing/shared_stack_examples.rb +36 -0
- data/examples/passing/simple_matcher_example.rb +31 -0
- data/examples/passing/spec_helper.rb +3 -0
- data/examples/passing/stack.rb +36 -0
- data/examples/passing/stack_spec.rb +64 -0
- data/examples/passing/stack_spec_with_nested_example_groups.rb +67 -0
- data/examples/passing/stubbing_example.rb +69 -0
- data/examples/passing/yielding_example.rb +33 -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/features/example_groups/autogenerated_docstrings.feature +45 -0
- data/features/example_groups/example_group_with_should_methods.feature +17 -0
- data/features/example_groups/nested_groups.feature +17 -0
- data/features/example_groups/output.feature +20 -0
- data/features/interop/examples_and_tests_together.feature +31 -0
- data/features/interop/test_but_not_test_unit.feature +14 -0
- data/features/interop/test_case_with_should_methods.feature +17 -0
- data/features/mock_framework_integration/use_flexmock.feature +27 -0
- data/features/step_definitions/running_rspec.rb +54 -0
- data/features/support/env.rb +26 -0
- data/features/support/helpers/cmdline.rb +9 -0
- data/features/support/matchers/smart_match.rb +37 -0
- data/init.rb +9 -0
- data/lib/adapters/mock_frameworks/flexmock.rb +24 -0
- data/lib/adapters/mock_frameworks/mocha.rb +20 -0
- data/lib/adapters/mock_frameworks/rr.rb +22 -0
- data/lib/adapters/mock_frameworks/rspec.rb +20 -0
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/rspec.rb +47 -0
- data/lib/spec.rb +7 -0
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/dsl/main.rb +87 -0
- data/lib/spec/example.rb +187 -0
- data/lib/spec/example/before_and_after_hooks.rb +99 -0
- data/lib/spec/example/errors.rb +30 -0
- data/lib/spec/example/example_group.rb +26 -0
- data/lib/spec/example/example_group_factory.rb +98 -0
- data/lib/spec/example/example_group_methods.rb +376 -0
- data/lib/spec/example/example_matcher.rb +44 -0
- data/lib/spec/example/example_methods.rb +137 -0
- data/lib/spec/example/module_reopening_fix.rb +21 -0
- data/lib/spec/example/pending.rb +18 -0
- data/lib/spec/example/shared_example_group.rb +59 -0
- data/lib/spec/expectations.rb +60 -0
- data/lib/spec/expectations/differs/default.rb +66 -0
- data/lib/spec/expectations/errors.rb +12 -0
- data/lib/spec/expectations/extensions.rb +2 -0
- data/lib/spec/expectations/extensions/object.rb +63 -0
- data/lib/spec/expectations/extensions/string_and_symbol.rb +17 -0
- data/lib/spec/expectations/handler.rb +32 -0
- data/lib/spec/interop/test.rb +12 -0
- data/lib/spec/interop/test/unit/autorunner.rb +6 -0
- data/lib/spec/interop/test/unit/testcase.rb +73 -0
- data/lib/spec/interop/test/unit/testresult.rb +6 -0
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +34 -0
- data/lib/spec/interop/test/unit/ui/console/testrunner.rb +61 -0
- data/lib/spec/matchers.rb +141 -0
- data/lib/spec/matchers/be.rb +208 -0
- data/lib/spec/matchers/be_close.rb +21 -0
- data/lib/spec/matchers/change.rb +148 -0
- data/lib/spec/matchers/eql.rb +25 -0
- data/lib/spec/matchers/equal.rb +25 -0
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +16 -0
- data/lib/spec/matchers/generated_descriptions.rb +48 -0
- data/lib/spec/matchers/has.rb +15 -0
- data/lib/spec/matchers/have.rb +150 -0
- data/lib/spec/matchers/include.rb +80 -0
- data/lib/spec/matchers/match.rb +22 -0
- 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 +70 -0
- data/lib/spec/matchers/raise_error.rb +128 -0
- data/lib/spec/matchers/respond_to.rb +71 -0
- data/lib/spec/matchers/satisfy.rb +47 -0
- data/lib/spec/matchers/simple_matcher.rb +132 -0
- data/lib/spec/matchers/throw_symbol.rb +106 -0
- data/lib/spec/matchers/wrap_expectation.rb +55 -0
- data/lib/spec/mocks.rb +200 -0
- data/lib/spec/mocks/argument_expectation.rb +49 -0
- data/lib/spec/mocks/argument_matchers.rb +237 -0
- data/lib/spec/mocks/error_generator.rb +82 -0
- data/lib/spec/mocks/errors.rb +10 -0
- data/lib/spec/mocks/extensions.rb +1 -0
- data/lib/spec/mocks/extensions/object.rb +3 -0
- data/lib/spec/mocks/framework.rb +15 -0
- data/lib/spec/mocks/message_expectation.rb +331 -0
- data/lib/spec/mocks/methods.rb +51 -0
- data/lib/spec/mocks/mock.rb +55 -0
- data/lib/spec/mocks/order_group.rb +29 -0
- data/lib/spec/mocks/proxy.rb +230 -0
- data/lib/spec/mocks/space.rb +28 -0
- data/lib/spec/mocks/spec_methods.rb +55 -0
- data/lib/spec/rake/spectask.rb +225 -0
- data/lib/spec/rake/verify_rcov.rb +52 -0
- data/lib/spec/ruby.rb +9 -0
- data/lib/spec/runner.rb +88 -0
- data/lib/spec/runner/backtrace_tweaker.rb +58 -0
- data/lib/spec/runner/class_and_arguments_parser.rb +14 -0
- data/lib/spec/runner/command_line.rb +36 -0
- data/lib/spec/runner/configuration.rb +166 -0
- data/lib/spec/runner/drb_command_line.rb +20 -0
- data/lib/spec/runner/example_group_runner.rb +70 -0
- data/lib/spec/runner/formatter/base_formatter.rb +79 -0
- data/lib/spec/runner/formatter/base_text_formatter.rb +127 -0
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +27 -0
- data/lib/spec/runner/formatter/failing_examples_formatter.rb +20 -0
- data/lib/spec/runner/formatter/html_formatter.rb +340 -0
- data/lib/spec/runner/formatter/nested_text_formatter.rb +65 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +51 -0
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +34 -0
- data/lib/spec/runner/formatter/snippet_extractor.rb +52 -0
- data/lib/spec/runner/formatter/specdoc_formatter.rb +39 -0
- data/lib/spec/runner/formatter/text_mate_formatter.rb +16 -0
- data/lib/spec/runner/heckle_runner.rb +74 -0
- data/lib/spec/runner/heckle_runner_unsupported.rb +10 -0
- data/lib/spec/runner/option_parser.rb +204 -0
- data/lib/spec/runner/options.rb +320 -0
- data/lib/spec/runner/reporter.rb +167 -0
- data/lib/spec/runner/spec_parser.rb +73 -0
- data/lib/spec/version.rb +15 -0
- data/resources/rake/examples.rake +7 -0
- data/resources/rake/examples_with_rcov.rake +9 -0
- data/resources/rake/failing_examples_with_html.rake +9 -0
- data/resources/rake/verify_rcov.rake +7 -0
- data/resources/spec/example_group_with_should_methods.rb +12 -0
- data/resources/spec/simple_spec.rb +8 -0
- data/resources/test/spec_and_test_together.rb +57 -0
- data/resources/test/spec_including_test_but_not_unit.rb +11 -0
- data/resources/test/test_case_with_should_methods.rb +30 -0
- data/spec/README.jruby +15 -0
- data/spec/autotest/autotest_helper.rb +6 -0
- data/spec/autotest/autotest_matchers.rb +47 -0
- data/spec/autotest/discover_spec.rb +8 -0
- data/spec/autotest/failed_results_re_spec.rb +24 -0
- data/spec/autotest/rspec_spec.rb +114 -0
- data/spec/rspec_suite.rb +6 -0
- data/spec/ruby_forker.rb +13 -0
- data/spec/spec.opts +6 -0
- data/spec/spec/dsl/main_spec.rb +88 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +49 -0
- data/spec/spec/example/example_group_factory_spec.rb +224 -0
- data/spec/spec/example/example_group_methods_spec.rb +653 -0
- data/spec/spec/example/example_group_spec.rb +661 -0
- data/spec/spec/example/example_matcher_spec.rb +79 -0
- data/spec/spec/example/example_methods_spec.rb +204 -0
- data/spec/spec/example/helper_method_spec.rb +24 -0
- data/spec/spec/example/nested_example_group_spec.rb +71 -0
- data/spec/spec/example/pending_module_spec.rb +139 -0
- data/spec/spec/example/predicate_matcher_spec.rb +21 -0
- data/spec/spec/example/shared_example_group_spec.rb +257 -0
- data/spec/spec/example/subclassing_example_group_spec.rb +25 -0
- data/spec/spec/expectations/differs/default_spec.rb +127 -0
- data/spec/spec/expectations/extensions/object_spec.rb +45 -0
- data/spec/spec/expectations/fail_with_spec.rb +71 -0
- data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +10 -0
- data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +10 -0
- data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +10 -0
- data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +13 -0
- data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +10 -0
- data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +10 -0
- data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +10 -0
- data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +38 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +48 -0
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +18 -0
- data/spec/spec/interop/test/unit/testcase_spec.rb +49 -0
- data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +9 -0
- data/spec/spec/matchers/be_close_spec.rb +41 -0
- data/spec/spec/matchers/be_spec.rb +303 -0
- data/spec/spec/matchers/change_spec.rb +329 -0
- data/spec/spec/matchers/description_generation_spec.rb +172 -0
- data/spec/spec/matchers/eql_spec.rb +29 -0
- data/spec/spec/matchers/equal_spec.rb +29 -0
- data/spec/spec/matchers/exist_spec.rb +57 -0
- data/spec/spec/matchers/handler_spec.rb +111 -0
- data/spec/spec/matchers/has_spec.rb +63 -0
- data/spec/spec/matchers/have_spec.rb +399 -0
- data/spec/spec/matchers/include_spec.rb +88 -0
- data/spec/spec/matchers/match_array_spec.rb +83 -0
- data/spec/spec/matchers/match_spec.rb +37 -0
- data/spec/spec/matchers/matcher_methods_spec.rb +66 -0
- data/spec/spec/matchers/operator_matcher_spec.rb +191 -0
- data/spec/spec/matchers/raise_error_spec.rb +333 -0
- data/spec/spec/matchers/respond_to_spec.rb +116 -0
- data/spec/spec/matchers/satisfy_spec.rb +36 -0
- data/spec/spec/matchers/simple_matcher_spec.rb +93 -0
- data/spec/spec/matchers/throw_symbol_spec.rb +96 -0
- data/spec/spec/mocks/any_number_of_times_spec.rb +36 -0
- data/spec/spec/mocks/argument_expectation_spec.rb +23 -0
- data/spec/spec/mocks/at_least_spec.rb +97 -0
- data/spec/spec/mocks/at_most_spec.rb +93 -0
- data/spec/spec/mocks/bug_report_10260_spec.rb +8 -0
- data/spec/spec/mocks/bug_report_10263_spec.rb +24 -0
- data/spec/spec/mocks/bug_report_11545_spec.rb +32 -0
- data/spec/spec/mocks/bug_report_15719_spec.rb +30 -0
- data/spec/spec/mocks/bug_report_496.rb +19 -0
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/mocks/bug_report_7611_spec.rb +19 -0
- data/spec/spec/mocks/bug_report_7805_spec.rb +22 -0
- data/spec/spec/mocks/bug_report_8165_spec.rb +31 -0
- data/spec/spec/mocks/bug_report_8302_spec.rb +26 -0
- data/spec/spec/mocks/failing_argument_matchers_spec.rb +95 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +90 -0
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
- data/spec/spec/mocks/mock_ordering_spec.rb +84 -0
- data/spec/spec/mocks/mock_space_spec.rb +54 -0
- data/spec/spec/mocks/mock_spec.rb +579 -0
- data/spec/spec/mocks/multiple_return_value_spec.rb +113 -0
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +53 -0
- data/spec/spec/mocks/null_object_mock_spec.rb +54 -0
- data/spec/spec/mocks/once_counts_spec.rb +53 -0
- data/spec/spec/mocks/options_hash_spec.rb +35 -0
- data/spec/spec/mocks/partial_mock_spec.rb +149 -0
- data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +66 -0
- data/spec/spec/mocks/passing_argument_matchers_spec.rb +145 -0
- data/spec/spec/mocks/precise_counts_spec.rb +52 -0
- data/spec/spec/mocks/record_messages_spec.rb +26 -0
- data/spec/spec/mocks/stub_spec.rb +194 -0
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +14 -0
- data/spec/spec/mocks/twice_counts_spec.rb +67 -0
- data/spec/spec/package/bin_spec_spec.rb +22 -0
- data/spec/spec/runner/class_and_argument_parser_spec.rb +23 -0
- data/spec/spec/runner/command_line_spec.rb +141 -0
- data/spec/spec/runner/configuration_spec.rb +301 -0
- data/spec/spec/runner/drb_command_line_spec.rb +97 -0
- data/spec/spec/runner/empty_file.txt +0 -0
- data/spec/spec/runner/example_group_runner_spec.rb +33 -0
- data/spec/spec/runner/examples.txt +2 -0
- data/spec/spec/runner/failed.txt +3 -0
- data/spec/spec/runner/formatter/base_formatter_spec.rb +23 -0
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +23 -0
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +45 -0
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +33 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +365 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +387 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +371 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +381 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +379 -0
- 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 +62 -0
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +318 -0
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +65 -0
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +145 -0
- data/spec/spec/runner/formatter/snippet_extractor_spec.rb +18 -0
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +104 -0
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +159 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +365 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +373 -0
- 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/heckle_runner_spec.rb +78 -0
- data/spec/spec/runner/heckler_spec.rb +20 -0
- data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +45 -0
- data/spec/spec/runner/option_parser_spec.rb +396 -0
- data/spec/spec/runner/options_spec.rb +469 -0
- data/spec/spec/runner/output_one_time_fixture.rb +7 -0
- data/spec/spec/runner/output_one_time_fixture_runner.rb +8 -0
- data/spec/spec/runner/output_one_time_spec.rb +16 -0
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +62 -0
- data/spec/spec/runner/reporter_spec.rb +238 -0
- data/spec/spec/runner/resources/a_bar.rb +0 -0
- data/spec/spec/runner/resources/a_foo.rb +0 -0
- data/spec/spec/runner/resources/a_spec.rb +1 -0
- 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.opts +2 -0
- data/spec/spec/runner/spec_drb.opts +1 -0
- data/spec/spec/runner/spec_parser/spec_parser_fixture.rb +70 -0
- data/spec/spec/runner/spec_parser_spec.rb +91 -0
- data/spec/spec/runner/spec_spaced.opts +2 -0
- data/spec/spec/runner_spec.rb +11 -0
- data/spec/spec/spec_classes.rb +133 -0
- data/spec/spec/spec_spec.rb +21 -0
- data/spec/spec_helper.rb +107 -0
- metadata +388 -0
@@ -0,0 +1,469 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/resources/custom_example_group_runner'
|
3
|
+
|
4
|
+
module Spec
|
5
|
+
module Runner
|
6
|
+
describe Options do
|
7
|
+
before(:each) do
|
8
|
+
@err = StringIO.new('')
|
9
|
+
@out = StringIO.new('')
|
10
|
+
@options = Options.new(@err, @out)
|
11
|
+
|
12
|
+
before_suite_parts = []
|
13
|
+
after_suite_parts = []
|
14
|
+
@options.stub!(:before_suite_parts).and_return(before_suite_parts)
|
15
|
+
@options.stub!(:after_suite_parts).and_return(after_suite_parts)
|
16
|
+
end
|
17
|
+
|
18
|
+
after(:each) do
|
19
|
+
Spec::Expectations.differ = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#examples" do
|
23
|
+
it "should default to empty array" do
|
24
|
+
@options.examples.should == []
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#include_pattern" do
|
29
|
+
it "should default to '**/*_spec.rb'" do
|
30
|
+
@options.filename_pattern.should == "**/*_spec.rb"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#files_to_load" do
|
35
|
+
|
36
|
+
it "should load files not following pattern if named explicitly" do
|
37
|
+
file = File.expand_path(File.dirname(__FILE__) + "/resources/a_bar.rb")
|
38
|
+
@options.files << file
|
39
|
+
@options.files_to_load.should include(file)
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "with default --pattern" do
|
43
|
+
it "should load files named _spec.rb" do
|
44
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources/")
|
45
|
+
@options.files << dir
|
46
|
+
@options.files_to_load.should == ["#{dir}/a_spec.rb"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "with explicit pattern (single)" do
|
51
|
+
before(:each) do
|
52
|
+
@options.filename_pattern = "**/*_foo.rb"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should load files following pattern" do
|
56
|
+
file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
|
57
|
+
@options.files << file
|
58
|
+
@options.files_to_load.should include(file)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should load files in directories following pattern" do
|
62
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
63
|
+
@options.files << dir
|
64
|
+
@options.files_to_load.should include("#{dir}/a_foo.rb")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should not load files in directories not following pattern" do
|
68
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
69
|
+
@options.files << dir
|
70
|
+
@options.files_to_load.should_not include("#{dir}/a_bar.rb")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "with explicit pattern (comma,separated,values)" do
|
75
|
+
|
76
|
+
before(:each) do
|
77
|
+
@options.filename_pattern = "**/*_foo.rb,**/*_bar.rb"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should support comma separated values" do
|
81
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
82
|
+
@options.files << dir
|
83
|
+
@options.files_to_load.should include("#{dir}/a_foo.rb")
|
84
|
+
@options.files_to_load.should include("#{dir}/a_bar.rb")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should support comma separated values with spaces" do
|
88
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
89
|
+
@options.files << dir
|
90
|
+
@options.files_to_load.should include("#{dir}/a_foo.rb")
|
91
|
+
@options.files_to_load.should include("#{dir}/a_bar.rb")
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#backtrace_tweaker" do
|
99
|
+
it "should default to QuietBacktraceTweaker" do
|
100
|
+
@options.backtrace_tweaker.class.should == QuietBacktraceTweaker
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#dry_run" do
|
105
|
+
it "should default to false" do
|
106
|
+
@options.dry_run.should == false
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#context_lines" do
|
111
|
+
it "should default to 3" do
|
112
|
+
@options.context_lines.should == 3
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#parse_diff with nil" do
|
117
|
+
before(:each) do
|
118
|
+
@options.parse_diff nil
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should make diff_format unified" do
|
122
|
+
@options.diff_format.should == :unified
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should set Spec::Expectations.differ to be a default differ" do
|
126
|
+
Spec::Expectations.differ.class.should ==
|
127
|
+
::Spec::Expectations::Differs::Default
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "#parse_diff with 'unified'" do
|
132
|
+
before(:each) do
|
133
|
+
@options.parse_diff 'unified'
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should make diff_format unified and uses default differ_class" do
|
137
|
+
@options.diff_format.should == :unified
|
138
|
+
@options.differ_class.should equal(Spec::Expectations::Differs::Default)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should set Spec::Expectations.differ to be a default differ" do
|
142
|
+
Spec::Expectations.differ.class.should ==
|
143
|
+
::Spec::Expectations::Differs::Default
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "#parse_diff with 'context'" do
|
148
|
+
before(:each) do
|
149
|
+
@options.parse_diff 'context'
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should make diff_format context and uses default differ_class" do
|
153
|
+
@options.diff_format.should == :context
|
154
|
+
@options.differ_class.should == Spec::Expectations::Differs::Default
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should set Spec::Expectations.differ to be a default differ" do
|
158
|
+
Spec::Expectations.differ.class.should ==
|
159
|
+
::Spec::Expectations::Differs::Default
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#parse_diff with Custom::Differ" do
|
164
|
+
before(:each) do
|
165
|
+
@options.parse_diff 'Custom::Differ'
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should use custom differ_class" do
|
169
|
+
@options.diff_format.should == :custom
|
170
|
+
@options.differ_class.should == Custom::Differ
|
171
|
+
Spec::Expectations.differ.should be_instance_of(Custom::Differ)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should set Spec::Expectations.differ to be a default differ" do
|
175
|
+
Spec::Expectations.differ.class.should ==
|
176
|
+
::Custom::Differ
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe "#parse_diff with missing class name" do
|
181
|
+
it "should raise error" do
|
182
|
+
lambda { @options.parse_diff "Custom::MissingDiffer" }.should raise_error(NameError)
|
183
|
+
@err.string.should match(/Couldn't find differ class Custom::MissingDiffer/n)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "#parse_example" do
|
188
|
+
it "with argument thats not a file path, sets argument as the example" do
|
189
|
+
example = "something or other"
|
190
|
+
File.file?(example).should == false
|
191
|
+
@options.parse_example example
|
192
|
+
@options.examples.should eql(["something or other"])
|
193
|
+
end
|
194
|
+
|
195
|
+
it "with argument that is a file path, sets examples to contents of the file" do
|
196
|
+
example = "#{File.dirname(__FILE__)}/examples.txt"
|
197
|
+
File.should_receive(:file?).with(example).and_return(true)
|
198
|
+
file = StringIO.new("Sir, if you were my husband, I would poison your drink.\nMadam, if you were my wife, I would drink it.")
|
199
|
+
File.should_receive(:open).with(example).and_return(file)
|
200
|
+
|
201
|
+
@options.parse_example example
|
202
|
+
@options.examples.should eql([
|
203
|
+
"Sir, if you were my husband, I would poison your drink.",
|
204
|
+
"Madam, if you were my wife, I would drink it."
|
205
|
+
])
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "#examples_should_not_be_run" do
|
210
|
+
it "should cause #run_examples to return true and do nothing" do
|
211
|
+
@options.examples_should_not_be_run
|
212
|
+
ExampleGroupRunner.should_not_receive(:new)
|
213
|
+
|
214
|
+
@options.run_examples.should be_true
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe "#load_class" do
|
219
|
+
it "should raise error when not class name" do
|
220
|
+
lambda do
|
221
|
+
@options.__send__(:load_class, 'foo', 'fruit', '--food')
|
222
|
+
end.should raise_error('"foo" is not a valid class name')
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe "#reporter" do
|
227
|
+
it "returns a Reporter" do
|
228
|
+
@options.reporter.should be_instance_of(Reporter)
|
229
|
+
@options.reporter.options.should === @options
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "#number_of_examples" do
|
234
|
+
context "when --example is parsed" do
|
235
|
+
it "provides the number of examples parsed instead of the total number of examples collected" do
|
236
|
+
@example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
|
237
|
+
it "uses this example_group 1" do; end
|
238
|
+
it "uses this example_group 2" do; end
|
239
|
+
it "uses this example_group 3" do; end
|
240
|
+
end
|
241
|
+
@options.add_example_group @example_group
|
242
|
+
@options.parse_example("an example")
|
243
|
+
@options.number_of_examples.should == 1
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "#add_example_group affecting passed in example_group" do
|
249
|
+
it "runs all examples when options.examples is empty" do
|
250
|
+
example_1_has_run = false
|
251
|
+
example_2_has_run = false
|
252
|
+
@example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
|
253
|
+
it "runs 1" do
|
254
|
+
example_1_has_run = true
|
255
|
+
end
|
256
|
+
it "runs 2" do
|
257
|
+
example_2_has_run = true
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
@options.examples.clear
|
262
|
+
|
263
|
+
@options.add_example_group @example_group
|
264
|
+
@options.run_examples
|
265
|
+
example_1_has_run.should be_true
|
266
|
+
example_2_has_run.should be_true
|
267
|
+
end
|
268
|
+
|
269
|
+
it "keeps all example_definitions when options.examples is empty" do
|
270
|
+
example_1_has_run = false
|
271
|
+
example_2_has_run = false
|
272
|
+
@example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
|
273
|
+
it "runs 1" do
|
274
|
+
example_1_has_run = true
|
275
|
+
end
|
276
|
+
it "runs 2" do
|
277
|
+
example_2_has_run = true
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
@options.add_example_group @example_group
|
282
|
+
@options.run_examples
|
283
|
+
example_1_has_run.should be_true
|
284
|
+
example_2_has_run.should be_true
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
describe "#add_example_group affecting example_group" do
|
289
|
+
it "adds example_group when example_group has example_definitions and is not shared" do
|
290
|
+
@example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
|
291
|
+
it "uses this example_group" do
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
@options.number_of_examples.should == 0
|
296
|
+
@options.add_example_group @example_group
|
297
|
+
@options.number_of_examples.should == 1
|
298
|
+
@options.example_groups.length.should == 1
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
describe "#remove_example_group" do
|
303
|
+
it "should remove the ExampleGroup from the list of ExampleGroups" do
|
304
|
+
@example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
|
305
|
+
end
|
306
|
+
@options.add_example_group @example_group
|
307
|
+
@options.example_groups.should include(@example_group)
|
308
|
+
|
309
|
+
@options.remove_example_group @example_group
|
310
|
+
@options.example_groups.should_not include(@example_group)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
describe "#run_examples" do
|
315
|
+
describe "when not given a custom runner" do
|
316
|
+
it "should use the standard" do
|
317
|
+
runner = ::Spec::Runner::ExampleGroupRunner.new(@options)
|
318
|
+
::Spec::Runner::ExampleGroupRunner.should_receive(:new).
|
319
|
+
with(@options).
|
320
|
+
and_return(runner)
|
321
|
+
@options.user_input_for_runner = nil
|
322
|
+
|
323
|
+
@options.run_examples
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
describe "when given a custom runner" do
|
328
|
+
it "should use the custom runner" do
|
329
|
+
runner = Custom::ExampleGroupRunner.new(@options, nil)
|
330
|
+
Custom::ExampleGroupRunner.should_receive(:new).
|
331
|
+
with(@options, nil).
|
332
|
+
and_return(runner)
|
333
|
+
@options.user_input_for_runner = "Custom::ExampleGroupRunner"
|
334
|
+
|
335
|
+
@options.run_examples
|
336
|
+
end
|
337
|
+
|
338
|
+
it "should use the custom runner with extra options" do
|
339
|
+
runner = Custom::ExampleGroupRunner.new(@options, 'something')
|
340
|
+
Custom::ExampleGroupRunner.should_receive(:new).
|
341
|
+
with(@options, 'something').
|
342
|
+
and_return(runner)
|
343
|
+
@options.user_input_for_runner = "Custom::ExampleGroupRunner:something"
|
344
|
+
|
345
|
+
@options.run_examples
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe "when there are examples" do
|
350
|
+
before(:each) do
|
351
|
+
@example_group = Class.new(::Spec::Example::ExampleGroup)
|
352
|
+
@options.add_example_group @example_group
|
353
|
+
@options.formatters << Formatter::BaseTextFormatter.new(@options, @out)
|
354
|
+
end
|
355
|
+
|
356
|
+
it "runs the Examples and outputs the result" do
|
357
|
+
@options.run_examples
|
358
|
+
@out.string.should include("0 examples, 0 failures")
|
359
|
+
end
|
360
|
+
|
361
|
+
it "sets #examples_run? to true" do
|
362
|
+
@options.examples_run?.should be_false
|
363
|
+
@options.run_examples
|
364
|
+
@options.examples_run?.should be_true
|
365
|
+
end
|
366
|
+
|
367
|
+
describe "and the suite passes" do
|
368
|
+
before do
|
369
|
+
@example_group.should_receive(:run).and_return(true)
|
370
|
+
end
|
371
|
+
|
372
|
+
it "invokes after_suite_parts with true" do
|
373
|
+
success_result = nil
|
374
|
+
@options.after_suite_parts << lambda do |success|
|
375
|
+
success_result = success
|
376
|
+
end
|
377
|
+
|
378
|
+
@options.run_examples
|
379
|
+
success_result.should be_true
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
describe "and the suite fails" do
|
384
|
+
before(:each) do
|
385
|
+
@example_group.should_receive(:run).and_return(false)
|
386
|
+
end
|
387
|
+
|
388
|
+
it "invokes after_suite_parts with false" do
|
389
|
+
success_result = nil
|
390
|
+
@options.after_suite_parts << lambda do |success|
|
391
|
+
success_result = success
|
392
|
+
end
|
393
|
+
|
394
|
+
@options.run_examples
|
395
|
+
success_result.should be_false
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
describe "when using heckle runner" do
|
400
|
+
before(:each) do
|
401
|
+
@heckle_runner_mock = mock("HeckleRunner")
|
402
|
+
@options.heckle_runner = @heckle_runner_mock
|
403
|
+
end
|
404
|
+
|
405
|
+
it "should heckle" do
|
406
|
+
@heckle_runner_mock.should_receive(:heckle_with)
|
407
|
+
@options.run_examples
|
408
|
+
end
|
409
|
+
|
410
|
+
it "shouldn't heckle recursively" do
|
411
|
+
heckled = false
|
412
|
+
@heckle_runner_mock.should_receive(:heckle_with) {
|
413
|
+
heckled.should == false
|
414
|
+
heckled = true
|
415
|
+
@options.run_examples
|
416
|
+
}
|
417
|
+
@options.run_examples
|
418
|
+
end
|
419
|
+
|
420
|
+
it "shouldn't load spec files twice" do
|
421
|
+
example_runner = mock("ExampleGroupRunner")
|
422
|
+
example_runner_inside_heckle = mock("ExampleGroupRunner inside Heckle")
|
423
|
+
|
424
|
+
ExampleGroupRunner.should_receive(:new).twice.and_return(
|
425
|
+
example_runner, example_runner_inside_heckle
|
426
|
+
)
|
427
|
+
|
428
|
+
example_runner.stub!(:run)
|
429
|
+
example_runner.should_receive(:load_files)
|
430
|
+
@heckle_runner_mock.stub!(:heckle_with).and_return { @options.run_examples }
|
431
|
+
example_runner_inside_heckle.stub!(:run)
|
432
|
+
example_runner_inside_heckle.should_not_receive(:load_files)
|
433
|
+
|
434
|
+
@options.run_examples
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
describe "when there are no examples" do
|
440
|
+
before(:each) do
|
441
|
+
@options.formatters << Formatter::BaseTextFormatter.new(@options, @out)
|
442
|
+
end
|
443
|
+
|
444
|
+
it "does not run Examples and does not output a result" do
|
445
|
+
@options.run_examples
|
446
|
+
@out.string.should_not include("examples")
|
447
|
+
@out.string.should_not include("failures")
|
448
|
+
end
|
449
|
+
|
450
|
+
it "sets #examples_run? to false" do
|
451
|
+
@options.examples_run?.should be_false
|
452
|
+
@options.run_examples
|
453
|
+
@options.examples_run?.should be_false
|
454
|
+
end
|
455
|
+
|
456
|
+
it "invokes after_suite_parts with true" do
|
457
|
+
success_result = nil
|
458
|
+
@options.after_suite_parts << lambda do |success|
|
459
|
+
success_result = success
|
460
|
+
end
|
461
|
+
|
462
|
+
@options.run_examples
|
463
|
+
success_result.should be_true
|
464
|
+
end
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|