Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit 0efb411b9362edc742458b174f118e11b337b20c 0 parents
Greg Williams authored
13 Default (OSX).sublime-keymap
@@ -0,0 +1,13 @@
+[
+ { "keys": ["super+alt+b"],
+ "command": "exec",
+ "args": {"cmd": ["rake", "spec"]},
+ "file_regex": "# ([A-Za-z0-9_./ ]+rb):([0-9]+)",
+ "working_dir": "${folder}"
+ },
+
+ { "keys": ["super+alt+period"], "command": "open_rspec_file", "args": {"option": "test_and_source"} },
+ { "keys": ["super+period"], "command": "open_rspec_file", "args": {"option": "next"} },
+ { "keys": ["super+alt+s"], "command": "open_rspec_file", "args": {"option": "source"} },
+ { "keys": ["super+alt+t"], "command": "open_rspec_file", "args": {"option": "test"} }
+]
3  Default (Windows).sublime-keymap
@@ -0,0 +1,3 @@
+[
+ { "keys": ["alt+f7"], "command": "exec", "args": {"cmd": ["rake", "spec"], "file_regex": "# ([A-Za-z0-9_./ ]+rb):([0-9]+)"} }
+]
63 OpenRSpecFile.py
@@ -0,0 +1,63 @@
+import sublime
+import sublime_plugin
+import re, inspect, os
+
+class OpenRspecFileCommand(sublime_plugin.WindowCommand):
+
+ def run(self, option):
+ if not self.window.active_view():
+ return
+
+ self.views = []
+ window = self.window
+ current_file_path = self.window.active_view().file_name()
+
+ if re.search(r"\w+\.rb$", current_file_path):
+
+ current_file = re.search(r"([\w\.]+)$", current_file_path).group(1)
+ base_name = re.search(r"(\w+)\.(\w+)$", current_file).group(1)
+ base_name = re.sub('_spef.rb', '', base_name)
+
+ source_matcher = re.compile("[/\\\\]" + base_name + "\.rb$")
+ test_matcher = re.compile("[/\\\\]" + base_name + "_spec\.rb$")
+
+ print(current_file)
+
+ if option == 'next':
+ print "Current file: " + current_file
+ if re.search(re.compile(base_name + "_spec\.rb$"), current_file):
+ self.open_project_file(source_matcher, window)
+ elif re.search(re.compile(base_name + "\.rb$"), current_file):
+ self.open_project_file(test_matcher, window)
+ else:
+ print "Current file is not valid for RSpec switch file!"
+ elif option == 'source':
+ self.open_project_file(source_matcher, window)
+ elif option == 'test':
+ self.open_project_file(test_matcher, window)
+ elif option == 'test_and_source':
+ window.run_command('set_layout', {
+ "cols": [0.0, 0.5, 1.0],
+ "rows": [0.0, 1.0],
+ "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
+ })
+ self.open_project_file(test_matcher, window, 0)
+ self.open_project_file(source_matcher, window, 1)
+
+ for v in self.views:
+ window.focus_view(v)
+
+ def open_project_file(self, file_matcher, window, auto_set_view=-1):
+ for root, dirs, files in os.walk(window.folders()[0]):
+ for f in files:
+ if re.search(r"\.rb$", f):
+ cur_file = os.path.join(root, f)
+ print "Assessing: " + cur_file
+ if file_matcher.search(cur_file):
+ file_view = window.open_file(os.path.join(root, f))
+ if auto_set_view >= 0: # don't set the view unless specified
+ window.run_command('move_to_group', {'group': auto_set_view})
+ self.views.append(file_view)
+ print("Opened: " + f)
+ return
+ print("No matching files!")
15 README.md
@@ -0,0 +1,15 @@
+Description
+===========
+[RSpec](http://rspec.info/) is a BDD (Behavioral-Driven Development) testing framework for Ruby. This package adds support to Sublime Text 2 for testing Ruby applications wioth RSpec.
+
+Package Installation
+====================
+Bring up a command line in the Packages/ folder of your Sublime user folder, and execute the following:
+> git clone git://github.com/SublimeText/RSpec.git
+
+When you launch Sublime Text 2, it will pick up the contents of this package so that you can consume the goodness that it provides.
+
+Features
+========
+* RSpec.sublime-build for executing unit tests for the active module via the S2 *Build* command
+ * You must assign the builder for your project to 'Ceedling'
6 RSpec.sublime-build
@@ -0,0 +1,6 @@
+{
+ "cmd": ["rspec", "$file"],
+ "file_regex": "# ([A-Za-z0-9_./ ]+rb):([0-9]+)",
+ "working_dir": "${folder}",
+ "selector": "source.ruby"
+}
Please sign in to comment.
Something went wrong with that request. Please try again.