guard-rspec 4.3.1 → 4.4.1

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +262 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +2 -0
  5. data/.rubocop_todo.yml +10 -0
  6. data/.travis.yml +2 -3
  7. data/CONTRIBUTING.md +1 -1
  8. data/Gemfile +9 -2
  9. data/Guardfile +11 -4
  10. data/README.md +8 -4
  11. data/Rakefile +23 -2
  12. data/gemfiles/Gemfile.rspec-2.14 +1 -0
  13. data/gemfiles/Gemfile.rspec-2.99 +14 -0
  14. data/gemfiles/Gemfile.rspec-3.0 +1 -0
  15. data/guard-rspec.gemspec +18 -16
  16. data/lib/guard/rspec.rb +13 -8
  17. data/lib/guard/rspec/command.rb +30 -12
  18. data/lib/guard/rspec/deprecator.rb +32 -11
  19. data/lib/guard/rspec/inspectors/base_inspector.rb +36 -15
  20. data/lib/guard/rspec/inspectors/factory.rb +7 -8
  21. data/lib/guard/rspec/inspectors/focused_inspector.rb +2 -2
  22. data/lib/guard/rspec/inspectors/keeping_inspector.rb +7 -6
  23. data/lib/guard/rspec/inspectors/simple_inspector.rb +3 -3
  24. data/lib/guard/rspec/notifier.rb +9 -5
  25. data/lib/guard/rspec/options.rb +12 -10
  26. data/lib/guard/rspec/runner.rb +41 -25
  27. data/lib/guard/rspec/templates/Guardfile +43 -15
  28. data/lib/guard/rspec/version.rb +1 -1
  29. data/lib/guard/rspec_formatter.rb +111 -0
  30. data/spec/lib/guard/rspec/command_spec.rb +48 -12
  31. data/spec/lib/guard/rspec/deprecator_spec.rb +37 -18
  32. data/spec/lib/guard/rspec/inspectors/base_inspector_spec.rb +129 -18
  33. data/spec/lib/guard/rspec/inspectors/factory_spec.rb +20 -15
  34. data/spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb +79 -13
  35. data/spec/lib/guard/rspec/inspectors/keeping_inspector_spec.rb +103 -33
  36. data/spec/lib/guard/rspec/inspectors/shared_examples.rb +93 -31
  37. data/spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb +52 -16
  38. data/spec/lib/guard/rspec/notifier_spec.rb +49 -27
  39. data/spec/lib/guard/rspec/runner_spec.rb +120 -77
  40. data/spec/lib/guard/rspec_formatter_spec.rb +144 -0
  41. data/spec/lib/guard/rspec_spec.rb +23 -18
  42. data/spec/spec_helper.rb +99 -14
  43. metadata +12 -7
  44. data/lib/guard/rspec/formatter.rb +0 -99
  45. data/spec/lib/guard/rspec/formatter_spec.rb +0 -122
@@ -1,22 +1,25 @@
1
- require 'spec_helper'
1
+ require "guard/compat/test/helper"
2
+ require "guard/rspec/deprecator"
2
3
 
3
- describe Guard::RSpec::Deprecator do
4
+ RSpec.describe Guard::RSpec::Deprecator do
4
5
  let(:options) { {} }
5
6
  let(:deprecator) { Guard::RSpec::Deprecator.new(options) }
6
7
 
7
- describe '#warns_about_deprecated_options' do
8
+ describe "#warns_about_deprecated_options" do
8
9
 
9
- describe 'handling of environment variable SPEC_OPTS' do
10
+ describe "handling of environment variable SPEC_OPTS" do
10
11
  it "shows warning if SPEC_OPTS is set" do
11
- ENV['SPEC_OPTS'] = '-f p'
12
+ ENV["SPEC_OPTS"] = "-f p"
12
13
  expect(Guard::UI).to receive(:warning).with(
13
- 'The SPEC_OPTS environment variable is present. This can conflict with guard-rspec.')
14
+ "The SPEC_OPTS environment variable is present." +
15
+ " This can conflict with guard-rspec.")
14
16
  deprecator.warns_about_deprecated_options
15
- ENV['SPEC_OPTS'] = nil # otherwise other specs pick it up and fail
17
+ ENV["SPEC_OPTS"] = nil # otherwise other specs pick it up and fail
16
18
  end
