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



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

def activate
  @view.activate @model
end

#after_allObject



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

def after_all;
end

#after_eachObject



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

def after_each;
end

#archiveObject



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

def archive
  @view.archive @model
end

#before_allObject

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



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

def before_all;
end

#before_eachObject



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

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



126
127
128
129
# File 'lib/watirmark/controller/actions.rb', line 126

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



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

def copy
  @view.copy @model
end

#createObject

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

#deactivateObject



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

def deactivate
  @view.deactivate @model
end

#deleteObject



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

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

#getObject

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_recordObject



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

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



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

def publish
  @view.publish @model
end

#restoreObject



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_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



136
137
138
# File 'lib/watirmark/controller/actions.rb', line 136

def starts_with(x)
  /^#{Regexp.escape(x)}/
end

#unpublishObject



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

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



65
66
67
# File 'lib/watirmark/controller/actions.rb', line 65

def verify_until(&block)
  run_with_stop_condition(:verify, block)
end