plymouth 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -11,16 +11,13 @@ _Start Pry in the context of a failed test_
11
11
  It currently supports [Bacon](https://github.com/chneukirchen/bacon), [Minitest](https://github.com/seattlerb/minitest), and [RSpec](https://github.com/rspec/rspec).
12
12
  Support for other testing libraries is (usually) trivial to add.
13
13
 
14
- `plymouth` utilizes the powerful [pry-exception_explorer](https://github.com/pry/pry-exception_explorer) gem.
14
+ plymouth utilizes the powerful [pry-exception_explorer](https://github.com/pry/pry-exception_explorer) gem.
15
15
 
16
16
  plymouth currently only runs on **MRI 1.9.2+ (including 1.9.3)**
17
-
18
- * Install the [gem](https://rubygems.org/gems/plymouth): `gem install plymouth`
19
- * See the [source code](http://github.com/banister/plymouth)
20
17
 
21
18
  **How to use:**
22
19
 
23
- After installing the gem, simply add the following line to your test suite:
20
+ After installing the [gem](https://rubygems.org/gems/plymouth), simply add the following line to your test suite:
24
21
 
25
22
  `require 'plymouth'`
26
23
 
@@ -68,7 +65,9 @@ From: /Users/john/ruby/play/rspec_intercept.rb @ line 9:
68
65
 
69
66
  [1] (pry) #<RSpec::Core::ExampleGroup::Nested_1>: 0> @array.size
70
67
  => 1
71
- [2] (pry) #<RSpec::Core::ExampleGroup::Nested_1>: 0> ^D
68
+ [2] (pry) #<RSpec::Core::ExampleGroup::Nested_1>: 0> edit --current
69
+ => nil
70
+ [3] (pry) #<RSpec::Core::ExampleGroup::Nested_1>: 0> ^D
72
71
  F
73
72
 
74
73
  Failures:
@@ -87,6 +86,14 @@ Failed examples:
87
86
  rspec ./rspec_intercept.rb:8 # Array should be empty
88
87
  ```
89
88
 
89
+ Edit the failing test code in an editor
90
+ ---
91
+
92
+ Notice the line `edit --current` from the example above. Entering this command will take you to the line in the test file
93
+ where the failing test was defined. Once here you can modify the test code as you please. Note that the file will not be
94
+ reloaded after editing is complete, instead any modifications you make will only take effect the next time you run the test suite.
95
+
96
+
90
97
  The 'USE_PLYMOUTH' Environment variable
91
98
  -------
92
99
 
@@ -94,12 +101,22 @@ To make it easier to run your test suite normally (without plymouth's interventi
94
101
  can be defined. If the `USE_PLYMOUTH` environment variable is set to `"false"`, `"0"`, or `"no"` plymouth will not intercept test failures.
95
102
  If `USE_PLYMOUTH` is not defined at all, plymouth will be used by default.
96
103
 
104
+ Travis Compatibility
105
+ ---
106
+
107
+ To prevent plymouth messing up testing on [travis](http://travis-ci.org/), add the following line to your `.travis.yml` file:
108
+
109
+ ```
110
+ env: USE_PLYMOUTH="no"
111
+ ```
112
+
97
113
  Limitations
98
114
  -------------------------
99
115
 
100
116
  * Occasional (very rare) segfault on 1.9.3 (seems to work fine on 1.9.2). Please [report](https://github.com/banister/plymouth/issues) all segfaults with a full backtrace!
101
117
  * Only supports MRI.
102
118
  * Currently limited to just Bacon, RSpec and Minitest. Support for more testing libraries will be added in the future.
119
+ * Only intercepts test **failures**, does not yet (generally) intercept test **errors**. Support for this will be added soon.
103
120
 
104
121
  Contact
105
122
  -------
data/Rakefile CHANGED
@@ -28,7 +28,7 @@ def apply_spec_defaults(s)
28
28
  s.require_path = 'lib'
29
29
  s.homepage = "http://github.com/banister/#{PROJECT_NAME}"
30
30
  s.has_rdoc = 'yard'
31
- s.add_dependency('pry-exception_explorer', '>=0.1.6')
31
+ s.add_dependency('pry-exception_explorer', '>=0.1.7')
32
32
  s.add_development_dependency("bacon","~>1.1.0")
33
33
  s.add_development_dependency('rspec')
34
34
  s.required_ruby_version = '>= 1.9.2'
@@ -12,4 +12,12 @@ describe Array do
12
12
  it 'should be empty' do
13
13
  @array.empty?.should == true
14
14
  end
15
+
16
+ it 'should have 3 items' do
17
+ [1, 2, 3].size.should == 3
18
+ end
19
+
20
+ it 'should contain only numbers' do
21
+ [1, "2", 3].all? { |v| v.is_a?(Fixnum).should == true }
22
+ end
15
23
  end
data/lib/plymouth.rb CHANGED
@@ -1,23 +1,35 @@
1
1
  # plymouth.rb
2
2
  # (C) 2012 John Mair (banisterfiend); MIT license
3
3
 
4
- require "plymouth/version"
5
4
  require 'pry-exception_explorer'
5
+ require "plymouth/version"
6
+ require 'plymouth/commands'
6
7
 
7
- if !ENV.has_key?("USE_PLYMOUTH")
8
- EE.enabled = true
9
- elsif ["0", "false", "no"].include?(ENV["USE_PLYMOUTH"].downcase)
10
- EE.enabled = false
11
- else
12
- EE.enabled = true
13
- end
8
+ module Plymouth
9
+
10
+ # Enable plymouth.
11
+ # @return [Boolean]
12
+ def self.enable!
13
+ ::EE.enabled = true
14
+ end
14
15
 
16
+ # Disable plymouth.
17
+ # @return [Boolean]
18
+ def self.disable!
19
+ ::EE.enabled = false
20
+ end
21
+
22
+ # @return [Boolean] Whether Plymouth is enabled.
23
+ def self.enabled?
24
+ ::EE.enabled?
25
+ end
26
+ end
15
27
 
16
28
  message = nil
17
29
 
18
30
  # Ensure auto-reloading is off, so that `edit --current` does not try
19
31
  # to reload the test file
20
- Pry.config.disable_auto_reload
32
+ Pry.config.disable_auto_reload = true
21
33
 
22
34
  # Decorate `whereami` command to include test failure information
23
35
  Pry.config.commands.before_command("whereami") do
@@ -30,7 +42,7 @@ if defined?(Bacon)
30
42
  EE.intercept do |frame, ex|
31
43
 
32
44
  if ex.is_a?(Bacon::Error) && frame.method_name != :run_requirement
33
- message = ex
45
+ message = ex.message
34
46
  true
35
47
  else
36
48
  false
@@ -43,7 +55,7 @@ elsif defined?(RSpec)
43
55
  EE.intercept do |frame, ex|
44
56
 
45
57
  if ex.class.name =~ /RSpec::Expectations::ExpectationNotMetError/
46
- message = ex
58
+ message = ex.message
47
59
  true
48
60
  else
49
61
  false
@@ -58,7 +70,7 @@ elsif defined?(MiniTest)
58
70
  EE.intercept do |frame, ex|
59
71
 
60
72
  if ex.is_a?(MiniTest::Assertion)
61
- message = ex
73
+ message = ex.message
62
74
  true
63
75
  else
64
76
  false
@@ -69,4 +81,11 @@ elsif defined?(MiniTest)
69
81
  end
70
82
  end
71
83
 
84
+ # Disable Plymouth if USE_PLYMOUTH environment variable is falsy
85
+ Plymouth.enable!
86
+ if ['0', 'false', 'no'].include?(ENV['USE_PLYMOUTH'].to_s.downcase)
87
+ Plymouth.disable!
88
+ end
72
89
 
90
+ # Bring in plymouth commands
91
+ Pry.commands.import Plymouth::Commands
@@ -0,0 +1,28 @@
1
+ module Plymouth
2
+ Commands = Pry::CommandSet.new do
3
+ create_command "plymouth-off", "Disable Plymouth." do
4
+ banner <<-BANNER
5
+ Usage: plymouth-off
6
+ Exit the REPL and turn Plymouth off for the duration of the test suite.
7
+ BANNER
8
+
9
+ def process
10
+ Plymouth.disable!
11
+
12
+ # exit the REPL
13
+ run "exit-all"
14
+ end
15
+ end
16
+
17
+ create_command "plymouth-on", "Enable Plymouth." do
18
+ banner <<-BANNER
19
+ Usage: plymouth-off
20
+ Enable Plymouth.
21
+ BANNER
22
+
23
+ def process
24
+ Plymouth.enable!
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Plymouth
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/plymouth.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "plymouth"
5
- s.version = "0.3.1"
5
+ s.version = "0.3.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Mair (banisterfiend)"]
9
- s.date = "2012-02-09"
9
+ s.date = "2012-02-10"
10
10
  s.description = "Start an interactive session when a test fails"
11
11
  s.email = "jrmair@gmail.com"
12
12
  s.files = [".gemtest", ".gitignore", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "examples/example_bacon.rb", "examples/example_minitest.rb", "examples/example_rspec.rb", "lib/plymouth.rb", "lib/plymouth/version.rb", "plymouth.gemspec", "test/test.rb"]
@@ -21,16 +21,16 @@ Gem::Specification.new do |s|
21
21
  s.specification_version = 3
22
22
 
23
23
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
24
- s.add_runtime_dependency(%q<pry-exception_explorer>, [">= 0.1.6"])
24
+ s.add_runtime_dependency(%q<pry-exception_explorer>, [">= 0.1.7"])
25
25
  s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
26
26
  s.add_development_dependency(%q<rspec>, [">= 0"])
27
27
  else
28
- s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.6"])
28
+ s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.7"])
29
29
  s.add_dependency(%q<bacon>, ["~> 1.1.0"])
30
30
  s.add_dependency(%q<rspec>, [">= 0"])
31
31
  end
32
32
  else
33
- s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.6"])
33
+ s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.7"])
34
34
  s.add_dependency(%q<bacon>, ["~> 1.1.0"])
35
35
  s.add_dependency(%q<rspec>, [">= 0"])
36
36
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: plymouth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.1
5
+ version: 0.3.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Mair (banisterfiend)
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-02-09 00:00:00 Z
13
+ date: 2012-02-10 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry-exception_explorer
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.1.6
23
+ version: 0.1.7
24
24
  type: :runtime
25
25
  version_requirements: *id001
26
26
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,7 @@ files:
66
66
  - examples/example_minitest.rb
67
67
  - examples/example_rspec.rb
68
68
  - lib/plymouth.rb
69
+ - lib/plymouth/commands.rb
69
70
  - lib/plymouth/version.rb
70
71
  - plymouth.gemspec
71
72
  - test/test.rb