Browse files

Do not search focus tag in files that already have a line number on r…

…erun.
  • Loading branch information...
1 parent a212b12 commit e94a22c0d4b9b09a351e880eaf7c9b9fba293a38 @netzpirat committed Jan 15, 2013
Showing with 17 additions and 5 deletions.
  1. +4 −0 CHANGELOG.md
  2. +2 −2 lib/guard/cucumber/focuser.rb
  3. +11 −3 spec/guard/cucumber/focuser_spec.rb
View
4 CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## Master
+
+- Do not search focus tag in files that already have a line number on rerun.
+
## 1.3.1 - Jan 7, 2013
- [#7][]: Fix `run_all` with enabled focus option. ([@martco][])
View
4 lib/guard/cucumber/focuser.rb
@@ -51,9 +51,9 @@ def focus(paths, focus_tag)
# @return [Array<Integer>] the line numbers that include the focus tag in path
#
def scan_path_for_focus_tag(path, focus_tag)
- line_numbers = []
+ return [] if File.directory?(path) || path.include?(':')
- return line_numbers if File.directory?(path)
+ line_numbers = []
File.open(path, 'r') do |file|
while (line = file.gets)
View
14 spec/guard/cucumber/focuser_spec.rb
@@ -6,9 +6,9 @@
let(:focus_tag) { '@focus' }
let(:null_device) { RUBY_PLATFORM.index('mswin') ? 'NUL' : '/dev/null' }
- let(:dir) { 'features' }
- let(:path) { 'foo.feature' }
- let(:path_two) { 'bar.feature' }
+ let(:dir) { 'features' }
+ let(:path) { 'foo.feature' }
+ let(:path_two) { 'bar.feature' }
describe '.focus' do
context 'when passed an empty paths list' do
@@ -115,6 +115,14 @@
end
end
+ context 'file that has already a line number' do
+ let(:path) { 'bar.feature:12' }
+
+ it 'returns an empty array' do
+ File.should_not_receive(:open).with(path, 'r')
+ focuser.scan_path_for_focus_tag(path, focus_tag).should eql([])
+ end
+ end
end
describe '.append_line_numbers_to_path' do

0 comments on commit e94a22c

Please sign in to comment.