Skip to content

Commit

Permalink
Added ability to disable pry.
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Nov 17, 2014
1 parent b6a3a47 commit 465cc0d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Lines of Code](http://img.shields.io/badge/loc-480-brightgreen.svg)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
[![Lines of Code](http://img.shields.io/badge/loc-464-brightgreen.svg)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
[![Code Status](https://codeclimate.com/github/hopsoft/pry-test.png)](https://codeclimate.com/github/hopsoft/pry-test)
[![Dependency Status](https://gemnasium.com/hopsoft/pry-test.png)](https://gemnasium.com/hopsoft/pry-test)
[![Build Status](https://travis-ci.org/hopsoft/pry-test.png)](https://travis-ci.org/hopsoft/pry-test)
[![Coverage Status](https://img.shields.io/coveralls/hopsoft/pry-test.svg)](https://coveralls.io/r/hopsoft/pry-test?branch=master)

# PryTest

#### Speed up your test workflow: `fail` -> `pry` -> `pass`
A testing framework that supports debugging test failures & errors as they happen.

## Benefits

Expand Down Expand Up @@ -100,9 +100,8 @@ pry-test --demo
Try some advanced features.

```sh
pry-test --demo --pry
pry-test --demo --async
pry-test --demo --formatter doc
pry-test --demo --disable-pry
```

## Testing Your Own Projects
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ task :default => [:test]

desc "Runs the test suite."
task :test do
exec File.expand_path("../bin/pry-test", __FILE__)
exec File.expand_path("../bin/pry-test --disable-pry", __FILE__)
end

11 changes: 9 additions & 2 deletions bin/pry-test
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ parser = OptionParser.new do |opts|
desc = "Stops the test run after the first failure. "
opts.on("--fail-fast", desc) { |value| options[:fail_fast] = value }

desc = "Disabled pry during the test run. "
opts.on("--disable-pry", desc) { |value| options[:disable_pry] = value }

opts.on("-v", "--version", "Show version.") do
puts "PryTest #{PryTest::VERSION}"
exit 0
Expand Down Expand Up @@ -70,8 +73,12 @@ end
runner = PryTest::Runner.new(formatter.new, options)

# setup pry -------------------------------------------------------------------
if RUBY_ENGINE == "jruby" || RUBY_ENGINE == "rbx" || options[:async]
puts red("Disabling pry when running with: #{RUBY_ENGINE}; #{options.inspect}")
if options[:async] || RUBY_ENGINE == "jruby" || RUBY_ENGINE == "rbx"
optional[:disable_pry] = true
end

if options[:disable_pry]
puts magenta("Disabling pry when running with: [#{RUBY_ENGINE}] #{options.inspect}")
exit runner.run
else
begin
Expand Down
2 changes: 1 addition & 1 deletion lib/pry-test/test_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def assert(value)
@asserts << assert_info(caller).merge(:value => value)

if !value
binding.pry(:quiet => true)
binding.pry(:quiet => true) unless @options[:disable_pry]

# I don't really like the coupling to the runner here
PryTest::Runner.exit = true if @options[:fail_fast]
Expand Down
4 changes: 2 additions & 2 deletions pry-test.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Gem::Specification.new do |spec|
spec.version = PryTest::VERSION
spec.license = "MIT"
spec.homepage = "https://github.com/hopsoft/pry-test"
spec.summary = "Speed up your test workflow: fail -> pry -> pass"
spec.description = "Speed up your test workflow: fail -> pry -> pass"
spec.summary = "A testing framework that supports debugging test failures & errors as they happen."
spec.description = "A testing framework that supports debugging test failures & errors as they happen."

spec.authors = ["Nathan Hopkins"]
spec.email = ["natehop@gmail.com"]
Expand Down
1 change: 0 additions & 1 deletion test/color_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Crayon
CRAYON = Crayon.new

test "red" do
assert false
assert PryTest::Color.red("foo") == "\e[31mfoo\e[0m"
assert ColorTest::CRAYON.red("foo") == "\e[31mfoo\e[0m"
end
Expand Down

0 comments on commit 465cc0d

Please sign in to comment.