Class: Guard::RSpecFormatter
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- Guard::RSpecFormatter
- Defined in:
- lib/guard/rspec_formatter.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- WIKI_ENV_WARN_URL =
"https://github.com/guard/guard-rspec/wiki/Warning:-no-environment"
- NO_ENV_WARNING_MSG =
"no environment passed - see #{WIKI_ENV_WARN_URL}"
- NO_RESULTS_VALUE_MSG =
":results_file value unknown (using defaults)"
- UNSUPPORTED_PATTERN =
"Your RSpec.configuration.pattern uses characters "\ "unsupported by your Ruby version (File::FNM_EXTGLOB is undefined)"
Class Method Summary collapse
-
.extract_spec_location(metadata) ⇒ Object
rspec issue github.com/rspec/rspec-core/issues/793.
- .rspec_3? ⇒ Boolean
- .spec_path?(path) ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.extract_spec_location(metadata) ⇒ Object
rspec issue github.com/rspec/rspec-core/issues/793
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/guard/rspec_formatter.rb', line 48 def self.extract_spec_location() = location = [:location] until spec_path?(location) = [:parent_example_group] || [:example_group] unless STDERR.puts "no spec file location in #{.inspect}" return [:location] end # rspec issue https://github.com/rspec/rspec-core/issues/1243 location = ([:location] || "").split(":").first end location end |
.rspec_3? ⇒ Boolean
31 32 33 |
# File 'lib/guard/rspec_formatter.rb', line 31 def self.rspec_3? ::RSpec::Core::Version::STRING.split(".").first == "3" end |
.spec_path?(path) ⇒ Boolean
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/guard/rspec_formatter.rb', line 67 def self.spec_path?(path) pattern = ::RSpec.configuration.pattern flags = File::FNM_PATHNAME | File::FNM_DOTMATCH if File.const_defined?(:FNM_EXTGLOB) # ruby >= 2 flags |= File::FNM_EXTGLOB elsif pattern =~ /[{}]/ fail Error::UnsupportedPattern end path ||= "" path = path.sub(/:\d+\z/, "") path = Pathname.new(path).cleanpath.to_s File.fnmatch(pattern, path, flags) end |
Instance Method Details
#dump_summary(*args) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/guard/rspec_formatter.rb', line 83 def dump_summary(*args) return write_summary(*args) unless self.class.rspec_3? notification = args[0] write_summary( notification.duration, notification.example_count, notification.failure_count, notification.pending_count ) end |
#example_failed(failure) ⇒ Object
38 39 40 |
# File 'lib/guard/rspec_formatter.rb', line 38 def example_failed(failure) examples.push failure.example end |
#examples ⇒ Object
42 43 44 |
# File 'lib/guard/rspec_formatter.rb', line 42 def examples @examples ||= [] end |