Class: ProxyPacRb::RSpecMatchers::BeTheSameProxyPacFile

Inherits:
BaseMatcher
  • Object
show all
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

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

has_default_failure_messages?

Methods included from ProxyPacRb::RSpecMatchers::BaseMatcher::HashFormatting

improve_hash_formatting

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

Returns:

  • (Boolean)


33
34
35
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 33

def diffable?
  true
end

#failure_messageObject



37
38
39
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 37

def failure_message
  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_negatedObject



41
42
43
# File 'lib/proxy_pac_rb/rspec/matchers/proxy.rb', line 41

def failure_message_when_negated
  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

Returns:

  • (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