rspec 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/CHANGES +57 -32
  2. data/EXAMPLES.rd +0 -0
  3. data/Rakefile +22 -21
  4. data/bin/spec +9 -11
  5. data/doc/README +1 -3
  6. data/doc/plugin/syntax.rb +27 -5
  7. data/doc/src/core_team.page +22 -0
  8. data/doc/src/default.css +11 -11
  9. data/doc/src/default.template +0 -1
  10. data/doc/src/documentation/index.page +183 -8
  11. data/doc/src/documentation/meta.info +7 -7
  12. data/doc/src/documentation/mocks.page +168 -109
  13. data/doc/src/documentation/underscores.page +20 -0
  14. data/doc/src/examples.page +2 -1
  15. data/doc/src/images/David_and_Aslak.jpg +0 -0
  16. data/doc/src/images/Whats_That_Dude.jpg +0 -0
  17. data/doc/src/index.page +70 -3
  18. data/doc/src/meta.info +18 -11
  19. data/doc/src/tools/index.page +40 -134
  20. data/doc/src/tools/meta.info +9 -3
  21. data/doc/src/tools/rails.page +3 -1
  22. data/doc/src/tools/rake.page +20 -3
  23. data/doc/src/tools/rcov.page +19 -0
  24. data/doc/src/tools/spec.page +99 -0
  25. data/doc/src/tools/test2rspec.page +2 -4
  26. data/doc/src/tutorials/index.page +52 -0
  27. data/doc/src/tutorials/meta.info +31 -0
  28. data/doc/src/tutorials/notes.txt +252 -0
  29. data/doc/src/tutorials/stack.rb +11 -0
  30. data/doc/src/tutorials/stack_01.page +224 -0
  31. data/doc/src/tutorials/stack_02.page +180 -0
  32. data/doc/src/tutorials/stack_03.page +291 -0
  33. data/doc/src/tutorials/stack_04.page +203 -0
  34. data/doc/src/tutorials/stack_04.page.orig +123 -0
  35. data/doc/src/tutorials/stack_05.page +90 -0
  36. data/doc/src/tutorials/stack_05.page.orig +124 -0
  37. data/doc/src/tutorials/stack_06.page +359 -0
  38. data/doc/src/tutorials/stack_06.page.orig +359 -0
  39. data/doc/src/tutorials/stack_spec.rb +41 -0
  40. data/examples/airport_spec.rb +4 -4
  41. data/examples/{spec_framework_spec.rb → bdd_framework_spec.rb} +6 -7
  42. data/examples/mocking_spec.rb +0 -5
  43. data/examples/stack_spec.rb +6 -7
  44. data/examples/sugar_spec.rb +14 -0
  45. data/lib/spec/api.rb +5 -2
  46. data/lib/spec/api/helper/should_base.rb +17 -22
  47. data/lib/spec/api/helper/should_helper.rb +4 -3
  48. data/lib/spec/api/helper/should_negator.rb +3 -2
  49. data/lib/spec/api/mocks/argument_expectation.rb +104 -0
  50. data/lib/spec/api/{mock.rb → mocks/message_expectation.rb} +47 -96
  51. data/lib/spec/api/mocks/mock.rb +63 -0
  52. data/lib/spec/api/mocks/order_group.rb +21 -0
  53. data/lib/spec/api/sugar.rb +47 -0
  54. data/lib/spec/rake/rcov_verify.rb +45 -0
  55. data/lib/spec/rake/spectask.rb +41 -56
  56. data/lib/spec/runner.rb +4 -1
  57. data/lib/spec/runner/backtrace_tweaker.rb +24 -3
  58. data/lib/spec/runner/base_text_formatter.rb +28 -0
  59. data/lib/spec/runner/context.rb +21 -18
  60. data/lib/spec/runner/context_runner.rb +20 -31
  61. data/lib/spec/runner/execution_context.rb +3 -3
  62. data/lib/spec/runner/kernel_ext.rb +10 -1
  63. data/lib/spec/runner/option_parser.rb +32 -14
  64. data/lib/spec/runner/progress_bar_formatter.rb +21 -0
  65. data/lib/spec/runner/rdoc_formatter.rb +15 -5
  66. data/lib/spec/runner/reporter.rb +100 -0
  67. data/lib/spec/runner/specdoc_formatter.rb +20 -0
  68. data/lib/spec/runner/specification.rb +42 -22
  69. data/lib/spec/version.rb +1 -1
  70. data/test/rcov/rcov_testtask.rb +1 -0
  71. data/test/spec/api/duck_type_test.rb +4 -4
  72. data/test/spec/api/helper/raising_test.rb +37 -17
  73. data/test/spec/api/{mock_arg_constraints_test.rb → mocks/mock_arg_constraints_test.rb} +10 -4
  74. data/test/spec/api/mocks/mock_ordering_test.rb +62 -0
  75. data/test/spec/api/{mock_test.rb → mocks/mock_test.rb} +30 -7
  76. data/test/spec/api/mocks/null_object_test.rb +31 -0
  77. data/test/spec/api/sugar_test.rb +71 -0
  78. data/test/spec/runner/backtrace_tweaker_test.rb +52 -4
  79. data/test/spec/runner/context_runner_test.rb +41 -21
  80. data/test/spec/runner/context_test.rb +60 -32
  81. data/test/spec/runner/execution_context_test.rb +4 -3
  82. data/test/spec/runner/failure_dump_test.rb +92 -0
  83. data/test/spec/runner/kernel_ext_test.rb +1 -2
  84. data/test/spec/runner/option_parser_test.rb +48 -28
  85. data/test/spec/runner/progress_bar_formatter_test.rb +48 -0
  86. data/test/spec/runner/rdoc_formatter_test.rb +31 -4
  87. data/test/spec/runner/reporter_test.rb +103 -0
  88. data/test/spec/runner/specdoc_formatter_test.rb +50 -0
  89. data/test/spec/runner/specification_test.rb +49 -11
  90. data/test/test_helper.rb +1 -4
  91. metadata +46 -15
  92. data/doc/src/community.page +0 -7
  93. data/doc/src/documentation/api.page +0 -185
  94. data/doc/src/why_rspec.page +0 -7
  95. data/examples/empty_stack_spec.rb +0 -22
  96. data/examples/team_spec.rb +0 -30
  97. data/lib/spec/api/duck_type.rb +0 -16
  98. data/lib/spec/runner/simple_text_reporter.rb +0 -88
  99. data/test/rcov/rcov_verify.rb +0 -28
  100. 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