17
19
  it "does not show warning if SPEC_OPTS is unset" do
18
20
  expect(Guard::UI).to_not receive(:warning).with(
19
- 'The SPEC_OPTS environment variable is present. This can conflict with guard-rspec.')
21
+ "The SPEC_OPTS environment variable is present." +
22
+ " This can conflict with guard-rspec.")
20
23
  deprecator.warns_about_deprecated_options
21
24
  end
22
25
  end
@@ -26,7 +29,9 @@ describe Guard::RSpec::Deprecator do
26
29
 
27
30
  it "shows deprecation warning" do
28
31
  expect(Guard::UI).to receive(:warning).with(
29
- 'Guard::RSpec DEPRECATION WARNING: The :version option is deprecated. Only RSpec ~> 2.14 is now supported.')
32
+ "Guard::RSpec DEPRECATION WARNING:" +
33
+ " The :version option is deprecated." +
34
+ " Only RSpec ~> 2.14 is now supported.")
30
35
  deprecator.warns_about_deprecated_options
31
36
  end
32
37
  end
@@ -36,39 +41,53 @@ describe Guard::RSpec::Deprecator do
36
41
 
37
42
  it "shows deprecation warning" do
38
43
  expect(Guard::UI).to receive(:warning).with(
39
- 'Guard::RSpec DEPRECATION WARNING: The :exclude option is deprecated. Please Guard ignore method instead. https://github.com/guard/guard#ignore')
44
+ "Guard::RSpec DEPRECATION WARNING:" +
45
+ " The :exclude option is deprecated." +
46
+ " Please Guard ignore method instead." +
47
+ " https://github.com/guard/guard#ignore")
40
48
  deprecator.warns_about_deprecated_options
41
49
  end
42
50
  end
43
51
 
44
- %w[color drb fail_fast formatter env bundler binstubs rvm cli spring turnip zeus foreman].each do |option|
52
+ %w(color drb fail_fast formatter env bundler binstubs rvm cli
53
+ spring turnip zeus foreman).each do |option|
45
54
  describe "with #{option} option" do
46
55
  let(:options) { { option.to_sym => 1 } }
47
56
 
48
57
  it "shows deprecation warning" do
49
58
  expect(Guard::UI).to receive(:warning).with(
50
- "Guard::RSpec DEPRECATION WARNING: The :#{option} option is deprecated. Please customize the new :cmd option to fit your need.")
59
+ "Guard::RSpec DEPRECATION WARNING: The :#{option} option is" +
60
+ " deprecated. Please customize the new :cmd option to" +
61
+ " fit your need.")
51
62
  deprecator.warns_about_deprecated_options
52
63
  end
53
64
  end
54
65
  end
55
66
 
56
- describe 'with keep_failed option' do
67
+ describe "with keep_failed option" do
57
68
  let(:options) { { keep_failed: true } }
58
69
 
59
- it 'shows deprecation warning' do
70
+ it "shows deprecation warning" do
60
71
  expect(Guard::UI).to receive(:warning).with(
61
- 'Guard::RSpec DEPRECATION WARNING: The :keep_failed option is deprecated. Please set new :failed_mode option value to :keep instead. https://github.com/guard/guard-rspec#list-of-available-options')
72
+ "Guard::RSpec DEPRECATION WARNING:" +
73
+ " The :keep_failed option is deprecated." +
74
+ " Please set new :failed_mode option value to" +
75
+ " :keep instead." +
76
+ " https://github.com/guard/guard-rspec#list-of-available-options")
62
77
  deprecator.warns_about_deprecated_options
63
78
  end
64
79
  end
65
80
 
66
- describe 'with focus_on_failed option' do
81
+ describe "with focus_on_failed option" do
67
82
  let(:options) { { focus_on_failed: true } }
68
83
 
69
- it 'shows deprecation warning' do
84
+ it "shows deprecation warning" do
70
85
  expect(Guard::UI).to receive(:warning).with(
71
- 'Guard::RSpec DEPRECATION WARNING: The :focus_on_failed option is deprecated. Focus mode is the default and can be changed using new :failed_mode option. https://github.com/guard/guard-rspec#list-of-available-options')
86
+ "Guard::RSpec DEPRECATION WARNING:" +
87
+ " The :focus_on_failed option is deprecated." +
88
+ " Focus mode is the default and can be changed using new" +
89
+ " :failed_mode option." +
90
+ " https://github.com/guard/guard-rspec#list-of-available-options")
72
91
  deprecator.warns_about_deprecated_options
