Sha256: e09350fe5eed8351bbb4ecb202768facd33ea66cef8385ccace7150698125df1
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
# encoding: utf-8 RSpec::Matchers.define :exit_with_code do |code| supports_block_expectations actual = nil match do |block| begin block.call rescue SystemExit => e actual = e.status end actual && actual == code end failure_message do "expected block to call exit(#{code}) but exit" + (actual.nil? ? ' not called' : "(#{actual}) was called") end failure_message_when_negated do "expected block not to call exit(#{code})" end description do "expect block to call exit(#{code})" end end RSpec::Matchers.define :find_offenses_in do |code| match do |cop| inspect_source(cop, [code]) includes_highlight(cop) && includes_message(cop) && cop.offenses.any? end chain :with_highlight do |highlight| @highlight = highlight end chain :with_message do |message| @message = message end def includes_highlight(cop) return true unless @highlight cop.highlights.include?(@highlight) end def includes_message(cop) return true unless @message cop.offenses.map(&:message).include?(@message) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.28.0 | spec/support/custom_matchers.rb |
rubocop-0.27.1 | spec/support/custom_matchers.rb |
rubocop-0.27.0 | spec/support/custom_matchers.rb |