Module: PageMatch::Helpers

Defined in:
lib/page_match/helpers.rb

Instance Method Summary collapse

Instance Method Details

#have_button(label) ⇒ Object



11
12
13
14
15
16
# File 'lib/page_match/helpers.rb', line 11

def have_button(label)
  PageMatch.match do |m|
    m.have %(a button named "#{label}")
    m.page { has_button?(label) }
  end
end

#have_check_box(form, field) ⇒ Object



53
54
55
56
57
58
# File 'lib/page_match/helpers.rb', line 53

def have_check_box(form, field)
  PageMatch.match do |m|
    m.have %(a checkbox on the #{form} form for #{field.inspect.gsub(/_$/, '')})
    m.page { has_selector?(:xpath, %(.//input[@id="#{form}_#{field}"][@type="checkbox"])) }
  end
end

#have_flash_error(error) ⇒ Object



25
26
27
28
29
30
# File 'lib/page_match/helpers.rb', line 25

def have_flash_error(error)
  PageMatch.match do |m|
    m.have %(a flash error containing "#{error}")
    m.page { within("#flash_error") { has_content?(error) } }
  end
end

#have_flash_notice(note) ⇒ Object



18
19
20
21
22
23
# File 'lib/page_match/helpers.rb', line 18

def have_flash_notice(note)
  PageMatch.match do |m|
    m.have %(a flash notice containing "#{note}")
    m.page { within("#flash_notice") { has_content?(note) } }
  end
end

#have_form_error(error) ⇒ Object



32
33
34
35
36
37
# File 'lib/page_match/helpers.rb', line 32

def have_form_error(error)
  PageMatch.match do |m|
    m.have %(a form error that contains "#{error}")
    m.page { within(".error_messages") { has_content?(error) } }
  end
end


4
5
6
7
8
9
# File 'lib/page_match/helpers.rb', line 4

def have_link(label)
  PageMatch.match do |m|
    m.have %(a link named "#{label}")
    m.page { has_link?(label) }
  end
end

#have_select_field(form, field) ⇒ Object



60
61
62
63
64
65
# File 'lib/page_match/helpers.rb', line 60

def have_select_field(form, field)
  PageMatch.match do |m|
    m.have %(a select field on the #{form} form for #{field.inspect})
    m.page { has_selector?(:xpath, %(.//select[@id="#{form}_#{field}"])) }
  end
end

#have_text_area(form, field) ⇒ Object



46
47
48
49
50
51
# File 'lib/page_match/helpers.rb', line 46

def have_text_area(form, field)
  PageMatch.match do |m|
    m.have %(a text area on the #{form} form for #{field.inspect})
    m.page { has_selector?(:xpath, %(.//textarea[@id="#{form}_#{field}"])) }
  end
end

#have_text_field(form, field) ⇒ Object



39
40
41
42
43
44
# File 'lib/page_match/helpers.rb', line 39

def have_text_field(form, field)
  PageMatch.match do |m|
    m.have %(a text field on the #{form} form for #{field.inspect})
    m.page { has_selector?(:xpath, %(.//input[@id="#{form}_#{field}"][@type="text"])) }
  end
end