Class: PageMatch::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/page_match/page.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePage

Returns a new instance of Page.



6
7
8
9
10
11
# File 'lib/page_match/page.rb', line 6

def initialize
  @contain = %(expected the page to contain)
  @not_contain = %(expected the page to not contain)
  @did = %(but it did)
  @did_not = %(but it didn't)
end

Instance Attribute Details

#containObject

Returns the value of attribute contain.



4
5
6
# File 'lib/page_match/page.rb', line 4

def contain
  @contain
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/page_match/page.rb', line 3

def description
  @description
end

#didObject

Returns the value of attribute did.



4
5
6
# File 'lib/page_match/page.rb', line 4

def did
  @did
end

#did_notObject

Returns the value of attribute did_not.



4
5
6
# File 'lib/page_match/page.rb', line 4

def did_not
  @did_not
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/page_match/page.rb', line 3

def message
  @message
end

#not_containObject

Returns the value of attribute not_contain.



4
5
6
# File 'lib/page_match/page.rb', line 4

def not_contain
  @not_contain
end

Class Method Details

.match {|page| ... } ⇒ Object

Yields:



13
14
15
16
17
# File 'lib/page_match/page.rb', line 13

def self.match(&block)
  page = Page.new
  yield page if block_given?
  page
end

Instance Method Details

#failure_messageObject



28
29
30
# File 'lib/page_match/page.rb', line 28

def failure_message
  %(#{contain} #{message}, #{did_not})
end

#have(msg = '') ⇒ Object



23
24
25
26
# File 'lib/page_match/page.rb', line 23

def have(msg='')
  @message = msg
  @description = %(have #{msg})
end

#matches?(page_instance) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/page_match/page.rb', line 36

def matches?(page_instance)
  page_instance.instance_eval(&@page_block)
end

#negative_failure_messageObject



32
33
34
# File 'lib/page_match/page.rb', line 32

def negative_failure_message
  %(#{not_contain} #{message}, #{did})
end

#page(&block) ⇒ Object



19
20
21
# File 'lib/page_match/page.rb', line 19

def page(&block)
  @page_block = block
end