Navigation Menu

Skip to content

Commit

Permalink
Show views related to test/spec at the top of the list
Browse files Browse the repository at this point in the history
With Test::Unit, view tests are found in the controller test file, so the best we can do is to show all views for the controller associated with the currently active controller spec at the top of the list.

RSpec, on the other hand, uses separate view specs, so here we can show the particular view associated with the currently active spec at the top of the list.
  • Loading branch information
noklesta committed Jul 8, 2012
1 parent 444e812 commit b433791
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions SublimeRailsNav.py
Expand Up @@ -201,6 +201,21 @@ def construct_related_file_name_pattern(self, current_file):
pattern = re.sub(self.CONTROLLER_DIR, self.VIEW_DIR, current_file)
pattern = re.sub(r'(\w+)_controller\.\w+$', '\g<1>' + os.sep, pattern)
return pattern
elif self.test_type == 'test' and self.controller_test_dir in current_file:
# With Test::Unit, view tests are found in the controller test
# file, so the best we can do is to show all views for the
# controller associated with the currently active controller test
# at the top of the list.
pattern = re.sub(self.controller_test_dir, self.VIEW_DIR, current_file)
pattern = re.sub(r'(\w+)_controller_test\.rb$', '\g<1>' + os.sep, pattern)
return pattern
elif self.test_type == 'spec' and self.view_test_dir in current_file:
# RSpec uses separate view specs, so here we can show the
# particular view associated with the currently active spec at the
# top of the list.
pattern = re.sub(self.view_test_dir, self.VIEW_DIR, current_file)
pattern = re.sub(r'(\w+)\.[\w\.]+$', '\g<1>\.', pattern)
return pattern
else:
return None

Expand Down

0 comments on commit b433791

Please sign in to comment.