guard-rspec 4.3.1 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +262 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +10 -0
- data/.travis.yml +2 -3
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +9 -2
- data/Guardfile +11 -4
- data/README.md +8 -4
- data/Rakefile +23 -2
- data/gemfiles/Gemfile.rspec-2.14 +1 -0
- data/gemfiles/Gemfile.rspec-2.99 +14 -0
- data/gemfiles/Gemfile.rspec-3.0 +1 -0
- data/guard-rspec.gemspec +18 -16
- data/lib/guard/rspec.rb +13 -8
- data/lib/guard/rspec/command.rb +30 -12
- data/lib/guard/rspec/deprecator.rb +32 -11
- data/lib/guard/rspec/inspectors/base_inspector.rb +36 -15
- data/lib/guard/rspec/inspectors/factory.rb +7 -8
- data/lib/guard/rspec/inspectors/focused_inspector.rb +2 -2
- data/lib/guard/rspec/inspectors/keeping_inspector.rb +7 -6
- data/lib/guard/rspec/inspectors/simple_inspector.rb +3 -3
- data/lib/guard/rspec/notifier.rb +9 -5
- data/lib/guard/rspec/options.rb +12 -10
- data/lib/guard/rspec/runner.rb +41 -25
- data/lib/guard/rspec/templates/Guardfile +43 -15
- data/lib/guard/rspec/version.rb +1 -1
- data/lib/guard/rspec_formatter.rb +111 -0
- data/spec/lib/guard/rspec/command_spec.rb +48 -12
- data/spec/lib/guard/rspec/deprecator_spec.rb +37 -18
- data/spec/lib/guard/rspec/inspectors/base_inspector_spec.rb +129 -18
- data/spec/lib/guard/rspec/inspectors/factory_spec.rb +20 -15
- data/spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb +79 -13
- data/spec/lib/guard/rspec/inspectors/keeping_inspector_spec.rb +103 -33
- data/spec/lib/guard/rspec/inspectors/shared_examples.rb +93 -31
- data/spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb +52 -16
- data/spec/lib/guard/rspec/notifier_spec.rb +49 -27
- data/spec/lib/guard/rspec/runner_spec.rb +120 -77
- data/spec/lib/guard/rspec_formatter_spec.rb +144 -0
- data/spec/lib/guard/rspec_spec.rb +23 -18
- data/spec/spec_helper.rb +99 -14
- metadata +12 -7
- data/lib/guard/rspec/formatter.rb +0 -99
- data/spec/lib/guard/rspec/formatter_spec.rb +0 -122
@@ -0,0 +1,144 @@
|
|
1
|
+
require "guard/rspec_formatter"
|
2
|
+
|
3
|
+
RSpec.describe Guard::RSpecFormatter do
|
4
|
+
describe "::TEMPORARY_FILE_PATH" do
|
5
|
+
subject { Pathname.new(described_class::TEMPORARY_FILE_PATH) }
|
6
|
+
it { is_expected.to be_relative }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#write_summary" do
|
10
|
+
let(:writer) do
|
11
|
+
StringIO.new
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:formatter) do
|
15
|
+
described_class.new(StringIO.new).tap do |formatter|
|
16
|
+
allow(formatter).to receive(:_write) do |&block|
|
17
|
+
block.call writer
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:result) do
|
23
|
+
writer.rewind
|
24
|
+
writer.read
|
25
|
+
end
|
26
|
+
|
27
|
+
context "without stubbed IO" do
|
28
|
+
let(:formatter) do
|
29
|
+
described_class.new(StringIO.new)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "creates temporary file and and writes to it" do
|
33
|
+
file = File.expand_path(described_class::TEMPORARY_FILE_PATH)
|
34
|
+
|
35
|
+
expect(FileUtils).to receive(:mkdir_p).
|
36
|
+
with(File.dirname(file)) {}
|
37
|
+
|
38
|
+
expect(File).to receive(:open).
|
39
|
+
with(file, "w") do |_, _, &block|
|
40
|
+
block.call writer
|
41
|
+
end
|
42
|
+
|
43
|
+
formatter.write_summary(123, 1, 2, 3)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with failures" do
|
48
|
+
let(:spec_filename) { "failed_location_spec.rb" }
|
49
|
+
|
50
|
+
let(:failed_example) do
|
51
|
+
double(
|
52
|
+
execution_result: { status: "failed" },
|
53
|
+
metadata: { location: spec_filename }
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def expected_output(spec_filename)
|
58
|
+
/^3 examples, 1 failures in 123\.0 seconds\n#{spec_filename}\n$/
|
59
|
+
end
|
60
|
+
|
61
|
+
it "writes summary line and failed location in tmp dir" do
|
62
|
+
allow(formatter).to receive(:examples) { [failed_example] }
|
63
|
+
formatter.write_summary(123, 3, 1, 0)
|
64
|
+
expect(result).to match expected_output(spec_filename)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "writes only uniq filenames out" do
|
68
|
+
allow(formatter).to receive(:examples).
|
69
|
+
and_return([failed_example, failed_example])
|
70
|
+
|
71
|
+
formatter.write_summary(123, 3, 1, 0)
|
72
|
+
expect(result).to match expected_output(spec_filename)
|
73
|
+
end
|
74
|
+
|
75
|
+
context "for rspec 3" do
|
76
|
+
let(:notification) do
|
77
|
+
Struct.new(:duration, :example_count, :failure_count, :pending_count).
|
78
|
+
new(123, 3, 1, 0)
|
79
|
+
end
|
80
|
+
before do
|
81
|
+
allow(formatter.class).to receive(:rspec_3?).and_return(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "writes summary line and failed location" do
|
85
|
+
allow(formatter).to receive(:examples) { [failed_example] }
|
86
|
+
formatter.dump_summary(notification)
|
87
|
+
expect(result).to match expected_output(spec_filename)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should find the spec file for shared examples" do
|
93
|
+
metadata = {
|
94
|
+
location: "./spec/support/breadcrumbs.rb:75",
|
95
|
+
example_group: { location: "./spec/requests/breadcrumbs_spec.rb:218" }
|
96
|
+
}
|
97
|
+
|
98
|
+
result = described_class.extract_spec_location(metadata)
|
99
|
+
expect(result).to start_with "./spec/requests/breadcrumbs_spec.rb"
|
100
|
+
end
|
101
|
+
|
102
|
+
# Skip location because of rspec issue
|
103
|
+
# https://github.com/rspec/rspec-core/issues/1243
|
104
|
+
it "returns only the spec file without line number for shared examples" do
|
105
|
+
metadata = {
|
106
|
+
location: "./spec/support/breadcrumbs.rb:75",
|
107
|
+
example_group: { location: "./spec/requests/breadcrumbs_spec.rb:218" }
|
108
|
+
}
|
109
|
+
expect(described_class.extract_spec_location(metadata)).
|
110
|
+
to eq "./spec/requests/breadcrumbs_spec.rb"
|
111
|
+
end
|
112
|
+
|
113
|
+
context "when a shared examples has no location" do
|
114
|
+
it "should return location of the root spec" do
|
115
|
+
metadata = {
|
116
|
+
location: "./spec/support/breadcrumbs.rb:75",
|
117
|
+
example_group: {}
|
118
|
+
}
|
119
|
+
|
120
|
+
expect(STDERR).to receive(:puts).
|
121
|
+
with("no spec file found for #{metadata[:location]}") {}
|
122
|
+
|
123
|
+
expect(described_class.extract_spec_location(metadata)).
|
124
|
+
to eq metadata[:location]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "with only success" do
|
129
|
+
it "notifies success" do
|
130
|
+
formatter.write_summary(123, 3, 0, 0)
|
131
|
+
expect(result).to match /^3 examples, 0 failures in 123\.0 seconds\n$/
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "with pending" do
|
136
|
+
it "notifies pending too" do
|
137
|
+
formatter.write_summary(123, 3, 0, 1)
|
138
|
+
expect(result).to match(
|
139
|
+
/^3 examples, 0 failures \(1 pending\) in 123\.0 seconds\n$/
|
140
|
+
)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -1,50 +1,56 @@
|
|
1
|
-
require
|
1
|
+
require "guard/compat/test/helper"
|
2
|
+
require "guard/rspec"
|
2
3
|
|
3
|
-
describe Guard::RSpec do
|
4
|
+
RSpec.describe Guard::RSpec do
|
4
5
|
let(:default_options) { Guard::RSpec::Options::DEFAULTS }
|
5
6
|
let(:options) { {} }
|
6
7
|
let(:plugin) { Guard::RSpec.new(options) }
|
7
8
|
let(:runner) { double(Guard::RSpec::Runner) }
|
8
|
-
|
9
|
+
|
10
|
+
before do
|
9
11
|
allow(Guard::UI).to receive(:info)
|
10
12
|
allow(Guard::RSpec::Deprecator).to receive(:warns_about_deprecated_options)
|
11
13
|
allow(Guard::RSpec::Runner).to receive(:new) { runner }
|
12
|
-
|
14
|
+
end
|
13
15
|
|
14
|
-
describe
|
15
|
-
it
|
16
|
+
describe ".initialize" do
|
17
|
+
it "instanciates with default and custom options" do
|
16
18
|
guard_rspec = Guard::RSpec.new(foo: :bar)
|
17
19
|
expect(guard_rspec.options).to eq(default_options.merge(foo: :bar))
|
18
20
|
end
|
19
21
|
|
20
|
-
it
|
21
|
-
expect(Guard::RSpec::Runner).to receive(:new).
|
22
|
+
it "instanciates Runner with all default and custom options" do
|
23
|
+
expect(Guard::RSpec::Runner).to receive(:new).
|
24
|
+
with(default_options.merge(foo: :bar))
|
22
25
|
Guard::RSpec.new(foo: :bar)
|
23
26
|
end
|
24
27
|
|
25
|
-
it
|
26
|
-
expect(Guard::RSpec::Deprecator).
|
28
|
+
it "warns deprecated options" do
|
29
|
+
expect(Guard::RSpec::Deprecator).
|
30
|
+
to receive(:warns_about_deprecated_options).
|
31
|
+
with(default_options.merge(foo: :bar))
|
32
|
+
|
27
33
|
Guard::RSpec.new(foo: :bar)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
describe
|
37
|
+
describe "#start" do
|
32
38
|
it "doesn't call #run_all by default" do
|
33
39
|
expect(plugin).to_not receive(:run_all)
|
34
40
|
plugin.start
|
35
41
|
end
|
36
42
|
|
37
|
-
context
|
43
|
+
context "with all_on_start at true" do
|
38
44
|
let(:options) { { all_on_start: true } }
|
39
45
|
|
40
|
-
it
|
46
|
+
it "calls #run_all" do
|
41
47
|
expect(plugin).to receive(:run_all)
|
42
48
|
plugin.start
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
|
-
describe
|
53
|
+
describe "#run_all" do
|
48
54
|
it "runs all specs via runner" do
|
49
55
|
expect(runner).to receive(:run_all) { true }
|
50
56
|
plugin.run_all
|
@@ -57,15 +63,15 @@ describe Guard::RSpec do
|
|
57
63
|
end
|
58
64
|
end
|
59
65
|
|
60
|
-
describe
|
66
|
+
describe "#reload" do
|
61
67
|
it "reloads via runner" do
|
62
68
|
expect(runner).to receive(:reload)
|
63
69
|
plugin.reload
|
64
70
|
end
|
65
71
|
end
|
66
72
|
|
67
|
-
describe
|
68
|
-
let(:paths) { %w
|
73
|
+
describe "#run_on_modifications" do
|
74
|
+
let(:paths) { %w(path1 path2) }
|
69
75
|
it "runs all specs via runner" do
|
70
76
|
expect(runner).to receive(:run).with(paths) { true }
|
71
77
|
plugin.run_on_modifications(paths)
|
@@ -84,4 +90,3 @@ describe Guard::RSpec do
|
|
84
90
|
end
|
85
91
|
|
86
92
|
end
|
87
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,109 @@
|
|
1
|
-
require
|
2
|
-
require 'guard/rspec'
|
1
|
+
require "rspec"
|
3
2
|
|
4
|
-
if ENV[
|
5
|
-
require
|
3
|
+
if ENV["CI"]
|
4
|
+
require "coveralls"
|
6
5
|
Coveralls.wear!
|
7
6
|
end
|
8
7
|
|
9
|
-
|
8
|
+
rspec_version = ::RSpec::Version::STRING.to_f
|
9
|
+
old_rspec = (rspec_version < 3)
|
10
10
|
|
11
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
11
12
|
RSpec.configure do |config|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
config.expect_with :rspec do |expectations|
|
14
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
15
|
+
# and `failure_message` of custom matchers include text for helper methods
|
16
|
+
# defined using `chain`, e.g.:
|
17
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
18
|
+
# # => "be bigger than 2 and smaller than 4"
|
19
|
+
# ...rather than:
|
20
|
+
# # => "be bigger than 2"
|
21
|
+
|
22
|
+
unless old_rspec
|
23
|
+
if rspec_version > 3.0
|
24
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
25
|
+
end
|
26
|
+
end
|
17
27
|
end
|
18
|
-
|
19
|
-
config.
|
28
|
+
|
29
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
30
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
31
|
+
config.mock_with :rspec do |mocks|
|
32
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
33
|
+
# a real object. This is generally recommended, and will default to
|
34
|
+
# `true` in RSpec 4.
|
35
|
+
unless old_rspec
|
36
|
+
mocks.verify_partial_doubles = true
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
# These two settings work together to allow you to limit a spec run
|
42
|
+
# to individual examples or groups you care about by tagging them with
|
43
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
44
|
+
# get run.
|
45
|
+
config.filter_run focus: ENV["CI"] != "true"
|
20
46
|
config.run_all_when_everything_filtered = true
|
21
|
-
|
22
|
-
|
47
|
+
|
48
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
49
|
+
# recommended.
|
50
|
+
# For more details, see:
|
51
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
52
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
53
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
54
|
+
|
55
|
+
unless old_rspec
|
56
|
+
config.disable_monkey_patching!
|
57
|
+
end
|
58
|
+
|
59
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
60
|
+
# be too noisy due to issues in dependencies.
|
61
|
+
# config.warnings = true
|
62
|
+
|
63
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
64
|
+
# file, and it's useful to allow more verbose output when running an
|
65
|
+
# individual spec file.
|
66
|
+
if config.files_to_run.one?
|
67
|
+
# Use the documentation formatter for detailed output,
|
68
|
+
# unless a formatter has already been configured
|
69
|
+
# (e.g. via a command-line flag).
|
70
|
+
config.default_formatter = "doc"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Print the 10 slowest examples and example groups at the
|
74
|
+
# end of the spec run, to help surface which specs are running
|
75
|
+
# particularly slow.
|
76
|
+
# config.profile_examples = 10
|
77
|
+
|
78
|
+
# Run specs in random order to surface order dependencies. If you find an
|
79
|
+
# order dependency and want to debug it, you can fix the order by providing
|
80
|
+
# the seed, which is printed after each run.
|
81
|
+
# --seed 1234
|
82
|
+
config.order = :random
|
83
|
+
|
84
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
85
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
86
|
+
# test failures related to randomization by passing the same `--seed` value
|
87
|
+
# as the one that triggered the failure.
|
88
|
+
Kernel.srand config.seed
|
89
|
+
|
90
|
+
config.raise_errors_for_deprecations!
|
91
|
+
|
92
|
+
config.before do
|
93
|
+
allow(Dir).to receive(:[]) do |*args|
|
94
|
+
abort "stub me: Dir[#{args.first}]!"
|
95
|
+
end
|
96
|
+
|
97
|
+
%w(directory? delete readlines).each do |meth|
|
98
|
+
allow(File).to receive(meth.to_sym) do |*args|
|
99
|
+
abort "stub me: File.#{meth}(#{args.map(&:inspect) * ","})!"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
%w(mkdir).each do |meth|
|
104
|
+
allow(FileUtils).to receive(meth.to_sym) do |*args|
|
105
|
+
abort "stub me: FileUtils.#{meth}(#{args.map(&:inspect) * ","})!"
|
106
|
+
end
|
107
|
+
end
|
23
108
|
end
|
24
109
|
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.
|
4
|
+
version: 4.4.1
|
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-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.99.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '4.0'
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 2.99.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '4.0'
|
@@ -99,6 +99,10 @@ extensions: []
|
|
99
99
|
extra_rdoc_files: []
|
100
100
|
files:
|
101
101
|
- ".gitignore"
|
102
|
+
- ".hound.yml"
|
103
|
+
- ".rspec"
|
104
|
+
- ".rubocop.yml"
|
105
|
+
- ".rubocop_todo.yml"
|
102
106
|
- ".travis.yml"
|
103
107
|
- CONTRIBUTING.md
|
104
108
|
- Gemfile
|
@@ -107,12 +111,12 @@ files:
|
|
107
111
|
- README.md
|
108
112
|
- Rakefile
|
109
113
|
- gemfiles/Gemfile.rspec-2.14
|
114
|
+
- gemfiles/Gemfile.rspec-2.99
|
110
115
|
- gemfiles/Gemfile.rspec-3.0
|
111
116
|
- guard-rspec.gemspec
|
112
117
|
- lib/guard/rspec.rb
|
113
118
|
- lib/guard/rspec/command.rb
|
114
119
|
- lib/guard/rspec/deprecator.rb
|
115
|
-
- lib/guard/rspec/formatter.rb
|
116
120
|
- lib/guard/rspec/inspectors/base_inspector.rb
|
117
121
|
- lib/guard/rspec/inspectors/factory.rb
|
118
122
|
- lib/guard/rspec/inspectors/focused_inspector.rb
|
@@ -123,9 +127,9 @@ files:
|
|
123
127
|
- lib/guard/rspec/runner.rb
|
124
128
|
- lib/guard/rspec/templates/Guardfile
|
125
129
|
- lib/guard/rspec/version.rb
|
130
|
+
- lib/guard/rspec_formatter.rb
|
126
131
|
- spec/lib/guard/rspec/command_spec.rb
|
127
132
|
- spec/lib/guard/rspec/deprecator_spec.rb
|
128
|
-
- spec/lib/guard/rspec/formatter_spec.rb
|
129
133
|
- spec/lib/guard/rspec/inspectors/base_inspector_spec.rb
|
130
134
|
- spec/lib/guard/rspec/inspectors/factory_spec.rb
|
131
135
|
- spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb
|
@@ -134,6 +138,7 @@ files:
|
|
134
138
|
- spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb
|
135
139
|
- spec/lib/guard/rspec/notifier_spec.rb
|
136
140
|
- spec/lib/guard/rspec/runner_spec.rb
|
141
|
+
- spec/lib/guard/rspec_formatter_spec.rb
|
137
142
|
- spec/lib/guard/rspec_spec.rb
|
138
143
|
- spec/spec_helper.rb
|
139
144
|
homepage: https://rubygems.org/gems/guard-rspec
|
@@ -163,7 +168,6 @@ summary: Guard gem for RSpec
|
|
163
168
|
test_files:
|
164
169
|
- spec/lib/guard/rspec/command_spec.rb
|
165
170
|
- spec/lib/guard/rspec/deprecator_spec.rb
|
166
|
-
- spec/lib/guard/rspec/formatter_spec.rb
|
167
171
|
- spec/lib/guard/rspec/inspectors/base_inspector_spec.rb
|
168
172
|
- spec/lib/guard/rspec/inspectors/factory_spec.rb
|
169
173
|
- spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb
|
@@ -172,5 +176,6 @@ test_files:
|
|
172
176
|
- spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb
|
173
177
|
- spec/lib/guard/rspec/notifier_spec.rb
|
174
178
|
- spec/lib/guard/rspec/runner_spec.rb
|
179
|
+
- spec/lib/guard/rspec_formatter_spec.rb
|
175
180
|
- spec/lib/guard/rspec_spec.rb
|
176
181
|
- spec/spec_helper.rb
|