Module: Watirmark::Actions

Included in:
WebPage::Controller
Defined in:
lib/watirmark/controller/actions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#recordsObject

Returns the value of attribute records.



4
5
6
# File 'lib/watirmark/controller/actions.rb', line 4

def records
  @records
end

Instance Method Details

#activateObject



109
110
111
# File 'lib/watirmark/controller/actions.rb', line 109

def activate
  @view.activate @model
end

#after_allObject



146
147
# File 'lib/watirmark/controller/actions.rb', line 146

def after_all;
end

#after_eachObject



149
150
# File 'lib/watirmark/controller/actions.rb', line 149

def after_each;
end

#archiveObject



97
98
99
# File 'lib/watirmark/controller/actions.rb', line 97

def archive
  @view.archive @model
end

#before_allObject

Stubs so converted XLS->RSPEC files don’t fail



140
141
# File 'lib/watirmark/controller/actions.rb', line 140

def before_all;
end

#before_eachObject



143
144
# File 'lib/watirmark/controller/actions.rb', line 143

def before_each;
end

#check_defaultsObject 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_populateObject



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

#copyObject



89
90
91
# File 'lib/watirmark/controller/actions.rb', line 89

def copy
  @view.copy @model
end

#createObject

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

#deactivateObject



113
114
115
# File 'lib/watirmark/controller/actions.rb', line 113

def deactivate
  @view.deactivate @model
end

#deleteObject



85
86
87
# File 'lib/watirmark/controller/actions.rb', line 85

def delete
  @view.delete @model
end

#editObject

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

#getObject

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_recordObject



117
118
119
# File 'lib/watirmark/controller/actions.rb', line 117

def locate_record
  @view.locate_record @model
end

#populate_data_overridden?Boolean

Returns:

  • (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

#publishObject



101
102
103
# File 'lib/watirmark/controller/actions.rb', line 101

def publish
  @view.publish @model
end

#restoreObject



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_recordObject



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

#unpublishObject



105
106
107
# File 'lib/watirmark/controller/actions.rb', line 105

def unpublish
  @view.unpublish @model
end

#verifyObject

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