5
5
before { clean_current_dir }
6
6
7
7
it 'prints a rerun command for shared examples in external files that works to rerun' do
8
- write_file "spec/support/shared_examples.rb" , "" "
8
+ write_file "spec/support/shared_examples.rb" , "
9
9
RSpec.shared_examples 'with a failing example' do
10
10
example { expect(1).to eq(2) } # failing
11
11
example { expect(2).to eq(2) } # passing
12
12
end
13
- " ""
13
+ "
14
14
15
- write_file "spec/host_group_spec.rb" , "" "
15
+ write_file "spec/host_group_spec.rb" , "
16
16
load File.expand_path('../support/shared_examples.rb', __FILE__)
17
17
18
18
RSpec.describe 'A group with shared examples' do
22
22
RSpec.describe 'A group with a passing example' do
23
23
example { expect(1).to eq(1) }
24
24
end
25
- " ""
25
+ "
26
26
27
27
run_command ""
28
28
expect ( last_cmd_stdout ) . to include ( "3 examples, 1 failure" )
@@ -40,7 +40,7 @@ def run_rerun_command_for_failing_spec
40
40
41
41
context "with a shared example containing a context in a separate file" do
42
42
it "runs the example nested inside the shared" do
43
- write_file_formatted 'spec/shared_example.rb' , "" "
43
+ write_file_formatted 'spec/shared_example.rb' , "
44
44
RSpec.shared_examples_for 'a shared example' do
45
45
it 'succeeds' do
46
46
end
@@ -50,15 +50,15 @@ def run_rerun_command_for_failing_spec
50
50
end
51
51
end
52
52
end
53
- " ""
53
+ "
54
54
55
- write_file_formatted 'spec/simple_spec.rb' , "" "
55
+ write_file_formatted 'spec/simple_spec.rb' , "
56
56
require File.join(File.dirname(__FILE__), 'shared_example.rb')
57
57
58
58
RSpec.describe 'top level' do
59
59
it_behaves_like 'a shared example'
60
60
end
61
- " ""
61
+ "
62
62
63
63
run_command 'spec/simple_spec.rb:3 -fd'
64
64
expect ( last_cmd_stdout ) . to match ( /2 examples, 0 failures/ )
@@ -67,7 +67,7 @@ def run_rerun_command_for_failing_spec
67
67
68
68
context "passing a line-number filter" do
69
69
it "trumps exclusions, except for :if/:unless (which are absolute exclusions)" do
70
- write_file_formatted 'spec/a_spec.rb' , "" "
70
+ write_file_formatted 'spec/a_spec.rb' , "
71
71
RSpec.configure do |c|
72
72
c.filter_run_excluding :slow
73
73
end
@@ -82,7 +82,7 @@ def run_rerun_command_for_failing_spec
82
82
example('ex 4', :slow ) { }
83
83
example('ex 5', :if => false) { }
84
84
end
85
- " ""
85
+ "
86
86
87
87
run_command "spec/a_spec.rb -fd"
88
88
expect ( last_cmd_stdout ) . to include ( "1 example, 0 failures" , "ex 3" ) . and exclude ( "ex 1" , "ex 2" , "ex 4" , "ex 5" )
@@ -100,14 +100,14 @@ def run_rerun_command_for_failing_spec
100
100
101
101
context "passing a line-number-filtered file and a non-filtered file" do
102
102
it "applies the line number filtering only to the filtered file, running all specs in the non-filtered file except excluded ones" do
103
- write_file_formatted "spec/file_1_spec.rb" , "" "
103
+ write_file_formatted "spec/file_1_spec.rb" , "
104
104
RSpec.describe 'File 1' do
105
105
it('passes') { }
106
106
it('fails') { fail }
107
107
end
108
- " ""
108
+ "
109
109
110
- write_file_formatted "spec/file_2_spec.rb" , "" "
110
+ write_file_formatted "spec/file_2_spec.rb" , "
111
111
RSpec.configure do |c|
112
112
c.filter_run_excluding :exclude_me
113
113
end
@@ -117,7 +117,7 @@ def run_rerun_command_for_failing_spec
117
117
it('passes') { }
118
118
it('fails', :exclude_me) { fail }
119
119
end
120
- " ""
120
+ "
121
121
122
122
run_command "spec/file_1_spec.rb:2 spec/file_2_spec.rb -fd"
123
123
expect ( last_cmd_stdout ) . to match ( /3 examples, 0 failures/ )
@@ -127,21 +127,21 @@ def run_rerun_command_for_failing_spec
127
127
128
128
context "passing example ids at the command line" do
129
129
it "selects matching examples" do
130
- write_file_formatted "spec/file_1_spec.rb" , "" "
130
+ write_file_formatted "spec/file_1_spec.rb" , "
131
131
RSpec.describe 'File 1' do
132
132
1.upto(3) do |i|
133
133
example('ex ' + i.to_s) { expect(i).to be_odd }
134
134
end
135
135
end
136
- " ""
136
+ "
137
137
138
- write_file_formatted "spec/file_2_spec.rb" , "" "
138
+ write_file_formatted "spec/file_2_spec.rb" , "
139
139
RSpec.describe 'File 2' do
140
140
1.upto(3) do |i|
141
141
example('ex ' + i.to_s) { expect(i).to be_even }
142
142
end
143
143
end
144
- " ""
144
+ "
145
145
146
146
# Using the form that Metadata.relative_path returns...
147
147
run_command "./spec/file_1_spec.rb[1:1,1:3] ./spec/file_2_spec.rb[1:2]"
@@ -162,7 +162,7 @@ def run_rerun_command_for_failing_spec
162
162
end
163
163
164
164
it "selects matching example groups" do
165
- write_file_formatted "spec/file_1_spec.rb" , "" "
165
+ write_file_formatted "spec/file_1_spec.rb" , "
166
166
RSpec.describe 'Group 1' do
167
167
example { fail }
168
168
@@ -175,7 +175,7 @@ def run_rerun_command_for_failing_spec
175
175
example { fail }
176
176
end
177
177
end
178
- " ""
178
+ "
179
179
180
180
run_command "./spec/file_1_spec.rb[1:2]"
181
181
expect ( last_cmd_stdout ) . to match ( /2 examples, 0 failures/ )
0 commit comments