Class: ProxyPacRb::RSpecMatchers::BeTheSameProxyPacFile
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- ProxyPacRb::RSpecMatchers::BeTheSameProxyPacFile
- Defined in:
- lib/proxy_pac_rb/rspec/matchers/proxy.rb
Overview
Check if other proxy pac the same
Constant Summary
Constants inherited from BaseMatcher
ProxyPacRb::RSpecMatchers::BaseMatcher::UNDEFINED
Instance Attribute Summary
Attributes inherited from BaseMatcher
#actual, #expected, #rescued_exception
Instance Method Summary collapse
- #diffable? ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected) ⇒ BeTheSameProxyPacFile
constructor
A new instance of BeTheSameProxyPacFile.
- #matches?(actual) ⇒ Boolean
Methods inherited from BaseMatcher
#actual_formatted, #description, #expected_formatted, #expects_call_stack_jump?, #match_unless_raises, matcher_name, #supports_block_expectations?
Methods included from ProxyPacRb::RSpecMatchers::BaseMatcher::DefaultFailureMessages
Methods included from ProxyPacRb::RSpecMatchers::BaseMatcher::HashFormatting
Constructor Details
#initialize(expected) ⇒ BeTheSameProxyPacFile
Returns a new instance of BeTheSameProxyPacFile.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 9 def initialize(expected) @file_a = begin file = ProxyPacRb::ProxyPacFile.new(source: expected) loader.load(file) file end @expected = @file_a.content end |
Instance Method Details
#diffable? ⇒ Boolean
33 34 35 |
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 33 def diffable? true end |
#failure_message ⇒ Object
37 38 39 |
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 37 def format(%(expected that proxy.pac "%s" is equal to proxy.pac "%s", but it is not.), @file_a.source.truncate(30), @file_b.source.truncate(30)) end |
#failure_message_when_negated ⇒ Object
41 42 43 |
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 41 def format(%(expected that proxy.pac "%s" is not equal to proxy.pac "%s", but it is the same.), @file_a.source.truncate(30), @file_b.source.truncate(30)) end |
#matches?(actual) ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 20 def matches?(actual) @file_b = begin file = ProxyPacRb::ProxyPacFile.new(source: actual) loader.load(file) file end @actual = @file_b.content values_match?(@expected, @actual) end |