guard-rspec 4.6.4 → 4.6.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8b12fb48580695950c8de23fee6eafe3018f160
4
- data.tar.gz: 5b4a3fc56f713c6061fd282e422cccb960141dbe
3
+ metadata.gz: 36f680214b513178f42ad7f47d9fa8f6059eb5df
4
+ data.tar.gz: 9ed784b1fe3be511dfaec7d934cc88b2c7d674bf
5
5
  SHA512:
6
- metadata.gz: 812a1cf6163606ada0a1bc33c14386c7a3fd9fbe5da3699f1b99b5acbd8251db4047bd2c8fd9424a69ff3ccce53bd329552f6a52977f72681fa2befc75f0a146
7
- data.tar.gz: 67efd2a4f6b8f9ea6e6d92c9ed6899cd8f77683c42e4427e495bf0ed6901c0c23141d96e4fdf5bf298c2fd1674620b1e03cc3a068da528204c2078e06541c3dd
6
+ metadata.gz: ebe1c445d9b2b52cb5f5b50d92d4d7bc8611034c95972dd79e1b29cd85a9e85a0ae9649c1e1eee4d820266306c1dabb8ba8fec42c83d4bd7d76ef4cdc6b7790d
7
+ data.tar.gz: 9d758975348f80fa7dafcd71aeed1cdbdfd49dd32a82ab7ec60576f51da23600112dae3ac8c8edffb3a4ece91a1396c6ba74a49fcaaa81e152ad7a0f7c1bbbcf
data/.hound.yml CHANGED
@@ -196,9 +196,6 @@ StringLiterals:
196
196
  VariableInterpolation:
197
197
  Enabled: false
198
198
 
199
- TrailingComma:
200
- Enabled: false
201
-
202
199
  TrivialAccessors:
203
200
  Enabled: false
204
201
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2014 Thibaud Guillaume-Gentil
1
+ Copyright (c) 2010-2016 Thibaud Guillaume-Gentil
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Guard::RSpec allows to automatically & intelligently launch specs when files are modified.
6
6
 
7
7
  * Compatible with RSpec >2.14 & 3
8
- * Tested against Ruby 1.9.3, 2.0.0, 2.1.5, 2.2.0 JRuby and Rubinius.
8
+ * Tested against Ruby 2.2.x, JRuby and Rubinius.
9
9
 
10
10
  ## Install
11
11
 
@@ -10,9 +10,9 @@ Gem::Specification.new do |s|
10
10
  s.email = "thibaud@thibaud.gg"
11
11
  s.summary = "Guard gem for RSpec"
12
12
  s.description = "Guard::RSpec automatically run your specs" +
13
- " (much like autotest)."
13
+ " (much like autotest)."
14
14
 
15
- s.homepage = "https://rubygems.org/gems/guard-rspec"
15
+ s.homepage = "https://github.com/guard/guard-rspec"
16
16
  s.license = "MIT"
17
17
 
18
18
  s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
@@ -25,7 +25,7 @@ module Guard
25
25
  end
26
26
 
27
27
  def start
28
- Guard::Compat::UI.info "Guard::RSpec is running"
28
+ Compat::UI.info "Guard::RSpec is running"
29
29
  run_all if options[:all_on_start]
30
30
  end
31
31
 
@@ -71,8 +71,8 @@ module Guard
71
71
  return unless options.key?(:focus_on_failed)
72
72
  _deprecated(
73
73
  "The :focus_on_failed option is deprecated." +
74
- " Focus mode is the default and can be changed using new" +
75
- " :failed_mode option." +
74
+ " Please set new :failed_mode option value to" +
75
+ " :focus instead." +
76
76
  " https://github.com/guard/guard-rspec#list-of-available-options")
77
77
  end
78
78
 
@@ -37,7 +37,7 @@ module Guard
37
37
 
38
38
  def ruby
39
39
  # Ruby apps
40
- @ruby || OpenStruct.new.tap do |ruby|
40
+ @ruby ||= OpenStruct.new.tap do |ruby|
41
41
  ruby.lib_files = %r{^(lib/.+)\.rb$}
42
42
  end
43
43
  end
@@ -25,8 +25,8 @@ module Guard
25
25
  def failed(locations)
26
26
  if locations.empty?
27
27
  @focused_locations = []
28
- else
29
- @focused_locations = locations if focused_locations.empty?
28
+ elsif focused_locations.empty?
29
+ @focused_locations = locations
30
30
  end
31
31
  end
32
32
 
@@ -5,14 +5,14 @@ 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: :none, # :keep and :focus are other posibilities
8
+ failed_mode: :none, # :keep and :focus are other posibilities
9
9
  spec_paths: %w(spec),
