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,653 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
|
|
3
|
+
module Spec
|
|
4
|
+
module Example
|
|
5
|
+
describe 'ExampleGroupMethods' do
|
|
6
|
+
with_sandboxed_options do
|
|
7
|
+
attr_reader :example_group, :result, :reporter
|
|
8
|
+
before(:each) do
|
|
9
|
+
# See http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/525-arity-changed-on-partial-mocks#ticket-525-2
|
|
10
|
+
method_with_three_args = lambda { |arg1, arg2, arg3| }
|
|
11
|
+
options.formatters << mock("formatter", :null_object => true, :example_pending => method_with_three_args)
|
|
12
|
+
options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
|
|
13
|
+
@reporter = FakeReporter.new(@options)
|
|
14
|
+
options.reporter = reporter
|
|
15
|
+
@example_group = Class.new(ExampleGroupDouble) do
|
|
16
|
+
describe("ExampleGroup")
|
|
17
|
+
it "does nothing"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
after(:each) do
|
|
22
|
+
ExampleGroup.reset
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
["describe","context"].each do |method|
|
|
26
|
+
describe "##{method}" do
|
|
27
|
+
describe "when creating an ExampleGroup" do
|
|
28
|
+
before(:each) do
|
|
29
|
+
@parent_example_group = Class.new(ExampleGroupDouble) do
|
|
30
|
+
example "first example" do; end
|
|
31
|
+
end
|
|
32
|
+
@child_example_group = @parent_example_group.__send__ method, "Child" do
|
|
33
|
+
example "second example" do; end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should create a subclass of the ExampleGroup when passed a block" do
|
|
38
|
+
@child_example_group.superclass.should == @parent_example_group
|
|
39
|
+
options.example_groups.should include(@child_example_group)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should not inherit examples" do
|
|
43
|
+
@child_example_group.should have(1).examples
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "records the spec path" do
|
|
47
|
+
@child_example_group.spec_path.should =~ /#{__FILE__}:#{__LINE__ - 15}/
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "when creating a SharedExampleGroup" do
|
|
52
|
+
before(:each) do
|
|
53
|
+
@shared_example_group = @example_group.__send__ method, "A Shared ExampleGroup", :shared => true do; end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
after(:each) do
|
|
57
|
+
SharedExampleGroup.instance_eval{@shared_example_groups}.delete @shared_example_group
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should create a SharedExampleGroup" do
|
|
61
|
+
@shared_example_group.should_not be_nil
|
|
62
|
+
SharedExampleGroup.find("A Shared ExampleGroup").should == @shared_example_group
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
[:specify, :it].each do |method|
|
|
70
|
+
describe "##{method.to_s}" do
|
|
71
|
+
it "should should create an example" do
|
|
72
|
+
lambda {
|
|
73
|
+
@example_group.__send__(method, "")
|
|
74
|
+
}.should change { @example_group.examples.length }.by(1)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
[:xit, :xspecify].each do |method|
|
|
80
|
+
describe "##{method.to_s}" do
|
|
81
|
+
before(:each) do
|
|
82
|
+
Kernel.stub!(:warn)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should NOT create an example" do
|
|
86
|
+
lambda {
|
|
87
|
+
@example_group.__send__(method,"")
|
|
88
|
+
}.should_not change(@example_group.examples, :length)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should warn that the example is disabled" do
|
|
92
|
+
Kernel.should_receive(:warn).with("Example disabled: foo")
|
|
93
|
+
@example_group.__send__(method,"foo")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
describe "#examples" do
|
|
100
|
+
it "should have Examples" do
|
|
101
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
102
|
+
it "should exist" do; end
|
|
103
|
+
end
|
|
104
|
+
example_group.examples.length.should == 1
|
|
105
|
+
example_group.examples.first.description.should == "should exist"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should not include methods that begin with test (only when TU interop is loaded)" do
|
|
109
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
110
|
+
def test_any_args(*args)
|
|
111
|
+
true.should be_true
|
|
112
|
+
end
|
|
113
|
+
def test_something
|
|
114
|
+
1.should == 1
|
|
115
|
+
end
|
|
116
|
+
def test
|
|
117
|
+
raise "This is not a real test"
|
|
118
|
+
end
|
|
119
|
+
def testify
|
|
120
|
+
raise "This is not a real test"
|
|
121
|
+
end
|
|
122
|
+
def should_something
|
|
123
|
+
# forces the run
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
example_group.examples.length.should == 1
|
|
127
|
+
example_group.run(options).should be_true
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "should include methods that begin with should and has an arity of 0 in suite" do
|
|
131
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
132
|
+
def shouldCamelCase
|
|
133
|
+
true.should be_true
|
|
134
|
+
end
|
|
135
|
+
def should_any_args(*args)
|
|
136
|
+
true.should be_true
|
|
137
|
+
end
|
|
138
|
+
def should_something
|
|
139
|
+
1.should == 1
|
|
140
|
+
end
|
|
141
|
+
def should_not_something
|
|
142
|
+
1.should_not == 2
|
|
143
|
+
end
|
|
144
|
+
def should
|
|
145
|
+
raise "This is not a real example"
|
|
146
|
+
end
|
|
147
|
+
def should_not
|
|
148
|
+
raise "This is not a real example"
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
example_group.should have(4).examples
|
|
152
|
+
descriptions = example_group.examples.collect {|example| example.description.to_s}
|
|
153
|
+
descriptions.should include(
|
|
154
|
+
"shouldCamelCase",
|
|
155
|
+
"should_any_args",
|
|
156
|
+
"should_something",
|
|
157
|
+
"should_not_something")
|
|
158
|
+
descriptions.should_not include(
|
|
159
|
+
"should",
|
|
160
|
+
"should_not"
|
|
161
|
+
)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "should not include methods that begin with test_ and has an arity > 0 in suite" do
|
|
165
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
166
|
+
def test_invalid(foo)
|
|
167
|
+
1.should == 1
|
|
168
|
+
end
|
|
169
|
+
def testInvalidCamelCase(foo)
|
|
170
|
+
1.should == 1
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
example_group.should have(:no).examples
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "should not include methods that begin with should_ and has an arity > 0 in suite" do
|
|
177
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
178
|
+
def should_invalid(foo)
|
|
179
|
+
1.should == 2
|
|
180
|
+
end
|
|
181
|
+
def shouldInvalidCamelCase(foo)
|
|
182
|
+
1.should == 3
|
|
183
|
+
end
|
|
184
|
+
def should_not_invalid(foo)
|
|
185
|
+
1.should == 4
|
|
186
|
+
end
|
|
187
|
+
def should_valid
|
|
188
|
+
1.should == 1
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
example_group.should have(1).examples
|
|
192
|
+
example_group.run(options).should be_true
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it "should run should_methods" do
|
|
196
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
197
|
+
def should_valid
|
|
198
|
+
1.should == 2
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
example_group.should have(1).examples
|
|
202
|
+
example_group.run(options).should be_false
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
describe "#set_description" do
|
|
207
|
+
attr_reader :example_group
|
|
208
|
+
before do
|
|
209
|
+
class << example_group
|
|
210
|
+
public :set_description
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
describe "given a String" do
|
|
215
|
+
before(:each) do
|
|
216
|
+
example_group.set_description("abc")
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
specify ".description should return the String passed into .set_description" do
|
|
220
|
+
example_group.description.should == "abc"
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
specify ".described_type should provide nil as its type" do
|
|
224
|
+
example_group.described_type.should be_nil
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
describe "given a Class" do
|
|
229
|
+
before(:each) do
|
|
230
|
+
example_group.set_description(ExampleGroup)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
specify ".description should return a String representation of that type (fully qualified) as its name" do
|
|
234
|
+
example_group.description.should == "Spec::Example::ExampleGroup"
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
specify ".described_type should return the passed in type" do
|
|
238
|
+
example_group.described_type.should == Spec::Example::ExampleGroup
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
describe "given a String and a Class" do
|
|
243
|
+
before(:each) do
|
|
244
|
+
example_group.set_description("behaving", ExampleGroup)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
specify ".description should return String then space then Type" do
|
|
248
|
+
example_group.description.should == "behaving Spec::Example::ExampleGroup"
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
specify ".described_type should return the passed in type" do
|
|
252
|
+
example_group.described_type.should == Spec::Example::ExampleGroup
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
describe "given a Class and a String (starting with an alpha char)" do
|
|
257
|
+
before(:each) do
|
|
258
|
+
example_group.set_description(ExampleGroup, "behaving")
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
specify ".description should return the Type then space then String" do
|
|
262
|
+
example_group.description.should == "Spec::Example::ExampleGroup behaving"
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
describe "given a Class and a String (starting with a '.')" do
|
|
267
|
+
before(:each) do
|
|
268
|
+
example_group.set_description(ExampleGroup, ".behaving")
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
specify ".description should return the Type then String" do
|
|
272
|
+
example_group.description.should == "Spec::Example::ExampleGroup.behaving"
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
describe "#set_description(Class, String starting with #)" do
|
|
277
|
+
before(:each) do
|
|
278
|
+
example_group.set_description(ExampleGroup, "#behaving")
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
specify "should return the Class then String" do
|
|
282
|
+
example_group.description.should == "Spec::Example::ExampleGroup#behaving"
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
describe "#set_description(Class, String containing .)" do
|
|
287
|
+
before(:each) do
|
|
288
|
+
example_group.set_description(ExampleGroup, "calling a.b")
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
specify ".description should return the Type then space then String" do
|
|
292
|
+
example_group.description.should == "Spec::Example::ExampleGroup calling a.b"
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
describe "#set_description(Class, String containing #)" do
|
|
297
|
+
before(:each) do
|
|
298
|
+
example_group.set_description(ExampleGroup, "is #1")
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
specify ".description should return the Type then space then String" do
|
|
302
|
+
example_group.description.should == "Spec::Example::ExampleGroup is #1"
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
describe "#set_description(String, Type, String)" do
|
|
307
|
+
before(:each) do
|
|
308
|
+
example_group.set_description("A", Hash, "with one entry")
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
specify ".description should return the first String then space then Type then second String" do
|
|
312
|
+
example_group.description.should == "A Hash with one entry"
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
describe "#set_description(Hash representing options)" do
|
|
317
|
+
before(:each) do
|
|
318
|
+
example_group.set_description(:a => "b", :spec_path => "blah")
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
it ".spec_path should expand the passed in :spec_path option passed into the constructor" do
|
|
322
|
+
example_group.spec_path.should == File.expand_path("blah")
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it ".description_options should return all the options passed in" do
|
|
326
|
+
example_group.description_options.should == {:a => "b", :spec_path => "blah"}
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
describe "#description" do
|
|
333
|
+
it "should return the same description instance for each call" do
|
|
334
|
+
example_group.description.should eql(example_group.description)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
it "should not add a space when description_text begins with #" do
|
|
338
|
+
child_example_group = Class.new(example_group) do
|
|
339
|
+
describe("#foobar", "Does something")
|
|
340
|
+
end
|
|
341
|
+
child_example_group.description.should == "ExampleGroup#foobar Does something"
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
it "should not add a space when description_text begins with ." do
|
|
345
|
+
child_example_group = Class.new(example_group) do
|
|
346
|
+
describe(".foobar", "Does something")
|
|
347
|
+
end
|
|
348
|
+
child_example_group.description.should == "ExampleGroup.foobar Does something"
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
it "should return the class name if nil" do
|
|
352
|
+
example_group.set_description(nil)
|
|
353
|
+
example_group.description.should =~ /Class:/
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
it "should return the class name if nil" do
|
|
357
|
+
example_group.set_description("")
|
|
358
|
+
example_group.description.should =~ /Class:/
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
it "is cached" do
|
|
362
|
+
example_group.set_description("describe me")
|
|
363
|
+
example_group.description.should be(example_group.description)
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
describe "#description_parts" do
|
|
368
|
+
it "should return an Array of the current class description args" do
|
|
369
|
+
example_group.description_parts.should == [example_group.description]
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
it "should return an Array of the description args from each class in the hierarchy" do
|
|
373
|
+
parent_example_group = Class.new(ExampleGroupDouble) do
|
|
374
|
+
describe("Parent")
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
child_example_group = Class.new(parent_example_group)
|
|
378
|
+
child_example_group.describe("Child", ExampleGroup)
|
|
379
|
+
child_example_group.description.should_not be_empty
|
|
380
|
+
|
|
381
|
+
grand_child_example_group = Class.new(child_example_group)
|
|
382
|
+
grand_child_example_group.describe("GrandChild", ExampleGroup)
|
|
383
|
+
grand_child_example_group.description.should_not be_empty
|
|
384
|
+
|
|
385
|
+
grand_child_example_group.description_parts.should == [
|
|
386
|
+
"Parent",
|
|
387
|
+
"Child",
|
|
388
|
+
Spec::Example::ExampleGroup,
|
|
389
|
+
"GrandChild",
|
|
390
|
+
Spec::Example::ExampleGroup
|
|
391
|
+
]
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
it "caches the description parts" do
|
|
395
|
+
example_group.description_parts.should equal(example_group.description_parts)
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
describe "#described_type" do
|
|
400
|
+
it "should return passed in type" do
|
|
401
|
+
child_example_group = Class.new(example_group) do
|
|
402
|
+
describe Object
|
|
403
|
+
end
|
|
404
|
+
child_example_group.described_type.should == Object
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
it "should return #described_type of superclass when no passed in type" do
|
|
408
|
+
parent_example_group = Class.new(ExampleGroupDouble) do
|
|
409
|
+
describe Object, "#foobar"
|
|
410
|
+
end
|
|
411
|
+
child_example_group = Class.new(parent_example_group) do
|
|
412
|
+
describe "not a type"
|
|
413
|
+
end
|
|
414
|
+
child_example_group.described_type.should == Object
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
it "is cached per example group" do
|
|
418
|
+
klass = Class.new
|
|
419
|
+
group = Class.new(ExampleGroupDouble) do
|
|
420
|
+
describe(klass)
|
|
421
|
+
end
|
|
422
|
+
group.should_receive(:description_parts).once.and_return([klass])
|
|
423
|
+
group.described_type
|
|
424
|
+
group.described_type
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
describe "#remove_after" do
|
|
429
|
+
it "should unregister a given after(:each) block" do
|
|
430
|
+
after_all_ran = false
|
|
431
|
+
proc = Proc.new { after_all_ran = true }
|
|
432
|
+
|
|
433
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
434
|
+
specify("example") {}
|
|
435
|
+
after(:each, &proc)
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
example_group.run(options)
|
|
439
|
+
after_all_ran.should be_true
|
|
440
|
+
|
|
441
|
+
after_all_ran = false
|
|
442
|
+
example_group.remove_after(:each, &proc)
|
|
443
|
+
example_group.run(options)
|
|
444
|
+
after_all_ran.should be_false
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
describe "#include" do
|
|
449
|
+
it "should have accessible class methods from included module" do
|
|
450
|
+
mod_method_called = false
|
|
451
|
+
mod = Module.new do
|
|
452
|
+
class_methods = Module.new do
|
|
453
|
+
define_method :mod_method do
|
|
454
|
+
mod_method_called = true
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
self.class.class_eval do
|
|
459
|
+
define_method(:included) do |receiver|
|
|
460
|
+
receiver.extend class_methods
|
|
461
|
+
end
|
|
462
|
+
end
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
@example_group.__send__ :include, mod
|
|
466
|
+
|
|
467
|
+
@example_group.mod_method
|
|
468
|
+
mod_method_called.should be_true
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
describe "#number_of_examples" do
|
|
473
|
+
it "should count number of examples" do
|
|
474
|
+
proc do
|
|
475
|
+
@example_group.it("one") {}
|
|
476
|
+
@example_group.it("two") {}
|
|
477
|
+
@example_group.it("three") {}
|
|
478
|
+
@example_group.it("four") {}
|
|
479
|
+
end.should change {@example_group.number_of_examples}.by(4)
|
|
480
|
+
end
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
describe "#class_eval" do
|
|
484
|
+
it "should allow constants to be defined" do
|
|
485
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
486
|
+
FOO = 1
|
|
487
|
+
it "should reference FOO" do
|
|
488
|
+
FOO.should == 1
|
|
489
|
+
end
|
|
490
|
+
end
|
|
491
|
+
success = example_group.run(options)
|
|
492
|
+
success.should be_true
|
|
493
|
+
Object.const_defined?(:FOO).should == false
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
describe '#register' do
|
|
498
|
+
after(:each) do
|
|
499
|
+
Spec::Runner.options.remove_example_group example_group
|
|
500
|
+
end
|
|
501
|
+
it "should add ExampleGroup to set of ExampleGroups to be run" do
|
|
502
|
+
Spec::Runner.options.add_example_group example_group
|
|
503
|
+
options.example_groups.should include(example_group)
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
describe '#remove_example_group' do
|
|
508
|
+
before(:each) do
|
|
509
|
+
Spec::Runner.options.add_example_group example_group
|
|
510
|
+
end
|
|
511
|
+
it "should remove ExampleGroup from set of ExampleGroups to be run" do
|
|
512
|
+
Spec::Runner.options.remove_example_group example_group
|
|
513
|
+
options.example_groups.should_not include(example_group)
|
|
514
|
+
end
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
describe "#run" do
|
|
518
|
+
describe "given an example group with at least one example" do
|
|
519
|
+
it "should call add_example_group" do
|
|
520
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
521
|
+
example("anything") {}
|
|
522
|
+
end
|
|
523
|
+
reporter.should_receive(:add_example_group)
|
|
524
|
+
example_group.run(options)
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
describe "given an example group with no examples" do
|
|
529
|
+
it "should NOT call add_example_group" do
|
|
530
|
+
example_group = Class.new(ExampleGroupDouble) do end
|
|
531
|
+
reporter.should_not_receive(:add_example_group)
|
|
532
|
+
example_group.run(options)
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
describe "#matcher_class=" do
|
|
538
|
+
it "should call new and matches? on the class used for matching examples" do
|
|
539
|
+
example_group = Class.new(ExampleGroupDouble) do
|
|
540
|
+
it "should do something" do end
|
|
541
|
+
def self.specified_examples
|
|
542
|
+
["something"]
|
|
543
|
+
end
|
|
544
|
+
def self.to_s
|
|
545
|
+
"TestMatcher"
|
|
546
|
+
end
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
matcher = mock("matcher")
|
|
550
|
+
matcher.should_receive(:matches?).with(["something"]).any_number_of_times
|
|
551
|
+
|
|
552
|
+
matcher_class = Class.new
|
|
553
|
+
matcher_class.should_receive(:new).with("TestMatcher", "should do something").and_return(matcher)
|
|
554
|
+
|
|
555
|
+
begin
|
|
556
|
+
ExampleGroupMethods.matcher_class = matcher_class
|
|
557
|
+
|
|
558
|
+
example_group.run(options)
|
|
559
|
+
ensure
|
|
560
|
+
ExampleGroupMethods.matcher_class = ExampleMatcher
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
describe "#options" do
|
|
566
|
+
it "should expose the options hash" do
|
|
567
|
+
group = describe("group", :this => 'hash') {}
|
|
568
|
+
group.options[:this].should == 'hash'
|
|
569
|
+
end
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
describe "#backtrace" do
|
|
573
|
+
it "returns the backtrace from where the example group was defined" do
|
|
574
|
+
example_group = Class.new(ExampleGroupDouble).describe("foo") do
|
|
575
|
+
example "bar" do; end
|
|
576
|
+
end
|
|
577
|
+
example_group.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
|
578
|
+
end
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
describe "#example_group_backtrace (deprecated)" do
|
|
582
|
+
before(:each) do
|
|
583
|
+
Kernel.stub!(:warn)
|
|
584
|
+
end
|
|
585
|
+
it "sends a deprecation warning" do
|
|
586
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
|
587
|
+
Kernel.should_receive(:warn).with(/#example_group_backtrace.*deprecated.*#backtrace instead/m)
|
|
588
|
+
example_group.example_group_backtrace
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
it "returns the backtrace from where the example group was defined" do
|
|
592
|
+
example_group = Class.new(ExampleGroupDouble).describe("foo") do
|
|
593
|
+
example "bar" do; end
|
|
594
|
+
end
|
|
595
|
+
example_group.example_group_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
|
596
|
+
end
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
describe "#before" do
|
|
600
|
+
it "stores before(:each) blocks" do
|
|
601
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
|
602
|
+
block = lambda {}
|
|
603
|
+
example_group.before(:each, &block)
|
|
604
|
+
example_group.before_each_parts.should include(block)
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
it "stores before(:all) blocks" do
|
|
608
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
|
609
|
+
block = lambda {}
|
|
610
|
+
example_group.before(:all, &block)
|
|
611
|
+
example_group.before_all_parts.should include(block)
|
|
612
|
+
end
|
|
613
|
+
|
|
614
|
+
it "stores before(:suite) blocks" do
|
|
615
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
|
616
|
+
parts = []
|
|
617
|
+
ExampleGroupMethods.stub!(:before_suite_parts).and_return(parts)
|
|
618
|
+
block = lambda {}
|
|
619
|
+
example_group.before(:suite, &block)
|
|
620
|
+
example_group.before_suite_parts.should include(block)
|
|
621
|
+
end
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
describe "#after" do
|
|
626
|
+
it "stores after(:each) blocks" do
|
|
627
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
|
628
|
+
block = lambda {}
|
|
629
|
+
example_group.after(:each, &block)
|
|
630
|
+
example_group.after_each_parts.should include(block)
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
it "stores after(:all) blocks" do
|
|
634
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
|
635
|
+
block = lambda {}
|
|
636
|
+
example_group.after(:all, &block)
|
|
637
|
+
example_group.after_all_parts.should include(block)
|
|
638
|
+
end
|
|
639
|
+
|
|
640
|
+
it "stores after(:suite) blocks" do
|
|
641
|
+
example_group = Class.new(ExampleGroupDouble) {}
|
|
642
|
+
parts = []
|
|
643
|
+
ExampleGroupMethods.stub!(:after_suite_parts).and_return(parts)
|
|
644
|
+
block = lambda {}
|
|
645
|
+
example_group.after(:suite, &block)
|
|
646
|
+
example_group.after_suite_parts.should include(block)
|
|
647
|
+
end
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
end
|
|
651
|
+
end
|
|
652
|
+
end
|
|
653
|
+
end
|