- runner = ContextRunner.new ["-o","stringio"], false, StringIO.new
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
- def test_should_call_run_for_standalone
34
- context1 = Api::Mock.new "context1"
35
- context1.should.receive(:run)
36
- runner = ContextRunner.standalone context1, ["-o","stringio"]
37
- context1.__verify
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
- @listener = Api::Mock.new "listener"
8
+ @formatter = Api::Mock.new "formatter"
9
9
  @context = Context.new("context") {}
10
10
  end
11
11
 
12
- def test_should_add_itself_to_listener_on_run
13
- @listener.should.receive(:add_context).with "context"
14
- @context.run(@listener)
15
- @listener.__verify
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 test_should_add_itself_to_listener_on_run_docs
19
- @listener.should.receive(:add_context).with "context"
20
- @context.run_docs(@listener)
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(@listener)
23
+ @context.run(@formatter)
30
24
  assert $spec_ran
31
- @listener.__verify
25
+ @formatter.__verify
32
26
  end
33
27
 
34
- def test_spec_doc
35
- @listener.should.receive(:add_context).with :any_args
36
- @listener.should.receive(:add_spec).with "test"
37
- @context.specify("test") {}
38
- @context.run_docs(@listener)
39
- assert $spec_ran
40
- @listener.__verify
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
- @listener.should.receive(:add_context).with :any_args
45
- @listener.should.receive(:add_spec).with :any_args
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(@listener)
44
+ @context.run(@formatter)
50
45
  assert $setup_ran
51
- @listener.__verify
46
+ @formatter.__verify
52
47
  end
53
48
 
54
49
  def test_teardwown
55
- @listener.should.receive(:add_context).with :any_args
56
- @listener.should.receive(:add_spec).with :any_args
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(@listener)
55
+ @context.run(@formatter)
61
56
  assert $teardwown_ran
62
- @listener.__verify
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(duck_type.is_a? Api::DuckType)
23
- assert(duck_type.walks_like? [])
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
@@ -5,9 +5,8 @@ module Spec
5
5
  class KernelExtTest < Test::Unit::TestCase
6
6
  def test_create_context
7
7
  assert_nothing_raised do
8
- @cxt = context("") {}
8
+ context("") {}
9
9
  end
10
- assert @cxt.instance_of? Spec::Runner::Context
11
10
  end
12
11
  end
13
12
  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 test_verbose_should_be_true_by_default
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 test_out_should_be_stdout_by_default
30
- options = OptionParser.parse([], false, @err)
31
- assert_equal(STDOUT, options.out)
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 test_verbose_should_be_settable_with_v
35
- options = OptionParser.parse(["-v"], false, @err, @out)
36
- assert(options.verbose)
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 test_verbose_should_be_settable_with_verbose
40
- options = OptionParser.parse(["--verbose"], false, @err, @out)
41
- assert(options.verbose)
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 test_doc_should_be_false_by_default
64
+ def test_should_print_usage_to_err_if_no_dir_specified
45
65
  options = OptionParser.parse([], false, @err, @out)
46
- assert(!options.doc)
66
+ assert_match(/Usage: spec/, @err.string)
47
67
  end
48
68
 
49
- def test_doc_should_be_settable_with_d
50
- options = OptionParser.parse(["-d"], false, @err, @out)
51
- assert(options.doc)
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 test_out_should_be_settable_with_o
55
- options = OptionParser.parse(["-o","test.txt"], false, @err, @out)
56
- assert_equal("test.txt", options.out)
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 test_out_should_be_settable_with_of
60
- options = OptionParser.parse(["--of","test.txt"], false, @err, @out)
61
- assert_equal("test.txt", options.out)
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 test_should_print_usage_to_err_if_no_dir_specified
65
- options = OptionParser.parse([], false, @err, @out)
66
- assert_match(/Usage: spec/, @err.string)
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 test_out_should_be_stringio_if_set_to_stringio
70
- options = OptionParser.parse(["-o","stringio"], false, @err, @out)
71
- options.out.should.be.an.instance.of StringIO
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