Skip to content

Commit

Permalink
Run on additions, not just modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDaugherty committed Feb 19, 2021
1 parent 1cf25c7 commit 3e3e1c4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/guard/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def run_on_modifications(paths)
_throw_if_failed { runner.run(paths) }
end

alias run_on_additions run_on_modifications

private

def _throw_if_failed
Expand Down
19 changes: 19 additions & 0 deletions spec/lib/guard/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,23 @@
plugin.run_on_modifications(paths)
end
end

describe "#run_on_additions" do
let(:paths) { %w[path1 path2] }
it "runs all specs via runner" do
expect(runner).to receive(:run).with(paths) { true }
plugin.run_on_additions(paths)
end

it "does nothing if paths empty" do
expect(runner).to_not receive(:run)
plugin.run_on_additions([])
end

it "throws task_has_failed if runner return false" do
allow(runner).to receive(:run) { false }
expect(plugin).to receive(:throw).with(:task_has_failed)
plugin.run_on_additions(paths)
end
end
end

0 comments on commit 3e3e1c4

Please sign in to comment.