watirmark 5.29.2 → 5.29.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6863f2ffd5c7d3f536ee996f273bbd3e22b29cee
4
- data.tar.gz: 44bee9f7b30b0fdacf9947f6f7f31398527bb959
3
+ metadata.gz: e0a29b86dfedffc425b759146a17e4e131b19c47
4
+ data.tar.gz: 70c357b0cadb675104ec1bdc982a81340e05bd05
5
5
  SHA512:
6
- metadata.gz: ef17f156091e90821158b4c0d3286055b6f63b82782bb520ba02b6c0f9bf8fd1346dfee7fc3c4736f035012880aa9d62df19bb9ec75e89339441ccab77cdff80
7
- data.tar.gz: eee08540eebbda2d609c6c06ca702f9eec887449d32de34c91672aa80a9e802917eb107a182c1fbf11c0dfc9a29cec1ac1e3af7b6c730bd190c59900006f5264
6
+ metadata.gz: a4e21b4bd41ecc14958cda3f64a1a686da4b2d3206086b6465da3c01873e9250f474a82098ac6020f094d5c020b1a7a4051e1da4e1b299de0eca16d16d2b8160
7
+ data.tar.gz: eb0dc66a6e7ef0764e3d29fe705277918977118bdb6bd953123e2ad419155d38d9d97d7a1dc42b57cdc518ce6a30324fe700d8c1d554e814d3f23593b1aa70f7
@@ -48,8 +48,7 @@ module Watirmark
48
48
  def edit
49
49
  search_for_record
50
50
  @view.edit @model
51
- populate_data(@model.updates)
52
- @model.clear_updates
51
+ populate_data
53
52
  check_for_noop_populate
54
53
  end
55
54
 
@@ -38,14 +38,14 @@ module Watirmark
38
38
  initialize_model(data)
39
39
  end
40
40
 
41
- def populate_data(updates=nil)
42
- submit_process_page(@last_process_page.underscored_name) {submit} if populate_values(updates)
41
+ def populate_data
42
+ submit_process_page(@last_process_page.underscored_name) {submit} if populate_values
43
43
  end
44
44
 
45
- def populate_values(updates=nil)
45
+ def populate_values
46
46
  @seen_value = false
47
47
  @last_process_page = nil
48
- keyed_update_elements(updates).each do |k|
48
+ keyed_elements.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)
@@ -159,11 +159,6 @@ 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
-
167
162
  def locate_model(supermodel)
168
163
  case supermodel
169
164
  when Hash
@@ -118,6 +118,13 @@ class ModelOpenStruct < OpenStruct
118
118
  h
119
119
  end
120
120
 
121
+ def includes? hash
122
+ raise "#{hash.inspect} is not a Hash" unless hash.is_a?(Hash)
123
+ h = self.to_h
124
+ hash.each_pair { |key, value| return false unless h[key] == value }
125
+ true
126
+ end
127
+
121
128
  # Stub these out so it doesn't find anything
122
129
  def find(model)
123
130
  end
@@ -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, :updates
18
+ attr_reader :keywords
19
19
 
20
20
  def marshal_dump
21
21
  [@keywords, @model_name, @models, @parent, @children, @model_type, self.to_h]
@@ -107,19 +107,11 @@ module Watirmark
107
107
  # Update the model using the provided hash
108
108
  def update hash
109
109
  remove_empty_entries hash
110
- hash.each_pair do |key, value|
111
- @updates << key
112
- send "#{key}=", value
113
- end
110
+ hash.each_pair { |key, value| send "#{key}=", value }
114
111
  self
115
112
  end
116
113
  alias :has :update
117
114
 
118
- def clear_updates
119
- @updates = []
120
- end
121
-
122
-
123
115
  # Update the model using the provided hash but only if exists (TODO: may not be needed any more)
124
116
  def update_existing_members hash
125
117
  remove_empty_entries hash
@@ -1,5 +1,5 @@
1
1
  module Watirmark
2
2
  module Version
3
- STRING = '5.29.2'
3
+ STRING = '5.29.3'
4
4
  end
5
5
  end
@@ -151,60 +151,4 @@ 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
210
154
  end
@@ -99,20 +99,6 @@ 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
-
116
102
  end
117
103
 
118
104
  describe "defaults" do
@@ -503,7 +489,7 @@ end
503
489
  describe "keywords" do
504
490
  before :all do
505
491
  module FactoryTest
506
- class ElementTest
492
+ class Element
507
493
  attr_accessor :value
508
494
 
509
495
  def initialize(x)
@@ -512,9 +498,9 @@ describe "keywords" do
512
498
  end
513
499
 
514
500
  class SomeView < Page
515
- keyword(:first_name) { ElementTest.new :a }
516
- keyword(:middle_name) { ElementTest.new :b }
517
- keyword(:last_name) { ElementTest.new :c }
501
+ keyword(:first_name) { Element.new :a }
502
+ keyword(:middle_name) { Element.new :b }
503
+ keyword(:last_name) { Element.new :c }
518
504
  end
519
505
 
520
506
  class SomeModel < Watirmark::Model::Factory
@@ -0,0 +1,27 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe "ModelOpenStruct includes?" do
4
+ before :all do
5
+ @struct = ModelOpenStruct.new(a: 1, b: 2, c: 'three')
6
+ end
7
+
8
+ it 'open struct includes hash' do
9
+ @struct.includes?(a: 1, c: 'three').should == true
10
+ end
11
+
12
+ it 'open struct does not include hash' do
13
+ @struct.includes?(d: 1).should == false
14
+ end
15
+
16
+ it 'single element hash' do
17
+ @struct.includes?(a: 1).should == true
18
+ end
19
+
20
+ it 'return true if hash is nil' do
21
+ expect { @struct.includes?(nil) }.should raise_error
22
+ end
23
+
24
+ it 'throw error if hash is not passed' do
25
+ expect { @struct.includes?(Object.new) }.should raise_error
26
+ end
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watirmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.29.2
4
+ version: 5.29.3
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-10-15 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir-webdriver
@@ -205,6 +205,7 @@ files:
205
205
  - spec/helper_methods_spec.rb
206
206
  - spec/model_factory_spec.rb
207
207
  - spec/model_traits_spec.rb
208
+ - spec/open_struct_spec.rb
208
209
  - spec/page_spec.rb
209
210
  - spec/process_page_spec.rb
210
211
  - spec/session_spec.rb
@@ -232,13 +233,14 @@ rubyforge_project:
232
233
  rubygems_version: 2.4.8
233
234
  signing_key:
234
235
  specification_version: 4
235
- summary: watirmark 5.29.2
236
+ summary: watirmark 5.29.3
236
237
  test_files:
237
238
  - spec/model_traits_spec.rb
238
239
  - spec/session_spec.rb
239
240
  - spec/controller_spec.rb
240
241
  - spec/controllers_and_models_spec.rb
241
242
  - spec/model_factory_spec.rb
243
+ - spec/open_struct_spec.rb
242
244
  - spec/helper_methods_spec.rb
243
245
  - spec/controller_actions_spec.rb
244
246
  - spec/watir_webdriver_spec.rb