guard-rspec 2.1.0 → 4.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.hound.yml +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +40 -0
- data/.travis.yml +14 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +25 -0
- data/Guardfile +28 -0
- data/{LICENSE → LICENSE.txt} +4 -2
- data/README.md +99 -114
- data/Rakefile +38 -0
- data/gemfiles/Gemfile.rspec-2.99 +6 -0
- data/gemfiles/Gemfile.rspec-3.4 +6 -0
- data/gemfiles/common +9 -0
- data/guard-rspec.gemspec +25 -0
- data/lib/guard/rspec/command.rb +71 -0
- data/lib/guard/rspec/deprecator.rb +86 -0
- data/lib/guard/rspec/dsl.rb +72 -0
- data/lib/guard/rspec/inspectors/base_inspector.rb +73 -0
- data/lib/guard/rspec/inspectors/factory.rb +23 -0
- data/lib/guard/rspec/inspectors/focused_inspector.rb +39 -0
- data/lib/guard/rspec/inspectors/keeping_inspector.rb +97 -0
- data/lib/guard/rspec/inspectors/simple_inspector.rb +21 -0
- data/lib/guard/rspec/notifier.rb +55 -0
- data/lib/guard/rspec/options.rb +37 -0
- data/lib/guard/rspec/results.rb +23 -0
- data/lib/guard/rspec/rspec_process.rb +93 -0
- data/lib/guard/rspec/runner.rb +71 -174
- data/lib/guard/rspec/templates/Guardfile +49 -17
- data/lib/guard/rspec/version.rb +1 -1
- data/lib/guard/rspec.rb +30 -59
- data/lib/guard/rspec_defaults.rb +5 -0
- data/lib/guard/rspec_formatter.rb +147 -0
- data/lib/guard/rspec_formatter_results_path.rb +29 -0
- data/spec/acceptance/fixtures/succeeding_spec.rb +4 -0
- data/spec/acceptance/formatter_spec.rb +46 -0
- data/spec/lib/guard/rspec/command_spec.rb +95 -0
- data/spec/lib/guard/rspec/deprecator_spec.rb +101 -0
- data/spec/lib/guard/rspec/inspectors/base_inspector_spec.rb +144 -0
- data/spec/lib/guard/rspec/inspectors/factory_spec.rb +45 -0
- data/spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb +140 -0
- data/spec/lib/guard/rspec/inspectors/keeping_inspector_spec.rb +200 -0
- data/spec/lib/guard/rspec/inspectors/shared_examples.rb +121 -0
- data/spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb +59 -0
- data/spec/lib/guard/rspec/notifier_spec.rb +90 -0
- data/spec/lib/guard/rspec/results_spec.rb +66 -0
- data/spec/lib/guard/rspec/rspec_process_spec.rb +152 -0
- data/spec/lib/guard/rspec/runner_spec.rb +372 -0
- data/spec/lib/guard/rspec/template_spec.rb +78 -0
- data/spec/lib/guard/rspec_formatter_spec.rb +277 -0
- data/spec/lib/guard/rspec_spec.rb +91 -0
- data/spec/spec_helper.rb +145 -0
- metadata +103 -42
- data/lib/guard/rspec/formatter.rb +0 -56
- data/lib/guard/rspec/inspector.rb +0 -72
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
require 'gem_isolator'
|
5
|
+
|
6
|
+
RSpec.describe "Formatter test", type: :acceptance do
|
7
|
+
context "when isolated" do
|
8
|
+
before { allow(Kernel).to receive(:system).and_call_original }
|
9
|
+
|
10
|
+
let!(:formatter) { File.expand_path('lib/guard/rspec_formatter.rb') }
|
11
|
+
|
12
|
+
context "when a valid results file path is given" do
|
13
|
+
around do |example|
|
14
|
+
Tempfile.open('results') do |tempfile|
|
15
|
+
@results_file = tempfile.path
|
16
|
+
example.run
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when a succeeding command is given" do
|
21
|
+
let!(:spec) do
|
22
|
+
File.expand_path('spec/acceptance/fixtures/succeeding_spec.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:rspec_args) do
|
26
|
+
['-r', formatter, '-f', 'Guard::RSpecFormatter', spec]
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when guard is not in Gemfile" do
|
30
|
+
let(:gems) { [%w(rspec ~>3.4)] }
|
31
|
+
|
32
|
+
it "works" do
|
33
|
+
GemIsolator.isolate(gems: gems) do |env, isolation|
|
34
|
+
env = env.merge('GUARD_RSPEC_RESULTS_FILE' => @results_file)
|
35
|
+
|
36
|
+
# TODO: I don't know why Travis needs a full path for binaries
|
37
|
+
# for system() to work.
|
38
|
+
rspec = env['PATH'].sub(/:.*/, '/rspec')
|
39
|
+
expect(isolation.system(env, rspec, *rspec_args)).to eq(true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "launchy"
|
2
|
+
|
3
|
+
require "guard/compat/test/helper"
|
4
|
+
require "guard/rspec/command"
|
5
|
+
|
6
|
+
RSpec.describe Guard::RSpec::Command do
|
7
|
+
let(:options) { {} }
|
8
|
+
let(:paths) { %w(path1 path2) }
|
9
|
+
let(:command) { Guard::RSpec::Command.new(paths, options) }
|
10
|
+
|
11
|
+
describe ".initialize" do
|
12
|
+
it "sets paths at the end" do
|
13
|
+
expect(command).to match(/path1 path2$/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets custom failure exit code" do
|
17
|
+
expect(command).to match(/--failure-exit-code 2/)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "sets formatter" do
|
21
|
+
regexp = %r{-r .*/lib/guard/rspec_formatter.rb -f Guard::RSpecFormatter}
|
22
|
+
expect(command).to match(regexp)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with custom cmd" do
|
26
|
+
let(:options) { { cmd: "rspec -t ~slow" } }
|
27
|
+
|
28
|
+
it "uses custom cmd" do
|
29
|
+
expect(command).to match(/^rspec -t ~slow/)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with RSpec defined formatter" do
|
34
|
+
let(:formatters) { [%w(doc output)] }
|
35
|
+
|
36
|
+
before do
|
37
|
+
allow(RSpec::Core::ConfigurationOptions).to receive(:new) do
|
38
|
+
instance_double(RSpec::Core::ConfigurationOptions,
|
39
|
+
options: { formatters: formatters })
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "uses them" do
|
44
|
+
expect(command).to match(/-f doc -o output/)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with no RSpec defined formatter" do
|
49
|
+
before do
|
50
|
+
allow(RSpec::Core::ConfigurationOptions).to receive(:new) do
|
51
|
+
instance_double(RSpec::Core::ConfigurationOptions,
|
52
|
+
options: { formatters: nil })
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "sets default progress formatter" do
|
57
|
+
expect(command).to match(/-f progress/)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with formatter in cmd" do
|
62
|
+
let(:options) { { cmd: "rspec -f doc" } }
|
63
|
+
|
64
|
+
it "sets no other formatters" do
|
65
|
+
expect(command).to match(/-f doc/)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "with cmd_additional_args" do
|
70
|
+
let(:options) { { cmd: "rspec", cmd_additional_args: "-f progress" } }
|
71
|
+
|
72
|
+
it "uses them" do
|
73
|
+
expect(command).to match(/-f progress/)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context ":chdir option present" do
|
78
|
+
let(:chdir) { "moduleA" }
|
79
|
+
let(:paths) do
|
80
|
+
%w(path1 path2).map { |p| "#{chdir}#{File::Separator}#{p}" }
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:options) do
|
84
|
+
{
|
85
|
+
cmd: "cd #{chdir} && rspec",
|
86
|
+
chdir: chdir
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
it "strips path of chdir" do
|
91
|
+
expect(command).to match(/path1 path2/)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "guard/compat/test/helper"
|
2
|
+
require "guard/rspec/deprecator"
|
3
|
+
|
4
|
+
RSpec.describe Guard::RSpec::Deprecator do
|
5
|
+
let(:options) { {} }
|
6
|
+
let(:deprecator) { Guard::RSpec::Deprecator.new(options) }
|
7
|
+
|
8
|
+
describe "#warns_about_deprecated_options" do
|
9
|
+
describe "handling of environment variable SPEC_OPTS" do
|
10
|
+
it "shows warning if SPEC_OPTS is set" do
|
11
|
+
ENV["SPEC_OPTS"] = "-f p"
|
12
|
+
expect(Guard::Compat::UI).to receive(:warning).with(
|
13
|
+
"The SPEC_OPTS environment variable is present." \
|
14
|
+
" This can conflict with guard-rspec."
|
15
|
+
)
|
16
|
+
deprecator.warns_about_deprecated_options
|
17
|
+
ENV["SPEC_OPTS"] = nil # otherwise other specs pick it up and fail
|
18
|
+
end
|
19
|
+
it "does not show warning if SPEC_OPTS is unset" do
|
20
|
+
expect(Guard::Compat::UI).to_not receive(:warning).with(
|
21
|
+
"The SPEC_OPTS environment variable is present." \
|
22
|
+
" This can conflict with guard-rspec."
|
23
|
+
)
|
24
|
+
deprecator.warns_about_deprecated_options
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "with version option" do
|
29
|
+
let(:options) { { version: 1 } }
|
30
|
+
|
31
|
+
it "shows deprecation warning" do
|
32
|
+
expect(Guard::Compat::UI).to receive(:warning).with(
|
33
|
+
"Guard::RSpec DEPRECATION WARNING:" \
|
34
|
+
" The :version option is deprecated." \
|
35
|
+
" Only RSpec ~> 2.14 is now supported."
|
36
|
+
)
|
37
|
+
deprecator.warns_about_deprecated_options
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "with exclude option" do
|
42
|
+
let(:options) { { exclude: "**" } }
|
43
|
+
|
44
|
+
it "shows deprecation warning" do
|
45
|
+
expect(Guard::Compat::UI).to receive(:warning).with(
|
46
|
+
"Guard::RSpec DEPRECATION WARNING:" \
|
47
|
+
" The :exclude option is deprecated." \
|
48
|
+
" Please Guard ignore method instead." \
|
49
|
+
" https://github.com/guard/guard#ignore"
|
50
|
+
)
|
51
|
+
deprecator.warns_about_deprecated_options
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
%w(color drb fail_fast formatter env bundler binstubs rvm cli
|
56
|
+
spring turnip zeus foreman).each do |option|
|
57
|
+
describe "with #{option} option" do
|
58
|
+
let(:options) { { option.to_sym => 1 } }
|
59
|
+
|
60
|
+
it "shows deprecation warning" do
|
61
|
+
expect(Guard::Compat::UI).to receive(:warning).with(
|
62
|
+
"Guard::RSpec DEPRECATION WARNING: The :#{option} option is" \
|
63
|
+
" deprecated. Please customize the new :cmd option to" \
|
64
|
+
" fit your need."
|
65
|
+
)
|
66
|
+
deprecator.warns_about_deprecated_options
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "with keep_failed option" do
|
72
|
+
let(:options) { { keep_failed: true } }
|
73
|
+
|
74
|
+
it "shows deprecation warning" do
|
75
|
+
expect(Guard::Compat::UI).to receive(:warning).with(
|
76
|
+
"Guard::RSpec DEPRECATION WARNING:" \
|
77
|
+
" The :keep_failed option is deprecated." \
|
78
|
+
" Please set new :failed_mode option value to" \
|
79
|
+
" :keep instead." \
|
80
|
+
" https://github.com/guard/guard-rspec#list-of-available-options"
|
81
|
+
)
|
82
|
+
deprecator.warns_about_deprecated_options
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "with focus_on_failed option" do
|
87
|
+
let(:options) { { focus_on_failed: true } }
|
88
|
+
|
89
|
+
it "shows deprecation warning" do
|
90
|
+
expect(Guard::Compat::UI).to receive(:warning).with(
|
91
|
+
"Guard::RSpec DEPRECATION WARNING:" \
|
92
|
+
" The :focus_on_failed option is deprecated." \
|
93
|
+
" Please set new :failed_mode option value to" \
|
94
|
+
" :focus instead." \
|
95
|
+
" https://github.com/guard/guard-rspec#list-of-available-options"
|
96
|
+
)
|
97
|
+
deprecator.warns_about_deprecated_options
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require "guard/compat/test/helper"
|
2
|
+
|
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) } }
|
7
|
+
let(:inspector) { Guard::RSpec::Inspectors::BaseInspector.new(options) }
|
8
|
+
let(:paths) { %w(spec/foo_spec.rb spec/bar_spec.rb) }
|
9
|
+
|
10
|
+
describe ".initialize" do
|
11
|
+
it "sets options and spec_paths" do
|
12
|
+
expect(inspector.options).to include(:custom, :spec_paths)
|
13
|
+
expect(inspector.options[:custom]).to eq("value")
|
14
|
+
expect(inspector.spec_paths).to eq(%w(myspec))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
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
|
+
allow(Dir).to receive(:[]).
|
59
|
+
with("moduleA/spec/**{,/*/**}/*[_.]spec.rb").
|
60
|
+
and_return(paths)
|
61
|
+
|
62
|
+
allow(Dir).to receive(:[]).
|
63
|
+
with("moduleA/spec/**{,/*/**}/*.feature").
|
64
|
+
and_return([])
|
65
|
+
|
66
|
+
allow(File).to receive(:directory?).
|
67
|
+
with("moduleA/spec").and_return(false)
|
68
|
+
|
69
|
+
expect(subject).to eq(paths)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "with spec files" do
|
75
|
+
let(:paths) do
|
76
|
+
["app/models/a_foo.rb", "spec/models/a_foo_spec.rb"]
|
77
|
+
end
|
78
|
+
let(:spec_files) do
|
79
|
+
[["spec/models/a_foo_spec.rb",
|
80
|
+
"spec/models/b_foo_spec.rb"]]
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns matching paths" do
|
84
|
+
allow(File).to receive(:directory?).with("app/models/a_foo.rb").
|
85
|
+
and_return(false)
|
86
|
+
|
87
|
+
allow(File).to receive(:directory?).with("spec/models/a_foo_spec.rb").
|
88
|
+
and_return(false)
|
89
|
+
|
90
|
+
allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*[_.]spec.rb").
|
91
|
+
and_return(spec_files)
|
92
|
+
|
93
|
+
allow(Dir).to receive(:[]).with("spec/**{,/*/**}/*.feature").
|
94
|
+
and_return([])
|
95
|
+
|
96
|
+
expect(subject).to eq(["spec/models/a_foo_spec.rb"])
|
97
|
+
end
|
98
|
+
|
99
|
+
context "chdir option present" do
|
100
|
+
let(:chdir) { "moduleA" }
|
101
|
+
let(:paths) do
|
102
|
+
["moduleA/models/a_foo.rb", "spec/models/a_foo_spec.rb"]
|
103
|
+
end
|
104
|
+
|
105
|
+
let(:spec_files) do
|
106
|
+
[["moduleA/spec/models/a_foo_spec.rb",
|
107
|
+
"moduleA/spec/models/b_foo_spec.rb"]]
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns matching paths" do
|
111
|
+
allow(File).to receive(:directory?).with("moduleA/models/a_foo.rb").
|
112
|
+
and_return(false)
|
113
|
+
|
114
|
+
allow(File).to receive(:directory?).
|
115
|
+
with("spec/models/a_foo_spec.rb").
|
116
|
+
and_return(false)
|
117
|
+
|
118
|
+
allow(Dir).to receive(:[]).
|
119
|
+
with("moduleA/spec/**{,/*/**}/*[_.]spec.rb").
|
120
|
+
and_return(spec_files)
|
121
|
+
|
122
|
+
allow(Dir).to receive(:[]).
|
123
|
+
with("moduleA/spec/**{,/*/**}/*.feature").
|
124
|
+
and_return([])
|
125
|
+
|
126
|
+
expect(subject).to eq(["spec/models/a_foo_spec.rb"])
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#failed" do
|
134
|
+
it "should not be implemented here" do
|
135
|
+
expect { inspector.failed(paths) }.to raise_error(NotImplementedError)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#reload" do
|
140
|
+
it "should not be implemented here" do
|
141
|
+
expect { inspector.reload }.to raise_error(NotImplementedError)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "guard/compat/test/helper"
|
2
|
+
|
3
|
+
require "guard/rspec/inspectors/factory"
|
4
|
+
|
5
|
+
RSpec.describe Guard::RSpec::Inspectors::Factory do
|
6
|
+
let(:factory) { Guard::RSpec::Inspectors::Factory }
|
7
|
+
let(:options) { {} }
|
8
|
+
|
9
|
+
it "can not be instantiated" do
|
10
|
+
expect { factory.new(options) }.to raise_error(NoMethodError)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with :focus failed mode and custom options" do
|
14
|
+
let(:options) { { failed_mode: :focus, custom: "value" } }
|
15
|
+
|
16
|
+
it "creates FocusedInspector instance with custom options" do
|
17
|
+
inspector = factory.create(options)
|
18
|
+
expect(inspector).
|
19
|
+
to be_an_instance_of(Guard::RSpec::Inspectors::FocusedInspector)
|
20
|
+
expect(inspector.options).to eq(options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with :keep failed mode and custom options" do
|
25
|
+
let(:options) { { failed_mode: :keep, custom: "value" } }
|
26
|
+
|
27
|
+
it "creates KeepingInspector instance with custom options" do
|
28
|
+
inspector = factory.create(options)
|
29
|
+
expect(inspector).
|
30
|
+
to be_an_instance_of(Guard::RSpec::Inspectors::KeepingInspector)
|
31
|
+
expect(inspector.options).to eq(options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with :none failed mode and custom options" do
|
36
|
+
let(:options) { { failed_mode: :none, custom: "value" } }
|
37
|
+
|
38
|
+
it "creates SimpleInspector instance with custom options" do
|
39
|
+
inspector = factory.create(options)
|
40
|
+
expect(inspector).
|
41
|
+
to be_an_instance_of(Guard::RSpec::Inspectors::SimpleInspector)
|
42
|
+
expect(inspector.options).to eq(options)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require "guard/compat/test/helper"
|
2
|
+
|
3
|
+
require "lib/guard/rspec/inspectors/shared_examples"
|
4
|
+
|
5
|
+
require "guard/rspec/inspectors/focused_inspector"
|
6
|
+
|
7
|
+
klass = Guard::RSpec::Inspectors::FocusedInspector
|
8
|
+
|
9
|
+
RSpec.describe klass do
|
10
|
+
include_examples "inspector", klass
|
11
|
+
|
12
|
+
# Use real paths because BaseInspector#_clean will be used to clean them
|
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([])
|
52
|
+
|
53
|
+
expect(inspector.paths(paths)).to match_array(paths)
|
54
|
+
inspector.failed(failed_locations)
|
55
|
+
|
56
|
+
# Return failed_locations until they pass
|
57
|
+
3.times do
|
58
|
+
expect(inspector.paths(other_paths)).to match_array(failed_locations)
|
59
|
+
inspector.failed(other_failed_locations)
|
60
|
+
|
61
|
+
expect(inspector.paths(paths)).to match_array(failed_locations)
|
62
|
+
inspector.failed(other_failed_locations)
|
63
|
+
|
64
|
+
expect(inspector.paths([])).to match_array(failed_locations)
|
65
|
+
inspector.failed(failed_locations)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Now all pass
|
69
|
+
expect(inspector.paths(paths)).to match_array(failed_locations)
|
70
|
+
inspector.failed([])
|
71
|
+
|
72
|
+
# And some fails again
|
73
|
+
expect(inspector.paths(other_paths)).to match_array(other_paths)
|
74
|
+
inspector.failed(other_failed_locations)
|
75
|
+
|
76
|
+
# Return other_failed_locations until they pass
|
77
|
+
3.times do
|
78
|
+
expect(inspector.paths(other_paths)).
|
79
|
+
to match_array(other_failed_locations)
|
80
|
+
|
81
|
+
inspector.failed(other_failed_locations)
|
82
|
+
|
83
|
+
expect(inspector.paths(paths)).to match_array(other_failed_locations)
|
84
|
+
inspector.failed(other_failed_locations)
|
85
|
+
|
86
|
+
expect(inspector.paths([])).to match_array(other_failed_locations)
|
87
|
+
inspector.failed(failed_locations)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Now all pass
|
91
|
+
expect(inspector.paths(paths)).to match_array(other_failed_locations)
|
92
|
+
inspector.failed([])
|
93
|
+
|
94
|
+
expect(inspector.paths(paths)).to match_array(paths)
|
95
|
+
inspector.failed([])
|
96
|
+
|
97
|
+
expect(inspector.paths(other_paths)).to match_array(other_paths)
|
98
|
+
inspector.failed([])
|
99
|
+
|
100
|
+
expect(inspector.paths([])).to eq([])
|
101
|
+
end
|
102
|
+
|
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
|
+
|
133
|
+
expect(inspector.paths(paths)).to match_array(paths)
|
134
|
+
inspector.failed(failed_locations)
|
135
|
+
|
136
|
+
inspector.reload
|
137
|
+
expect(inspector.paths(other_paths)).to match_array(other_paths)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|