Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run on additions, not just modifications #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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