Skip to content

Commit

Permalink
fixture autocompletion maintains whitespace prefix (ugh - no tests fo…
Browse files Browse the repository at this point in the history
…r this code)
  • Loading branch information
drnic committed May 29, 2008
1 parent 5055740 commit 8d29c78
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Support/bin/fixture_auto_complete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
def parse_line
current_line = TextMate.current_line
if RailsPath.new.file_type == :fixture
line_parts = current_line.split(":")
[:fixture] + line_parts.map { |p| p.strip }
if fixture_finder = current_line.match(/^([\s\t]+)\b([a-z_]+)\:([a-z_]*)/)
[:fixture] + fixture_finder[1..3]
end
else
if fixture_finder = current_line.match(/\b([a-z_]+)\(\:([a-z_]*)\)/)
[:test] + fixture_finder[1..2]
if fixture_finder = current_line.match(/^([\s\t]+).*\b([a-z_]+)\(\:([a-z_]*)\)/)
[:test] + fixture_finder[1..3]
end
end
end
Expand Down Expand Up @@ -51,7 +52,7 @@ def filter_fixtures(fixtures, filter)
end
end

filetype, ref, filter = parse_line
filetype, start_line_gap, ref, filter = parse_line
filter = "" if filter.nil?
foreign_fixtures = load_referenced_fixture_file(ref).keys
candidates = filter_fixtures(foreign_fixtures, filter)
Expand All @@ -71,8 +72,8 @@ def filter_fixtures(fixtures, filter)
print selected_fixture
else
if filetype == :fixture
print " #{ref}: #{selected_fixture}"
print "#{start_line_gap}#{ref}: #{selected_fixture}"
else
print " @#{Inflector.singularize ref} = #{ref}(:#{selected_fixture})"
print "#{start_line_gap}@#{Inflector.singularize ref} = #{ref}(:#{selected_fixture})"
end
end

0 comments on commit 8d29c78

Please sign in to comment.