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.
Files changed (147) hide show
  1. data/History.txt +35 -0
  2. data/License.txt +1 -1
  3. data/Manifest.txt +22 -73
  4. data/README.txt +2 -2
  5. data/Rakefile +32 -7
  6. data/TODO.txt +9 -4
  7. data/bin/spec +1 -1
  8. data/cucumber.yml +2 -0
  9. data/examples/failing/spec_helper.rb +1 -1
  10. data/examples/passing/filtered_formatter.rb +18 -0
  11. data/examples/passing/filtered_formatter_example.rb +31 -0
  12. data/examples/passing/spec_helper.rb +1 -1
  13. data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +17 -18
  14. data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
  15. data/features/example_groups/autogenerated_docstrings.feature +2 -2
  16. data/features/example_groups/example_group_with_should_methods.feature +1 -1
  17. data/features/example_groups/nested_groups.feature +1 -1
  18. data/features/interop/examples_and_tests_together.feature +1 -1
  19. data/features/interop/test_but_not_test_unit.feature +1 -1
  20. data/features/interop/test_case_with_should_methods.feature +1 -1
  21. data/features/mock_framework_integration/use_flexmock.feature +22 -4
  22. data/features/mock_framework_integration/use_mocha.feature +27 -0
  23. data/features/mock_framework_integration/use_rr.feature +27 -0
  24. data/features/step_definitions/running_rspec.rb +5 -3
  25. data/features/support/env.rb +1 -1
  26. data/features-pending/cli/conditional_exclusion.feature +39 -0
  27. data/lib/{adapters → spec/adapters}/mock_frameworks/flexmock.rb +1 -0
  28. data/lib/{adapters → spec/adapters}/mock_frameworks/mocha.rb +1 -0
  29. data/lib/{adapters → spec/adapters}/mock_frameworks/rr.rb +1 -0
  30. data/lib/{adapters → spec/adapters}/mock_frameworks/rspec.rb +0 -1
  31. data/lib/spec/autorun.rb +3 -0
  32. data/lib/spec/example/before_and_after_hooks.rb +5 -20
  33. data/lib/spec/example/example_description.rb +15 -0
  34. data/lib/spec/example/example_group.rb +0 -15
  35. data/lib/spec/example/example_group_factory.rb +34 -46
  36. data/lib/spec/example/example_group_hierarchy.rb +53 -0
  37. data/lib/spec/example/example_group_methods.rb +96 -211
  38. data/lib/spec/example/example_methods.rb +62 -81
  39. data/lib/spec/example/module_reopening_fix.rb +23 -1
  40. data/lib/spec/example/predicate_matchers.rb +47 -0
  41. data/lib/spec/example/subject.rb +91 -0
  42. data/lib/spec/example.rb +4 -0
  43. data/lib/spec/expectations/extensions.rb +0 -1
  44. data/lib/spec/expectations/handler.rb +6 -1
  45. data/lib/spec/expectations.rb +1 -1
  46. data/lib/spec/interop/test/unit/testcase.rb +5 -22
  47. data/lib/spec/interop/test.rb +1 -0
  48. data/lib/spec/matchers/be.rb +2 -7
  49. data/lib/spec/matchers/be_close.rb +20 -5
  50. data/lib/spec/matchers/change.rb +5 -3
  51. data/lib/spec/matchers/eql.rb +24 -6
  52. data/lib/spec/matchers/equal.rb +24 -6
  53. data/lib/spec/matchers/exist.rb +21 -5
  54. data/lib/spec/matchers/generated_descriptions.rb +2 -2
  55. data/lib/spec/matchers/has.rb +28 -11
  56. data/lib/spec/matchers/match.rb +25 -7
  57. data/lib/spec/matchers/match_array.rb +1 -1
  58. data/lib/spec/matchers/method_missing.rb +2 -2
  59. data/lib/spec/matchers/operator_matcher.rb +12 -5
  60. data/lib/spec/matchers/raise_error.rb +1 -1
  61. data/lib/spec/matchers/respond_to.rb +1 -1
  62. data/lib/spec/matchers/satisfy.rb +5 -5
  63. data/lib/spec/matchers/throw_symbol.rb +1 -3
  64. data/lib/spec/mocks/argument_expectation.rb +1 -1
  65. data/lib/spec/mocks/argument_matchers.rb +233 -0
  66. data/lib/spec/mocks/error_generator.rb +2 -6
  67. data/lib/spec/mocks/message_expectation.rb +3 -11
  68. data/lib/spec/mocks/mock.rb +1 -1
  69. data/lib/spec/mocks/proxy.rb +5 -1
  70. data/lib/spec/runner/configuration.rb +3 -3
  71. data/lib/spec/runner/drb_command_line.rb +2 -1
  72. data/lib/spec/runner/example_group_runner.rb +2 -1
  73. data/lib/spec/runner/formatter/base_text_formatter.rb +28 -17
  74. data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +3 -5
  75. data/lib/spec/runner/formatter/html_formatter.rb +2 -3
  76. data/lib/spec/runner/formatter/nested_text_formatter.rb +7 -25
  77. data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
  78. data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -7
  79. data/lib/spec/runner/heckle_runner_unsupported.rb +1 -1
  80. data/lib/spec/runner/option_parser.rb +16 -19
  81. data/lib/spec/runner/options.rb +28 -26
  82. data/lib/spec/runner/reporter.rb +8 -9
  83. data/lib/spec/runner.rb +6 -28
  84. data/lib/spec/test/unit.rb +10 -0
  85. data/lib/spec/version.rb +2 -2
  86. data/{features/support → resources}/helpers/cmdline.rb +2 -2
  87. data/resources/rake/verify_rcov.rake +1 -1
  88. data/resources/spec/example_group_with_should_methods.rb +1 -1
  89. data/resources/spec/simple_spec.rb +1 -1
  90. data/resources/test/spec_and_test_together.rb +2 -3
  91. data/resources/test/spec_including_test_but_not_unit.rb +1 -1
  92. data/resources/test/test_case_with_should_methods.rb +2 -3
  93. data/rspec.gemspec +5 -5
  94. data/spec/spec/dsl/main_spec.rb +3 -3
  95. data/spec/spec/example/example_group_class_definition_spec.rb +11 -14
  96. data/spec/spec/example/example_group_factory_spec.rb +31 -44
  97. data/spec/spec/example/example_group_methods_spec.rb +86 -52
  98. data/spec/spec/example/example_group_spec.rb +16 -75
  99. data/spec/spec/example/example_matcher_spec.rb +10 -10
  100. data/spec/spec/example/example_methods_spec.rb +101 -241
  101. data/spec/spec/example/nested_example_group_spec.rb +2 -2
  102. data/spec/spec/example/pending_module_spec.rb +1 -1
  103. data/spec/spec/example/shared_example_group_spec.rb +2 -2
  104. data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +2 -2
  105. data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +2 -2
  106. data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +2 -2
  107. data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +2 -2
  108. data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +2 -2
  109. data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +2 -2
  110. data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +2 -2
  111. data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +2 -2
  112. data/spec/spec/matchers/change_spec.rb +8 -0
  113. data/spec/spec/matchers/exist_spec.rb +8 -4
  114. data/spec/spec/matchers/handler_spec.rb +8 -1
  115. data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
  116. data/spec/spec/mocks/{bug_report_496.rb → bug_report_496_spec.rb} +0 -0
  117. data/spec/spec/mocks/failing_argument_matchers_spec.rb +95 -0
  118. data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
  119. data/spec/spec/mocks/passing_argument_matchers_spec.rb +145 -0
  120. data/spec/spec/runner/configuration_spec.rb +12 -12
  121. data/spec/spec/runner/formatter/base_text_formatter_spec.rb +72 -1
  122. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +8 -8
  123. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +4 -4
  124. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +8 -8
  125. data/spec/spec/runner/formatter/html_formatted-1.8.7.html +38 -26
  126. data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -53
  127. data/spec/spec/runner/formatter/html_formatter_spec.rb +100 -48
  128. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -34
  129. data/spec/spec/runner/formatter/profile_formatter_spec.rb +1 -1
  130. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +8 -6
  131. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
  132. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +20 -20
  133. data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +38 -26
  134. data/spec/spec/runner/formatter/{spec_mate_formatter_spec.rb → text_mate_formatter_spec.rb} +10 -8
  135. data/spec/spec/runner/heckle_runner_spec.rb +1 -1
  136. data/spec/spec/runner/option_parser_spec.rb +15 -13
  137. data/spec/spec/runner/options_spec.rb +34 -0
  138. data/spec/spec/runner/reporter_spec.rb +65 -61
  139. data/spec/spec/runner/spec_drb.opts +1 -0
  140. data/spec/spec/runner_spec.rb +7 -5
  141. data/spec/spec_helper.rb +23 -0
  142. metadata +25 -76
  143. data/examples/passing/legacy_spec.rb +0 -11
  144. data/features/support/helpers/story_helper.rb +0 -13
  145. data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
  146. data/resources/spec/spec_with_flexmock.rb +0 -19
  147. data/spec/spec/spec_spec.rb +0 -21
