Skip to content

Commit 7d9241d

Browse files
author
Alexey Chernenkov
committed
Fix RSpec 3.0.0 compatibility
1 parent 719e0c8 commit 7d9241d

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

gemfiles/Gemfile.rspec-3.0

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source "https://rubygems.org"
22

33
gemspec path: '../'
44

5-
gem 'rspec', '~> 3.0.0.beta'
5+
gem 'rspec', '~> 3.0.0'
66

77
group :test do
88
gem 'coveralls', require: false

lib/guard/rspec/formatter.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ def self.rspec_3?
1111
end
1212

1313
if rspec_3?
14-
::RSpec::Core::Formatters.register self, :dump_summary
14+
::RSpec::Core::Formatters.register self, :dump_summary, :example_failed
15+
16+
def example_failed(failure)
17+
examples.push failure.example
18+
end
19+
20+
def examples
21+
@examples ||= []
22+
end
1523
end
1624

1725
# rspec issue https://github.com/rspec/rspec-core/issues/793
@@ -74,7 +82,7 @@ def _write(&block)
7482
end
7583

7684
def _failed_paths
77-
failed = examples.select { |e| e.execution_result[:status] == 'failed' }
85+
failed = examples.select { |e| e.execution_result[:status].to_s == 'failed' }
7886
failed.map { |e| self.class.extract_spec_location(e.metadata) }.sort.uniq
7987
end
8088

lib/guard/rspec/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Guard
22
module RSpecVersion
3-
VERSION = '4.2.9'
3+
VERSION = '4.2.10'
44
end
55
end

spec/spec_helper.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66
Coveralls.wear!
77
end
88

9+
rspec_major_version = RSpec::Version::STRING.to_i
10+
911
RSpec.configure do |config|
10-
config.color_enabled = true
12+
if rspec_major_version < 3
13+
config.color_enabled = true
14+
config.treat_symbols_as_metadata_keys_with_true_values = true
15+
else
16+
config.color = true
17+
end
1118
config.order = :random
1219
config.filter_run focus: ENV['CI'] != 'true'
13-
config.treat_symbols_as_metadata_keys_with_true_values = true if RSpec::Version::STRING.to_i < 3
1420
config.run_all_when_everything_filtered = true
1521
config.expect_with :rspec do |c|
1622
c.syntax = :expect

0 commit comments

Comments
 (0)