73
92
  end
74
93
  end
@@ -1,34 +1,145 @@
1
- require 'spec_helper'
1
+ require "guard/compat/test/helper"
2
2
 
3
- describe Guard::RSpec::Inspectors::BaseInspector do
4
- let(:options) { { custom: 'value', spec_paths: %w[myspec] } }
3
+ require "guard/rspec/inspectors/base_inspector"
4
+
5
+ RSpec.describe Guard::RSpec::Inspectors::BaseInspector do
6
+ let(:options) { { custom: "value", spec_paths: %w(myspec) } }
5
7
  let(:inspector) { Guard::RSpec::Inspectors::BaseInspector.new(options) }
6
- let(:paths) { %w[spec/foo_spec.rb spec/bar_spec.rb] }
7
- let(:abstract_error) { 'Must be implemented in subclass' }
8
+ let(:paths) { %w(spec/foo_spec.rb spec/bar_spec.rb) }
8
9
 
9
- describe '.initialize' do
10
- it 'sets options and spec_paths' do
10
+ describe ".initialize" do
11
+ it "sets options and spec_paths" do
11
12
  expect(inspector.options).to include(:custom, :spec_paths)
12
- expect(inspector.options[:custom]).to eq('value')
13
- expect(inspector.spec_paths).to eq(%w[myspec])
13
+ expect(inspector.options[:custom]).to eq("value")
14
+ expect(inspector.spec_paths).to eq(%w(myspec))
14
15
  end
15
16
  end
16
17
 
17
- describe '#paths' do
18
- it 'should not be emplemented here' do
19
- expect { inspector.paths(paths) }.to raise_error(abstract_error)
18
+ describe "#paths" do
19
+ it "should not be implemented here" do
20
+ expect { inspector.paths(paths) }.to raise_error(NotImplementedError)
21
+ end
22
+
23
+ context "specific inspector" do
24
+ class FooInspector < Guard::RSpec::Inspectors::BaseInspector
25
+ def paths(paths)
26
+ _clean(paths)
27
+ end
28
+ end
29
+
30
+ let(:options) do
31
+ {
32
+ chdir: chdir,
33
+ spec_paths: ["spec"]
34
+ }
35
+ end
36
+ let(:chdir) { nil }
37
+ let(:inspector) { FooInspector.new(options) }
38
+
39
+ subject { inspector.paths(paths) }
40
+
41
+ context "with dirs" do
42
+ let(:paths) { ["spec"] }
43
+
44
+ it "returns matching paths" do
45
+ allow(File).to receive(:directory?).
46
+ with("spec").and_return(false)
47
+
48
+ allow(Dir).to receive(:[]).and_return(["foo"])
49
+
50
+ expect(subject).to eq(paths)
51
+ end
52
+
53
+ context "chdir option present" do
54
+ let(:chdir) { "moduleA" }
55
+ let(:paths) { ["#{chdir}/spec"] }
56
+
57
+ it "returns matching paths" do
58
+
59
+ allow(Dir).to receive(:[]).
60
+ with("moduleA/spec/**{,/*/**}/*[_.]spec.rb").
61
+ and_return(paths)
62
+
63
+ allow(Dir).to receive(:[]).
64
+ with("moduleA/spec/**{,/*/**}/*.feature").
65
+ and_return([])
66
+
67
+ allow(File).to receive(:directory?).
68
+ with("moduleA/spec").and_return(false)
69
+
70
+ expect(subject).to eq(paths)
71
+ end
72
+ end
73
+ end
74
+
75
+ context "with spec files" do
76
+ let(:paths) do
77
+ ["app/models/a_foo.rb", "spec/models/a_foo_spec.rb"]
78
+ end
79
+ let(:spec_files) do
80
+ [["spec/models/a_foo_spec.rb",
81
+ "spec/models/b_foo_spec.rb"]]
82
+ end
83
+
84
+ it "returns matching paths" do
85
+ allow(File).to receive(:directory?).with("app/models/a_foo.rb").
86
+ and_return(false)
87
+
88
+ allow(File).to receive(:directory?).with("spec/models/a_foo_spec.rb").
89
+ and_return(false)
90
+
91
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*[_.]spec.rb").
92
+ and_return(spec_files)
93
+
94
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*.feature").
95
+ and_return([])
96
+
97
+ expect(subject).to eq(["spec/models/a_foo_spec.rb"])
98
+ end
99
+
100
+ context "chdir option present" do
101
+ let(:chdir) { "moduleA" }
102
+ let(:paths) do
103
+ ["moduleA/models/a_foo.rb", "spec/models/a_foo_spec.rb"]
104
+ end
105
+
106
+ let(:spec_files) do
107
+ [["moduleA/spec/models/a_foo_spec.rb",
108
+ "moduleA/spec/models/b_foo_spec.rb"]]
109
+ end
110
+
111
+ it "returns matching paths" do
112
+ allow(File).to receive(:directory?).with("moduleA/models/a_foo.rb").
113
+ and_return(false)
114
+
115
+ allow(File).to receive(:directory?).
116
+ with("spec/models/a_foo_spec.rb").
117
+ and_return(false)
118
+
119
+ allow(Dir).to receive(:[]).
120
+ with("moduleA/spec/**{,/*/**}/*[_.]spec.rb").
121
+ and_return(spec_files)
122
+
123
+ allow(Dir).to receive(:[]).
124
+ with("moduleA/spec/**{,/*/**}/*.feature").
125
+ and_return([])
126
+
127
+ expect(subject).to eq(["spec/models/a_foo_spec.rb"])
128
+ end
129
+ end
130
+ end
20
131
  end
