rspec 1.1.3 → 1.1.4

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 (122) hide show
  1. data/CHANGES +35 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README +9 -44
  4. data/Rakefile +34 -51
  5. data/TODO +0 -1
  6. data/UPGRADE +0 -24
  7. data/bin/spec +0 -0
  8. data/bin/spec_translator +0 -0
  9. data/examples/pure/behave_as_example.rb +0 -0
  10. data/examples/pure/partial_mock_example.rb +1 -0
  11. data/examples/stories/calculator.rb +1 -1
  12. data/lib/autotest/rspec.rb +7 -9
  13. data/lib/spec/example.rb +1 -1
  14. data/lib/spec/example/configuration.rb +30 -16
  15. data/lib/spec/example/example_group.rb +2 -1
  16. data/lib/spec/example/example_group_factory.rb +23 -21
  17. data/lib/spec/example/example_group_methods.rb +18 -5
  18. data/lib/spec/example/example_matcher.rb +0 -0
  19. data/lib/spec/example/example_methods.rb +6 -0
  20. data/lib/spec/example/module_inclusion_warnings.rb +37 -0
  21. data/lib/spec/expectations/differs/default.rb +1 -1
  22. data/lib/spec/expectations/extensions/object.rb +4 -12
  23. data/lib/spec/expectations/handler.rb +8 -0
  24. data/lib/spec/extensions.rb +1 -0
  25. data/lib/spec/extensions/metaclass.rb +7 -0
  26. data/lib/spec/extensions/object.rb +0 -4
  27. data/lib/spec/matchers/change.rb +1 -1
  28. data/lib/spec/matchers/has.rb +1 -11
  29. data/lib/spec/matchers/operator_matcher.rb +0 -0
  30. data/lib/spec/matchers/raise_error.rb +53 -30
  31. data/lib/spec/mocks.rb +1 -1
  32. data/lib/spec/mocks/argument_constraint_matchers.rb +5 -1
  33. data/lib/spec/mocks/argument_expectation.rb +26 -0
  34. data/lib/spec/mocks/extensions.rb +1 -0
  35. data/lib/spec/mocks/framework.rb +15 -0
  36. data/lib/spec/mocks/message_expectation.rb +29 -5
  37. data/lib/spec/mocks/mock.rb +9 -7
  38. data/lib/spec/mocks/proxy.rb +26 -12
  39. data/lib/spec/rake/spectask.rb +5 -5
  40. data/lib/spec/runner/backtrace_tweaker.rb +1 -1
  41. data/lib/spec/runner/formatter/base_formatter.rb +2 -3
  42. data/lib/spec/runner/formatter/base_text_formatter.rb +2 -2
  43. data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +4 -8
  44. data/lib/spec/runner/formatter/html_formatter.rb +18 -14
  45. data/lib/spec/runner/formatter/nested_text_formatter.rb +65 -0
  46. data/lib/spec/runner/formatter/profile_formatter.rb +4 -0
  47. data/lib/spec/runner/formatter/progress_bar_formatter.rb +5 -1
  48. data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
  49. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +18 -7
  50. data/lib/spec/runner/option_parser.rb +17 -15
  51. data/lib/spec/runner/options.rb +37 -14
  52. data/lib/spec/runner/reporter.rb +15 -11
  53. data/lib/spec/story/extensions/regexp.rb +2 -2
  54. data/lib/spec/story/extensions/string.rb +2 -2
  55. data/lib/spec/story/runner.rb +9 -5
  56. data/lib/spec/story/runner/plain_text_story_runner.rb +2 -2
  57. data/lib/spec/story/runner/scenario_runner.rb +8 -0
  58. data/lib/spec/story/runner/story_mediator.rb +1 -1
  59. data/lib/spec/story/runner/story_runner.rb +3 -1
  60. data/lib/spec/story/step.rb +4 -4
  61. data/lib/spec/story/story.rb +8 -11
  62. data/lib/spec/story/world.rb +0 -1
  63. data/lib/spec/version.rb +2 -2
  64. data/plugins/mock_frameworks/rspec.rb +2 -0
  65. data/spec/autotest/rspec_spec.rb +12 -10
  66. data/spec/spec/example/configuration_spec.rb +0 -0
  67. data/spec/spec/example/example_group/described_module_spec.rb +20 -0
  68. data/spec/spec/example/example_group/warning_messages_spec.rb +76 -0
  69. data/spec/spec/example/example_group_factory_spec.rb +117 -102
  70. data/spec/spec/example/example_group_methods_spec.rb +51 -17
  71. data/spec/spec/example/example_group_spec.rb +13 -1
  72. data/spec/spec/example/example_methods_spec.rb +28 -6
  73. data/spec/spec/example/nested_example_group_spec.rb +12 -0
  74. data/spec/spec/example/predicate_matcher_spec.rb +0 -0
  75. data/spec/spec/expectations/differs/default_spec.rb +27 -9
  76. data/spec/spec/matchers/be_spec.rb +24 -0
  77. data/spec/spec/matchers/has_spec.rb +16 -0
  78. data/spec/spec/matchers/raise_error_spec.rb +124 -0
  79. data/spec/spec/mocks/{bug_report_10263.rb → bug_report_10263_spec.rb} +0 -0
  80. data/spec/spec/mocks/bug_report_11545_spec.rb +2 -0
  81. data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +8 -0
  82. data/spec/spec/mocks/hash_including_matcher_spec.rb +32 -0
  83. data/spec/spec/mocks/mock_spec.rb +56 -37
  84. data/spec/spec/mocks/partial_mock_spec.rb +41 -5
  85. data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +6 -0
  86. data/spec/spec/runner/execution_context_spec.rb +7 -1
  87. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +3 -2
  88. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +30 -25
  89. data/spec/spec/runner/formatter/html_formatter_spec.rb +0 -3
  90. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +333 -0
  91. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +12 -2
  92. data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -2
  93. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +110 -78
  94. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +105 -1
  95. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -28
  96. data/spec/spec/runner/option_parser_spec.rb +65 -49
  97. data/spec/spec/runner/options_spec.rb +103 -17
  98. data/spec/spec/runner/reporter_spec.rb +10 -7
  99. data/spec/spec/runner/spec_drb.opts +1 -0
  100. data/spec/spec/runner/spec_parser_spec.rb +10 -4
  101. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +14 -13
  102. data/spec/spec/story/runner/scenario_runner_spec.rb +124 -52
  103. data/spec/spec/story/runner/story_mediator_spec.rb +2 -2
  104. data/spec/spec/story/runner/story_runner_spec.rb +40 -2
  105. data/spec/spec/story/runner_spec.rb +59 -72
  106. data/spec/spec/story/step_spec.rb +20 -1
  107. data/spec/spec/story/story_spec.rb +2 -2
  108. data/stories/all.rb +1 -1
  109. data/stories/example_groups/stories.rb +4 -3
  110. data/stories/mock_framework_integration/stories.rb +7 -0
  111. data/stories/mock_framework_integration/use_flexmock.story +9 -0
  112. data/stories/resources/spec/spec_with_flexmock.rb +18 -0
  113. metadata +21 -18
  114. data/pre_commit/lib/pre_commit.rb +0 -4
  115. data/pre_commit/lib/pre_commit/core.rb +0 -50
  116. data/pre_commit/lib/pre_commit/pre_commit.rb +0 -54
  117. data/pre_commit/lib/pre_commit/rspec.rb +0 -111
  118. data/pre_commit/lib/pre_commit/rspec_on_rails.rb +0 -313
  119. data/pre_commit/spec/pre_commit/pre_commit_spec.rb +0 -15
  120. data/pre_commit/spec/pre_commit/rspec_on_rails_spec.rb +0 -36
  121. data/pre_commit/spec/spec_helper.rb +0 -3
  122. data/pre_commit/spec/spec_suite.rb +0 -11
