Skip to content

Commit

Permalink
Konacha::Runner checks test files existence with absolute paths to
Browse files Browse the repository at this point in the history
prevent invalid path issue when used in a Rails engine
  • Loading branch information
lcoq committed Feb 27, 2014
1 parent 788335c commit 9f6867f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/guard/konacha/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def konacha_path(path)
end

def real_path(path)
::Konacha.config[:spec_dir] + konacha_path(path) + (path[/\.js(\.coffee)?$/] || '')
Rails.root.join(::Konacha.config[:spec_dir] + konacha_path(path) + (path[/\.js(\.coffee)?$/] || '')).to_s
end

def unique_id
Expand Down
10 changes: 9 additions & 1 deletion spec/guard/konacha/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@

before do
runner.stub(:runner) { konacha_runner }
File.stub(:exists?) { true }
konacha_formatter.stub(:any?) { true }
end

it 'should run each path through runner and format results' do
File.stub(:exists?) { true }
runner.stub(:formatter) { konacha_formatter }
konacha_formatter.should_receive(:reset)
konacha_runner.should_receive(:run).with('/1')
Expand All @@ -58,6 +58,14 @@
runner.run(['spec/javascripts/1.js', 'spec/javascripts/foo/bar.js'])
end

it 'should run each path with a valid extension' do
File.should_receive(:exists?).with(Rails.root.join('spec/javascripts/1.js').to_s).and_return(true)
File.should_receive(:exists?).with(Rails.root.join('spec/javascripts/foo/bar.js.coffee').to_s).and_return(true)
konacha_runner.should_receive(:run).with('/1')
konacha_runner.should_receive(:run).with('/foo/bar')
runner.run(['spec/javascripts/1.js', 'spec/javascripts/foo/bar.js.coffee'])
end

it 'should run when called with no arguemnts' do
runner.stub(:formatter) { konacha_formatter }
konacha_formatter.should_receive(:write_summary)
Expand Down

0 comments on commit 9f6867f

Please sign in to comment.