dchelimsky-rspec 1.1.11 → 1.1.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/.autotest +4 -0
  2. data/History.txt +19 -3
  3. data/Manifest.txt +6 -1
  4. data/examples/failing/README.txt +7 -0
  5. data/examples/failing/diffing_spec.rb +36 -0
  6. data/examples/failing/failing_autogenerated_docstrings_example.rb +19 -0
  7. data/examples/failing/failure_in_setup.rb +10 -0
  8. data/examples/failing/failure_in_teardown.rb +10 -0
  9. data/examples/failing/mocking_example.rb +40 -0
  10. data/examples/failing/mocking_with_flexmock.rb +26 -0
  11. data/examples/failing/mocking_with_mocha.rb +25 -0
  12. data/examples/failing/mocking_with_rr.rb +27 -0
  13. data/examples/failing/partial_mock_example.rb +20 -0
  14. data/examples/failing/predicate_example.rb +34 -0
  15. data/examples/failing/raising_example.rb +47 -0
  16. data/examples/failing/spec_helper.rb +3 -0
  17. data/examples/failing/syntax_error_example.rb +7 -0
  18. data/examples/failing/team_spec.rb +44 -0
  19. data/examples/failing/timeout_behaviour.rb +7 -0
  20. data/examples/passing/custom_formatter.rb +1 -1
  21. data/examples/passing/simple_matcher_example.rb +31 -0
  22. data/lib/autotest/rspec.rb +1 -1
  23. data/lib/spec/dsl/main.rb +82 -0
  24. data/lib/spec/dsl.rb +1 -0
  25. data/lib/spec/example/before_and_after_hooks.rb +2 -1
  26. data/lib/spec/example/configuration.rb +1 -1
  27. data/lib/spec/example/example_group.rb +1 -0
  28. data/lib/spec/example/example_group_factory.rb +2 -1
  29. data/lib/spec/example/example_group_methods.rb +40 -25
  30. data/lib/spec/example/example_methods.rb +19 -8
  31. data/lib/spec/example.rb +15 -17
  32. data/lib/spec/expectations/handler.rb +23 -28
  33. data/lib/spec/expectations/wrap_expectation.rb +56 -0
  34. data/lib/spec/expectations.rb +22 -18
  35. data/lib/spec/extensions.rb +0 -1
  36. data/lib/spec/interop/test/unit/testcase.rb +19 -17
  37. data/lib/spec/matchers/be_close.rb +6 -22
  38. data/lib/spec/matchers/eql.rb +7 -25
  39. data/lib/spec/matchers/equal.rb +6 -24
  40. data/lib/spec/matchers/errors.rb +5 -0
  41. data/lib/spec/matchers/exist.rb +8 -14
  42. data/lib/spec/matchers/generated_descriptions.rb +48 -0
  43. data/lib/spec/matchers/has.rb +12 -28
  44. data/lib/spec/matchers/include.rb +12 -9
  45. data/lib/spec/matchers/match.rb +8 -27
  46. data/lib/spec/matchers/method_missing.rb +9 -0
  47. data/lib/spec/matchers/operator_matcher.rb +23 -46
  48. data/lib/spec/matchers/raise_error.rb +4 -8
  49. data/lib/spec/matchers/respond_to.rb +2 -1
  50. data/lib/spec/matchers/throw_symbol.rb +9 -3
  51. data/lib/spec/mocks/message_expectation.rb +0 -5
  52. data/lib/spec/mocks/proxy.rb +12 -10
  53. data/lib/spec/rake/spectask.rb +4 -6
  54. data/lib/spec/runner/class_and_arguments_parser.rb +7 -9
  55. data/lib/spec/runner/command_line.rb +6 -8
  56. data/lib/spec/runner/formatter/base_text_formatter.rb +3 -2
  57. data/lib/spec/runner/option_parser.rb +4 -6
  58. data/lib/spec/runner/spec_parser.rb +5 -5
  59. data/lib/spec/runner.rb +37 -39
  60. data/lib/spec/story/runner/story_runner.rb +10 -6
  61. data/lib/spec/story/runner.rb +40 -42
  62. data/lib/spec/story/world.rb +66 -70
  63. data/lib/spec/version.rb +3 -1
  64. data/lib/spec.rb +21 -19
  65. data/rspec.gemspec +15 -6
  66. data/spec/autotest/autotest_helper.rb +2 -2
  67. data/spec/autotest/discover_spec.rb +4 -15
  68. data/spec/autotest/failed_results_re_spec.rb +24 -0
  69. data/spec/autotest/rspec_spec.rb +0 -37
  70. data/spec/spec/dsl/main_spec.rb +65 -0
  71. data/spec/spec/example/example_group_class_definition_spec.rb +6 -2
  72. data/spec/spec/example/example_group_factory_spec.rb +2 -1
  73. data/spec/spec/example/example_group_methods_spec.rb +138 -141
  74. data/spec/spec/example/example_group_spec.rb +3 -5
  75. data/spec/spec/example/example_methods_spec.rb +60 -23
  76. data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
  77. data/spec/spec/interop/test/unit/spec_spec.rb +1 -5
  78. data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +4 -0
  79. data/spec/spec/matchers/be_close_spec.rb +12 -10
  80. data/spec/spec/matchers/description_generation_spec.rb +1 -1
  81. data/spec/spec/matchers/eql_spec.rb +7 -6
  82. data/spec/spec/matchers/equal_spec.rb +7 -6
  83. data/spec/spec/matchers/has_spec.rb +1 -1
  84. data/spec/spec/matchers/have_spec.rb +23 -18
  85. data/spec/spec/matchers/include_spec.rb +24 -0
  86. data/spec/spec/matchers/matcher_methods_spec.rb +1 -13
  87. data/spec/spec/matchers/throw_symbol_spec.rb +3 -3
  88. data/spec/spec/mocks/bug_report_11545_spec.rb +4 -5
  89. data/spec/spec/mocks/bug_report_496.rb +11 -9
  90. data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
  91. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +1 -1
  92. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +4 -14
  93. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +1 -1
  94. data/spec/spec/runner/options_spec.rb +1 -1
  95. data/spec/spec/runner/spec_parser_spec.rb +76 -80
  96. data/spec/spec_helper.rb +4 -0
  97. data/stories/example_groups/autogenerated_docstrings +4 -4
  98. data/stories/interop/test_but_not_test_unit +14 -0
  99. data/stories/resources/helpers/story_helper.rb +1 -1
  100. data/stories/resources/test/spec_including_test_but_not_unit.rb +11 -0
  101. data/story_server/prototype/javascripts/prototype.js +1 -1
  102. metadata +34 -53
  103. data/lib/spec/extensions/metaclass.rb +0 -7
@@ -0,0 +1,48 @@
1
+ module Spec
2
+ module Matchers
3
+ def self.last_matcher
4
+ @last_matcher
5
+ end
6
+
7
+ def self.last_matcher=(last_matcher)
8
+ @last_matcher = last_matcher
9
+ end
10
+
11
+ def self.last_should
12
+ @last_should
13
+ end
14
+
15
+ def self.last_should=(last_should)
16
+ @last_should = last_should
17
+ end
18
+
19
+ def self.clear_generated_description
20
+ self.last_matcher = nil
21
+ self.last_should = nil
22
+ end
23
+
24
+ def self.generated_description
25
+ return nil if last_should.nil?
26
+ "#{last_should} #{last_description}"
27
+ end
28
+
29
+ private
30
+
31
+ def self.last_description
32
+ last_matcher.respond_to?(:description) ? last_matcher.description : <<-MESSAGE
33
+ When you call a matcher in an example without a String, like this:
34
+
35
+ specify { object.should matcher }
36
+
37
+ or this:
38
+
39
+ it { should matcher }
40
+
41
+ the runner expects the matcher to have a #describe method. You should either
42
+ add a String to the example this matcher is being used in, or give it a
43
+ description method. Then you won't have to suffer this lengthy warning again.
44
+ MESSAGE
45
+ end
46
+ end
47
+ end
48
+
@@ -1,34 +1,18 @@
1
1
  module Spec
2
2
  module Matchers
3
-
4
- class Has #:nodoc:
5
- def initialize(sym, *args)
6
- @sym = sym
7
- @args = args
8
- end
9
-
10
- def matches?(given)
11
- given.__send__(predicate, *@args)
12
- end
13
-
14
- def failure_message
15
- "expected ##{predicate}(#{@args[0].inspect}) to return true, got false"
16
- end
17
-
18
- def negative_failure_message
19
- "expected ##{predicate}(#{@args[0].inspect}) to return false, got true"
3
+ def has(sym, *args) # :nodoc:
4
+ simple_matcher do |actual, matcher|
5
+ matcher.failure_message = "expected ##{predicate(sym)}(#{args[0].inspect}) to return true, got false"
6
+ matcher.negative_failure_message = "expected ##{predicate(sym)}(#{args[0].inspect}) to return false, got true"
7
+ matcher.description = "have key #{args[0].inspect}"
8
+ actual.__send__(predicate(sym), *args)
20
9
  end
21
-
22
- def description
23
- "have key #{@args[0].inspect}"
24
- end
25
-
26
- private
27
- def predicate
28
- "#{@sym.to_s.sub("have_","has_")}?".to_sym
29
- end
30
-
31
10
  end
32
-
11
+
12
+ private
13
+ def predicate(sym)
14
+ "#{sym.to_s.sub("have_","has_")}?".to_sym
15
+ end
16
+
33
17
  end
34
18
  end
@@ -7,16 +7,19 @@ module Spec
7
7
  @expecteds = expecteds
8
8
  end
9
9
 
10
- def matches?(given)
11
- @given = given
10
+ def matches?(actual)
11
+ @actual = actual
12
12
  @expecteds.each do |expected|
13
- case given
14
- when Hash
15
- expected.each_pair do |k,v|
16
- return false unless given[k] == v
13
+ if actual.is_a?(Hash)
14
+ if expected.is_a?(Hash)
15
+ expected.each_pair do |k,v|
16
+ return false unless actual[k] == v
17
+ end
18
+ else
19
+ return false unless actual.has_key?(expected)
17
20
  end
18
21
  else
19
- return false unless given.include?(expected)
22
+ return false unless actual.include?(expected)
20
23
  end
21
24
  end
22
25
  true
@@ -36,7 +39,7 @@ module Spec
36
39
 
37
40
  private
38
41
  def _message(maybe_not="")
39
- "expected #{@given.inspect} #{maybe_not}to include #{_pretty_print(@expecteds)}"
42
+ "expected #{@actual.inspect} #{maybe_not}to include #{_pretty_print(@expecteds)}"
40
43
  end
41
44
 
42
45
  def _pretty_print(array)
@@ -58,7 +61,7 @@ module Spec
58
61
  # should include(expected)
59
62
  # should_not include(expected)
60
63
  #
61
- # Passes if given includes expected. This works for
64
+ # Passes if actual includes expected. This works for
62
65
  # collections and Strings. You can also pass in multiple args
63
66
  # and it will only pass if all args are found in collection.
64
67
  #
@@ -1,41 +1,22 @@
1
1
  module Spec
2
2
  module Matchers
3
3
 
4
- class Match #:nodoc:
5
- def initialize(regexp)
6
- @regexp = regexp
7
- end
8
-
9
- def matches?(given)
10
- @given = given
11
- return true if given =~ @regexp
12
- return false
13
- end
14
-
15
- def failure_message
16
- return "expected #{@given.inspect} to match #{@regexp.inspect}", @regexp, @given
17
- end
18
-
19
- def negative_failure_message
20
- return "expected #{@given.inspect} not to match #{@regexp.inspect}", @regexp, @given
21
- end
22
-
23
- def description
24
- "match #{@regexp.inspect}"
25
- end
26
- end
27
-
28
4
  # :call-seq:
29
5
  # should match(regexp)
30
6
  # should_not match(regexp)
31
7
  #
32
- # Given a Regexp, passes if given =~ regexp
8
+ # Given a Regexp, passes if actual =~ regexp
33
9
  #
34
10
  # == Examples
35
11
  #
36
- # email.should match(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
12
+ # email.should match(/^([^\s]+)((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
37
13
  def match(regexp)
38
- Matchers::Match.new(regexp)
14
+ simple_matcher do |actual, matcher|
15
+ matcher.failure_message = "expected #{actual.inspect} to match #{regexp.inspect}", regexp, actual
16
+ matcher.negative_failure_message = "expected #{actual.inspect} not to match #{regexp.inspect}", regexp, actual
17
+ matcher.description = "match #{regexp.inspect}"
18
+ actual =~ regexp
19
+ end
39
20
  end
40
21
  end
41
22
  end
@@ -0,0 +1,9 @@
1
+ module Spec
2
+ module Matchers
3
+ def method_missing(sym, *args, &block) # :nodoc:
4
+ return Matchers::Be.new(sym, *args) if sym.starts_with?("be_")
5
+ return has(sym, *args) if sym.starts_with?("have_")
6
+ super
7
+ end
8
+ end
9
+ end
@@ -1,40 +1,20 @@
1
1
  module Spec
2
2
  module Matchers
3
- class BaseOperatorMatcher
4
- def initialize(given)
5
- @given = given
3
+ class OperatorMatcher
4
+ def initialize(actual)
5
+ @actual = actual
6
6
  end
7
-
8
- def ==(expected)
9
- __delegate_method_missing_to_given("==", expected)
10
- end
11
-
12
- def ===(expected)
13
- __delegate_method_missing_to_given("===", expected)
14
- end
15
-
16
- def =~(expected)
17
- __delegate_method_missing_to_given("=~", expected)
18
- end
19
-
20
- def >(expected)
21
- __delegate_method_missing_to_given(">", expected)
22
- end
23
-
24
- def >=(expected)
25
- __delegate_method_missing_to_given(">=", expected)
26
- end
27
-
28
- def <(expected)
29
- __delegate_method_missing_to_given("<", expected)
30
- end
31
-
32
- def <=(expected)
33
- __delegate_method_missing_to_given("<=", expected)
7
+
8
+ ['==','===','<','<=','>=','>','=~'].each do |operator|
9
+ define_method operator do |expected|
10
+ ::Spec::Matchers.last_matcher = self
11
+ @operator, @expected = operator, expected
12
+ __delegate_operator(@actual, operator, expected)
13
+ end
34
14
  end
35
15
 
36
16
  def fail_with_message(message)
37
- Spec::Expectations.fail_with(message, @expected, @given)
17
+ Spec::Expectations.fail_with(message, @expected, @actual)
38
18
  end
39
19
 
40
20
  def description
@@ -43,27 +23,24 @@ module Spec
43
23
 
44
24
  end
45
25
 
46
- class PositiveOperatorMatcher < BaseOperatorMatcher #:nodoc:
26
+ class PositiveOperatorMatcher < OperatorMatcher #:nodoc:
47
27
 
48
- def __delegate_method_missing_to_given(operator, expected)
49
- @expected = expected
50
- @operator = operator
51
- ::Spec::Matchers.last_matcher = self
52
- return true if @given.__send__(operator, expected)
53
- return fail_with_message("expected: #{expected.inspect},\n got: #{@given.inspect} (using #{operator})") if ['==','===', '=~'].include?(operator)
54
- return fail_with_message("expected: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@given.inspect}")
28
+ def __delegate_operator(actual, operator, expected)
29
+ return true if actual.__send__(operator, expected)
30
+ if ['==','===', '=~'].include?(operator)
31
+ fail_with_message("expected: #{expected.inspect},\n got: #{actual.inspect} (using #{operator})")
32
+ else
33
+ fail_with_message("expected: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}")
34
+ end
55
35
  end
56
36
 
57
37
  end
58
38
 
59
- class NegativeOperatorMatcher < BaseOperatorMatcher #:nodoc:
39
+ class NegativeOperatorMatcher < OperatorMatcher #:nodoc:
60
40
 
61
- def __delegate_method_missing_to_given(operator, expected)
62
- @expected = expected
63
- @operator = operator
64
- ::Spec::Matchers.last_matcher = self
65
- return true unless @given.__send__(operator, expected)
66
- return fail_with_message("expected not: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@given.inspect}")
41
+ def __delegate_operator(actual, operator, expected)
42
+ return true unless actual.__send__(operator, expected)
43
+ return fail_with_message("expected not: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}")
67
44
  end
68
45
 
69
46
  end
@@ -47,20 +47,16 @@ module Spec
47
47
  def verify_message
48
48
  case @expected_message
49
49
  when nil
50
- return true
50
+ true
51
51
  when Regexp
52
- return @expected_message =~ @given_error.message
52
+ @expected_message =~ @given_error.message
53
53
  else
54
- return @expected_message == @given_error.message
54
+ @expected_message == @given_error.message
55
55
  end
