dchelimsky-rspec 1.1.12 → 1.1.99.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +35 -0
- data/License.txt +1 -1
- data/Manifest.txt +22 -73
- data/README.txt +2 -2
- data/Rakefile +32 -7
- data/TODO.txt +9 -4
- data/bin/spec +1 -1
- data/cucumber.yml +2 -0
- data/examples/failing/spec_helper.rb +1 -1
- data/examples/passing/filtered_formatter.rb +18 -0
- data/examples/passing/filtered_formatter_example.rb +31 -0
- data/examples/passing/spec_helper.rb +1 -1
- data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +17 -18
- data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
- data/features/example_groups/autogenerated_docstrings.feature +2 -2
- data/features/example_groups/example_group_with_should_methods.feature +1 -1
- data/features/example_groups/nested_groups.feature +1 -1
- data/features/interop/examples_and_tests_together.feature +1 -1
- data/features/interop/test_but_not_test_unit.feature +1 -1
- data/features/interop/test_case_with_should_methods.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +22 -4
- data/features/mock_framework_integration/use_mocha.feature +27 -0
- data/features/mock_framework_integration/use_rr.feature +27 -0
- data/features/step_definitions/running_rspec.rb +5 -3
- data/features/support/env.rb +1 -1
- data/features-pending/cli/conditional_exclusion.feature +39 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/flexmock.rb +1 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/mocha.rb +1 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/rr.rb +1 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/rspec.rb +0 -1
- data/lib/spec/autorun.rb +3 -0
- data/lib/spec/example/before_and_after_hooks.rb +5 -20
- data/lib/spec/example/example_description.rb +15 -0
- data/lib/spec/example/example_group.rb +0 -15
- data/lib/spec/example/example_group_factory.rb +34 -46
- data/lib/spec/example/example_group_hierarchy.rb +53 -0
- data/lib/spec/example/example_group_methods.rb +96 -211
- data/lib/spec/example/example_methods.rb +62 -81
- data/lib/spec/example/module_reopening_fix.rb +23 -1
- data/lib/spec/example/predicate_matchers.rb +47 -0
- data/lib/spec/example/subject.rb +91 -0
- data/lib/spec/example.rb +4 -0
- data/lib/spec/expectations/extensions.rb +0 -1
- data/lib/spec/expectations/handler.rb +6 -1
- data/lib/spec/expectations.rb +1 -1
- data/lib/spec/interop/test/unit/testcase.rb +5 -22
- data/lib/spec/interop/test.rb +1 -0
- data/lib/spec/matchers/be.rb +2 -7
- data/lib/spec/matchers/be_close.rb +20 -5
- data/lib/spec/matchers/change.rb +5 -3
- data/lib/spec/matchers/eql.rb +24 -6
- data/lib/spec/matchers/equal.rb +24 -6
- data/lib/spec/matchers/exist.rb +21 -5
- data/lib/spec/matchers/generated_descriptions.rb +2 -2
- data/lib/spec/matchers/has.rb +28 -11
- data/lib/spec/matchers/match.rb +25 -7
- data/lib/spec/matchers/match_array.rb +1 -1
- data/lib/spec/matchers/method_missing.rb +2 -2
- data/lib/spec/matchers/operator_matcher.rb +12 -5
- data/lib/spec/matchers/raise_error.rb +1 -1
- data/lib/spec/matchers/respond_to.rb +1 -1
- data/lib/spec/matchers/satisfy.rb +5 -5
- data/lib/spec/matchers/throw_symbol.rb +1 -3
- data/lib/spec/mocks/argument_expectation.rb +1 -1
- data/lib/spec/mocks/argument_matchers.rb +233 -0
- data/lib/spec/mocks/error_generator.rb +2 -6
- data/lib/spec/mocks/message_expectation.rb +3 -11
- data/lib/spec/mocks/mock.rb +1 -1
- data/lib/spec/mocks/proxy.rb +5 -1
- data/lib/spec/runner/configuration.rb +3 -3
- data/lib/spec/runner/drb_command_line.rb +2 -1
- data/lib/spec/runner/example_group_runner.rb +2 -1
- data/lib/spec/runner/formatter/base_text_formatter.rb +28 -17
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +3 -5
- data/lib/spec/runner/formatter/html_formatter.rb +2 -3
- data/lib/spec/runner/formatter/nested_text_formatter.rb +7 -25
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -7
- data/lib/spec/runner/heckle_runner_unsupported.rb +1 -1
- data/lib/spec/runner/option_parser.rb +16 -19
- data/lib/spec/runner/options.rb +28 -26
- data/lib/spec/runner/reporter.rb +8 -9
- data/lib/spec/runner.rb +6 -28
- data/lib/spec/test/unit.rb +10 -0
- data/lib/spec/version.rb +2 -2
- data/{features/support → resources}/helpers/cmdline.rb +2 -2
- data/resources/rake/verify_rcov.rake +1 -1
- data/resources/spec/example_group_with_should_methods.rb +1 -1
- data/resources/spec/simple_spec.rb +1 -1
- data/resources/test/spec_and_test_together.rb +2 -3
- data/resources/test/spec_including_test_but_not_unit.rb +1 -1
- data/resources/test/test_case_with_should_methods.rb +2 -3
- data/rspec.gemspec +5 -5
- data/spec/spec/dsl/main_spec.rb +3 -3
- data/spec/spec/example/example_group_class_definition_spec.rb +11 -14
- data/spec/spec/example/example_group_factory_spec.rb +31 -44
- data/spec/spec/example/example_group_methods_spec.rb +86 -52
- data/spec/spec/example/example_group_spec.rb +16 -75
- data/spec/spec/example/example_matcher_spec.rb +10 -10
- data/spec/spec/example/example_methods_spec.rb +101 -241
- data/spec/spec/example/nested_example_group_spec.rb +2 -2
- data/spec/spec/example/pending_module_spec.rb +1 -1
- data/spec/spec/example/shared_example_group_spec.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +2 -2
- data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +2 -2
- data/spec/spec/matchers/change_spec.rb +8 -0
- data/spec/spec/matchers/exist_spec.rb +8 -4
- data/spec/spec/matchers/handler_spec.rb +8 -1
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
- data/spec/spec/mocks/{bug_report_496.rb → bug_report_496_spec.rb} +0 -0
- data/spec/spec/mocks/failing_argument_matchers_spec.rb +95 -0
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
- data/spec/spec/mocks/passing_argument_matchers_spec.rb +145 -0
- data/spec/spec/runner/configuration_spec.rb +12 -12
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +72 -1
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +8 -8
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +4 -4
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +8 -8
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +38 -26
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -53
- data/spec/spec/runner/formatter/html_formatter_spec.rb +100 -48
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -34
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +8 -6
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +20 -20
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +38 -26
- data/spec/spec/runner/formatter/{spec_mate_formatter_spec.rb → text_mate_formatter_spec.rb} +10 -8
- data/spec/spec/runner/heckle_runner_spec.rb +1 -1
- data/spec/spec/runner/option_parser_spec.rb +15 -13
- data/spec/spec/runner/options_spec.rb +34 -0
- data/spec/spec/runner/reporter_spec.rb +65 -61
- data/spec/spec/runner/spec_drb.opts +1 -0
- data/spec/spec/runner_spec.rb +7 -5
- data/spec/spec_helper.rb +23 -0
- metadata +25 -76
- data/examples/passing/legacy_spec.rb +0 -11
- data/features/support/helpers/story_helper.rb +0 -13
- data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
- data/resources/spec/spec_with_flexmock.rb +0 -19
- data/spec/spec/spec_spec.rb +0 -21
@@ -1,9 +1,27 @@
|
|
1
|
-
|
1
|
+
Feature: mock with flexmock
|
2
2
|
|
3
3
|
As an RSpec user who prefers flexmock
|
4
4
|
I want to be able to use flexmock without rspec mocks interfering
|
5
5
|
|
6
6
|
Scenario: Mock with flexmock
|
7
|
-
Given the
|
8
|
-
|
9
|
-
|
7
|
+
Given the following spec:
|
8
|
+
"""
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
config.mock_with :flexmock
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "plugging in flexmock" do
|
14
|
+
it "allows flexmock to be used" do
|
15
|
+
target = Object.new
|
16
|
+
flexmock(target).should_receive(:foo).once
|
17
|
+
target.foo
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does not include rspec mocks" do
|
21
|
+
Spec.const_defined?(:Mocks).should be_false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
When I run it with the spec command
|
26
|
+
Then the exit code should be 0
|
27
|
+
And the stdout should match "2 examples, 0 failures"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: mock with mocha
|
2
|
+
|
3
|
+
As an RSpec user who prefers mocha
|
4
|
+
I want to be able to use mocha without rspec mocks interfering
|
5
|
+
|
6
|
+
Scenario: Mock with mocha
|
7
|
+
Given the following spec:
|
8
|
+
"""
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
config.mock_with :mocha
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "plugging in mocha" do
|
14
|
+
it "allows mocha to be used" do
|
15
|
+
target = Object.new
|
16
|
+
target.expects(:foo).once
|
17
|
+
target.foo
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does not include rspec mocks" do
|
21
|
+
Spec.const_defined?(:Mocks).should be_false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
When I run it with the spec command
|
26
|
+
Then the exit code should be 0
|
27
|
+
And the stdout should match "2 examples, 0 failures"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: mock with rr
|
2
|
+
|
3
|
+
As an RSpec user who prefers rr
|
4
|
+
I want to be able to use rr without rspec mocks interfering
|
5
|
+
|
6
|
+
Scenario: Mock with rr
|
7
|
+
Given the following spec:
|
8
|
+
"""
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
config.mock_with :rr
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "plugging in rr" do
|
14
|
+
it "allows rr to be used" do
|
15
|
+
target = Object.new
|
16
|
+
mock(target).foo
|
17
|
+
target.foo
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does not include rspec mocks" do
|
21
|
+
Spec.const_defined?(:Mocks).should be_false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
When I run it with the spec command
|
26
|
+
Then the exit code should be 0
|
27
|
+
And the stdout should match "2 examples, 0 failures"
|
@@ -6,7 +6,9 @@ Given /^the file (.*)$/ do |relative_path|
|
|
6
6
|
end
|
7
7
|
|
8
8
|
Given /^the following spec:$/ do |spec|
|
9
|
-
|
9
|
+
dir = File.join(File.dirname(__FILE__), "/../../tmp")
|
10
|
+
FileUtils.mkdir(dir) unless test ?d, dir
|
11
|
+
@path = "#{dir}/current_example.rb"
|
10
12
|
File.open(@path, "w") do |f|
|
11
13
|
f.write spec
|
12
14
|
end
|
@@ -19,8 +21,8 @@ When /^I run it with the (.*)$/ do |interpreter|
|
|
19
21
|
when /^ruby interpreter/
|
20
22
|
args = interpreter.gsub('ruby interpreter','')
|
21
23
|
ruby("#{@path}#{args}", stderr_file.path)
|
22
|
-
when /^spec
|
23
|
-
args = interpreter.gsub('spec
|
24
|
+
when /^spec command/
|
25
|
+
args = interpreter.gsub('spec command','')
|
24
26
|
spec("#{@path}#{args}", stderr_file.path)
|
25
27
|
when 'CommandLine object' then cmdline(@path, stderr_file.path)
|
26
28
|
else raise "Unknown interpreter: #{interpreter}"
|
data/features/support/env.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: conditional exclusion of example groups
|
2
|
+
|
3
|
+
Example groups can be excluded from a run by matching the value of the
|
4
|
+
--exclude argument against options passed to an example group. The value
|
5
|
+
can be a key or a key:value pair (separated by a ":").
|
6
|
+
|
7
|
+
Scenario: exclusion using explicit value
|
8
|
+
Given the following spec:
|
9
|
+
"""
|
10
|
+
describe "This should run" do
|
11
|
+
it { 5.should == 5 }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "This should not run", :slow => true do
|
15
|
+
it { 1_000_000.times { 5.should == 5 } }
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I run it with the spec command --format specdoc --exclude slow:true
|
19
|
+
Then the exit code should be 0
|
20
|
+
And the stdout should match "1 example, 0 failures"
|
21
|
+
And the stdout should match /This should run$/m
|
22
|
+
But the stdout should not match "This should not run"
|
23
|
+
|
24
|
+
Scenario: exclusion using default value (true)
|
25
|
+
Given the following spec:
|
26
|
+
"""
|
27
|
+
describe "This should run" do
|
28
|
+
it { 5.should == 5 }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "This should not run", :slow => true do
|
32
|
+
it { 1_000_000.times { 5.should == 5 } }
|
33
|
+
end
|
34
|
+
"""
|
35
|
+
When I run it with the spec command --format specdoc --exclude slow
|
36
|
+
Then the exit code should be 0
|
37
|
+
And the stdout should match "1 example, 0 failures"
|
38
|
+
And the stdout should match /This should run$/m
|
39
|
+
But the stdout should not match "This should not run"
|
data/lib/spec/autorun.rb
ADDED
@@ -37,21 +37,14 @@ module Spec
|
|
37
37
|
after_parts(*args) << block
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
after_each_parts.delete(block)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Deprecated. Use before(:each)
|
46
|
-
def setup(&block)
|
47
|
-
before(:each, &block)
|
40
|
+
def before_each_parts # :nodoc:
|
41
|
+
@before_each_parts ||= []
|
48
42
|
end
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
after(:each, &block)
|
44
|
+
def after_each_parts # :nodoc:
|
45
|
+
@after_each_parts ||= []
|
53
46
|
end
|
54
|
-
|
47
|
+
|
55
48
|
def before_all_parts # :nodoc:
|
56
49
|
@before_all_parts ||= []
|
57
50
|
end
|
@@ -60,14 +53,6 @@ module Spec
|
|
60
53
|
@after_all_parts ||= []
|
61
54
|
end
|
62
55
|
|
63
|
-
def before_each_parts # :nodoc:
|
64
|
-
@before_each_parts ||= []
|
65
|
-
end
|
66
|
-
|
67
|
-
def after_each_parts # :nodoc:
|
68
|
-
@after_each_parts ||= []
|
69
|
-
end
|
70
|
-
|
71
56
|
def before_suite_parts
|
72
57
|
BeforeAndAfterHooks.before_suite_parts
|
73
58
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Spec
|
2
|
+
module Example
|
3
|
+
class ExampleDescription
|
4
|
+
attr_reader :description, :options, :backtrace
|
5
|
+
|
6
|
+
def initialize(description, options={}, backtrace=nil)
|
7
|
+
@description, @options, @backtrace = description, options, backtrace
|
8
|
+
end
|
9
|
+
|
10
|
+
def ==(other)
|
11
|
+
(other.description == description) & (other.backtrace == backtrace)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -5,22 +5,7 @@ module Spec
|
|
5
5
|
class ExampleGroup
|
6
6
|
extend Spec::Example::ExampleGroupMethods
|
7
7
|
include Spec::Example::ExampleMethods
|
8
|
-
|
9
|
-
def initialize(defined_description, options={}, &implementation)
|
10
|
-
@_options = options
|
11
|
-
@_defined_description = defined_description
|
12
|
-
@_implementation = implementation || pending_implementation
|
13
|
-
@_backtrace = caller
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def pending_implementation
|
19
|
-
error = NotYetImplementedError.new(caller)
|
20
|
-
lambda { raise(error) }
|
21
|
-
end
|
22
8
|
end
|
23
9
|
end
|
24
10
|
end
|
25
11
|
|
26
|
-
Spec::ExampleGroup = Spec::Example::ExampleGroup
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Spec
|
2
2
|
module Example
|
3
|
+
|
3
4
|
class ExampleGroupFactory
|
4
5
|
module ClassMethods
|
5
6
|
def reset
|
@@ -7,13 +8,27 @@ module Spec
|
|
7
8
|
default(ExampleGroup)
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def example_group_creation_listeners
|
12
|
+
@example_group_creation_listeners ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
def register_example_group(klass)
|
16
|
+
example_group_creation_listeners.each do |listener|
|
17
|
+
listener.register_example_group(klass)
|
15
18
|
end
|
16
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_shared_example_group(*args, &example_group_block) # :nodoc:
|
22
|
+
::Spec::Example::add_spec_path_to(args)
|
23
|
+
::Spec::Example::SharedExampleGroup.register(*args, &example_group_block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_example_group(*args, &block)
|
27
|
+
raise ArgumentError if args.empty?
|
28
|
+
raise ArgumentError unless block
|
29
|
+
Spec::Example::add_spec_path_to(args)
|
30
|
+
superclass = determine_superclass(args.last)
|
31
|
+
superclass.describe(*args, &block)
|
17
32
|
end
|
18
33
|
|
19
34
|
# Registers an example group class +klass+ with the symbol +type+. For
|
@@ -31,44 +46,22 @@ module Spec
|
|
31
46
|
# implicitly use an instance of FarmExampleGroup for any file loaded
|
32
47
|
# from the <tt>./spec/farm</tt> directory.
|
33
48
|
def register(key, example_group_class)
|
34
|
-
@example_group_types[key] = example_group_class
|
49
|
+
@example_group_types[key.to_sym] = example_group_class
|
35
50
|
end
|
36
|
-
|
51
|
+
|
37
52
|
# Sets the default ExampleGroup class
|
38
53
|
def default(example_group_class)
|
54
|
+
Spec.__send__ :remove_const, :ExampleGroup if Spec.const_defined?(:ExampleGroup)
|
55
|
+
Spec.const_set(:ExampleGroup, example_group_class)
|
39
56
|
old = @example_group_types
|
40
57
|
@example_group_types = Hash.new(example_group_class)
|
41
58
|
@example_group_types.merge!(old) if old
|
42
59
|
end
|
43
60
|
|
44
|
-
def
|
45
|
-
|
46
|
-
key
|
47
|
-
else
|
48
|
-
@example_group_types[key]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def create_example_group(*args, &block)
|
53
|
-
raise ArgumentError if args.empty?
|
54
|
-
raise ArgumentError unless block
|
55
|
-
Spec::Example::add_spec_path_to(args)
|
56
|
-
superclass = determine_superclass(args.last)
|
57
|
-
superclass.describe(*args, &block)
|
58
|
-
end
|
59
|
-
|
60
|
-
def create_shared_example_group(*args, &block)
|
61
|
-
Spec::Example::add_spec_path_to(args)
|
62
|
-
SharedExampleGroup.register(*args, &block)
|
61
|
+
def [](key)
|
62
|
+
@example_group_types[key]
|
63
63
|
end
|
64
|
-
|
65
|
-
def include_constants_in(context, &block)
|
66
|
-
if (Spec::Ruby.version.to_f >= 1.9 && Module === context && !(Class === context))
|
67
|
-
return lambda {include context;instance_eval(&block)}
|
68
|
-
end
|
69
|
-
block
|
70
|
-
end
|
71
|
-
|
64
|
+
|
72
65
|
def assign_scope(scope, args)
|
73
66
|
args.last[:scope] = scope
|
74
67
|
end
|
@@ -76,18 +69,13 @@ module Spec
|
|
76
69
|
protected
|
77
70
|
|
78
71
|
def determine_superclass(opts)
|
79
|
-
|
80
|
-
|
81
|
-
elsif opts[:spec_path] =~ /spec(\\|\/)(#{@example_group_types.keys.join('|')})/
|
82
|
-
$2 == '' ? nil : $2.to_sym
|
72
|
+
if type = opts[:type]
|
73
|
+
self[type]
|
74
|
+
elsif opts[:spec_path] =~ /spec(\\|\/)(#{@example_group_types.keys.sort_by{|k| k.to_s.length}.reverse.join('|')})/
|
75
|
+
self[$2 == '' ? nil : $2.to_sym]
|
76
|
+
else
|
77
|
+
self[nil]
|
83
78
|
end
|
84
|
-
get(key)
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def registered_types
|
90
|
-
@example_group_types.values
|
91
79
|
end
|
92
80
|
|
93
81
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Spec
|
2
|
+
module Example
|
3
|
+
class ExampleGroupHierarchy < Array
|
4
|
+
def initialize(example_group_class)
|
5
|
+
push example_group_class
|
6
|
+
if example_group_class.respond_to?(:superclass) && example_group_class.superclass.respond_to?(:example_group_hierarchy)
|
7
|
+
unshift example_group_class.superclass.example_group_hierarchy
|
8
|
+
flatten!
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def run_before_all(example)
|
13
|
+
example.eval_each_fail_fast(before_all_parts)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_before_each(example)
|
17
|
+
example.eval_each_fail_fast(before_each_parts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_after_each(example)
|
21
|
+
example.eval_each_fail_slow(after_each_parts)
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_after_all(example)
|
25
|
+
example.eval_each_fail_slow(after_all_parts)
|
26
|
+
end
|
27
|
+
|
28
|
+
def before_all_parts
|
29
|
+
@before_all_parts ||= collect {|klass| klass.before_all_parts}.flatten
|
30
|
+
end
|
31
|
+
|
32
|
+
def before_each_parts
|
33
|
+
@before_each_parts ||= collect {|klass| klass.before_each_parts}.flatten
|
34
|
+
end
|
35
|
+
|
36
|
+
def after_each_parts
|
37
|
+
@after_each_parts ||= reverse.collect {|klass| klass.after_each_parts}.flatten
|
38
|
+
end
|
39
|
+
|
40
|
+
def after_all_parts
|
41
|
+
@after_all_parts ||= reverse.collect {|klass| klass.after_all_parts}.flatten
|
42
|
+
end
|
43
|
+
|
44
|
+
def nested_descriptions
|
45
|
+
@nested_descriptions ||= collect {|eg| nested_description_from(eg) == "" ? nil : nested_description_from(eg) }.compact
|
46
|
+
end
|
47
|
+
|
48
|
+
def nested_description_from(example_group)
|
49
|
+
example_group.description_args.join
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|