21
132
  end
22
133
 
23
- describe '#failed' do
24
- it 'should not be emplemented here' do
25
- expect { inspector.failed(paths) }.to raise_error(abstract_error)
134
+ describe "#failed" do
135
+ it "should not be implemented here" do
136
+ expect { inspector.failed(paths) }.to raise_error(NotImplementedError)
26
137
  end
27
138
  end
28
139
 
29
- describe '#reload' do
30
- it 'should not be emplemented here' do
31
- expect { inspector.reload }.to raise_error(abstract_error)
140
+ describe "#reload" do
141
+ it "should not be implemented here" do
142
+ expect { inspector.reload }.to raise_error(NotImplementedError)
32
143
  end
33
144
  end
34
145
  end
@@ -1,39 +1,44 @@
1
- require 'spec_helper'
1
+ require "guard/compat/test/helper"
2
2
 
3
- describe Guard::RSpec::Inspectors::Factory do
3
+ require "guard/rspec/inspectors/factory"
4
+
5
+ RSpec.describe Guard::RSpec::Inspectors::Factory do
4
6
  let(:factory) { Guard::RSpec::Inspectors::Factory }
5
7
  let(:options) { {} }
6
8
 
7
- it 'can not be instantiated' do
9
+ it "can not be instantiated" do
8
10
  expect { factory.new(options) }.to raise_error(NoMethodError)
9
11
  end
10
12
 
11
- context 'with :focus failed mode and custom options' do
12
- let(:options) { { failed_mode: :focus, custom: 'value' } }
13
+ context "with :focus failed mode and custom options" do
14
+ let(:options) { { failed_mode: :focus, custom: "value" } }
13
15
 
14
- it 'creates FocusedInspector instance with custom options' do
16
+ it "creates FocusedInspector instance with custom options" do
15
17
  inspector = factory.create(options)
16
- expect(inspector).to be_an_instance_of(Guard::RSpec::Inspectors::FocusedInspector)
18
+ expect(inspector).
19
+ to be_an_instance_of(Guard::RSpec::Inspectors::FocusedInspector)
17
20
  expect(inspector.options).to eq(options)
18
21
  end
19
22
  end
20
23
 
21
- context 'with :keep failed mode and custom options' do
22
- let(:options) { { failed_mode: :keep, custom: 'value' } }
24
+ context "with :keep failed mode and custom options" do
25
+ let(:options) { { failed_mode: :keep, custom: "value" } }
23
26
 
24
- it 'creates KeepingInspector instance with custom options' do
27
+ it "creates KeepingInspector instance with custom options" do
25
28
  inspector = factory.create(options)
