guard-rspec 4.2.10 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f57a6766ffd007d4a2e7127e6af6980bf6de9913
4
- data.tar.gz: 520368ee18516a03137dad77da4cd1793e1f2db0
3
+ metadata.gz: 00930069139ba2580eec04320eb269416d82eda6
4
+ data.tar.gz: 3a00495af182f78389eb1ed02b1650bc45529432
5
5
  SHA512:
6
- metadata.gz: 456c281b2de5e96b79466a1f7d335521f34ab32994c4d4748567ac7f2e5a1672c3b016bf3c24acfe49f506850af2bf26a281b2460befc76f349745b080cc1722
7
- data.tar.gz: dac1d282bf1987eb9231e69a852a31c5201dcfc6b2a5f58d081722bd2f417806f0ce79db9dd6d5ac310e2b06c989f0c837f0419e4f633f22260752c457eec1e5
6
+ metadata.gz: 27a9b85a443f667139c86d9f02dab969838615017714625e5f5612b98121e81e7b44a41a5b2a18c17ca5ed3556c0eff29d3b7cd2461b9ac5c2a797722bcd7e69
7
+ data.tar.gz: 3216abd7e0e2297f1d34a101f159af23859359405625c00aa14018bf52d8935fdcd0c09230bd5c125f6dbb24c2c36ac183d1b0d21465e841d25d8dc53dbea549
data/README.md CHANGED
@@ -58,7 +58,7 @@ Please read [Guard doc](https://github.com/guard/guard#readme) for more informat
58
58
 
59
59
  ## Options
60
60
 
61
- Guard::RSpec 4.0 use now a more simple approach with the new `cmd` option that let you precisely define which rspec command will be launched on each run. As example if you want to support Spring with a custom formatter (progress by default) use:
61
+ Guard::RSpec 4.0 now uses a simpler approach with the new `cmd` option that let you precisely define which rspec command will be launched on each run. This option is required due to the number of different ways possible to invoke rspec, the template now includes a default that should work for most applications but may not be optimal for all. As example if you want to support Spring with a custom formatter (progress by default) use:
62
62
 
63
63
  ``` ruby
64
64
  guard :rspec, cmd: 'spring rspec -f doc' do
@@ -83,9 +83,9 @@ cmd: 'zeus rspec' # Specify a custom rspec command to run, default: 'rspec'
83
83
  spec_paths: ['spec'] # Specify a custom array of paths that contain spec files
84
84
  failed_mode: :focus # What to do with failed specs
85
85
  # Available values:
86
- # :focus (default) - focus on the first 10 failed specs, rerun till they pass
86
+ # :focus - focus on the first 10 failed specs, rerun till they pass
87
87
  # :keep - keep failed specs until they pass (add them to new ones)
88
- # :none - just report
88
+ # :none (default) - just report
89
89
  all_after_pass: true # Run all specs after changed specs pass, default: false
90
90
  all_on_start: true # Run all the specs at startup, default: false
91
91
  launchy: nil # Pass a path to an rspec results file, e.g. ./tmp/spec_results.html
@@ -5,9 +5,9 @@ module Guard
5
5
  all_on_start: false,
6
6
  all_after_pass: false,
7
7
  run_all: { message: 'Running all specs' },
8
- failed_mode: :focus, # :keep and :none are other posibilities
8
+ failed_mode: :none, # :keep and :focus are other posibilities
9
9
  spec_paths: %w[spec],
10
- cmd: 'rspec',
10
+ cmd: nil,
11
11
  launchy: nil,
12
12
  notification: true
13
13
  }
@@ -36,6 +36,7 @@ module Guard
36
36
  private
37
37
 
38
38
  def _run(all, paths, options)
39
+ return unless _cmd_option_present(options)
39
40
  command = Command.new(paths, options)
40
41
  _without_bundler_env { Kernel.system(command) }.tap do |success|
41
42
  if _command_success?(success)
@@ -62,6 +63,13 @@ module Guard
62
63
  end
63
64
  end
64
65
 
66
+ def _cmd_option_present(options)
67
+ return true if options[:cmd]
68
+ Guard::UI.error('No cmd option specified, unable to run specs!')
69
+ notifier.notify_failure
70
+ false
71
+ end
72
+
65
73
  def _command_success?(success)
66
74
  return false if success.nil?
67
75
  [Command::FAILURE_EXIT_CODE, 0].include?($?.exitstatus)
@@ -1,4 +1,12 @@
1
- guard :rspec do
1
+ # Note: The cmd option is now required due to the increasing number of ways
2
+ # rspec may be run, below are examples of the most common uses.
3
+ # * bundler: 'bundle exec rspec'
4
+ # * bundler binstubs: 'bin/rspec'
5
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
6
+ # installed the spring binstubs per the docs)
7
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
8
+ # * 'just' rspec: 'rspec'
9
+ guard :rspec, cmd: 'bundle exec rspec' do
2
10
  watch(%r{^spec/.+_spec\.rb$})
3
11
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
12
  watch('spec/spec_helper.rb') { "spec" }
@@ -10,6 +18,7 @@ guard :rspec do
10
18
  watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
11
19
  watch('config/routes.rb') { "spec/routing" }
12
20
  watch('app/controllers/application_controller.rb') { "spec/controllers" }
21
+ watch('spec/rails_helper.rb') { "spec" }
13
22
 
14
23
  # Capybara features specs
15
24
  watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = '4.2.10'
3
+ VERSION = '4.3.0'
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'launchy'
3
3
 
4
4
  describe Guard::RSpec::Runner do
5
- let(:options) { {} }
5
+ let(:options) { {cmd: 'rspec'} }
6
6
  let(:runner) { Guard::RSpec::Runner.new(options) }
7
7
  let(:inspector) { double(Guard::RSpec::Inspectors::SimpleInspector) }
8
8
  let(:notifier) { double(Guard::RSpec::Notifier) }
@@ -54,6 +54,7 @@ describe Guard::RSpec::Runner do
54
54
  describe '#run_all' do
55
55
  let(:options) { {
56
56
  spec_paths: %w[spec1 spec2],
57
+ cmd: 'rspec',
57
58
  run_all: { message: 'Custom message' }
58
59
  } }
59
60
  before { allow(inspector).to receive(:failed) }
@@ -89,6 +90,28 @@ describe Guard::RSpec::Runner do
89
90
  runner.run_all
90
91
  end
91
92
  end
93
+
94
+ context 'with no cmd' do
95
+ before {
96
+ options[:cmd] = nil
97
+ allow(Guard::RSpec::Command).to receive(:new)
98
+ allow(Guard::UI).to receive(:error).with(an_instance_of(String))
99
+ allow(notifier).to receive(:notify_failure)
100
+ runner.run_all
101
+ }
102
+
103
+ it 'does not build' do
104
+ expect(Guard::RSpec::Command).to_not have_received(:new)
105
+ end
106
+
107
+ it 'issues a warning to the user' do
108
+ expect(Guard::UI).to have_received(:error).with(an_instance_of(String))
109
+ end
110
+
111
+ it 'notifies the notifer of failure' do
112
+ expect(notifier).to have_received(:notify_failure)
113
+ end
114
+ end
92
115
  end
93
116
 
94
117
  describe '#run' do
@@ -121,7 +144,7 @@ describe Guard::RSpec::Runner do
121
144
  end
122
145
 
123
146
  context 'with all_after_pass option' do
124
- let(:options) { { all_after_pass: true } }
147
+ let(:options) { { cmd: 'rspec', all_after_pass: true } }
125
148
 
126
149
  it 're-runs all if run is success' do
127
150
  expect(runner).to receive(:run_all)
@@ -130,7 +153,7 @@ describe Guard::RSpec::Runner do
130
153
  end
131
154
 
132
155
  context 'with launchy option' do
133
- let(:options) { { launchy: 'launchy_path' } }
156
+ let(:options) { { cmd: 'rspec', launchy: 'launchy_path' } }
134
157
 
135
158
  before {
136
159
  allow(Pathname).to receive(:new).with('launchy_path') { double(exist?: true) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.10
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-09 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard