rspec 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +57 -32
- data/EXAMPLES.rd +0 -0
- data/Rakefile +22 -21
- data/bin/spec +9 -11
- data/doc/README +1 -3
- data/doc/plugin/syntax.rb +27 -5
- data/doc/src/core_team.page +22 -0
- data/doc/src/default.css +11 -11
- data/doc/src/default.template +0 -1
- data/doc/src/documentation/index.page +183 -8
- data/doc/src/documentation/meta.info +7 -7
- data/doc/src/documentation/mocks.page +168 -109
- data/doc/src/documentation/underscores.page +20 -0
- data/doc/src/examples.page +2 -1
- data/doc/src/images/David_and_Aslak.jpg +0 -0
- data/doc/src/images/Whats_That_Dude.jpg +0 -0
- data/doc/src/index.page +70 -3
- data/doc/src/meta.info +18 -11
- data/doc/src/tools/index.page +40 -134
- data/doc/src/tools/meta.info +9 -3
- data/doc/src/tools/rails.page +3 -1
- data/doc/src/tools/rake.page +20 -3
- data/doc/src/tools/rcov.page +19 -0
- data/doc/src/tools/spec.page +99 -0
- data/doc/src/tools/test2rspec.page +2 -4
- data/doc/src/tutorials/index.page +52 -0
- data/doc/src/tutorials/meta.info +31 -0
- data/doc/src/tutorials/notes.txt +252 -0
- data/doc/src/tutorials/stack.rb +11 -0
- data/doc/src/tutorials/stack_01.page +224 -0
- data/doc/src/tutorials/stack_02.page +180 -0
- data/doc/src/tutorials/stack_03.page +291 -0
- data/doc/src/tutorials/stack_04.page +203 -0
- data/doc/src/tutorials/stack_04.page.orig +123 -0
- data/doc/src/tutorials/stack_05.page +90 -0
- data/doc/src/tutorials/stack_05.page.orig +124 -0
- data/doc/src/tutorials/stack_06.page +359 -0
- data/doc/src/tutorials/stack_06.page.orig +359 -0
- data/doc/src/tutorials/stack_spec.rb +41 -0
- data/examples/airport_spec.rb +4 -4
- data/examples/{spec_framework_spec.rb → bdd_framework_spec.rb} +6 -7
- data/examples/mocking_spec.rb +0 -5
- data/examples/stack_spec.rb +6 -7
- data/examples/sugar_spec.rb +14 -0
- data/lib/spec/api.rb +5 -2
- data/lib/spec/api/helper/should_base.rb +17 -22
- data/lib/spec/api/helper/should_helper.rb +4 -3
- data/lib/spec/api/helper/should_negator.rb +3 -2
- data/lib/spec/api/mocks/argument_expectation.rb +104 -0
- data/lib/spec/api/{mock.rb → mocks/message_expectation.rb} +47 -96
- data/lib/spec/api/mocks/mock.rb +63 -0
- data/lib/spec/api/mocks/order_group.rb +21 -0
- data/lib/spec/api/sugar.rb +47 -0
- data/lib/spec/rake/rcov_verify.rb +45 -0
- data/lib/spec/rake/spectask.rb +41 -56
- data/lib/spec/runner.rb +4 -1
- data/lib/spec/runner/backtrace_tweaker.rb +24 -3
- data/lib/spec/runner/base_text_formatter.rb +28 -0
- data/lib/spec/runner/context.rb +21 -18
- data/lib/spec/runner/context_runner.rb +20 -31
- data/lib/spec/runner/execution_context.rb +3 -3
- data/lib/spec/runner/kernel_ext.rb +10 -1
- data/lib/spec/runner/option_parser.rb +32 -14
- data/lib/spec/runner/progress_bar_formatter.rb +21 -0
- data/lib/spec/runner/rdoc_formatter.rb +15 -5
- data/lib/spec/runner/reporter.rb +100 -0
- data/lib/spec/runner/specdoc_formatter.rb +20 -0
- data/lib/spec/runner/specification.rb +42 -22
- data/lib/spec/version.rb +1 -1
- data/test/rcov/rcov_testtask.rb +1 -0
- data/test/spec/api/duck_type_test.rb +4 -4
- data/test/spec/api/helper/raising_test.rb +37 -17
- data/test/spec/api/{mock_arg_constraints_test.rb → mocks/mock_arg_constraints_test.rb} +10 -4
- data/test/spec/api/mocks/mock_ordering_test.rb +62 -0
- data/test/spec/api/{mock_test.rb → mocks/mock_test.rb} +30 -7
- data/test/spec/api/mocks/null_object_test.rb +31 -0
- data/test/spec/api/sugar_test.rb +71 -0
- data/test/spec/runner/backtrace_tweaker_test.rb +52 -4
- data/test/spec/runner/context_runner_test.rb +41 -21
- data/test/spec/runner/context_test.rb +60 -32
- data/test/spec/runner/execution_context_test.rb +4 -3
- data/test/spec/runner/failure_dump_test.rb +92 -0
- data/test/spec/runner/kernel_ext_test.rb +1 -2
- data/test/spec/runner/option_parser_test.rb +48 -28
- data/test/spec/runner/progress_bar_formatter_test.rb +48 -0
- data/test/spec/runner/rdoc_formatter_test.rb +31 -4
- data/test/spec/runner/reporter_test.rb +103 -0
- data/test/spec/runner/specdoc_formatter_test.rb +50 -0
- data/test/spec/runner/specification_test.rb +49 -11
- data/test/test_helper.rb +1 -4
- metadata +46 -15
- data/doc/src/community.page +0 -7
- data/doc/src/documentation/api.page +0 -185
- data/doc/src/why_rspec.page +0 -7
- data/examples/empty_stack_spec.rb +0 -22
- data/examples/team_spec.rb +0 -30
- data/lib/spec/api/duck_type.rb +0 -16
- data/lib/spec/runner/simple_text_reporter.rb +0 -88
- data/test/rcov/rcov_verify.rb +0 -28
- data/test/spec/runner/simple_text_reporter_test.rb +0 -123
@@ -4,37 +4,57 @@ module Spec
|
|
4
4
|
module Runner
|
5
5
|
class ContextRunnerTest < Test::Unit::TestCase
|
6
6
|
|
7
|
-
def test_should_call_run_doc_on_context
|
8
|
-
context1 = Api::Mock.new "context1"
|
9
|
-
context2 = Api::Mock.new "context2"
|
10
|
-
context1.should.receive(:run_docs)
|
11
|
-
context2.should.receive(:run_docs)
|
12
|
-
runner = ContextRunner.new ["-d"], false, StringIO.new
|
13
|
-
runner.add_context context1
|
14
|
-
runner.add_context context2
|
15
|
-
runner.run
|
16
|
-
context1.__verify
|
17
|
-
context2.__verify
|
18
|
-
end
|
19
|
-
|
20
7
|
def test_should_call_run_on_context
|
21
|
-
context1 = Api::Mock.new "context1"
|
22
|
-
context2 = Api::Mock.new "context2"
|
8
|
+
context1 = Api::Mock.new "context1", :null_object=>true
|
9
|
+
context2 = Api::Mock.new "context2", :null_object=>true
|
23
10
|
context1.should.receive(:run)
|
11
|
+
context1.should.receive(:number_of_specs).and.return(0)
|
24
12
|
context2.should.receive(:run)
|
25
|
-
|
13
|
+
context2.should.receive(:number_of_specs).and.return(0)
|
14
|
+
|
15
|
+
reporter = Api::Mock.new 'reporter'
|
16
|
+
reporter.should_receive(:start).with(0)
|
17
|
+
reporter.should_receive(:end)
|
18
|
+
reporter.should_receive(:dump)
|
19
|
+
|
20
|
+
runner = ContextRunner.new(reporter, false, false)
|
26
21
|
runner.add_context context1
|
27
22
|
runner.add_context context2
|
23
|
+
|
28
24
|
runner.run
|
25
|
+
|
29
26
|
context1.__verify
|
30
27
|
context2.__verify
|
28
|
+
reporter.__verify
|
31
29
|
end
|
30
|
+
|
31
|
+
def test_should_support_single_spec
|
32
|
+
legal_context = Api::Mock.new "legal context"
|
33
|
+
legal_context.should_receive(:matches?).at_least(:once).and_return(true)
|
34
|
+
legal_context.should_receive(:run)
|
35
|
+
legal_context.should_receive(:isolate)
|
36
|
+
legal_context.should_receive(:number_of_specs).and_return(1)
|
37
|
+
|
38
|
+
illegal_context = Api::Mock.new "illegal context"
|
39
|
+
illegal_context.should_receive(:matches?).and_return(false)
|
40
|
+
illegal_context.should_receive(:run).never
|
41
|
+
illegal_context.should_receive(:number_of_specs).never
|
42
|
+
|
43
|
+
reporter = Api::Mock.new 'reporter'
|
32
44
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
45
|
+
runner = ContextRunner.new(reporter, false, false, "legal context legal spec")
|
46
|
+
runner.add_context legal_context
|
47
|
+
runner.add_context illegal_context
|
48
|
+
|
49
|
+
reporter.should_receive(:start)
|
50
|
+
reporter.should_receive(:end)
|
51
|
+
reporter.should_receive(:dump)
|
52
|
+
|
53
|
+
runner.run
|
54
|
+
|
55
|
+
legal_context.__verify
|
56
|
+
illegal_context.__verify
|
57
|
+
reporter.__verify
|
38
58
|
end
|
39
59
|
|
40
60
|
end
|
@@ -5,63 +5,91 @@ module Spec
|
|
5
5
|
class ContextTest < Test::Unit::TestCase
|
6
6
|
|
7
7
|
def setup
|
8
|
-
@
|
8
|
+
@formatter = Api::Mock.new "formatter"
|
9
9
|
@context = Context.new("context") {}
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
@
|
14
|
-
@context.run(@
|
15
|
-
@
|
12
|
+
def test_should_add_itself_to_formatter_on_run
|
13
|
+
@formatter.should.receive(:add_context).with "context"
|
14
|
+
@context.run(@formatter)
|
15
|
+
@formatter.__verify
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@listener.__verify
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_spec
|
25
|
-
@listener.should.receive(:add_context).with :any_args
|
26
|
-
@listener.should.receive(:add_spec).with "test", :anything
|
18
|
+
def test_should_run_spec
|
19
|
+
@formatter.should.receive(:add_context).with :any_args
|
20
|
+
@formatter.should.receive(:add_spec).with "test", :anything, :anything
|
27
21
|
$spec_ran = false
|
28
22
|
@context.specify("test") {$spec_ran = true}
|
29
|
-
@context.run(@
|
23
|
+
@context.run(@formatter)
|
30
24
|
assert $spec_ran
|
31
|
-
@
|
25
|
+
@formatter.__verify
|
32
26
|
end
|
33
27
|
|
34
|
-
def
|
35
|
-
@
|
36
|
-
@
|
37
|
-
|
38
|
-
@context.
|
39
|
-
|
40
|
-
|
28
|
+
def test_should_run_spec_dry
|
29
|
+
@formatter.should.receive(:add_context).with :any_args
|
30
|
+
@formatter.should.receive(:add_spec).with "test"
|
31
|
+
$spec_ran = false
|
32
|
+
@context.specify("test") {$spec_ran = true}
|
33
|
+
@context.run(@formatter, true)
|
34
|
+
assert !$spec_ran
|
35
|
+
@formatter.__verify
|
41
36
|
end
|
42
37
|
|
43
38
|
def test_setup
|
44
|
-
@
|
45
|
-
@
|
39
|
+
@formatter.should.receive(:add_context).with :any_args
|
40
|
+
@formatter.should.receive(:add_spec).with :any_args
|
46
41
|
$setup_ran = false
|
47
42
|
@context.setup {$setup_ran = true}
|
48
43
|
@context.specify("test") {true}
|
49
|
-
@context.run(@
|
44
|
+
@context.run(@formatter)
|
50
45
|
assert $setup_ran
|
51
|
-
@
|
46
|
+
@formatter.__verify
|
52
47
|
end
|
53
48
|
|
54
49
|
def test_teardwown
|
55
|
-
@
|
56
|
-
@
|
50
|
+
@formatter.should.receive(:add_context).with :any_args
|
51
|
+
@formatter.should.receive(:add_spec).with :any_args
|
57
52
|
$teardwown_ran = false
|
58
53
|
@context.teardown {$teardwown_ran = true}
|
59
54
|
@context.specify("test") {true}
|
60
|
-
@context.run(@
|
55
|
+
@context.run(@formatter)
|
61
56
|
assert $teardwown_ran
|
62
|
-
@
|
57
|
+
@formatter.__verify
|
63
58
|
end
|
64
|
-
|
59
|
+
|
60
|
+
def test_spec_count_1
|
61
|
+
@context.specify("test") {}
|
62
|
+
assert_equal(1, @context.number_of_specs)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_spec_count_4
|
66
|
+
@context.specify("one") {}
|
67
|
+
@context.specify("two") {}
|
68
|
+
@context.specify("three") {}
|
69
|
+
@context.specify("four") {}
|
70
|
+
assert_equal(4, @context.number_of_specs)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_matches_should_pass_if_matches_context_and_spec
|
74
|
+
@context.specify("spec") {}
|
75
|
+
assert @context.matches? "context spec"
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_matches_should_fail_if_input_does_not_start_with_name
|
79
|
+
assert !@context.matches?("contextual spec")
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_matches_should_fail_if_input_does_not_include_valid_spec
|
83
|
+
assert !@context.matches?("context spec")
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_isolate_should_trim_specs
|
87
|
+
@context.specify("spec1") {}
|
88
|
+
@context.specify("spec2") {}
|
89
|
+
@context.isolate "context spec1"
|
90
|
+
assert_equal 1, @context.number_of_specs
|
91
|
+
end
|
92
|
+
|
65
93
|
end
|
66
94
|
end
|
67
95
|
end
|
@@ -3,11 +3,12 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Runner
|
5
5
|
class ExecutionContextTest < Test::Unit::TestCase
|
6
|
+
|
6
7
|
def test_should_add_new_mock_to_spec_when_mock_message_received
|
7
8
|
spec = Api::Mock.new "spec"
|
8
9
|
spec.should.receive(:add_mock) {|mock| mock.instance_of? Api::Mock}
|
9
10
|
ec = ExecutionContext.new spec
|
10
|
-
mock = ec.mock("a mock")
|
11
|
+
mock = ec.mock("a mock", :null_object=>true)
|
11
12
|
end
|
12
13
|
|
13
14
|
def test_violated
|
@@ -19,8 +20,8 @@ module Spec
|
|
19
20
|
def test_duck_type
|
20
21
|
ec = ExecutionContext.new(Api::Mock.new("spec", :null_object => true))
|
21
22
|
duck_type = ec.duck_type(:length)
|
22
|
-
assert
|
23
|
-
assert
|
23
|
+
assert duck_type.is_a?(Api::DuckTypeArgConstraint)
|
24
|
+
assert duck_type.matches?([])
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Runner
|
5
|
+
class ProgressBarFormatterFailureDumpTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@io = StringIO.new
|
9
|
+
@reporter = Reporter.new(ProgressBarFormatter.new(@io), QuietBacktraceTweaker.new)
|
10
|
+
@reporter.add_context "context"
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_backtrace error
|
14
|
+
error.set_backtrace ["/a/b/c/d/e.rb:34:in `__instance_exec'"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_spacing_between_sections
|
18
|
+
error = Spec::Api::ExpectationNotMetError.new "message"
|
19
|
+
set_backtrace error
|
20
|
+
@reporter.add_spec "spec", error, "spec"
|
21
|
+
@reporter.dump
|
22
|
+
assert_match(/\nF\n\n1\)\nExpectationNotMetError in 'context spec'\nmessage\n\/a\/b\/c\/d\/e.rb:34:in `spec'\n\nFinished in /, @io.string)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_end_with_line_break
|
26
|
+
error = Spec::Api::ExpectationNotMetError.new "message"
|
27
|
+
set_backtrace error
|
28
|
+
@reporter.add_spec "spec", error, "spec"
|
29
|
+
@reporter.dump
|
30
|
+
assert_match(/\n\z/, @io.string)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_should_include_informational_header
|
34
|
+
error = Spec::Api::ExpectationNotMetError.new "message"
|
35
|
+
set_backtrace error
|
36
|
+
@reporter.add_spec "spec", error, "spec"
|
37
|
+
@reporter.dump
|
38
|
+
assert_match(/^ExpectationNotMetError in 'context spec'/, @io.string)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_should_include_context_and_spec_name_in_backtrace_if_error_in_spec
|
42
|
+
error = RuntimeError.new "message"
|
43
|
+
set_backtrace error
|
44
|
+
@reporter.add_spec "spec", error, "spec"
|
45
|
+
@reporter.dump
|
46
|
+
assert_match(/RuntimeError in 'context spec'/, @io.string)
|
47
|
+
assert_match(/:in `spec'/, @io.string)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_should_include_context_and_setup_in_backtrace_if_error_in_setup
|
51
|
+
error = RuntimeError.new
|
52
|
+
set_backtrace error
|
53
|
+
@reporter.add_spec "spec", error, "setup"
|
54
|
+
@reporter.dump
|
55
|
+
assert_match(/RuntimeError in 'context spec'/, @io.string)
|
56
|
+
assert_match(/in `setup'/, @io.string)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_should_include_context_and_teardown_in_backtrace_if_error_in_teardown
|
60
|
+
error = RuntimeError.new
|
61
|
+
set_backtrace error
|
62
|
+
@reporter.add_spec "spec", error, "teardown"
|
63
|
+
@reporter.dump
|
64
|
+
assert_match(/RuntimeError in 'context spec'/, @io.string)
|
65
|
+
assert_match(/in `teardown'/, @io.string)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
class SpecdocFormatterFailureDumpTest < Test::Unit::TestCase
|
71
|
+
|
72
|
+
def setup
|
73
|
+
@io = StringIO.new
|
74
|
+
@reporter = Reporter.new(SpecdocFormatter.new(@io), QuietBacktraceTweaker.new)
|
75
|
+
@reporter.add_context "context"
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_backtrace error
|
79
|
+
error.set_backtrace ["/a/b/c/d/e.rb:34:in `__instance_exec'"]
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_spacing_between_sections
|
83
|
+
error = Spec::Api::ExpectationNotMetError.new "message"
|
84
|
+
set_backtrace error
|
85
|
+
@reporter.add_spec "spec", error, "spec"
|
86
|
+
@reporter.dump
|
87
|
+
assert_match(/\ncontext\n- spec \(FAILED - 1\)\n\n1\)\nExpectationNotMetError in 'context spec'\nmessage\n\/a\/b\/c\/d\/e.rb:34:in `spec'\n\nFinished in /, @io.string)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -21,54 +21,74 @@ module Spec
|
|
21
21
|
assert_match(/Usage: spec \[options\] \(FILE\|DIRECTORY\)\+/n, @out.read)
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def test_verbose_should_be_false_by_default
|
25
25
|
options = OptionParser.parse([], false, @err, @out)
|
26
26
|
assert(!options.verbose)
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
options = OptionParser.parse([], false, @err)
|
31
|
-
|
29
|
+
def test_dry_run_should_be_settable
|
30
|
+
options = OptionParser.parse(["--dry-run"], false, @err, @out)
|
31
|
+
assert(options.dry_run)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_use_progress_bar_formatter_by_default
|
35
|
+
options = OptionParser.parse([], false, @err, @out)
|
36
|
+
assert_equal(ProgressBarFormatter, options.formatter_type)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_should_use_specdoc_formatter_when_format_is_specdoc
|
40
|
+
options = OptionParser.parse(["--format","specdoc"], false, @err, @out)
|
41
|
+
assert_equal(SpecdocFormatter, options.formatter_type)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_should_use_specdoc_formatter_when_format_is_s
|
45
|
+
options = OptionParser.parse(["--format","s"], false, @err, @out)
|
46
|
+
assert_equal(SpecdocFormatter, options.formatter_type)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_use_rdoc_formatter_when_format_is_rdoc
|
50
|
+
options = OptionParser.parse(["--format","rdoc"], false, @err, @out)
|
51
|
+
assert_equal(RdocFormatter, options.formatter_type)
|
32
52
|
end
|
33
53
|
|
34
|
-
def
|
35
|
-
options = OptionParser.parse(["
|
36
|
-
|
54
|
+
def test_should_use_rdoc_formatter_when_format_is_r
|
55
|
+
options = OptionParser.parse(["--format","r"], false, @err, @out)
|
56
|
+
assert_equal(RdocFormatter, options.formatter_type)
|
37
57
|
end
|
38
58
|
|
39
|
-
def
|
40
|
-
options = OptionParser.parse(["--
|
41
|
-
assert(options.
|
59
|
+
def test_should_select_dry_run_for_rdoc_formatter
|
60
|
+
options = OptionParser.parse(["--format","rdoc"], false, @err, @out)
|
61
|
+
assert(options.dry_run)
|
42
62
|
end
|
43
63
|
|
44
|
-
def
|
64
|
+
def test_should_print_usage_to_err_if_no_dir_specified
|
45
65
|
options = OptionParser.parse([], false, @err, @out)
|
46
|
-
|
66
|
+
assert_match(/Usage: spec/, @err.string)
|
47
67
|
end
|
48
68
|
|
49
|
-
def
|
50
|
-
options = OptionParser.parse([
|
51
|
-
assert
|
69
|
+
def test_backtrace_tweaker_should_be_quiet_by_default
|
70
|
+
options = OptionParser.parse([], false, @err, @out)
|
71
|
+
assert options.backtrace_tweaker.instance_of?(QuietBacktraceTweaker)
|
52
72
|
end
|
53
73
|
|
54
|
-
def
|
55
|
-
options = OptionParser.parse(["-
|
56
|
-
|
74
|
+
def test_backtrace_tweaker_should_be_noisy_with_b
|
75
|
+
options = OptionParser.parse(["-b"], false, @err, @out)
|
76
|
+
assert options.backtrace_tweaker.instance_of?(NoisyBacktraceTweaker)
|
57
77
|
end
|
58
78
|
|
59
|
-
def
|
60
|
-
options = OptionParser.parse(["--
|
61
|
-
|
79
|
+
def test_backtrace_tweaker_should_be_noisy_with_backtrace
|
80
|
+
options = OptionParser.parse(["--backtrace"], false, @err, @out)
|
81
|
+
assert options.backtrace_tweaker.instance_of?(NoisyBacktraceTweaker)
|
62
82
|
end
|
63
|
-
|
64
|
-
def
|
65
|
-
options = OptionParser.parse([], false, @err, @out)
|
66
|
-
|
83
|
+
|
84
|
+
def test_should_support_single_spec_with_spec
|
85
|
+
options = OptionParser.parse(["--spec","something or other"], false, @err, @out)
|
86
|
+
assert_equal "something or other", options.spec_name
|
67
87
|
end
|
68
88
|
|
69
|
-
def
|
70
|
-
options = OptionParser.parse(["-
|
71
|
-
options.
|
89
|
+
def test_should_support_single_spec_with_s
|
90
|
+
options = OptionParser.parse(["-s","something or other"], false, @err, @out)
|
91
|
+
assert_equal "something or other", options.spec_name
|
72
92
|
end
|
73
93
|
end
|
74
94
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
module Spec
|
3
|
+
module Runner
|
4
|
+
class ProgressBarFormatterTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@io = StringIO.new
|
8
|
+
@formatter = ProgressBarFormatter.new(@io)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_push_line_break_for_context
|
12
|
+
@formatter.add_context("context", :ignored)
|
13
|
+
assert_equal("\n", @io.string)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_push_dot_for_passing_spec
|
17
|
+
@formatter.spec_passed("spec")
|
18
|
+
assert_equal(".", @io.string)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_push_F_for_failing_spec
|
22
|
+
@formatter.spec_failed("spec", 98)
|
23
|
+
assert_equal("F", @io.string)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_produce_standard_summary
|
27
|
+
@formatter.dump_summary(4,3,2,1)
|
28
|
+
assert_equal("\nFinished in 4 seconds\n\n3 contexts, 2 specifications, 1 failure\n", @io.string)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_produce_line_break_on_start_dump
|
32
|
+
@formatter.start_dump
|
33
|
+
assert_equal("\n", @io.string)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
class ProgressBarFormatterDryRunTest < Test::Unit::TestCase
|
37
|
+
def setup
|
38
|
+
@io = StringIO.new
|
39
|
+
@formatter = ProgressBarFormatter.new(@io, true)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_should_not_produce_summary_on_dry_run
|
43
|
+
@formatter.dump_summary(4,3,2,1)
|
44
|
+
assert_equal("", @io.string)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|