data/lib/spec/mocks.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'spec/mocks/framework'
1
2
  require 'spec/mocks/methods'
2
3
  require 'spec/mocks/argument_constraint_matchers'
3
4
  require 'spec/mocks/spec_methods'
@@ -11,7 +12,6 @@ require 'spec/mocks/error_generator'
11
12
  require 'spec/mocks/extensions/object'
12
13
  require 'spec/mocks/space'
13
14
 
14
-
15
15
  module Spec
16
16
  # == Mocks and Stubs
17
17
  #
@@ -1,7 +1,7 @@
1
1
  module Spec
2
2
  module Mocks
3
3
  module ArgumentConstraintMatchers
4
-
4
+
5
5
  # Shortcut for creating an instance of Spec::Mocks::DuckTypeArgConstraint
6
6
  def duck_type(*args)
7
7
  DuckTypeArgConstraint.new(*args)
@@ -19,6 +19,10 @@ module Spec
19
19
  BooleanArgConstraint.new(nil)
20
20
  end
21
21
 
22
+ def hash_including(expected={})
23
+ HashIncludingConstraint.new(expected)
24
+ end
25
+
22
26
  def no_args
23
27
  NoArgsConstraint.new
24
28
  end
@@ -108,6 +108,32 @@ module Spec
108
108
  "duck_type"
