Class: BotAway::TestCase::Matchers::HoneypotMatcher
- Inherits:
-
Object
- Object
- BotAway::TestCase::Matchers::HoneypotMatcher
- Defined in:
- lib/bot-away/test_case/matchers/honeypot_matcher.rb
Instance Attribute Summary collapse
-
#tag_id ⇒ Object
readonly
Returns the value of attribute tag_id.
-
#tag_name ⇒ Object
readonly
Returns the value of attribute tag_name.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(tag_name, tag_id) ⇒ HoneypotMatcher
constructor
A new instance of HoneypotMatcher.
- #match(key, value, suffix = nil) ⇒ Object
- #matches?(target) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(tag_name, tag_id) ⇒ HoneypotMatcher
Returns a new instance of HoneypotMatcher.
4 5 6 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 4 def initialize(tag_name, tag_id) @tag_name, @tag_id = tag_name, tag_id end |
Instance Attribute Details
#tag_id ⇒ Object (readonly)
Returns the value of attribute tag_id.
2 3 4 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 2 def tag_id @tag_id end |
#tag_name ⇒ Object (readonly)
Returns the value of attribute tag_name.
2 3 4 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 2 def tag_name @tag_name end |
Instance Method Details
#description ⇒ Object
19 20 21 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 19 def description "include a honeypot named '#{tag_name}' with id '#{tag_id}'" end |
#failure_message ⇒ Object
23 24 25 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 23 def "expected #{@target.inspect}\n to match #{@rx.inspect}" end |
#match(key, value, suffix = nil) ⇒ Object
14 15 16 17 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 14 def match(key, value, suffix = nil) @rx = /#{key}=['"]#{Regexp::escape value}["']/ @target[@rx] end |
#matches?(target) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 8 def matches?(target) target = target.call if target.kind_of?(Proc) @target = target match(:id, tag_id) && match(:name, tag_name) end |
#negative_failure_message ⇒ Object
27 28 29 |
# File 'lib/bot-away/test_case/matchers/honeypot_matcher.rb', line 27 def "expected #{@target.inspect}\n to not match #{@rx.inspect}" end |