Giter Club home page Giter Club logo

rspec.tmbundle's Introduction

RSpec TextMate Bundle

This bundle works with TextMate 2 and RSpec 2 and 3. For TextMate 1 and/or RSpec 1 please use the legacy version from the branch “rspec1-textmate1”.

Installation

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

Running RSpec examples

Commands for running examples:

  • Run Examples ⌘R: Run all examples in the current spec file.
  • Run Single Example ⇧⌘R: Run the example on the current line (also works for example groups).
  • Run Examples in Selected Files/Directories ⌥⇧⌘R: Run all examples from the files / directories selected in the file browser. If nothing is selected, run all examples in spec/. Hint: ⇧⌘A ⌥⇧⌘R is a quick way to run all specs (⇧⌘A deselects everything in the file browser).
  • Run Again ⌥⌘R: Repeat the last run command (can be example file, single example or examples in selected files).

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).

Configuring TextMate for running examples

The bundle runs RSpec in a subshell. The command to start RSpec is determined as such:

  • If a binstub (bin/rspec) is present, it is used for running RSpec (this works great for preloaders like Spring, too).
  • If there is no binstub, but Gemfile.lock is present, RSpec is run via bundle exec rspec.
  • 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).

Running RSpec / Ruby from a subshell means that TextMate must be configured to work with whatever Ruby version manager you're using (rbenv, rvm, …). Normally, this means customizing the $PATH variable. See Defining a $PATH in the TextMate blog for details and caveats.

Setting the base directory for running examples

Per default, RSpec is run from the directory currently designated as “project folder” in TextMate. This can be overriden by setting TM_RSPEC_BASEDIR.

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:

app/        # Rails app
spec/       # examples for the Rails app
my_engine/
  app/      # Engine
  spec/     # examples for the Engine

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/.

To achieve this, create a file my_engine/.tm_properties with the following line:

TM_RSPEC_BASEDIR=$CWD

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 ⌘R 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.

Configuration

In addition to the standard TextMate shell variables, the RSpec TextMate bundle supports the following:

TM_RSPEC_BASEDIR

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.

TM_RSPEC_FORMATTER

Set a custom formatter other than RSpec's TextMate formatter. Use the full classname, e.g. 'Spec::Core::Formatters::WebKit'

TM_RSPEC_OPTS

Use this to set RSpec options just as you would in an .rspec file.

RVM Integration

[NOTE: Information in this section may be outdated]

There are lots of ways to configure TextMate to work with rvm, but this is the one that we recommend:

With rvm installed, take the full path to rvm-auto-ruby, found via: which rvm-auto-ruby

Next, set up a TM_RUBY option in TextMate/Preferences/Advanced/Shell Variables that points to the rvm-auto-ruby command.

Learn more at:

History

Parts of RSpec.tmbundle are based on Florian Weber's TDDMate.

License

The license of RSpec.tmbundle is the same as RSpec's.

rspec.tmbundle's People

Contributors

alexch avatar dchelimsky avatar drnic avatar elia avatar ged avatar gemyago avatar gja avatar glennfu avatar granth avatar grimen avatar humblehacker avatar infininight avatar jperkins avatar justinko avatar lukemelia avatar mahnve avatar mvanholstyn avatar noniq avatar nruth avatar olly avatar pcasaretto avatar purp avatar simonjefford avatar stjernstrom avatar thilo avatar timcharper avatar underpantsgnome avatar unpublishedworks avatar zilkey avatar zmoazeni avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.