|
4 | 4 |
|
5 | 5 | Then /^the output should contain all of these:$/ do |table|
|
6 | 6 | table.raw.flatten.each do |string|
|
7 |
| - assert_partial_output(string, all_output) |
| 7 | + expect(all_output).to include(string) |
8 | 8 | end
|
9 | 9 | end
|
10 | 10 |
|
|
28 | 28 | step %q{the exit status should be 0}
|
29 | 29 | end
|
30 | 30 |
|
31 |
| -Then /^it should pass with "(.*?)"$/ do |string| |
32 |
| - step %Q{the output should contain "#{string}"} |
33 |
| - step %q{the exit status should be 0} |
34 |
| -end |
35 |
| - |
36 | 31 | Then /^the example(?:s)? should(?: all)? fail$/ do
|
37 | 32 | step %q{the output should not contain "0 examples"}
|
38 | 33 | step %q{the output should not contain "0 failures"}
|
|
98 | 93 | end
|
99 | 94 |
|
100 | 95 | Given /^I have a brand new project with no files$/ do
|
101 |
| - in_current_dir do |
| 96 | + cd('.') do |
102 | 97 | expect(Dir["**/*"]).to eq([])
|
103 | 98 | end
|
104 | 99 | end
|
105 | 100 |
|
106 | 101 | Given /^I have run `([^`]*)`$/ do |cmd|
|
107 |
| - fail_on_error = true |
108 |
| - run_simple(unescape(cmd), fail_on_error) |
| 102 | + run_command_and_stop(sanitize_text(cmd), :fail_on_error => true) |
109 | 103 | end
|
110 | 104 |
|
111 | 105 | Given(/^a vendored gem named "(.*?)" containing a file named "(.*?)" with:$/) do |gem_name, file_name, file_contents|
|
112 | 106 | gem_dir = "vendor/#{gem_name}-1.2.3"
|
113 | 107 | step %Q{a file named "#{gem_dir}/#{file_name}" with:}, file_contents
|
114 |
| - set_env('RUBYOPT', ENV['RUBYOPT'] + " -I#{gem_dir}/lib") |
| 108 | + set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + " -I#{gem_dir}/lib") |
115 | 109 | end
|
116 | 110 |
|
117 | 111 | When "I accept the recommended settings by removing `=begin` and `=end` from `spec/spec_helper.rb`" do
|
118 |
| - in_current_dir do |
| 112 | + cd('.') do |
119 | 113 | spec_helper = File.read("spec/spec_helper.rb")
|
120 | 114 | expect(spec_helper).to include("=begin", "=end")
|
121 | 115 |
|
|
138 | 132 | end
|
139 | 133 |
|
140 | 134 | When(/^I fix "(.*?)" by replacing "(.*?)" with "(.*?)"$/) do |file_name, original, replacement|
|
141 |
| - in_current_dir do |
| 135 | + cd('.') do |
142 | 136 | contents = File.read(file_name)
|
143 | 137 | expect(contents).to include(original)
|
144 | 138 | fixed = contents.sub(original, replacement)
|
145 | 139 | File.open(file_name, "w") { |f| f.write(fixed) }
|
146 | 140 | end
|
147 | 141 | end
|
148 | 142 |
|
149 |
| -Then(/^it should fail with "(.*?)"$/) do |snippet| |
150 |
| - assert_failing_with(snippet) |
151 |
| -end |
152 |
| - |
153 | 143 | Given(/^I have not configured `example_status_persistence_file_path`$/) do
|
154 |
| - in_current_dir do |
| 144 | + cd('.') do |
155 | 145 | return unless File.exist?("spec/spec_helper.rb")
|
156 | 146 | return unless File.read("spec/spec_helper.rb").include?("example_status_persistence_file_path")
|
157 | 147 | File.open("spec/spec_helper.rb", "w") { |f| f.write("") }
|
|
173 | 163 | end
|
174 | 164 |
|
175 | 165 | Then(/^bisect should (succeed|fail) with output like:$/) do |succeed, expected_output|
|
176 |
| - last_process = only_processes.last |
| 166 | + last_process = all_commands.last |
177 | 167 | expected_status = succeed == "succeed" ? 0 : 1
|
178 |
| - expect(last_exit_status).to eq(expected_status), |
179 |
| - "Expected exit status of #{expected_status} but got #{last_exit_status} \n\n" \ |
| 168 | + expect(last_process.exit_status).to eq(expected_status), |
| 169 | + "Expected exit status of #{expected_status} but got #{last_process.exit_status} \n\n" \ |
180 | 170 | "Output:\n\n#{last_process.stdout}"
|
181 | 171 |
|
182 | 172 | expected = normalize_durations(expected_output)
|
|
191 | 181 | end
|
192 | 182 |
|
193 | 183 | When(/^I run `([^`]+)` and abort in the middle with ctrl\-c$/) do |cmd|
|
194 |
| - set_env('RUBYOPT', ENV['RUBYOPT'] + " -r#{File.expand_path("../../support/send_sigint_during_bisect.rb", __FILE__)}") |
| 184 | + set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + " -r#{File.expand_path("../../support/send_sigint_during_bisect.rb", __FILE__)}") |
195 | 185 | step "I run `#{cmd}`"
|
196 | 186 | end
|
197 | 187 |
|
|
218 | 208 | # - "Nested" group listed (it should be the outer group)
|
219 | 209 | # - The example group class name is listed (it should be the location)
|
220 | 210 |
|
221 |
| - expect(all_output).not_to match(/nested/i) |
222 |
| - expect(all_output).not_to match(/inf/i) |
223 |
| - expect(all_output).not_to match(/\b0 examples/i) |
| 211 | + output = all_output |
| 212 | + |
| 213 | + expect(output).not_to match(/nested/i) |
| 214 | + expect(output).not_to match(/inf/i) |
| 215 | + expect(output).not_to match(/\b0 examples/i) |
224 | 216 |
|
225 | 217 | seconds = '\d+(?:\.\d+)? seconds'
|
226 | 218 |
|
227 |
| - expect(all_output).to match( |
| 219 | + expect(output).to match( |
228 | 220 | %r{Top 1 slowest example groups?:\n\s+slow before context hook\n\s+#{seconds} average \(#{seconds} / 1 example\) \./spec/example_spec\.rb:1}
|
229 | 221 | )
|
230 | 222 | end
|
231 | 223 |
|
232 | 224 | Given(/^I have changed `([^`]+)` to `([^`]+)` in "(.*?)"$/) do |old_code, new_code, file_name|
|
233 |
| - in_current_dir do |
| 225 | + cd('.') do |
234 | 226 | file_content = File.read(file_name)
|
235 | 227 | expect(file_content).to include(old_code)
|
236 | 228 | new_file_content = file_content.sub(old_code, new_code)
|
|
0 commit comments