rspec 0.5.12 → 0.5.13

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.
Files changed (54) hide show
  1. data/CHANGES +9 -1
  2. data/README +2 -2
  3. data/Rakefile +13 -5
  4. data/examples/custom_formatter.rb +2 -2
  5. data/examples/file_accessor.rb +18 -0
  6. data/examples/file_accessor_spec.rb +38 -0
  7. data/examples/io_processor.rb +8 -0
  8. data/examples/io_processor_spec.rb +21 -0
  9. data/lib/spec/api/exceptions.rb +3 -0
  10. data/lib/spec/api/mocks/message_expectation.rb +45 -29
  11. data/lib/spec/api/mocks/mock.rb +1 -1
  12. data/lib/spec/api/mocks/order_group.rb +1 -1
  13. data/lib/spec/runner.rb +1 -5
  14. data/lib/spec/runner/formatter.rb +5 -0
  15. data/lib/spec/runner/formatter/base_text_formatter.rb +79 -0
  16. data/lib/spec/runner/formatter/html_formatter.rb +156 -0
  17. data/lib/spec/runner/formatter/progress_bar_formatter.rb +27 -0
  18. data/lib/spec/runner/formatter/rdoc_formatter.rb +22 -0
  19. data/lib/spec/runner/formatter/specdoc_formatter.rb +22 -0
  20. data/lib/spec/runner/option_parser.rb +17 -17
  21. data/lib/spec/runner/reporter.rb +1 -1
  22. data/lib/spec/version.rb +1 -1
  23. data/test/spec/api/helper/arbitrary_predicate_test.rb +38 -38
  24. data/test/spec/api/helper/diff_test.rb +1 -1
  25. data/test/spec/api/helper/identity_test.rb +17 -10
  26. data/test/spec/api/helper/{equality_test.rb → object_equality_test.rb} +15 -29
  27. data/test/spec/api/helper/regex_matching_test.rb +7 -9
  28. data/test/spec/api/helper/throwing_test.rb +11 -12
  29. data/test/spec/api/helper/true_false_special_case_test.rb +15 -17
  30. data/test/spec/api/helper/typing_test.rb +27 -26
  31. data/test/spec/api/mocks/mock_arg_constraints_test.rb +1 -1
  32. data/test/spec/api/mocks/mock_test.rb +45 -11
  33. data/test/spec/api/mocks/null_object_test.rb +3 -3
  34. data/test/spec/runner/context_matching_test.rb +2 -2
  35. data/test/spec/runner/formatter/failure_dump_test.rb +94 -0
  36. data/test/spec/runner/formatter/html_formatter_test.rb +48 -0
  37. data/test/spec/runner/formatter/progress_bar_formatter_test.rb +56 -0
  38. data/test/spec/runner/formatter/rdoc_formatter_test.rb +51 -0
  39. data/test/spec/runner/formatter/specdoc_formatter_test.rb +57 -0
  40. data/test/spec/runner/kernel_ext_test.rb +1 -1
  41. data/test/spec/runner/option_parser_test.rb +22 -12
  42. data/test/spec/runner/reporter_test.rb +1 -1
  43. data/test/test_classes.rb +7 -7
  44. metadata +19 -14
  45. data/lib/spec/runner/base_text_formatter.rb +0 -77
  46. data/lib/spec/runner/html_formatter.rb +0 -153
  47. data/lib/spec/runner/progress_bar_formatter.rb +0 -25
  48. data/lib/spec/runner/rdoc_formatter.rb +0 -20
  49. data/lib/spec/runner/specdoc_formatter.rb +0 -20
  50. data/test/spec/runner/failure_dump_test.rb +0 -92
  51. data/test/spec/runner/html_formatter_test.rb +0 -47
  52. data/test/spec/runner/progress_bar_formatter_test.rb +0 -54
  53. data/test/spec/runner/rdoc_formatter_test.rb +0 -50
  54. data/test/spec/runner/specdoc_formatter_test.rb +0 -55
metadata CHANGED
@@ -3,9 +3,9 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rspec
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.12
7
- date: 2006-06-16 00:00:00 -05:00
8
- summary: RSpec-0.5.12 - BDD for Ruby http://rspec.rubyforge.org/
6
+ version: 0.5.13
7
+ date: 2006-06-22 00:00:00 -05:00
8
+ summary: RSpec-0.5.13 - BDD for Ruby http://rspec.rubyforge.org/
9
9
  require_paths:
10
10
  - lib
11
11
  email: rspec-devel@rubyforge.org