10
10
  cmd: nil,
11
11
  cmd_additional_args: nil,
12
12
  launchy: nil,
13
13
  notification: true,
14
14
  title: "RSpec results"
15
- }
15
+ }.freeze
16
16
 
17
17
  class << self
18
18
  def with_defaults(options = {})
@@ -56,8 +56,6 @@ module Guard
56
56
  end
57
57
  end
58
58
 
59
- private
60
-
61
59
  attr_reader :command
62
60
  attr_reader :exit_code
63
61
  attr_reader :formatter_tmp_file
@@ -16,7 +16,7 @@ module Guard
16
16
  end
17
17
 
18
18
  # NOTE: must match with const in RSpecFormatter!
19
- TEMPORARY_FILE_PATH ||= "tmp/rspec_guard_result"
19
+ TEMPORARY_FILE_PATH ||= "tmp/rspec_guard_result".freeze
20
20
 
21
21
  attr_accessor :options, :inspector, :notifier
22
22
 
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RSpecVersion
3
- VERSION = "4.6.4"
3
+ VERSION = "4.6.5".freeze
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  class RSpecDefaults
3
- TEMPORARY_FILE_PATH = "tmp/rspec_guard_result"
3
+ TEMPORARY_FILE_PATH = "tmp/rspec_guard_result".freeze
4
4
  end
5
5
  end
@@ -7,18 +7,22 @@ require "fileutils"
7
7
  require "rspec"
8
8
  require "rspec/core/formatters/base_formatter"
9
9
 
10
- require "guard/rspec_defaults"
10
+ require_relative "rspec_defaults"
11
11
 
12
12
  module Guard
13
13
  class RSpecFormatter < ::RSpec::Core::Formatters::BaseFormatter
14
14
  WIKI_ENV_WARN_URL =
15
- "https://github.com/guard/guard-rspec/wiki/Warning:-no-environment"
15
+ "https://github.com/guard/guard-rspec/wiki/Warning:-no-environment".freeze
16
16
 
17
- NO_ENV_WARNING_MSG = "no environment passed - see #{WIKI_ENV_WARN_URL}"
18
- NO_RESULTS_VALUE_MSG = ":results_file value unknown (using defaults)"
17
+ NO_ENV_WARNING_MSG =
18
+ "no environment passed - see #{WIKI_ENV_WARN_URL}".freeze
19
19
 
20
- UNSUPPORTED_PATTERN = "Your RSpec.configuration.pattern uses characters "\
21
- "unsupported by your Ruby version (File::FNM_EXTGLOB is undefined)"
20
+ NO_RESULTS_VALUE_MSG =
21
+ ":results_file value unknown (using defaults)".freeze
22
+
23
+ UNSUPPORTED_PATTERN =
24
+ "Your RSpec.configuration.pattern uses characters "\
25
+ "unsupported by your Ruby version (File::FNM_EXTGLOB is undefined)".freeze
22
26
 
23
27
  class Error < RuntimeError
24
28
  class UnsupportedPattern < Error
@@ -44,40 +48,54 @@ module Guard
44
48
  end
45
49
  end
46
50
 
47
- # rspec issue https://github.com/rspec/rspec-core/issues/793
48
- def self.extract_spec_location(metadata)
49
- root_metadata = metadata
50
- location = metadata[:location]
51
+ class << self
52
+ # rspec issue https://github.com/rspec/rspec-core/issues/793
53
+ def extract_spec_location(metadata)
54
+ root_metadata = metadata
55
+ location = metadata[:location]
56
+
57
+ until spec_path?(location)
58
+ metadata = metadata[:parent_example_group] || metadata[:example_group]
51
59
 
52
- until spec_path?(location)
53
- metadata = metadata[:parent_example_group] || metadata[:example_group]
60
+ unless metadata
61
+ STDERR.puts "no spec file location in #{root_metadata.inspect}"
62
+ return root_metadata[:location]
63
+ end
54
64
 
55
- unless metadata
56
- STDERR.puts "no spec file location in #{root_metadata.inspect}"
57
- return root_metadata[:location]
65
+ # rspec issue https://github.com/rspec/rspec-core/issues/1243
66
+ location = first_colon_separated_entry(metadata[:location])
58
67
  end
59
68
 
60
- # rspec issue https://github.com/rspec/rspec-core/issues/1243
61
- location = (metadata[:location] || "").split(":").first
69
+ location
62
70
  end
63
71
 
64
- location
65
- end
72
+ def spec_path?(path)
73
+ pattern = ::RSpec.configuration.pattern
74
+
75
+ flags = supported_fnmatch_flags(pattern)
76
+ path ||= ""
77
+ path = path.sub(/:\d+\z/, "")
78
+ path = Pathname.new(path).cleanpath.to_s
79
+ stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
80
+ File.fnmatch(stripped, path, flags)
81
+ end
66
82
 
