Module: Watirmark::Actions
- Included in:
- WebPage::Controller
- Defined in:
- lib/watirmark/controller/actions.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
Returns the value of attribute records.
Instance Method Summary collapse
- #activate ⇒ Object
- #after_all ⇒ Object
- #after_each ⇒ Object
- #archive ⇒ Object
-
#before_all ⇒ Object
Stubs so converted XLS->RSPEC files don’t fail.
- #before_each ⇒ Object
-
#check_defaults ⇒ Object
(also: #check_create_defaults)
Navigate to the View’s create page and verify against the models hash.
- #check_for_noop_populate ⇒ Object
- #copy ⇒ Object
-
#create ⇒ Object
Navigate to the View’s create page and populate with values from the models hash.
- #create_until(&block) ⇒ Object
- #deactivate ⇒ Object
- #delete ⇒ Object
-
#edit ⇒ Object
Navigate to the View’s edit page and verify all values in the models hash.
- #edit_until(&block) ⇒ Object
-
#get ⇒ Object
Navigate to the View’s create page and populate with values from the models hash.
- #locate_record ⇒ Object
- #populate_data_overridden? ⇒ Boolean
- #publish ⇒ Object
- #restore ⇒ Object
- #run(*actions, &block) ⇒ Object
- #search_for_record ⇒ Object
-
#starts_with(x) ⇒ Object
A helper function for translating a string into a pattern match for the beginning of a string.
- #unpublish ⇒ Object
-
#verify ⇒ Object
Navigate to the View’s edit page and for every value in the models hash, verify that the html element has the proper value for each keyword.
- #verify_until(&block) ⇒ Object
Instance Attribute Details
#records ⇒ Object
Returns the value of attribute records.
4 5 6 |
# File 'lib/watirmark/controller/actions.rb', line 4 def records @records end |
Instance Method Details
#activate ⇒ Object
109 110 111 |
# File 'lib/watirmark/controller/actions.rb', line 109 def activate @view.activate @model end |
#after_all ⇒ Object
146 147 |
# File 'lib/watirmark/controller/actions.rb', line 146 def after_all; end |
#after_each ⇒ Object
149 150 |
# File 'lib/watirmark/controller/actions.rb', line 149 def after_each; end |
#archive ⇒ Object
97 98 99 |
# File 'lib/watirmark/controller/actions.rb', line 97 def archive @view.archive @model end |
#before_all ⇒ Object
Stubs so converted XLS->RSPEC files don’t fail
140 141 |
# File 'lib/watirmark/controller/actions.rb', line 140 def before_all; end |
#before_each ⇒ Object
143 144 |
# File 'lib/watirmark/controller/actions.rb', line 143 def before_each; end |
#check_defaults ⇒ Object Also known as: check_create_defaults
Navigate to the View’s create page and verify against the models hash. This is useful for making sure that the create page has the proper default values and contains the proper elements
125 126 127 128 |
# File 'lib/watirmark/controller/actions.rb', line 125 def check_defaults @view.create @model verify_data end |
#check_for_noop_populate ⇒ Object
33 34 35 |
# File 'lib/watirmark/controller/actions.rb', line 33 def check_for_noop_populate warn "Warning: Expected to populate values but none were provided" unless @seen_value || populate_data_overridden? end |
#copy ⇒ Object
89 90 91 |
# File 'lib/watirmark/controller/actions.rb', line 89 def copy @view.copy @model end |
#create ⇒ Object
Navigate to the View’s create page and populate with values from the models hash
57 58 59 60 61 |
# File 'lib/watirmark/controller/actions.rb', line 57 def create @view.create @model populate_data check_for_noop_populate end |
#create_until(&block) ⇒ Object
72 73 74 |
# File 'lib/watirmark/controller/actions.rb', line 72 def create_until(&block) run_with_stop_condition(:create, block) end |
#deactivate ⇒ Object
113 114 115 |
# File 'lib/watirmark/controller/actions.rb', line 113 def deactivate @view.deactivate @model end |
#delete ⇒ Object
85 86 87 |
# File 'lib/watirmark/controller/actions.rb', line 85 def delete @view.delete @model end |
#edit ⇒ Object
Navigate to the View’s edit page and verify all values in the models hash
48 49 50 51 52 53 |
# File 'lib/watirmark/controller/actions.rb', line 48 def edit search_for_record @view.edit @model populate_data check_for_noop_populate end |
#edit_until(&block) ⇒ Object
68 69 70 |
# File 'lib/watirmark/controller/actions.rb', line 68 def edit_until(&block) run_with_stop_condition(:edit, block) end |
#get ⇒ Object
Navigate to the View’s create page and populate with values from the models hash
78 79 80 81 82 83 |
# File 'lib/watirmark/controller/actions.rb', line 78 def get unless @view.exists? @model @view.create @model populate_data end end |
#locate_record ⇒ Object
117 118 119 |
# File 'lib/watirmark/controller/actions.rb', line 117 def locate_record @view.locate_record @model end |
#populate_data_overridden? ⇒ Boolean
29 30 31 |
# File 'lib/watirmark/controller/actions.rb', line 29 def populate_data_overridden? self.class.instance_method(:populate_data).owner == self.class end |
#publish ⇒ Object
101 102 103 |
# File 'lib/watirmark/controller/actions.rb', line 101 def publish @view.publish @model end |
#restore ⇒ Object
93 94 95 |
# File 'lib/watirmark/controller/actions.rb', line 93 def restore @view.restore @model end |
#run(*actions, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/watirmark/controller/actions.rb', line 6 def run(*actions, &block) begin run_callback_method :before_all record_list.each do |record| create_model(record) execute_actions(actions, block) end run_callback_method :after_all ensure clear_record_list end end |
#search_for_record ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/watirmark/controller/actions.rb', line 19 def search_for_record if @search search_controller = @search.new(@supermodel) if search_controller.respond_to?(:current_record_visible?) return if search_controller.current_record_visible? end search_controller.create end end |
#starts_with(x) ⇒ Object
A helper function for translating a string into a pattern match for the beginning of a string
135 136 137 |
# File 'lib/watirmark/controller/actions.rb', line 135 def starts_with(x) /^#{Regexp.escape(x)}/ end |
#unpublish ⇒ Object
105 106 107 |
# File 'lib/watirmark/controller/actions.rb', line 105 def unpublish @view.unpublish @model end |
#verify ⇒ Object
Navigate to the View’s edit page and for every value in the models hash, verify that the html element has the proper value for each keyword
40 41 42 43 44 |
# File 'lib/watirmark/controller/actions.rb', line 40 def verify search_for_record @view.edit @model verify_data end |
#verify_until(&block) ⇒ Object
64 65 66 |
# File 'lib/watirmark/controller/actions.rb', line 64 def verify_until(&block) run_with_stop_condition(:verify, block) end |