rspec-core 2.6.4 → 2.7.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/{bin → exe}/autospec +0 -0
- data/{bin → exe}/rspec +0 -0
- data/features/Upgrade.md +11 -0
- data/features/command_line/exit_status.feature +20 -3
- data/features/command_line/format_option.feature +8 -0
- data/features/command_line/line_number_appended_to_path.feature +35 -1
- data/features/command_line/line_number_option.feature +16 -3
- data/features/command_line/pattern_option.feature +31 -0
- data/features/command_line/rake_task.feature +1 -1
- data/features/command_line/ruby.feature +22 -0
- data/features/configuration/default_path.feature +38 -0
- data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
- data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
- data/features/filtering/inclusion_filters.feature +4 -5
- data/features/formatters/text_formatter.feature +16 -13
- data/features/helper_methods/let.feature +4 -4
- data/features/hooks/around_hooks.feature +1 -1
- data/features/hooks/before_and_after_hooks.feature +3 -3
- data/features/hooks/filtering.feature +13 -6
- data/features/metadata/user_defined.feature +12 -10
- data/features/pending/pending_examples.feature +21 -8
- data/features/step_definitions/additional_cli_steps.rb +1 -1
- data/features/subject/attribute_of_subject.feature +2 -2
- data/features/support/env.rb +1 -2
- data/lib/rspec/core.rb +1 -23
- data/lib/rspec/core/configuration.rb +64 -16
- data/lib/rspec/core/configuration_options.rb +11 -4
- data/lib/rspec/core/example.rb +10 -7
- data/lib/rspec/core/example_group.rb +34 -18
- data/lib/rspec/core/formatters/base_text_formatter.rb +10 -2
- data/lib/rspec/core/formatters/html_formatter.rb +3 -1
- data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
- data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
- data/lib/rspec/core/hooks.rb +2 -2
- data/lib/rspec/core/let.rb +5 -5
- data/lib/rspec/core/metadata.rb +136 -94
- data/lib/rspec/core/option_parser.rb +10 -5
- data/lib/rspec/core/pending.rb +2 -1
- data/lib/rspec/core/rake_task.rb +26 -15
- data/lib/rspec/core/reporter.rb +2 -3
- data/lib/rspec/core/runner.rb +1 -1
- data/lib/rspec/core/shared_example_group.rb +4 -4
- data/lib/rspec/core/subject.rb +7 -7
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +4 -8
- data/spec/autotest/discover_spec.rb +2 -2
- data/spec/autotest/failed_results_re_spec.rb +29 -21
- data/spec/autotest/rspec_spec.rb +3 -3
- data/spec/rspec/core/command_line_spec.rb +1 -6
- data/spec/rspec/core/configuration_options_spec.rb +65 -13
- data/spec/rspec/core/configuration_spec.rb +148 -37
- data/spec/rspec/core/deprecations_spec.rb +2 -2
- data/spec/rspec/core/drb_command_line_spec.rb +6 -6
- data/spec/rspec/core/example_group_spec.rb +197 -61
- data/spec/rspec/core/example_spec.rb +33 -16
- data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +149 -1
- data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +85 -17
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
- data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
- data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +86 -18
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
- data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
- data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
- data/spec/rspec/core/let_spec.rb +19 -6
- data/spec/rspec/core/metadata_spec.rb +146 -61
- data/spec/rspec/core/pending_example_spec.rb +4 -4
- data/spec/rspec/core/rake_task_spec.rb +71 -50
- data/spec/rspec/core/reporter_spec.rb +2 -2
- data/spec/rspec/core/ruby_project_spec.rb +2 -2
- data/spec/rspec/core/runner_spec.rb +4 -1
- data/spec/rspec/core/shared_example_group_spec.rb +15 -119
- data/spec/rspec/core/subject_spec.rb +13 -13
- data/spec/rspec/core/world_spec.rb +31 -22
- data/spec/rspec/core_spec.rb +1 -29
- data/spec/spec_helper.rb +51 -49
- data/spec/support/shared_example_groups.rb +3 -3
- data/spec/support/spec_files.rb +8 -8
- metadata +79 -93
- data/.document +0 -5
- data/.gitignore +0 -12
- data/.rspec +0 -0
- data/.travis.yml +0 -9
- data/Changelog.md +0 -305
- data/Gemfile +0 -49
- data/Guardfile +0 -5
- data/License.txt +0 -23
- data/Rakefile +0 -93
- data/cucumber.yml +0 -2
- data/features/.nav +0 -57
- data/rspec-core.gemspec +0 -24
- data/script/FullBuildRakeFile +0 -63
- data/script/console +0 -8
- data/script/cucumber +0 -1
- data/script/full_build +0 -1
- data/script/spec +0 -1
- data/spec.txt +0 -1126
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
@@ -71,6 +71,18 @@ module RSpec::Core
|
|
71
71
|
config.should_receive(:require).with('rspec/core/mocking/with_absolutely_nothing')
|
72
72
|
config.mock_framework = :crazy_new_mocking_framework_ive_not_yet_heard_of
|
73
73
|
end
|
74
|
+
|
75
|
+
context 'when there are already some example groups defined' do
|
76
|
+
before(:each) do
|
77
|
+
RSpec.world.stub(:example_groups).and_return([double.as_null_object])
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'raises an error since this setting must be applied before any groups are defined' do
|
81
|
+
expect {
|
82
|
+
config.mock_framework = :rspec
|
83
|
+
}.to raise_error(/must be configured before any example groups are defined/)
|
84
|
+
end
|
85
|
+
end
|
74
86
|
end
|
75
87
|
|
76
88
|
describe "#mock_with" do
|
@@ -109,6 +121,18 @@ module RSpec::Core
|
|
109
121
|
config.expect_with :not_supported
|
110
122
|
end.to raise_error(ArgumentError)
|
111
123
|
end
|
124
|
+
|
125
|
+
context 'when there are already some example groups defined' do
|
126
|
+
before(:each) do
|
127
|
+
RSpec.world.stub(:example_groups).and_return([double.as_null_object])
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'raises an error since this setting must be applied before any groups are defined' do
|
131
|
+
expect {
|
132
|
+
config.expect_with :rspec
|
133
|
+
}.to raise_error(/must be configured before any example groups are defined/)
|
134
|
+
end
|
135
|
+
end
|
112
136
|
end
|
113
137
|
|
114
138
|
describe "#expecting_with_rspec?" do
|
@@ -145,22 +169,47 @@ module RSpec::Core
|
|
145
169
|
|
146
170
|
describe "#files_to_run" do
|
147
171
|
it "loads files not following pattern if named explicitly" do
|
148
|
-
|
149
|
-
config.
|
150
|
-
|
172
|
+
config.files_or_directories_to_run = "spec/rspec/core/resources/a_bar.rb"
|
173
|
+
config.files_to_run.should eq([ "spec/rspec/core/resources/a_bar.rb"])
|
174
|
+
end
|
175
|
+
|
176
|
+
it "prevents repitition of dir when start of the pattern" do
|
177
|
+
config.pattern = "spec/**/a_spec.rb"
|
178
|
+
config.files_or_directories_to_run = "spec"
|
179
|
+
config.files_to_run.should eq(["spec/rspec/core/resources/a_spec.rb"])
|
180
|
+
end
|
181
|
+
|
182
|
+
it "does not prevent repitition of dir when later of the pattern" do
|
183
|
+
config.pattern = "rspec/**/a_spec.rb"
|
184
|
+
config.files_or_directories_to_run = "spec"
|
185
|
+
config.files_to_run.should eq(["spec/rspec/core/resources/a_spec.rb"])
|
151
186
|
end
|
152
187
|
|
153
188
|
context "with default pattern" do
|
154
189
|
it "loads files named _spec.rb" do
|
155
|
-
dir = "
|
156
|
-
config.files_or_directories_to_run =
|
157
|
-
config.files_to_run.should
|
190
|
+
dir = "spec/rspec/core/resources"
|
191
|
+
config.files_or_directories_to_run = "spec/rspec/core/resources"
|
192
|
+
config.files_to_run.should eq([ "spec/rspec/core/resources/a_spec.rb"])
|
158
193
|
end
|
159
194
|
|
160
195
|
it "loads files in Windows" do
|
161
196
|
file = "C:\\path\\to\\project\\spec\\sub\\foo_spec.rb"
|
162
197
|
config.files_or_directories_to_run = file
|
163
|
-
config.files_to_run.should
|
198
|
+
config.files_to_run.should eq([file])
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "with default default_path" do
|
203
|
+
it "loads files in the default path when run by rspec" do
|
204
|
+
config.stub(:command) { 'rspec' }
|
205
|
+
config.files_or_directories_to_run = []
|
206
|
+
config.files_to_run.should_not be_empty
|
207
|
+
end
|
208
|
+
|
209
|
+
it "does not load files in the default path when run by ruby" do
|
210
|
+
config.stub(:command) { 'ruby' }
|
211
|
+
config.files_or_directories_to_run = []
|
212
|
+
config.files_to_run.should be_empty
|
164
213
|
end
|
165
214
|
end
|
166
215
|
end
|
@@ -209,9 +258,9 @@ module RSpec::Core
|
|
209
258
|
end
|
210
259
|
|
211
260
|
describe "path with line number" do
|
212
|
-
it "assigns the line number as
|
261
|
+
it "assigns the line number as a location filter" do
|
213
262
|
config.files_or_directories_to_run = "path/to/a_spec.rb:37"
|
214
|
-
config.filter.should
|
263
|
+
config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37]}})
|
215
264
|
end
|
216
265
|
end
|
217
266
|
|
@@ -221,10 +270,42 @@ module RSpec::Core
|
|
221
270
|
config.full_description = "foo"
|
222
271
|
config.filter.should_not have_key(:focused)
|
223
272
|
end
|
273
|
+
end
|
224
274
|
|
225
|
-
|
226
|
-
|
227
|
-
|
275
|
+
context "with line number" do
|
276
|
+
|
277
|
+
it "assigns the file and line number as a location filter" do
|
278
|
+
config.files_or_directories_to_run = "path/to/a_spec.rb:37"
|
279
|
+
config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37]}})
|
280
|
+
end
|
281
|
+
|
282
|
+
it "assigns multiple files with line numbers as location filters" do
|
283
|
+
config.files_or_directories_to_run = "path/to/a_spec.rb:37", "other_spec.rb:44"
|
284
|
+
config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37],
|
285
|
+
File.expand_path("other_spec.rb") => [44]}})
|
286
|
+
end
|
287
|
+
|
288
|
+
it "assigns files with multiple line numbers as location filters" do
|
289
|
+
config.files_or_directories_to_run = "path/to/a_spec.rb:37", "path/to/a_spec.rb:44"
|
290
|
+
config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37, 44]}})
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
context "with multiple line numbers" do
|
295
|
+
it "assigns the file and line numbers as a location filter" do
|
296
|
+
config.files_or_directories_to_run = "path/to/a_spec.rb:1:3:5:7"
|
297
|
+
config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [1,3,5,7]}})
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
it "assigns the example name as the filter on description" do
|
302
|
+
config.full_description = "foo"
|
303
|
+
config.filter.should eq({:full_description => /foo/})
|
304
|
+
end
|
305
|
+
|
306
|
+
describe "#default_path" do
|
307
|
+
it 'defaults to "spec"' do
|
308
|
+
config.default_path.should eq('spec')
|
228
309
|
end
|
229
310
|
end
|
230
311
|
|
@@ -251,7 +332,7 @@ module RSpec::Core
|
|
251
332
|
|
252
333
|
group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
|
253
334
|
group.should_not respond_to(:you_call_this_a_blt?)
|
254
|
-
group.new.you_call_this_a_blt?.should
|
335
|
+
group.new.you_call_this_a_blt?.should eq("egad man, where's the mayo?!?!?")
|
255
336
|
end
|
256
337
|
end
|
257
338
|
|
@@ -263,7 +344,7 @@ module RSpec::Core
|
|
263
344
|
|
264
345
|
group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
|
265
346
|
group.should_not respond_to(:you_call_this_a_blt?)
|
266
|
-
group.new.you_call_this_a_blt?.should
|
347
|
+
group.new.you_call_this_a_blt?.should eq("egad man, where's the mayo?!?!?")
|
267
348
|
end
|
268
349
|
end
|
269
350
|
|
@@ -468,29 +549,29 @@ module RSpec::Core
|
|
468
549
|
describe "#filter_run" do
|
469
550
|
it_behaves_like "metadata hash builder" do
|
470
551
|
def metadata_hash(*args)
|
471
|
-
config.filter_run
|
552
|
+
config.filter_run(*args)
|
472
553
|
config.filter
|
473
554
|
end
|
474
555
|
end
|
475
556
|
|
476
557
|
it "sets the filter" do
|
477
558
|
config.filter_run :focus => true
|
478
|
-
config.filter[:focus].should
|
559
|
+
config.filter[:focus].should be(true)
|
479
560
|
end
|
480
561
|
|
481
562
|
it "merges with existing filters" do
|
482
563
|
config.filter_run :filter1 => true
|
483
564
|
config.filter_run :filter2 => false
|
484
565
|
|
485
|
-
config.filter[:filter1].should
|
486
|
-
config.filter[:filter2].should
|
566
|
+
config.filter[:filter1].should be(true)
|
567
|
+
config.filter[:filter2].should be(false)
|
487
568
|
end
|
488
569
|
|
489
|
-
it "warns if :
|
490
|
-
config.filter_run :
|
570
|
+
it "warns if :line_numbers is already a filter" do
|
571
|
+
config.filter_run :line_numbers => [100]
|
491
572
|
config.should_receive(:warn).with(
|
492
573
|
"Filtering by {:focus=>true} is not possible since you " \
|
493
|
-
"are already filtering by {:
|
574
|
+
"are already filtering by {:line_numbers=>[100]}"
|
494
575
|
)
|
495
576
|
config.filter_run :focus => true
|
496
577
|
end
|
@@ -508,22 +589,22 @@ module RSpec::Core
|
|
508
589
|
describe "#filter_run_excluding" do
|
509
590
|
it_behaves_like "metadata hash builder" do
|
510
591
|
def metadata_hash(*args)
|
511
|
-
config.filter_run_excluding
|
592
|
+
config.filter_run_excluding(*args)
|
512
593
|
config.exclusion_filter
|
513
594
|
end
|
514
595
|
end
|
515
596
|
|
516
597
|
it "sets the filter" do
|
517
598
|
config.filter_run_excluding :slow => true
|
518
|
-
config.exclusion_filter[:slow].should
|
599
|
+
config.exclusion_filter[:slow].should be(true)
|
519
600
|
end
|
520
601
|
|
521
602
|
it "merges with existing filters" do
|
522
603
|
config.filter_run_excluding :filter1 => true
|
523
604
|
config.filter_run_excluding :filter2 => false
|
524
605
|
|
525
|
-
config.exclusion_filter[:filter1].should
|
526
|
-
config.exclusion_filter[:filter2].should
|
606
|
+
config.exclusion_filter[:filter1].should be(true)
|
607
|
+
config.exclusion_filter[:filter2].should be(false)
|
527
608
|
end
|
528
609
|
end
|
529
610
|
|
@@ -574,24 +655,24 @@ module RSpec::Core
|
|
574
655
|
end
|
575
656
|
end
|
576
657
|
|
577
|
-
describe "
|
658
|
+
describe "line_numbers=" do
|
578
659
|
before { config.stub(:warn) }
|
579
660
|
|
580
|
-
it "sets the line
|
581
|
-
config.
|
582
|
-
config.filter.should
|
661
|
+
it "sets the line numbers" do
|
662
|
+
config.line_numbers = ['37']
|
663
|
+
config.filter.should eq({:line_numbers => [37]})
|
583
664
|
end
|
584
665
|
|
585
666
|
it "overrides :focused" do
|
586
667
|
config.filter_run :focused => true
|
587
|
-
config.
|
588
|
-
config.filter.should
|
668
|
+
config.line_numbers = ['37']
|
669
|
+
config.filter.should eq({:line_numbers => [37]})
|
589
670
|
end
|
590
671
|
|
591
672
|
it "prevents :focused" do
|
592
|
-
config.
|
673
|
+
config.line_numbers = ['37']
|
593
674
|
config.filter_run :focused => true
|
594
|
-
config.filter.should
|
675
|
+
config.filter.should eq({:line_numbers => [37]})
|
595
676
|
end
|
596
677
|
end
|
597
678
|
|
@@ -599,14 +680,14 @@ module RSpec::Core
|
|
599
680
|
context "given true" do
|
600
681
|
it "clears the backtrace clean patterns" do
|
601
682
|
config.full_backtrace = true
|
602
|
-
config.backtrace_clean_patterns.should
|
683
|
+
config.backtrace_clean_patterns.should eq([])
|
603
684
|
end
|
604
685
|
end
|
605
686
|
|
606
687
|
context "given false" do
|
607
688
|
it "restores backtrace clean patterns" do
|
608
689
|
config.full_backtrace = false
|
609
|
-
config.backtrace_clean_patterns.should
|
690
|
+
config.backtrace_clean_patterns.should eq(RSpec::Core::Configuration::DEFAULT_BACKTRACE_PATTERNS)
|
610
691
|
end
|
611
692
|
end
|
612
693
|
|
@@ -619,6 +700,23 @@ module RSpec::Core
|
|
619
700
|
end
|
620
701
|
end
|
621
702
|
|
703
|
+
describe "#cleaned_from_backtrace? defaults" do
|
704
|
+
it "returns true for rspec files" do
|
705
|
+
config.cleaned_from_backtrace?("lib/rspec/core.rb").
|
706
|
+
should be_true
|
707
|
+
end
|
708
|
+
|
709
|
+
it "returns true for spec_helper" do
|
710
|
+
config.cleaned_from_backtrace?("spec/spec_helper.rb").
|
711
|
+
should be_true
|
712
|
+
end
|
713
|
+
|
714
|
+
it "returns true for java files (for JRuby)" do
|
715
|
+
config.cleaned_from_backtrace?("org/jruby/RubyArray.java:2336").
|
716
|
+
should be_true
|
717
|
+
end
|
718
|
+
end
|
719
|
+
|
622
720
|
describe "#debug=true" do
|
623
721
|
before do
|
624
722
|
if defined?(Debugger)
|
@@ -733,12 +831,12 @@ module RSpec::Core
|
|
733
831
|
|
734
832
|
it "delegates the getter to the other option" do
|
735
833
|
config.another_custom_option = "this value"
|
736
|
-
config.custom_option.should
|
834
|
+
config.custom_option.should eq("this value")
|
737
835
|
end
|
738
836
|
|
739
837
|
it "delegates the setter to the other option" do
|
740
838
|
config.custom_option = "this value"
|
741
|
-
config.another_custom_option.should
|
839
|
+
config.another_custom_option.should eq("this value")
|
742
840
|
end
|
743
841
|
|
744
842
|
it "delegates the predicate to the other option" do
|
@@ -805,5 +903,18 @@ module RSpec::Core
|
|
805
903
|
end
|
806
904
|
end
|
807
905
|
|
906
|
+
describe "#reset" do
|
907
|
+
it "clears the reporter" do
|
908
|
+
config.reporter.should_not be_nil
|
909
|
+
config.reset
|
910
|
+
config.instance_variable_get("@reporter").should be_nil
|
911
|
+
end
|
912
|
+
|
913
|
+
it "clears the formatters" do
|
914
|
+
config.add_formatter "doc"
|
915
|
+
config.reset
|
916
|
+
config.formatters.should be_empty
|
917
|
+
end
|
918
|
+
end
|
808
919
|
end
|
809
920
|
end
|
@@ -9,7 +9,7 @@ describe "deprecations" do
|
|
9
9
|
|
10
10
|
it "returns RSpec" do
|
11
11
|
RSpec.stub(:warn_deprecation)
|
12
|
-
Spec.should
|
12
|
+
Spec.should eq(RSpec)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "doesn't include backward compatibility in const_missing backtrace" do
|
@@ -32,7 +32,7 @@ describe "deprecations" do
|
|
32
32
|
|
33
33
|
it "delegates to example" do
|
34
34
|
RSpec.stub(:warn_deprecation)
|
35
|
-
running_example.should
|
35
|
+
running_example.should eq(example)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "::DRbCommandLine", :
|
3
|
+
describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' do
|
4
4
|
let(:config) { RSpec::Core::Configuration.new }
|
5
5
|
let(:out) { StringIO.new }
|
6
6
|
let(:err) { StringIO.new }
|
@@ -41,14 +41,14 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
41
41
|
context "without RSPEC_DRB environment variable set" do
|
42
42
|
it "defaults to 8989" do
|
43
43
|
with_RSPEC_DRB_set_to(nil) do
|
44
|
-
command_line([]).drb_port.should
|
44
|
+
command_line([]).drb_port.should eq(8989)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
it "sets the DRb port" do
|
49
49
|
with_RSPEC_DRB_set_to(nil) do
|
50
|
-
command_line(["--drb-port", "1234"]).drb_port.should
|
51
|
-
command_line(["--drb-port", "5678"]).drb_port.should
|
50
|
+
command_line(["--drb-port", "1234"]).drb_port.should eq(1234)
|
51
|
+
command_line(["--drb-port", "5678"]).drb_port.should eq(5678)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -58,7 +58,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
58
58
|
context "without config variable set" do
|
59
59
|
it "uses RSPEC_DRB value" do
|
60
60
|
with_RSPEC_DRB_set_to('9000') do
|
61
|
-
command_line([]).drb_port.should
|
61
|
+
command_line([]).drb_port.should eq("9000")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -66,7 +66,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
66
66
|
context "and config variable set" do
|
67
67
|
it "uses configured value" do
|
68
68
|
with_RSPEC_DRB_set_to('9000') do
|
69
|
-
command_line(%w[--drb-port 5678]).drb_port.should
|
69
|
+
command_line(%w[--drb-port 5678]).drb_port.should eq(5678)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -28,12 +28,12 @@ module RSpec::Core
|
|
28
28
|
|
29
29
|
it 'processes string args as part of the description' do
|
30
30
|
group = ExampleGroup.describe("some", "separate", "strings")
|
31
|
-
group.description.should
|
31
|
+
group.description.should eq("some separate strings")
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'processes symbol args as part of the description' do
|
35
35
|
group = ExampleGroup.describe(:some, :separate, :symbols)
|
36
|
-
group.description.should
|
36
|
+
group.description.should eq("some separate symbols")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -48,7 +48,7 @@ module RSpec::Core
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'treats the first argument as part of the description when it is a symbol' do
|
51
|
-
group.description.should
|
51
|
+
group.description.should eq("symbol")
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -95,7 +95,7 @@ module RSpec::Core
|
|
95
95
|
describe("grandchild 2") {}
|
96
96
|
end
|
97
97
|
end
|
98
|
-
group.descendants.size.should
|
98
|
+
group.descendants.size.should eq(4)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -104,7 +104,7 @@ module RSpec::Core
|
|
104
104
|
it "is known by parent" do
|
105
105
|
parent = ExampleGroup.describe
|
106
106
|
child = parent.describe
|
107
|
-
parent.children.should
|
107
|
+
parent.children.should eq([child])
|
108
108
|
end
|
109
109
|
|
110
110
|
it "is not registered in world" do
|
@@ -112,7 +112,7 @@ module RSpec::Core
|
|
112
112
|
parent = ExampleGroup.describe
|
113
113
|
world.register(parent)
|
114
114
|
child = parent.describe
|
115
|
-
world.example_groups.should
|
115
|
+
world.example_groups.should eq([parent])
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -128,7 +128,7 @@ module RSpec::Core
|
|
128
128
|
group.stub(:world) { world }
|
129
129
|
all_examples = [ group.example("first"), group.example("second") ]
|
130
130
|
|
131
|
-
group.filtered_examples.should
|
131
|
+
group.filtered_examples.should eq(all_examples)
|
132
132
|
end
|
133
133
|
|
134
134
|
it "includes examples directly matching filter" do
|
@@ -140,7 +140,7 @@ module RSpec::Core
|
|
140
140
|
]
|
141
141
|
group.example("third (not-filtered)")
|
142
142
|
|
143
|
-
group.filtered_examples.should
|
143
|
+
group.filtered_examples.should eq(filtered_examples)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -163,7 +163,7 @@ module RSpec::Core
|
|
163
163
|
]
|
164
164
|
unfiltered_example = group.example("third (not-filtered)")
|
165
165
|
|
166
|
-
group.filtered_examples.should
|
166
|
+
group.filtered_examples.should eq([unfiltered_example])
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
@@ -239,7 +239,7 @@ module RSpec::Core
|
|
239
239
|
group = ExampleGroup.describe
|
240
240
|
group.stub(:world) { world }
|
241
241
|
example = group.example("does something")
|
242
|
-
group.filtered_examples.should
|
242
|
+
group.filtered_examples.should eq([example])
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -249,7 +249,7 @@ module RSpec::Core
|
|
249
249
|
group = ExampleGroup.describe
|
250
250
|
group.stub(:world) { world }
|
251
251
|
example = group.example("does something")
|
252
|
-
group.filtered_examples.should
|
252
|
+
group.filtered_examples.should eq([])
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
@@ -258,7 +258,7 @@ module RSpec::Core
|
|
258
258
|
|
259
259
|
context "with a constant as the first parameter" do
|
260
260
|
it "is that constant" do
|
261
|
-
ExampleGroup.describe(Object) { }.describes.should
|
261
|
+
ExampleGroup.describe(Object) { }.describes.should eq(Object)
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
@@ -308,7 +308,7 @@ module RSpec::Core
|
|
308
308
|
describe '#description' do
|
309
309
|
it "grabs the description from the metadata" do
|
310
310
|
group = ExampleGroup.describe(Object, "my desc") { }
|
311
|
-
group.description.should
|
311
|
+
group.description.should eq(group.metadata[:example_group][:description])
|
312
312
|
end
|
313
313
|
end
|
314
314
|
|
@@ -318,15 +318,15 @@ module RSpec::Core
|
|
318
318
|
end
|
319
319
|
|
320
320
|
it "adds the the file_path to metadata" do
|
321
|
-
ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].should
|
321
|
+
ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].should eq(__FILE__)
|
322
322
|
end
|
323
323
|
|
324
324
|
it "has a reader for file_path" do
|
325
|
-
ExampleGroup.describe(Object) { }.file_path.should
|
325
|
+
ExampleGroup.describe(Object) { }.file_path.should eq(__FILE__)
|
326
326
|
end
|
327
327
|
|
328
328
|
it "adds the line_number to metadata" do
|
329
|
-
ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].should
|
329
|
+
ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].should eq(__LINE__)
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|
@@ -454,7 +454,7 @@ module RSpec::Core
|
|
454
454
|
|
455
455
|
group.run
|
456
456
|
|
457
|
-
order.should
|
457
|
+
order.should eq([
|
458
458
|
:before_all_defined_in_config,
|
459
459
|
:top_level_before_all,
|
460
460
|
:before_each,
|
@@ -470,7 +470,7 @@ module RSpec::Core
|
|
470
470
|
:nested_after_all,
|
471
471
|
:top_level_after_all,
|
472
472
|
:after_all_defined_in_config
|
473
|
-
]
|
473
|
+
])
|
474
474
|
end
|
475
475
|
|
476
476
|
context "after(:all)" do
|
@@ -509,22 +509,22 @@ module RSpec::Core
|
|
509
509
|
it "treats an error in before(:each) as a failure" do
|
510
510
|
group = ExampleGroup.describe
|
511
511
|
group.before(:each) { raise "error in before each" }
|
512
|
-
example = group.example("equality") { 1.should
|
513
|
-
group.run.should
|
512
|
+
example = group.example("equality") { 1.should eq(2) }
|
513
|
+
group.run.should be(false)
|
514
514
|
|
515
|
-
example.metadata[:execution_result][:exception].message.should
|
515
|
+
example.metadata[:execution_result][:exception].message.should eq("error in before each")
|
516
516
|
end
|
517
517
|
|
518
518
|
it "treats an error in before(:all) as a failure" do
|
519
519
|
group = ExampleGroup.describe
|
520
520
|
group.before(:all) { raise "error in before all" }
|
521
|
-
example = group.example("equality") { 1.should
|
522
|
-
group.run.should
|
521
|
+
example = group.example("equality") { 1.should eq(2) }
|
522
|
+
group.run.should be_false
|
523
523
|
|
524
524
|
example.metadata.should_not be_nil
|
525
525
|
example.metadata[:execution_result].should_not be_nil
|
526
526
|
example.metadata[:execution_result][:exception].should_not be_nil
|
527
|
-
example.metadata[:execution_result][:exception].message.should
|
527
|
+
example.metadata[:execution_result][:exception].message.should eq("error in before all")
|
528
528
|
end
|
529
529
|
|
530
530
|
it "treats an error in before(:all) as a failure for a spec in a nested group" do
|
@@ -533,7 +533,7 @@ module RSpec::Core
|
|
533
533
|
before(:all) { raise "error in before all" }
|
534
534
|
|
535
535
|
describe "nested" do
|
536
|
-
example = it("equality") { 1.should
|
536
|
+
example = it("equality") { 1.should eq(2) }
|
537
537
|
end
|
538
538
|
end
|
539
539
|
group.run
|
@@ -541,7 +541,7 @@ module RSpec::Core
|
|
541
541
|
example.metadata.should_not be_nil
|
542
542
|
example.metadata[:execution_result].should_not be_nil
|
543
543
|
example.metadata[:execution_result][:exception].should_not be_nil
|
544
|
-
example.metadata[:execution_result][:exception].message.should
|
544
|
+
example.metadata[:execution_result][:exception].message.should eq("error in before all")
|
545
545
|
end
|
546
546
|
|
547
547
|
context "when an error occurs in an after(:all) hook" do
|
@@ -552,7 +552,7 @@ module RSpec::Core
|
|
552
552
|
let(:group) do
|
553
553
|
ExampleGroup.describe do
|
554
554
|
after(:all) { raise "error in after all" }
|
555
|
-
it("equality") { 1.should
|
555
|
+
it("equality") { 1.should eq(1) }
|
556
556
|
end
|
557
557
|
end
|
558
558
|
|
@@ -561,7 +561,7 @@ module RSpec::Core
|
|
561
561
|
example = group.examples.first
|
562
562
|
example.metadata.should_not be_nil
|
563
563
|
example.metadata[:execution_result].should_not be_nil
|
564
|
-
example.metadata[:execution_result][:status].should
|
564
|
+
example.metadata[:execution_result][:status].should eq("passed")
|
565
565
|
end
|
566
566
|
|
567
567
|
it "rescues the error and prints it out" do
|
@@ -576,7 +576,7 @@ module RSpec::Core
|
|
576
576
|
group.before(:all) { running_example = example }
|
577
577
|
group.example("no-op") { }
|
578
578
|
group.run
|
579
|
-
running_example.should
|
579
|
+
running_example.should be(nil)
|
580
580
|
end
|
581
581
|
|
582
582
|
it "has access to example options within before(:each)" do
|
@@ -585,7 +585,7 @@ module RSpec::Core
|
|
585
585
|
group.before(:each) { option = example.options[:data] }
|
586
586
|
group.example("no-op", :data => :sample) { }
|
587
587
|
group.run
|
588
|
-
option.should
|
588
|
+
option.should eq(:sample)
|
589
589
|
end
|
590
590
|
|
591
591
|
it "has access to example options within after(:each)" do
|
@@ -594,7 +594,7 @@ module RSpec::Core
|
|
594
594
|
group.after(:each) { option = example.options[:data] }
|
595
595
|
group.example("no-op", :data => :sample) { }
|
596
596
|
group.run
|
597
|
-
option.should
|
597
|
+
option.should eq(:sample)
|
598
598
|
end
|
599
599
|
|
600
600
|
it "has no 'running example' within after(:all)" do
|
@@ -603,7 +603,24 @@ module RSpec::Core
|
|
603
603
|
group.after(:all) { running_example = example }
|
604
604
|
group.example("no-op") { }
|
605
605
|
group.run
|
606
|
-
running_example.should
|
606
|
+
running_example.should be(nil)
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
610
|
+
matcher :add_a_pending_example_with do |method_name|
|
611
|
+
match do |group|
|
612
|
+
group = ExampleGroup.describe
|
613
|
+
group.send(method_name, "is pending") { }
|
614
|
+
group.run
|
615
|
+
group.examples.first.should be_pending
|
616
|
+
end
|
617
|
+
end
|
618
|
+
|
619
|
+
%w[pending xit xspecify xexample].each do |method_name|
|
620
|
+
describe "##{method_name}" do
|
621
|
+
it "generates a pending example" do
|
622
|
+
ExampleGroup.describe.should add_a_pending_example_with(method_name)
|
623
|
+
end
|
607
624
|
end
|
608
625
|
end
|
609
626
|
|
@@ -612,14 +629,7 @@ module RSpec::Core
|
|
612
629
|
it "allows adding an example using 'it'" do
|
613
630
|
group = ExampleGroup.describe
|
614
631
|
group.it("should do something") { }
|
615
|
-
group.examples.size.should
|
616
|
-
end
|
617
|
-
|
618
|
-
it "allows adding a pending example using 'xit'" do
|
619
|
-
group = ExampleGroup.describe
|
620
|
-
group.xit("is pending") { }
|
621
|
-
group.run
|
622
|
-
group.examples.first.should be_pending
|
632
|
+
group.examples.size.should eq(1)
|
623
633
|
end
|
624
634
|
|
625
635
|
it "exposes all examples at examples" do
|
@@ -635,9 +645,9 @@ module RSpec::Core
|
|
635
645
|
group.it("should 1") { }
|
636
646
|
group.it("should 2") { }
|
637
647
|
group.it("should 3") { }
|
638
|
-
group.examples[0].description.should
|
639
|
-
group.examples[1].description.should
|
640
|
-
group.examples[2].description.should
|
648
|
+
group.examples[0].description.should eq('should 1')
|
649
|
+
group.examples[1].description.should eq('should 2')
|
650
|
+
group.examples[2].description.should eq('should 3')
|
641
651
|
end
|
642
652
|
|
643
653
|
end
|
@@ -650,7 +660,7 @@ module RSpec::Core
|
|
650
660
|
end
|
651
661
|
|
652
662
|
it "sets the description to 'A sample nested describe'" do
|
653
|
-
example.example_group.description.should
|
663
|
+
example.example_group.description.should eq('A sample nested group')
|
654
664
|
end
|
655
665
|
|
656
666
|
it "has top level metadata from the example_group and its ancestors" do
|
@@ -670,8 +680,8 @@ module RSpec::Core
|
|
670
680
|
|
671
681
|
it "returns true if all examples pass" do
|
672
682
|
group = ExampleGroup.describe('group') do
|
673
|
-
example('ex 1') { 1.should
|
674
|
-
example('ex 2') { 1.should
|
683
|
+
example('ex 1') { 1.should eq(1) }
|
684
|
+
example('ex 2') { 1.should eq(1) }
|
675
685
|
end
|
676
686
|
group.stub(:filtered_examples) { group.examples }
|
677
687
|
group.run(reporter).should be_true
|
@@ -679,8 +689,8 @@ module RSpec::Core
|
|
679
689
|
|
680
690
|
it "returns false if any of the examples fail" do
|
681
691
|
group = ExampleGroup.describe('group') do
|
682
|
-
example('ex 1') { 1.should
|
683
|
-
example('ex 2') { 1.should
|
692
|
+
example('ex 1') { 1.should eq(1) }
|
693
|
+
example('ex 2') { 1.should eq(2) }
|
684
694
|
end
|
685
695
|
group.stub(:filtered_examples) { group.examples }
|
686
696
|
group.run(reporter).should be_false
|
@@ -688,8 +698,8 @@ module RSpec::Core
|
|
688
698
|
|
689
699
|
it "runs all examples, regardless of any of them failing" do
|
690
700
|
group = ExampleGroup.describe('group') do
|
691
|
-
example('ex 1') { 1.should
|
692
|
-
example('ex 2') { 1.should
|
701
|
+
example('ex 1') { 1.should eq(2) }
|
702
|
+
example('ex 2') { 1.should eq(1) }
|
693
703
|
end
|
694
704
|
group.stub(:filtered_examples) { group.examples }
|
695
705
|
group.filtered_examples.each do |example|
|
@@ -709,11 +719,11 @@ module RSpec::Core
|
|
709
719
|
end
|
710
720
|
|
711
721
|
it "can access a before each ivar at the same level" do
|
712
|
-
@before_each_top_level.should
|
722
|
+
@before_each_top_level.should eq('before_each_top_level')
|
713
723
|
end
|
714
724
|
|
715
725
|
it "can access a before all ivar at the same level" do
|
716
|
-
@before_all_top_level.should
|
726
|
+
@before_all_top_level.should eq('before_all_top_level')
|
717
727
|
end
|
718
728
|
|
719
729
|
it "can access the before all ivars in the before_all_ivars hash", :ruby => 1.8 do
|
@@ -726,11 +736,11 @@ module RSpec::Core
|
|
726
736
|
|
727
737
|
describe "but now I am nested" do
|
728
738
|
it "can access a parent example groups before each ivar at a nested level" do
|
729
|
-
@before_each_top_level.should
|
739
|
+
@before_each_top_level.should eq('before_each_top_level')
|
730
740
|
end
|
731
741
|
|
732
742
|
it "can access a parent example groups before all ivar at a nested level" do
|
733
|
-
@before_all_top_level.should
|
743
|
+
@before_all_top_level.should eq("before_all_top_level")
|
734
744
|
end
|
735
745
|
|
736
746
|
it "changes to before all ivars from within an example do not persist outside the current describe" do
|
@@ -739,7 +749,7 @@ module RSpec::Core
|
|
739
749
|
|
740
750
|
describe "accessing a before_all ivar that was changed in a parent example_group" do
|
741
751
|
it "does not have access to the modified version" do
|
742
|
-
@before_all_top_level.should
|
752
|
+
@before_all_top_level.should eq('before_all_top_level')
|
743
753
|
end
|
744
754
|
end
|
745
755
|
end
|
@@ -749,12 +759,12 @@ module RSpec::Core
|
|
749
759
|
describe "ivars are not shared across examples" do
|
750
760
|
it "(first example)" do
|
751
761
|
@a = 1
|
752
|
-
@b.should
|
762
|
+
defined?(@b).should be_false
|
753
763
|
end
|
754
764
|
|
755
765
|
it "(second example)" do
|
756
766
|
@b = 2
|
757
|
-
@a.should
|
767
|
+
defined?(@a).should be_false
|
758
768
|
end
|
759
769
|
end
|
760
770
|
|
@@ -769,7 +779,7 @@ module RSpec::Core
|
|
769
779
|
end
|
770
780
|
end
|
771
781
|
|
772
|
-
group.top_level_description.should
|
782
|
+
group.top_level_description.should eq("top")
|
773
783
|
end
|
774
784
|
end
|
775
785
|
|
@@ -826,7 +836,7 @@ module RSpec::Core
|
|
826
836
|
it "does something" do
|
827
837
|
# pass
|
828
838
|
end
|
829
|
-
describe
|
839
|
+
describe "nested" do
|
830
840
|
it "does something else" do
|
831
841
|
# pass
|
832
842
|
end
|
@@ -843,7 +853,7 @@ module RSpec::Core
|
|
843
853
|
it "does something (wrong - fail)" do
|
844
854
|
raise "fail"
|
845
855
|
end
|
846
|
-
describe
|
856
|
+
describe "nested" do
|
847
857
|
it "does something else" do
|
848
858
|
# pass
|
849
859
|
end
|
@@ -860,7 +870,7 @@ module RSpec::Core
|
|
860
870
|
it "does something" do
|
861
871
|
# pass
|
862
872
|
end
|
863
|
-
describe
|
873
|
+
describe "nested" do
|
864
874
|
it "does something else (wrong -fail)" do
|
865
875
|
raise "fail"
|
866
876
|
end
|
@@ -888,6 +898,15 @@ module RSpec::Core
|
|
888
898
|
end
|
889
899
|
group.run.should be_true
|
890
900
|
end
|
901
|
+
|
902
|
+
it "raises a helpful error message when shared context is not found" do
|
903
|
+
expect do
|
904
|
+
ExampleGroup.describe do
|
905
|
+
include_context "shared stuff"
|
906
|
+
end
|
907
|
+
end.to raise_error(ArgumentError,%q|Could not find shared context "shared stuff"|)
|
908
|
+
end
|
909
|
+
|
891
910
|
end
|
892
911
|
|
893
912
|
describe "#include_examples" do
|
@@ -904,7 +923,124 @@ module RSpec::Core
|
|
904
923
|
end
|
905
924
|
group.examples.first.description.should eq("does something")
|
906
925
|
end
|
926
|
+
|
927
|
+
it "raises a helpful error message when shared context is not found" do
|
928
|
+
expect do
|
929
|
+
ExampleGroup.describe do
|
930
|
+
include_examples "shared stuff"
|
931
|
+
end
|
932
|
+
end.to raise_error(ArgumentError,%q|Could not find shared examples "shared stuff"|)
|
933
|
+
end
|
907
934
|
end
|
908
935
|
|
936
|
+
describe "#it_should_behave_like" do
|
937
|
+
it "creates a nested group" do
|
938
|
+
shared_examples_for("thing") {}
|
939
|
+
group = ExampleGroup.describe('fake group')
|
940
|
+
group.it_should_behave_like("thing")
|
941
|
+
group.should have(1).children
|
942
|
+
end
|
943
|
+
|
944
|
+
it "creates a nested group for a class" do
|
945
|
+
klass = Class.new
|
946
|
+
shared_examples_for(klass) {}
|
947
|
+
group = ExampleGroup.describe('fake group')
|
948
|
+
group.it_should_behave_like(klass)
|
949
|
+
group.should have(1).children
|
950
|
+
end
|
951
|
+
|
952
|
+
it "adds shared examples to nested group" do
|
953
|
+
shared_examples_for("thing") do
|
954
|
+
it("does something")
|
955
|
+
end
|
956
|
+
group = ExampleGroup.describe('fake group')
|
957
|
+
shared_group = group.it_should_behave_like("thing")
|
958
|
+
shared_group.should have(1).examples
|
959
|
+
end
|
960
|
+
|
961
|
+
it "adds shared instance methods to nested group" do
|
962
|
+
shared_examples_for("thing") do
|
963
|
+
def foo; end
|
964
|
+
end
|
965
|
+
group = ExampleGroup.describe('fake group')
|
966
|
+
shared_group = group.it_should_behave_like("thing")
|
967
|
+
shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
|
968
|
+
end
|
969
|
+
|
970
|
+
it "adds shared class methods to nested group" do
|
971
|
+
shared_examples_for("thing") do
|
972
|
+
def self.foo; end
|
973
|
+
end
|
974
|
+
group = ExampleGroup.describe('fake group')
|
975
|
+
shared_group = group.it_should_behave_like("thing")
|
976
|
+
shared_group.methods.map{|m| m.to_s}.should include("foo")
|
977
|
+
end
|
978
|
+
|
979
|
+
context "given some parameters" do
|
980
|
+
it "passes the parameters to the shared example group" do
|
981
|
+
passed_params = {}
|
982
|
+
|
983
|
+
shared_examples_for("thing") do |param1, param2|
|
984
|
+
it("has access to the given parameters") do
|
985
|
+
passed_params[:param1] = param1
|
986
|
+
passed_params[:param2] = param2
|
987
|
+
end
|
988
|
+
end
|
989
|
+
|
990
|
+
group = ExampleGroup.describe("group") do
|
991
|
+
it_should_behave_like "thing", :value1, :value2
|
992
|
+
end
|
993
|
+
group.run
|
994
|
+
|
995
|
+
passed_params.should eq({ :param1 => :value1, :param2 => :value2 })
|
996
|
+
end
|
997
|
+
|
998
|
+
it "adds shared instance methods to nested group" do
|
999
|
+
shared_examples_for("thing") do |param1|
|
1000
|
+
def foo; end
|
1001
|
+
end
|
1002
|
+
group = ExampleGroup.describe('fake group')
|
1003
|
+
shared_group = group.it_should_behave_like("thing", :a)
|
1004
|
+
shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
it "evals the shared example group only once" do
|
1008
|
+
eval_count = 0
|
1009
|
+
shared_examples_for("thing") { |p| eval_count += 1 }
|
1010
|
+
group = ExampleGroup.describe('fake group')
|
1011
|
+
shared_group = group.it_should_behave_like("thing", :a)
|
1012
|
+
eval_count.should eq(1)
|
1013
|
+
end
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
context "given a block" do
|
1017
|
+
it "evaluates the block in nested group" do
|
1018
|
+
scopes = []
|
1019
|
+
shared_examples_for("thing") do
|
1020
|
+
it("gets run in the nested group") do
|
1021
|
+
scopes << self.class
|
1022
|
+
end
|
1023
|
+
end
|
1024
|
+
group = ExampleGroup.describe("group") do
|
1025
|
+
it_should_behave_like "thing" do
|
1026
|
+
it("gets run in the same nested group") do
|
1027
|
+
scopes << self.class
|
1028
|
+
end
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
group.run
|
1032
|
+
|
1033
|
+
scopes[0].should be(scopes[1])
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
it "raises a helpful error message when shared context is not found" do
|
1038
|
+
expect do
|
1039
|
+
ExampleGroup.describe do
|
1040
|
+
it_should_behave_like "shared stuff"
|
1041
|
+
end
|
1042
|
+
end.to raise_error(ArgumentError,%q|Could not find shared examples "shared stuff"|)
|
1043
|
+
end
|
1044
|
+
end
|
909
1045
|
end
|
910
1046
|
end
|