rspec-core 2.0.0.beta.9 → 2.0.0.beta.10
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/VERSION +1 -1
- data/features/configuration/custom_settings.feature +86 -0
- data/features/formatters/custom_formatter.feature +1 -1
- data/lib/rspec/core.rb +6 -1
- data/lib/rspec/core/backward_compatibility.rb +3 -5
- data/lib/rspec/core/command_line.rb +52 -0
- data/lib/rspec/core/configuration.rb +106 -118
- data/lib/rspec/core/configuration_options.rb +30 -88
- data/lib/rspec/core/deprecation.rb +3 -4
- data/lib/rspec/core/drb_command_line.rb +29 -0
- data/lib/rspec/core/formatters/base_formatter.rb +3 -8
- data/lib/rspec/core/formatters/base_text_formatter.rb +2 -2
- data/lib/rspec/core/formatters/documentation_formatter.rb +2 -2
- data/lib/rspec/core/kernel_extensions.rb +1 -1
- data/lib/rspec/core/metadata.rb +11 -11
- data/lib/rspec/core/option_parser.rb +84 -0
- data/lib/rspec/core/runner.rb +17 -42
- data/lib/rspec/core/world.rb +2 -2
- data/lib/rspec/monkey.rb +1 -0
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +7 -0
- data/rspec-core.gemspec +18 -59
- data/spec/rspec/core/configuration_options_spec.rb +91 -7
- data/spec/rspec/core/configuration_spec.rb +52 -18
- data/spec/rspec/core/deprecations_spec.rb +4 -2
- data/spec/rspec/core/drb_command_line_spec.rb +151 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -1
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +1 -2
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +1 -2
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -2
- data/spec/rspec/core/resources/a_spec.rb +1 -1
- data/spec/rspec/core/runner_spec.rb +38 -27
- data/spec/rspec/core/shared_example_group_spec.rb +1 -1
- data/spec/spec_helper.rb +56 -41
- metadata +17 -58
- data/example_specs/failing/README.txt +0 -7
- data/example_specs/failing/diffing_spec.rb +0 -38
- data/example_specs/failing/failing_implicit_docstrings_example.rb +0 -19
- data/example_specs/failing/failure_in_after.rb +0 -10
- data/example_specs/failing/failure_in_before.rb +0 -10
- data/example_specs/failing/mocking_example.rb +0 -40
- data/example_specs/failing/mocking_with_flexmock.rb +0 -26
- data/example_specs/failing/mocking_with_mocha.rb +0 -25
- data/example_specs/failing/mocking_with_rr.rb +0 -27
- data/example_specs/failing/partial_mock_example.rb +0 -20
- data/example_specs/failing/pending_example.rb +0 -9
- data/example_specs/failing/predicate_example.rb +0 -34
- data/example_specs/failing/raising_example.rb +0 -47
- data/example_specs/failing/spec_helper.rb +0 -1
- data/example_specs/failing/syntax_error_example.rb +0 -7
- data/example_specs/failing/team_spec.rb +0 -43
- data/example_specs/failing/timeout_behaviour.rb +0 -7
- data/example_specs/passing/custom_formatter.rb +0 -12
- data/example_specs/passing/custom_matchers.rb +0 -54
- data/example_specs/passing/dynamic_spec.rb +0 -9
- data/example_specs/passing/file_accessor.rb +0 -19
- data/example_specs/passing/file_accessor_spec.rb +0 -38
- data/example_specs/passing/filtered_formatter.rb +0 -18
- data/example_specs/passing/filtered_formatter_example.rb +0 -31
- data/example_specs/passing/greeter_spec.rb +0 -31
- data/example_specs/passing/helper_method_example.rb +0 -14
- data/example_specs/passing/implicit_docstrings_example.rb +0 -18
- data/example_specs/passing/io_processor.rb +0 -8
- data/example_specs/passing/io_processor_spec.rb +0 -21
- data/example_specs/passing/mocking_example.rb +0 -27
- data/example_specs/passing/multi_threaded_example_group_runner.rb +0 -26
- data/example_specs/passing/nested_classes_example.rb +0 -36
- data/example_specs/passing/options_example.rb +0 -31
- data/example_specs/passing/options_formatter.rb +0 -20
- data/example_specs/passing/partial_mock_example.rb +0 -29
- data/example_specs/passing/pending_example.rb +0 -20
- data/example_specs/passing/predicate_example.rb +0 -27
- data/example_specs/passing/shared_example_group_example.rb +0 -81
- data/example_specs/passing/shared_stack_examples.rb +0 -36
- data/example_specs/passing/spec_helper.rb +0 -1
- data/example_specs/passing/stack.rb +0 -36
- data/example_specs/passing/stack_spec.rb +0 -64
- data/example_specs/passing/stack_spec_with_nested_example_groups.rb +0 -67
- data/example_specs/passing/stubbing_example.rb +0 -69
- data/example_specs/passing/subject_example.rb +0 -45
- data/example_specs/passing/yielding_example.rb +0 -33
- data/example_specs/ruby1.9.compatibility/access_to_constants_spec.rb +0 -85
- data/example_specs/spec_helper.rb +0 -10
- data/features/configuration/custom_options.feature +0 -71
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.10
|
@@ -0,0 +1,86 @@
|
|
1
|
+
Feature: custom settings
|
2
|
+
|
3
|
+
In order to seamlessly provide users more configuration settings
|
4
|
+
As an RSpec extenstion-library author
|
5
|
+
I want to define new settings on the RSpec.configuration object
|
6
|
+
|
7
|
+
Scenario: simple setting
|
8
|
+
Given a file named "additional_setting_spec.rb" with:
|
9
|
+
"""
|
10
|
+
RSpec.configure do |c|
|
11
|
+
c.add_setting :custom_setting
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "custom setting" do
|
15
|
+
it "is nil by default" do
|
16
|
+
RSpec.configuration.custom_setting.should be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "acts false by default" do
|
20
|
+
RSpec.configuration.custom_setting.should be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is exposed as a predicate" do
|
24
|
+
RSpec.configuration.custom_setting?.should be_false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can be overridden" do
|
28
|
+
RSpec.configuration.custom_setting = true
|
29
|
+
RSpec.configuration.custom_setting.should be_true
|
30
|
+
RSpec.configuration.custom_setting?.should be_true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
"""
|
34
|
+
When I run "rspec ./additional_setting_spec.rb"
|
35
|
+
Then I should see "0 failures"
|
36
|
+
|
37
|
+
Scenario: default to true
|
38
|
+
Given a file named "additional_setting_spec.rb" with:
|
39
|
+
"""
|
40
|
+
RSpec.configure do |c|
|
41
|
+
c.add_setting :custom_setting, :default => true
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "custom setting" do
|
45
|
+
it "is true by default" do
|
46
|
+
RSpec.configuration.custom_setting.should be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "is exposed as a predicate" do
|
50
|
+
RSpec.configuration.custom_setting?.should be_true
|
51
|
+
end
|
52
|
+
|
53
|
+
it "can be overridden" do
|
54
|
+
RSpec.configuration.custom_setting = false
|
55
|
+
RSpec.configuration.custom_setting.should be_false
|
56
|
+
RSpec.configuration.custom_setting?.should be_false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
"""
|
60
|
+
When I run "rspec ./additional_setting_spec.rb"
|
61
|
+
Then I should see "0 failures"
|
62
|
+
|
63
|
+
Scenario: overridden in a subsequent RSpec.configure block
|
64
|
+
Given a file named "additional_setting_spec.rb" with:
|
65
|
+
"""
|
66
|
+
RSpec.configure do |c|
|
67
|
+
c.add_setting :custom_setting
|
68
|
+
end
|
69
|
+
|
70
|
+
RSpec.configure do |c|
|
71
|
+
c.custom_setting = true
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "custom setting" do
|
75
|
+
it "returns the value set in the last cofigure block to get eval'd" do
|
76
|
+
RSpec.configuration.custom_setting.should be_true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "is exposed as a predicate" do
|
80
|
+
RSpec.configuration.custom_setting?.should be_true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
"""
|
84
|
+
When I run "rspec ./additional_setting_spec.rb"
|
85
|
+
Then I should see "0 failures"
|
86
|
+
|
@@ -10,7 +10,7 @@ Feature: custom formatters
|
|
10
10
|
"""
|
11
11
|
require "rspec/runner/formatter/base_formatter"
|
12
12
|
|
13
|
-
class CustomFormatter <
|
13
|
+
class CustomFormatter < RSpec::Runner::Formatter::BaseFormatter
|
14
14
|
def initialize(options, output)
|
15
15
|
@output = output
|
16
16
|
end
|
data/lib/rspec/core.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rspec/core/kernel_extensions'
|
|
2
2
|
require 'rspec/core/object_extensions'
|
3
3
|
require 'rspec/core/load_path'
|
4
4
|
require 'rspec/core/deprecation'
|
5
|
+
require 'rspec/core/formatters'
|
5
6
|
|
6
7
|
require 'rspec/core/hooks'
|
7
8
|
require 'rspec/core/subject'
|
@@ -12,12 +13,14 @@ require 'rspec/core/pending'
|
|
12
13
|
require 'rspec/core/around_proxy'
|
13
14
|
require 'rspec/core/world'
|
14
15
|
require 'rspec/core/configuration'
|
16
|
+
require 'rspec/core/option_parser'
|
15
17
|
require 'rspec/core/configuration_options'
|
18
|
+
require 'rspec/core/command_line'
|
19
|
+
require 'rspec/core/drb_command_line'
|
16
20
|
require 'rspec/core/runner'
|
17
21
|
require 'rspec/core/example'
|
18
22
|
require 'rspec/core/shared_example_group'
|
19
23
|
require 'rspec/core/example_group'
|
20
|
-
require 'rspec/core/formatters'
|
21
24
|
require 'rspec/core/version'
|
22
25
|
require 'rspec/core/errors'
|
23
26
|
|
@@ -62,3 +65,5 @@ require 'rspec/core/backward_compatibility'
|
|
62
65
|
|
63
66
|
# TODO - make this configurable with default 'on'
|
64
67
|
require 'rspec/expectations'
|
68
|
+
|
69
|
+
require 'rspec/monkey'
|
@@ -9,15 +9,13 @@ module RSpec
|
|
9
9
|
module ConstMissing
|
10
10
|
def const_missing(name)
|
11
11
|
case name
|
12
|
-
when :Rspec
|
13
|
-
RSpec
|
14
|
-
when :Spec
|
15
|
-
RSpec.warn <<-WARNING
|
12
|
+
when :Rspec, :Spec
|
13
|
+
RSpec.warn_deprecation <<-WARNING
|
16
14
|
*****************************************************************
|
17
15
|
DEPRECATION WARNING: you are using a deprecated constant that will
|
18
16
|
be removed from a future version of RSpec.
|
19
17
|
|
20
|
-
*
|
18
|
+
* #{name} is deprecated.
|
21
19
|
* RSpec is the new top-level module in RSpec-2
|
22
20
|
|
23
21
|
#{caller(0)[1]}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Core
|
3
|
+
class CommandLine
|
4
|
+
def initialize(argv)
|
5
|
+
@options = RSpec::Core::ConfigurationOptions.new(argv)
|
6
|
+
@options.configure(configuration)
|
7
|
+
configuration.require_files_to_run
|
8
|
+
configuration.configure_mock_framework
|
9
|
+
end
|
10
|
+
|
11
|
+
def run(err, out)
|
12
|
+
configuration.error_stream = err
|
13
|
+
configuration.output_stream = out
|
14
|
+
world.announce_inclusion_filter
|
15
|
+
|
16
|
+
configuration.reporter.report(example_count) do |reporter|
|
17
|
+
example_groups.run_examples(reporter)
|
18
|
+
end
|
19
|
+
|
20
|
+
example_groups.success?
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def example_count
|
26
|
+
world.example_count
|
27
|
+
end
|
28
|
+
|
29
|
+
module ExampleGroups
|
30
|
+
def run_examples(reporter)
|
31
|
+
@success = self.inject(true) {|success, group| success &= group.run(reporter)}
|
32
|
+
end
|
33
|
+
|
34
|
+
def success?
|
35
|
+
@success ||= false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def example_groups
|
40
|
+
world.example_groups.extend(ExampleGroups)
|
41
|
+
end
|
42
|
+
|
43
|
+
def configuration
|
44
|
+
RSpec.configuration
|
45
|
+
end
|
46
|
+
|
47
|
+
def world
|
48
|
+
RSpec.world
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,66 +1,109 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Core
|
3
3
|
class Configuration
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
attr_reader :options
|
4
|
+
def self.add_setting(name, opts={})
|
5
|
+
if opts[:alias]
|
6
|
+
alias_method name, opts[:alias]
|
7
|
+
alias_method "#{name}=", "#{opts[:alias]}="
|
8
|
+
alias_method "#{name}?", "#{opts[:alias]}?"
|
9
|
+
else
|
10
|
+
define_method("#{name}=") {|val| settings[name] = val}
|
11
|
+
define_method(name) { settings.has_key?(name) ? settings[name] : opts[:default] }
|
12
|
+
define_method("#{name}?") { !!(send name) }
|
13
|
+
end
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
add_setting :error_stream
|
17
|
+
add_setting :output_stream
|
18
|
+
add_setting :output, :alias => :output_stream
|
19
|
+
add_setting :drb_port
|
20
|
+
add_setting :color_enabled
|
21
|
+
add_setting :profile_examples
|
22
|
+
add_setting :run_all_when_everything_filtered
|
23
|
+
add_setting :mock_framework, :default => :rspec
|
24
|
+
add_setting :filter
|
25
|
+
add_setting :exclusion_filter
|
26
|
+
add_setting :filename_pattern, :default => '**/*_spec.rb'
|
27
|
+
add_setting :files_to_run, :default => []
|
28
|
+
add_setting :include_or_extend_modules, :default => []
|
29
|
+
add_setting :formatter_class, :default => RSpec::Core::Formatters::ProgressFormatter
|
30
|
+
add_setting :backtrace_clean_patterns, :default => [
|
31
|
+
/\/lib\/ruby\//,
|
32
|
+
/bin\/rcov:/,
|
33
|
+
/vendor\/rails/,
|
34
|
+
/bin\/rspec/,
|
35
|
+
/bin\/spec/,
|
36
|
+
/lib\/rspec\/(core|expectations|matchers|mocks)/
|
37
|
+
]
|
38
|
+
|
39
|
+
# :call-seq:
|
40
|
+
# add_setting(:name)
|
41
|
+
# add_setting(:name, :default => "default_value")
|
42
|
+
# add_setting(:name, :alias => :other_setting)
|
43
|
+
#
|
44
|
+
# Use this to add custom settings to the RSpec.configuration object.
|
45
|
+
#
|
46
|
+
# RSpec.configuration.add_setting :foo
|
47
|
+
#
|
48
|
+
# Creates three methods on the configuration object, a setter, a getter,
|
49
|
+
# and a predicate:
|
50
|
+
#
|
51
|
+
# RSpec.configuration.foo=(value)
|
52
|
+
# RSpec.configuration.foo()
|
53
|
+
# RSpec.configuration.foo?() # returns !!foo
|
54
|
+
#
|
55
|
+
# Intended for extension frameworks like rspec-rails, so they can add config
|
56
|
+
# settings that are domain specific. For example:
|
57
|
+
#
|
58
|
+
# RSpec.configure do |c|
|
59
|
+
# c.add_setting :use_transactional_fixtures, :default => true
|
60
|
+
# c.add_setting :use_transactional_examples, :alias => :use_transactional_fixtures
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# == Options
|
64
|
+
#
|
65
|
+
# +add_setting+ takes an optional hash that supports the following
|
66
|
+
# keys:
|
67
|
+
#
|
68
|
+
# :default => "default value"
|
69
|
+
#
|
70
|
+
# This sets the default value for the getter and the predicate (which
|
71
|
+
# will return +true+ as long as the value is not +false+ or +nil+).
|
72
|
+
#
|
73
|
+
# :alias => :other_setting
|
74
|
+
#
|
75
|
+
# Aliases its setter, getter, and predicate, to those for the
|
76
|
+
# +other_setting+.
|
77
|
+
def add_setting(name, opts={})
|
78
|
+
self.class.add_setting(name, opts)
|
79
|
+
end
|
80
|
+
|
81
|
+
def puts(message)
|
82
|
+
output_stream.puts(message)
|
83
|
+
end
|
84
|
+
|
85
|
+
def hooks
|
86
|
+
@hooks ||= {
|
20
87
|
:before => { :each => [], :all => [], :suite => [] },
|
21
88
|
:after => { :each => [], :all => [], :suite => [] }
|
22
89
|
}
|
23
|
-
@include_or_extend_modules = []
|
24
|
-
@filter, @exclusion_filter = nil, nil
|
25
|
-
@options = default_options
|
26
90
|
end
|
27
|
-
|
28
|
-
def
|
29
|
-
{
|
30
|
-
:color_enabled => false,
|
31
|
-
:mock_framework => nil,
|
32
|
-
:profile_examples => false,
|
33
|
-
:files_to_run => [],
|
34
|
-
:filename_pattern => '**/*_spec.rb',
|
35
|
-
:formatter_class => RSpec::Core::Formatters::ProgressFormatter,
|
36
|
-
:backtrace_clean_patterns => [/\/lib\/ruby\//,
|
37
|
-
/bin\/rcov:/,
|
38
|
-
/vendor\/rails/,
|
39
|
-
/bin\/rspec/,
|
40
|
-
/bin\/spec/,
|
41
|
-
/lib\/rspec\/(core|expectations|matchers|mocks)/]
|
42
|
-
}
|
91
|
+
|
92
|
+
def settings
|
93
|
+
@settings ||= {}
|
43
94
|
end
|
44
95
|
|
45
96
|
def clear_inclusion_filter
|
46
97
|
self.filter = nil
|
47
98
|
end
|
48
|
-
|
49
|
-
def cleaned_from_backtrace?(line)
|
50
|
-
@options[:backtrace_clean_patterns].any? { |regex| line =~ regex }
|
51
|
-
end
|
52
|
-
|
53
|
-
def backtrace_clean_patterns
|
54
|
-
@options[:backtrace_clean_patterns]
|
55
|
-
end
|
56
99
|
|
57
|
-
def
|
58
|
-
|
100
|
+
def cleaned_from_backtrace?(line)
|
101
|
+
backtrace_clean_patterns.any? { |regex| line =~ regex }
|
59
102
|
end
|
60
103
|
|
61
104
|
def require_mock_framework_adapter
|
62
|
-
require case
|
63
|
-
when
|
105
|
+
require case mock_framework.to_s
|
106
|
+
when /rspec/i
|
64
107
|
'rspec/core/mocking/with_rspec'
|
65
108
|
when /mocha/i
|
66
109
|
'rspec/core/mocking/with_mocha'
|
@@ -73,20 +116,8 @@ module RSpec
|
|
73
116
|
end
|
74
117
|
end
|
75
118
|
|
76
|
-
def filename_pattern
|
77
|
-
@options[:filename_pattern]
|
78
|
-
end
|
79
|
-
|
80
|
-
def filename_pattern=(new_pattern)
|
81
|
-
@options[:filename_pattern] = new_pattern
|
82
|
-
end
|
83
|
-
|
84
|
-
def color_enabled=(on_or_off)
|
85
|
-
@options[:color_enabled] = on_or_off
|
86
|
-
end
|
87
|
-
|
88
119
|
def full_backtrace=(bool)
|
89
|
-
|
120
|
+
backtrace_clean_patterns.clear
|
90
121
|
end
|
91
122
|
|
92
123
|
def libs=(libs)
|
@@ -111,10 +142,6 @@ EOM
|
|
111
142
|
end
|
112
143
|
end
|
113
144
|
|
114
|
-
def color_enabled?
|
115
|
-
@options[:color_enabled]
|
116
|
-
end
|
117
|
-
|
118
145
|
def line_number=(line_number)
|
119
146
|
filter_run :line_number => line_number.to_i
|
120
147
|
end
|
@@ -123,19 +150,6 @@ EOM
|
|
123
150
|
filter_run :full_description => /#{description}/
|
124
151
|
end
|
125
152
|
|
126
|
-
# Enable profiling of example run - defaults to false
|
127
|
-
def profile_examples
|
128
|
-
@options[:profile_examples]
|
129
|
-
end
|
130
|
-
|
131
|
-
def profile_examples=(on_or_off)
|
132
|
-
@options[:profile_examples] = on_or_off
|
133
|
-
end
|
134
|
-
|
135
|
-
def formatter_class
|
136
|
-
@options[:formatter_class]
|
137
|
-
end
|
138
|
-
|
139
153
|
def formatter=(formatter_to_use)
|
140
154
|
formatter_class = case formatter_to_use.to_s
|
141
155
|
when 'd', 'doc', 'documentation', 's', 'n', 'spec', 'nested'
|
@@ -145,19 +159,17 @@ EOM
|
|
145
159
|
else
|
146
160
|
raise ArgumentError, "Formatter '#{formatter_to_use}' unknown - maybe you meant 'documentation' or 'progress'?."
|
147
161
|
end
|
148
|
-
|
162
|
+
self.formatter_class = formatter_class
|
149
163
|
end
|
150
|
-
|
164
|
+
|
151
165
|
def formatter
|
152
|
-
@formatter ||= formatter_class.new
|
166
|
+
@formatter ||= formatter_class.new(output)
|
153
167
|
end
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
158
|
-
|
168
|
+
|
169
|
+
alias_method :reporter, :formatter
|
170
|
+
|
159
171
|
def files_or_directories_to_run=(*files)
|
160
|
-
|
172
|
+
self.files_to_run = files.flatten.inject([]) do |result, file|
|
161
173
|
if File.directory?(file)
|
162
174
|
filename_pattern.split(",").each do |pattern|
|
163
175
|
result += Dir["#{file}/#{pattern.strip}"]
|
@@ -178,45 +190,33 @@ EOM
|
|
178
190
|
end
|
179
191
|
|
180
192
|
def filter_run(options={})
|
181
|
-
|
193
|
+
self.filter = options unless filter and filter[:line_number] || filter[:full_description]
|
182
194
|
end
|
183
195
|
|
184
|
-
def
|
185
|
-
|
196
|
+
def include(mod, filters={})
|
197
|
+
include_or_extend_modules << [:include, mod, filters]
|
186
198
|
end
|
187
199
|
|
188
|
-
def
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
def puts(msg="")
|
193
|
-
output.puts(msg)
|
194
|
-
end
|
195
|
-
|
196
|
-
def include(mod, options={})
|
197
|
-
@include_or_extend_modules << [:include, mod, options]
|
198
|
-
end
|
199
|
-
|
200
|
-
def extend(mod, options={})
|
201
|
-
@include_or_extend_modules << [:extend, mod, options]
|
200
|
+
def extend(mod, filters={})
|
201
|
+
include_or_extend_modules << [:extend, mod, filters]
|
202
202
|
end
|
203
203
|
|
204
204
|
def find_modules(group)
|
205
|
-
|
205
|
+
include_or_extend_modules.select do |include_or_extend, mod, filters|
|
206
206
|
group.all_apply?(filters)
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
210
|
def before(each_or_all=:each, options={}, &block)
|
211
|
-
|
211
|
+
hooks[:before][each_or_all] << [options, block]
|
212
212
|
end
|
213
213
|
|
214
214
|
def after(each_or_all=:each, options={}, &block)
|
215
|
-
|
215
|
+
hooks[:after][each_or_all] << [options, block]
|
216
216
|
end
|
217
217
|
|
218
218
|
def find_hook(hook, each_or_all, group)
|
219
|
-
|
219
|
+
hooks[hook][each_or_all].select do |filters, block|
|
220
220
|
group.all_apply?(filters)
|
221
221
|
end.map { |filters, block| block }
|
222
222
|
end
|
@@ -229,18 +229,6 @@ EOM
|
|
229
229
|
def require_files_to_run
|
230
230
|
files_to_run.map {|f| require File.expand_path(f) }
|
231
231
|
end
|
232
|
-
|
233
|
-
def add_option(mname, options)
|
234
|
-
case options[:type]
|
235
|
-
when :boolean
|
236
|
-
(class << self; self; end).class_eval do
|
237
|
-
attr_accessor mname
|
238
|
-
define_method("#{mname}?") { !!(send mname) }
|
239
|
-
end
|
240
|
-
instance_variable_set "@#{mname}", options[:default]
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
232
|
end
|
245
233
|
end
|
246
234
|
end
|