26
- expect(inspector).to be_an_instance_of(Guard::RSpec::Inspectors::KeepingInspector)
29
+ expect(inspector).
30
+ to be_an_instance_of(Guard::RSpec::Inspectors::KeepingInspector)
27
31
  expect(inspector.options).to eq(options)
28
32
  end
29
33
  end
30
34
 
31
- context 'with :none failed mode and custom options' do
32
- let(:options) { { failed_mode: :none, custom: 'value' } }
35
+ context "with :none failed mode and custom options" do
36
+ let(:options) { { failed_mode: :none, custom: "value" } }
33
37
 
34
- it 'creates SimpleInspector instance with custom options' do
38
+ it "creates SimpleInspector instance with custom options" do
35
39
  inspector = factory.create(options)
36
- expect(inspector).to be_an_instance_of(Guard::RSpec::Inspectors::SimpleInspector)
40
+ expect(inspector).
41
+ to be_an_instance_of(Guard::RSpec::Inspectors::SimpleInspector)
37
42
  expect(inspector.options).to eq(options)
38
43
  end
39
44
  end
@@ -1,19 +1,55 @@
1
- require 'spec_helper'
2
- require 'lib/guard/rspec/inspectors/shared_examples'
1
+ require "guard/compat/test/helper"
2
+
3
+ require "lib/guard/rspec/inspectors/shared_examples"
4
+
5
+ require "guard/rspec/inspectors/focused_inspector"
3
6
 
4
7
  klass = Guard::RSpec::Inspectors::FocusedInspector
5
8
 
6
- describe klass do
7
- include_examples 'inspector', klass
9
+ RSpec.describe klass do
10
+ include_examples "inspector", klass
8
11
 
9
12
  # Use real paths because BaseInspector#_clean will be used to clean them
10
- let(:other_paths) { [
11
- 'spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb',
12
- 'spec/lib/guard/rspec/runner_spec.rb'
13
- ] }
14
- let(:other_failed_locations) { %w[./spec/lib/guard/rspec/deprecator_spec.rb:446] }
13
+ let(:other_paths) do
14
+ [
15
+ "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb",
16
+ "spec/lib/guard/rspec/runner_spec.rb"
17
+ ]
18
+ end
19
+
20
+ let(:other_failed_locations) do
21
+ %w(./spec/lib/guard/rspec/deprecator_spec.rb:446)
22
+ end
23
+
24
+ it "remembers failed paths and returns them until they all pass" do
25
+ allow(File).to receive(:directory?).
26
+ with("spec/lib/guard/rspec/inspectors/base_inspector_spec.rb").
27
+ and_return(false)
28
+
29
+ allow(File).to receive(:directory?).
30
+ with("spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb").
31
+ and_return(false)
32
+
33
+ allow(File).to receive(:directory?).
34
+ with("spec/lib/guard/rspec/runner_spec.rb").
35
+ and_return(false)
36
+
37
+ allow(File).to receive(:directory?).
38
+ with("spec/lib/guard/rspec/deprecator_spec.rb").
39
+ and_return(false)
40
+
41
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*[_.]spec.rb").
42
+ and_return(paths + other_paths)
43
+
44
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*[_.]spec.rb").
45
+ and_return([])
46
+
47
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*.feature").
48
+ and_return([])
49
+
50
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*.feature").
51
+ and_return([])
15
52
 
16
- it 'remembers failed paths and returns them until they all pass' do
17
53
  expect(inspector.paths(paths)).to match_array(paths)
18
54
  inspector.failed(failed_locations)
19
55
 
@@ -39,7 +75,9 @@ describe klass do
39
75
 
40
76
  # Return other_failed_locations until they pass
41
77
  3.times do
42
- expect(inspector.paths(other_paths)).to match_array(other_failed_locations)
78
+ expect(inspector.paths(other_paths)).
79
+ to match_array(other_failed_locations)
80
+
43
81
  inspector.failed(other_failed_locations)
44
82
 
45
83
  expect(inspector.paths(paths)).to match_array(other_failed_locations)
@@ -62,8 +100,36 @@ describe klass do
62
100
  expect(inspector.paths([])).to eq([])
63
101
  end
64
102
 