67
- def self.spec_path?(path)
68
- pattern = ::RSpec.configuration.pattern
83
+ private
69
84
 
70
- flags = File::FNM_PATHNAME | File::FNM_DOTMATCH
71
- if File.const_defined?(:FNM_EXTGLOB) # ruby >= 2
72
- flags |= File::FNM_EXTGLOB
73
- elsif pattern =~ /[{}]/
74
- fail Error::UnsupportedPattern
85
+ def first_colon_separated_entry(entries)
86
+ (entries || "").split(":").first
75
87
  end
76
88
 
77
- path ||= ""
78
- path = path.sub(/:\d+\z/, "")
79
- path = Pathname.new(path).cleanpath.to_s
80
- File.fnmatch(pattern, path, flags)
89
+ def supported_fnmatch_flags(pattern)
90
+ flags = File::FNM_PATHNAME | File::FNM_DOTMATCH
91
+
92
+ # ruby >= 2
93
+ return flags |= File::FNM_EXTGLOB if File.const_defined?(:FNM_EXTGLOB)
94
+
95
+ fail Error::UnsupportedPattern if pattern =~ /[{}]/
96
+
97
+ flags
98
+ end
81
99
  end
82
100
 
83
101
  def dump_summary(*args)
@@ -134,8 +152,8 @@ module Guard
134
152
  def _results_file
135
153
  path = ENV["GUARD_RSPEC_RESULTS_FILE"]
136
154
  if path.nil?
137
- STDERR.puts "Guard::RSpec: Warning: #{NO_ENV_WARNING_MSG}\n" \
138
- "Guard::RSpec: Warning: #{NO_RESULTS_VALUE_MSG}"
155
+ STDERR.puts("Guard::RSpec: Warning: #{NO_ENV_WARNING_MSG}\n" \
156
+ "Guard::RSpec: Warning: #{NO_RESULTS_VALUE_MSG}")
139
157
  path = RSpecDefaults::TEMPORARY_FILE_PATH
140
158
  end
141
159
 
@@ -84,8 +84,8 @@ RSpec.describe Guard::RSpec::Deprecator do
84
84
  expect(Guard::Compat::UI).to receive(:warning).with(
85
85
  "Guard::RSpec DEPRECATION WARNING:" +
86
86
  " The :focus_on_failed option is deprecated." +
87
- " Focus mode is the default and can be changed using new" +
88
- " :failed_mode option." +
87
+ " Please set new :failed_mode option value to" +
88
+ " :focus instead." +
89
89
  " https://github.com/guard/guard-rspec#list-of-available-options")
90
90
  deprecator.warns_about_deprecated_options
91
91
  end
@@ -58,11 +58,13 @@ RSpec.describe klass do
58
58
 
59
59
  # Line numbers in failed_locations needs to be omitted because of
60
60
  # https://github.com/rspec/rspec-core/issues/952
61
- expect(inspector.paths(other_paths)).to match_array([
62
- "spec/lib/guard/rspec/deprecator_spec.rb",
63
- "spec/lib/guard/rspec/runner_spec.rb",
64
- "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb"
65
- ])
61
+ expect(inspector.paths(other_paths)).to match_array(
62
+ [
63
+ "spec/lib/guard/rspec/deprecator_spec.rb",
64
+ "spec/lib/guard/rspec/runner_spec.rb",
65
+ "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb"
66
+ ]
67
+ )
66
68
  inspector.failed(other_failed_locations)
67
69
 
68
70
  # Now it returns other failed locations
@@ -70,18 +72,24 @@ RSpec.describe klass do
70
72
  inspector.paths(
71
73
  %w(spec/lib/guard/rspec/inspectors/base_inspector_spec.rb)
72
74
  )
73
- ).to match_array([
74
- "spec/lib/guard/rspec/runner_spec.rb",
75
- "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb",
76
- "spec/lib/guard/rspec/inspectors/base_inspector_spec.rb"
77
- ])
75
+ ).to match_array(
76
+ [
77
+ "spec/lib/guard/rspec/runner_spec.rb",
78
+ "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb",
79
+ "spec/lib/guard/rspec/inspectors/base_inspector_spec.rb"
80
+ ]
81
+ )
78
82
  inspector.failed(other_failed_locations)
79
83
 