56
56
  end
57
57
 
58
58
  def failure_message
59
- if @eval_block
60
- return @given_error.message
61
- else
62
- return "expected #{expected_error}#{given_error}"
63
- end
59
+ @eval_block ? @given_error.message : "expected #{expected_error}#{given_error}"
64
60
  end
65
61
 
66
62
  def negative_failure_message
@@ -26,7 +26,8 @@ module Spec
26
26
  end
27
27
 
28
28
  def description
29
- "respond to ##{@names.to_s}"
29
+ # Ruby 1.9 returns the same thing for array.to_s as array.inspect, so just use array.inspect here
30
+ "respond to #{@names.inspect}"
30
31
  end
31
32
  end
32
33
 
@@ -21,9 +21,13 @@ module Spec
21
21
  end
22
22
  @caught_symbol = @expected_symbol unless @caught_arg == :nothing_thrown
23
23
  end
24
- rescue NameError => e
25
- raise e unless e.message =~ /uncaught throw/
26
- @caught_symbol = e.name.to_sym
24
+
25
+ # Ruby 1.8 uses NameError with `symbol'
26
+ # Ruby 1.9 uses ArgumentError with :symbol
27
+ rescue NameError, ArgumentError => e
28
+ raise e unless e.message =~ /uncaught throw (`|\:)([a-zA-Z0-9_]*)(')?/
29
+ @caught_symbol = $2.to_sym
30
+
27
31
  ensure
28
32
  if @expected_symbol.nil?
29
33
  return !@caught_symbol.nil?
@@ -31,6 +35,8 @@ module Spec
31
35
  if @expected_arg.nil?
32
36
  return @caught_symbol == @expected_symbol
33
37
  else
38
+ # puts [@caught_symbol, @expected_symbol].inspect
39
+ # puts [@caught_arg, @expected_arg].inspect
34
40
  return @caught_symbol == @expected_symbol && @caught_arg == @expected_arg
35
41
  end
36
42
  end
@@ -39,11 +39,6 @@ module Spec
39
39
  child
40
40
  end
41
41
 
42
- def error_generator_opts=(opts={})
43
- @error_generator.opts = opts
44
- end
45
- protected :error_generator_opts=
46
-
47
42
  def expected_args
48
43
  @args_expectation.args
49
44
  end
@@ -98,7 +98,7 @@ module Spec
98
98
  expectation.advise(args, block) if null_object? unless expectation.expected_messages_received?
99
99
  raise_unexpected_message_args_error(expectation, *args) unless (has_negative_expectation?(sym) or null_object?)
100
100
  else
101
- @target.send :method_missing, sym, *args, &block
101
+ @target.__send__ :method_missing, sym, *args, &block
102
102
  end
103
103
  end
104
104
 
@@ -125,14 +125,16 @@ module Spec
125
125
 
126
126
  def define_expected_method(sym)
127
127
  visibility_string = "#{visibility(sym)} :#{sym}"
128
- if target_responds_to?(sym) && !target_metaclass.method_defined?(munge(sym))
129
- munged_sym = munge(sym)
130
- target_metaclass.instance_eval do
131
- alias_method munged_sym, sym if method_defined?(sym.to_s)
128
+ unless @proxied_methods.include?(sym)
129
+ if target_responds_to?(sym)
130
+ munged_sym = munge(sym)
131
+ target_metaclass.instance_eval do
132
+ alias_method munged_sym, sym if method_defined?(sym.to_s)
133
+ end
134
+ @proxied_methods << sym
132
135
  end
133
- @proxied_methods << sym
134
136
  end
135
-
137
+
136
138
  target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__)
137
139
  def #{sym}(*args, &block)
138
140
  __mock_proxy.message_received :#{sym}, *args, &block
@@ -142,9 +144,9 @@ module Spec
142
144
  end
143
145
 
144
146
  def target_responds_to?(sym)
145
- return @target.send(munge(:respond_to?),sym) if @already_proxied_respond_to
147
+ return @target.__send__(munge(:respond_to?),sym) if @already_proxied_respond_to
146
148
  return @already_proxied_respond_to = true if sym == :respond_to?
147
- return @target.respond_to?(sym)
149
+ return @target.respond_to?(sym, true)
148
150
  end
149
151
 
150
152
  def visibility(sym)
@@ -193,7 +195,7 @@ module Spec
193
195
  alias_method sym, munged_sym
194
196
  undef_method munged_sym
195
197
  else
196
- undef_method sym
198
+ remove_method sym
197
199
  end
198
200
  end
199
201
  end
@@ -56,12 +56,10 @@ module Spec
56
56
  # end
57
57
  #
58
58
  class SpecTask < ::Rake::TaskLib
59
- class << self
60
- def attr_accessor(*names)
61
- super(*names)
62
- names.each do |name|
63
- module_eval "def #{name}() evaluate(@#{name}) end" # Allows use of procs
64
- end
59
+ def self.attr_accessor(*names)
60
+ super(*names)
61
+ names.each do |name|
62
+ module_eval "def #{name}() evaluate(@#{name}) end" # Allows use of procs
65
63
  end
66
64
  end
67
65
 
@@ -1,16 +1,14 @@
1
1
  module Spec
2
2
  module Runner
3
3
  class ClassAndArgumentsParser
4
- class << self
5
- def parse(s)
6
- if s =~ /([a-zA-Z_]+(?:::[a-zA-Z_]+)*):?(.*)/
7
- arg = $2 == "" ? nil : $2
8
- [$1, arg]
9
- else
10
- raise "Couldn't parse #{s.inspect}"
11
- end
4
+ def self.parse(s)
5
+ if s =~ /([a-zA-Z_]+(?:::[a-zA-Z_]+)*):?(.*)/
6
+ arg = $2 == "" ? nil : $2
7
+ [$1, arg]
8
+ else
9
+ raise "Couldn't parse #{s.inspect}"
12
10
  end
13
11
  end
14
12
  end
15
13
  end
16
- end
14
+ end
@@ -3,14 +3,12 @@ require 'spec/runner/option_parser'
3
3
  module Spec
4
4
  module Runner
5
5
  class CommandLine
6
- class << self
7
- def run(tmp_options=Spec::Runner.options)
8
- orig_options = Spec::Runner.options
9
- Spec::Runner.use tmp_options
10
- tmp_options.run_examples
11
- ensure
12
- Spec::Runner.use orig_options
13
- end
6
+ def self.run(tmp_options=Spec::Runner.options)
7
+ orig_options = Spec::Runner.options
8
+ Spec::Runner.use tmp_options
9
+ tmp_options.run_examples
10
+ ensure
11
+ Spec::Runner.use orig_options
14
12
  end
15
13
  end
16
14
  end
@@ -14,6 +14,7 @@ module Spec
14
14
  def initialize(options, where)
15
15
  super
16
16
  if where.is_a?(String)
17
+ FileUtils.mkdir_p(File.dirname(where))
17
18
  @output = File.open(where, 'w')
18
19
  else
19
20
  @output = where
@@ -69,8 +70,8 @@ module Spec
69
70
  @output.puts
70
71
  @output.puts "Pending:"
71
72
  @pending_examples.each do |pending_example|
72
- @output.puts "#{pending_example[0]} (#{pending_example[1]})"
73
- @output.puts " Called from #{pending_example[2]}"
73
+ @output.puts "\n#{pending_example[0]} (#{pending_example[1]})"
74
+ @output.puts "#{pending_example[2]}\n"
74
75
  end
75
76
  end
76
77
  @output.flush
@@ -4,12 +4,10 @@ require 'stringio'
4
4
  module Spec
5
5
  module Runner
6
6
  class OptionParser < ::OptionParser
7
- class << self
8
- def parse(args, err, out)
9
- parser = new(err, out)
10
- parser.parse(args)
11
- parser.options
12
- end
7
+ def self.parse(args, err, out)
8
+ parser = new(err, out)
9
+ parser.parse(args)
10
+ parser.options
13
11
  end
14
12
 
15
13
  attr_reader :options
@@ -12,7 +12,7 @@ module Spec
12
12
  best_match.clear
13
13
  file = File.expand_path(file)
14
14
  Spec::Runner.options.example_groups.each do |example_group|
15
- consider_example_groups_for_best_match example_group, file, line_number
15
+ consider_example_group_for_best_match example_group, file, line_number
16
16
 
17
17
  example_group.examples.each do |example|
18
18
  consider_example_for_best_match example, example_group, file, line_number
@@ -31,8 +31,8 @@ module Spec
31
31
 
32
32
  protected
33
33
 
34
- def consider_example_groups_for_best_match(example_group, file, line_number)
35
- parsed_backtrace = parse_backtrace(example_group.registration_backtrace)
34
+ def consider_example_group_for_best_match(example_group, file, line_number)
35
+ parsed_backtrace = parse_backtrace(example_group.backtrace)
36
36
  parsed_backtrace.each do |example_file, example_line|
37
37
  if is_best_match?(file, line_number, example_file, example_line)
38
38
  best_match.clear
@@ -43,7 +43,7 @@ module Spec
43
43
  end
44
44
 
45
45
  def consider_example_for_best_match(example, example_group, file, line_number)
46
- parsed_backtrace = parse_backtrace(example.implementation_backtrace)
46
+ parsed_backtrace = parse_backtrace(example.backtrace)
47
47
  parsed_backtrace.each do |example_file, example_line|
48
48
  if is_best_match?(file, line_number, example_file, example_line)
49
49
  best_match.clear
@@ -61,7 +61,7 @@ module Spec
61
61
  end
62
62
 
63
63
  def parse_backtrace(backtrace)
64
- backtrace.collect do |trace_line|
64
+ Array(backtrace).collect do |trace_line|
65
65
  split_line = trace_line.split(':')
66
66
  [split_line[0], Integer(split_line[1])]
67
67
  end
data/lib/spec/runner.rb CHANGED
@@ -164,50 +164,48 @@ module Spec
164
164
  # end
165
165
  # end
166
166
  module Runner
167
- class << self
168
- def configuration # :nodoc:
169
- @configuration ||= Spec::Example::Configuration.new
170
- end
171
-
172
- # Use this to configure various configurable aspects of
173
- # RSpec:
174
- #
175
- # Spec::Runner.configure do |configuration|
176
- # # Configure RSpec here
177
- # end
178
- #
179
- # The yielded <tt>configuration</tt> object is a
180
- # Spec::Example::Configuration instance. See its RDoc
181
- # for details about what you can do with it.
182
- #
183
- def configure
184
- yield configuration
185
- end
186
-
187
- def register_at_exit_hook # :nodoc:
188
- unless @already_registered_at_exit_hook
189
- at_exit do
190
- unless $! || Spec.run? || Spec::Example::ExampleGroupFactory.registered_or_ancestor_of_registered?(options.example_groups)
191
- success = Spec.run
192
- exit success if Spec.exit?
193
- end
167
+ def self.configuration # :nodoc:
168
+ @configuration ||= Spec::Example::Configuration.new
169
+ end
170
+
171
+ # Use this to configure various configurable aspects of
172
+ # RSpec:
173
+ #
174
+ # Spec::Runner.configure do |configuration|
175
+ # # Configure RSpec here
176
+ # end
177
+ #
178
+ # The yielded <tt>configuration</tt> object is a
179
+ # Spec::Example::Configuration instance. See its RDoc
180
+ # for details about what you can do with it.
181
+ #
182
+ def self.configure
183
+ yield configuration
184
+ end
185
+
186
+ def self.register_at_exit_hook # :nodoc:
187
+ unless @already_registered_at_exit_hook
188
+ at_exit do
189
+ unless $! || Spec.run? || Spec::Example::ExampleGroupFactory.registered_or_ancestor_of_registered?(options.example_groups)
190
+ success = Spec.run
191
+ exit success if Spec.exit?
194
192
  end
195
- @already_registered_at_exit_hook = true
196
193
  end
194
+ @already_registered_at_exit_hook = true
197
195
  end
196
+ end
198
197
 
199
- def options # :nodoc:
200
- @options ||= begin
201
- parser = ::Spec::Runner::OptionParser.new($stderr, $stdout)
202
- parser.order!(ARGV)
203
- parser.options
204
- end
205
- end
206
-
207
- def use options
208
- @options = options
198
+ def self.options # :nodoc:
199
+ @options ||= begin
200
+ parser = ::Spec::Runner::OptionParser.new($stderr, $stdout)
201
+ parser.order!(ARGV)
202
+ parser.options
209
203
  end
210
-
211
204
  end
205
+
206
+ def self.use options
207
+ @options = options
208
+ end
209
+
212
210
  end
213
211
  end