rspec-core 2.0.0.beta.22 → 2.0.0.rc
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/Gemfile +2 -2
- data/{History.md → History.markdown} +24 -2
- data/Rakefile +1 -0
- data/Upgrade.markdown +36 -3
- data/bin/rspec +1 -2
- data/features/command_line/configure.feature +4 -4
- data/features/command_line/example_name_option.feature +17 -3
- data/features/command_line/exit_status.feature +13 -28
- data/features/command_line/line_number_appended_to_path.feature +12 -16
- data/features/command_line/line_number_option.feature +4 -5
- data/features/command_line/rake_task.feature +68 -0
- data/features/configuration/custom_settings.feature +2 -4
- data/features/configuration/fail_fast.feature +77 -0
- data/features/configuration/read_options_from_file.feature +2 -5
- data/features/example_groups/basic_structure.feature +54 -0
- data/features/example_groups/shared_example_group.feature +38 -27
- data/features/filtering/exclusion_filters.feature +40 -4
- data/features/filtering/inclusion_filters.feature +36 -27
- data/features/filtering/run_all_when_everything_filtered.feature +46 -0
- data/features/hooks/before_and_after_hooks.feature +21 -1
- data/features/pending/pending_examples.feature +24 -5
- data/lib/rspec/autorun.rb +2 -0
- data/lib/rspec/core.rb +6 -4
- data/lib/rspec/core/configuration.rb +69 -23
- data/lib/rspec/core/configuration_options.rb +1 -0
- data/lib/rspec/core/example.rb +0 -1
- data/lib/rspec/core/example_group.rb +23 -8
- data/lib/rspec/core/formatters/base_formatter.rb +14 -4
- data/lib/rspec/core/formatters/base_text_formatter.rb +2 -0
- data/lib/rspec/core/formatters/documentation_formatter.rb +2 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
- data/lib/rspec/core/metadata.rb +18 -11
- data/lib/rspec/core/option_parser.rb +6 -1
- data/lib/rspec/core/rake_task.rb +10 -10
- data/lib/rspec/core/runner.rb +20 -1
- data/lib/rspec/core/subject.rb +26 -3
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +2 -1
- data/spec/autotest/failed_results_re_spec.rb +1 -1
- data/spec/rspec/core/configuration_spec.rb +13 -0
- data/spec/rspec/core/example_group_spec.rb +107 -26
- data/spec/rspec/core/example_spec.rb +11 -24
- data/spec/rspec/core/formatters/base_formatter_spec.rb +17 -1
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +6 -5
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +3 -2
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +25 -22
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +23 -20
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +25 -22
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +25 -2
- data/spec/rspec/core/formatters/html_formatter_spec.rb +10 -2
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -0
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -0
- data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
- data/spec/rspec/core/hooks_spec.rb +4 -4
- data/spec/rspec/core/metadata_spec.rb +20 -0
- data/spec/rspec/core/option_parser_spec.rb +16 -0
- data/spec/rspec/core/rake_task_spec.rb +0 -1
- data/spec/rspec/core/reporter_spec.rb +1 -1
- data/spec/rspec/core/runner_spec.rb +18 -0
- data/spec/rspec/core/shared_example_group_spec.rb +2 -2
- data/spec/spec_helper.rb +14 -3
- metadata +54 -45
- data/.rspec +0 -1
- data/features/example_groups/describe_aliases.feature +0 -25
- data/features/example_groups/nested_groups.feature +0 -44
- data/lib/rspec/core/around_proxy.rb +0 -14
- data/lib/rspec/core/formatters.rb +0 -8
data/lib/rspec/core/metadata.rb
CHANGED
@@ -10,12 +10,10 @@ module RSpec
|
|
10
10
|
end
|
11
11
|
|
12
12
|
store(:example_group, example_group || {})
|
13
|
-
store(:behaviour, self[:example_group])
|
14
13
|
yield self if block_given?
|
15
14
|
end
|
16
15
|
|
17
16
|
RESERVED_KEYS = [
|
18
|
-
:behaviour,
|
19
17
|
:description,
|
20
18
|
:example_group,
|
21
19
|
:execution_result,
|
@@ -29,9 +27,9 @@ module RSpec
|
|
29
27
|
user_metadata = args.last.is_a?(Hash) ? args.pop : {}
|
30
28
|
ensure_valid_keys(user_metadata)
|
31
29
|
|
32
|
-
self[:example_group][:describes] = described_class_from(args)
|
33
|
-
self[:example_group][:description] = description_from(args)
|
34
|
-
self[:example_group][:full_description] = full_description_from(args)
|
30
|
+
self[:example_group][:describes] = described_class_from(*args)
|
31
|
+
self[:example_group][:description] = description_from(*args)
|
32
|
+
self[:example_group][:full_description] = full_description_from(*args)
|
35
33
|
|
36
34
|
self[:example_group][:block] = user_metadata.delete(:example_group_block)
|
37
35
|
self[:example_group][:caller] = user_metadata.delete(:caller) || caller(1)
|
@@ -126,19 +124,28 @@ EOM
|
|
126
124
|
@superclass_metadata ||= { :example_group => {} }
|
127
125
|
end
|
128
126
|
|
129
|
-
def description_from(args)
|
130
|
-
|
127
|
+
def description_from(*args)
|
128
|
+
args.inject("") do |result, a|
|
129
|
+
a = a.to_s.strip
|
130
|
+
if result == ""
|
131
|
+
a
|
132
|
+
elsif a =~ /^(#|::|\.)/
|
133
|
+
"#{result}#{a}"
|
134
|
+
else
|
135
|
+
"#{result} #{a}"
|
136
|
+
end
|
137
|
+
end
|
131
138
|
end
|
132
139
|
|
133
|
-
def full_description_from(args)
|
140
|
+
def full_description_from(*args)
|
134
141
|
if superclass_metadata[:example_group][:full_description]
|
135
|
-
|
142
|
+
description_from(superclass_metadata[:example_group][:full_description], *args)
|
136
143
|
else
|
137
|
-
description_from(args)
|
144
|
+
description_from(*args)
|
138
145
|
end
|
139
146
|
end
|
140
147
|
|
141
|
-
def described_class_from(args)
|
148
|
+
def described_class_from(*args)
|
142
149
|
if args.first.is_a?(String) || args.first.is_a?(Symbol)
|
143
150
|
superclass_metadata[:example_group][:describes]
|
144
151
|
else
|
@@ -9,9 +9,10 @@ module RSpec::Core
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def parse!(args)
|
12
|
+
return {} if args.empty?
|
12
13
|
if args.include?("--formatter")
|
13
|
-
args[args.index("--formatter")] = "--format"
|
14
14
|
RSpec.deprecate("the --formatter option", "-f or --format")
|
15
|
+
args[args.index("--formatter")] = "--format"
|
15
16
|
end
|
16
17
|
options = {}
|
17
18
|
parser(options).parse!(args)
|
@@ -50,6 +51,10 @@ module RSpec::Core
|
|
50
51
|
options[:formatter] = o
|
51
52
|
end
|
52
53
|
|
54
|
+
parser.on('-o', '--out FILE', 'output to a file instead of STDOUT') do |o|
|
55
|
+
options[:output_stream] = o
|
56
|
+
end
|
57
|
+
|
53
58
|
parser.on_tail('-h', '--help', "You're looking at it.") do
|
54
59
|
puts parser
|
55
60
|
exit
|
data/lib/rspec/core/rake_task.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'rspec/core/deprecation'
|
3
4
|
require 'rake'
|
4
5
|
require 'rake/tasklib'
|
5
6
|
|
6
7
|
module RSpec
|
7
8
|
module Core
|
8
|
-
|
9
9
|
class RakeTask < ::Rake::TaskLib
|
10
10
|
|
11
11
|
# Name of task.
|
@@ -46,7 +46,7 @@ module RSpec
|
|
46
46
|
# executed spec command to stdout.
|
47
47
|
#
|
48
48
|
# default:
|
49
|
-
#
|
49
|
+
# true
|
50
50
|
attr_accessor :verbose
|
51
51
|
|
52
52
|
# Use rcov for code coverage?
|
@@ -89,7 +89,7 @@ module RSpec
|
|
89
89
|
@name = args.shift || :spec
|
90
90
|
@pattern, @rcov_path, @rcov_opts, @ruby_opts, @rspec_opts = nil, nil, nil, nil, nil
|
91
91
|
@warning, @rcov = false, false
|
92
|
-
@fail_on_error = true
|
92
|
+
@verbose, @fail_on_error = true, true
|
93
93
|
|
94
94
|
yield self if block_given?
|
95
95
|
|
@@ -103,22 +103,23 @@ module RSpec
|
|
103
103
|
if files_to_run.empty?
|
104
104
|
puts "No examples matching #{pattern} could be found"
|
105
105
|
else
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
begin
|
107
|
+
ruby(spec_command)
|
108
|
+
rescue
|
109
|
+
puts failure_message if failure_message
|
110
|
+
raise("ruby #{spec_command} failed") if fail_on_error
|
110
111
|
end
|
111
112
|
end
|
112
113
|
end
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
117
|
+
private
|
118
|
+
|
116
119
|
def files_to_run # :nodoc:
|
117
120
|
FileList[ pattern ].map { |f| %["#{f}"] }
|
118
121
|
end
|
119
122
|
|
120
|
-
private
|
121
|
-
|
122
123
|
def spec_command
|
123
124
|
@spec_command ||= begin
|
124
125
|
cmd_parts = [ruby_opts]
|
@@ -155,6 +156,5 @@ module RSpec
|
|
155
156
|
end
|
156
157
|
|
157
158
|
end
|
158
|
-
|
159
159
|
end
|
160
160
|
end
|
data/lib/rspec/core/runner.rb
CHANGED
@@ -4,8 +4,27 @@ module RSpec
|
|
4
4
|
module Core
|
5
5
|
class Runner
|
6
6
|
|
7
|
+
def self.autorun
|
8
|
+
return if autorun_disabled? || installed_at_exit? || running_in_drb?
|
9
|
+
@installed_at_exit = true
|
10
|
+
at_exit { run(ARGV, $stderr, $stdout) ? exit(0) : exit(1) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.autorun_disabled?
|
14
|
+
@autorun_disabled ||= false
|
15
|
+
end
|
16
|
+
|
7
17
|
def self.disable_autorun!
|
8
|
-
|
18
|
+
@autorun_disabled = true
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.installed_at_exit?
|
22
|
+
@installed_at_exit ||= false
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.running_in_drb?
|
26
|
+
(DRb.current_server rescue false) &&
|
27
|
+
!!((DRb.current_server.uri) =~ /druby\:\/\/127.0.0.1\:/)
|
9
28
|
end
|
10
29
|
|
11
30
|
def self.trap_interrupt
|
data/lib/rspec/core/subject.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
1
3
|
module RSpec
|
2
4
|
module Core
|
3
5
|
module Subject
|
@@ -86,7 +88,7 @@ module RSpec
|
|
86
88
|
# with dots, the result is as though you concatenated that +String+
|
87
89
|
# onto the subject in an expression.
|
88
90
|
#
|
89
|
-
# describe Person
|
91
|
+
# describe Person do
|
90
92
|
# let(:person) do
|
91
93
|
# person = Person.new
|
92
94
|
# person.phone_numbers << "555-1212"
|
@@ -94,13 +96,34 @@ module RSpec
|
|
94
96
|
#
|
95
97
|
# its("phone_numbers.first") { should == "555-1212" }
|
96
98
|
# end
|
99
|
+
#
|
100
|
+
# When the subject is a +Hash+, you can refer to the Hash keys by
|
101
|
+
# specifying a +Symbol+ or +String+ in an array.
|
102
|
+
#
|
103
|
+
# describe "a configuration Hash" do
|
104
|
+
# subject do
|
105
|
+
# { :max_users => 3,
|
106
|
+
# 'admin' => :all_permissions }
|
107
|
+
# end
|
108
|
+
#
|
109
|
+
# its([:max_users]) { should == 3 }
|
110
|
+
# its(['admin']) { should == :all_permissions }
|
111
|
+
#
|
112
|
+
# # You can still access to its regular methods this way:
|
113
|
+
# its(:keys) { should include(:max_users) }
|
114
|
+
# its(:count) { should == 2 }
|
115
|
+
# end
|
97
116
|
def its(attribute, &block)
|
98
117
|
describe(attribute) do
|
99
118
|
example do
|
100
119
|
self.class.class_eval do
|
101
120
|
define_method(:subject) do
|
102
|
-
|
103
|
-
|
121
|
+
if super().is_a?(Hash) && attribute.is_a?(Array)
|
122
|
+
OpenStruct.new(super()).send(attribute.first)
|
123
|
+
else
|
124
|
+
attribute.to_s.split('.').inject(super()) do |target, method|
|
125
|
+
target.send(method)
|
126
|
+
end
|
104
127
|
end
|
105
128
|
end
|
106
129
|
end
|
data/lib/rspec/core/version.rb
CHANGED
data/lib/rspec/core/world.rb
CHANGED
@@ -2,7 +2,8 @@ module RSpec
|
|
2
2
|
module Core
|
3
3
|
class World
|
4
4
|
|
5
|
-
attr_reader :example_groups, :filtered_examples
|
5
|
+
attr_reader :example_groups, :filtered_examples, :wants_to_quit
|
6
|
+
attr_writer :wants_to_quit
|
6
7
|
|
7
8
|
def initialize(configuration=RSpec.configuration)
|
8
9
|
@configuration = configuration
|
@@ -6,7 +6,7 @@ describe "failed_results_re for autotest" do
|
|
6
6
|
let(:example_output) do
|
7
7
|
group = RSpec::Core::ExampleGroup.describe("group name")
|
8
8
|
example = group.example("example name") { "this".should eq("that") }
|
9
|
-
group.
|
9
|
+
group.run(formatter)
|
10
10
|
RSpec.configuration.stub(:color_enabled?) { false }
|
11
11
|
formatter.dump_failures
|
12
12
|
output.string
|
@@ -278,6 +278,19 @@ module RSpec::Core
|
|
278
278
|
config.formatter.should be_an_instance_of(RSpec::CustomFormatter)
|
279
279
|
end
|
280
280
|
|
281
|
+
it "requires and sets a formatter based on its class fully qualified name" do
|
282
|
+
config.should_receive(:require).with('rspec/custom_formatter2') do
|
283
|
+
RSpec.const_set("CustomFormatter2", Class.new(Formatters::BaseFormatter))
|
284
|
+
end
|
285
|
+
config.formatter = "RSpec::CustomFormatter2"
|
286
|
+
config.formatter.should be_an_instance_of(RSpec::CustomFormatter2)
|
287
|
+
end
|
288
|
+
|
289
|
+
it "raises NameError if class is unresolvable" do
|
290
|
+
config.should_receive(:require).with('rspec/custom_formatter3')
|
291
|
+
lambda { config.formatter = "RSpec::CustomFormatter3" }.should raise_error(NameError)
|
292
|
+
end
|
293
|
+
|
281
294
|
it "raises ArgumentError if formatter is unknown" do
|
282
295
|
lambda { config.formatter = :progresss }.should raise_error(ArgumentError)
|
283
296
|
end
|
@@ -25,7 +25,7 @@ module RSpec::Core
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
group.
|
28
|
+
group.run
|
29
29
|
examples_run.should have(1).example
|
30
30
|
end
|
31
31
|
|
@@ -44,7 +44,7 @@ module RSpec::Core
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
group.
|
47
|
+
group.run
|
48
48
|
examples_run.should have(2).examples
|
49
49
|
end
|
50
50
|
end
|
@@ -158,7 +158,7 @@ module RSpec::Core
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
group.
|
161
|
+
group.run.should be_true
|
162
162
|
end
|
163
163
|
end
|
164
164
|
end
|
@@ -216,7 +216,7 @@ module RSpec::Core
|
|
216
216
|
group.before(:all) { order << 3 }
|
217
217
|
group.example("example") {}
|
218
218
|
|
219
|
-
group.
|
219
|
+
group.run
|
220
220
|
|
221
221
|
order.should == [1,2,3]
|
222
222
|
end
|
@@ -229,7 +229,7 @@ module RSpec::Core
|
|
229
229
|
group.before(:each) { order << 3 }
|
230
230
|
group.example("example") {}
|
231
231
|
|
232
|
-
group.
|
232
|
+
group.run
|
233
233
|
|
234
234
|
order.should == [1,2,3]
|
235
235
|
end
|
@@ -242,7 +242,7 @@ module RSpec::Core
|
|
242
242
|
group.after(:each) { order << 3 }
|
243
243
|
group.example("example") {}
|
244
244
|
|
245
|
-
group.
|
245
|
+
group.run
|
246
246
|
|
247
247
|
order.should == [3,2,1]
|
248
248
|
end
|
@@ -255,11 +255,42 @@ module RSpec::Core
|
|
255
255
|
group.after(:all) { order << 3 }
|
256
256
|
group.example("example") {}
|
257
257
|
|
258
|
-
group.
|
258
|
+
group.run
|
259
259
|
|
260
260
|
order.should == [3,2,1]
|
261
261
|
end
|
262
262
|
|
263
|
+
it "only runs before/after(:all) hooks from example groups that have specs that run" do
|
264
|
+
hooks_run = []
|
265
|
+
|
266
|
+
RSpec.configure do |c|
|
267
|
+
c.filter_run :focus => true
|
268
|
+
end
|
269
|
+
|
270
|
+
unfiltered_group = ExampleGroup.describe "unfiltered" do
|
271
|
+
before(:all) { hooks_run << :unfiltered_before_all }
|
272
|
+
after(:all) { hooks_run << :unfiltered_after_all }
|
273
|
+
|
274
|
+
context "a subcontext" do
|
275
|
+
it("has an example") { }
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
filtered_group = ExampleGroup.describe "filtered", :focus => true do
|
280
|
+
before(:all) { hooks_run << :filtered_before_all }
|
281
|
+
after(:all) { hooks_run << :filtered_after_all }
|
282
|
+
|
283
|
+
context "a subcontext" do
|
284
|
+
it("has an example") { }
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
unfiltered_group.run
|
289
|
+
filtered_group.run
|
290
|
+
|
291
|
+
hooks_run.should == [:filtered_before_all, :filtered_after_all]
|
292
|
+
end
|
293
|
+
|
263
294
|
it "runs before_all_defined_in_config, before all, before each, example, after each, after all, after_all_defined_in_config in that order" do
|
264
295
|
order = []
|
265
296
|
|
@@ -283,7 +314,7 @@ module RSpec::Core
|
|
283
314
|
context2.after(:all) { order << :nested_after_all }
|
284
315
|
context2.example("nested example 2") { order << :nested_example_2 }
|
285
316
|
|
286
|
-
group.
|
317
|
+
group.run
|
287
318
|
|
288
319
|
order.should == [
|
289
320
|
:before_all_defined_in_config,
|
@@ -311,7 +342,7 @@ module RSpec::Core
|
|
311
342
|
group.example("ignore") { }
|
312
343
|
|
313
344
|
expect do
|
314
|
-
group.
|
345
|
+
group.run
|
315
346
|
end.to_not raise_error
|
316
347
|
end
|
317
348
|
|
@@ -319,7 +350,7 @@ module RSpec::Core
|
|
319
350
|
group = ExampleGroup.describe
|
320
351
|
group.before(:each) { raise "error in before each" }
|
321
352
|
example = group.example("equality") { 1.should == 2}
|
322
|
-
group.
|
353
|
+
group.run
|
323
354
|
|
324
355
|
example.metadata[:execution_result][:exception_encountered].message.should == "error in before each"
|
325
356
|
end
|
@@ -328,7 +359,24 @@ module RSpec::Core
|
|
328
359
|
group = ExampleGroup.describe
|
329
360
|
group.before(:all) { raise "error in before all" }
|
330
361
|
example = group.example("equality") { 1.should == 2}
|
331
|
-
group.
|
362
|
+
group.run
|
363
|
+
|
364
|
+
example.metadata.should_not be_nil
|
365
|
+
example.metadata[:execution_result].should_not be_nil
|
366
|
+
example.metadata[:execution_result][:exception_encountered].should_not be_nil
|
367
|
+
example.metadata[:execution_result][:exception_encountered].message.should == "error in before all"
|
368
|
+
end
|
369
|
+
|
370
|
+
it "treats an error in before(:all) as a failure for a spec in a nested group" do
|
371
|
+
example = nil
|
372
|
+
group = ExampleGroup.describe do
|
373
|
+
before(:all) { raise "error in before all" }
|
374
|
+
|
375
|
+
describe "nested" do
|
376
|
+
example = it("equality") { 1.should == 2}
|
377
|
+
end
|
378
|
+
end
|
379
|
+
group.run
|
332
380
|
|
333
381
|
example.metadata.should_not be_nil
|
334
382
|
example.metadata[:execution_result].should_not be_nil
|
@@ -341,7 +389,7 @@ module RSpec::Core
|
|
341
389
|
running_example = :none
|
342
390
|
group.before(:all) { running_example = example }
|
343
391
|
group.example("no-op") { }
|
344
|
-
group.
|
392
|
+
group.run
|
345
393
|
running_example.should == nil
|
346
394
|
end
|
347
395
|
|
@@ -350,7 +398,7 @@ module RSpec::Core
|
|
350
398
|
option = nil
|
351
399
|
group.before(:each) { option = example.options[:data] }
|
352
400
|
group.example("no-op", :data => :sample) { }
|
353
|
-
group.
|
401
|
+
group.run
|
354
402
|
option.should == :sample
|
355
403
|
end
|
356
404
|
|
@@ -359,7 +407,7 @@ module RSpec::Core
|
|
359
407
|
option = nil
|
360
408
|
group.after(:each) { option = example.options[:data] }
|
361
409
|
group.example("no-op", :data => :sample) { }
|
362
|
-
group.
|
410
|
+
group.run
|
363
411
|
option.should == :sample
|
364
412
|
end
|
365
413
|
|
@@ -368,7 +416,7 @@ module RSpec::Core
|
|
368
416
|
running_example = :none
|
369
417
|
group.after(:all) { running_example = example }
|
370
418
|
group.example("no-op") { }
|
371
|
-
group.
|
419
|
+
group.run
|
372
420
|
running_example.should == nil
|
373
421
|
end
|
374
422
|
end
|
@@ -381,6 +429,13 @@ module RSpec::Core
|
|
381
429
|
group.examples.size.should == 1
|
382
430
|
end
|
383
431
|
|
432
|
+
it "allows adding a pending example using 'xit'" do
|
433
|
+
group = ExampleGroup.describe
|
434
|
+
group.xit("is pending") { }
|
435
|
+
group.run
|
436
|
+
group.examples.first.should be_pending
|
437
|
+
end
|
438
|
+
|
384
439
|
it "exposes all examples at examples" do
|
385
440
|
group = ExampleGroup.describe
|
386
441
|
group.it("should do something 1") { }
|
@@ -518,14 +573,6 @@ module RSpec::Core
|
|
518
573
|
end
|
519
574
|
|
520
575
|
describe "#its" do
|
521
|
-
its(:class) { should == RSpec::Core::ExampleGroup }
|
522
|
-
it "does not interfere between examples" do
|
523
|
-
subject.class.should == RSpec::Core::ExampleGroup
|
524
|
-
end
|
525
|
-
context "subject modified in before block" do
|
526
|
-
before { subject.class.should == RSpec::Core::ExampleGroup }
|
527
|
-
end
|
528
|
-
|
529
576
|
context "with nil value" do
|
530
577
|
subject do
|
531
578
|
Class.new do
|
@@ -549,6 +596,24 @@ module RSpec::Core
|
|
549
596
|
its("name.size.class") { should == Fixnum }
|
550
597
|
end
|
551
598
|
|
599
|
+
context "when it is a Hash" do
|
600
|
+
subject do
|
601
|
+
{ :attribute => 'value',
|
602
|
+
'another_attribute' => 'another_value' }
|
603
|
+
end
|
604
|
+
its([:attribute]) { should == 'value' }
|
605
|
+
its([:attribute]) { should_not == 'another_value' }
|
606
|
+
its([:another_attribute]) { should == 'another_value' }
|
607
|
+
its([:another_attribute]) { should_not == 'value' }
|
608
|
+
its(:keys) { should =~ ['another_attribute', :attribute] }
|
609
|
+
|
610
|
+
context "when referring to an attribute without the proper array syntax" do
|
611
|
+
it "raises a NoMethodError" do
|
612
|
+
expect{ its(:attribute) }.to raise_error(NoMethodError)
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
552
617
|
context "calling and overriding super" do
|
553
618
|
it "calls to the subject defined in the parent group" do
|
554
619
|
group = ExampleGroup.describe(Array) do
|
@@ -563,9 +628,10 @@ module RSpec::Core
|
|
563
628
|
end
|
564
629
|
end
|
565
630
|
|
566
|
-
group.
|
631
|
+
group.run.should be_true
|
567
632
|
end
|
568
633
|
end
|
634
|
+
|
569
635
|
end
|
570
636
|
|
571
637
|
describe "#top_level_description" do
|
@@ -585,10 +651,25 @@ module RSpec::Core
|
|
585
651
|
describe "#run" do
|
586
652
|
let(:reporter) { double("reporter").as_null_object }
|
587
653
|
|
654
|
+
context "with fail_fast? => true" do
|
655
|
+
it "does not run examples after the failed example" do
|
656
|
+
group = RSpec::Core::ExampleGroup.describe
|
657
|
+
group.stub(:fail_fast?) { true }
|
658
|
+
examples_run = []
|
659
|
+
group.example('example 1') { examples_run << self }
|
660
|
+
group.example('example 2') { examples_run << self; fail; }
|
661
|
+
group.example('example 3') { examples_run << self }
|
662
|
+
|
663
|
+
group.run
|
664
|
+
|
665
|
+
examples_run.length.should eq(2)
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
588
669
|
context "with RSpec.wants_to_quit=true" do
|
589
670
|
before do
|
590
|
-
RSpec.stub(:
|
591
|
-
RSpec.stub(:wants_to_quit) { true }
|
671
|
+
RSpec.world.stub(:example_groups) { [] }
|
672
|
+
RSpec.world.stub(:wants_to_quit) { true }
|
592
673
|
end
|
593
674
|
|
594
675
|
it "returns without starting the group" do
|