@@ -1,9 +1,27 @@
1
- Story: Getting correct output with flexmock
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 file ../../resources/spec/spec_with_flexmock.rb
8
- When I run it with the ruby interpreter
9
- Then the exit code should be 0
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
- @path = "/tmp/example_spec.rb"
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 script/
23
- args = interpreter.gsub('spec script','')
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}"
@@ -16,7 +16,7 @@ module RspecWorld
16
16
  end
17
17
 
18
18
  def cmdline(args, stderr)
19
- ruby("#{File.dirname(__FILE__) + '/helpers/cmdline.rb'} #{args}", stderr)
19
+ ruby("#{File.dirname(__FILE__) + '/../../resources/helpers/cmdline.rb'} #{args}", stderr)
20
20
  end
21
21
  end
22
22
 
@@ -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"
@@ -3,6 +3,7 @@
3
3
  # Created by Jim Weirich on 2007-04-10.
4
4
  # Copyright (c) 2007. All rights reserved.
5
5
 
6
+ require 'rubygems'
6
7
  require 'flexmock/rspec'
7
8
 
8
9
  module Spec
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'mocha/standalone'
2
3
  require 'mocha/object'
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'rr'
2
3
 
3
4
  patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS
@@ -1,4 +1,3 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec", "mocks"))
2
1
  require 'spec/mocks/framework'
3
2
  require 'spec/mocks/extensions'
4
3
 
@@ -0,0 +1,3 @@
1
+ require 'spec'
2
+
3
+ Spec::Runner.autorun
@@ -37,21 +37,14 @@ module Spec
37
37
  after_parts(*args) << block
38
38
  end
39
39
 
40
- # TODO - deprecate this unless there is a reason why it exists
41
- def remove_after(scope, &block) # :nodoc:
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
- # Deprecated. Use after(:each)
51
- def teardown(&block)
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 registered_or_ancestor_of_registered?(example_group_classes) # :nodoc:
11
- example_group_classes.each do |example_group_class|
12
- return false unless registered_types.any? do |registered_type|
13
- registered_type.ancestors.include? example_group_class
14
- end
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
- return true
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 get(key=nil)
45
- if @example_group_types.values.include?(key)
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
- key = if opts[:type]
80
- opts[:type]
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