watirmark 5.28.2 → 5.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df6f52af72e6865375e5d300d361e426812e09f0
4
- data.tar.gz: 641fdc217abd970ff0c143c974720f3cc20a7185
3
+ metadata.gz: 869eb50af6ffc0f094ab946ce3a02e65300f0cf5
4
+ data.tar.gz: cb1343978e8f19130cefe1da8ddaa3b9e1a9b469
5
5
  SHA512:
6
- metadata.gz: 5eb5c8a47a4b4fdc9cd7ac2e4174342837a9e1b53671fa6fc1c9d7d14f3118a7e487dd93110d6a3a49659d3ca41bbb9e5f1e02c21f8b641f6c220fd758f16d0c
7
- data.tar.gz: 2234f957ac4b12d63b43476f389cdefec566d41a6578f0975785e59d5a4fbbc7838f22b91f78c92e346d4e01b744515611b635dd8f8253a1a339bcddcf982964
6
+ metadata.gz: 31406663981f396d3660f6785f46a5f63c75dab98d847a7262c5fd3b35a9c2efda3ed5210efba9b6f171f646182d930494f3cc8781fe29a645e87b45f861a5d9
7
+ data.tar.gz: 54971e2d3debcb65fca67e92faab264b339601f528c57af641f065b888a17e5574af87ca13748f9188b272af2e1499853f2de5dcbd388e446b7650131412bb99
@@ -0,0 +1 @@
1
+ Set :firebug to true in config file to automatically download and use latest version of Firebug extension for Firefox
@@ -27,6 +27,7 @@ module Watirmark
27
27
  :prefer_css => false,
28
28
  :watir_timeout => 30,
29
29
  :http_timeout => 60,
30
+ :firebug => false,
30
31
  # database
31
32
  :dbhostname => nil,
32
33
  :dbusername => nil,
@@ -48,7 +48,8 @@ module Watirmark
48
48
  def edit
49
49
  search_for_record
50
50
  @view.edit @model
51
- populate_data
51
+ populate_data(@model.updates)
52
+ @model.clear_updates
52
53
  check_for_noop_populate
53
54
  end
54
55
 
@@ -38,14 +38,14 @@ module Watirmark
38
38
  initialize_model(data)
39
39
  end
40
40
 
41
- def populate_data
42
- submit_process_page(@last_process_page.underscored_name) {submit} if populate_values
41
+ def populate_data(updates=nil)
42
+ submit_process_page(@last_process_page.underscored_name) {submit} if populate_values(updates)
43
43
  end
44
44
 
45
- def populate_values
45
+ def populate_values(updates=nil)
46
46
  @seen_value = false
47
47
  @last_process_page = nil
48
- keyed_elements.each do |k|
48
+ keyed_update_elements(updates).each do |k|
49
49
  next unless k.populate_allowed?
50
50
  submit_process_page_when_page_changes(k)
51
51
  before_process_page(k)
@@ -123,7 +123,7 @@ module Watirmark
123
123
 
124
124
  def populate_keyword_value(keyed_element)
125
125
  call_method_if_exists("populate_#{keyed_element.keyword}") do
126
- @view.send(keyed_element.keyword).wait_until_present unless @view.send(keyed_element.keyword).kind_of? Watir::Radio
126
+ @view.send(keyed_element.keyword).wait_until_present
127
127
  @view.send("#{keyed_element.keyword}=", value(keyed_element))
128
128
  end
129
129
  end
@@ -159,6 +159,11 @@ module Watirmark
159
159
  @view.keyed_elements.select{|e| !value(e).nil?}
160
160
  end
161
161
 
162
+ def keyed_update_elements(updates)
163
+ Watirmark.logger.info("Editing these keyword(s) in populate_data: #{updates}") unless updates.nil? || updates.empty?
164
+ keyed_elements.select{|k| updates.nil? || updates.include?(k.keyword) }
165
+ end
166
+
162
167
  def locate_model(supermodel)
163
168
  case supermodel
164
169
  when Hash
@@ -10,12 +10,20 @@ module HookHelper
10
10
  end
11
11
 
12
12
 
13
- def take_screenshot
14
- image = "#{Time.now.to_i}-#{UUID.new.generate(:compact)}.png"
15
- path = "reports/screenshots"
13
+ def take_screenshot(folder='', feature='')
14
+ path = "reports/screenshots/#{folder}"
15
+ if folder.empty?
16
+ image = "#{Time.now.to_i}-#{UUID.new.generate(:compact)}.png"
17
+ else
18
+ image = "#{feature}.png"
19
+ end
16
20
  file = "#{path}/#{image}"
17
21
  FileUtils.mkdir_p path unless File.directory? path
18
22
  begin
23
+ if Page.browser.alert.exists?
24
+ Watirmark.logger.warn("Alert is Open while taking screenshot: #{Page.browser.alert.text}")
25
+ Page.browser.alert.close
26
+ end
19
27
  Page.browser.screenshot.save file
20
28
  data = File.open(file, 'rb') { |f| f.read }
21
29
  data = Base64.encode64(data)
@@ -13,9 +13,16 @@ Before do |scenario|
13
13
  end
