Module: Chop::DSL

Extended by:
DSL
Included in:
Chop, DSL
Defined in:
lib/chop/dsl.rb

Instance Method Summary collapse

Instance Method Details

#create!(klass, table, &block) ⇒ Object



7
8
9
# File 'lib/chop/dsl.rb', line 7

def create! klass, table, &block
  Create.create! klass, table, &block
end

#diff!(selector, table, session: Capybara.current_session, as: nil, timeout: nil, **kwargs, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/chop/dsl.rb', line 11

def diff! selector, table, session: Capybara.current_session, as: nil, timeout: nil, **kwargs, &block
  sync_timeout = timeout || Capybara.default_max_wait_time
  class_name = if as
    as.to_s
  elsif selector.respond_to?(:tag_name)
    selector.tag_name
  else
    session.document.synchronize sync_timeout, errors: session.driver.invalid_element_errors do
      session.find(selector).tag_name
    end
  end.camelize
  klass = const_get("Chop::#{class_name}")
  kwargs[:session] = session
  kwargs[:timeout] = timeout if timeout
  klass.diff! selector, table, **kwargs, &block
end

#fill_in!(table) ⇒ Object



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

def fill_in! table
  Form.fill_in! table
end