Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Start Pry in the context of a failed test

tag: v0.3.0

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gemtest
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .yardopts
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 plymouth.gemspec
README.md

plymouth

(C) John Mair (banisterfiend) 2012

Start an interactive session on test failure

Warning BETA software: Please file an issue if you have any problems

plymouth is a gem to automatically start a Pry session when a test fails, putting you in the context of the failure. It currently supports Bacon, Minitest, and RSpec. Support for other testing libraries is (usually) trivial to add.

plymouth utilizes the powerful pry-exception_explorer gem.

plymouth currently only runs on MRI 1.9.2+ (including 1.9.3)

How to use:

Simply add the following line to your test suite:

require 'plymouth'

plymouth should auto-detect which testing library you're using, and 'just work' :)

Example: Intercept a failing test in RSpec

Inside the test file:

require 'plymouth'

describe Array do
  before do
    @array = [1]
  end

  it 'should be empty' do
    @array.empty?.should == true
  end
end

And here is the result of running the above test with the rspec executable:

Test failure: expected: true
     got: false (using ==)

Frame number: 0/14
Frame type: block

From: /Users/john/ruby/play/rspec_intercept.rb @ line 9:

     4:   before do
     5:     @array = [1]
     6:   end
     7: 
     8:   it 'should be empty' do
 =>  9:     @array.empty?.should == true
    10:   end
    11: end

[1] (pry) #<RSpec::Core::ExampleGroup::Nested_1>: 0> @array.size                                                                                                                           
=> 1
[2] (pry) #<RSpec::Core::ExampleGroup::Nested_1>: 0> ^D
F

Failures:

  1) Array should be empty
     Failure/Error: @array.empty?.should == true
       expected: true
            got: false (using ==)
     # ./rspec_intercept.rb:9:in `block (2 levels) in <top (required)>'

Finished in 7.74 seconds
1 example, 1 failure

Failed examples:

rspec ./rspec_intercept.rb:8 # Array should be empty

The 'USE_PLYMOUTH' Environment variable

To make it easier to run your test suite normally (without plymouth's intervention) a USE_PLYMOUTH environment variable can be defined. If the USE_PLYMOUTH environment variable is set to "false", "0", or "no" plymouth will not intercept test failures. If USE_PLYMOUTH is not defined at all, plymouth will be used by default.

Limitations

  • Occasional segfault on 1.9.3 (seems to work fine on 1.9.2). Please report all segfaults with a full backtrace!
  • Only supports MRI.
  • Currently limited to just Bacon, RSpec and Minitest. Support for more testing libraries will be added in the future.

Contact

Problems or questions contact me at github

License

(The MIT License)

Copyright (c) 2012 John Mair (banisterfiend)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.