rspec-core 2.0.0.beta.8 → 2.0.0.beta.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +8 -8
- data/Rakefile +9 -9
- data/Upgrade.markdown +6 -6
- data/VERSION +1 -1
- data/cucumber.yml +2 -7
- data/example_specs/passing/subject_example.rb +45 -0
- data/example_specs/spec_helper.rb +1 -1
- data/features/command_line/line_number_appended_to_path.feature +11 -13
- data/features/command_line/line_number_option.feature +3 -3
- data/features/configuration/custom_options.feature +71 -0
- data/features/configuration/options_file.feature +13 -13
- data/features/example_groups/describe_aliases.feature +1 -1
- data/features/example_groups/nested_groups.feature +4 -5
- data/features/filtering/inclusion_filters.feature +74 -0
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/hooks/around_hook.feature +1 -1
- data/features/hooks/before_and_after_hooks.feature +61 -33
- data/features/hooks/described_class.feature +1 -1
- data/features/hooks/halt.feature +2 -2
- data/features/mock_framework_integration/use_flexmock.feature +2 -2
- data/features/mock_framework_integration/use_mocha.feature +2 -2
- data/features/mock_framework_integration/use_rr.feature +2 -2
- data/features/mock_framework_integration/use_rspec.feature +2 -2
- data/features/pending/pending_examples.feature +5 -5
- data/features/subject/explicit_subject.feature +4 -4
- data/features/subject/implicit_subject.feature +2 -2
- data/features/support/env.rb +1 -1
- data/lib/autotest/rspec2.rb +1 -1
- data/lib/rspec/autorun.rb +1 -1
- data/lib/rspec/core.rb +16 -9
- data/lib/rspec/core/around_proxy.rb +1 -1
- data/lib/rspec/core/backward_compatibility.rb +29 -1
- data/lib/rspec/core/configuration.rb +24 -16
- data/lib/rspec/core/configuration_options.rb +2 -2
- data/lib/rspec/core/deprecation.rb +3 -3
- data/lib/rspec/core/errors.rb +1 -1
- data/lib/rspec/core/example.rb +10 -3
- data/lib/rspec/core/example_group.rb +83 -58
- data/lib/rspec/core/formatters.rb +1 -1
- data/lib/rspec/core/formatters/base_formatter.rb +4 -4
- data/lib/rspec/core/formatters/base_text_formatter.rb +3 -3
- data/lib/rspec/core/formatters/documentation_formatter.rb +6 -9
- data/lib/rspec/core/formatters/helpers.rb +5 -4
- data/lib/rspec/core/formatters/progress_formatter.rb +1 -1
- data/lib/rspec/core/hooks.rb +1 -1
- data/lib/rspec/core/kernel_extensions.rb +3 -23
- data/lib/rspec/core/let.rb +73 -5
- data/lib/rspec/core/load_path.rb +1 -1
- data/lib/rspec/core/metadata.rb +20 -8
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +1 -1
- data/lib/rspec/core/mocking/with_flexmock.rb +1 -1
- data/lib/rspec/core/mocking/with_mocha.rb +1 -1
- data/lib/rspec/core/mocking/with_rr.rb +2 -2
- data/lib/rspec/core/mocking/with_rspec.rb +3 -3
- data/lib/rspec/core/object_extensions.rb +15 -0
- data/lib/rspec/core/pending.rb +2 -2
- data/lib/rspec/core/rake_task.rb +2 -2
- data/lib/rspec/core/ruby_project.rb +1 -1
- data/lib/rspec/core/runner.rb +13 -8
- data/lib/rspec/core/shared_example_group.rb +16 -6
- data/lib/rspec/core/subject.rb +23 -7
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +45 -38
- data/rspec-core.gemspec +17 -11
- data/spec/autotest/failed_results_re_spec.rb +1 -1
- data/spec/rspec/core/configuration_options_spec.rb +17 -7
- data/spec/rspec/core/configuration_spec.rb +46 -18
- data/spec/rspec/core/deprecations_spec.rb +8 -0
- data/spec/rspec/core/example_group_spec.rb +194 -56
- data/spec/rspec/core/example_spec.rb +18 -6
- data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -2
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +18 -2
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +29 -4
- data/spec/rspec/core/formatters/helpers_spec.rb +18 -11
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
- data/spec/rspec/core/kernel_extensions_spec.rb +5 -9
- data/spec/rspec/core/metadata_spec.rb +29 -8
- data/spec/rspec/core/pending_example_spec.rb +7 -7
- data/spec/rspec/core/ruby_project_spec.rb +1 -1
- data/spec/rspec/core/runner_spec.rb +9 -9
- data/spec/rspec/core/shared_example_group_spec.rb +3 -3
- data/spec/rspec/core/subject_spec.rb +1 -1
- data/spec/rspec/core/world_spec.rb +16 -35
- data/spec/rspec/core_spec.rb +9 -9
- data/spec/spec_helper.rb +11 -13
- data/spec/support/matchers.rb +2 -2
- data/specs.watchr +11 -11
- metadata +16 -10
data/lib/rspec/core/runner.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module RSpec
|
2
2
|
module Core
|
3
3
|
class Runner
|
4
4
|
|
@@ -13,18 +13,23 @@ module Rspec
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def configuration
|
16
|
-
|
16
|
+
RSpec.configuration
|
17
17
|
end
|
18
18
|
|
19
19
|
def reporter
|
20
20
|
configuration.formatter
|
21
21
|
end
|
22
22
|
|
23
|
+
def inclusion_filter
|
24
|
+
RSpec.configuration.filter
|
25
|
+
end
|
26
|
+
|
23
27
|
def run(args = [])
|
24
28
|
configure(args)
|
25
|
-
|
29
|
+
RSpec.world.announce_inclusion_filter
|
30
|
+
|
26
31
|
reporter.report(example_count) do |reporter|
|
27
|
-
example_groups.
|
32
|
+
example_groups.run_examples(reporter)
|
28
33
|
end
|
29
34
|
|
30
35
|
example_groups.success?
|
@@ -33,21 +38,21 @@ module Rspec
|
|
33
38
|
private
|
34
39
|
|
35
40
|
def configure(args)
|
36
|
-
|
41
|
+
RSpec::Core::ConfigurationOptions.new(args).apply_to(configuration)
|
37
42
|
configuration.require_files_to_run
|
38
43
|
configuration.configure_mock_framework
|
39
44
|
end
|
40
45
|
|
41
46
|
def example_count
|
42
|
-
|
47
|
+
RSpec.world.example_count
|
43
48
|
end
|
44
49
|
|
45
50
|
def example_groups
|
46
|
-
|
51
|
+
RSpec.world.example_groups.extend(ExampleGroups)
|
47
52
|
end
|
48
53
|
|
49
54
|
module ExampleGroups
|
50
|
-
def
|
55
|
+
def run_examples(reporter)
|
51
56
|
@success = self.inject(true) {|success, group| success &= group.run(reporter)}
|
52
57
|
end
|
53
58
|
|
@@ -1,19 +1,25 @@
|
|
1
|
-
module
|
1
|
+
module RSpec
|
2
2
|
module Core
|
3
3
|
module SharedExampleGroup
|
4
4
|
|
5
5
|
def share_examples_for(name, &block)
|
6
6
|
ensure_shared_example_group_name_not_taken(name)
|
7
|
-
|
7
|
+
RSpec.world.shared_example_groups[name] = block
|
8
8
|
end
|
9
9
|
|
10
10
|
def share_as(name, &block)
|
11
11
|
if Object.const_defined?(name)
|
12
|
-
|
12
|
+
mod = Object.const_get(name)
|
13
|
+
raise_name_error unless mod.created_from_caller(caller)
|
13
14
|
end
|
14
15
|
|
15
16
|
mod = Module.new do
|
16
17
|
@shared_block = block
|
18
|
+
@caller_line = caller.last
|
19
|
+
|
20
|
+
def self.created_from_caller(other_caller)
|
21
|
+
@caller_line == other_caller.last
|
22
|
+
end
|
17
23
|
|
18
24
|
def self.included(kls)
|
19
25
|
kls.module_eval(&@shared_block)
|
@@ -21,15 +27,19 @@ module Rspec
|
|
21
27
|
end
|
22
28
|
|
23
29
|
shared_const = Object.const_set(name, mod)
|
24
|
-
|
30
|
+
RSpec.world.shared_example_groups[shared_const] = block
|
25
31
|
end
|
26
32
|
|
27
33
|
alias :shared_examples_for :share_examples_for
|
28
34
|
|
29
35
|
private
|
30
36
|
|
37
|
+
def raise_name_error
|
38
|
+
raise NameError, "The first argument (#{name}) to share_as must be a legal name for a constant not already in use."
|
39
|
+
end
|
40
|
+
|
31
41
|
def ensure_shared_example_group_name_not_taken(name)
|
32
|
-
if
|
42
|
+
if RSpec.world.shared_example_groups.has_key?(name)
|
33
43
|
raise ArgumentError.new("Shared example group '#{name}' already exists")
|
34
44
|
end
|
35
45
|
end
|
@@ -38,4 +48,4 @@ module Rspec
|
|
38
48
|
end
|
39
49
|
end
|
40
50
|
|
41
|
-
include
|
51
|
+
include RSpec::Core::SharedExampleGroup
|
data/lib/rspec/core/subject.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
module
|
1
|
+
module RSpec
|
2
2
|
module Core
|
3
3
|
module Subject
|
4
|
-
|
4
|
+
|
5
5
|
def self.included(kls)
|
6
6
|
kls.extend ClassMethods
|
7
7
|
kls.__send__ :alias_method, :__should_for_example_group__, :should
|
8
8
|
kls.__send__ :alias_method, :__should_not_for_example_group__, :should_not
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def subject
|
12
|
-
|
12
|
+
attribute_of_subject || original_subject
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# When +should+ is called with no explicit receiver, the call is
|
16
16
|
# delegated to the object returned by +subject+. Combined with
|
17
17
|
# an implicit subject (see +subject+), this supports very concise
|
@@ -37,7 +37,7 @@ module Rspec
|
|
37
37
|
def should_not(matcher=nil, message=nil)
|
38
38
|
self == subject ? self.__should_not_for_example_group__(matcher) : subject.should_not(matcher,message)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
module ClassMethods
|
42
42
|
# Defines an explicit subject for an example group which can then be the
|
43
43
|
# implicit receiver (through delegation) of calls to +should+.
|
@@ -54,7 +54,7 @@ module Rspec
|
|
54
54
|
def subject(&block)
|
55
55
|
block ? @explicit_subject_block = block : explicit_subject || implicit_subject
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
attr_reader :explicit_subject_block # :nodoc:
|
59
59
|
|
60
60
|
private
|
@@ -72,6 +72,22 @@ module Rspec
|
|
72
72
|
Class === described ? proc { described.new } : proc { described }
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def original_subject
|
79
|
+
@original_subject ||= instance_eval(&self.class.subject)
|
80
|
+
end
|
81
|
+
|
82
|
+
def attribute_of_subject
|
83
|
+
original_subject.send(running_example.description) if using_attribute?
|
84
|
+
end
|
85
|
+
|
86
|
+
def using_attribute?
|
87
|
+
running_example.in_block? &&
|
88
|
+
running_example.metadata[:attribute_of_subject]
|
89
|
+
end
|
90
|
+
|
75
91
|
end
|
76
92
|
end
|
77
93
|
end
|
data/lib/rspec/core/version.rb
CHANGED
data/lib/rspec/core/world.rb
CHANGED
@@ -1,58 +1,43 @@
|
|
1
|
-
module
|
1
|
+
module RSpec
|
2
2
|
module Core
|
3
3
|
class World
|
4
4
|
|
5
|
-
attr_reader :example_groups
|
5
|
+
attr_reader :example_groups, :filtered_examples
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@example_groups = []
|
9
|
+
@filtered_examples = Hash.new { |hash,group|
|
10
|
+
hash[group] = begin
|
11
|
+
examples = group.examples.dup
|
12
|
+
examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter
|
13
|
+
examples = apply_inclusion_filters(examples, inclusion_filter) if inclusion_filter
|
14
|
+
examples.uniq
|
15
|
+
end
|
16
|
+
}
|
9
17
|
end
|
10
18
|
|
11
|
-
def
|
12
|
-
|
19
|
+
def configuration
|
20
|
+
RSpec.configuration
|
13
21
|
end
|
14
22
|
|
15
|
-
def
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def shared_example_groups
|
20
|
-
@shared_example_groups ||= {}
|
23
|
+
def inclusion_filter
|
24
|
+
configuration.filter
|
21
25
|
end
|
22
26
|
|
23
|
-
def
|
24
|
-
|
25
|
-
if inclusion_filter || exclusion_filter
|
26
|
-
if Rspec.configuration.run_all_when_everything_filtered? && filtered_example_groups.empty?
|
27
|
-
Rspec.configuration.puts "No examples were matched by #{inclusion_filter.inspect}, running all"
|
28
|
-
all_example_groups
|
29
|
-
else
|
30
|
-
Rspec.configuration.puts "Run filtered using #{inclusion_filter.inspect}"
|
31
|
-
filtered_example_groups
|
32
|
-
end
|
33
|
-
else
|
34
|
-
all_example_groups
|
35
|
-
end
|
36
|
-
end
|
27
|
+
def exclusion_filter
|
28
|
+
configuration.exclusion_filter
|
37
29
|
end
|
38
30
|
|
39
|
-
def
|
40
|
-
|
31
|
+
def find_modules(group)
|
32
|
+
configuration.find_modules(group)
|
41
33
|
end
|
42
34
|
|
43
|
-
def
|
44
|
-
@
|
35
|
+
def shared_example_groups
|
36
|
+
@shared_example_groups ||= {}
|
45
37
|
end
|
46
38
|
|
47
|
-
def
|
48
|
-
|
49
|
-
examples = example_group.examples
|
50
|
-
examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter
|
51
|
-
examples = apply_inclusion_filters(examples, inclusion_filter) if inclusion_filter
|
52
|
-
examples.uniq!
|
53
|
-
example_group.examples_to_run.replace(examples)
|
54
|
-
!examples.empty?
|
55
|
-
end
|
39
|
+
def example_count
|
40
|
+
example_groups.collect {|g| g.descendents}.flatten.inject(0) { |sum, g| sum += g.filtered_examples.size }
|
56
41
|
end
|
57
42
|
|
58
43
|
def apply_inclusion_filters(examples, conditions={})
|
@@ -65,12 +50,34 @@ module Rspec
|
|
65
50
|
examples.reject &all_apply?(conditions)
|
66
51
|
end
|
67
52
|
|
68
|
-
def
|
53
|
+
def preceding_declaration_line(filter_line)
|
69
54
|
declaration_line_numbers.inject(nil) do |highest_prior_declaration_line, line|
|
70
55
|
line <= filter_line ? line : highest_prior_declaration_line
|
71
56
|
end
|
72
57
|
end
|
58
|
+
|
59
|
+
def announce_inclusion_filter
|
60
|
+
if inclusion_filter
|
61
|
+
if RSpec.configuration.run_all_when_everything_filtered? && RSpec.world.example_count == 0
|
62
|
+
RSpec.configuration.puts "No examples were matched by #{inclusion_filter.inspect}, running all"
|
63
|
+
RSpec.configuration.clear_inclusion_filter
|
64
|
+
filtered_examples.clear
|
65
|
+
else
|
66
|
+
RSpec.configuration.puts "Run filtered using #{inclusion_filter.inspect}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
73
70
|
|
71
|
+
def run_hook(hook, scope, group, example)
|
72
|
+
find_hook(hook, scope, group).each { |blk| example.instance_eval(&blk) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def find_hook(hook, scope, group)
|
76
|
+
RSpec.configuration.hooks[hook][scope].select do |filters, block|
|
77
|
+
group.all_apply?(filters)
|
78
|
+
end.map { |filters, block| block }
|
79
|
+
end
|
80
|
+
|
74
81
|
private
|
75
82
|
|
76
83
|
def all_apply?(conditions)
|
data/rspec-core.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-core}
|
8
|
-
s.version = "2.0.0.beta.
|
8
|
+
s.version = "2.0.0.beta.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chad Humphries", "David Chelimsky"]
|
12
|
-
s.date = %q{2010-
|
13
|
-
s.description = %q{
|
12
|
+
s.date = %q{2010-05-27}
|
13
|
+
s.description = %q{RSpec runner and example group classes}
|
14
14
|
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
15
15
|
s.executables = ["rspec", "spec"]
|
16
16
|
s.extra_rdoc_files = [
|
@@ -75,15 +75,18 @@ Gem::Specification.new do |s|
|
|
75
75
|
"example_specs/passing/stack_spec.rb",
|
76
76
|
"example_specs/passing/stack_spec_with_nested_example_groups.rb",
|
77
77
|
"example_specs/passing/stubbing_example.rb",
|
78
|
+
"example_specs/passing/subject_example.rb",
|
78
79
|
"example_specs/passing/yielding_example.rb",
|
79
80
|
"example_specs/ruby1.9.compatibility/access_to_constants_spec.rb",
|
80
81
|
"example_specs/spec_helper.rb",
|
81
82
|
"features/command_line/example_name_option.feature",
|
82
83
|
"features/command_line/line_number_appended_to_path.feature",
|
83
84
|
"features/command_line/line_number_option.feature",
|
85
|
+
"features/configuration/custom_options.feature",
|
84
86
|
"features/configuration/options_file.feature",
|
85
87
|
"features/example_groups/describe_aliases.feature",
|
86
88
|
"features/example_groups/nested_groups.feature",
|
89
|
+
"features/filtering/inclusion_filters.feature",
|
87
90
|
"features/formatters/custom_formatter.feature",
|
88
91
|
"features/hooks/around_hook.feature",
|
89
92
|
"features/hooks/before_and_after_hooks.feature",
|
@@ -124,6 +127,7 @@ Gem::Specification.new do |s|
|
|
124
127
|
"lib/rspec/core/mocking/with_mocha.rb",
|
125
128
|
"lib/rspec/core/mocking/with_rr.rb",
|
126
129
|
"lib/rspec/core/mocking/with_rspec.rb",
|
130
|
+
"lib/rspec/core/object_extensions.rb",
|
127
131
|
"lib/rspec/core/pending.rb",
|
128
132
|
"lib/rspec/core/rake_task.rb",
|
129
133
|
"lib/rspec/core/ruby_project.rb",
|
@@ -138,6 +142,7 @@ Gem::Specification.new do |s|
|
|
138
142
|
"spec/autotest/rspec_spec.rb",
|
139
143
|
"spec/rspec/core/configuration_options_spec.rb",
|
140
144
|
"spec/rspec/core/configuration_spec.rb",
|
145
|
+
"spec/rspec/core/deprecations_spec.rb",
|
141
146
|
"spec/rspec/core/example_group_spec.rb",
|
142
147
|
"spec/rspec/core/example_spec.rb",
|
143
148
|
"spec/rspec/core/formatters/base_formatter_spec.rb",
|
@@ -168,7 +173,7 @@ Gem::Specification.new do |s|
|
|
168
173
|
s.homepage = %q{http://github.com/rspec/core}
|
169
174
|
s.post_install_message = %q{**************************************************
|
170
175
|
|
171
|
-
Thank you for installing rspec-core-2.0.0.beta.
|
176
|
+
Thank you for installing rspec-core-2.0.0.beta.9
|
172
177
|
|
173
178
|
This is beta software. If you are looking
|
174
179
|
for a supported production release, please
|
@@ -180,12 +185,13 @@ Gem::Specification.new do |s|
|
|
180
185
|
s.require_paths = ["lib"]
|
181
186
|
s.rubyforge_project = %q{rspec}
|
182
187
|
s.rubygems_version = %q{1.3.6}
|
183
|
-
s.summary = %q{rspec-core-2.0.0.beta.
|
188
|
+
s.summary = %q{rspec-core-2.0.0.beta.9}
|
184
189
|
s.test_files = [
|
185
190
|
"spec/autotest/failed_results_re_spec.rb",
|
186
191
|
"spec/autotest/rspec_spec.rb",
|
187
192
|
"spec/rspec/core/configuration_options_spec.rb",
|
188
193
|
"spec/rspec/core/configuration_spec.rb",
|
194
|
+
"spec/rspec/core/deprecations_spec.rb",
|
189
195
|
"spec/rspec/core/example_group_spec.rb",
|
190
196
|
"spec/rspec/core/example_spec.rb",
|
191
197
|
"spec/rspec/core/formatters/base_formatter_spec.rb",
|
@@ -218,19 +224,19 @@ Gem::Specification.new do |s|
|
|
218
224
|
s.specification_version = 3
|
219
225
|
|
220
226
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
221
|
-
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
222
|
-
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
227
|
+
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.9"])
|
228
|
+
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.9"])
|
223
229
|
s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
|
224
230
|
s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
|
225
231
|
else
|
226
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
227
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
232
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.9"])
|
233
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.9"])
|
228
234
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
229
235
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
230
236
|
end
|
231
237
|
else
|
232
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
233
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
238
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.9"])
|
239
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.9"])
|
234
240
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
235
241
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
236
242
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe RSpec::Core::ConfigurationOptions do
|
5
5
|
|
6
6
|
def options_from_args(*args)
|
7
|
-
|
7
|
+
RSpec::Core::ConfigurationOptions.new(args).parse_command_line_options
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'color_enabled' do
|
@@ -77,6 +77,16 @@ describe Rspec::Core::ConfigurationOptions do
|
|
77
77
|
options_from_args("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"])
|
78
78
|
end
|
79
79
|
|
80
|
+
it "provides no files or directories if spec directory does not exist" do
|
81
|
+
FileTest.stub(:directory?).with("spec").and_return false
|
82
|
+
options_from_args().should include(:files_or_directories_to_run => [])
|
83
|
+
end
|
84
|
+
|
85
|
+
it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
|
86
|
+
options_from_args("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"])
|
87
|
+
|
88
|
+
end
|
89
|
+
|
80
90
|
end
|
81
91
|
|
82
92
|
describe "--backtrace (-b)" do
|
@@ -100,7 +110,7 @@ describe Rspec::Core::ConfigurationOptions do
|
|
100
110
|
File.stub(:exist?) { true }
|
101
111
|
File.stub(:readlines) { ["--formatter", "doc"] }
|
102
112
|
|
103
|
-
cli_options =
|
113
|
+
cli_options = RSpec::Core::ConfigurationOptions.new([])
|
104
114
|
cli_options.apply_to(config)
|
105
115
|
config.formatter.should == 'doc'
|
106
116
|
end
|
@@ -109,7 +119,7 @@ describe Rspec::Core::ConfigurationOptions do
|
|
109
119
|
File.stub(:exist?) { true }
|
110
120
|
File.stub(:readlines) { ["--formatter doc"] }
|
111
121
|
|
112
|
-
cli_options =
|
122
|
+
cli_options = RSpec::Core::ConfigurationOptions.new([])
|
113
123
|
cli_options.apply_to(config)
|
114
124
|
config.formatter.should == 'doc'
|
115
125
|
end
|
@@ -126,7 +136,7 @@ describe Rspec::Core::ConfigurationOptions do
|
|
126
136
|
raise "Unexpected path: #{path}"
|
127
137
|
end
|
128
138
|
end
|
129
|
-
cli_options =
|
139
|
+
cli_options = RSpec::Core::ConfigurationOptions.new(["--no-color"])
|
130
140
|
|
131
141
|
cli_options.apply_to(config)
|
132
142
|
|
@@ -147,7 +157,7 @@ describe Rspec::Core::ConfigurationOptions do
|
|
147
157
|
raise "Unexpected path: #{path}"
|
148
158
|
end
|
149
159
|
end
|
150
|
-
cli_options =
|
160
|
+
cli_options = RSpec::Core::ConfigurationOptions.new([])
|
151
161
|
|
152
162
|
cli_options.apply_to(config)
|
153
163
|
|
@@ -155,7 +165,7 @@ describe Rspec::Core::ConfigurationOptions do
|
|
155
165
|
end
|
156
166
|
|
157
167
|
it "prefers CLI options over file options" do
|
158
|
-
config_options =
|
168
|
+
config_options = RSpec::Core::ConfigurationOptions.new(['--formatter', 'progress'])
|
159
169
|
config_options.stub(:parse_options_file).and_return(:formatter => 'documentation')
|
160
170
|
|
161
171
|
config_options.apply_to(config)
|