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
110 111 112 |
# File 'lib/watirmark/controller/actions.rb', line 110 def activate @view.activate @model end |
#after_all ⇒ Object
147 148 |
# File 'lib/watirmark/controller/actions.rb', line 147 def after_all; end |
#after_each ⇒ Object
150 151 |
# File 'lib/watirmark/controller/actions.rb', line 150 def after_each; end |
#archive ⇒ Object
98 99 100 |
# File 'lib/watirmark/controller/actions.rb', line 98 def archive @view.archive @model end |
#before_all ⇒ Object
Stubs so converted XLS->RSPEC files don’t fail
141 142 |
# File 'lib/watirmark/controller/actions.rb', line 141 def before_all; end |
#before_each ⇒ Object
144 145 |
# File 'lib/watirmark/controller/actions.rb', line 144 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
126 127 128 129 |
# File 'lib/watirmark/controller/actions.rb', line 126 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
90 91 92 |
# File 'lib/watirmark/controller/actions.rb', line 90 def copy @view.copy @model end |
#create ⇒ Object
Navigate to the View’s create page and populate with values from the models hash
58 59 60 61 62 |
# File 'lib/watirmark/controller/actions.rb', line 58 def create @view.create @model populate_data check_for_noop_populate end |
#create_until(&block) ⇒ Object
73 74 75 |
# File 'lib/watirmark/controller/actions.rb', line 73 def create_until(&block) run_with_stop_condition(:create, block) end |
#deactivate ⇒ Object
114 115 116 |
# File 'lib/watirmark/controller/actions.rb', line 114 def deactivate @view.deactivate @model end |
#delete ⇒ Object
86 87 88 |
# File 'lib/watirmark/controller/actions.rb', line 86 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 54 |
# File 'lib/watirmark/controller/actions.rb', line 48 def edit search_for_record @view.edit @model populate_data(@model.updates) @model.clear_updates check_for_noop_populate end |
#edit_until(&block) ⇒ Object
69 70 71 |
# File 'lib/watirmark/controller/actions.rb', line 69 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
79 80 81 82 83 84 |
# File 'lib/watirmark/controller/actions.rb', line 79 def get unless @view.exists? @model @view.create @model populate_data end end |
#locate_record ⇒ Object
118 119 120 |
# File 'lib/watirmark/controller/actions.rb', line 118 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
102 103 104 |
# File 'lib/watirmark/controller/actions.rb', line 102 def publish @view.publish @model end |
#restore ⇒ Object
94 95 96 |
# File 'lib/watirmark/controller/actions.rb', line 94 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
136 137 138 |
# File 'lib/watirmark/controller/actions.rb', line 136 def starts_with(x) /^#{Regexp.escape(x)}/ end |
#unpublish ⇒ Object
106 107 108 |
# File 'lib/watirmark/controller/actions.rb', line 106 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
65 66 67 |
# File 'lib/watirmark/controller/actions.rb', line 65 def verify_until(&block) run_with_stop_condition(:verify, block) end |