109
109
  end
110
110
  end
111
+
112
+ class HashIncludingConstraint
113
+ def initialize(expected)
114
+ @expected = expected
115
+ end
116
+
117
+ def ==(actual)
118
+ @expected.each do | key, value |
119
+ # check key for case that value evaluates to nil
120
+ return false unless actual.has_key?(key) && actual[key] == value
121
+ end
122
+ true
123
+ rescue NoMethodError => ex
124
+ return false
125
+ end
126
+
127
+ def matches?(value)
128
+ self == value
129
+ end
130
+
131
+ def description
132
+ "hash_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})"
133
+ end
134
+
135
+ end
136
+
111
137
 
112
138
  class ArgumentExpectation
113
139
  attr_reader :args
@@ -0,0 +1 @@
1
+ require 'spec/mocks/extensions/object'
@@ -0,0 +1,15 @@
1
+ # Require everything except the global extensions of class and object. This
2
+ # supports wrapping rspec's mocking functionality without invading every
3
+ # object in the system.
4
+
5
+ require 'spec/mocks/methods'
6
+ require 'spec/mocks/argument_constraint_matchers'
7
+ require 'spec/mocks/spec_methods'
8
+ require 'spec/mocks/proxy'
9
+ require 'spec/mocks/mock'
10
+ require 'spec/mocks/argument_expectation'
11
+ require 'spec/mocks/message_expectation'
12
+ require 'spec/mocks/order_group'
13
+ require 'spec/mocks/errors'
14
+ require 'spec/mocks/error_generator'
15
+ require 'spec/mocks/space'
@@ -72,12 +72,18 @@ module Spec
72
72
  end
73
73
 
74
74
  def invoke(args, block)
75
+ if @expected_received_count == 0
76
+ @actual_received_count += 1
77
+ @error_generator.raise_expectation_error @sym, @expected_received_count, @actual_received_count, *args
78
+ end
79
+
75
80
  @order_group.handle_order_constraint self
76
81
 
77
82
  begin
78
83
  Kernel::raise @exception_to_raise unless @exception_to_raise.nil?
79
84
  Kernel::throw @symbol_to_throw unless @symbol_to_throw.nil?
80
85
 
86
+
81
87
  if !@method_block.nil?
82
88
  default_return_val = invoke_method_block(args)
83
89
  elsif @args_to_yield.size > 0
@@ -112,12 +118,14 @@ module Spec
112
118
  if block.nil?
113
119
  @error_generator.raise_missing_block_error @args_to_yield
114
120
  end
121
+ value = nil
115
122
  @args_to_yield.each do |args_to_yield_this_time|
116
123
  if block.arity > -1 && args_to_yield_this_time.length != block.arity
117
124
  @error_generator.raise_wrong_arity_error args_to_yield_this_time, block.arity
118
125
  end
119
- block.call(*args_to_yield_this_time)
126
+ value = block.call(*args_to_yield_this_time)
120
127
  end
128
+ value
121
129
  end
122
130
 
123
131
  def invoke_consecutive_return_block(args, block)
@@ -147,9 +155,8 @@ module Spec
147
155
  @sym == sym and not @args_expectation.check_args(args)
148
156
  end
149
157
 
150
- def verify_messages_received
151
- return if ignoring_args? || matches_exact_count? ||
152
- matches_at_least_count? || matches_at_most_count?
158
+ def verify_messages_received
159
+ return if expected_messages_received?
153
160
 
154
161
  generate_error
155
162
  rescue Spec::Mocks::MockExpectationError => error
@@ -157,6 +164,11 @@ module Spec
157
164
  Kernel::raise error
158
165
  end
159
166
 
167
+ def expected_messages_received?
168
+ ignoring_args? || matches_exact_count? ||
169
+ matches_at_least_count? || matches_at_most_count?
170
+ end
171
+
160
172
  def ignoring_args?
161
173
  @expected_received_count == :any
162
174
  end
@@ -173,8 +185,20 @@ module Spec
173
185
  @expected_received_count == @actual_received_count
174
186
  end
175
187
 
188
+ def similar_messages
189
+ @similar_messages ||= []
190
+ end
191
+
192
+ def advise(args, block)
193
+ similar_messages << args
194
+ end
195
+
176
196
  def generate_error
