Skip to content
This repository
Browse code

Added RunLastRubyTest class to run_ruby_test.py. Added menu items and…

… context items to run last test
  • Loading branch information...
commit 1c4abd4b4381469ca7e7cbd6c0fe59f4aada997a 1 parent aeeb4ac
Jonathan Eatherly authored
1  Context.sublime-menu
@@ -6,6 +6,7 @@
6 6
       [
7 7
         { "caption": "Run single test / scenario / spec", "command": "run_single_ruby_test" },
8 8
         { "caption": "Run all tests / feature / full spec", "command": "run_all_ruby_test" },
  9
+        { "caption": "Run last test(s) / feature / spec", "command": "run_last_ruby_test" },
9 10
         { "caption": "-" },
10 11
         { "caption": "Show test panel", "command": "show_test_panel" },
11 12
         { "caption": "-" },
1  Default (Linux).sublime-keymap
... ...
@@ -1,6 +1,7 @@
1 1
 [
2 2
   { "keys": ["ctrl+shift+r"], "command": "run_single_ruby_test" }, // single test
3 3
   { "keys": ["ctrl+shift+t"], "command": "run_all_ruby_test" }, // test file
  4
+  { "keys": ["ctrl+shift+e"], "command": "run_last_ruby_test" }, // test file
4 5
 
5 6
   { "keys": ["ctrl+shift+x"], "command": "show_test_panel" }, // show test panel
6 7
 
1  Default (OSX).sublime-keymap
... ...
@@ -1,6 +1,7 @@
1 1
 [
2 2
   { "keys": ["super+shift+r"], "command": "run_single_ruby_test" }, // single test
3 3
   { "keys": ["super+shift+t"], "command": "run_all_ruby_test" }, // test file
  4
+  { "keys": ["super+shift+e"], "command": "run_last_ruby_test" }, // test file
4 5
 
5 6
   { "keys": ["super+shift+x"], "command": "show_test_panel" }, // show test panel
6 7
 
1  Default (Windows).sublime-keymap
... ...
@@ -1,6 +1,7 @@
1 1
 [
2 2
   { "keys": ["ctrl+shift+r"], "command": "run_single_ruby_test" }, // single test
3 3
   { "keys": ["ctrl+shift+t"], "command": "run_all_ruby_test" }, // test file
  4
+  { "keys": ["ctrl+shift+e"], "command": "run_last_ruby_test" }, // test file
4 5
 
5 6
   { "keys": ["ctrl+shift+x"], "command": "show_test_panel" }, // show test panel
6 7
 
1  Main.sublime-menu
@@ -9,6 +9,7 @@
9 9
             [
10 10
               { "caption": "Run single test / scenario / spec", "command": "run_single_ruby_test" },
11 11
               { "caption": "Run all tests / feature / full spec", "command": "run_all_ruby_test" },
  12
+              { "caption": "Run last tests / feature / spec", "command": "run_last_ruby_test" },
12 13
               { "caption": "-" },
13 14
               { "caption": "Show test panel", "command": "show_test_panel" },
14 15
               { "caption": "-" },
1  README.md
Source Rendered
@@ -36,6 +36,7 @@ Usage
36 36
 
37 37
  - Run single ruby test: Command-Shift-R
38 38
  - Run all ruby tests from current file: Command-Shift-T
  39
+ - Run last ruby test(s): Command-Shift-E
39 40
  - Show test panel: Command-Shift-X
40 41
  - Check RB, ERB file syntax: Alt+Shift+V
41 42
 
4  RubyTest.last-run
... ...
@@ -0,0 +1,4 @@
  1
+{
  2
+  "last_test_run": "",
  3
+  "last_test_file": ""
  4
+}
24  run_ruby_test.py
@@ -67,6 +67,13 @@ def load_config(self):
67 67
     global CUCUMBER_UNIT_FOLDER; CUCUMBER_UNIT_FOLDER = s.get("ruby_cucumber_folder")
68 68
     global RSPEC_UNIT_FOLDER; RSPEC_UNIT_FOLDER = s.get("ruby_rspec_folder")
69 69
 
  70
+  def save_test_run(self, ex, file_name):
  71
+    s = sublime.load_settings("RubyTest.last-run")
  72
+    s.set("last_test_run", ex)
  73
+    s.set("last_test_file", file_name)
  74
+
  75
+    sublime.save_settings("RubyTest.last-run")
  76
+
70 77
   def show_tests_panel(self):
71 78
     if not hasattr(self, 'output_view'):
72 79
       self.output_view = self.window.get_output_panel("tests")
@@ -152,6 +159,8 @@ def run(self):
152 159
       ex = self.project_path(folder_name , RSPEC_UNIT + " " + rspec_folder + file_name + " -e " + test_name)
153 160
 
154 161
     if match_obj:
  162
+      self.save_test_run(ex, file_name)
  163
+      
155 164
       self.show_tests_panel()
156 165
 
157 166
       self.is_running = True
@@ -181,10 +190,25 @@ def run(self):
181 190
       sublime.error_message("Only *_test.rb, *_spec.rb, *.feature files supported!")
182 191
       return
183 192
 
  193
+    self.save_test_run(ex, file_name)
  194
+
184 195
     self.is_running = True
185 196
     self.proc = AsyncProcess(ex, self)
186 197
     StatusProcess("Starting tests from file " + file_name, self)
187 198
 
  199
+class RunLastRubyTest(RunSingleRubyTest):
  200
+  def load_last_run(self):
  201
+    s = sublime.load_settings("RubyTest.last-run")
  202
+    global LAST_TEST_RUN; LAST_TEST_RUN = s.get("last_test_run")
  203
+    global LAST_TEST_FILE; LAST_TEST_FILE = s.get("last_test_file")
  204
+
  205
+  def run(self):
  206
+    self.load_last_run()
  207
+    self.show_tests_panel()
  208
+    self.is_running = True
  209
+    self.proc = AsyncProcess(LAST_TEST_RUN, self)
  210
+    StatusProcess("Starting tests from file " + LAST_TEST_FILE, self)
  211
+
188 212
 class ShowTestPanel(sublime_plugin.WindowCommand):
189 213
   def run(self):
190 214
     self.window.run_command("show_panel", {"panel": "output.tests"})

0 notes on commit 1c4abd4

Please sign in to comment.
Something went wrong with that request. Please try again.