rspec 1.0.0 → 1.3.1
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/.document +7 -0
- data/History.rdoc +1546 -0
- data/{MIT-LICENSE → License.txt} +3 -1
- data/Manifest.txt +384 -0
- data/README.rdoc +41 -0
- data/Rakefile +94 -229
- data/Ruby1.9.rdoc +31 -0
- data/TODO.txt +17 -0
- data/Upgrade.rdoc +260 -0
- data/bin/autospec +4 -0
- data/bin/spec +5 -3
- data/cucumber.yml +5 -0
- data/examples/failing/README.txt +11 -0
- data/examples/failing/diffing_spec.rb +36 -0
- data/examples/failing/failing_implicit_docstrings_example.rb +17 -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 +38 -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 +18 -0
- data/examples/failing/pending_example.rb +7 -0
- data/examples/failing/predicate_example.rb +32 -0
- data/examples/failing/raising_example.rb +47 -0
- data/examples/failing/syntax_error_example.rb +7 -0
- data/examples/failing/team_spec.rb +41 -0
- data/examples/failing/timeout_behaviour.rb +5 -0
- data/examples/{custom_formatter.rb → passing/custom_formatter.rb} +1 -1
- data/examples/passing/dynamic_spec.rb +7 -0
- data/examples/{file_accessor.rb → passing/file_accessor.rb} +18 -18
- data/examples/{file_accessor_spec.rb → passing/file_accessor_spec.rb} +37 -38
- data/examples/passing/filtered_formatter.rb +17 -0
- data/examples/passing/filtered_formatter_example.rb +31 -0
- data/examples/{greeter_spec.rb → passing/greeter_spec.rb} +1 -1
- data/examples/passing/helper_method_example.rb +12 -0
- data/examples/passing/implicit_docstrings_example.rb +16 -0
- data/examples/{io_processor.rb → passing/io_processor.rb} +8 -8
- data/examples/{io_processor_spec.rb → passing/io_processor_spec.rb} +2 -3
- data/examples/{mocking_example.rb → passing/mocking_example.rb} +0 -2
- data/examples/{multi_threaded_behaviour_runner.rb → passing/multi_threaded_example_group_runner.rb} +10 -9
- data/examples/passing/nested_classes_example.rb +35 -0
- data/examples/passing/options_example.rb +29 -0
- data/examples/passing/options_formatter.rb +20 -0
- data/examples/{partial_mock_example.rb → passing/partial_mock_example.rb} +2 -3
- data/examples/passing/pending_example.rb +18 -0
- data/examples/{predicate_example.rb → passing/predicate_example.rb} +1 -3
- data/examples/{shared_behaviours_example.rb → passing/shared_example_group_example.rb} +15 -11
- data/examples/passing/shared_stack_examples.rb +36 -0
- data/examples/passing/simple_matcher_example.rb +29 -0
- data/examples/{stack.rb → passing/stack.rb} +1 -1
- data/examples/{stack_spec.rb → passing/stack_spec.rb} +6 -40
- data/examples/passing/stack_spec_with_nested_example_groups.rb +66 -0
- data/examples/{stubbing_example.rb → passing/stubbing_example.rb} +1 -3
- data/examples/passing/yielding_example.rb +31 -0
- data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +85 -0
- data/features/before_and_after_blocks/before_and_after_blocks.feature +167 -0
- data/features/command_line/line_number_option.feature +56 -0
- data/features/command_line/line_number_option_with_example_with_no_name.feature +22 -0
- data/features/example_groups/define_example_attribute.feature +41 -0
- data/features/example_groups/example_group_with_should_methods.feature +29 -0
- data/features/example_groups/implicit_docstrings.feature +59 -0
- data/features/example_groups/nested_groups.feature +32 -0
- data/features/expectations/customized_message.feature +54 -0
- data/features/expectations/expect_change.feature +65 -0
- data/features/expectations/expect_error.feature +44 -0
- data/features/extensions/custom_example_group.feature +19 -0
- data/features/formatters/custom_formatter.feature +30 -0
- data/features/formatters/nested_formatter.feature +32 -0
- data/features/interop/cucumber_stubs_dont_leak.feature +11 -0
- data/features/interop/examples_and_tests_together.feature +84 -0
- data/features/interop/rspec_output.feature +25 -0
- data/features/interop/test_but_not_test_unit.feature +26 -0
- data/features/interop/test_case_with_should_methods.feature +46 -0
- data/features/load_paths/add_lib_to_load_path.feature +20 -0
- data/features/load_paths/add_spec_to_load_path.feature +20 -0
- data/features/matchers/define_diffable_matcher.feature +26 -0
- data/features/matchers/define_matcher.feature +179 -0
- data/features/matchers/define_matcher_outside_rspec.feature +38 -0
- data/features/matchers/define_matcher_with_fluent_interface.feature +48 -0
- data/features/matchers/define_wrapped_matcher.feature +56 -0
- data/features/matchers/match_unless_raises.feature +60 -0
- data/features/matchers/match_unless_raises_unexpected_error.feature +39 -0
- data/features/mock_framework_integration/use_flexmock.feature +27 -0
- data/features/mock_framework_integration/use_mocha.feature +27 -0
- data/features/mock_framework_integration/use_rr.feature +27 -0
- data/features/mocks/block_local_expectations.feature +62 -0
- data/features/mocks/mix_stubs_and_mocks.feature +22 -0
- data/features/mocks/stub_implementation.feature +26 -0
- data/features/pending/pending_examples.feature +81 -0
- data/features/runner/specify_line_number.feature +32 -0
- data/features/spec_helper/spec_helper.feature +25 -0
- data/features/step_definitions/running_rspec_steps.rb +52 -0
- data/features/step_definitions/stubbing_steps.rb +16 -0
- data/features/subject/explicit_subject.feature +31 -0
- data/features/subject/implicit_subject.feature +43 -0
- data/features/support/env.rb +83 -0
- data/features/support/matchers/smart_match.rb +31 -0
- data/geminstaller.yml +29 -0
- data/init.rb +9 -0
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/rspec.rb +54 -0
- data/lib/spec/adapters/mock_frameworks/flexmock.rb +24 -0
- data/{plugins → lib/spec/adapters}/mock_frameworks/mocha.rb +8 -4
- data/lib/spec/adapters/mock_frameworks/rr.rb +22 -0
- data/lib/spec/adapters/mock_frameworks/rspec.rb +21 -0
- data/lib/spec/autorun.rb +3 -0
- data/lib/spec/deprecation.rb +41 -0
- data/lib/spec/dsl/main.rb +93 -0
- data/lib/spec/dsl.rb +1 -10
- data/lib/spec/example/args_and_options.rb +27 -0
- data/lib/spec/example/before_and_after_hooks.rb +93 -0
- data/lib/spec/example/errors.rb +25 -0
- data/lib/spec/example/example_group.rb +10 -0
- data/lib/spec/example/example_group_factory.rb +82 -0
- data/lib/spec/example/example_group_hierarchy.rb +53 -0
- data/lib/spec/example/example_group_methods.rb +287 -0
- data/lib/spec/example/example_group_proxy.rb +61 -0
- data/lib/spec/example/example_matcher.rb +43 -0
- data/lib/spec/example/example_methods.rb +152 -0
- data/lib/spec/example/example_proxy.rb +41 -0
- data/lib/spec/example/module_reopening_fix.rb +43 -0
- data/lib/spec/example/pending.rb +18 -0
- data/lib/spec/example/predicate_matchers.rb +46 -0
- data/lib/spec/example/shared_example_group.rb +59 -0
- data/lib/spec/example/subject.rb +114 -0
- data/lib/spec/example.rb +164 -0
- data/lib/spec/expectations/errors.rb +7 -1
- data/lib/spec/expectations/extensions/kernel.rb +52 -0
- data/lib/spec/expectations/extensions.rb +1 -2
- data/lib/spec/expectations/fail_with.rb +45 -0
- data/lib/spec/expectations/handler.rb +37 -30
- data/lib/spec/expectations.rb +2 -23
- data/lib/spec/extensions/instance_exec.rb +31 -0
- data/lib/spec/interop/test/unit/autorunner.rb +6 -0
- data/lib/spec/interop/test/unit/testcase.rb +56 -0
- data/lib/spec/interop/test/unit/testresult.rb +6 -0
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +36 -0
- data/lib/spec/interop/test/unit/ui/console/testrunner.rb +61 -0
- data/lib/spec/interop/test.rb +44 -0
- data/lib/spec/matchers/be.rb +183 -140
- data/lib/spec/matchers/be_close.rb +18 -23
- data/lib/spec/matchers/be_instance_of.rb +26 -0
- data/lib/spec/matchers/be_kind_of.rb +26 -0
- data/lib/spec/matchers/change.rb +72 -41
- data/lib/spec/matchers/compatibility.rb +14 -0
- data/lib/spec/matchers/dsl.rb +20 -0
- data/lib/spec/matchers/eql.rb +25 -26
- data/lib/spec/matchers/equal.rb +35 -25
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +16 -0
- data/lib/spec/matchers/generated_descriptions.rb +36 -0
- data/lib/spec/matchers/has.rb +17 -26
- data/lib/spec/matchers/have.rb +36 -24
- data/lib/spec/matchers/include.rb +22 -48
- data/lib/spec/matchers/match.rb +11 -31
- data/lib/spec/matchers/match_array.rb +71 -0
- data/lib/spec/matchers/matcher.rb +132 -0
- data/lib/spec/matchers/method_missing.rb +9 -0
- data/lib/spec/matchers/operator_matcher.rb +55 -44
- data/lib/spec/matchers/pretty.rb +37 -0
- data/lib/spec/matchers/raise_exception.rb +131 -0
- data/lib/spec/matchers/respond_to.rb +35 -9
- data/lib/spec/matchers/satisfy.rb +2 -2
- data/lib/spec/matchers/simple_matcher.rb +134 -0
- data/lib/spec/matchers/throw_symbol.rb +56 -31
- data/lib/spec/matchers/wrap_expectation.rb +55 -0
- data/lib/spec/matchers.rb +104 -48
- data/lib/spec/mocks/argument_expectation.rb +28 -112
- data/lib/spec/mocks/argument_matchers.rb +237 -0
- data/lib/spec/mocks/error_generator.rb +20 -13
- data/lib/spec/mocks/errors.rb +1 -1
- data/lib/spec/mocks/example_methods.rb +69 -0
- data/lib/spec/mocks/extensions.rb +1 -0
- data/lib/spec/mocks/framework.rb +15 -0
- data/lib/spec/mocks/message_expectation.rb +206 -93
- data/lib/spec/mocks/methods.rb +66 -7
- data/lib/spec/mocks/mock.rb +53 -11
- data/lib/spec/mocks/proxy.rb +160 -55
- data/lib/spec/mocks/space.rb +2 -2
- data/lib/spec/mocks.rb +14 -23
- data/lib/spec/rake/spectask.rb +108 -53
- data/lib/spec/rake/verify_rcov.rb +4 -4
- data/lib/spec/ruby.rb +9 -0
- data/lib/spec/runner/backtrace_tweaker.rb +45 -23
- data/lib/spec/runner/class_and_arguments_parser.rb +14 -0
- data/lib/spec/runner/command_line.rb +7 -14
- data/lib/spec/runner/configuration.rb +202 -0
- data/lib/spec/runner/differs/default.rb +93 -0
- data/lib/spec/runner/differs/load-diff-lcs.rb +12 -0
- data/lib/spec/runner/drb_command_line.rb +18 -7
- data/lib/spec/runner/example_group_runner.rb +58 -0
- data/lib/spec/runner/extensions/kernel.rb +5 -46
- data/lib/spec/runner/formatter/base_formatter.rb +97 -26
- data/lib/spec/runner/formatter/base_text_formatter.rb +79 -39
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +25 -0
- data/lib/spec/runner/formatter/failing_examples_formatter.rb +6 -8
- data/lib/spec/runner/formatter/html_formatter.rb +101 -75
- data/lib/spec/runner/formatter/nested_text_formatter.rb +50 -0
- data/lib/spec/runner/formatter/no_op_method_missing.rb +21 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +47 -0
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +11 -8
- data/lib/spec/runner/formatter/silent_formatter.rb +10 -0
- data/lib/spec/runner/formatter/snippet_extractor.rb +2 -2
- data/lib/spec/runner/formatter/specdoc_formatter.rb +20 -15
- data/lib/spec/runner/formatter/text_mate_formatter.rb +16 -0
- data/lib/spec/runner/heckle_runner.rb +56 -56
- data/lib/spec/runner/{heckle_runner_win.rb → heckle_runner_unsupported.rb} +10 -10
- data/lib/spec/runner/line_number_query.rb +78 -0
- data/lib/spec/runner/option_parser.rb +147 -148
- data/lib/spec/runner/options.rb +343 -95
- data/lib/spec/runner/reporter.rb +117 -60
- data/lib/spec/runner.rb +39 -138
- data/lib/spec/stubs/cucumber.rb +5 -0
- data/lib/spec/test/unit.rb +10 -0
- data/lib/spec/version.rb +14 -22
- data/lib/spec.rb +5 -10
- data/resources/helpers/cmdline.rb +8 -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/spec/README.jruby +15 -0
- data/spec/autotest/autotest_helper.rb +8 -0
- data/spec/autotest/autotest_matchers.rb +38 -0
- data/spec/autotest/discover_spec.rb +8 -0
- data/spec/autotest/failed_results_re_spec.rb +31 -0
- data/spec/autotest/rspec_spec.rb +126 -0
- data/spec/ruby_forker.rb +13 -0
- data/spec/spec/dsl/main_spec.rb +103 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +51 -0
- data/spec/spec/example/example_group_factory_spec.rb +180 -0
- data/spec/spec/example/example_group_methods_spec.rb +778 -0
- data/spec/spec/example/example_group_proxy_spec.rb +107 -0
- data/spec/spec/example/example_group_spec.rb +632 -0
- data/spec/spec/example/example_matcher_spec.rb +85 -0
- data/spec/spec/example/example_methods_spec.rb +162 -0
- data/spec/spec/example/example_proxy_spec.rb +57 -0
- data/spec/spec/example/helper_method_spec.rb +24 -0
- data/spec/spec/{dsl/behaviour_eval_spec.rb → example/nested_example_group_spec.rb} +25 -3
- data/spec/spec/example/pending_module_spec.rb +58 -0
- data/spec/spec/example/predicate_matcher_spec.rb +41 -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/example/subject_spec.rb +110 -0
- data/spec/spec/expectations/differs/default_spec.rb +100 -13
- data/spec/spec/expectations/extensions/{object_spec.rb → kernel_spec.rb} +13 -14
- data/spec/spec/expectations/fail_with_spec.rb +42 -17
- data/spec/spec/expectations/handler_spec.rb +206 -0
- data/spec/spec/expectations/wrap_expectation_spec.rb +31 -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/test_case_with_various_names.rb +22 -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 +50 -0
- data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +9 -0
- data/spec/spec/matchers/be_close_spec.rb +32 -21
- data/spec/spec/matchers/be_instance_of_spec.rb +36 -0
- data/spec/spec/matchers/be_kind_of_spec.rb +33 -0
- data/spec/spec/matchers/be_spec.rb +261 -10
- data/spec/spec/matchers/change_spec.rb +178 -61
- data/spec/spec/matchers/compatibility_spec.rb +28 -0
- data/spec/spec/matchers/description_generation_spec.rb +47 -46
- data/spec/spec/matchers/dsl_spec.rb +34 -0
- data/spec/spec/matchers/eql_spec.rb +14 -9
- data/spec/spec/matchers/equal_spec.rb +43 -14
- data/spec/spec/matchers/exist_spec.rb +41 -24
- data/spec/spec/matchers/has_spec.rb +154 -1
- data/spec/spec/matchers/have_spec.rb +311 -189
- data/spec/spec/matchers/include_spec.rb +45 -2
- data/spec/spec/matchers/match_array_spec.rb +115 -0
- data/spec/spec/matchers/match_spec.rb +25 -5
- data/spec/spec/matchers/matcher_spec.rb +289 -0
- data/spec/spec/matchers/matchers_spec.rb +2 -0
- data/spec/spec/matchers/operator_matcher_spec.rb +48 -15
- data/spec/spec/matchers/raise_exception_spec.rb +345 -0
- data/spec/spec/matchers/respond_to_spec.rb +78 -16
- data/spec/spec/matchers/satisfy_spec.rb +1 -1
- data/spec/spec/matchers/simple_matcher_spec.rb +100 -0
- data/spec/spec/matchers/throw_symbol_spec.rb +111 -41
- data/spec/spec/mocks/and_yield_spec.rb +117 -0
- data/spec/spec/mocks/any_number_of_times_spec.rb +9 -2
- data/spec/spec/mocks/argument_expectation_spec.rb +19 -15
- data/spec/spec/mocks/argument_matchers_spec.rb +19 -0
- data/spec/spec/mocks/at_least_spec.rb +2 -2
- data/spec/spec/mocks/at_most_spec.rb +3 -3
- data/spec/spec/mocks/bug_report_10260_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_10263_spec.rb +27 -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_spec.rb +17 -0
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/mocks/bug_report_7611_spec.rb +2 -2
- data/spec/spec/mocks/bug_report_7805_spec.rb +2 -2
- data/spec/spec/mocks/bug_report_8165_spec.rb +4 -4
- data/spec/spec/mocks/bug_report_8302_spec.rb +2 -2
- data/spec/spec/mocks/bug_report_830_spec.rb +21 -0
- data/spec/spec/mocks/double_spec.rb +12 -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 +15 -5
- data/spec/spec/mocks/mock_space_spec.rb +1 -1
- data/spec/spec/mocks/mock_spec.rb +346 -129
- data/spec/spec/mocks/multiple_return_value_spec.rb +9 -9
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +53 -0
- data/spec/spec/mocks/null_object_mock_spec.rb +15 -1
- data/spec/spec/mocks/once_counts_spec.rb +2 -2
- data/spec/spec/mocks/options_hash_spec.rb +19 -17
- data/spec/spec/mocks/partial_mock_spec.rb +124 -12
- data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +2 -2
- data/spec/spec/mocks/passing_argument_matchers_spec.rb +145 -0
- data/spec/spec/mocks/precise_counts_spec.rb +2 -2
- data/spec/spec/mocks/record_messages_spec.rb +2 -2
- data/spec/spec/mocks/stub_chain_spec.rb +42 -0
- data/spec/spec/mocks/stub_implementation_spec.rb +31 -0
- data/spec/spec/mocks/stub_spec.rb +147 -103
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +26 -0
- data/spec/spec/mocks/twice_counts_spec.rb +2 -2
- data/spec/spec/mocks/unstub_spec.rb +127 -0
- data/spec/spec/package/bin_spec_spec.rb +11 -7
- data/spec/spec/rake/spectask_spec.rb +150 -0
- data/spec/spec/runner/class_and_argument_parser_spec.rb +23 -0
- data/spec/spec/runner/command_line_spec.rb +158 -29
- data/spec/spec/runner/configuration_spec.rb +320 -0
- data/spec/spec/runner/drb_command_line_spec.rb +137 -72
- data/spec/spec/runner/empty_file.txt +0 -0
- data/spec/spec/runner/example_group_runner_spec.rb +26 -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 +30 -0
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +113 -0
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +45 -0
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +17 -12
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +377 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +377 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +377 -0
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +377 -0
- data/spec/spec/runner/formatter/html_formatter_spec.rb +112 -52
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +329 -0
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +70 -0
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +87 -16
- data/spec/spec/runner/formatter/snippet_extractor_spec.rb +14 -7
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +153 -50
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6-jruby.html +371 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +371 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +371 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +371 -0
- data/spec/spec/runner/formatter/text_mate_formatter_spec.rb +106 -0
- data/spec/spec/runner/heckle_runner_spec.rb +32 -17
- data/spec/spec/runner/heckler_spec.rb +17 -11
- data/spec/spec/runner/line_number_query/line_number_query_fixture.rb +70 -0
- data/spec/spec/runner/line_number_query_spec.rb +129 -0
- data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +27 -21
- data/spec/spec/runner/option_parser_spec.rb +367 -164
- data/spec/spec/runner/options_spec.rb +506 -94
- data/spec/spec/runner/output_one_time_fixture.rb +7 -0
- data/spec/spec/runner/output_one_time_fixture_runner.rb +7 -0
- data/spec/spec/runner/output_one_time_spec.rb +15 -0
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +94 -27
- data/spec/spec/runner/reporter_spec.rb +212 -121
- 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 +8 -0
- data/spec/spec/runner/spec.opts +2 -0
- data/spec/spec/runner/spec_drb.opts +2 -0
- data/spec/spec/runner/spec_spaced.opts +2 -0
- data/spec/spec/runner_spec.rb +13 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +87 -45
- data/spec/support/macros.rb +29 -0
- data/spec/{spec → support}/spec_classes.rb +26 -4
- metadata +461 -141
- data/CHANGES +0 -748
- data/EXAMPLES.rd +0 -108
- data/README +0 -70
- data/UPGRADE +0 -31
- data/bin/spec_translator +0 -8
- data/examples/auto_spec_description_example.rb +0 -19
- data/examples/before_and_after_example.rb +0 -39
- data/examples/behave_as_example.rb +0 -45
- data/examples/dynamic_spec.rb +0 -9
- data/examples/helper_method_example.rb +0 -11
- data/examples/legacy_spec.rb +0 -10
- data/examples/not_yet_implemented_spec.rb +0 -12
- data/examples/priority.txt +0 -1
- data/examples/spec_helper.rb +0 -1
- data/examples/test_case_adapter_example.rb +0 -26
- data/examples/test_case_spec.rb +0 -65
- data/lib/spec/dsl/behaviour.rb +0 -204
- data/lib/spec/dsl/behaviour_callbacks.rb +0 -77
- data/lib/spec/dsl/behaviour_eval.rb +0 -177
- data/lib/spec/dsl/behaviour_factory.rb +0 -42
- data/lib/spec/dsl/composite_proc_builder.rb +0 -28
- data/lib/spec/dsl/configuration.rb +0 -119
- data/lib/spec/dsl/description.rb +0 -46
- data/lib/spec/dsl/example.rb +0 -127
- data/lib/spec/dsl/example_matcher.rb +0 -28
- data/lib/spec/dsl/example_should_raise_handler.rb +0 -74
- data/lib/spec/expectations/differs/default.rb +0 -61
- data/lib/spec/expectations/extensions/object.rb +0 -66
- data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
- data/lib/spec/extensions/object.rb +0 -6
- data/lib/spec/extensions.rb +0 -1
- data/lib/spec/matchers/raise_error.rb +0 -100
- data/lib/spec/mocks/argument_constraint_matchers.rb +0 -12
- data/lib/spec/mocks/spec_methods.rb +0 -30
- data/lib/spec/runner/behaviour_runner.rb +0 -102
- data/lib/spec/runner/extensions/object.rb +0 -32
- data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +0 -25
- data/lib/spec/runner/formatter/rdoc_formatter.rb +0 -24
- data/lib/spec/runner/formatter.rb +0 -9
- data/lib/spec/runner/spec_parser.rb +0 -50
- data/lib/spec/test_case_adapter.rb +0 -10
- data/lib/spec/translator.rb +0 -106
- data/plugins/mock_frameworks/flexmock.rb +0 -27
- data/plugins/mock_frameworks/rspec.rb +0 -18
- data/spec/spec/dsl/behaviour_factory_spec.rb +0 -30
- data/spec/spec/dsl/behaviour_spec.rb +0 -604
- data/spec/spec/dsl/composite_proc_builder_spec.rb +0 -57
- data/spec/spec/dsl/configuration_spec.rb +0 -50
- data/spec/spec/dsl/description_spec.rb +0 -81
- data/spec/spec/dsl/example_class_spec.rb +0 -24
- data/spec/spec/dsl/example_instance_spec.rb +0 -162
- data/spec/spec/dsl/example_should_raise_spec.rb +0 -137
- data/spec/spec/dsl/predicate_matcher_spec.rb +0 -21
- data/spec/spec/dsl/shared_behaviour_spec.rb +0 -208
- data/spec/spec/matchers/handler_spec.rb +0 -88
- data/spec/spec/matchers/matcher_methods_spec.rb +0 -78
- data/spec/spec/matchers/raise_error_spec.rb +0 -147
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +0 -73
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +0 -92
- data/spec/spec/runner/behaviour_runner_spec.rb +0 -118
- data/spec/spec/runner/context_matching_spec.rb +0 -27
- data/spec/spec/runner/execution_context_spec.rb +0 -31
- data/spec/spec/runner/extensions/kernel_spec.rb +0 -36
- data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +0 -27
- data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +0 -21
- data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +0 -36
- data/spec/spec/runner/formatter/rdoc_formatter_dry_run_spec.rb +0 -19
- data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +0 -46
- data/spec/spec/runner/formatter/specdoc_formatter_dry_run_spec.rb +0 -21
- data/spec/spec/runner/object_ext_spec.rb +0 -11
- data/spec/spec/runner/spec_matcher_spec.rb +0 -102
- data/spec/spec/runner/spec_parser_spec.rb +0 -93
- data/spec/spec/translator_spec.rb +0 -216
- /data/examples/{custom_expectation_matchers.rb → passing/custom_matchers.rb} +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
module ExampleExpectations
|
|
4
|
-
|
|
5
|
-
class ArbitraryMatcher
|
|
6
|
-
def initialize(*args, &block)
|
|
7
|
-
if args.last.is_a? Hash
|
|
8
|
-
@expected = args.last[:expected]
|
|
9
|
-
end
|
|
10
|
-
if block_given?
|
|
11
|
-
@expected = block.call
|
|
12
|
-
end
|
|
13
|
-
@block = block
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def matches?(target)
|
|
17
|
-
@target = target
|
|
18
|
-
return @expected == target
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def with(new_value)
|
|
22
|
-
@expected = new_value
|
|
23
|
-
self
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def failure_message
|
|
27
|
-
"expected #{@expected}, got #{@target}"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def negative_failure_message
|
|
31
|
-
"expected not #{@expected}, got #{@target}"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
class PositiveOnlyMatcher < ArbitraryMatcher
|
|
36
|
-
undef negative_failure_message
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def arbitrary_matcher(*args, &block)
|
|
40
|
-
ArbitraryMatcher.new(*args, &block)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def positive_only_matcher(*args, &block)
|
|
44
|
-
PositiveOnlyMatcher.new(*args, &block)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
module Spec
|
|
50
|
-
module Expectations
|
|
51
|
-
describe ExpectationMatcherHandler, ".handle_matcher" do
|
|
52
|
-
it "should ask the matcher if it matches" do
|
|
53
|
-
matcher = mock("matcher")
|
|
54
|
-
actual = Object.new
|
|
55
|
-
matcher.should_receive(:matches?).with(actual).and_return(true)
|
|
56
|
-
ExpectationMatcherHandler.handle_matcher(actual, matcher)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe ExpectationMatcherHandler do
|
|
61
|
-
include ExampleExpectations
|
|
62
|
-
|
|
63
|
-
it "should handle submitted args" do
|
|
64
|
-
5.should arbitrary_matcher(:expected => 5)
|
|
65
|
-
5.should arbitrary_matcher(:expected => "wrong").with(5)
|
|
66
|
-
lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5")
|
|
67
|
-
lambda { 5.should arbitrary_matcher(:expected => 5).with(4) }.should fail_with("expected 4, got 5")
|
|
68
|
-
5.should_not arbitrary_matcher(:expected => 4)
|
|
69
|
-
5.should_not arbitrary_matcher(:expected => 5).with(4)
|
|
70
|
-
lambda { 5.should_not arbitrary_matcher(:expected => 5) }.should fail_with("expected not 5, got 5")
|
|
71
|
-
lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5")
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "should handle the submitted block" do
|
|
75
|
-
5.should arbitrary_matcher { 5 }
|
|
76
|
-
5.should arbitrary_matcher(:expected => 4) { 5 }
|
|
77
|
-
5.should arbitrary_matcher(:expected => 4).with(5) { 3 }
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "should explain when matcher does not support should_not" do
|
|
81
|
-
lambda {
|
|
82
|
-
5.should_not positive_only_matcher(:expected => 5)
|
|
83
|
-
}.should fail_with(/Matcher does not support should_not.\n/)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module Matchers
|
|
5
|
-
context %Q{The Spec::Matchers module gets included in the execution context of every spec.
|
|
6
|
-
This module should provide the following methods, each of which returns a Matcher object.} do
|
|
7
|
-
it "be_true" do
|
|
8
|
-
be_true.should be_an_instance_of(Be)
|
|
9
|
-
end
|
|
10
|
-
it "be_false" do
|
|
11
|
-
be_false.should be_an_instance_of(Be)
|
|
12
|
-
end
|
|
13
|
-
it "be_nil" do
|
|
14
|
-
be_nil.should be_an_instance_of(Be)
|
|
15
|
-
end
|
|
16
|
-
it "be_arbitrary_predicate" do
|
|
17
|
-
be_arbitrary_predicate.should be_an_instance_of(Be)
|
|
18
|
-
end
|
|
19
|
-
it "be_close" do
|
|
20
|
-
be_close(1,2).should be_an_instance_of(BeClose)
|
|
21
|
-
end
|
|
22
|
-
it "change" do
|
|
23
|
-
change("target", :message).should be_an_instance_of(Change)
|
|
24
|
-
end
|
|
25
|
-
it "eql" do
|
|
26
|
-
eql(:expected).should be_an_instance_of(Eql)
|
|
27
|
-
end
|
|
28
|
-
it "equal" do
|
|
29
|
-
equal(:expected).should be_an_instance_of(Equal)
|
|
30
|
-
end
|
|
31
|
-
it "have" do
|
|
32
|
-
have(0).should be_an_instance_of(Have)
|
|
33
|
-
end
|
|
34
|
-
it "have_exactly" do
|
|
35
|
-
have_exactly(0).should be_an_instance_of(Have)
|
|
36
|
-
end
|
|
37
|
-
it "have_at_least" do
|
|
38
|
-
have_at_least(0).should be_an_instance_of(Have)
|
|
39
|
-
end
|
|
40
|
-
it "have_at_most" do
|
|
41
|
-
have_at_most(0).should be_an_instance_of(Have)
|
|
42
|
-
end
|
|
43
|
-
it "include" do
|
|
44
|
-
include(:value).should be_an_instance_of(Include)
|
|
45
|
-
end
|
|
46
|
-
it "match" do
|
|
47
|
-
match(:value).should be_an_instance_of(Match)
|
|
48
|
-
end
|
|
49
|
-
it "raise_error" do
|
|
50
|
-
raise_error.should be_an_instance_of(RaiseError)
|
|
51
|
-
raise_error(NoMethodError).should be_an_instance_of(RaiseError)
|
|
52
|
-
raise_error(NoMethodError, "message").should be_an_instance_of(RaiseError)
|
|
53
|
-
end
|
|
54
|
-
it "satisfy" do
|
|
55
|
-
satisfy{}.should be_an_instance_of(Satisfy)
|
|
56
|
-
end
|
|
57
|
-
it "throw_symbol" do
|
|
58
|
-
throw_symbol.should be_an_instance_of(ThrowSymbol)
|
|
59
|
-
throw_symbol(:sym).should be_an_instance_of(ThrowSymbol)
|
|
60
|
-
end
|
|
61
|
-
it "respond_to" do
|
|
62
|
-
respond_to(:sym).should be_an_instance_of(RespondTo)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe "Spec::Matchers#method_missing" do
|
|
67
|
-
it "should convert be_xyz to Be(:be_xyz)" do
|
|
68
|
-
Be.should_receive(:new).with(:be_whatever)
|
|
69
|
-
be_whatever
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "should convert have_xyz to Has(:have_xyz)" do
|
|
73
|
-
Has.should_receive(:new).with(:have_whatever)
|
|
74
|
-
have_whatever
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "should raise_error" do
|
|
4
|
-
it "should pass if anything is raised" do
|
|
5
|
-
lambda {raise}.should raise_error
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "should fail if nothing is raised" do
|
|
9
|
-
lambda {
|
|
10
|
-
lambda {}.should raise_error
|
|
11
|
-
}.should fail_with("expected Exception but nothing was raised")
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe "should_not raise_error" do
|
|
16
|
-
it "should pass if nothing is raised" do
|
|
17
|
-
lambda {}.should_not raise_error
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should fail if anything is raised" do
|
|
21
|
-
lambda {
|
|
22
|
-
lambda {raise}.should_not raise_error
|
|
23
|
-
}.should fail_with("expected no Exception, got RuntimeError")
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe "should raise_error(NamedError)" do
|
|
28
|
-
it "should pass if named error is raised" do
|
|
29
|
-
lambda { non_existent_method }.should raise_error(NameError)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "should fail if nothing is raised" do
|
|
33
|
-
lambda {
|
|
34
|
-
lambda { }.should raise_error(NameError)
|
|
35
|
-
}.should fail_with("expected NameError but nothing was raised")
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should fail if another error is raised" do
|
|
39
|
-
lambda {
|
|
40
|
-
lambda { raise }.should raise_error(NameError)
|
|
41
|
-
}.should fail_with("expected NameError, got RuntimeError")
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe "should_not raise_error(NamedError)" do
|
|
46
|
-
it "should pass if nothing is raised" do
|
|
47
|
-
lambda { }.should_not raise_error(NameError)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should pass if another error is raised" do
|
|
51
|
-
lambda { raise }.should_not raise_error(NameError)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "should fail if named error is raised" do
|
|
55
|
-
lambda {
|
|
56
|
-
lambda { non_existent_method }.should_not raise_error(NameError)
|
|
57
|
-
}.should fail_with(/expected no NameError, got #<NameError: undefined/)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "should raise_error(NamedError, error_message) with String" do
|
|
62
|
-
it "should pass if named error is raised with same message" do
|
|
63
|
-
lambda { raise "example message" }.should raise_error(RuntimeError, "example message")
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "should fail if nothing is raised" do
|
|
67
|
-
lambda {
|
|
68
|
-
lambda {}.should raise_error(RuntimeError, "example message")
|
|
69
|
-
}.should fail_with("expected RuntimeError with \"example message\" but nothing was raised")
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "should fail if incorrect error is raised" do
|
|
73
|
-
lambda {
|
|
74
|
-
lambda { raise }.should raise_error(NameError, "example message")
|
|
75
|
-
}.should fail_with("expected NameError with \"example message\", got RuntimeError")
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "should fail if correct error is raised with incorrect message" do
|
|
79
|
-
lambda {
|
|
80
|
-
lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, "example message")
|
|
81
|
-
}.should fail_with(/expected RuntimeError with \"example message\", got #<RuntimeError: not the example message/)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
describe "should_not raise_error(NamedError, error_message) with String" do
|
|
86
|
-
it "should pass if nothing is raised" do
|
|
87
|
-
lambda {}.should_not raise_error(RuntimeError, "example message")
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "should pass if a different error is raised" do
|
|
91
|
-
lambda { raise }.should_not raise_error(NameError, "example message")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it "should pass if same error is raised with different message" do
|
|
95
|
-
lambda { raise RuntimeError.new("not the example message") }.should_not raise_error(RuntimeError, "example message")
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "should fail if named error is raised with same message" do
|
|
99
|
-
lambda {
|
|
100
|
-
lambda { raise "example message" }.should_not raise_error(RuntimeError, "example message")
|
|
101
|
-
}.should fail_with("expected no RuntimeError with \"example message\", got #<RuntimeError: example message>")
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
describe "should raise_error(NamedError, error_message) with Regexp" do
|
|
106
|
-
it "should pass if named error is raised with matching message" do
|
|
107
|
-
lambda { raise "example message" }.should raise_error(RuntimeError, /ample mess/)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "should fail if nothing is raised" do
|
|
111
|
-
lambda {
|
|
112
|
-
lambda {}.should raise_error(RuntimeError, /ample mess/)
|
|
113
|
-
}.should fail_with("expected RuntimeError with message matching /ample mess/ but nothing was raised")
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it "should fail if incorrect error is raised" do
|
|
117
|
-
lambda {
|
|
118
|
-
lambda { raise }.should raise_error(NameError, /ample mess/)
|
|
119
|
-
}.should fail_with("expected NameError with message matching /ample mess/, got RuntimeError")
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it "should fail if correct error is raised with incorrect message" do
|
|
123
|
-
lambda {
|
|
124
|
-
lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, /less than ample mess/)
|
|
125
|
-
}.should fail_with("expected RuntimeError with message matching /less than ample mess/, got #<RuntimeError: not the example message>")
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
describe "should_not raise_error(NamedError, error_message) with Regexp" do
|
|
130
|
-
it "should pass if nothing is raised" do
|
|
131
|
-
lambda {}.should_not raise_error(RuntimeError, /ample mess/)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it "should pass if a different error is raised" do
|
|
135
|
-
lambda { raise }.should_not raise_error(NameError, /ample mess/)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it "should pass if same error is raised with non-matching message" do
|
|
139
|
-
lambda { raise RuntimeError.new("non matching message") }.should_not raise_error(RuntimeError, /ample mess/)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "should fail if named error is raised with matching message" do
|
|
143
|
-
lambda {
|
|
144
|
-
lambda { raise "example message" }.should_not raise_error(RuntimeError, /ample mess/)
|
|
145
|
-
}.should fail_with("expected no RuntimeError with message matching /ample mess/, got #<RuntimeError: example message>")
|
|
146
|
-
end
|
|
147
|
-
end
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module Mocks
|
|
5
|
-
describe "FailingMockArgumentConstraints" do
|
|
6
|
-
before do
|
|
7
|
-
@mock = mock("test mock")
|
|
8
|
-
@reporter = Mock.new("reporter", :null_object => true)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after do
|
|
12
|
-
@mock.rspec_reset
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should reject goose when expecting a duck" do
|
|
16
|
-
@mock.should_receive(:random_call).with(DuckTypeArgConstraint.new(:abs, :div))
|
|
17
|
-
lambda { @mock.random_call("I don't respond to :abs or :div") }.should raise_error(MockExpectationError)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should reject non boolean" do
|
|
21
|
-
@mock.should_receive(:random_call).with(:boolean)
|
|
22
|
-
lambda do
|
|
23
|
-
@mock.random_call("false")
|
|
24
|
-
end.should raise_error(MockExpectationError)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "should reject non numeric" do
|
|
28
|
-
@mock.should_receive(:random_call).with(:numeric)
|
|
29
|
-
lambda do
|
|
30
|
-
@mock.random_call("1")
|
|
31
|
-
end.should raise_error(MockExpectationError)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should reject non string" do
|
|
35
|
-
@mock.should_receive(:random_call).with(:string)
|
|
36
|
-
lambda do
|
|
37
|
-
@mock.random_call(123)
|
|
38
|
-
end.should raise_error(MockExpectationError)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should fail if regexp does not match submitted string" do
|
|
42
|
-
@mock.should_receive(:random_call).with(/bcd/)
|
|
43
|
-
lambda { @mock.random_call("abc") }.should raise_error(MockExpectationError)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should fail if regexp does not match submitted regexp" do
|
|
47
|
-
@mock.should_receive(:random_call).with(/bcd/)
|
|
48
|
-
lambda { @mock.random_call(/bcde/) }.should raise_error(MockExpectationError)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should fail for a hash w/ wrong values" do
|
|
52
|
-
@mock.should_receive(:random_call).with(:a => "b", :c => "d")
|
|
53
|
-
lambda do
|
|
54
|
-
@mock.random_call(:a => "b", :c => "e")
|
|
55
|
-
end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "should fail for a hash w/ wrong keys" do
|
|
59
|
-
@mock.should_receive(:random_call).with(:a => "b", :c => "d")
|
|
60
|
-
lambda do
|
|
61
|
-
@mock.random_call("a" => "b", "c" => "d")
|
|
62
|
-
end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "should match against a Matcher" do
|
|
66
|
-
lambda do
|
|
67
|
-
@mock.should_receive(:msg).with(equal(3))
|
|
68
|
-
@mock.msg(37)
|
|
69
|
-
end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (equal 3) but received it with (37)")
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module Mocks
|
|
5
|
-
describe "a mock, in handling arguments" do
|
|
6
|
-
before(:each) do
|
|
7
|
-
@mock = Mock.new("test mock")
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
after(:each) do
|
|
11
|
-
@mock.rspec_verify
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "should accept true as boolean" do
|
|
15
|
-
@mock.should_receive(:random_call).with(:boolean)
|
|
16
|
-
@mock.random_call(true)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "should accept false as boolean" do
|
|
20
|
-
@mock.should_receive(:random_call).with(:boolean)
|
|
21
|
-
@mock.random_call(false)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should accept fixnum as numeric" do
|
|
25
|
-
@mock.should_receive(:random_call).with(:numeric)
|
|
26
|
-
@mock.random_call(1)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should accept float as numeric" do
|
|
30
|
-
@mock.should_receive(:random_call).with(:numeric)
|
|
31
|
-
@mock.random_call(1.5)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should accept string as anything" do
|
|
35
|
-
@mock.should_receive(:random_call).with("a", :anything, "c")
|
|
36
|
-
@mock.random_call("a", "whatever", "c")
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should match duck type with one method" do
|
|
40
|
-
@mock.should_receive(:random_call).with(DuckTypeArgConstraint.new(:length))
|
|
41
|
-
@mock.random_call([])
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should match duck type with two methods" do
|
|
45
|
-
@mock.should_receive(:random_call).with(DuckTypeArgConstraint.new(:abs, :div))
|
|
46
|
-
@mock.random_call(1)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should match non special symbol" do
|
|
50
|
-
@mock.should_receive(:random_call).with(:some_symbol)
|
|
51
|
-
@mock.random_call(:some_symbol)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "should match string" do
|
|
55
|
-
@mock.should_receive(:random_call).with(:string)
|
|
56
|
-
@mock.random_call("a string")
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should match string against regexp" do
|
|
60
|
-
@mock.should_receive(:random_call).with(/bcd/)
|
|
61
|
-
@mock.random_call("abcde")
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "should match regexp against regexp" do
|
|
65
|
-
@mock.should_receive(:random_call).with(/bcd/)
|
|
66
|
-
@mock.random_call(/bcd/)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "should match against a hash submitted and received by value" do
|
|
70
|
-
@mock.should_receive(:random_call).with(:a => "a", :b => "b")
|
|
71
|
-
@mock.random_call(:a => "a", :b => "b")
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "should match against a hash submitted by reference and received by value" do
|
|
75
|
-
opts = {:a => "a", :b => "b"}
|
|
76
|
-
@mock.should_receive(:random_call).with(opts)
|
|
77
|
-
@mock.random_call(:a => "a", :b => "b")
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "should match against a hash submitted by value and received by reference" do
|
|
81
|
-
opts = {:a => "a", :b => "b"}
|
|
82
|
-
@mock.should_receive(:random_call).with(:a => "a", :b => "b")
|
|
83
|
-
@mock.random_call(opts)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "should match against a Matcher" do
|
|
87
|
-
@mock.should_receive(:msg).with(equal(37))
|
|
88
|
-
@mock.msg(37)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module Runner
|
|
5
|
-
describe BehaviourRunner do
|
|
6
|
-
|
|
7
|
-
it "should only run behaviours with at least one example" do
|
|
8
|
-
desired_context = mock("desired context")
|
|
9
|
-
desired_context.should_receive(:run)
|
|
10
|
-
desired_context.should_receive(:retain_examples_matching!)
|
|
11
|
-
desired_context.should_receive(:number_of_examples).twice.and_return(1)
|
|
12
|
-
desired_context.should_receive(:shared?).and_return(false)
|
|
13
|
-
|
|
14
|
-
other_context = mock("other context")
|
|
15
|
-
other_context.should_receive(:run).never
|
|
16
|
-
other_context.should_receive(:retain_examples_matching!)
|
|
17
|
-
other_context.should_receive(:number_of_examples).and_return(0)
|
|
18
|
-
|
|
19
|
-
reporter = mock("reporter")
|
|
20
|
-
options = Options.new
|
|
21
|
-
options.reporter = reporter
|
|
22
|
-
options.examples = ["desired context legal spec"]
|
|
23
|
-
|
|
24
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
|
25
|
-
runner.add_behaviour(desired_context)
|
|
26
|
-
runner.add_behaviour(other_context)
|
|
27
|
-
reporter.should_receive(:start)
|
|
28
|
-
reporter.should_receive(:end)
|
|
29
|
-
reporter.should_receive(:dump)
|
|
30
|
-
runner.run([], false)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should dump even if Interrupt exception is occurred" do
|
|
34
|
-
behaviour = Spec::DSL::Behaviour.new("context") do
|
|
35
|
-
it "no error" do
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should interrupt" do
|
|
39
|
-
raise Interrupt
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
reporter = mock("reporter")
|
|
44
|
-
reporter.should_receive(:start)
|
|
45
|
-
reporter.should_receive(:add_behaviour).with("context")
|
|
46
|
-
reporter.should_receive(:example_started).twice
|
|
47
|
-
reporter.should_receive(:example_finished).twice
|
|
48
|
-
reporter.should_receive(:rspec_verify)
|
|
49
|
-
reporter.should_receive(:rspec_reset)
|
|
50
|
-
reporter.should_receive(:end)
|
|
51
|
-
reporter.should_receive(:dump)
|
|
52
|
-
|
|
53
|
-
options = Options.new
|
|
54
|
-
options.reporter = reporter
|
|
55
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
|
56
|
-
runner.add_behaviour(behaviour)
|
|
57
|
-
runner.run([], false)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should heckle when options have heckle_runner" do
|
|
61
|
-
context = mock("context", :null_object => true)
|
|
62
|
-
context.should_receive(:number_of_examples).twice.and_return(1)
|
|
63
|
-
context.should_receive(:run).and_return(0)
|
|
64
|
-
context.should_receive(:shared?).and_return(false)
|
|
65
|
-
|
|
66
|
-
reporter = mock("reporter")
|
|
67
|
-
reporter.should_receive(:start).with(1)
|
|
68
|
-
reporter.should_receive(:end)
|
|
69
|
-
reporter.should_receive(:dump).and_return(0)
|
|
70
|
-
|
|
71
|
-
heckle_runner = mock("heckle_runner")
|
|
72
|
-
heckle_runner.should_receive(:heckle_with)
|
|
73
|
-
|
|
74
|
-
options = Options.new
|
|
75
|
-
options.reporter = reporter
|
|
76
|
-
options.heckle_runner = heckle_runner
|
|
77
|
-
|
|
78
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
|
79
|
-
runner.add_behaviour(context)
|
|
80
|
-
runner.run([], false)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should run specs backward if options.reverse is true" do
|
|
84
|
-
options = Options.new
|
|
85
|
-
options.reverse = true
|
|
86
|
-
|
|
87
|
-
reporter = mock("reporter")
|
|
88
|
-
reporter.should_receive(:start).with(3)
|
|
89
|
-
reporter.should_receive(:end)
|
|
90
|
-
reporter.should_receive(:dump).and_return(0)
|
|
91
|
-
options.reporter = reporter
|
|
92
|
-
|
|
93
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
|
94
|
-
c1 = mock("c1")
|
|
95
|
-
c1.should_receive(:number_of_examples).twice.and_return(1)
|
|
96
|
-
c1.should_receive(:shared?).and_return(false)
|
|
97
|
-
|
|
98
|
-
c2 = mock("c2")
|
|
99
|
-
c2.should_receive(:number_of_examples).twice.and_return(2)
|
|
100
|
-
c2.should_receive(:shared?).and_return(false)
|
|
101
|
-
c2.should_receive(:run) do
|
|
102
|
-
c1.should_receive(:run)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
runner.add_behaviour(c1)
|
|
106
|
-
runner.add_behaviour(c2)
|
|
107
|
-
|
|
108
|
-
runner.run([], false)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "should yield global configuration" do
|
|
112
|
-
Spec::Runner.configure do |config|
|
|
113
|
-
config.should equal(Spec::Runner.configuration)
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module DSL
|
|
5
|
-
describe "ContextMatching" do
|
|
6
|
-
|
|
7
|
-
before(:each) do
|
|
8
|
-
@formatter = Spec::Mocks::Mock.new("formatter")
|
|
9
|
-
@behaviour = Behaviour.new("context") {}
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "run all specs when spec is not specified" do
|
|
13
|
-
@behaviour.it("spec1") {}
|
|
14
|
-
@behaviour.it("spec2") {}
|
|
15
|
-
@behaviour.retain_examples_matching!(["context"])
|
|
16
|
-
@behaviour.number_of_examples.should == 2
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "should only run specified examples when specified" do
|
|
20
|
-
@behaviour.it("spec1") {}
|
|
21
|
-
@behaviour.it("spec2") {}
|
|
22
|
-
@behaviour.retain_examples_matching!(["context spec1"])
|
|
23
|
-
@behaviour.number_of_examples.should == 1
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "ExecutionContext" do
|
|
4
|
-
|
|
5
|
-
it "should provide duck_type()" do
|
|
6
|
-
dt = duck_type(:length)
|
|
7
|
-
dt.should be_an_instance_of(Spec::Mocks::DuckTypeArgConstraint)
|
|
8
|
-
dt.matches?([]).should be_true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should violate when violated()" do
|
|
12
|
-
lambda do
|
|
13
|
-
violated
|
|
14
|
-
end.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should provide mock()" do
|
|
18
|
-
mock("thing").should be_an_instance_of(Spec::Mocks::Mock)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should provide stub()" do
|
|
22
|
-
thing_stub = stub("thing").should be_an_instance_of(Spec::Mocks::Mock)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "should add method stubs to stub()" do
|
|
26
|
-
thing_stub = stub("thing", :a => "A", :b => "B")
|
|
27
|
-
thing_stub.a.should == "A"
|
|
28
|
-
thing_stub.b.should == "B"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe Kernel, "when extended by rspec" do
|
|
4
|
-
it "should respond to :describe" do
|
|
5
|
-
Object.new.should respond_to(:describe)
|
|
6
|
-
Object.new.should respond_to(:context)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe Kernel, " when creating behaviours with describe" do
|
|
11
|
-
|
|
12
|
-
it "should fail when no block given" do
|
|
13
|
-
lambda { describe "foo" }.should raise_error(ArgumentError)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should fail when no description given" do
|
|
17
|
-
lambda { describe do; end }.should raise_error(ArgumentError)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe Kernel, "#respond_to" do
|
|
22
|
-
before(:each) do
|
|
23
|
-
@kernel_impersonator = Class.new do
|
|
24
|
-
include Kernel
|
|
25
|
-
end.new
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should return a Spec::Matchers::RespondTo" do
|
|
29
|
-
@kernel_impersonator.respond_to.should be_an_instance_of(Spec::Matchers::RespondTo)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "should pass the submitted names to the RespondTo instance" do
|
|
33
|
-
Spec::Matchers::RespondTo.should_receive(:new).with(:a,'b','c?')
|
|
34
|
-
@kernel_impersonator.respond_to(:a,'b','c?')
|
|
35
|
-
end
|
|
36
|
-
end
|