Module: Briar::Label

Defined in:
lib/briar/label.rb

Instance Method Summary collapse

Instance Method Details

#label_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/briar/label.rb', line 5

def label_exists? (name)
  !query("label marked:'#{name}'").empty?
end

#label_exists_with_text?(name, text) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/briar/label.rb', line 16

def label_exists_with_text? (name, text)
  actual = query("label marked:'#{name}'", :text).first
  actual.eql? text
end

#should_not_see_label_with_text(name, text) ⇒ Object



28
29
30
31
32
# File 'lib/briar/label.rb', line 28

def should_not_see_label_with_text (name, text)
  if label_exists_with_text?(name, text)
    screenshot_and_raise "i expected that i would not see '#{text}' in label named '#{name}'"
  end
end

#should_see_label(name) ⇒ Object



9
10
11
12
13
14
# File 'lib/briar/label.rb', line 9

def should_see_label (name)
  res = label_exists?(name)
  unless res
    screenshot_and_raise "i could not find label with access id #{name}"
  end
end

#should_see_label_with_text(name, text) ⇒ Object



21
22
23
24
25
26
# File 'lib/briar/label.rb', line 21

def should_see_label_with_text (name, text)
  unless label_exists_with_text?(name, text)
    actual = query("label marked:'#{name}'", :text).first
    screenshot_and_raise "i expected to see '#{text}' in label named '#{name}' but found '#{actual}'"
  end
end

#touch_label(label_id, wait_for_view_id = nil) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/briar/label.rb', line 44

def touch_label (label_id, wait_for_view_id=nil)
  wait_for_label label_id
  touch("label marked:'#{label_id}'")
  if wait_for_view_id != nil
    wait_for_view wait_for_view_id
  else
    step_pause
  end
end

#wait_for_label(label_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/briar/label.rb', line 34

def wait_for_label (label_id, timeout=BRIAR_WAIT_TIMEOUT)
  msg = "waited for '#{timeout}' seconds but did not see label '#{label_id}'"
  wait_for(:timeout => timeout,
           :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
           :post_timeout => BRIAR_WAIT_STEP_PAUSE,
           :timeout_message => msg) do
    label_exists? label_id
  end
end