65
- describe '#reload' do
66
- it 'force to forget about focused locations' do
103
+ describe "#reload" do
104
+ it "force to forget about focused locations" do
105
+ allow(File).to receive(:directory?).
106
+ with("spec/lib/guard/rspec/inspectors/base_inspector_spec.rb").
107
+ and_return(false)
108
+
109
+ allow(File).to receive(:directory?).
110
+ with("spec/lib/guard/rspec/runner_spec.rb").
111
+ and_return(false)
112
+
113
+ allow(File).to receive(:directory?).
114
+ with("spec/lib/guard/rspec/deprecator_spec.rb").
115
+ and_return(false)
116
+
117
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*[_.]spec.rb").
118
+ and_return(paths + other_paths)
119
+
120
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*[_.]spec.rb").
121
+ and_return([])
122
+
123
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*.feature").
124
+ and_return([])
125
+
126
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*.feature").
127
+ and_return([])
128
+
129
+ allow(File).to receive(:directory?).
130
+ with("spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb").
131
+ and_return(false)
132
+
67
133
  expect(inspector.paths(paths)).to match_array(paths)
68
134
  inspector.failed(failed_locations)
69
135
 
@@ -1,55 +1,123 @@
1
- require 'spec_helper'
2
- require 'lib/guard/rspec/inspectors/shared_examples'
1
+ require "guard/compat/test/helper"
2
+
3
+ require "lib/guard/rspec/inspectors/shared_examples"
4
+
5
+ require "guard/rspec/inspectors/keeping_inspector"
3
6
 
4
7
  klass = Guard::RSpec::Inspectors::KeepingInspector
5
8
 
6
- describe klass do
7
- include_examples 'inspector', klass
9
+ RSpec.describe klass do
10
+ include_examples "inspector", klass
8
11
 
9
12
  # Use real paths because BaseInspector#_clean will be used to clean them
10
- let(:other_paths) { [
11
- 'spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb',
12
- 'spec/lib/guard/rspec/runner_spec.rb'
13
- ] }
14
- let(:other_failed_locations) { [
15
- './spec/lib/guard/rspec/runner_spec.rb:12',
16
- './spec/lib/guard/rspec/runner_spec.rb:100',
17
- './spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb:12'
18
- ] }
19
-
20
- it 'remembers failed paths and returns them along with new paths' do
13
+ let(:other_paths) do
14
+ [
15
+ "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb",
16
+ "spec/lib/guard/rspec/runner_spec.rb"
17
+ ]
18
+ end
19
+ let(:other_failed_locations) do
20
+ [
21
+ "./spec/lib/guard/rspec/runner_spec.rb:12",
22
+ "./spec/lib/guard/rspec/runner_spec.rb:100",
23
+ "./spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb:12"
24
+ ]
25
+ end
26
+
27
+ it "remembers failed paths and returns them along with new paths" do
28
+ allow(File).to receive(:directory?).
29
+ with("spec/lib/guard/rspec/inspectors/base_inspector_spec.rb").
30
+ and_return(false)
31
+
32
+ allow(File).to receive(:directory?).
33
+ with("spec/lib/guard/rspec/runner_spec.rb").
34
+ and_return(false)
35
+
36
+ allow(File).to receive(:directory?).
37
+ with("spec/lib/guard/rspec/deprecator_spec.rb").
38
+ and_return(false)
39
+
40
+ allow(File).to receive(:directory?).
41
+ with("spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb").
42
+ and_return(false)
43
+
44
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*[_.]spec.rb").
45
+ and_return(paths + other_paths)
46
+
47
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*[_.]spec.rb").
48
+ and_return([])
49
+
50
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*.feature").
51
+ and_return([])
52
+
53
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*.feature").
54
+ and_return([])
55
+
21
56
  expect(inspector.paths(paths)).to eq(paths)
22
57
  inspector.failed(failed_locations)
23
58
 
24
59
  # Line numbers in failed_locations needs to be omitted because of
25
60
  # https://github.com/rspec/rspec-core/issues/952
26
61
  expect(inspector.paths(other_paths)).to match_array([
27
- 'spec/lib/guard/rspec/deprecator_spec.rb',
28
- 'spec/lib/guard/rspec/runner_spec.rb',
29
- 'spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb'
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"
30
65
  ])
31
66
  inspector.failed(other_failed_locations)
