rspec 1.2.2 → 1.2.3
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.
- data/History.rdoc +31 -1
- data/Manifest.txt +14 -12
- data/Rakefile +1 -1
- data/Upgrade.rdoc +43 -3
- data/examples/failing/failing_implicit_docstrings_example.rb +5 -5
- data/examples/passing/implicit_docstrings_example.rb +3 -3
- data/features/before_and_after_blocks/before_and_after_blocks.feature +20 -21
- data/features/example_groups/example_group_with_should_methods.feature +20 -8
- data/features/example_groups/implicit_docstrings.feature +36 -20
- data/features/example_groups/nested_groups.feature +25 -10
- data/features/extensions/custom_example_group.feature +19 -0
- data/features/formatters/custom_formatter.feature +30 -0
- data/features/heckle/heckle.feature +7 -7
- data/features/interop/examples_and_tests_together.feature +63 -14
- data/features/interop/rspec_output.feature +25 -0
- data/features/interop/test_but_not_test_unit.feature +19 -7
- data/features/interop/test_case_with_should_methods.feature +37 -8
- data/features/matchers/{create_matcher.feature → define_matcher.feature} +54 -30
- data/features/matchers/{create_matcher_outside_rspec.feature → define_matcher_outside_rspec.feature} +7 -7
- data/features/mock_framework_integration/use_flexmock.feature +3 -3
- data/features/mock_framework_integration/use_mocha.feature +3 -3
- data/features/mock_framework_integration/use_rr.feature +3 -3
- data/features/mocks/mix_stubs_and_mocks.feature +4 -4
- data/features/pending/pending_examples.feature +18 -18
- data/features/runner/specify_line_number.feature +32 -0
- data/features/step_definitions/running_rspec_steps.rb +41 -0
- data/features/subject/explicit_subject.feature +4 -4
- data/features/subject/implicit_subject.feature +4 -4
- data/features/support/env.rb +64 -11
- data/features/support/matchers/smart_match.rb +10 -35
- data/lib/spec.rb +1 -0
- data/lib/spec/deprecation.rb +40 -0
- data/lib/spec/dsl/main.rb +10 -5
- data/lib/spec/example.rb +1 -27
- data/lib/spec/example/args_and_options.rb +27 -0
- data/lib/spec/example/before_and_after_hooks.rb +30 -21
- data/lib/spec/example/errors.rb +8 -18
- data/lib/spec/example/example_group_factory.rb +0 -4
- data/lib/spec/example/example_group_methods.rb +27 -41
- data/lib/spec/example/example_group_proxy.rb +12 -22
- data/lib/spec/example/example_methods.rb +8 -18
- data/lib/spec/example/example_proxy.rb +4 -4
- data/lib/spec/example/pending.rb +3 -4
- data/lib/spec/example/predicate_matchers.rb +1 -1
- data/lib/spec/example/subject.rb +2 -0
- data/lib/spec/expectations.rb +1 -26
- data/lib/spec/expectations/extensions.rb +1 -1
- data/lib/spec/expectations/extensions/kernel.rb +52 -0
- data/lib/spec/expectations/handler.rb +21 -10
- data/lib/spec/matchers/be.rb +3 -3
- data/lib/spec/matchers/be_close.rb +17 -21
- data/lib/spec/matchers/be_instance_of.rb +7 -26
- data/lib/spec/matchers/be_kind_of.rb +7 -26
- data/lib/spec/matchers/dsl.rb +9 -4
- data/lib/spec/matchers/eql.rb +24 -25
- data/lib/spec/matchers/equal.rb +25 -25
- data/lib/spec/matchers/exist.rb +5 -21
- data/lib/spec/matchers/include.rb +22 -44
- data/lib/spec/matchers/match.rb +5 -25
- data/lib/spec/matchers/match_array.rb +8 -4
- data/lib/spec/matchers/matcher.rb +13 -2
- data/lib/spec/matchers/pretty.rb +1 -0
- data/lib/spec/matchers/simple_matcher.rb +2 -2
- data/lib/spec/mocks/mock.rb +10 -10
- data/lib/spec/mocks/spec_methods.rb +1 -1
- data/lib/spec/runner/configuration.rb +53 -42
- data/lib/spec/{expectations → runner}/differs/default.rb +0 -0
- data/lib/spec/{expectations → runner}/differs/load-diff-lcs.rb +0 -0
- data/lib/spec/runner/drb_command_line.rb +1 -1
- data/lib/spec/runner/example_group_runner.rb +0 -12
- data/lib/spec/runner/formatter/base_formatter.rb +77 -30
- data/lib/spec/runner/formatter/base_text_formatter.rb +19 -24
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +1 -1
- data/lib/spec/runner/formatter/html_formatter.rb +4 -6
- data/lib/spec/runner/formatter/nested_text_formatter.rb +2 -2
- data/lib/spec/runner/formatter/no_op_method_missing.rb +21 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +0 -4
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +4 -5
- data/lib/spec/runner/formatter/silent_formatter.rb +10 -0
- data/lib/spec/runner/formatter/specdoc_formatter.rb +2 -2
- data/lib/spec/runner/option_parser.rb +14 -7
- data/lib/spec/runner/options.rb +17 -7
- data/lib/spec/runner/reporter.rb +69 -64
- data/lib/spec/version.rb +1 -1
- data/spec/spec/dsl/main_spec.rb +7 -0
- data/spec/spec/example/example_group_methods_spec.rb +16 -32
- data/spec/spec/example/example_group_proxy_spec.rb +25 -5
- data/spec/spec/example/example_group_spec.rb +2 -2
- data/spec/spec/example/example_methods_spec.rb +19 -24
- data/spec/spec/example/example_proxy_spec.rb +11 -1
- data/spec/spec/example/pending_module_spec.rb +2 -108
- data/spec/spec/example/predicate_matcher_spec.rb +23 -3
- data/spec/spec/expectations/extensions/object_spec.rb +9 -9
- data/spec/spec/expectations/fail_with_spec.rb +13 -13
- data/spec/spec/expectations/handler_spec.rb +44 -15
- data/spec/spec/matchers/be_close_spec.rb +9 -0
- data/spec/spec/matchers/be_instance_of_spec.rb +6 -4
- data/spec/spec/matchers/be_kind_of_spec.rb +5 -3
- data/spec/spec/matchers/be_spec.rb +1 -5
- data/spec/spec/matchers/compatibility_spec.rb +1 -1
- data/spec/spec/matchers/dsl_spec.rb +10 -1
- data/spec/spec/matchers/eql_spec.rb +8 -4
- data/spec/spec/matchers/equal_spec.rb +8 -4
- data/spec/spec/matchers/exist_spec.rb +1 -1
- data/spec/spec/matchers/include_spec.rb +1 -1
- data/spec/spec/matchers/match_array_spec.rb +26 -1
- data/spec/spec/matchers/match_spec.rb +2 -2
- data/spec/spec/matchers/matcher_methods_spec.rb +0 -3
- data/spec/spec/matchers/matcher_spec.rb +53 -0
- data/spec/spec/matchers/operator_matcher_spec.rb +1 -1
- data/spec/spec/mocks/mock_spec.rb +6 -0
- data/spec/spec/runner/configuration_spec.rb +11 -1
- data/spec/spec/runner/drb_command_line_spec.rb +13 -1
- data/spec/spec/runner/example_group_runner_spec.rb +0 -7
- data/spec/spec/runner/formatter/base_formatter_spec.rb +19 -12
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +4 -4
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +31 -34
- data/spec/spec/runner/formatter/html_formatter_spec.rb +20 -0
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -20
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +22 -3
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +24 -3
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +25 -28
- data/spec/spec/runner/formatter/text_mate_formatter_spec.rb +2 -2
- data/spec/spec/runner/option_parser_spec.rb +108 -40
- data/spec/spec/runner/reporter_spec.rb +16 -17
- data/spec/spec_helper.rb +4 -1
- metadata +20 -18
- data/features/example_groups/output.feature +0 -20
- data/features/step_definitions/running_rspec.rb +0 -69
- data/lib/spec/expectations/extensions/object.rb +0 -63
- data/resources/spec/example_group_with_should_methods.rb +0 -12
- data/resources/spec/simple_spec.rb +0 -8
- data/resources/test/spec_and_test_together.rb +0 -56
- data/resources/test/spec_including_test_but_not_unit.rb +0 -11
- data/resources/test/test_case_with_should_methods.rb +0 -29
data/lib/spec.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Spec
|
2
|
+
class << self
|
3
|
+
def deprecate(method, alternate_method=nil)
|
4
|
+
message = <<-NOTICE
|
5
|
+
|
6
|
+
*****************************************************************
|
7
|
+
DEPRECATION WARNING: you are using deprecated behaviour that will
|
8
|
+
be removed from a future version of RSpec.
|
9
|
+
|
10
|
+
#{caller(0)[2]}
|
11
|
+
|
12
|
+
* #{method} is deprecated.
|
13
|
+
NOTICE
|
14
|
+
if alternate_method
|
15
|
+
message << <<-ADDITIONAL
|
16
|
+
* please use #{alternate_method} instead.
|
17
|
+
ADDITIONAL
|
18
|
+
end
|
19
|
+
|
20
|
+
message << "*****************************************************************"
|
21
|
+
warn(message)
|
22
|
+
end
|
23
|
+
|
24
|
+
def warn(message)
|
25
|
+
Kernel.warn(message)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class HashWithDeprecationNotice < Hash
|
31
|
+
def initialize(method, alternate_method=nil, &block)
|
32
|
+
@method, @alternate_method = method, alternate_method
|
33
|
+
end
|
34
|
+
def []=(k,v)
|
35
|
+
Spec.deprecate(@method, @alternate_method)
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
data/lib/spec/dsl/main.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Spec
|
2
2
|
module DSL
|
3
3
|
module Main
|
4
|
+
include Spec::Example::ArgsAndOptions
|
5
|
+
|
4
6
|
# Creates and returns a class that includes the ExampleGroupMethods
|
5
7
|
# module. Which ExampleGroup type is created depends on the directory of the file
|
6
8
|
# calling this method. For example, Spec::Rails will use different
|
@@ -13,15 +15,16 @@ module Spec
|
|
13
15
|
#
|
14
16
|
# describe "name", :type => :something_special do ...
|
15
17
|
#
|
16
|
-
# The reason for using different
|
18
|
+
# The reason for using different example group classes is to have different
|
17
19
|
# matcher methods available from within the <tt>describe</tt> block.
|
18
20
|
#
|
19
21
|
# See Spec::Example::ExampleGroupFactory#register for details about how to
|
20
22
|
# register special implementations.
|
21
23
|
#
|
22
24
|
def describe(*args, &block)
|
23
|
-
Spec::Example::
|
24
|
-
|
25
|
+
raise Spec::Example::NoDescriptionError.new("example group", caller(0)[1]) if args.empty?
|
26
|
+
add_options(args, :scope => self)
|
27
|
+
set_location(args.options, caller(0)[1])
|
25
28
|
Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
|
26
29
|
end
|
27
30
|
alias :context :describe
|
@@ -42,7 +45,8 @@ module Spec
|
|
42
45
|
# end
|
43
46
|
# end
|
44
47
|
def share_examples_for(*args, &block)
|
45
|
-
|
48
|
+
add_options(args)
|
49
|
+
set_location(args.options, caller(0)[1])
|
46
50
|
Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block)
|
47
51
|
end
|
48
52
|
alias :shared_examples_for :share_examples_for
|
@@ -74,7 +78,8 @@ module Spec
|
|
74
78
|
def share_as(name, &block)
|
75
79
|
begin
|
76
80
|
args = [name]
|
77
|
-
|
81
|
+
add_options(args)
|
82
|
+
set_location(args.options, caller(0)[1])
|
78
83
|
Object.const_set(name, Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block))
|
79
84
|
rescue NameError => e
|
80
85
|
raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n")
|
data/lib/spec/example.rb
CHANGED
@@ -142,37 +142,11 @@ module Spec
|
|
142
142
|
# end
|
143
143
|
# end
|
144
144
|
module Example
|
145
|
-
class << self
|
146
|
-
def args_and_options(*args) # :nodoc:
|
147
|
-
with_options_from(args) do |options|
|
148
|
-
return args, options
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def scope_from(*args) # :nodoc:
|
153
|
-
args[0] || :each
|
154
|
-
end
|
155
|
-
|
156
|
-
def scope_and_options(*args) # :nodoc:
|
157
|
-
args, options = args_and_options(*args)
|
158
|
-
return scope_from(*args), options
|
159
|
-
end
|
160
|
-
|
161
|
-
def set_location(args, location) # :nodoc:
|
162
|
-
args << {} unless Hash === args.last
|
163
|
-
args.last[:location] ||= location
|
164
|
-
end
|
165
|
-
|
166
|
-
private
|
167
|
-
|
168
|
-
def with_options_from(args)
|
169
|
-
yield Hash === args.last ? args.pop : {} if block_given?
|
170
|
-
end
|
171
|
-
end
|
172
145
|
end
|
173
146
|
end
|
174
147
|
|
175
148
|
require 'timeout'
|
149
|
+
require 'spec/example/args_and_options'
|
176
150
|
require 'spec/example/predicate_matchers'
|
177
151
|
require 'spec/example/example_group_proxy'
|
178
152
|
require 'spec/example/example_proxy'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Spec
|
2
|
+
module Example
|
3
|
+
module ArgsAndOptions
|
4
|
+
def args_and_options(*args) # :nodoc:
|
5
|
+
options = Hash === args.last ? args.pop : {}
|
6
|
+
return args, options
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_options(args, options={}) # :nodoc:
|
10
|
+
args << {} unless Hash === args.last
|
11
|
+
args.extend WithOptions
|
12
|
+
args.options.merge!(options)
|
13
|
+
args.options
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_location(options, location) # :nodoc:
|
17
|
+
options[:location] ||= location
|
18
|
+
end
|
19
|
+
|
20
|
+
module WithOptions # :nodoc:
|
21
|
+
def options
|
22
|
+
last
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -2,39 +2,48 @@ module Spec
|
|
2
2
|
module Example
|
3
3
|
module BeforeAndAfterHooks
|
4
4
|
class << self
|
5
|
-
def before_suite_parts
|
5
|
+
def before_suite_parts # :nodoc:
|
6
6
|
@before_suite_parts ||= []
|
7
7
|
end
|
8
8
|
|
9
|
-
def after_suite_parts
|
9
|
+
def after_suite_parts # :nodoc:
|
10
10
|
@after_suite_parts ||= []
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
# Registers a block to be executed before
|
15
|
-
#
|
16
|
-
|
17
|
-
|
14
|
+
# Registers a block to be executed before examples. <tt>scope</tt> can be
|
15
|
+
# <tt>:each</tt> (default), <tt>:all</tt>, or <tt>:suite</tt>. When
|
16
|
+
# <tt>:each</tt>, the block is executed before each example. When
|
17
|
+
# <tt>:all</tt>, the block is executed only once before any examples are
|
18
|
+
# run.
|
19
|
+
def append_before(scope = :each, &block)
|
20
|
+
before_parts(scope) << block
|
18
21
|
end
|
22
|
+
alias_method :before, :append_before
|
19
23
|
|
20
24
|
# Registers a block to be executed before each example.
|
21
|
-
# This method
|
22
|
-
|
23
|
-
|
25
|
+
# This method prepends +block+ to existing before blocks.
|
26
|
+
#
|
27
|
+
# See <tt>append_before</tt> for scoping semantics.
|
28
|
+
def prepend_before(scope = :each, &block)
|
29
|
+
before_parts(scope).unshift(block)
|
24
30
|
end
|
25
|
-
alias_method :before, :append_before
|
26
31
|
|
27
32
|
# Registers a block to be executed after each example.
|
28
33
|
# This method prepends +block+ to existing after blocks.
|
29
|
-
|
30
|
-
|
34
|
+
#
|
35
|
+
# See <tt>append_before</tt> for scoping semantics.
|
36
|
+
def prepend_after(scope = :each, &block)
|
37
|
+
after_parts(scope).unshift(block)
|
31
38
|
end
|
32
39
|
alias_method :after, :prepend_after
|
33
40
|
|
34
41
|
# Registers a block to be executed after each example.
|
35
42
|
# This method appends +block+ to existing after blocks.
|
36
|
-
|
37
|
-
|
43
|
+
#
|
44
|
+
# See <tt>append_before</tt> for scoping semantics.
|
45
|
+
def append_after(scope = :each, &block)
|
46
|
+
after_parts(scope) << block
|
38
47
|
end
|
39
48
|
|
40
49
|
def before_each_parts # :nodoc:
|
@@ -53,26 +62,26 @@ module Spec
|
|
53
62
|
@after_all_parts ||= []
|
54
63
|
end
|
55
64
|
|
56
|
-
def before_suite_parts
|
65
|
+
def before_suite_parts # :nodoc:
|
57
66
|
BeforeAndAfterHooks.before_suite_parts
|
58
67
|
end
|
59
68
|
|
60
|
-
def after_suite_parts
|
69
|
+
def after_suite_parts # :nodoc:
|
61
70
|
BeforeAndAfterHooks.after_suite_parts
|
62
71
|
end
|
63
72
|
|
64
|
-
private
|
73
|
+
private
|
65
74
|
|
66
|
-
def before_parts(
|
67
|
-
case
|
75
|
+
def before_parts(scope)
|
76
|
+
case scope
|
68
77
|
when :each; before_each_parts
|
69
78
|
when :all; before_all_parts
|
70
79
|
when :suite; before_suite_parts
|
71
80
|
end
|
72
81
|
end
|
73
82
|
|
74
|
-
def after_parts(
|
75
|
-
case
|
83
|
+
def after_parts(scope)
|
84
|
+
case scope
|
76
85
|
when :each; after_each_parts
|
77
86
|
when :all; after_all_parts
|
78
87
|
when :suite; after_suite_parts
|
data/lib/spec/example/errors.rb
CHANGED
@@ -1,30 +1,20 @@
|
|
1
1
|
module Spec
|
2
2
|
module Example
|
3
|
-
class ExamplePendingError < StandardError
|
4
|
-
attr_reader :pending_caller
|
5
|
-
|
6
|
-
def initialize(message=nil, pending_caller=nil)
|
7
|
-
super(message)
|
8
|
-
@pending_caller = pending_caller || caller[2]
|
9
|
-
end
|
10
|
-
end
|
3
|
+
class ExamplePendingError < StandardError; end
|
11
4
|
|
12
5
|
class NotYetImplementedError < ExamplePendingError
|
13
6
|
MESSAGE = "Not Yet Implemented"
|
14
|
-
|
15
|
-
|
16
|
-
def initialize(backtrace)
|
7
|
+
def initialize
|
17
8
|
super(MESSAGE)
|
18
|
-
@pending_caller = pending_caller_from(backtrace)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def pending_caller_from(backtrace)
|
24
|
-
backtrace.detect {|line| !line.include?(RSPEC_ROOT_LIB) }
|
25
9
|
end
|
26
10
|
end
|
27
11
|
|
28
12
|
class PendingExampleFixedError < StandardError; end
|
13
|
+
|
14
|
+
class NoDescriptionError < ArgumentError
|
15
|
+
def initialize(kind, location)
|
16
|
+
super("No description supplied for #{kind} declared on #{location}")
|
17
|
+
end
|
18
|
+
end
|
29
19
|
end
|
30
20
|
end
|
@@ -1,14 +1,23 @@
|
|
1
1
|
module Spec
|
2
2
|
module Example
|
3
3
|
|
4
|
-
module ExampleGroupMethods
|
4
|
+
module ExampleGroupMethods
|
5
5
|
class << self
|
6
6
|
attr_accessor :matcher_class
|
7
|
+
|
8
|
+
def build_description_from(*args)
|
9
|
+
text = args.inject("") do |description, arg|
|
10
|
+
description << " " unless (description == "" || arg.to_s =~ /^(\s|\.|#)/)
|
11
|
+
description << arg.to_s
|
12
|
+
end
|
13
|
+
text == "" ? nil : text
|
14
|
+
end
|
7
15
|
end
|
8
16
|
|
9
17
|
include Spec::Example::BeforeAndAfterHooks
|
10
18
|
include Spec::Example::Subject::ExampleGroupMethods
|
11
19
|
include Spec::Example::PredicateMatchers
|
20
|
+
include Spec::Example::ArgsAndOptions
|
12
21
|
|
13
22
|
attr_reader :options, :location
|
14
23
|
|
@@ -17,20 +26,6 @@ module Spec
|
|
17
26
|
ExampleGroupFactory.register_example_group(klass)
|
18
27
|
end
|
19
28
|
|
20
|
-
# Provides the backtrace up to where this example_group was declared.
|
21
|
-
def backtrace
|
22
|
-
defined?(@backtrace) ? @backtrace : nil
|
23
|
-
end
|
24
|
-
|
25
|
-
# Deprecated - use +backtrace()+
|
26
|
-
def example_group_backtrace
|
27
|
-
Kernel.warn <<-WARNING
|
28
|
-
ExampleGroupMethods#example_group_backtrace is deprecated and will be removed
|
29
|
-
from a future version. Please use ExampleGroupMethods#backtrace instead.
|
30
|
-
WARNING
|
31
|
-
backtrace
|
32
|
-
end
|
33
|
-
|
34
29
|
# Makes the describe/it syntax available from a class. For example:
|
35
30
|
#
|
36
31
|
# class StackSpec < Spec::ExampleGroup
|
@@ -46,9 +41,10 @@ WARNING
|
|
46
41
|
# end
|
47
42
|
#
|
48
43
|
def describe(*args, &example_group_block)
|
44
|
+
raise Spec::Example::NoDescriptionError.new("example group", caller(0)[1]) if args.empty?
|
49
45
|
if example_group_block
|
50
|
-
|
51
|
-
options
|
46
|
+
options = add_options(args)
|
47
|
+
set_location(options, caller(0)[1])
|
52
48
|
if options[:shared]
|
53
49
|
ExampleGroupFactory.create_shared_example_group(*args, &example_group_block)
|
54
50
|
else
|
@@ -77,8 +73,7 @@ WARNING
|
|
77
73
|
end
|
78
74
|
|
79
75
|
def pending_implementation
|
80
|
-
|
81
|
-
lambda { raise(error) }
|
76
|
+
lambda { raise(Spec::Example::NotYetImplementedError) }
|
82
77
|
end
|
83
78
|
|
84
79
|
alias_method :it, :example
|
@@ -101,23 +96,23 @@ WARNING
|
|
101
96
|
define_methods_from_predicate_matchers
|
102
97
|
|
103
98
|
success, before_all_instance_variables = run_before_all(run_options)
|
104
|
-
success, after_all_instance_variables =
|
99
|
+
success, after_all_instance_variables = run_examples(success, before_all_instance_variables, examples, run_options)
|
105
100
|
success = run_after_all(success, after_all_instance_variables, run_options)
|
106
101
|
end
|
107
102
|
|
108
103
|
def set_description(*args)
|
109
|
-
@description_args, @options =
|
104
|
+
@description_args, @options = args_and_options(*args)
|
110
105
|
@backtrace = caller(1)
|
111
106
|
@location = File.expand_path(options[:location]) if options[:location]
|
112
107
|
self
|
113
108
|
end
|
114
109
|
|
115
|
-
def notify(
|
116
|
-
|
110
|
+
def notify(reporter) # :nodoc:
|
111
|
+
reporter.example_group_started(ExampleGroupProxy.new(self))
|
117
112
|
end
|
118
113
|
|
119
114
|
def description
|
120
|
-
@description ||= build_description_from(*description_parts) || to_s
|
115
|
+
@description ||= ExampleGroupMethods.build_description_from(*description_parts) || to_s
|
121
116
|
end
|
122
117
|
|
123
118
|
def described_type
|
@@ -198,7 +193,7 @@ WARNING
|
|
198
193
|
end
|
199
194
|
end
|
200
195
|
|
201
|
-
def
|
196
|
+
def run_examples(success, instance_variables, examples, run_options)
|
202
197
|
return [success, instance_variables] unless success
|
203
198
|
|
204
199
|
after_all_instance_variables = instance_variables
|
@@ -218,22 +213,22 @@ WARNING
|
|
218
213
|
after_all = new(example_proxy)
|
219
214
|
after_all.set_instance_variables_from_hash(instance_variables)
|
220
215
|
example_group_hierarchy.run_after_all(after_all)
|
221
|
-
|
216
|
+
success
|
222
217
|
rescue Exception => e
|
223
218
|
run_options.reporter.example_failed(example_proxy, e)
|
224
|
-
|
219
|
+
false
|
225
220
|
end
|
226
221
|
|
227
222
|
def examples_to_run(run_options)
|
228
|
-
return example_proxies unless
|
229
|
-
example_proxies.reject do |
|
223
|
+
return example_proxies unless examples_were_specified?(run_options)
|
224
|
+
example_proxies.reject do |proxy|
|
230
225
|
matcher = ExampleGroupMethods.matcher_class.
|
231
|
-
new(description.to_s,
|
226
|
+
new(description.to_s, proxy.description)
|
232
227
|
!matcher.matches?(run_options.examples)
|
233
228
|
end
|
234
229
|
end
|
235
230
|
|
236
|
-
def
|
231
|
+
def examples_were_specified?(run_options)
|
237
232
|
!run_options.examples.empty?
|
238
233
|
end
|
239
234
|
|
@@ -256,21 +251,12 @@ WARNING
|
|
256
251
|
when SharedExampleGroup
|
257
252
|
include shared_example_group
|
258
253
|
else
|
259
|
-
example_group = SharedExampleGroup.find(shared_example_group)
|
260
|
-
unless example_group
|
254
|
+
unless example_group = SharedExampleGroup.find(shared_example_group)
|
261
255
|
raise RuntimeError.new("Shared Example Group '#{shared_example_group}' can not be found")
|
262
256
|
end
|
263
257
|
include(example_group)
|
264
258
|
end
|
265
259
|
end
|
266
|
-
|
267
|
-
def build_description_from(*args)
|
268
|
-
text = args.inject("") do |description, arg|
|
269
|
-
description << " " unless (description == "" || arg.to_s =~ /^(\s|\.|#)/)
|
270
|
-
description << arg.to_s
|
271
|
-
end
|
272
|
-
text == "" ? nil : text
|
273
|
-
end
|
274
260
|
end
|
275
261
|
|
276
262
|
end
|