14
14
 
15
15
  After do |scenario|
16
- (file, file_type) = HookHelper.take_screenshot
16
+ if scenario.passed?
17
+ prepend = 'p_'
18
+ elsif scenario.failed?
19
+ prepend = 'f_'
20
+ else
21
+ prepend = 'i_'
22
+ end
23
+ folder = scenario.location.to_s[/\/features\/([^\.]*)/, 1]
24
+ feature = prepend+scenario.title.tr(' ', '_')
25
+ (file, file_type) = HookHelper.take_screenshot(folder, feature)
17
26
  embed file, file_type
18
27
  HookHelper.serialize_models
19
28
  end
20
-
21
-
@@ -20,15 +20,9 @@ module ModelHelper
20
20
  # Perform an action using a models and update
21
21
  # the models if that action is successful
22
22
  def with_model(model, table)
23
- orig_model = model.clone
24
- update_model(model, table)
23
+ cloned_model = model.clone
24
+ update_model(cloned_model, table)
25
25
  yield
26
- if Watirmark::Session.instance.post_failure
27
- Watirmark.logger.info "Reverting Model #{Watirmark::Session.instance.post_failure}"
28
- model.update(orig_model.to_h) # revert models on failure
29
- elsif model.to_h != orig_model.to_h
30
- Watirmark.logger.info "Updated model '#{model.model_name}' #{hash_record(table).inspect}"
31
- end
32
26
  end
33
27
  end
34
28
 
@@ -15,7 +15,7 @@ module Watirmark
15
15
  include FactoryMethodGenerators
16
16
 
17
17
  attr_accessor :defaults, :model_name, :models, :parent, :children, :model_type
18
- attr_reader :keywords
18
+ attr_reader :keywords, :updates
19
19
 
20
20
  def marshal_dump
21
21
  [@keywords, @model_name, @models, @parent, @children, @model_type, self.to_h]
@@ -33,6 +33,7 @@ module Watirmark
33
33
  @search = self.class.search || Proc.new{nil}
34
34
  @keywords = self.class.keys.dup || []
35
35
  @children = self.class.children.dup.map(&:new)
36
+ @updates = []
36
37
  set_model_name
37
38
  set_default_values
38
39
  create_model_getters_and_setters
@@ -106,11 +107,18 @@ module Watirmark
106
107
  # Update the model using the provided hash
107
108
  def update hash
108
109
  remove_empty_entries hash
109
- hash.each_pair { |key, value| send "#{key}=", value }
110
+ hash.each_pair do |key, value|
111
+ @updates << key
112
+ send "#{key}=", value
113
+ end
110
114
  self
111
115
  end
112
116
  alias :has :update
113
117
 
118
+ def clear_updates
119
+ @updates = []
120
+ end
121
+
114
122
 
115
123
  # Update the model using the provided hash but only if exists (TODO: may not be needed any more)
116
124
  def update_existing_members hash
@@ -94,6 +94,19 @@ module Watirmark
94
94
  profile['security.warn_viewing_mixed.show_once'] = false
95
95
  profile['security.mixed_content.block_active_content'] = false
96
96
  end
97
+ if config.firebug
98
+ unless RbConfig::CONFIG['host_os'].match('linux')
99
+ warn "Firebug with Firefox only supported on Linux"
100
+ return
101
+ end
102
+ path = (File.expand_path "../../../bin/firefox_extensions/firebug", __FILE__)
103
+ file = 'addon-1843-latest.xpi'
104
+ Dir.chdir(path) do
105
+ File.delete(file) if File.exists?(file)
106
+ `wget https://addons.mozilla.org/firefox/downloads/latest/1843/addon-1843-latest.xpi`
107
+ end
108
+ profile.add_extension("#{path}/#{file}")
109
+ end
97
110
  profile["focusmanager.testmode"] = true
98
111
  profile
99
112
  end
@@ -1,5 +1,5 @@
1
1
  module Watirmark
2
2
  module Version
3
- STRING = '5.28.2'
3
+ STRING = '5.29.0'
4
4
  end
5
5
  end
@@ -151,4 +151,60 @@ describe Watirmark::Actions do
151
151
  it 'should not throw an exception if populate_data is overridden' do
152
152
  lambda { ControllerActionsTest::ActionCreateControllerWithOverride.new.create }.should_not raise_error
153
153
  end
