newbamboo-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/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,79 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Example
|
5
|
+
describe ExampleMatcher, "#matches?" do
|
6
|
+
def match_description(description)
|
7
|
+
simple_matcher do |actual, matcher|
|
8
|
+
matcher.failure_message = "expected matcher.matches?(#{description.inspect}) to return true, got false"
|
9
|
+
matcher.negative_failure_message = "expected matcher.matches?(#{description.inspect}) to return false, got true"
|
10
|
+
actual.matches?(description)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should match correct example_group and example" do
|
15
|
+
matcher = ExampleMatcher.new("example_group", "example")
|
16
|
+
matcher.should match_description("example_group example")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not match wrong example" do
|
20
|
+
matcher = ExampleMatcher.new("example_group", "other example")
|
21
|
+
matcher.should_not match_description("example_group example")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not match wrong example_group" do
|
25
|
+
matcher = ExampleMatcher.new("other example_group", "example")
|
26
|
+
matcher.should_not match_description("example_group example")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should match example only" do
|
30
|
+
matcher = ExampleMatcher.new("example_group", "example")
|
31
|
+
matcher.should match_description("example")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should match example_group only" do
|
35
|
+
matcher = ExampleMatcher.new("example_group", "example")
|
36
|
+
matcher.should match_description("example_group")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should match example_group ending with before(:all)" do
|
40
|
+
matcher = ExampleMatcher.new("example_group", "example")
|
41
|
+
matcher.should match_description("example_group before(:all)")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should escape regexp chars" do
|
45
|
+
matcher = ExampleMatcher.new("(con|text)", "[example]")
|
46
|
+
matcher.should_not match_description("con p")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should match when example_group is modularized" do
|
50
|
+
matcher = ExampleMatcher.new("MyModule::MyClass", "example")
|
51
|
+
matcher.should match_description("MyClass example")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ExampleMatcher, "#matches? normal case" do
|
56
|
+
it "matches when passed in example matches" do
|
57
|
+
matcher = ExampleMatcher.new("Foo", "bar")
|
58
|
+
matcher.matches?(["no match", "Foo bar"]).should == true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "does not match when no passed in examples match" do
|
62
|
+
matcher = ExampleMatcher.new("Foo", "bar")
|
63
|
+
matcher.matches?(["no match1", "no match2"]).should == false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe ExampleMatcher, "#matches? where description has '::' in it" do
|
68
|
+
it "matches when passed in example matches" do
|
69
|
+
matcher = ExampleMatcher.new("Foo::Bar", "baz")
|
70
|
+
matcher.matches?(["no match", "Foo::Bar baz"]).should == true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "does not match when no passed in examples match" do
|
74
|
+
matcher = ExampleMatcher.new("Foo::Bar", "baz")
|
75
|
+
matcher.matches?(["no match1", "no match2"]).should == false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Example
|
5
|
+
describe ExampleMethods do
|
6
|
+
module ModuleThatIsReopened; end
|
7
|
+
|
8
|
+
module ExampleMethods
|
9
|
+
include ModuleThatIsReopened
|
10
|
+
end
|
11
|
+
|
12
|
+
module ModuleThatIsReopened
|
13
|
+
def module_that_is_reopened_method; end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "with an included module that is reopened" do
|
17
|
+
it "should have repoened methods" do
|
18
|
+
method(:module_that_is_reopened_method).should_not be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "eval_block" do
|
23
|
+
before(:each) do
|
24
|
+
@example_group = ExampleGroup.dup
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "with a given description" do
|
28
|
+
it "should provide the given description" do
|
29
|
+
@example = @example_group.it("given description") { 2.should == 2 }
|
30
|
+
@example.eval_block
|
31
|
+
@example.description.should == "given description"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "with no given description" do
|
36
|
+
it "should provide the generated description" do
|
37
|
+
@example = @example_group.it { 2.should == 2 }
|
38
|
+
@example.eval_block
|
39
|
+
@example.description.should == "should == 2"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "with no implementation" do
|
44
|
+
it "should raise an NotYetImplementedError" do
|
45
|
+
lambda {
|
46
|
+
@example = @example_group.it
|
47
|
+
@example.eval_block
|
48
|
+
}.should raise_error(Spec::Example::NotYetImplementedError, "Not Yet Implemented")
|
49
|
+
end
|
50
|
+
|
51
|
+
def extract_error(&blk)
|
52
|
+
begin
|
53
|
+
blk.call
|
54
|
+
rescue Exception => e
|
55
|
+
return e
|
56
|
+
end
|
57
|
+
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should use the proper file and line number for the NotYetImplementedError" do
|
62
|
+
file = __FILE__
|
63
|
+
line_number = __LINE__ + 3
|
64
|
+
|
65
|
+
error = extract_error do
|
66
|
+
@example = @example_group.example
|
67
|
+
@example.eval_block
|
68
|
+
end
|
69
|
+
|
70
|
+
error.pending_caller.should =~ /#{file}:#{line_number}/
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#backtrace" do
|
76
|
+
it "returns the backtrace from where the example was defined" do
|
77
|
+
example = ExampleGroup.dup.new "name"
|
78
|
+
example.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#implementation_backtrace (deprecated)" do
|
83
|
+
before(:each) do
|
84
|
+
Kernel.stub!(:warn)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "sends a deprecation warning" do
|
88
|
+
Kernel.should_receive(:warn).with(/#implementation_backtrace.*deprecated.*#backtrace instead/m)
|
89
|
+
example = ExampleGroup.dup.new "name"
|
90
|
+
example.implementation_backtrace
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns the backtrace from where the example was defined" do
|
94
|
+
example = ExampleGroup.dup.new "name"
|
95
|
+
example.implementation_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#full_description" do
|
100
|
+
it "should return the full description of the ExampleGroup and Example" do
|
101
|
+
example_group = Class.new(ExampleGroupDouble).describe("An ExampleGroup")
|
102
|
+
example = example_group.new "should do something"
|
103
|
+
example.full_description.should == "An ExampleGroup should do something"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#subject" do
|
108
|
+
before(:each) do
|
109
|
+
@example_group = ExampleGroupDouble
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should return an instance of the described class" do
|
113
|
+
group = Class.new(ExampleGroupDouble).describe(Array)
|
114
|
+
example = group.new
|
115
|
+
example.subject.should == []
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should return nil for a module (as opposed to a class)" do
|
119
|
+
group = Class.new(ExampleGroupDouble).describe(Enumerable)
|
120
|
+
example = group.new
|
121
|
+
example.subject.should be_nil
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should return nil for a string" do
|
125
|
+
group = Class.new(ExampleGroupDouble).describe('foo')
|
126
|
+
example = group.new
|
127
|
+
example.subject.should be_nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Thing
|
132
|
+
attr_reader :arg
|
133
|
+
def initialize(arg=nil)
|
134
|
+
@arg = arg || :default
|
135
|
+
end
|
136
|
+
def ==(other)
|
137
|
+
@arg == other.arg
|
138
|
+
end
|
139
|
+
def eql?(other)
|
140
|
+
@arg == other.arg
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#should" do
|
145
|
+
before(:each) do
|
146
|
+
@example_group = Class.new(ExampleGroupDouble)
|
147
|
+
@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
|
148
|
+
end
|
149
|
+
|
150
|
+
context "in an ExampleGroup with an implicit subject" do
|
151
|
+
it "delegates matcher to the implied subject" do
|
152
|
+
@example_group.describe(Thing)
|
153
|
+
@example_group.example { should == Thing.new(:default) }
|
154
|
+
@example_group.example { should eql(Thing.new(:default)) }
|
155
|
+
@example_group.run(@options).should be_true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "in an ExampleGroup using an explicit subject" do
|
160
|
+
it "delegates matcher to the declared subject" do
|
161
|
+
@example_group.describe(Thing)
|
162
|
+
@example_group.subject { Thing.new(:other) }
|
163
|
+
@example_group.example { should == Thing.new(:other) }
|
164
|
+
@example_group.example { should eql(Thing.new(:other)) }
|
165
|
+
@example_group.run(@options).should be_true
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "#should_not" do
|
171
|
+
before(:each) do
|
172
|
+
@example_group = ExampleGroup.dup
|
173
|
+
end
|
174
|
+
|
175
|
+
context "in an ExampleGroup with an implicit subject" do
|
176
|
+
it "delegates matcher to the implied subject" do
|
177
|
+
@example_group.describe(Thing)
|
178
|
+
@example_group.example { should_not == Thing.new(:other) }
|
179
|
+
@example_group.example { should_not eql(Thing.new(:other)) }
|
180
|
+
@example_group.run(::Spec::Runner::Options.new(StringIO.new, StringIO.new)).should be_true
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context "in an ExampleGroup using an explicit subject" do
|
185
|
+
it "delegates matcher to the declared subject" do
|
186
|
+
@example_group.describe(Thing)
|
187
|
+
@example_group.subject { Thing.new(:other) }
|
188
|
+
@example_group.example { should_not == Thing.new(:default) }
|
189
|
+
@example_group.example { should_not eql(Thing.new(:default)) }
|
190
|
+
@example_group.run(::Spec::Runner::Options.new(StringIO.new, StringIO.new)).should be_true
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "#options" do
|
197
|
+
it "should expose the options hash" do
|
198
|
+
example = ExampleGroup.dup.new "name", :this => 'that' do; end
|
199
|
+
example.options[:this].should == 'that'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
# This was added to prove that http://rspec.lighthouseapp.com/projects/5645/tickets/211
|
4
|
+
# was fixed in ruby 1.9.1
|
5
|
+
|
6
|
+
module HelperMethodExample
|
7
|
+
describe "a helper method" do
|
8
|
+
def helper_method
|
9
|
+
"received call"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is available to examples in the same group" do
|
13
|
+
helper_method.should == "received call"
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "from a nested group" do
|
17
|
+
it "is available to examples in a nested group" do
|
18
|
+
helper_method.should == "received call"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Example
|
5
|
+
describe 'Nested Example Groups' do
|
6
|
+
parent = self
|
7
|
+
|
8
|
+
def count
|
9
|
+
@count ||= 0
|
10
|
+
@count = @count + 1
|
11
|
+
@count
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:all) do
|
15
|
+
count.should == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
before(:all) do
|
19
|
+
count.should == 2
|
20
|
+
end
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
count.should == 3
|
24
|
+
end
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
count.should == 4
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should run before(:all), before(:each), example, after(:each), after(:all) in order" do
|
31
|
+
count.should == 5
|
32
|
+
end
|
33
|
+
|
34
|
+
after(:each) do
|
35
|
+
count.should == 7
|
36
|
+
end
|
37
|
+
|
38
|
+
after(:each) do
|
39
|
+
count.should == 6
|
40
|
+
end
|
41
|
+
|
42
|
+
after(:all) do
|
43
|
+
count.should == 9
|
44
|
+
end
|
45
|
+
|
46
|
+
after(:all) do
|
47
|
+
count.should == 8
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'nested example group' do
|
51
|
+
self.superclass.should == parent
|
52
|
+
|
53
|
+
it "should run all before and after callbacks" do
|
54
|
+
count.should == 5
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "Nested Example Groups" do
|
60
|
+
describe "description options", :other_options => "other options" do
|
61
|
+
it "should have a spec_path" do
|
62
|
+
self.class.description_options[:spec_path].should match(/#{__FILE__}/)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should pass other options" do
|
66
|
+
self.class.description_options[:other_options].should == "other options"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module Spec
|
2
|
+
module Example
|
3
|
+
describe Pending do
|
4
|
+
|
5
|
+
it 'should raise an ExamplePendingError if no block is supplied' do
|
6
|
+
lambda {
|
7
|
+
pending "TODO"
|
8
|
+
}.should raise_error(ExamplePendingError, /TODO/)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should raise an ExamplePendingError if a supplied block fails as expected' do
|
12
|
+
lambda {
|
13
|
+
pending "TODO" do
|
14
|
+
raise "oops"
|
15
|
+
end
|
16
|
+
}.should raise_error(ExamplePendingError, /TODO/)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should raise an ExamplePendingError if a supplied block fails as expected with a mock' do
|
20
|
+
lambda {
|
21
|
+
pending "TODO" do
|
22
|
+
m = mock('thing')
|
23
|
+
m.should_receive(:foo)
|
24
|
+
m.rspec_verify
|
25
|
+
end
|
26
|
+
}.should raise_error(ExamplePendingError, /TODO/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should raise a PendingExampleFixedError if a supplied block starts working' do
|
30
|
+
lambda {
|
31
|
+
pending "TODO" do
|
32
|
+
# success!
|
33
|
+
end
|
34
|
+
}.should raise_error(PendingExampleFixedError, /TODO/)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have the correct file and line number for pending given with a block which fails" do
|
38
|
+
file = __FILE__
|
39
|
+
line_number = __LINE__ + 2
|
40
|
+
begin
|
41
|
+
pending do
|
42
|
+
raise
|
43
|
+
end
|
44
|
+
rescue => error
|
45
|
+
error.pending_caller.should == "#{file}:#{line_number}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should have the correct file and line number for pending given with no block" do
|
50
|
+
file = __FILE__
|
51
|
+
line_number = __LINE__ + 2
|
52
|
+
begin
|
53
|
+
pending("TODO")
|
54
|
+
rescue => error
|
55
|
+
error.pending_caller.should == "#{file}:#{line_number}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe ExamplePendingError do
|
61
|
+
it "should have the caller (from two calls from initialization)" do
|
62
|
+
two_calls_ago = caller[0]
|
63
|
+
ExamplePendingError.new("a message").pending_caller.should == two_calls_ago
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should keep the trace information from initialization" do
|
67
|
+
two_calls_ago = caller[0]
|
68
|
+
obj = ExamplePendingError.new("a message")
|
69
|
+
obj.pending_caller
|
70
|
+
def another_caller(obj)
|
71
|
+
obj.pending_caller
|
72
|
+
end
|
73
|
+
|
74
|
+
another_caller(obj).should == two_calls_ago
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should have the message provided" do
|
78
|
+
ExamplePendingError.new("a message").message.should == "a message"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should use a 'ExamplePendingError' as it's default message" do
|
82
|
+
ExamplePendingError.new.message.should == "Spec::Example::ExamplePendingError"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe NotYetImplementedError do
|
87
|
+
def rspec_root
|
88
|
+
File.expand_path(__FILE__.gsub("/spec/spec/example/pending_module_spec.rb", "/lib"))
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should have the root rspec path" do
|
92
|
+
NotYetImplementedError::RSPEC_ROOT_LIB.should == rspec_root
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should always have the error 'Not Yet Implemented'" do
|
96
|
+
NotYetImplementedError.new([]).message.should == "Not Yet Implemented"
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "pending_caller" do
|
100
|
+
it "should select an element out of the backtrace" do
|
101
|
+
error = NotYetImplementedError.new(["foo/bar.rb:18"])
|
102
|
+
|
103
|
+
error.pending_caller.should == "foo/bar.rb:18"
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should actually report the element from the backtrace" do
|
107
|
+
error = NotYetImplementedError.new(["bar.rb:18"])
|
108
|
+
|
109
|
+
error.pending_caller.should == "bar.rb:18"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should not use an element with the rspec root path" do
|
113
|
+
error = NotYetImplementedError.new(["#{rspec_root}:8"])
|
114
|
+
|
115
|
+
error.pending_caller.should be_nil
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should select the first line in the backtrace which isn't in the rspec root" do
|
119
|
+
error = NotYetImplementedError.new([
|
120
|
+
"#{rspec_root}/foo.rb:2",
|
121
|
+
"#{rspec_root}/foo/bar.rb:18",
|
122
|
+
"path1.rb:22",
|
123
|
+
"path2.rb:33"
|
124
|
+
])
|
125
|
+
|
126
|
+
error.pending_caller.should == "path1.rb:22"
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should cache the caller" do
|
130
|
+
backtrace = mock('backtrace')
|
131
|
+
backtrace.should_receive(:detect).once
|
132
|
+
|
133
|
+
error = NotYetImplementedError.new(backtrace)
|
134
|
+
error.pending_caller.should == error.pending_caller
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Example
|
5
|
+
class Fish
|
6
|
+
def can_swim?(distance_in_yards)
|
7
|
+
distance_in_yards < 1000
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "predicate_matcher[method_on_object] = matcher_method" do
|
12
|
+
predicate_matchers[:swim] = :can_swim?
|
13
|
+
it "should match matcher_method if method_on_object returns true" do
|
14
|
+
swim(100).matches?(Fish.new).should be_true
|
15
|
+
end
|
16
|
+
it "should not match matcher_method if method_on_object returns false" do
|
17
|
+
swim(10000).matches?(Fish.new).should be_false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|