Module: RiplWatir::Commands

Defined in:
lib/ripl_watir.rb

Instance Method Summary collapse

Instance Method Details

#classify(s) ⇒ Object



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

def classify s
  s.to_s.split('_').map(&:capitalize).join
end

#on_page(*args) ⇒ Object



47
48
49
50
51
# File 'lib/ripl_watir.rb', line 47

def on_page *args
  page_class(*args).tap do |p|
    yield p if block_given?
  end
end

#page_class(*args) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ripl_watir.rb', line 32

def page_class *args
  page = RiplWatir::Page.new RiplWatir.browser
  if ENV['RIPL_WATIR_RELOAD']
    load "pages/#{args.join '/'}.rb"
  else
    require "pages/#{args.join '/'}"
  end
  mod = Pages
  args.each do |name|
    mod = mod.const_get classify name
  end
  page.extend mod
  page
end

#visit_page(*args) ⇒ Object



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

def visit_page *args
  on_page(*args) do |p|
    p.goto
    yield p if block_given?
  end
end