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,318 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper.rb'
|
|
2
|
+
require 'spec/runner/formatter/nested_text_formatter'
|
|
3
|
+
|
|
4
|
+
module Spec
|
|
5
|
+
module Runner
|
|
6
|
+
module Formatter
|
|
7
|
+
describe NestedTextFormatter do
|
|
8
|
+
with_sandboxed_options do
|
|
9
|
+
attr_reader :io, :options, :formatter, :example_group
|
|
10
|
+
before(:each) do
|
|
11
|
+
@io = StringIO.new
|
|
12
|
+
options.stub!(:dry_run).and_return(false)
|
|
13
|
+
options.stub!(:colour).and_return(false)
|
|
14
|
+
@formatter = NestedTextFormatter.new(options, io)
|
|
15
|
+
@example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do
|
|
16
|
+
specify "example" do
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "where ExampleGroup has no superclasss with a description" do
|
|
22
|
+
before do
|
|
23
|
+
add_example_group
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_example_group
|
|
27
|
+
formatter.add_example_group(example_group)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#dump_summary" do
|
|
31
|
+
it "should produce standard summary without pending when pending has a 0 count" do
|
|
32
|
+
formatter.dump_summary(3, 2, 1, 0)
|
|
33
|
+
io.string.should == <<-OUT
|
|
34
|
+
ExampleGroup
|
|
35
|
+
|
|
36
|
+
Finished in 3 seconds
|
|
37
|
+
|
|
38
|
+
2 examples, 1 failure
|
|
39
|
+
OUT
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should produce standard summary" do
|
|
43
|
+
formatter.dump_summary(3, 2, 1, 4)
|
|
44
|
+
io.string.should == <<-OUT
|
|
45
|
+
ExampleGroup
|
|
46
|
+
|
|
47
|
+
Finished in 3 seconds
|
|
48
|
+
|
|
49
|
+
2 examples, 1 failure, 4 pending
|
|
50
|
+
OUT
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe "#add_example_group" do
|
|
55
|
+
describe "when ExampleGroup has description_args" do
|
|
56
|
+
before do
|
|
57
|
+
example_group.description_args.should_not be_nil
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "when ExampleGroup has no parents with description args" do
|
|
61
|
+
before do
|
|
62
|
+
example_group.superclass.description_args.should be_empty
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should push ExampleGroup name" do
|
|
66
|
+
io.string.should eql("ExampleGroup\n")
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "when ExampleGroup has one parent with description args" do
|
|
71
|
+
attr_reader :child_example_group
|
|
72
|
+
def add_example_group
|
|
73
|
+
example_group.description_args.should_not be_nil
|
|
74
|
+
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe "and parent ExampleGroups have not been printed" do
|
|
78
|
+
before do
|
|
79
|
+
formatter.add_example_group(child_example_group)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should push ExampleGroup name with two spaces of indentation" do
|
|
83
|
+
io.string.should == <<-OUT
|
|
84
|
+
ExampleGroup
|
|
85
|
+
Child ExampleGroup
|
|
86
|
+
OUT
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "and parent ExampleGroups have been printed" do
|
|
91
|
+
before do
|
|
92
|
+
formatter.add_example_group(example_group)
|
|
93
|
+
io.string = ""
|
|
94
|
+
formatter.add_example_group(child_example_group)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should print only the indented ExampleGroup" do
|
|
98
|
+
io.string.should == <<-OUT
|
|
99
|
+
Child ExampleGroup
|
|
100
|
+
OUT
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe "when ExampleGroup has two parents with description args" do
|
|
106
|
+
attr_reader :child_example_group, :grand_child_example_group
|
|
107
|
+
def add_example_group
|
|
108
|
+
example_group.description_args.should_not be_nil
|
|
109
|
+
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
110
|
+
@grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe "and parent ExampleGroups have not been printed" do
|
|
114
|
+
before do
|
|
115
|
+
formatter.add_example_group(grand_child_example_group)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should print the entire nested ExampleGroup heirarchy" do
|
|
119
|
+
io.string.should == <<-OUT
|
|
120
|
+
ExampleGroup
|
|
121
|
+
Child ExampleGroup
|
|
122
|
+
GrandChild ExampleGroup
|
|
123
|
+
OUT
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe "and parent ExampleGroups have been printed" do
|
|
128
|
+
before do
|
|
129
|
+
formatter.add_example_group(child_example_group)
|
|
130
|
+
io.string = ""
|
|
131
|
+
formatter.add_example_group(grand_child_example_group)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should print only the indented ExampleGroup" do
|
|
135
|
+
io.string.should == <<-OUT
|
|
136
|
+
GrandChild ExampleGroup
|
|
137
|
+
OUT
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
describe "when ExampleGroup description_args is nil" do
|
|
144
|
+
attr_reader :child_example_group
|
|
145
|
+
|
|
146
|
+
describe "and parent ExampleGroups have not been printed" do
|
|
147
|
+
def add_example_group
|
|
148
|
+
@child_example_group = Class.new(example_group)
|
|
149
|
+
child_example_group.description_args.should be_empty
|
|
150
|
+
formatter.add_example_group(child_example_group)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "should render only the parent ExampleGroup" do
|
|
154
|
+
io.string.should == <<-OUT
|
|
155
|
+
ExampleGroup
|
|
156
|
+
OUT
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
describe "and parent ExampleGroups have been printed" do
|
|
161
|
+
def add_example_group
|
|
162
|
+
@child_example_group = Class.new(example_group)
|
|
163
|
+
child_example_group.description_args.should be_empty
|
|
164
|
+
formatter.add_example_group(example_group)
|
|
165
|
+
io.string = ""
|
|
166
|
+
formatter.add_example_group(child_example_group)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "should not render anything" do
|
|
170
|
+
io.string.should == ""
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
describe "when ExampleGroup description_args is empty" do
|
|
176
|
+
def add_example_group
|
|
177
|
+
example_group.set_description
|
|
178
|
+
example_group.description_args.should be_empty
|
|
179
|
+
super
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "should not render anything" do
|
|
183
|
+
io.string.should == ""
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
describe "#example_failed" do
|
|
189
|
+
describe "where ExampleGroup has no superclasss with a description" do
|
|
190
|
+
describe "when having an error" do
|
|
191
|
+
it "should push failing spec name and failure number" do
|
|
192
|
+
formatter.example_failed(
|
|
193
|
+
example_group.it("spec"),
|
|
194
|
+
98,
|
|
195
|
+
::Spec::Runner::Reporter::Failure.new("c s", RuntimeError.new)
|
|
196
|
+
)
|
|
197
|
+
io.string.should == <<-OUT
|
|
198
|
+
ExampleGroup
|
|
199
|
+
spec (ERROR - 98)
|
|
200
|
+
OUT
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
describe "when having an expectation failure" do
|
|
205
|
+
it "should push failing spec name and failure number" do
|
|
206
|
+
formatter.example_failed(
|
|
207
|
+
example_group.it("spec"),
|
|
208
|
+
98,
|
|
209
|
+
::Spec::Runner::Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
|
|
210
|
+
)
|
|
211
|
+
io.string.should == <<-OUT
|
|
212
|
+
ExampleGroup
|
|
213
|
+
spec (FAILED - 98)
|
|
214
|
+
OUT
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
describe "where ExampleGroup has two superclasses with a description" do
|
|
220
|
+
attr_reader :child_example_group, :grand_child_example_group
|
|
221
|
+
|
|
222
|
+
def add_example_group
|
|
223
|
+
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
224
|
+
@grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
|
|
225
|
+
formatter.add_example_group(grand_child_example_group)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
describe "when having an error" do
|
|
229
|
+
it "should push failing spec name and failure number" do
|
|
230
|
+
formatter.example_failed(
|
|
231
|
+
grand_child_example_group.it("spec"),
|
|
232
|
+
98,
|
|
233
|
+
::Spec::Runner::Reporter::Failure.new("c s", RuntimeError.new)
|
|
234
|
+
)
|
|
235
|
+
io.string.should == <<-OUT
|
|
236
|
+
ExampleGroup
|
|
237
|
+
Child ExampleGroup
|
|
238
|
+
GrandChild ExampleGroup
|
|
239
|
+
spec (ERROR - 98)
|
|
240
|
+
OUT
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
describe "when having an expectation" do
|
|
245
|
+
it "should push failing spec name and failure number" do
|
|
246
|
+
formatter.example_failed(
|
|
247
|
+
grand_child_example_group.it("spec"),
|
|
248
|
+
98,
|
|
249
|
+
::Spec::Runner::Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
|
|
250
|
+
)
|
|
251
|
+
io.string.should == <<-OUT
|
|
252
|
+
ExampleGroup
|
|
253
|
+
Child ExampleGroup
|
|
254
|
+
GrandChild ExampleGroup
|
|
255
|
+
spec (FAILED - 98)
|
|
256
|
+
OUT
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
describe "#start" do
|
|
263
|
+
it "should push nothing on start" do
|
|
264
|
+
formatter.start(5)
|
|
265
|
+
io.string.should == <<-OUT
|
|
266
|
+
ExampleGroup
|
|
267
|
+
OUT
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
describe "#start_dump" do
|
|
272
|
+
it "should push nothing on start dump" do
|
|
273
|
+
formatter.start_dump
|
|
274
|
+
io.string.should == <<-OUT
|
|
275
|
+
ExampleGroup
|
|
276
|
+
OUT
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
describe "#example_passed" do
|
|
281
|
+
it "should push passing spec name" do
|
|
282
|
+
formatter.example_passed(example_group.it("spec"))
|
|
283
|
+
io.string.should == <<-OUT
|
|
284
|
+
ExampleGroup
|
|
285
|
+
spec
|
|
286
|
+
OUT
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
describe "#example_pending" do
|
|
291
|
+
it "should push pending example name and message" do
|
|
292
|
+
formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}")
|
|
293
|
+
io.string.should == <<-OUT
|
|
294
|
+
ExampleGroup
|
|
295
|
+
example (PENDING: reason)
|
|
296
|
+
OUT
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
it "should dump pending" do
|
|
300
|
+
formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}")
|
|
301
|
+
io.rewind
|
|
302
|
+
formatter.dump_pending
|
|
303
|
+
io.string.should =~ /Pending\:\n\nExampleGroup example \(reason\)\n/
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def have_single_level_example_group_output(expected_output)
|
|
308
|
+
expected = "ExampleGroup\n #{expected_output}"
|
|
309
|
+
::Spec::Matchers::SimpleMatcher.new(expected) do |actual|
|
|
310
|
+
actual == expected
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper.rb'
|
|
2
|
+
require 'spec/runner/formatter/profile_formatter'
|
|
3
|
+
|
|
4
|
+
module Spec
|
|
5
|
+
module Runner
|
|
6
|
+
module Formatter
|
|
7
|
+
describe ProfileFormatter do
|
|
8
|
+
attr_reader :io, :formatter
|
|
9
|
+
before(:each) do
|
|
10
|
+
@io = StringIO.new
|
|
11
|
+
options = mock('options')
|
|
12
|
+
options.stub!(:colour).and_return(true)
|
|
13
|
+
@formatter = ProfileFormatter.new(options, io)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should print a heading" do
|
|
17
|
+
formatter.start(0)
|
|
18
|
+
io.string.should eql("Profiling enabled.\n")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should record the current time when starting a new example" do
|
|
22
|
+
now = Time.now
|
|
23
|
+
Time.stub!(:now).and_return(now)
|
|
24
|
+
formatter.example_started('should foo')
|
|
25
|
+
formatter.instance_variable_get("@time").should == now
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should correctly record a passed example" do
|
|
29
|
+
now = Time.now
|
|
30
|
+
Time.stub!(:now).and_return(now)
|
|
31
|
+
parent_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe('Parent')
|
|
32
|
+
child_example_group = Class.new(parent_example_group).describe('Child')
|
|
33
|
+
|
|
34
|
+
formatter.add_example_group(child_example_group)
|
|
35
|
+
|
|
36
|
+
formatter.example_started('when foo')
|
|
37
|
+
Time.stub!(:now).and_return(now+1)
|
|
38
|
+
formatter.example_passed(stub('foo', :description => 'i like ice cream'))
|
|
39
|
+
|
|
40
|
+
formatter.start_dump
|
|
41
|
+
io.string.should include('Parent Child')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should sort the results in descending order" do
|
|
45
|
+
formatter.instance_variable_set("@example_times", [['a', 'a', 0.1], ['b', 'b', 0.3], ['c', 'c', 0.2]])
|
|
46
|
+
formatter.start_dump
|
|
47
|
+
formatter.instance_variable_get("@example_times").should == [ ['b', 'b', 0.3], ['c', 'c', 0.2], ['a', 'a', 0.1]]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should print the top 10 results" do
|
|
51
|
+
example_group = Class.new(::Spec::Example::ExampleGroup).describe("ExampleGroup")
|
|
52
|
+
formatter.add_example_group(example_group)
|
|
53
|
+
formatter.instance_variable_set("@time", Time.now)
|
|
54
|
+
|
|
55
|
+
15.times do
|
|
56
|
+
formatter.example_passed(stub('foo', :description => 'i like ice cream'))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
io.should_receive(:print).exactly(10)
|
|
60
|
+
formatter.start_dump
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper.rb'
|
|
2
|
+
require 'spec/runner/formatter/progress_bar_formatter'
|
|
3
|
+
|
|
4
|
+
module Spec
|
|
5
|
+
module Runner
|
|
6
|
+
module Formatter
|
|
7
|
+
describe ProgressBarFormatter do
|
|
8
|
+
before(:each) do
|
|
9
|
+
@io = StringIO.new
|
|
10
|
+
@options = mock('options')
|
|
11
|
+
@options.stub!(:dry_run).and_return(false)
|
|
12
|
+
@options.stub!(:colour).and_return(false)
|
|
13
|
+
@formatter = ProgressBarFormatter.new(@options, @io)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should produce line break on start dump" do
|
|
17
|
+
@formatter.start_dump
|
|
18
|
+
@io.string.should eql("\n")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should produce standard summary without pending when pending has a 0 count" do
|
|
22
|
+
@formatter.dump_summary(3, 2, 1, 0)
|
|
23
|
+
@io.string.should eql("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should produce standard summary" do
|
|
27
|
+
example_group = ExampleGroup.describe("example_group") do
|
|
28
|
+
specify "example" do
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
example = example_group.examples.first
|
|
32
|
+
@formatter.example_pending(example, "message", "#{__FILE__}:#{__LINE__}")
|
|
33
|
+
@io.rewind
|
|
34
|
+
@formatter.dump_summary(3, 2, 1, 1)
|
|
35
|
+
@io.string.should eql(%Q|
|
|
36
|
+
Finished in 3 seconds
|
|
37
|
+
|
|
38
|
+
2 examples, 1 failure, 1 pending
|
|
39
|
+
|)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should push green dot for passing spec" do
|
|
43
|
+
@io.should_receive(:tty?).and_return(true)
|
|
44
|
+
@options.should_receive(:colour).and_return(true)
|
|
45
|
+
@formatter.example_passed("spec")
|
|
46
|
+
@io.string.should == "\e[32m.\e[0m"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should push red F for failure spec" do
|
|
50
|
+
@io.should_receive(:tty?).and_return(true)
|
|
51
|
+
@options.should_receive(:colour).and_return(true)
|
|
52
|
+
@formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new))
|
|
53
|
+
@io.string.should eql("\e[31mF\e[0m")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should push magenta F for error spec" do
|
|
57
|
+
@io.should_receive(:tty?).and_return(true)
|
|
58
|
+
@options.should_receive(:colour).and_return(true)
|
|
59
|
+
@formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("c s", RuntimeError.new))
|
|
60
|
+
@io.string.should eql("\e[35mF\e[0m")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should push blue F for fixed pending spec" do
|
|
64
|
+
@io.should_receive(:tty?).and_return(true)
|
|
65
|
+
@options.should_receive(:colour).and_return(true)
|
|
66
|
+
@formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("c s", Spec::Example::PendingExampleFixedError.new))
|
|
67
|
+
@io.string.should eql("\e[34mF\e[0m")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should push nothing on start" do
|
|
71
|
+
@formatter.start(4)
|
|
72
|
+
@io.string.should eql("")
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "should ensure two ':' in the first backtrace" do
|
|
76
|
+
backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
|
77
|
+
@formatter.format_backtrace(backtrace).should eql(<<-EOE.rstrip)
|
|
78
|
+
/tmp/x.rb:1:
|
|
79
|
+
/tmp/x.rb:2:
|
|
80
|
+
/tmp/x.rb:3:
|
|
81
|
+
EOE
|
|
82
|
+
|
|
83
|
+
backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
|
84
|
+
@formatter.format_backtrace(backtrace).should eql(<<-EOE.rstrip)
|
|
85
|
+
/tmp/x.rb:1: message
|
|
86
|
+
/tmp/x.rb:2:
|
|
87
|
+
/tmp/x.rb:3:
|
|
88
|
+
EOE
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should dump pending with file and line number" do
|
|
92
|
+
example_group = ExampleGroup.describe("example_group") do
|
|
93
|
+
specify "example" do
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
example = example_group.examples.first
|
|
97
|
+
file = __FILE__
|
|
98
|
+
line = __LINE__ + 1
|
|
99
|
+
@formatter.example_pending(example, "message", "#{__FILE__}:#{__LINE__}")
|
|
100
|
+
@formatter.dump_pending
|
|
101
|
+
@io.string.should ==(<<-HERE)
|
|
102
|
+
*
|
|
103
|
+
Pending:
|
|
104
|
+
|
|
105
|
+
example_group example (message)
|
|
106
|
+
#{file}:#{line}
|
|
107
|
+
HERE
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
describe "ProgressBarFormatter outputting to custom out" do
|
|
112
|
+
before(:each) do
|
|
113
|
+
@out = mock("out")
|
|
114
|
+
@options = mock('options')
|
|
115
|
+
@out.stub!(:puts)
|
|
116
|
+
@formatter = ProgressBarFormatter.new(@options, @out)
|
|
117
|
+
@formatter.class.__send__ :public, :output_to_tty?
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
after(:each) do
|
|
121
|
+
@formatter.class.__send__ :protected, :output_to_tty?
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should not throw NoMethodError on output_to_tty?" do
|
|
125
|
+
@out.should_receive(:tty?).and_raise(NoMethodError)
|
|
126
|
+
@formatter.output_to_tty?.should be_false
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe ProgressBarFormatter, "dry run" do
|
|
131
|
+
before(:each) do
|
|
132
|
+
@io = StringIO.new
|
|
133
|
+
options = mock('options')
|
|
134
|
+
options.stub!(:dry_run).and_return(true)
|
|
135
|
+
@formatter = ProgressBarFormatter.new(options, @io)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it "should not produce summary on dry run" do
|
|
139
|
+
@formatter.dump_summary(3, 2, 1, 0)
|
|
140
|
+
@io.string.should eql("")
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper.rb'
|
|
2
|
+
require 'spec/runner/formatter/snippet_extractor'
|
|
3
|
+
|
|
4
|
+
module Spec
|
|
5
|
+
module Runner
|
|
6
|
+
module Formatter
|
|
7
|
+
describe SnippetExtractor do
|
|
8
|
+
it "should fall back on a default message when it doesn't understand a line" do
|
|
9
|
+
SnippetExtractor.new.snippet_for("blech").should == ["# Couldn't get snippet for blech", 1]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should fall back on a default message when it doesn't find the file" do
|
|
13
|
+
SnippetExtractor.new.lines_around("blech", 8).should == "# Couldn't get snippet for blech"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
|
+
begin
|
|
3
|
+
require 'nokogiri' # Needed to compare generated with wanted HTML
|
|
4
|
+
rescue LoadError
|
|
5
|
+
warn "nokogiri not loaded -- skipping TextMateFormatter specs"
|
|
6
|
+
return
|
|
7
|
+
end
|
|
8
|
+
require 'spec/runner/formatter/text_mate_formatter'
|
|
9
|
+
|
|
10
|
+
module Spec
|
|
11
|
+
module Runner
|
|
12
|
+
module Formatter
|
|
13
|
+
describe TextMateFormatter do
|
|
14
|
+
attr_reader :root, :suffix, :expected_file
|
|
15
|
+
before do
|
|
16
|
+
@root = File.expand_path(File.dirname(__FILE__) + '/../../../..')
|
|
17
|
+
@suffix = jruby? ? '-jruby' : ''
|
|
18
|
+
@expected_file = File.dirname(__FILE__) + "/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def produces_html_identical_to_manually_designed_document(opt)
|
|
22
|
+
root = File.expand_path(File.dirname(__FILE__) + '/../../../..')
|
|
23
|
+
|
|
24
|
+
Dir.chdir(root) do
|
|
25
|
+
args = [
|
|
26
|
+
'examples/failing/mocking_example.rb',
|
|
27
|
+
'examples/failing/diffing_spec.rb',
|
|
28
|
+
'examples/passing/stubbing_example.rb',
|
|
29
|
+
'examples/passing/pending_example.rb',
|
|
30
|
+
'--format',
|
|
31
|
+
'textmate',
|
|
32
|
+
opt
|
|
33
|
+
]
|
|
34
|
+
err = StringIO.new
|
|
35
|
+
out = StringIO.new
|
|
36
|
+
|
|
37
|
+
run_with ::Spec::Runner::OptionParser.parse(args, err, out)
|
|
38
|
+
|
|
39
|
+
yield(out.string)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# # Uncomment this spec temporarily in order to overwrite the expected with actual.
|
|
44
|
+
# # Use with care!!!
|
|
45
|
+
# describe "functional spec file generator" do
|
|
46
|
+
# it "generates a new comparison file" do
|
|
47
|
+
# Dir.chdir(root) do
|
|
48
|
+
# args = ['examples/failing/mocking_example.rb', 'examples/failing/diffing_spec.rb', 'examples/passing/stubbing_example.rb', 'examples/passing/pending_example.rb', '--format', 'textmate', '--diff']
|
|
49
|
+
# err = StringIO.new
|
|
50
|
+
# out = StringIO.new
|
|
51
|
+
# Spec::Runner::CommandLine.run(
|
|
52
|
+
# ::Spec::Runner::OptionParser.parse(args, err, out)
|
|
53
|
+
# )
|
|
54
|
+
#
|
|
55
|
+
# seconds = /\d+\.\d+ seconds/
|
|
56
|
+
# html = out.string.gsub seconds, 'x seconds'
|
|
57
|
+
#
|
|
58
|
+
# File.open(expected_file, 'w') {|io| io.write(html)}
|
|
59
|
+
# end
|
|
60
|
+
# end
|
|
61
|
+
# end
|
|
62
|
+
|
|
63
|
+
describe "functional spec using --diff" do
|
|
64
|
+
it "should produce HTML identical to the one we designed manually with --diff" do
|
|
65
|
+
produces_html_identical_to_manually_designed_document("--diff") do |html|
|
|
66
|
+
suffix = jruby? ? '-jruby' : ''
|
|
67
|
+
expected_file = File.dirname(__FILE__) + "/text_mate_formatted-#{::VERSION}#{suffix}.html"
|
|
68
|
+
unless File.file?(expected_file)
|
|
69
|
+
raise "There is no HTML file with expected content for this platform: #{expected_file}"
|
|
70
|
+
end
|
|
71
|
+
expected_html = File.read(expected_file)
|
|
72
|
+
|
|
73
|
+
seconds = /\d+\.\d+ seconds/
|
|
74
|
+
html.gsub! seconds, 'x seconds'
|
|
75
|
+
expected_html.gsub! seconds, 'x seconds'
|
|
76
|
+
|
|
77
|
+
doc = Nokogiri::HTML(html)
|
|
78
|
+
backtraces = doc.search("div.backtrace a")
|
|
79
|
+
doc.search("div.backtrace").remove
|
|
80
|
+
|
|
81
|
+
expected_doc = Nokogiri::HTML(expected_html)
|
|
82
|
+
expected_doc.search("div.backtrace").remove
|
|
83
|
+
|
|
84
|
+
doc.inner_html.should == expected_doc.inner_html
|
|
85
|
+
|
|
86
|
+
backtraces.each do |backtrace_link|
|
|
87
|
+
backtrace_link['href'].should include("txmt://open?url=")
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "functional spec using --dry-run" do
|
|
95
|
+
it "should produce HTML identical to the one we designed manually with --dry-run" do
|
|
96
|
+
produces_html_identical_to_manually_designed_document("--dry-run") do |html, expected_html|
|
|
97
|
+
html.should =~ /This was a dry-run/m
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|