154
+
155
+ describe 'Controllers will only populate newly updated values in the model' do
156
+
157
+ before(:all) do
158
+ class TestEditView < Page
159
+ keyword(:edit_test) {}
160
+ keyword(:edit_test_two) {}
161
+ def create(model); end
162
+ def edit(model); end
163
+ end
164
+ class TestEditController < Watirmark::WebPage::Controller
165
+ @view = TestEditView
166
+ def populate_edit_test; end
167
+ def populate_edit_test_two; end
168
+ end
169
+ class TestEditModel < Watirmark::Model::Factory
170
+ keywords :edit_test
171
+ defaults do
172
+ edit_test { true }
173
+ end
174
+ end
175
+ end
176
+
177
+ specify 'populate_data populates keywords that have not been populated before' do
178
+ model = TestEditModel.new
179
+ c = TestEditController.new(model)
180
+ model.update(edit_test: true)
181
+ c.expects(:populate_edit_test).once
182
+ c.run :edit
183
+ c.run :edit
184
+ c.run :edit
185
+ model.update(edit_test_two: true)
186
+ c.expects(:populate_edit_test_two).once
187
+ c.run :edit
188
+ c.run :edit
189
+ c.run :edit
190
+ end
191
+
192
+ specify 'create should populate every time regardless of model updates' do
193
+ model = TestEditModel.new
194
+ c = TestEditController.new(model)
195
+ c.expects(:populate_edit_test).twice
196
+ c.run :create
197
+ c.run :create
198
+ end
199
+
200
+ specify 'create should populate every time even when the model is updated' do
201
+ model = TestEditModel.new
202
+ c = TestEditController.new(model)
203
+ c.expects(:populate_edit_test).twice
204
+ c.run :create
205
+ model.update(edit_test_two: true)
206
+ c.expects(:populate_edit_test_two).once
207
+ c.run :create
208
+ end
209
+ end
154
210
  end
@@ -99,6 +99,20 @@ describe "#update" do
99
99
  lambda{keys.update(' '.to_sym=>'') }.should_not raise_error
100
100
  end
101
101
 
102
+ specify "model #updates hash is updated when any keywords in the model is updated" do
103
+ keys = FactoryTest::UpdateModel.new
104
+ keys.update(:username=>'username', :foo=>'foo')
105
+ expect(keys.updates).to include(:username)
106
+ expect(keys.updates).to include(:foo)
107
+ end
108
+
109
+ specify "model #updates hash is cleared when #clear_updates is called" do
110
+ keys = FactoryTest::UpdateModel.new
111
+ keys.update(:username=>'username', :foo=>'foo')
112
+ keys.clear_updates
113
+ expect(keys.updates).to be_empty
114
+ end
115
+
102
116
  end
103
117
 
104
118
  describe "defaults" do
@@ -489,7 +503,7 @@ end
489
503
  describe "keywords" do
490
504
  before :all do
491
505
  module FactoryTest
492
- class Element
506
+ class ElementTest
493
507
  attr_accessor :value
494
508
 
495
509
  def initialize(x)
@@ -498,9 +512,9 @@ describe "keywords" do
498
512
  end
499
513
 
500
514
  class SomeView < Page
501
- keyword(:first_name) { Element.new :a }
502
- keyword(:middle_name) { Element.new :b }
503
- keyword(:last_name) { Element.new :c }
515
+ keyword(:first_name) { ElementTest.new :a }
516
+ keyword(:middle_name) { ElementTest.new :b }
517
+ keyword(:last_name) { ElementTest.new :c }
504
518
  end
505
519
 
506
520
  class SomeModel < Watirmark::Model::Factory
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watirmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.28.2
4
+ version: 5.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hugh McGowan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-29 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir-webdriver
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: american_date
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: logger
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.2.8
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.2.8
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: uuid
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.3.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.3.7
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.6.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.6.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.19.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.19.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: activesupport
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '4.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '4.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: headless
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: Watirmark is an MVC test framework for watir-webdriver
@@ -129,6 +129,7 @@ executables:
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - bin/firefox_extensions/firebug/README.md
132
133
  - bin/watirmark
133
134
  - generators/new_project/generator.rb
134
135
  - generators/new_project/templates/config.yml.erb
@@ -218,32 +219,32 @@ require_paths:
218
219
  - lib
219
220
  required_ruby_version: !ruby/object:Gem::Requirement
220
221
  requirements:
221
- - - ">="
222
+ - - '>='
222
223
  - !ruby/object:Gem::Version
223
224
  version: '0'
224
225
  required_rubygems_version: !ruby/object:Gem::Requirement
225
226
  requirements:
226
- - - ">="
227
+ - - '>='
227
228
  - !ruby/object:Gem::Version
228
229
  version: '0'
229
230
  requirements: []
230
231
  rubyforge_project:
231
- rubygems_version: 2.4.7
232
+ rubygems_version: 2.4.8
232
233
  signing_key:
233
234
  specification_version: 4
234
- summary: watirmark 5.28.2
235
+ summary: watirmark 5.29.0
235
236
  test_files:
237
+ - spec/model_traits_spec.rb
236
238
  - spec/session_spec.rb
237
- - spec/helper_methods_spec.rb
239
+ - spec/controller_spec.rb
238
240
  - spec/controllers_and_models_spec.rb
239
- - spec/process_page_spec.rb
240
- - spec/page_spec.rb
241
- - spec/config_spec.rb
242
241
  - spec/model_factory_spec.rb
242
+ - spec/helper_methods_spec.rb
243
243
  - spec/controller_actions_spec.rb
244
- - spec/model_traits_spec.rb
245
244
  - spec/watir_webdriver_spec.rb
246
245
  - spec/spec_helper.rb
247
- - spec/controller_spec.rb
246
+ - spec/page_spec.rb
247
+ - spec/process_page_spec.rb
248
248
  - spec/assertions_spec.rb
249
+ - spec/config_spec.rb
249
250
  has_rdoc: