rspec 0.8.2 → 0.9.0
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/CHANGES +125 -9
- data/EXAMPLES.rd +50 -27
- data/README +14 -1
- data/Rakefile +95 -42
- data/UPGRADE +31 -0
- data/bin/spec +0 -1
- data/bin/spec_translator +6 -0
- data/examples/auto_spec_description_example.rb +19 -0
- data/examples/{setup_teardown_example.rb → before_and_after_example.rb} +6 -6
- data/examples/behave_as_example.rb +45 -0
- data/examples/custom_expectation_matchers.rb +13 -12
- data/examples/dynamic_spec.rb +2 -2
- data/examples/file_accessor_spec.rb +2 -2
- data/examples/greeter_spec.rb +3 -3
- data/examples/helper_method_example.rb +2 -2
- data/examples/io_processor_spec.rb +4 -4
- data/examples/legacy_spec.rb +10 -0
- data/examples/mocking_example.rb +5 -5
- data/examples/multi_threaded_behaviour_runner.rb +25 -0
- data/examples/partial_mock_example.rb +4 -4
- data/examples/predicate_example.rb +4 -4
- data/examples/priority.txt +1 -0
- data/examples/shared_behaviours_example.rb +31 -0
- data/examples/stack_spec.rb +52 -69
- data/examples/stubbing_example.rb +10 -10
- data/examples/test_case_adapter_example.rb +26 -0
- data/examples/test_case_spec.rb +6 -6
- data/lib/spec.rb +9 -4
- data/lib/spec/dsl.rb +10 -0
- data/lib/spec/dsl/behaviour.rb +189 -0
- data/lib/spec/dsl/behaviour_callbacks.rb +43 -0
- data/lib/spec/dsl/behaviour_eval.rb +170 -0
- data/lib/spec/dsl/behaviour_factory.rb +32 -0
- data/lib/spec/dsl/composite_proc_builder.rb +28 -0
- data/lib/spec/dsl/configuration.rb +38 -0
- data/lib/spec/dsl/description.rb +34 -0
- data/lib/spec/dsl/example.rb +114 -0
- data/lib/spec/dsl/example_matcher.rb +28 -0
- data/lib/spec/{runner/spec_should_raise_handler.rb → dsl/example_should_raise_handler.rb} +4 -4
- data/lib/spec/expectations.rb +0 -3
- data/lib/spec/expectations/differs/default.rb +0 -1
- data/lib/spec/expectations/extensions.rb +0 -1
- data/lib/spec/expectations/extensions/object.rb +10 -53
- data/lib/spec/expectations/handler.rb +14 -18
- data/lib/spec/extensions.rb +1 -0
- data/lib/spec/extensions/object.rb +6 -0
- data/lib/spec/matchers.rb +19 -21
- data/lib/spec/matchers/be.rb +40 -11
- data/lib/spec/matchers/be_close.rb +2 -2
- data/lib/spec/matchers/operator_matcher.rb +52 -0
- data/lib/spec/matchers/respond_to.rb +21 -11
- data/lib/spec/mocks.rb +5 -28
- data/lib/spec/mocks/argument_constraint_matchers.rb +12 -0
- data/lib/spec/mocks/argument_expectation.rb +7 -4
- data/lib/spec/mocks/methods.rb +11 -16
- data/lib/spec/mocks/mock.rb +6 -3
- data/lib/spec/mocks/{mock_handler.rb → proxy.rb} +4 -7
- data/lib/spec/mocks/space.rb +28 -0
- data/lib/spec/mocks/spec_methods.rb +30 -0
- data/lib/spec/rake/spectask.rb +23 -21
- data/lib/spec/rake/verify_rcov.rb +1 -0
- data/lib/spec/runner.rb +88 -35
- data/lib/spec/runner/backtrace_tweaker.rb +2 -1
- data/lib/spec/runner/behaviour_runner.rb +102 -0
- data/lib/spec/runner/command_line.rb +5 -17
- data/lib/spec/runner/drb_command_line.rb +2 -2
- data/lib/spec/runner/extensions/kernel.rb +22 -9
- data/lib/spec/runner/formatter.rb +4 -0
- data/lib/spec/runner/formatter/base_formatter.rb +63 -0
- data/lib/spec/runner/formatter/base_text_formatter.rb +22 -52
- data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +25 -0
- data/lib/spec/runner/formatter/failing_examples_formatter.rb +22 -0
- data/lib/spec/runner/formatter/html_formatter.rb +74 -29
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +6 -8
- data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
- data/lib/spec/runner/formatter/snippet_extractor.rb +52 -0
- data/lib/spec/runner/formatter/specdoc_formatter.rb +6 -6
- data/lib/spec/runner/heckle_runner.rb +8 -7
- data/lib/spec/runner/option_parser.rb +136 -55
- data/lib/spec/runner/options.rb +26 -0
- data/lib/spec/runner/reporter.rb +38 -31
- data/lib/spec/runner/spec_parser.rb +22 -13
- data/lib/spec/test_case_adapter.rb +10 -0
- data/lib/spec/translator.rb +103 -86
- data/lib/spec/version.rb +7 -15
- data/plugins/mock_frameworks/flexmock.rb +27 -0
- data/plugins/mock_frameworks/mocha.rb +21 -0
- data/plugins/mock_frameworks/rspec.rb +18 -0
- data/spec/spec/dsl/behaviour_eval_spec.rb +49 -0
- data/spec/spec/dsl/behaviour_factory_spec.rb +30 -0
- data/spec/spec/dsl/behaviour_spec.rb +508 -0
- data/spec/spec/dsl/composite_proc_builder_spec.rb +57 -0
- data/spec/spec/dsl/configuration_spec.rb +43 -0
- data/spec/spec/dsl/description_spec.rb +51 -0
- data/spec/spec/dsl/example_class_spec.rb +24 -0
- data/spec/spec/dsl/example_instance_spec.rb +140 -0
- data/spec/spec/dsl/example_should_raise_spec.rb +137 -0
- data/spec/spec/dsl/predicate_matcher_spec.rb +21 -0
- data/spec/spec/dsl/shared_behaviour_spec.rb +186 -0
- data/spec/spec/expectations/differs/default_spec.rb +12 -12
- data/spec/spec/expectations/extensions/object_spec.rb +10 -10
- data/spec/spec/expectations/fail_with_spec.rb +20 -20
- data/spec/spec/matchers/be_close_spec.rb +37 -31
- data/spec/spec/matchers/be_spec.rb +50 -41
- data/spec/spec/matchers/change_spec.rb +54 -54
- data/spec/spec/matchers/description_generation_spec.rb +43 -31
- data/spec/spec/matchers/eql_spec.rb +24 -37
- data/spec/spec/matchers/equal_spec.rb +24 -37
- data/spec/spec/matchers/exist_spec.rb +48 -0
- data/spec/spec/matchers/handler_spec.rb +36 -23
- data/spec/spec/matchers/has_spec.rb +8 -8
- data/spec/spec/matchers/have_spec.rb +38 -38
- data/spec/spec/matchers/include_spec.rb +6 -6
- data/spec/spec/matchers/match_spec.rb +8 -8
- data/spec/spec/matchers/matcher_methods_spec.rb +24 -31
- data/spec/spec/matchers/raise_error_spec.rb +34 -34
- data/spec/spec/matchers/respond_to_spec.rb +32 -8
- data/spec/spec/matchers/satisfy_spec.rb +6 -6
- data/spec/spec/matchers/should_===_spec.rb +38 -0
- data/spec/spec/matchers/should_==_spec.rb +37 -0
- data/spec/spec/matchers/should_=~_spec.rb +36 -0
- data/spec/spec/matchers/throw_symbol_spec.rb +47 -55
- data/spec/spec/mocks/any_number_of_times_spec.rb +16 -21
- data/spec/spec/mocks/argument_expectation_spec.rb +3 -3
- data/spec/spec/mocks/at_least_spec.rb +30 -30
- data/spec/spec/mocks/at_most_spec.rb +53 -57
- data/spec/spec/mocks/bug_report_10260_spec.rb +8 -0
- data/spec/spec/mocks/bug_report_7611_spec.rb +3 -3
- data/spec/spec/mocks/bug_report_7805_spec.rb +3 -3
- data/spec/spec/mocks/bug_report_8165_spec.rb +5 -5
- data/spec/spec/mocks/bug_report_8302_spec.rb +5 -5
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +26 -27
- data/spec/spec/mocks/mock_ordering_spec.rb +19 -15
- data/spec/spec/mocks/mock_space_spec.rb +54 -0
- data/spec/spec/mocks/mock_spec.rb +111 -141
- data/spec/spec/mocks/multiple_return_value_spec.rb +48 -48
- data/spec/spec/mocks/null_object_mock_spec.rb +10 -10
- data/spec/spec/mocks/once_counts_spec.rb +32 -35
- data/spec/spec/mocks/options_hash_spec.rb +12 -10
- data/spec/spec/mocks/partial_mock_spec.rb +15 -15
- data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +24 -22
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +19 -19
- data/spec/spec/mocks/precise_counts_spec.rb +28 -32
- data/spec/spec/mocks/record_messages_spec.rb +10 -10
- data/spec/spec/mocks/stub_spec.rb +45 -45
- data/spec/spec/mocks/twice_counts_spec.rb +21 -21
- data/spec/spec/package/bin_spec_spec.rb +12 -0
- data/spec/spec/runner/behaviour_runner_spec.rb +114 -0
- data/spec/spec/runner/command_line_spec.rb +8 -8
- data/spec/spec/runner/context_matching_spec.rb +14 -15
- data/spec/spec/runner/drb_command_line_spec.rb +12 -12
- data/spec/spec/runner/execution_context_spec.rb +8 -29
- data/spec/spec/runner/extensions/kernel_spec.rb +36 -0
- data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +27 -0
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +28 -0
- data/spec/spec/runner/formatter/html_formatter_spec.rb +9 -8
- data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +6 -6
- data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +10 -10
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +22 -27
- data/spec/spec/runner/formatter/rdoc_formatter_dry_run_spec.rb +6 -5
- data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +17 -17
- data/spec/spec/runner/formatter/snippet_extractor_spec.rb +11 -0
- data/spec/spec/runner/formatter/specdoc_formatter_dry_run_spec.rb +6 -6
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +17 -17
- data/spec/spec/runner/heckle_runner_spec.rb +21 -21
- data/spec/spec/runner/heckler_spec.rb +5 -5
- data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +12 -12
- data/spec/spec/runner/object_ext_spec.rb +3 -3
- data/spec/spec/runner/option_parser_spec.rb +171 -102
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +21 -12
- data/spec/spec/runner/reporter_spec.rb +106 -97
- data/spec/spec/runner/spec_matcher_spec.rb +46 -51
- data/spec/spec/runner/spec_parser_spec.rb +72 -16
- data/spec/spec/spec_classes.rb +12 -3
- data/spec/spec/translator_spec.rb +165 -36
- metadata +66 -76
- data/RELEASE-PLAN +0 -117
- data/examples/auto_spec_name_generation_example.rb +0 -18
- data/lib/spec/callback.rb +0 -11
- data/lib/spec/callback/callback_container.rb +0 -60
- data/lib/spec/callback/extensions/module.rb +0 -24
- data/lib/spec/callback/extensions/object.rb +0 -37
- data/lib/spec/deprecated.rb +0 -3
- data/lib/spec/expectations/extensions/proc.rb +0 -57
- data/lib/spec/expectations/should.rb +0 -5
- data/lib/spec/expectations/should/base.rb +0 -64
- data/lib/spec/expectations/should/change.rb +0 -69
- data/lib/spec/expectations/should/have.rb +0 -128
- data/lib/spec/expectations/should/not.rb +0 -74
- data/lib/spec/expectations/should/should.rb +0 -81
- data/lib/spec/expectations/sugar.rb +0 -47
- data/lib/spec/runner/context.rb +0 -154
- data/lib/spec/runner/context_eval.rb +0 -142
- data/lib/spec/runner/context_runner.rb +0 -55
- data/lib/spec/runner/execution_context.rb +0 -17
- data/lib/spec/runner/spec_matcher.rb +0 -25
- data/lib/spec/runner/specification.rb +0 -114
- data/spec/spec/callback/callback_container_spec.rb +0 -27
- data/spec/spec/callback/module_spec.rb +0 -37
- data/spec/spec/callback/object_spec.rb +0 -90
- data/spec/spec/callback/object_with_class_callback_spec.rb +0 -19
- data/spec/spec/expectations/should/should_==_spec.rb +0 -19
- data/spec/spec/expectations/should/should_=~_spec.rb +0 -13
- data/spec/spec/expectations/should/should_be_a_kind_of_spec.rb +0 -21
- data/spec/spec/expectations/should/should_be_an_instance_of_spec.rb +0 -30
- data/spec/spec/expectations/should/should_be_arbitrary_predicate_spec.rb +0 -81
- data/spec/spec/expectations/should/should_be_close_spec.rb +0 -18
- data/spec/spec/expectations/should/should_be_comparison_operator_spec.rb +0 -44
- data/spec/spec/expectations/should/should_be_false_spec.rb +0 -39
- data/spec/spec/expectations/should/should_be_spec.rb +0 -11
- data/spec/spec/expectations/should/should_be_true_spec.rb +0 -27
- data/spec/spec/expectations/should/should_change_spec.rb +0 -184
- data/spec/spec/expectations/should/should_eql_spec.rb +0 -11
- data/spec/spec/expectations/should/should_equal_spec.rb +0 -11
- data/spec/spec/expectations/should/should_have_at_least_spec.rb +0 -53
- data/spec/spec/expectations/should/should_have_at_most_spec.rb +0 -45
- data/spec/spec/expectations/should/should_have_key_spec.rb +0 -21
- data/spec/spec/expectations/should/should_have_spec.rb +0 -64
- data/spec/spec/expectations/should/should_include_spec.rb +0 -59
- data/spec/spec/expectations/should/should_match_spec.rb +0 -25
- data/spec/spec/expectations/should/should_not_==_spec.rb +0 -15
- data/spec/spec/expectations/should/should_not_be_a_kind_of_spec.rb +0 -21
- data/spec/spec/expectations/should/should_not_be_an_instance_of_spec.rb +0 -11
- data/spec/spec/expectations/should/should_not_be_arbitrary_predicate_spec.rb +0 -68
- data/spec/spec/expectations/should/should_not_be_spec.rb +0 -11
- data/spec/spec/expectations/should/should_not_change_spec.rb +0 -24
- data/spec/spec/expectations/should/should_not_eql_spec.rb +0 -11
- data/spec/spec/expectations/should/should_not_equal_spec.rb +0 -11
- data/spec/spec/expectations/should/should_not_have_key_spec.rb +0 -15
- data/spec/spec/expectations/should/should_not_include_spec.rb +0 -58
- data/spec/spec/expectations/should/should_not_match_spec.rb +0 -11
- data/spec/spec/expectations/should/should_not_raise_spec.rb +0 -75
- data/spec/spec/expectations/should/should_not_respond_to_spec.rb +0 -15
- data/spec/spec/expectations/should/should_not_throw_spec.rb +0 -35
- data/spec/spec/expectations/should/should_raise_spec.rb +0 -66
- data/spec/spec/expectations/should/should_respond_to_spec.rb +0 -15
- data/spec/spec/expectations/should/should_satisfy_spec.rb +0 -35
- data/spec/spec/expectations/should/should_throw_spec.rb +0 -27
- data/spec/spec/runner/context_runner_spec.rb +0 -100
- data/spec/spec/runner/context_spec.rb +0 -405
- data/spec/spec/runner/kernel_ext_spec.rb +0 -16
- data/spec/spec/runner/spec_name_generation_spec.rb +0 -102
- data/spec/spec/runner/specification_class_spec.rb +0 -72
- data/spec/spec/runner/specification_instance_spec.rb +0 -160
- data/spec/spec/runner/specification_should_raise_spec.rb +0 -136
|
@@ -2,9 +2,9 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Runner
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.new.
|
|
5
|
+
describe "ObjectExt" do
|
|
6
|
+
it "should add copy_instance_variables_from to object" do
|
|
7
|
+
Object.new.should respond_to(:copy_instance_variables_from)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
describe "OptionParser" do
|
|
4
|
+
before(:each) do
|
|
5
5
|
@out = StringIO.new
|
|
6
6
|
@err = StringIO.new
|
|
7
7
|
@parser = Spec::Runner::OptionParser.new
|
|
@@ -11,170 +11,195 @@ context "OptionParser" do
|
|
|
11
11
|
@parser.parse(args, @err, @out, true)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
def behaviour_runner(args)
|
|
15
|
+
@parser.create_behaviour_runner(args, @err, @out, true)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should accept dry run option" do
|
|
15
19
|
options = parse(["--dry-run"])
|
|
16
|
-
options.dry_run.
|
|
20
|
+
options.dry_run.should be_true
|
|
17
21
|
end
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
it "should eval and use custom formatter when none of the builtins" do
|
|
20
24
|
options = parse(["--format", "Custom::Formatter"])
|
|
21
|
-
options.
|
|
25
|
+
options.formatters[0].class.should be(Custom::Formatter)
|
|
22
26
|
end
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
|
|
28
|
+
it "should support formatters with relative and absolute paths, even on windows" do
|
|
29
|
+
options = parse([
|
|
30
|
+
"--format", "Custom::Formatter:C:\\foo\\bar",
|
|
31
|
+
"--format", "Custom::Formatter:foo/bar",
|
|
32
|
+
"--format", "Custom::Formatter:foo\\bar",
|
|
33
|
+
"--format", "Custom::Formatter:/foo/bar"
|
|
34
|
+
])
|
|
35
|
+
options.formatters[0].where.should eql("C:\\foo\\bar")
|
|
36
|
+
options.formatters[1].where.should eql("foo/bar")
|
|
37
|
+
options.formatters[2].where.should eql("foo\\bar")
|
|
38
|
+
options.formatters[3].where.should eql("/foo/bar")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should not be verbose by default" do
|
|
25
42
|
options = parse([])
|
|
26
|
-
options.verbose.
|
|
43
|
+
options.verbose.should be_nil
|
|
27
44
|
end
|
|
28
45
|
|
|
29
|
-
|
|
46
|
+
it "should not use colour by default" do
|
|
30
47
|
options = parse([])
|
|
31
|
-
options.colour.
|
|
48
|
+
options.colour.should be_nil
|
|
32
49
|
end
|
|
33
50
|
|
|
34
|
-
|
|
51
|
+
it "should print help to stdout" do
|
|
35
52
|
options = parse(["--help"])
|
|
36
53
|
@out.rewind
|
|
37
|
-
@out.read.
|
|
54
|
+
@out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
|
|
38
55
|
end
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
it "should print instructions about how to fix bad formatter" do
|
|
41
58
|
options = parse(["--format", "Custom::BadFormatter"])
|
|
42
|
-
@err.string.
|
|
59
|
+
@err.string.should match(/Couldn't find formatter class Custom::BadFormatter/n)
|
|
43
60
|
end
|
|
44
61
|
|
|
45
|
-
|
|
62
|
+
it "should print usage to err if no dir specified" do
|
|
46
63
|
options = parse([])
|
|
47
|
-
@err.string.
|
|
64
|
+
@err.string.should match(/Usage: spec/)
|
|
48
65
|
end
|
|
49
66
|
|
|
50
|
-
|
|
67
|
+
it "should print version to stdout" do
|
|
51
68
|
options = parse(["--version"])
|
|
52
69
|
@out.rewind
|
|
53
|
-
@out.read.
|
|
70
|
+
@out.read.should match(/RSpec-\d+\.\d+\.\d+.*\(r\d+\) - BDD for Ruby\nhttp:\/\/rspec.rubyforge.org\/\n/n)
|
|
54
71
|
end
|
|
55
72
|
|
|
56
|
-
|
|
57
|
-
options = parse(["-o", "#{File.expand_path(File.dirname(__FILE__))}/output_file.txt"])
|
|
58
|
-
options.out.should_be_an_instance_of File
|
|
59
|
-
options.out.path.should == "#{File.expand_path(File.dirname(__FILE__))}/output_file.txt"
|
|
60
|
-
File.delete(options.out.path) rescue nil
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
specify "should require file when require specified" do
|
|
73
|
+
it "should require file when require specified" do
|
|
64
74
|
lambda do
|
|
65
75
|
parse(["--require", "whatever"])
|
|
66
|
-
end.
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
specify "should select dry run for rdoc formatter" do
|
|
70
|
-
options = parse(["--format", "rdoc"])
|
|
71
|
-
options.dry_run.should_be(true)
|
|
76
|
+
end.should raise_error(LoadError)
|
|
72
77
|
end
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
it "should support c option" do
|
|
75
80
|
options = parse(["-c"])
|
|
76
|
-
options.colour.
|
|
81
|
+
options.colour.should be_true
|
|
77
82
|
end
|
|
78
83
|
|
|
79
|
-
|
|
84
|
+
it "should support queens colour option" do
|
|
80
85
|
options = parse(["--colour"])
|
|
81
|
-
options.colour.
|
|
86
|
+
options.colour.should be_true
|
|
82
87
|
end
|
|
83
88
|
|
|
84
|
-
|
|
89
|
+
it "should support us color option" do
|
|
85
90
|
options = parse(["--color"])
|
|
86
|
-
options.colour.
|
|
91
|
+
options.colour.should be_true
|
|
87
92
|
end
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
it "should support single example with -e option" do
|
|
95
|
+
options = parse(["-e", "something or other"])
|
|
96
|
+
options.examples.should eql(["something or other"])
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should support single example with -s option (will be removed when autotest supports -e)" do
|
|
90
100
|
options = parse(["-s", "something or other"])
|
|
91
|
-
options.
|
|
101
|
+
options.examples.should eql(["something or other"])
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should support single example with --example option" do
|
|
105
|
+
options = parse(["--example", "something or other"])
|
|
106
|
+
options.examples.should eql(["something or other"])
|
|
92
107
|
end
|
|
93
108
|
|
|
94
|
-
|
|
95
|
-
options = parse(["--
|
|
96
|
-
options.
|
|
109
|
+
it "should read several example names from file if --example is given an existing file name" do
|
|
110
|
+
options = parse(["--example", File.dirname(__FILE__) + '/examples.txt'])
|
|
111
|
+
options.examples.should eql([
|
|
112
|
+
"Sir, if you were my husband, I would poison your drink.",
|
|
113
|
+
"Madam, if you were my wife, I would drink it."])
|
|
97
114
|
end
|
|
98
115
|
|
|
99
|
-
|
|
116
|
+
it "should use html formatter when format is h" do
|
|
100
117
|
options = parse(["--format", "h"])
|
|
101
|
-
options.
|
|
118
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
|
|
102
119
|
end
|
|
103
120
|
|
|
104
|
-
|
|
121
|
+
it "should use html formatter when format is html" do
|
|
105
122
|
options = parse(["--format", "html"])
|
|
106
|
-
options.
|
|
123
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
|
|
107
124
|
end
|
|
108
125
|
|
|
109
|
-
|
|
126
|
+
it "should use html formatter with explicit output when format is html:test.html" do
|
|
127
|
+
FileUtils.rm 'test.html' if File.exist?('test.html')
|
|
128
|
+
options = parse(["--format", "html:test.html"])
|
|
129
|
+
File.should be_exist('test.html')
|
|
130
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
|
|
131
|
+
FileUtils.rm 'test.html'
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should use noisy backtrace tweaker with b option" do
|
|
110
135
|
options = parse(["-b"])
|
|
111
|
-
options.backtrace_tweaker.
|
|
136
|
+
options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
|
|
112
137
|
end
|
|
113
138
|
|
|
114
|
-
|
|
139
|
+
it "should use noisy backtrace tweaker with backtrace option" do
|
|
115
140
|
options = parse(["--backtrace"])
|
|
116
|
-
options.backtrace_tweaker.
|
|
141
|
+
options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
|
|
117
142
|
end
|
|
118
143
|
|
|
119
|
-
|
|
144
|
+
it "should use quiet backtrace tweaker by default" do
|
|
120
145
|
options = parse([])
|
|
121
|
-
options.backtrace_tweaker.
|
|
146
|
+
options.backtrace_tweaker.should be_instance_of(Spec::Runner::QuietBacktraceTweaker)
|
|
122
147
|
end
|
|
123
148
|
|
|
124
|
-
|
|
149
|
+
it "should use progress bar formatter by default" do
|
|
125
150
|
options = parse([])
|
|
126
|
-
options.
|
|
151
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter)
|
|
127
152
|
end
|
|
128
153
|
|
|
129
|
-
|
|
154
|
+
it "should use rdoc formatter when format is r" do
|
|
130
155
|
options = parse(["--format", "r"])
|
|
131
|
-
options.
|
|
156
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::RdocFormatter)
|
|
132
157
|
end
|
|
133
158
|
|
|
134
|
-
|
|
159
|
+
it "should use rdoc formatter when format is rdoc" do
|
|
135
160
|
options = parse(["--format", "rdoc"])
|
|
136
|
-
options.
|
|
161
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::RdocFormatter)
|
|
137
162
|
end
|
|
138
163
|
|
|
139
|
-
|
|
164
|
+
it "should use specdoc formatter when format is s" do
|
|
140
165
|
options = parse(["--format", "s"])
|
|
141
|
-
options.
|
|
166
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
|
|
142
167
|
end
|
|
143
168
|
|
|
144
|
-
|
|
169
|
+
it "should use specdoc formatter when format is specdoc" do
|
|
145
170
|
options = parse(["--format", "specdoc"])
|
|
146
|
-
options.
|
|
171
|
+
options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
|
|
147
172
|
end
|
|
148
173
|
|
|
149
|
-
|
|
174
|
+
it "should support diff option when format is not specified" do
|
|
150
175
|
options = parse(["--diff"])
|
|
151
|
-
options.diff_format.
|
|
176
|
+
options.diff_format.should == :unified
|
|
152
177
|
end
|
|
153
178
|
|
|
154
|
-
|
|
179
|
+
it "should use unified diff format option when format is unified" do
|
|
155
180
|
options = parse(["--diff", "unified"])
|
|
156
|
-
options.diff_format.
|
|
157
|
-
options.differ_class.
|
|
181
|
+
options.diff_format.should == :unified
|
|
182
|
+
options.differ_class.should equal(Spec::Expectations::Differs::Default)
|
|
158
183
|
end
|
|
159
184
|
|
|
160
|
-
|
|
185
|
+
it "should use context diff format option when format is context" do
|
|
161
186
|
options = parse(["--diff", "context"])
|
|
162
|
-
options.diff_format.should
|
|
163
|
-
options.differ_class.
|
|
187
|
+
options.diff_format.should == :context
|
|
188
|
+
options.differ_class.should == Spec::Expectations::Differs::Default
|
|
164
189
|
end
|
|
165
190
|
|
|
166
|
-
|
|
191
|
+
it "should use custom diff format option when format is a custom format" do
|
|
167
192
|
options = parse(["--diff", "Custom::Formatter"])
|
|
168
|
-
options.diff_format.
|
|
169
|
-
options.differ_class.
|
|
193
|
+
options.diff_format.should == :custom
|
|
194
|
+
options.differ_class.should == Custom::Formatter
|
|
170
195
|
end
|
|
171
196
|
|
|
172
|
-
|
|
197
|
+
it "should print instructions about how to fix bad differ" do
|
|
173
198
|
options = parse(["--diff", "Custom::BadFormatter"])
|
|
174
|
-
@err.string.
|
|
199
|
+
@err.string.should match(/Couldn't find differ class Custom::BadFormatter/n)
|
|
175
200
|
end
|
|
176
201
|
|
|
177
|
-
|
|
202
|
+
it "should support --line to identify spec" do
|
|
178
203
|
spec_parser = mock("spec_parser")
|
|
179
204
|
@parser.instance_variable_set('@spec_parser', spec_parser)
|
|
180
205
|
|
|
@@ -186,11 +211,11 @@ context "OptionParser" do
|
|
|
186
211
|
spec_parser.should_receive(:spec_name_for).with("fake_io", 169).and_return("some spec")
|
|
187
212
|
|
|
188
213
|
options = parse(["some file", "--line", "169"])
|
|
189
|
-
options.
|
|
190
|
-
File.
|
|
214
|
+
options.examples.should eql(["some spec"])
|
|
215
|
+
File.rspec_verify
|
|
191
216
|
end
|
|
192
217
|
|
|
193
|
-
|
|
218
|
+
it "should fail with error message if file is dir along with --line" do
|
|
194
219
|
spec_parser = mock("spec_parser")
|
|
195
220
|
@parser.instance_variable_set('@spec_parser', spec_parser)
|
|
196
221
|
|
|
@@ -200,10 +225,10 @@ context "OptionParser" do
|
|
|
200
225
|
@parser.instance_variable_set('@file_factory', file_factory)
|
|
201
226
|
|
|
202
227
|
options = parse(["some file", "--line", "169"])
|
|
203
|
-
@err.string.
|
|
228
|
+
@err.string.should match(/You must specify one file, not a directory when using the --line option/n)
|
|
204
229
|
end
|
|
205
230
|
|
|
206
|
-
|
|
231
|
+
it "should fail with error message if file is dir along with --line" do
|
|
207
232
|
spec_parser = mock("spec_parser")
|
|
208
233
|
@parser.instance_variable_set('@spec_parser', spec_parser)
|
|
209
234
|
|
|
@@ -213,57 +238,101 @@ context "OptionParser" do
|
|
|
213
238
|
@parser.instance_variable_set('@file_factory', file_factory)
|
|
214
239
|
|
|
215
240
|
options = parse(["some file", "--line", "169"])
|
|
216
|
-
@err.string.
|
|
241
|
+
@err.string.should match(/some file does not exist/n)
|
|
217
242
|
end
|
|
218
243
|
|
|
219
|
-
|
|
244
|
+
it "should fail with error message if more than one files are specified along with --line" do
|
|
220
245
|
spec_parser = mock("spec_parser")
|
|
221
246
|
@parser.instance_variable_set('@spec_parser', spec_parser)
|
|
222
247
|
|
|
223
248
|
options = parse(["some file", "some other file", "--line", "169"])
|
|
224
|
-
@err.string.
|
|
249
|
+
@err.string.should match(/Only one file can be specified when using the --line option/n)
|
|
225
250
|
end
|
|
226
251
|
|
|
227
|
-
|
|
252
|
+
it "should fail with error message if --example and --line are used simultaneously" do
|
|
228
253
|
spec_parser = mock("spec_parser")
|
|
229
254
|
@parser.instance_variable_set('@spec_parser', spec_parser)
|
|
230
255
|
|
|
231
|
-
options = parse(["some file", "--
|
|
232
|
-
@err.string.
|
|
256
|
+
options = parse(["some file", "--example", "some example", "--line", "169"])
|
|
257
|
+
@err.string.should match(/You cannot use both --line and --example/n)
|
|
233
258
|
end
|
|
234
259
|
|
|
235
260
|
if(PLATFORM != "i386-mswin32")
|
|
236
|
-
|
|
261
|
+
it "should heckle when --heckle is specified (and platform is not windows)" do
|
|
237
262
|
options = parse(["--heckle", "Spec"])
|
|
238
|
-
options.heckle_runner.
|
|
263
|
+
options.heckle_runner.should be_instance_of(Spec::Runner::HeckleRunner)
|
|
239
264
|
end
|
|
240
265
|
else
|
|
241
|
-
|
|
266
|
+
it "should barf when --heckle is specified (and platform is windows)" do
|
|
242
267
|
lambda do
|
|
243
268
|
options = parse(["--heckle", "Spec"])
|
|
244
|
-
end.
|
|
269
|
+
end.should raise_error(StandardError, "Heckle not supported on Windows")
|
|
245
270
|
end
|
|
246
271
|
end
|
|
247
|
-
|
|
248
|
-
|
|
272
|
+
|
|
273
|
+
it "should read options from file when --options is specified" do
|
|
249
274
|
Spec::Runner::CommandLine.should_receive(:run).with(["--diff", "--colour"], @err, @out, true, true)
|
|
250
275
|
options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
|
|
251
276
|
end
|
|
252
277
|
|
|
253
|
-
|
|
278
|
+
it "should append options from file when --options is specified" do
|
|
254
279
|
Spec::Runner::CommandLine.should_receive(:run).with(["some/spec.rb", "--diff", "--colour"], @err, @out, true, true)
|
|
255
280
|
options = parse(["some/spec.rb", "--options", File.dirname(__FILE__) + "/spec.opts"])
|
|
256
281
|
end
|
|
282
|
+
|
|
283
|
+
it "should read spaced and multi-line options from file when --options is specified" do
|
|
284
|
+
Spec::Runner::CommandLine.should_receive(:run).with(["--diff", "--colour", "--format", "s"], @err, @out, true, true)
|
|
285
|
+
options = parse(["--options", File.dirname(__FILE__) + "/spec_spaced.opts"])
|
|
286
|
+
end
|
|
257
287
|
|
|
258
|
-
|
|
259
|
-
FileUtils.rm 'spec.opts' rescue nil
|
|
260
|
-
options = parse(["--colour", "--generate-options", "spec.opts", "--diff"])
|
|
261
|
-
File.open('spec.opts').read.should == "--colour\n--diff\n"
|
|
262
|
-
FileUtils.rm 'spec.opts' rescue nil
|
|
288
|
+
it "should save config to file when --generate-options is specified" do
|
|
289
|
+
FileUtils.rm 'test.spec.opts' rescue nil
|
|
290
|
+
options = parse(["--colour", "--generate-options", "test.spec.opts", "--diff"])
|
|
291
|
+
File.open('test.spec.opts').read.should == "--colour\n--diff\n"
|
|
292
|
+
FileUtils.rm 'test.spec.opts' rescue nil
|
|
263
293
|
end
|
|
264
294
|
|
|
265
|
-
|
|
295
|
+
it "should call DrbCommandLine when --drb is specified" do
|
|
266
296
|
Spec::Runner::DrbCommandLine.should_receive(:run).with(["some/spec.rb", "--diff", "--colour"], @err, @out, true, true)
|
|
267
297
|
options = parse(["some/spec.rb", "--diff", "--drb", "--colour"])
|
|
268
298
|
end
|
|
299
|
+
|
|
300
|
+
it "should reverse spec order when --reverse is specified" do
|
|
301
|
+
options = parse(["some/spec.rb", "--reverse"])
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
it "should set an mtime comparator when --loadby mtime" do
|
|
305
|
+
behaviour_runner = behaviour_runner(["--loadby", 'mtime'])
|
|
306
|
+
Dir.chdir(File.dirname(__FILE__)) do
|
|
307
|
+
FileUtils.touch "most_recent_spec.rb"
|
|
308
|
+
all_files = ['command_line_spec.rb', 'most_recent_spec.rb']
|
|
309
|
+
sorted_files = behaviour_runner.sort_paths(all_files)
|
|
310
|
+
sorted_files.should == ["most_recent_spec.rb", "command_line_spec.rb"]
|
|
311
|
+
FileUtils.rm "most_recent_spec.rb"
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
it "should not use a runner by default" do
|
|
316
|
+
options = parse([])
|
|
317
|
+
options.runner_type.should be_nil
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
it "should use a custom runner when given" do
|
|
321
|
+
options = parse(["--runner", "Custom::BehaviourRunner"])
|
|
322
|
+
options.runner_type.should equal(Custom::BehaviourRunner)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it "should fail when custom runner not found" do
|
|
326
|
+
parse(["--runner", "whatever"])
|
|
327
|
+
@err.string.should match(/Couldn't find behaviour runner class/)
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
it "should return the correct default behaviour runner" do
|
|
331
|
+
@parser.create_behaviour_runner([], @err, @out, true).should be_instance_of(Spec::Runner::BehaviourRunner)
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
it "should return the correct default behaviour runner" do
|
|
335
|
+
@parser.create_behaviour_runner(["--runner", "Custom::BehaviourRunner"], @err, @out, true).should be_instance_of(Custom::BehaviourRunner)
|
|
336
|
+
end
|
|
337
|
+
|
|
269
338
|
end
|
|
@@ -2,26 +2,26 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Runner
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
describe "QuietBacktraceTweaker" do
|
|
6
|
+
before(:each) do
|
|
7
7
|
@error = RuntimeError.new
|
|
8
8
|
@tweaker = QuietBacktraceTweaker.new
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
it "should not barf on nil backtrace" do
|
|
12
12
|
lambda do
|
|
13
13
|
@tweaker.tweak_backtrace(@error, "spec name")
|
|
14
|
-
end.
|
|
14
|
+
end.should_not raise_error
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
it "should remove anything from textmate ruby bundle" do
|
|
18
18
|
@error.set_backtrace(["/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/tmruby.rb:147"])
|
|
19
19
|
@tweaker.tweak_backtrace(@error, "spec name")
|
|
20
|
-
@error.backtrace.
|
|
20
|
+
@error.backtrace.should be_empty
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
["expectations", "mocks", "runner"
|
|
23
|
+
it "should remove anything in lib spec dir" do
|
|
24
|
+
["expectations", "mocks", "runner"].each do |child|
|
|
25
25
|
element="/lib/spec/#{child}/anything.rb"
|
|
26
26
|
@error.set_backtrace([element])
|
|
27
27
|
@tweaker.tweak_backtrace(@error, "spec name")
|
|
@@ -31,16 +31,25 @@ module Spec
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
it "should remove mock_frameworks/rspec" do
|
|
35
|
+
element = "mock_frameworks/rspec"
|
|
36
|
+
@error.set_backtrace([element])
|
|
37
|
+
@tweaker.tweak_backtrace(@error, "spec name")
|
|
38
|
+
unless (@error.backtrace.empty?)
|
|
39
|
+
raise("Should have tweaked away '#{element}'")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should remove bin spec" do
|
|
35
44
|
@error.set_backtrace(["bin/spec:"])
|
|
36
45
|
@tweaker.tweak_backtrace(@error, "spec name")
|
|
37
|
-
@error.backtrace.
|
|
46
|
+
@error.backtrace.should be_empty
|
|
38
47
|
end
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
it "should clean up double slashes" do
|
|
41
50
|
@error.set_backtrace(["/a//b/c//d.rb"])
|
|
42
51
|
@tweaker.tweak_backtrace(@error, "spec name")
|
|
43
|
-
@error.backtrace.
|
|
52
|
+
@error.backtrace.should include("/a/b/c/d.rb")
|
|
44
53
|
end
|
|
45
54
|
end
|
|
46
55
|
end
|