Skip to content

Commit 66e0992

Browse files
committedApr 23, 2017
Include “Help” command
1 parent ac55c35 commit 66e0992

File tree

4 files changed

+119
-83
lines changed

4 files changed

+119
-83
lines changed
 

‎Commands/Help.tmCommand

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>beforeRunningCommand</key>
6+
<string>nop</string>
7+
<key>command</key>
8+
<string>#!/bin/bash
9+
10+
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
11+
12+
html_header "RSpec Bundle Help" "Ruby"
13+
"$TM_SUPPORT_PATH/lib/markdown_to_help.rb" "$TM_BUNDLE_SUPPORT/../HELP.md"
14+
html_footer</string>
15+
<key>input</key>
16+
<string>selection</string>
17+
<key>inputFormat</key>
18+
<string>text</string>
19+
<key>name</key>
20+
<string>Help</string>
21+
<key>outputCaret</key>
22+
<string>afterOutput</string>
23+
<key>outputFormat</key>
24+
<string>html</string>
25+
<key>outputLocation</key>
26+
<string>newWindow</string>
27+
<key>scope</key>
28+
<string>source.ruby.rspec, attr.rest.rspec</string>
29+
<key>uuid</key>
30+
<string>6F90381A-A17D-4EA5-99C3-5BBB151EA9B5</string>
31+
<key>version</key>
32+
<integer>2</integer>
33+
</dict>
34+
</plist>