@@ -58,20 +58,21 @@ files:
58
58
  - lib/spec/rake/rcov_verify.rb
59
59
  - lib/spec/rake/spectask.rb
60
60
  - lib/spec/runner/backtrace_tweaker.rb
61
- - lib/spec/runner/base_text_formatter.rb
62
61
  - lib/spec/runner/context.rb
63
62
  - lib/spec/runner/context_runner.rb
64
63
  - lib/spec/runner/execution_context.rb
65
- - lib/spec/runner/html_formatter.rb
64
+ - lib/spec/runner/formatter.rb
66
65
  - lib/spec/runner/instance_exec.rb
67
66
  - lib/spec/runner/kernel_ext.rb
68
67
  - lib/spec/runner/option_parser.rb
69
- - lib/spec/runner/progress_bar_formatter.rb
70
- - lib/spec/runner/rdoc_formatter.rb
71
68
  - lib/spec/runner/reporter.rb
72
69
  - lib/spec/runner/spec_matcher.rb
73
- - lib/spec/runner/specdoc_formatter.rb
74
70
  - lib/spec/runner/specification.rb
71
+ - lib/spec/runner/formatter/base_text_formatter.rb
72
+ - lib/spec/runner/formatter/html_formatter.rb
73
+ - lib/spec/runner/formatter/progress_bar_formatter.rb
74
+ - lib/spec/runner/formatter/rdoc_formatter.rb
75
+ - lib/spec/runner/formatter/specdoc_formatter.rb
75
76
  - lib/spec/test_to_spec/ruby2ruby.rb
76
77
  - lib/spec/test_to_spec/sexp_transformer.rb
77
78
  - lib/spec/test_to_spec/test_case_ext.rb
@@ -83,8 +84,8 @@ files:
83
84
  - test/spec/api/helper/arbitrary_predicate_test.rb
84
85
  - test/spec/api/helper/containment_test.rb
85
86
  - test/spec/api/helper/diff_test.rb
86
- - test/spec/api/helper/equality_test.rb
87
87
  - test/spec/api/helper/identity_test.rb
88
+ - test/spec/api/helper/object_equality_test.rb
88
89
  - test/spec/api/helper/raising_test.rb
89
90
  - test/spec/api/helper/regex_matching_test.rb
90
91
  - test/spec/api/helper/should_have_test.rb
@@ -101,16 +102,16 @@ files:
101
102
  - test/spec/runner/context_runner_test.rb
102
103
  - test/spec/runner/context_test.rb
103
104
  - test/spec/runner/execution_context_test.rb
104
- - test/spec/runner/failure_dump_test.rb
105
- - test/spec/runner/html_formatter_test.rb
106
105
  - test/spec/runner/kernel_ext_test.rb
107
106
  - test/spec/runner/option_parser_test.rb
108
- - test/spec/runner/progress_bar_formatter_test.rb
109
- - test/spec/runner/rdoc_formatter_test.rb
110
107
  - test/spec/runner/reporter_test.rb
111
108
  - test/spec/runner/spec_matcher_test.rb
112
- - test/spec/runner/specdoc_formatter_test.rb
113
109
  - test/spec/runner/specification_test.rb
110
+ - test/spec/runner/formatter/failure_dump_test.rb
111
+ - test/spec/runner/formatter/html_formatter_test.rb
112
+ - test/spec/runner/formatter/progress_bar_formatter_test.rb
113
+ - test/spec/runner/formatter/rdoc_formatter_test.rb
114
+ - test/spec/runner/formatter/specdoc_formatter_test.rb
114
115
  - test/spec/test_to_spec/ruby_to_ruby_test.rb
115
116
  - test/spec/test_to_spec/sexp_transformer_assertion_test.rb
116
117
  - test/spec/test_to_spec/sexp_transformer_test.rb
@@ -120,6 +121,10 @@ files:
120
121
  - examples/airport_spec.rb
121
122
  - examples/bdd_framework_spec.rb
122
123
  - examples/custom_formatter.rb
124
+ - examples/file_accessor.rb
125
+ - examples/file_accessor_spec.rb
126
+ - examples/io_processor.rb
127
+ - examples/io_processor_spec.rb
123
128
  - examples/mocking_spec.rb
124
129
  - examples/stack.rb
125
130
  - examples/stack_spec.rb
