Skip to content

Commit

Permalink
Merge pull request #234 from yujinakayama/dont-fail-with-no-target-file
Browse files Browse the repository at this point in the history
Don't fail when there are no spec files to run
  • Loading branch information
thibaudgg committed Dec 26, 2013
2 parents 6e756dc + 53865bd commit 900eb21
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
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

0 comments on commit 900eb21

Please # to comment.