|
191 | 191 | end |
192 | 192 | end |
193 | 193 |
|
| 194 | + context "with a custom results file" do |
| 195 | + let(:options) do |
| 196 | + { cmd: "rspec", results_file: results_file }.merge(chdir_options) |
| 197 | + end |
| 198 | + |
| 199 | + context "with no chdir option" do |
| 200 | + let(:chdir_options) { {} } |
| 201 | + |
| 202 | + context "when the path is relative" do |
| 203 | + let(:results_file) { "foobar.txt" } |
| 204 | + it "uses the given file" do |
| 205 | + expect(Guard::RSpec::RSpecProcess).to receive(:new). |
| 206 | + with(anything, results_file).and_return(process) |
| 207 | + runner.run(paths) |
| 208 | + end |
| 209 | + end |
| 210 | + |
| 211 | + context "when the path is absolute" do |
| 212 | + let(:results_file) { "/foo/foobar.txt" } |
| 213 | + it "uses the given path" do |
| 214 | + expect(Guard::RSpec::RSpecProcess).to receive(:new). |
| 215 | + with(anything, results_file).and_return(process) |
| 216 | + runner.run(paths) |
| 217 | + end |
| 218 | + end |
| 219 | + end |
| 220 | + |
| 221 | + context "with chdir option" do |
| 222 | + let(:chdir_options) { { chdir: "moduleA" } } |
| 223 | + |
| 224 | + context "when the path is relative" do |
| 225 | + let(:results_file) { "foobar.txt" } |
| 226 | + |
| 227 | + it "uses a path relative to chdir" do |
| 228 | + expect(Guard::RSpec::RSpecProcess).to receive(:new). |
| 229 | + with(anything, "moduleA/foobar.txt").and_return(process) |
| 230 | + runner.run(paths) |
| 231 | + end |
| 232 | + end |
| 233 | + |
| 234 | + context "when the path is absolute" do |
| 235 | + let(:results_file) { "/foo/foobar.txt" } |
| 236 | + it "uses the full given path anyway" do |
| 237 | + expect(Guard::RSpec::RSpecProcess).to receive(:new). |
| 238 | + with(anything, results_file).and_return(process) |
| 239 | + runner.run(paths) |
| 240 | + end |
| 241 | + end |
| 242 | + end |
| 243 | + end |
| 244 | + |
| 245 | + context "with no custom results file" do |
| 246 | + let(:options) { { cmd: "rspec" } } |
| 247 | + it "uses the default" do |
| 248 | + expect(Guard::RSpec::RSpecProcess).to receive(:new). |
| 249 | + with(anything, "tmp/rspec_guard_result").and_return(process) |
| 250 | + runner.run(paths) |
| 251 | + end |
| 252 | + end |
| 253 | + |
194 | 254 | it "notifies inspector about failed paths" do |
195 | 255 | expect(inspector).to receive(:failed).with([]) |
196 | 256 | runner.run(paths) |
|
225 | 285 | runner.run(paths) |
226 | 286 | end |
227 | 287 | end |
228 | | - |
229 | | - # TODO: remove / cleanup |
230 | | - describe "_tmp_file" do |
231 | | - subject { described_class.new.send(:_tmp_file, chdir) } |
232 | | - |
233 | | - context "with no chdir option" do |
234 | | - let(:chdir) { nil } |
235 | | - it { is_expected.to eq("tmp/rspec_guard_result") } |
236 | | - end |
237 | | - |
238 | | - context "chdir option" do |
239 | | - let(:chdir) { "moduleA" } |
240 | | - it { is_expected.to eq("moduleA/tmp/rspec_guard_result") } |
241 | | - end |
242 | | - end |
243 | 288 | end |
0 commit comments