‎HELP.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Running RSpec examples
2+
3+
Commands for running examples:
4+
5+
* __Run Examples__ <kbd>⌘R</kbd>: Run all examples in the current spec file.
6+
* __Run Single Example__ <kbd>⇧⌘R</kbd>: Run the example on the current line (also works for example groups).
7+
* __Run Examples in Selected Files/Directories__ <kbd>⌥⇧⌘R</kbd>: Run all examples from the files / directories selected in the file browser. If nothing is selected, run all examples in `spec/`. Hint: <kbd>⇧⌘A ⌥⇧⌘R</kbd> is a quick way to run all specs (<kbd>⇧⌘A</kbd> deselects everything in the file browser).
8+
* __Run Again__ <kbd>⌃⌥⌘R</kbd>: Repeat the last run command (can be example file, single example or examples in selected files).
9+
10+
If your project has an `.rspec` file in its root, the last two commands – “Run Examples in Selected Files/Directories” and “Run Again” – are available everywhere in your project (even in files that not using the “RSpec” mode).
11+
12+
# How RSpec is run
13+
14+
The bundle runs RSpec in a subshell. The command to start RSpec is determined as such:
15+
16+
* If a binstub (`bin/rspec`) is present, it is used for running RSpec (this works great for preloaders like [Spring](https://github.com/rails/spring), too).
17+
* If there is no binstub, but `Gemfile.lock` is present, RSpec is run via `bundle exec rspec`.
18+
* If there is neither a binstub nor a `Gemfile.lock`, RSpec is simply run via `rspec` (__not recommended__ – use only if you know exactly what you’re doing).
19+
20+
Internally the bundle uses `Executable.find` from the Ruby bundle to detect how to run RSpec. For details see https://github.com/textmate/ruby.tmbundle/blob/master/Support/lib/executable.rb
21+
22+
Running RSpec / Ruby from a subshell means that TextMate must be configured to work with whatever Ruby version manager you're using ([rbenv](https://github.com/sstephenson/rbenv), [rvm](http://rvm.io/), …). Normally, this means customizing the `$PATH` variable. See [Defining a $PATH](http://blog.macromates.com/2014/defining-a-path/) in the TextMate blog for details and caveats.
23+
24+
## Setting the base directory for running examples
25+
26+
Per default, RSpec is run from the directory currently designated as “project folder” in TextMate. This can be overriden by setting `TM_RSPEC_BASEDIR`.
27+
28+
It’s even possible to have different base directories for running RSpec in a single project. Take for example a Rails Engine with the following directory layout:
29+
30+
31+
app/ # Rails app
32+
spec/ # examples for the Rails app
33+
my_engine/
34+
app/ # Engine
35+
spec/ # examples for the Engine
36+
37+
The examples for the Rails app should be run from the top-level directory, but the examples for the Engine should be run from `my_engine/`.
38+
39+
To achieve this, create a file `my_engine/.tm_properties` with the following line:
40+
41+
TM_RSPEC_BASEDIR=$CWD
42+
43+
This makes sure that `TM_RSPEC_BASEDIR` is set to the full path of the `my_engine/` directory whenever you’re editing a file in this directory (or one of its subdirectories). So if you’re editing `my_engine/spec/foo_spec.rb` and press <kbd>⌘R</kbd> to run the examples, they will be run from the `my_engine/` directory, while running examples in, say, `spec/bar_spec.rb` are still run from the top-level project directory.
44+
45+
# Configuration
46+
47+
In addition to the standard TextMate shell variables, the RSpec
48+
TextMate bundle supports the following:
49+
50+
## TM\_RSPEC\_BASEDIR
51+
52+
Set the base directory for running RSpec (defaults to the current “Project Folder”). See “Setting the base directory for running examples” above for more info and an example.
53+
54+
## TM\_RSPEC\_FORMATTER
55+
56+
Set a custom formatter other than RSpec's TextMate formatter. Use
57+
the full classname, e.g. `'Spec::Core::Formatters::WebKit'`
58+
59+
## TM\_RSPEC\_OPTS
60+
61+
Use this to set RSpec options just as you would in an `.rspec`
62+
file.
63+
64+
# RVM Integration
65+
66+
[__NOTE: Information in this section may be outdated__]
67+
68+
There are lots of ways to configure TextMate to work with `rvm`,
69+
but this is the one that we recommend:
70+
71+
With rvm installed, take the full path to `rvm-auto-ruby`,
72+
found via: `which rvm-auto-ruby`
73+
74+
Next, set up a `TM_RUBY` option in
75+
`TextMate/Preferences/Advanced/Shell Variables` that points to the
76+
`rvm-auto-ruby` command.
77+
78+
Learn more at:
79+
80+
* [http://rvm.io/integration/textmate](http://rvm.io/integration/textmate)
81+
* [http://groups.google.com/group/rubyversionmanager/browse_thread/thread/64b84bbcdf49e9b?fwc=1&pli=1](http://groups.google.com/group/rubyversionmanager/browse_thread/thread/64b84bbcdf49e9b?fwc=1&pli=1)
82+

‎README.md

+2-83
Original file line numberDiff line numberDiff line change
@@ -6,90 +6,9 @@ This bundle works with **TextMate 2** and **RSpec 3**. For TextMate 1 and/or RSp
66

77
Open up TextMate’s preferences, go to “Bundles” and make sure “RSpec” is checked.
88

9-
## Running RSpec examples
9+
## Usage
1010

11-
Commands for running examples:
12-
13-
* __Run Examples__ <kbd>⌘R</kbd>: Run all examples in the current spec file.
14-
* __Run Single Example__ <kbd>⇧⌘R</kbd>: Run the example on the current line (also works for example groups).
15-
* __Run Examples in Selected Files/Directories__ <kbd>⌥⇧⌘R</kbd>: Run all examples from the files / directories selected in the file browser. If nothing is selected, run all examples in `spec/`. Hint: <kbd>⇧⌘A ⌥⇧⌘R</kbd> is a quick way to run all specs (<kbd>⇧⌘A</kbd> deselects everything in the file browser).
16-
* __Run Again__ <kbd>⌃⌥⌘R</kbd>: Repeat the last run command (can be example file, single example or examples in selected files).
17-
18-
If your project has an `.rspec` file in its root, the last two commands – “Run Examples in Selected Files/Directories” and “Run Again” – are available everywhere in your project (even in files that not using the “RSpec” mode).
19-
20-
## Configuring TextMate for running examples
21-
22-
The bundle runs RSpec in a subshell. The command to start RSpec is determined as such:
23-
24-
* If a binstub (`bin/rspec`) is present, it is used for running RSpec (this works great for preloaders like [Spring](https://github.com/rails/spring), too).
25-
* If there is no binstub, but `Gemfile.lock` is present, RSpec is run via `bundle exec rspec`.
26-
* If there is neither a binstub nor a `Gemfile.lock`, RSpec is simply run via `rspec` (__not recommended__ – use only if you know exactly what you’re doing).
27-
28-
Internally the bundle uses `Executable.find` from the Ruby bundle to detect how to run RSpec. For details see https://github.com/textmate/ruby.tmbundle/blob/master/Support/lib/executable.rb
29-
30-
Running RSpec / Ruby from a subshell means that TextMate must be configured to work with whatever Ruby version manager you're using ([rbenv](https://github.com/sstephenson/rbenv), [rvm](http://rvm.io/), …). Normally, this means customizing the `$PATH` variable. See [Defining a $PATH](http://blog.macromates.com/2014/defining-a-path/) in the TextMate blog for details and caveats.
31-
32-
### Setting the base directory for running examples
33-
34-
Per default, RSpec is run from the directory currently designated as “project folder” in TextMate. This can be overriden by setting `TM_RSPEC_BASEDIR`.
35-
36-
It’s even possible to have different base directories for running RSpec in a single project. Take for example a Rails Engine with the following directory layout:
37-
38-
```
39-
app/ # Rails app
40-
spec/ # examples for the Rails app
41-
my_engine/
42-
app/ # Engine
43-
spec/ # examples for the Engine
44-
```
45-
46-
The examples for the Rails app should be run from the top-level directory, but the examples for the Engine should be run from `my_engine/`.
47-
48-
To achieve this, create a file `my_engine/.tm_properties` with the following line:
49-
50-
```
51-
TM_RSPEC_BASEDIR=$CWD
52-
```
53-
54-
This makes sure that `TM_RSPEC_BASEDIR` is set to the full path of the `my_engine/` directory whenever you’re editing a file in this directory (or one of its subdirectories). So if you’re editing `my_engine/spec/foo_spec.rb` and press <kbd>⌘R</kbd> to run the examples, they will be run from the `my_engine/` directory, while running examples in, say, `spec/bar_spec.rb` are still run from the top-level project directory.
55-
56-
## Configuration
57-
58-
In addition to the standard TextMate shell variables, the RSpec
59-
TextMate bundle supports the following:
60-
61-
#### TM\_RSPEC\_BASEDIR
62-
63-
Set the base directory for running RSpec (defaults to the current “Project Folder”). See “Setting the base directory for running examples” above for more info and an example.
64-
65-
#### TM\_RSPEC\_FORMATTER
66-
67-
Set a custom formatter other than RSpec's TextMate formatter. Use
68-
the full classname, e.g. `'Spec::Core::Formatters::WebKit'`
69-
70-
#### TM\_RSPEC\_OPTS
71-
72-
Use this to set RSpec options just as you would in an `.rspec`
73-
file.
74-
75-
## RVM Integration
76-
77-
[__NOTE: Information in this section may be outdated__]
78-
79-
There are lots of ways to configure TextMate to work with `rvm`,
80-
but this is the one that we recommend:
81-
82-
With rvm installed, take the full path to `rvm-auto-ruby`,
83-
found via: `which rvm-auto-ruby`
84-
85-
Next, set up a `TM_RUBY` option in
86-
`TextMate/Preferences/Advanced/Shell Variables` that points to the
87-
`rvm-auto-ruby` command.
88-
89-
Learn more at:
90-
91-
* [http://rvm.io/integration/textmate](http://rvm.io/integration/textmate)
92-
* [http://groups.google.com/group/rubyversionmanager/browse_thread/thread/64b84bbcdf49e9b?fwc=1&pli=1](http://groups.google.com/group/rubyversionmanager/browse_thread/thread/64b84bbcdf49e9b?fwc=1&pli=1)
11+
See [HELP.md](HELP.md)
9312

9413
## History
9514

‎info.plist

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<string>B5906021-8E54-4863-A13B-EA46333DB5F2</string>
1717
<string>67E726E0-63E2-4840-B8BB-37F665CD34B9</string>
1818
<string>CB648A00-9F6C-4D9B-BB43-DADB40DE4C8E</string>
19+
<string>6F90381A-A17D-4EA5-99C3-5BBB151EA9B5</string>
1920
<string>------------------------------------</string>
2021
<string>651EC6EE-6034-4090-88FD-BC06D36190A8</string>
2122
<string>99ED184B-CA5F-41A8-AFA4-57640475185D</string>

0 commit comments

Comments
 (0)
Please sign in to comment.