Module: Kameleon::DSL

Defined in:
lib/kameleon/dsl.rb,
lib/kameleon/dsl/act/form.rb,
lib/kameleon/dsl/act/mouse.rb,
lib/kameleon/dsl/context/scope.rb,
lib/kameleon/dsl/verify/absence.rb,
lib/kameleon/dsl/verify/presence.rb

Defined Under Namespace

Modules: Act, Context, Verify Classes: ScopeProxy

Instance Method Summary collapse

Instance Method Details

#act_as(name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/kameleon/dsl.rb', line 44

def act_as(name)
  if block_given?
    using_session(name) do
      yield
    end
  else
    Capybara.session_name = name
  end
  self
end

#click(*args) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/kameleon/dsl.rb', line 63

def click(*args)
  Kameleon::DSL::Act::Mouse::Click.new(*args).tap do |click|
    click.actions.each do |action|
      if block = action.block
        instance_exec(*action.params, &block)
      else
        page.send(action.method, *action.params)
      end
    end
  end
end

#create_session(name = :default) ⇒ Object



40
41
42
# File 'lib/kameleon/dsl.rb', line 40

def create_session(name = :default)
  Kameleon::Session.new(name).tap { |ks| act_as(ks.name) }
end

#fill_in(args) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/kameleon/dsl.rb', line 75

def fill_in(args)
  Kameleon::DSL::Act::Form.new(args).tap do |form|
    form.actions.each do |action|
      if block = action.block
        instance_exec(*action.params, &block)
      else
        page.send(action.method, *action.params)
      end
    end
  end
end

#not_see(*args) ⇒ Object

! hmn - very similar to see



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kameleon/dsl.rb', line 28

def not_see(*args)
  Kameleon::DSL::Verify::Absence.new(*args).tap do |absence|
    absence.conditions.each do |condition|
      if condition.block
        instance_eval(condition.block)
      else
        page.should send(condition.method, *condition.params)
      end
    end
  end
end

#refresh_pageObject



87
88
89
# File 'lib/kameleon/dsl.rb', line 87

def refresh_page
  visit current_url
end

#see(*args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kameleon/dsl.rb', line 15

def see(*args)
  Kameleon::DSL::Verify::Presence.new(*args).tap do |presence|
    presence.conditions.each do |condition|
      if block = condition.block
        instance_exec(*condition.params, &block)
      else
        page.should send(condition.method, *condition.params)
      end
    end
  end
end

#within(*scope, &block) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/kameleon/dsl.rb', line 55

def within(*scope, &block)
  if block_given?
    super(*parse_selector(scope).selector)
  else
    ScopeProxy.new(self, scope)
  end
end