@@ -1,77 +0,0 @@
1
- module Spec
2
- module Runner
3
- # Baseclass for text-based formatters. Can in fact be used for
4
- # non-text based ones too - just ignore the +output+ constructor
5
- # argument.
6
- class BaseTextFormatter
7
- def initialize(output, dry_run=false)
8
- @dry_run = dry_run
9
- @output = output
10
- end
11
-
12
- # This method is invoked before any specs are run, right after
13
- # they have all been collected. This can be useful for special
14
- # formatters that need to provide progress on feedback (graphical ones)
15
- #
16
- # This method will only be invoked once, and the next one to be invoked
17
- # is #add_context
18
- def start(spec_count)
19
- end
20
-
21
- # This method is invoked at the beginning of the execution of each context.
22
- # +name+ is the name of the context and +first+ is true if it is the
23
- # first context - otherwise it's false.
24
- #
25
- # The next method to be invoked after this is #spec_started
26
- def add_context(name, first)
27
- end
28
-
29
- # This method is invoked right before a spec is executed.
30
- # The next method to be invoked after this one is one of #spec_failed
31
- # or #spec_passed.
32
- def spec_started(name)
33
- end
34
-
35
- # This method is invoked when a spec fails, i.e. an exception occurred
36
- # inside it (such as a failed should or other exception). +name+ is the name
37
- # of the specification. +counter+ is the sequence number of the failure
38
- # (starting at 1) and +failure+ is the associated Failure object.
39
- def spec_failed(name, counter, failure)
40
- end
41
-
42
- # This method is invoked when a spec passes. +name+ is the name of the
43
- # specification.
44
- def spec_passed(name)
45
- end
46
-
47
- # This method is invoked after all of the specs have executed. The next method
48
- # to be invoked after this one is #dump_failure (once for each failed spec),
49
- def start_dump
50
- end
51
-
52
- # Dumps detailed information about a spec failure.
53
- # This method is invoked for each failed spec after all specs have run. +counter+ is the sequence number
54
- # of the associated spec. +failure+ is a Failure object, which contains detailed
55
- # information about the failure.
56
- def dump_failure(counter, failure)
57
- @output << "\n"
58
- @output << counter.to_s << ")\n"
59
- @output << "#{failure.header}\n"
60
- @output << "#{failure.message}\n"
61
- @output << "#{failure.backtrace}\n"
62
- @output.flush
63
- end
64
-
65
- # This method is invoked at the very end.
66
- def dump_summary(duration, spec_count, failure_count)
67
- return if @dry_run
68
- @output << "\n"
69
- @output << "Finished in " << (duration).to_s << " seconds\n\n"
70
- @output << "#{spec_count} specification#{'s' unless spec_count == 1}, "
71
- @output << "#{failure_count} failure#{'s' unless failure_count == 1}"
72
- @output << "\n"
73
- @output.flush
74
- end
75
- end
76
- end
77
- end
@@ -1,153 +0,0 @@
1
- require 'spec/runner/base_text_formatter'
2
-
3
- module Spec
4
- module Runner
5
- class HtmlFormatter < Spec::Runner::BaseTextFormatter
6
- def initialize(output, dry_run=false)
7
- super
8
- @current_count = 0
9
- end
10
-
11
- def start(spec_count)
12
- @spec_count = spec_count
13
-
14
- @output.puts HEADER
15
- @output.flush
16
- end
17
-
18
- def add_context(name, first)
19
- unless first
20
- @output.puts " </div>"
21
- @output.puts "</div>"
22
- end
23
- @output.puts "<div class=\"context\">"
24
- @output.puts " <div>#{name}</div>"
25
- @output.puts " <div>"
26
- end
27
-
28
- def start_dump
29
- @output.puts " </div>"
30
- @output.puts "</div>"
31
- @output.flush
32
- end
33
-
34
- def spec_started(name)
35
- @current_spec = name
36
- @current_count += 1
37
- end
38
-
39
- def spec_passed(name)
40
- @output.puts "<div class=\"spec passed\">#{escape(@current_spec)}</div>"
41
- end
42
-
43
- def spec_failed(name, counter, failure)
44
- @output.puts "<div class=\"spec failed\">"
45
- @output.puts " <a href=\"#\" onclick=\"toggle('failure_#{counter}');return false;\">#{escape(@current_spec)}</a>"
46
- @output.puts " <div class=\"failure\" id=\"failure_#{counter}\" style=\"display:none\">"
47
- @output.puts " <div><pre>#{escape(failure.header)}</pre></div>" unless failure.header == ""
48
- @output.puts " <div><pre>#{escape(failure.message)}</pre></div>" unless failure.message == ""
49
- @output.puts " <div><pre>#{escape(failure.backtrace)}</pre></div>" unless failure.backtrace == ""
50
- @output.puts " </div>"
51
- @output.puts "</div>"
52
- @output.flush
53
- end
54
-
55
- def escape(string)
56
- string.gsub(/&/n, '&amp;').gsub(/\"/n, '&quot;').gsub(/>/n, '&gt;').gsub(/</n, '&lt;')
57
- end
58
-
59
- def dump_failure(counter, failure)
60
- # @output << "\n"
61
- # @output << counter.to_s << ")\n"
62
- # @output << "#{failure.header}\n"
63
- # @output << "#{failure.message}\n"
64
- # @output << "#{failure.backtrace}\n"
65
- # @output.flush
66
- end
67
-
68
- def dump_summary(duration, spec_count, failure_count)
69
- @output << "</body>"
70
- @output << "</html>"
71
- @output.flush
72
- end
73
-
74
- HEADER = <<-HEADER
75
- <?xml version="1.0" encoding="iso-8859-1"?>
76
- <!DOCTYPE html
77
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
78
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
79
-
80
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
81
- <head>
82
- <title>RSpec results</title>
83
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
84
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
85
- <style type="text/css">
86
- body {
87
- font-size: 10pt;
88
- font: "lucida grande";
89
- width: 85%;
90
- }
91
-
92
- .passed {
93
- background-color: #DDFFDD;
94
- }
95
-
96
- .failed {
97
- background-color: #FFDDDD;
98
- font-weight: bold;
99
- }
100
-
101
- .failed .failure {
102
- background-color: #FFDDDD;
103
- font-weight: normal;
104
- font-size: 9pt;
105
- }
106
-
107
- .context {
108
- padding:4px;
109
- border:1px solid #000000;
110
- margin-top:4px;
111
- }
112
-
113
- :link, :visited {
114
- color: #000000;
115
- text-decoration: none;
116
- padding-bottom: 0px;
117
- }
118
-
119
- :link:hover, :visited:hover {
120
- color: #c00;
121
- }
122
-
123
- </style>
124
- <script type="text/javascript">
125
- // <![CDATA[
126
-
127
- function toggle( id ) {
128
- if ( document.getElementById )
129
- elem = document.getElementById( id );
130
- else if ( document.all )
131
- elem = eval( "document.all." + id );
132
- else
133
- return false;
134
-
135
- elemStyle = elem.style;
136
-
137
- if ( elemStyle.display != "block" ) {
138
- elemStyle.display = "block"
139
- } else {
140
- elemStyle.display = "none"
141
- }
142
-
143
- return true;
144
- }
145
- // ]]>
146
- </script>
147
-
148
- </head>
149
- <body>
150
- HEADER
151
- end
152
- end
153
- end
@@ -1,25 +0,0 @@
1
- module Spec
2
- module Runner
3
- class ProgressBarFormatter < BaseTextFormatter
4
- def add_context(name, first)
5
- @output << "\n" if first
6
- @output.flush
7
- end
8
-
9
- def spec_failed(name, counter, failure)
10
- @output << 'F'
11
- @output.flush
12
- end
13
-
14
- def spec_passed(name)
15
- @output << '.'
16
- @output.flush
17
- end
18
-
19
- def start_dump
20
- @output << "\n"
21
- @output.flush
22
- end
23
- end
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- module Spec
2
- module Runner
3
- class RdocFormatter < BaseTextFormatter
4
- def add_context(name, first)
5
- @output << "# #{name}\n"
6
- @output.flush
7
- end
8
-
9
- def spec_passed(name)
10
- @output << "# * #{name}\n"
11
- @output.flush
12
- end
13
-
14
- def spec_failed(name, counter, failure)
15
- @output << "# * #{name} [#{counter} - FAILED]\n"
16
- @output.flush
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- module Spec
2
- module Runner
3
- class SpecdocFormatter < BaseTextFormatter
4
- def add_context(name, first)
5
- @output << "\n#{name}\n"
6
- @output.flush
7
- end
8
-
9
- def spec_failed(name, counter, failure)
10
- @output << "- #{name} (FAILED - #{counter})\n"
11
- @output.flush
12
- end
13
-
14
- def spec_passed(name)
15
- @output << "- #{name}\n"
16
- @output.flush
17
- end
18
- end
19
- end
20
- end
@@ -1,92 +0,0 @@
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.spec_finished "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.spec_finished "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.spec_finished "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.spec_finished "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.spec_finished "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.spec_finished "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.spec_finished "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