Skip to content
New issue

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

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

Already on GitHub? # to your account

Don't fail when there are no spec files to be run #234

Merged
merged 1 commit into from
Dec 26, 2013
Merged
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
4 changes: 2 additions & 2 deletions lib/guard/rspec/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def initialize(options = {})
def run_all
paths = options[:spec_paths]
options = @options.merge(@options[:run_all]).freeze
return if paths.empty?
return true if paths.empty?
::Guard::UI.info(options[:message], reset: true)
_run(true, paths, options)
end

def run(paths)
paths = inspector.paths(paths)
return if paths.empty?
return true if paths.empty?
::Guard::UI.info("Running: #{paths.join(' ')}", reset: true)
_run(false, paths, options)
end
Expand Down
34 changes: 30 additions & 4 deletions spec/lib/guard/rspec/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
end
end

shared_examples 'abort' do
it 'aborts' do
expect(Guard::UI).to_not receive(:info)
subject
end

it 'returns true' do
expect(subject).to be true
end
end

describe '#run_all' do
let(:options) { {
spec_paths: %w[spec1 spec2],
Expand All @@ -56,6 +67,17 @@
runner.run_all
end

context 'when no paths are given' do
subject { runner.run_all }

let(:options) { {
spec_paths: [],
run_all: { message: 'Custom message' }
} }

include_examples 'abort'
end

context 'with custom cmd' do
before {
options[:run_all][:cmd] = 'rspec -t ~slow'
Expand All @@ -82,10 +104,14 @@
runner.run(paths)
end

it 'returns if no paths are given' do
allow(inspector).to receive(:paths) { [] }
expect(Guard::UI).to_not receive(:info)
runner.run([])
context 'when no paths are given' do
subject { runner.run([]) }

before do
allow(inspector).to receive(:paths) { [] }
end

include_examples 'abort'
end

it 'builds commands with spec paths' do
Expand Down