Module: Dill::DSL
- Included in:
- Role
- Defined in:
- lib/dill/dsl.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#click(name, *args) ⇒ Object
Clicks the widget defined by
name
and optionalargs
. -
#document ⇒ Document
The current document with the class of the current object set as the widget lookup scope.
-
#eventually(wait_time = Capybara.default_wait_time, &block) ⇒ Object
re-run one or more assertions until either they all pass, or Dill times out, which will result in a test failure.
-
#has_widget?(name, *args) ⇒ Boolean
(also: #widget?)
Whether one or more widgets exist in the current document.
- #set(name, fields) ⇒ Object
- #submit(name, fields = {}) ⇒ Object
- #value(name, *args) ⇒ Object
- #values(name, *args) ⇒ Object
- #visit(path) ⇒ Object
-
#widget(name, *args) ⇒ Object
Returns a widget instance for the given name.
-
#widgets(name, *args) ⇒ Object
Returns a list of widget instances for the given name.
Instance Attribute Details
#widget_lookup_scope ⇒ Object
68 69 70 |
# File 'lib/dill/dsl.rb', line 68 def @widget_lookup_scope ||= end |
Instance Method Details
#click(name, *args) ⇒ Object
Clicks the widget defined by name
and optional args
.
Makes no distinction between links or buttons.
class MyWidget < Dill::Widget
root { |text| ['.my-widget', text: text] }
end
# <a href="#one" class="my-widget">One</li>
# <a href="#two" class="my-widget">Two</li> <!-- clicks this node -->
click :my_widget, 'Two'
16 17 18 |
# File 'lib/dill/dsl.rb', line 16 def click(name, *args) (name, *args).click end |
#document ⇒ Document
Returns the current document with the class of the current object set as the widget lookup scope.
22 23 24 |
# File 'lib/dill/dsl.rb', line 22 def document Document.new() end |
#eventually(wait_time = Capybara.default_wait_time, &block) ⇒ Object
re-run one or more assertions until either they all pass, or Dill times out, which will result in a test failure.
74 75 76 |
# File 'lib/dill/dsl.rb', line 74 def eventually(wait_time = Capybara.default_wait_time, &block) Checkpoint.wait_for wait_time, &block end |
#has_widget?(name, *args) ⇒ Boolean Also known as: widget?
Returns Whether one or more widgets exist in the current document.
28 29 30 |
# File 'lib/dill/dsl.rb', line 28 def (name, *args) document.(name, *args) end |
#set(name, fields) ⇒ Object
34 35 36 |
# File 'lib/dill/dsl.rb', line 34 def set(name, fields) (name).set fields end |
#submit(name, fields = {}) ⇒ Object
38 39 40 |
# File 'lib/dill/dsl.rb', line 38 def submit(name, fields = {}) (name).submit_with fields end |
#value(name, *args) ⇒ Object
42 43 44 |
# File 'lib/dill/dsl.rb', line 42 def value(name, *args) (name, *args).value end |
#values(name, *args) ⇒ Object
46 47 48 |
# File 'lib/dill/dsl.rb', line 46 def values(name, *args) (name, *args).map(&:value) end |
#visit(path) ⇒ Object
50 51 52 |
# File 'lib/dill/dsl.rb', line 50 def visit(path) Capybara.current_session.visit path end |
#widget(name, *args) ⇒ Object
Returns a widget instance for the given name.
57 58 59 |
# File 'lib/dill/dsl.rb', line 57 def (name, *args) document.(name, *args) end |
#widgets(name, *args) ⇒ Object
Returns a list of widget instances for the given name.
64 65 66 |
# File 'lib/dill/dsl.rb', line 64 def (name, *args) document.(name, *args) end |