80
- expect(inspector.paths(%w(spec/lib/guard/rspec/runner_spec.rb))).
81
- to match_array([
84
+ expect(
85
+ inspector.paths(%w(spec/lib/guard/rspec/runner_spec.rb))
86
+ ).to match_array(
87
+ [
82
88
  "spec/lib/guard/rspec/runner_spec.rb",
83
89
  "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb"
84
- ])
90
+ ]
91
+ )
92
+
85
93
  inspector.failed([])
86
94
 
87
95
  # Now there is no failed locations
@@ -6,7 +6,7 @@ RSpec.describe Guard::RSpec::Notifier do
6
6
  let(:options) { { notification: true, title: "RSpec results" } }
7
7
  let(:notifier) { Guard::RSpec::Notifier.new(options) }
8
8
 
9
- def expect_notification(title = "RSpec results", message, image, priority)
9
+ def expect_notification(message, image, priority, title = "RSpec results")
10
10
  expect(Guard::Compat::UI).to receive(:notify).
11
11
  with(message, title: title, image: image, priority: priority)
12
12
  end
@@ -21,7 +21,7 @@ RSpec.describe Guard::RSpec::Notifier do
21
21
  let(:options) { { notification: true, title: "Failure title" } }
22
22
 
23
23
  it "notifies with the title" do
24
- expect_notification("Failure title", "Failed", :failed, 2)
24
+ expect_notification("Failed", :failed, 2, "Failure title")
25
25
  notifier.notify_failure
26
26
  end
27
27
  end
@@ -64,7 +64,7 @@ RSpec.describe Guard::RSpec::Notifier do
64
64
  let(:options) { { notification: true, title: "Custom title" } }
65
65
 
66
66
  it "notifies with the title" do
67
- expect_notification("Custom title", "This is summary", :success, -2)
67
+ expect_notification("This is summary", :success, -2, "Custom title")
68
68
  notifier.notify("This is summary")
69
69
  end
70
70
  end
@@ -16,7 +16,7 @@ RSpec.describe Guard::RSpec::Results do
16
16
  [
17
17
  "5 examples, 2 failures (3 pending)\n",
18
18
  "foo1/bar1_spec.rb\n",
19
- "foo1/bar2_spec.rb\n",
19
+ "foo1/bar2_spec.rb\n"
20
20
  ]
21
21
  end
22
22
 
@@ -272,10 +272,12 @@ RSpec.describe Guard::RSpec::Runner do
272
272
 
273
273
  context "with failed paths" do
274
274
  before do
275
- allow(results).to receive(:failed_paths).and_return([
276
- "./failed_spec.rb:123",
277
- "./other/failed_spec.rb:77"
278
- ])
275
+ allow(results).to receive(:failed_paths).and_return(
276
+ [
277
+ "./failed_spec.rb:123",
278
+ "./other/failed_spec.rb:77"
279
+ ]
280
+ )
279
281
  end
280
282
 
281
283
  it "notifies inspector about failed paths" do
@@ -50,7 +50,8 @@ RSpec.describe Guard::RSpecFormatter do
50
50
 
51
51
  around do |example|
52
52
  env_var = "GUARD_RSPEC_RESULTS_FILE"
53
- old, ENV[env_var] = ENV[env_var], "foobar.txt"
53
+ old = ENV[env_var]
54
+ ENV[env_var] = "foobar.txt"
54
55
  example.run
55
56
  ENV[env_var] = old
56
57
  end
@@ -254,5 +255,22 @@ RSpec.describe Guard::RSpecFormatter do
254
255
  end
255
256
  end
256
257
  end
258
+
259
+ context "when RSpec 3.0 is configured to use multiple patterns" do
260
+ before do
261
+ allow(::RSpec.configuration).to receive(:pattern).
262
+ and_return("**{,/*/**}/*_spec.rb,**/*.feature")
263
+ end
264
+
265
+ it "matches a spec file with the first pattern" do
266
+ expect(described_class.spec_path?("./spec/foo_spec.rb")).
267
+ to be_truthy
268
+ end
269
+
270
+ it "matches a spec file with the second pattern" do
271
+ expect(described_class.spec_path?("./spec/acceptance/bar.feature")).
272
+ to be_truthy
273
+ end
274
+ end
257
275
  end
258
276
  end
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.6.4
4
+ version: 4.6.5
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: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -162,7 +162,7 @@ files:
162
162
  - spec/lib/guard/rspec_formatter_spec.rb
163
163
  - spec/lib/guard/rspec_spec.rb
164
164
  - spec/spec_helper.rb
165
- homepage: https://rubygems.org/gems/guard-rspec
165
+ homepage: https://github.com/guard/guard-rspec
166
166
  licenses:
167
167
  - MIT
168
168
  metadata: {}
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.4.5
185
+ rubygems_version: 2.5.1
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Guard gem for RSpec