177
- @error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args)
197
+ if similar_messages.empty?
198
+ @error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args)
199
+ else
200
+ @error_generator.raise_unexpected_message_args_error(self, *@similar_messages.first)
201
+ end
178
202
  end
179
203
 
180
204
  def with(*args, &block)
@@ -3,19 +3,21 @@ module Spec
3
3
  class Mock
4
4
  include Methods
5
5
 
6
- # Creates a new mock with a +name+ (that will be used in error messages only)
7
- # == Options:
8
- # * <tt>:null_object</tt> - if true, the mock object acts as a forgiving null object allowing any message to be sent to it.
6
+ # Creates a new mock with a +name+ (that will be used in error messages
7
+ # only) == Options:
8
+ # * <tt>:null_object</tt> - if true, the mock object acts as a forgiving
9
+ # null object allowing any message to be sent to it.
9
10
  def initialize(name, stubs_and_options={})
10
11
  @name = name
11
12
  @options = parse_options(stubs_and_options)
12
13
  assign_stubs(stubs_and_options)
13
14
  end
14
15
 
15
- # This allows for comparing the mock to other objects that proxy
16
- # such as ActiveRecords belongs_to proxy objects
17
- # By making the other object run the comparison, we're sure the call gets delegated to the proxy target
18
- # This is an unfortunate side effect from ActiveRecord, but this should be safe unless the RHS redefines == in a nonsensical manner
16
+ # This allows for comparing the mock to other objects that proxy such as
17
+ # ActiveRecords belongs_to proxy objects By making the other object run
18
+ # the comparison, we're sure the call gets delegated to the proxy target
19
+ # This is an unfortunate side effect from ActiveRecord, but this should
20
+ # be safe unless the RHS redefines == in a nonsensical manner
19
21
  def ==(other)
20
22
  other == __mock_proxy
21
23
  end
@@ -63,10 +63,14 @@ module Spec
63
63
  def message_received(sym, *args, &block)
64
64
  if expectation = find_matching_expectation(sym, *args)
65
65
  expectation.invoke(args, block)
66
- elsif stub = find_matching_method_stub(sym, *args)
66
+ elsif (stub = find_matching_method_stub(sym, *args))
67
+ if expectation = find_almost_matching_expectation(sym, *args)
68
+ expectation.advise(args, block) unless expectation.expected_messages_received?
69
+ end
67
70
  stub.invoke([], block)
68
71
  elsif expectation = find_almost_matching_expectation(sym, *args)
69
- raise_unexpected_message_args_error(expectation, *args) unless has_negative_expectation?(sym) unless null_object?
72
+ expectation.advise(args, block) if null_object? unless expectation.expected_messages_received?
73
+ raise_unexpected_message_args_error(expectation, *args) unless (has_negative_expectation?(sym) or null_object?)
70
74
  else
71
75
  @target.send :method_missing, sym, *args, &block
72
76
  end
@@ -88,18 +92,20 @@ module Spec
88
92
  end
89
93
 
90
94
  def define_expected_method(sym)
91
- if target_responds_to?(sym) && !metaclass.method_defined?(munge(sym))
95
+ visibility_string = "#{visibility(sym)} :#{sym}"
96
+ if target_responds_to?(sym) && !target_metaclass.method_defined?(munge(sym))
92
97
  munged_sym = munge(sym)
93
- metaclass.instance_eval do
98
+ target_metaclass.instance_eval do
94
99
  alias_method munged_sym, sym if method_defined?(sym.to_s)
95
100
  end
96
101
  @proxied_methods << sym
97
102
  end
98
103
 
99
- metaclass_eval(<<-EOF, __FILE__, __LINE__)
104
+ target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__)
100
105
  def #{sym}(*args, &block)
101
106
  __mock_proxy.message_received :#{sym}, *args, &block
102
107
  end
108
+ #{visibility_string}
103
109
  EOF
104
110
  end
105
111
 
@@ -109,6 +115,18 @@ module Spec
109
115
  return @target.respond_to?(sym)
110
116
  end
111
117
 
118
+ def visibility(sym)
119
+ if Mock === @target
120
+ 'public'
121
+ elsif target_metaclass.private_method_defined?(sym)
122
+ 'private'
123
+ elsif target_metaclass.protected_method_defined?(sym)
124
+ 'protected'
125
+ else
126
+ 'public'
127
+ end
128
+ end
129
+
112
130
  def munge(sym)
113
131
  "proxied_by_rspec__#{sym.to_s}".to_sym
114
132
  end
@@ -125,12 +143,8 @@ module Spec
125
143
  @proxied_methods.clear
126
144
  end
127
145
 
128
- def metaclass_eval(str, filename, lineno)
129
- metaclass.class_eval(str, filename, lineno)
130
- end
131
-
132
- def metaclass
133
- (class << @target; self; end)
146
+ def target_metaclass
147
+ class << @target; self; end
134
148
  end
135
149
 
136
150
  def verify_expectations
@@ -142,7 +156,7 @@ module Spec
142
156
  def reset_proxied_methods
143
157
  @proxied_methods.each do |sym|
144
158
  munged_sym = munge(sym)
145
- metaclass.instance_eval do
159
+ target_metaclass.instance_eval do
146
160
  if method_defined?(munged_sym.to_s)
147
161
  alias_method sym, munged_sym
148
162
  undef_method munged_sym
@@ -11,7 +11,7 @@ module Spec
11
11
  # A Rake task that runs a set of specs.
12
12
  #
13
13
  # Example:
14
- #
14
+ #
15
15
  # Spec::Rake::SpecTask.new do |t|
16
16
  # t.warning = true
17
17
  # t.rcov = true
@@ -87,7 +87,7 @@ module Spec
87
87
  # Whether or not to use RCov (default is false)
88
88
  # See http://eigenclass.org/hiki.rb?rcov
89
89
  attr_accessor :rcov
90
-
90
+
91
91
  # Array of commandline options to pass to RCov. Defaults to ['--exclude', 'lib\/spec,bin\/spec'].
92
92
  # Ignored if rcov=false
93
93
  # Setting the RCOV_OPTS environment variable overrides this.
@@ -117,7 +117,7 @@ module Spec
117
117
  # used, then the list of spec files is the union of the two.
118
118
  # Setting the SPEC environment variable overrides this.
119
119
  attr_accessor :spec_files
120
-
120
+
121
121
  # Use verbose output. If this is set to true, the task will print
122
122
  # the executed spec command to stdout. Defaults to false.
123
123
  attr_accessor :verbose
@@ -155,7 +155,7 @@ module Spec
155
155
  # ruby [ruby_opts] -Ilib -S rcov [rcov_opts] bin/spec -- examples [spec_opts]
156
156
  # or
157
157
  # ruby [ruby_opts] -Ilib bin/spec examples [spec_opts]
158
- cmd = "ruby "
158
+ cmd = "#{File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])} "
159
159
 
160
160
  rb_opts = ruby_opts.clone
161
161
  rb_opts << "-I\"#{lib_path}\""
@@ -210,7 +210,7 @@ module Spec
210
210
  STDERR.puts "RSPECOPTS is DEPRECATED and will be removed in a future version. Use SPEC_OPTS instead." if ENV['RSPECOPTS']
211
211
  ENV['SPEC_OPTS'] || ENV['RSPECOPTS'] || spec_opts.join(" ") || ""
212
212
  end
213
-
213
+
214
214
  def evaluate(o) # :nodoc:
215
215
  case o
216
216
  when Proc then o.call
@@ -27,7 +27,7 @@ module Spec
27
27
  /\/lib\/ruby\//,
28
28
  /bin\/spec:/,
29
29
  /bin\/rcov:/,
30
- /lib\/rspec_on_rails/,
30
+ /lib\/rspec-rails/,
31
31
  /vendor\/rails/,
32
32
  # TextMate's Ruby and RSpec plugins
33
33
  /Ruby\.tmbundle\/Support\/tmruby.rb:/,
@@ -19,8 +19,7 @@ module Spec
19
19
  end
20
20
 
21
21
  # This method is invoked at the beginning of the execution of each example_group.
22
- # +name+ is the name of the example_group and +first+ is true if it is the
23
- # first example_group - otherwise it's false.
22
+ # +example_group+ is the example_group.
24
23
  #
25
24
  # The next method to be invoked after this is #example_failed or #example_finished
26
25
  def add_example_group(example_group)
@@ -46,7 +45,7 @@ module Spec
46
45
  # been provided a block), or when an ExamplePendingError is raised.
47
46
  # +message+ is the message from the ExamplePendingError, if it exists, or the
48
47
  # default value of "Not Yet Implemented"
49
- def example_pending(example_group_description, example, message)
48
+ def example_pending(example, message)
50
49
  end
51
50
 
52
51
  # This method is invoked after all of the examples have executed. The next method
