Class: EagerEye::RSpec::Matchers::PassEagerEyeMatcher
- Inherits:
-
Object
- Object
- EagerEye::RSpec::Matchers::PassEagerEyeMatcher
- Defined in:
- lib/eager_eye/rspec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(options = {}) ⇒ PassEagerEyeMatcher
constructor
A new instance of PassEagerEyeMatcher.
- #matches?(path) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ PassEagerEyeMatcher
Returns a new instance of PassEagerEyeMatcher.
11 12 13 14 15 16 17 |
# File 'lib/eager_eye/rspec/matchers.rb', line 11 def initialize( = {}) @only = [:only] @exclude = [:exclude] || [] @max_issues = [:max_issues] || 0 @issues = [] @path = nil end |
Instance Method Details
#description ⇒ Object
47 48 49 50 51 52 |
# File 'lib/eager_eye/rspec/matchers.rb', line 47 def description desc = "pass EagerEye analysis" desc += " for #{@only.join(", ")}" if @only desc += " (max #{@max_issues} issues)" if @max_issues.positive? desc end |
#failure_message ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/eager_eye/rspec/matchers.rb', line 27 def = "expected #{@path} to pass EagerEye analysis" += " (max #{@max_issues} issues)" if @max_issues.positive? += ", but found #{@issues.count} issue(s):\n\n" @issues.group_by(&:file_path).each do |file, file_issues| += "#{file}:\n" file_issues.each do |issue| += " Line #{issue.line_number}: [#{issue.detector}] #{issue.}\n" end += "\n" end end |
#failure_message_when_negated ⇒ Object
43 44 45 |
# File 'lib/eager_eye/rspec/matchers.rb', line 43 def "expected #{@path} to have EagerEye issues, but it passed" end |
#matches?(path) ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/eager_eye/rspec/matchers.rb', line 19 def matches?(path) @path = path configure_eager_eye analyzer = build_analyzer @issues = analyzer.run @issues.count <= @max_issues end |