newbamboo-rspec 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +4 -0
- data/History.txt +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/dsl/main.rb +87 -0
- data/lib/spec/dsl.rb +1 -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/example.rb +187 -0
- data/lib/spec/expectations/differs/default.rb +66 -0
- data/lib/spec/expectations/errors.rb +12 -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/extensions.rb +2 -0
- data/lib/spec/expectations/handler.rb +32 -0
- data/lib/spec/expectations.rb +60 -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/interop/test.rb +12 -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/matchers.rb +141 -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/object.rb +3 -0
- data/lib/spec/mocks/extensions.rb +1 -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/mocks.rb +200 -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/backtrace_tweaker.rb +58 -0
- data/lib/spec/runner/class_and_arguments_parser.rb +14 -0
- data/lib/spec/runner/command_line.rb +35 -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/runner.rb +88 -0
- data/lib/spec/version.rb +15 -0
- data/lib/spec.rb +7 -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/rspec.gemspec +32 -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/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.opts +6 -0
- data/spec/spec_helper.rb +107 -0
- metadata +388 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
module Spec
|
|
2
|
+
module Runner
|
|
3
|
+
class Configuration
|
|
4
|
+
# Chooses what mock framework to use. Example:
|
|
5
|
+
#
|
|
6
|
+
# Spec::Runner.configure do |config|
|
|
7
|
+
# config.mock_with :rspec, :mocha, :flexmock, or :rr
|
|
8
|
+
# end
|
|
9
|
+
#
|
|
10
|
+
# To use any other mock framework, you'll have to provide your own
|
|
11
|
+
# adapter. This is simply a module that responds to the following
|
|
12
|
+
# methods:
|
|
13
|
+
#
|
|
14
|
+
# setup_mocks_for_rspec
|
|
15
|
+
# verify_mocks_for_rspec
|
|
16
|
+
# teardown_mocks_for_rspec.
|
|
17
|
+
#
|
|
18
|
+
# These are your hooks into the lifecycle of a given example. RSpec will
|
|
19
|
+
# call setup_mocks_for_rspec before running anything else in each
|
|
20
|
+
# Example. After executing the #after methods, RSpec will then call
|
|
21
|
+
# verify_mocks_for_rspec and teardown_mocks_for_rspec (this is
|
|
22
|
+
# guaranteed to run even if there are failures in
|
|
23
|
+
# verify_mocks_for_rspec).
|
|
24
|
+
#
|
|
25
|
+
# Once you've defined this module, you can pass that to mock_with:
|
|
26
|
+
#
|
|
27
|
+
# Spec::Runner.configure do |config|
|
|
28
|
+
# config.mock_with MyMockFrameworkAdapter
|
|
29
|
+
# end
|
|
30
|
+
#
|
|
31
|
+
def mock_with(mock_framework)
|
|
32
|
+
@mock_framework = case mock_framework
|
|
33
|
+
when Symbol
|
|
34
|
+
mock_framework_path(mock_framework.to_s)
|
|
35
|
+
else
|
|
36
|
+
mock_framework
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def mock_framework # :nodoc:
|
|
41
|
+
@mock_framework ||= mock_framework_path("rspec")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# :call-seq:
|
|
45
|
+
# include(Some::Helpers)
|
|
46
|
+
# include(Some::Helpers, More::Helpers)
|
|
47
|
+
# include(My::Helpers, :type => :key)
|
|
48
|
+
#
|
|
49
|
+
# Declares modules to be included in multiple example groups
|
|
50
|
+
# (<tt>describe</tt> blocks). With no <tt>:type</tt>, the modules listed
|
|
51
|
+
# will be included in all example groups.
|
|
52
|
+
#
|
|
53
|
+
# Use <tt>:type</tt> to restrict
|
|
54
|
+
# the inclusion to a subset of example groups. The value assigned to
|
|
55
|
+
# <tt>:type</tt> should be a key that maps to a class that is either a
|
|
56
|
+
# subclass of Spec::Example::ExampleGroup or extends
|
|
57
|
+
# Spec::Example::ExampleGroupMethods and includes
|
|
58
|
+
# Spec::Example::ExampleMethods.
|
|
59
|
+
#
|
|
60
|
+
# For example, the rspec-rails gem/plugin extends Test::Unit::TestCase
|
|
61
|
+
# with Spec::Example::ExampleGroupMethods and includes
|
|
62
|
+
# Spec::Example::ExampleMethods in it. So if you have a module of helper
|
|
63
|
+
# methods for controller examples, you could do this:
|
|
64
|
+
#
|
|
65
|
+
# config.include(ControllerExampleHelpers, :type => :controller)
|
|
66
|
+
#
|
|
67
|
+
# Only example groups that have that type will get the modules included:
|
|
68
|
+
#
|
|
69
|
+
# describe Account, :type => :model do
|
|
70
|
+
# # Will *not* include ControllerExampleHelpers
|
|
71
|
+
# end
|
|
72
|
+
#
|
|
73
|
+
# describe AccountsController, :type => :controller do
|
|
74
|
+
# # *Will* include ControllerExampleHelpers
|
|
75
|
+
# end
|
|
76
|
+
#
|
|
77
|
+
def include(*args)
|
|
78
|
+
include_or_extend(:include, *args)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# :call-seq:
|
|
82
|
+
# extend(Some::Helpers)
|
|
83
|
+
# extend(Some::Helpers, More::Helpers)
|
|
84
|
+
# extend(My::Helpers, :type => :key)
|
|
85
|
+
#
|
|
86
|
+
# Works just like #include, but extends the example groups
|
|
87
|
+
# with the modules rather than including them.
|
|
88
|
+
def extend(*args)
|
|
89
|
+
include_or_extend(:extend, *args)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Defines global predicate matchers. Example:
|
|
93
|
+
#
|
|
94
|
+
# config.predicate_matchers[:swim] = :can_swim?
|
|
95
|
+
#
|
|
96
|
+
# This makes it possible to say:
|
|
97
|
+
#
|
|
98
|
+
# person.should swim # passes if person.can_swim? returns true
|
|
99
|
+
#
|
|
100
|
+
def predicate_matchers
|
|
101
|
+
@predicate_matchers ||= {}
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Prepends a global <tt>before</tt> block to all example groups.
|
|
105
|
+
# See #append_before for filtering semantics.
|
|
106
|
+
def prepend_before(*args, &proc)
|
|
107
|
+
add_callback(:prepend_before, *args, &proc)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Appends a global <tt>before</tt> block to all example groups.
|
|
111
|
+
#
|
|
112
|
+
# If you want to restrict the block to a subset of all the example
|
|
113
|
+
# groups then specify this in a Hash as the last argument:
|
|
114
|
+
#
|
|
115
|
+
# config.prepend_before(:all, :type => :farm)
|
|
116
|
+
#
|
|
117
|
+
# or
|
|
118
|
+
#
|
|
119
|
+
# config.prepend_before(:type => :farm)
|
|
120
|
+
#
|
|
121
|
+
def append_before(*args, &proc)
|
|
122
|
+
add_callback(:append_before, *args, &proc)
|
|
123
|
+
end
|
|
124
|
+
alias_method :before, :append_before
|
|
125
|
+
|
|
126
|
+
# Prepends a global <tt>after</tt> block to all example groups.
|
|
127
|
+
# See #append_before for filtering semantics.
|
|
128
|
+
def prepend_after(*args, &proc)
|
|
129
|
+
add_callback(:prepend_after, *args, &proc)
|
|
130
|
+
end
|
|
131
|
+
alias_method :after, :prepend_after
|
|
132
|
+
|
|
133
|
+
# Appends a global <tt>after</tt> block to all example groups.
|
|
134
|
+
# See #append_before for filtering semantics.
|
|
135
|
+
def append_after(*args, &proc)
|
|
136
|
+
add_callback(:append_after, *args, &proc)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
private
|
|
140
|
+
|
|
141
|
+
def include_or_extend(action, *args)
|
|
142
|
+
modules, options = Spec::Example.args_and_options(*args)
|
|
143
|
+
[get_type_from_options(options)].flatten.each do |required_example_group|
|
|
144
|
+
required_example_group = required_example_group.to_sym if required_example_group
|
|
145
|
+
modules.each do |mod|
|
|
146
|
+
Spec::Example::ExampleGroupFactory.get(required_example_group).__send__(action, mod)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def add_callback(sym, *args, &proc)
|
|
152
|
+
scope, options = Spec::Example.scope_and_options(*args)
|
|
153
|
+
example_group = Spec::Example::ExampleGroupFactory.get(get_type_from_options(options))
|
|
154
|
+
example_group.__send__(sym, scope, &proc)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def get_type_from_options(options)
|
|
158
|
+
options[:type] || options[:behaviour_type]
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def mock_framework_path(framework_name)
|
|
162
|
+
File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "adapters", "mock_frameworks", framework_name))
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "drb/drb"
|
|
2
|
+
|
|
3
|
+
module Spec
|
|
4
|
+
module Runner
|
|
5
|
+
# Facade to run specs by connecting to a DRB server
|
|
6
|
+
class DrbCommandLine
|
|
7
|
+
# Runs specs on a DRB server. Note that this API is similar to that of
|
|
8
|
+
# CommandLine - making it possible for clients to use both interchangeably.
|
|
9
|
+
def self.run(options)
|
|
10
|
+
begin
|
|
11
|
+
DRb.start_service
|
|
12
|
+
spec_server = DRbObject.new_with_uri("druby://127.0.0.1:8989")
|
|
13
|
+
spec_server.run(options.argv, options.error_stream, options.output_stream)
|
|
14
|
+
rescue DRb::DRbConnError => e
|
|
15
|
+
options.error_stream.puts "No server is running"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Spec
|
|
2
|
+
module Runner
|
|
3
|
+
class ExampleGroupRunner
|
|
4
|
+
def initialize(options)
|
|
5
|
+
@options = options
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def load_files(files)
|
|
9
|
+
# It's important that loading files (or choosing not to) stays the
|
|
10
|
+
# responsibility of the ExampleGroupRunner. Some implementations (like)
|
|
11
|
+
# the one using DRb may choose *not* to load files, but instead tell
|
|
12
|
+
# someone else to do it over the wire.
|
|
13
|
+
$KCODE = 'u' if RUBY_VERSION < '1.9'
|
|
14
|
+
files.each do |file|
|
|
15
|
+
load file
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
prepare
|
|
21
|
+
success = true
|
|
22
|
+
example_groups.each do |example_group|
|
|
23
|
+
success = success & example_group.run(@options)
|
|
24
|
+
end
|
|
25
|
+
return success
|
|
26
|
+
ensure
|
|
27
|
+
finish
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
def prepare
|
|
32
|
+
reporter.start(number_of_examples)
|
|
33
|
+
example_groups.reverse! if reverse
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def finish
|
|
37
|
+
reporter.end
|
|
38
|
+
reporter.dump
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def reporter
|
|
42
|
+
@options.reporter
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def reverse
|
|
46
|
+
@options.reverse
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def example_groups
|
|
50
|
+
@options.example_groups
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def number_of_examples
|
|
54
|
+
@options.number_of_examples
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class BehaviourRunner < ExampleGroupRunner
|
|
59
|
+
def initialize(options)
|
|
60
|
+
Kernel.warn <<-WARNING
|
|
61
|
+
DEPRECATED: The BeheviourRunner class is deprecated and will
|
|
62
|
+
be removed from rspec-1.2.
|
|
63
|
+
|
|
64
|
+
Use ExampleGroupRunner instead.
|
|
65
|
+
WARNING
|
|
66
|
+
super
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module Spec
|
|
2
|
+
module Runner
|
|
3
|
+
module Formatter
|
|
4
|
+
# Baseclass for formatters that implements all required methods as no-ops.
|
|
5
|
+
class BaseFormatter
|
|
6
|
+
attr_accessor :example_group, :options, :where
|
|
7
|
+
def initialize(options, where)
|
|
8
|
+
@options = options
|
|
9
|
+
@where = where
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# This method is invoked before any examples are run, right after
|
|
13
|
+
# they have all been collected. This can be useful for special
|
|
14
|
+
# formatters that need to provide progress on feedback (graphical ones)
|
|
15
|
+
#
|
|
16
|
+
# This method will only be invoked once, and the next one to be invoked
|
|
17
|
+
# is #add_example_group
|
|
18
|
+
def start(example_count)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# This method is invoked at the beginning of the execution of each example_group.
|
|
22
|
+
# +example_group+ is the example_group.
|
|
23
|
+
#
|
|
24
|
+
# The next method to be invoked after this is #example_failed or #example_finished
|
|
25
|
+
def add_example_group(example_group)
|
|
26
|
+
@example_group = example_group
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# This method is invoked when an +example+ starts.
|
|
30
|
+
def example_started(example)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# This method is invoked when an +example+ passes.
|
|
34
|
+
def example_passed(example)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# This method is invoked when an +example+ fails, i.e. an exception occurred
|
|
38
|
+
# inside it (such as a failed should or other exception). +counter+ is the
|
|
39
|
+
# sequence number of the failure (starting at 1) and +failure+ is the associated
|
|
40
|
+
# Failure object.
|
|
41
|
+
def example_failed(example, counter, failure)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# This method is invoked when an example is not yet implemented (i.e. has not
|
|
45
|
+
# been provided a block), or when an ExamplePendingError is raised.
|
|
46
|
+
# +message+ is the message from the ExamplePendingError, if it exists, or the
|
|
47
|
+
# default value of "Not Yet Implemented"
|
|
48
|
+
# +pending_caller+ is the file and line number of the spec which
|
|
49
|
+
# has called the pending method
|
|
50
|
+
def example_pending(example, message, pending_caller)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# This method is invoked after all of the examples have executed. The next method
|
|
54
|
+
# to be invoked after this one is #dump_failure (once for each failed example),
|
|
55
|
+
def start_dump
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Dumps detailed information about an example failure.
|
|
59
|
+
# This method is invoked for each failed example after all examples have run. +counter+ is the sequence number
|
|
60
|
+
# of the associated example. +failure+ is a Failure object, which contains detailed
|
|
61
|
+
# information about the failure.
|
|
62
|
+
def dump_failure(counter, failure)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# This method is invoked after the dumping of examples and failures.
|
|
66
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# This gets invoked after the summary if option is set to do so.
|
|
70
|
+
def dump_pending
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.
|
|
74
|
+
def close
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require 'spec/runner/formatter/base_formatter'
|
|
2
|
+
|
|
3
|
+
module Spec
|
|
4
|
+
module Runner
|
|
5
|
+
module Formatter
|
|
6
|
+
# Baseclass for text-based formatters. Can in fact be used for
|
|
7
|
+
# non-text based ones too - just ignore the +output+ constructor
|
|
8
|
+
# argument.
|
|
9
|
+
class BaseTextFormatter < BaseFormatter
|
|
10
|
+
attr_reader :output, :pending_examples
|
|
11
|
+
# Creates a new instance that will write to +where+. If +where+ is a
|
|
12
|
+
# String, output will be written to the File with that name, otherwise
|
|
13
|
+
# +where+ is exected to be an IO (or an object that responds to #puts and #write).
|
|
14
|
+
def initialize(options, where)
|
|
15
|
+
super
|
|
16
|
+
if where.is_a?(String)
|
|
17
|
+
FileUtils.mkdir_p(File.dirname(where))
|
|
18
|
+
@output = File.open(where, 'w')
|
|
19
|
+
else
|
|
20
|
+
@output = where
|
|
21
|
+
end
|
|
22
|
+
@pending_examples = []
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def example_pending(example, message, pending_caller)
|
|
26
|
+
@pending_examples << [example.full_description, message, pending_caller]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def dump_failure(counter, failure)
|
|
30
|
+
@output.puts
|
|
31
|
+
@output.puts "#{counter.to_s})"
|
|
32
|
+
@output.puts colourise("#{failure.header}\n#{failure.exception.message}", failure)
|
|
33
|
+
@output.puts format_backtrace(failure.exception.backtrace)
|
|
34
|
+
@output.flush
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def colourise(s, failure)
|
|
38
|
+
if(failure.expectation_not_met?)
|
|
39
|
+
red(s)
|
|
40
|
+
elsif(failure.pending_fixed?)
|
|
41
|
+
blue(s)
|
|
42
|
+
else
|
|
43
|
+
magenta(s)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
|
48
|
+
return if dry_run?
|
|
49
|
+
@output.puts
|
|
50
|
+
@output.puts "Finished in #{duration} seconds"
|
|
51
|
+
@output.puts
|
|
52
|
+
|
|
53
|
+
summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
|
|
54
|
+
summary << ", #{pending_count} pending" if pending_count > 0
|
|
55
|
+
|
|
56
|
+
if failure_count == 0
|
|
57
|
+
if pending_count > 0
|
|
58
|
+
@output.puts yellow(summary)
|
|
59
|
+
else
|
|
60
|
+
@output.puts green(summary)
|
|
61
|
+
end
|
|
62
|
+
else
|
|
63
|
+
@output.puts red(summary)
|
|
64
|
+
end
|
|
65
|
+
@output.flush
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def dump_pending
|
|
69
|
+
unless @pending_examples.empty?
|
|
70
|
+
@output.puts
|
|
71
|
+
@output.puts "Pending:"
|
|
72
|
+
@pending_examples.each do |pending_example|
|
|
73
|
+
@output.puts "\n#{pending_example[0]} (#{pending_example[1]})"
|
|
74
|
+
@output.puts "#{pending_example[2]}\n"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
@output.flush
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def close
|
|
81
|
+
if IO === @output && @output != $stdout
|
|
82
|
+
@output.close
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def format_backtrace(backtrace)
|
|
87
|
+
return "" if backtrace.nil?
|
|
88
|
+
backtrace.map { |line| backtrace_line(line) }.join("\n")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
protected
|
|
92
|
+
|
|
93
|
+
def colour?
|
|
94
|
+
@options.colour ? true : false
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def dry_run?
|
|
98
|
+
@options.dry_run ? true : false
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def backtrace_line(line)
|
|
102
|
+
line.sub(/\A([^:]+:\d+)$/, '\\1:')
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def colour(text, colour_code)
|
|
106
|
+
return text unless colour? && output_to_tty?
|
|
107
|
+
"#{colour_code}#{text}\e[0m"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def output_to_tty?
|
|
111
|
+
begin
|
|
112
|
+
@output.tty? || ENV.has_key?("AUTOTEST")
|
|
113
|
+
rescue NoMethodError
|
|
114
|
+
false
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def green(text); colour(text, "\e[32m"); end
|
|
119
|
+
def red(text); colour(text, "\e[31m"); end
|
|
120
|
+
def magenta(text); colour(text, "\e[35m"); end
|
|
121
|
+
def yellow(text); colour(text, "\e[33m"); end
|
|
122
|
+
def blue(text); colour(text, "\e[34m"); end
|
|
123
|
+
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec/runner/formatter/base_text_formatter'
|
|
2
|
+
|
|
3
|
+
module Spec
|
|
4
|
+
module Runner
|
|
5
|
+
module Formatter
|
|
6
|
+
class FailingExampleGroupsFormatter < BaseTextFormatter
|
|
7
|
+
def example_failed(example, counter, failure)
|
|
8
|
+
if @example_group
|
|
9
|
+
description_parts = @example_group.description_parts.collect do |description|
|
|
10
|
+
description =~ /(.*) \(druby.*\)$/ ? $1 : description
|
|
11
|
+
end
|
|
12
|
+
@output.puts ::Spec::Example::ExampleGroupMethods.description_text(*description_parts)
|
|
13
|
+
|
|
14
|
+
@output.flush
|
|
15
|
+
@example_group = nil
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def dump_failure(counter, failure)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec/runner/formatter/base_text_formatter'
|
|
2
|
+
|
|
3
|
+
module Spec
|
|
4
|
+
module Runner
|
|
5
|
+
module Formatter
|
|
6
|
+
class FailingExamplesFormatter < BaseTextFormatter
|
|
7
|
+
def example_failed(example, counter, failure)
|
|
8
|
+
@output.puts "#{example_group.description} #{example.description}"
|
|
9
|
+
@output.flush
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def dump_failure(counter, failure)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|