@@ -26,8 +26,8 @@ module Spec
26
26
  @pending_examples = []
27
27
  end
28
28
 
29
- def example_pending(example_group_description, example, message)
30
- @pending_examples << ["#{example_group_description} #{example.description}", message]
29
+ def example_pending(example, message)
30
+ @pending_examples << [example.__full_description, message]
31
31
  end
32
32
 
33
33
  def dump_failure(counter, failure)
@@ -4,19 +4,15 @@ module Spec
4
4
  module Runner
5
5
  module Formatter
6
6
  class FailingExampleGroupsFormatter < BaseTextFormatter
7
- def add_example_group(example_group)
8
- super
9
- @example_group_description_parts = example_group.description_parts
10
- end
11
-
12
7
  def example_failed(example, counter, failure)
13
- if @example_group_description_parts
14
- description_parts = @example_group_description_parts.collect do |description|
8
+ if @example_group
9
+ description_parts = @example_group.description_parts.collect do |description|
15
10
  description =~ /(.*) \(druby.*\)$/ ? $1 : description
16
11
  end
17
12
  @output.puts ::Spec::Example::ExampleGroupMethods.description_text(*description_parts)
13
+
18
14
  @output.flush
19
- @example_group_description_parts = nil
15
+ @example_group = nil
20
16
  end
21
17
  end
22
18
 
@@ -9,18 +9,22 @@ module Spec
9
9
 
10
10
  def initialize(options, output)
11
11
  super
12
- @current_example_group_number = 0
13
- @current_example_number = 0
12
+ @example_group_number = 0
13
+ @example_number = 0
14
+ end
15
+
16
+ def method_missing(sym, *args)
17
+ # no-op
14
18
  end
15
19
 
16
20
  # The number of the currently running example_group
17
- def current_example_group_number
18
- @current_example_group_number
21
+ def example_group_number
22
+ @example_group_number
19
23
  end
20
24
 
21
25
  # The number of the currently running example (a global counter)
22
- def current_example_number
23
- @current_example_number
26
+ def example_number
27
+ @example_number
24
28
  end
25
29
 
26
30
  def start(example_count)
@@ -35,14 +39,14 @@ module Spec
35
39
  super
36
40
  @example_group_red = false
37
41
  @example_group_red = false
38
- @current_example_group_number += 1
39
- unless current_example_group_number == 1
42
+ @example_group_number += 1
43
+ unless example_group_number == 1
40
44
  @output.puts " </dl>"
41
45
  @output.puts "</div>"
42
46
  end
43
47
  @output.puts "<div class=\"example_group\">"
44
48
  @output.puts " <dl>"
45
- @output.puts " <dt id=\"example_group_#{current_example_group_number}\">#{h(example_group.description)}</dt>"
49
+ @output.puts " <dt id=\"example_group_#{example_group_number}\">#{h(example_group.description)}</dt>"
46
50
  @output.flush
47
51
  end
48
52
 
@@ -53,7 +57,7 @@ module Spec
53
57
  end
54
58
 
55
59
  def example_started(example)
56
- @current_example_number += 1
60
+ @example_number += 1
57
61
  end
58
62
 
59
63
  def example_passed(example)
@@ -67,7 +71,7 @@ module Spec
67
71
  failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
68
72
  @output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
69
73
  @header_red = true
70
- @output.puts " <script type=\"text/javascript\">makeRed('example_group_#{current_example_group_number}');</script>" unless @example_group_red
74
+ @output.puts " <script type=\"text/javascript\">makeRed('example_group_#{example_group_number}');</script>" unless @example_group_red
71
75
  @example_group_red = true
72
76
  move_progress
73
77
  @output.puts " <dd class=\"spec #{failure_style}\">"
@@ -81,9 +85,9 @@ module Spec
81
85
  @output.flush
82
86
  end
83
87
 
84
- def example_pending(example_group_description, example, message)
88
+ def example_pending(example, message)
85
89
  @output.puts " <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
86
- @output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{current_example_group_number}');</script>" unless @example_group_red
90
+ @output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{example_group_number}');</script>" unless @example_group_red
87
91
  move_progress
88
92
  @output.puts " <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{h(example.description)} (PENDING: #{h(message)})</span></dd>"
89
93
  @output.flush
@@ -106,7 +110,7 @@ module Spec
106
110
  def percent_done
107
111
  result = 100.0
108
112
  if @example_count != 0
109
- result = ((current_example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
113
+ result = ((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
110
114
  end
111
115
  result
112
116
  end