32
67
 
33
68
  # Now it returns other failed locations
34
- expect(inspector.paths(%w[spec/lib/guard/rspec/inspectors/base_inspector_spec.rb])).to match_array([
35
- 'spec/lib/guard/rspec/runner_spec.rb',
36
- 'spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb',
37
- 'spec/lib/guard/rspec/inspectors/base_inspector_spec.rb'
38
- ])
69
+ expect(
70
+ inspector.paths(
71
+ %w(spec/lib/guard/rspec/inspectors/base_inspector_spec.rb))
72
+ ).
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
+ ])
39
78
  inspector.failed(other_failed_locations)
40
79
 
41
- expect(inspector.paths(%w[spec/lib/guard/rspec/runner_spec.rb])).to match_array([
42
- 'spec/lib/guard/rspec/runner_spec.rb',
43
- 'spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb'
44
- ])
80
+ expect(inspector.paths(%w(spec/lib/guard/rspec/runner_spec.rb))).
81
+ to match_array([
82
+ "spec/lib/guard/rspec/runner_spec.rb",
83
+ "spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb"
84
+ ])
45
85
  inspector.failed([])
46
86
 
47
87
  # Now there is no failed locations
48
88
  expect(inspector.paths(paths)).to match_array(paths)
49
89
  end
50
90
 
51
- describe '#reload' do
52
- it 'force to forget about failed locations' do
91
+ describe "#reload" do
92
+ it "force to forget about failed locations" do
93
+ allow(File).to receive(:directory?).
94
+ with("spec/lib/guard/rspec/inspectors/base_inspector_spec.rb").
95
+ and_return(false)
96
+
97
+ allow(File).to receive(:directory?).
98
+ with("spec/lib/guard/rspec/runner_spec.rb").
99
+ and_return(false)
100
+
101
+ allow(File).to receive(:directory?).
102
+ with("spec/lib/guard/rspec/deprecator_spec.rb").
103
+ and_return(false)
104
+
105
+ allow(File).to receive(:directory?).
106
+ with("spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb").
107
+ and_return(false)
108
+
109
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*[_.]spec.rb").
110
+ and_return(paths + other_paths)
111
+
112
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*[_.]spec.rb").
113
+ and_return([])
114
+
115
+ allow(Dir).to receive(:[]).with("myspec/**{,/*/**}/*.feature").
116
+ and_return([])
117
+
118
+ allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*.feature").
119
+ and_return([])
120
+
53
121
  expect(inspector.paths(paths)).to eq(paths)
54
122
  inspector.failed(failed_locations)
55
123
 
@@ -66,7 +134,7 @@ end
66
134
  # bit it doesn't work because of bug with RSpec
67
135
  # https://github.com/rspec/rspec-core/issues/952
68
136
  #
69
- #describe klass do
137
+ # describe klass do
70
138
  # include_examples 'inspector', klass
71
139
  #
72
140
  # # Use real paths because BaseInspector#_clean will be used to clean them
@@ -93,14 +161,16 @@ end
93
161
  # inspector.failed(other_failed_locations)
94
162
  #
95
163
  # # Now it returns other failed locations
96
- # expect(inspector.paths(%w[spec/lib/guard/rspec/deprecator_spec.rb])).to match_array(
164
+ # expect(inspector.paths(%w[spec/lib/guard/rspec/deprecator_spec.rb])).to
165
+ # match_array(
97
166
  # other_failed_locations +
98
167
  # %w[spec/lib/guard/rspec/deprecator_spec.rb]
99
168
  # )
100
169
  # inspector.failed(other_failed_locations)
101
170
  #
102
171
  # # It returns runner_spec.rb without locations in that spec
103
- # expect(inspector.paths(%w[spec/lib/guard/rspec/runner_spec.rb])).to match_array([
172
+ # expect(inspector.paths(%w[spec/lib/guard/rspec/runner_spec.rb])).
173
+ # to match_array([
104
174
  # './spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb:12',
105
175
  # 'spec/lib/guard/rspec/runner_spec.rb'
106
176
  # ])
@@ -119,4 +189,4 @@ end
119
189
  # expect(inspector.paths(other_paths)).to match_array(other_paths)
120
190
  # end
121
191
  # end
122
- #end
192
+ # end