Skip to content

Commit 76f3565

Browse files
Run on additions, not just modifications
1 parent 1cf25c7 commit 76f3565

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/guard/rspec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def run_on_modifications(paths)
4242
_throw_if_failed { runner.run(paths) }
4343
end
4444

45+
alias_method :run_on_additions, :run_on_modifications
46+
4547
private
4648

4749
def _throw_if_failed

spec/lib/guard/rspec_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,23 @@
8888
plugin.run_on_modifications(paths)
8989
end
9090
end
91+
92+
describe "#run_on_additions" do
93+
let(:paths) { %w(path1 path2) }
94+
it "runs all specs via runner" do
95+
expect(runner).to receive(:run).with(paths) { true }
96+
plugin.run_on_additions(paths)
97+
end
98+
99+
it "does nothing if paths empty" do
100+
expect(runner).to_not receive(:run)
101+
plugin.run_on_additions([])
102+
end
103+
104+
it "throws task_has_failed if runner return false" do
105+
allow(runner).to receive(:run) { false }
106+
expect(plugin).to receive(:throw).with(:task_has_failed)
107+
plugin.run_on_additions(paths)
108+
end
109+
end
91110
end

0 commit comments

Comments
 (0)