watirmark 5.14.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/app_generators/create_project/create_project_generator.rb +115 -0
  2. data/app_generators/create_project/templates/features/env.rb.erb +8 -0
  3. data/app_generators/create_project/templates/features/model_steps.rb.erb +9 -0
  4. data/app_generators/create_project/templates/features/post_error_steps.rb.erb +15 -0
  5. data/app_generators/create_project/templates/features/sample.feature.erb +5 -0
  6. data/app_generators/create_project/templates/features/site_steps.rb.erb +7 -0
  7. data/app_generators/create_project/templates/generators/controller.rb.erb +9 -0
  8. data/app_generators/create_project/templates/generators/generate.rb.erb +9 -0
  9. data/app_generators/create_project/templates/generators/model.rb.erb +7 -0
  10. data/app_generators/create_project/templates/generators/mvc_generator.rb.erb +100 -0
  11. data/app_generators/create_project/templates/generators/rbeautify.rb.erb +212 -0
  12. data/app_generators/create_project/templates/generators/view.rb.erb +16 -0
  13. data/app_generators/create_project/templates/generators/workflow_loader.rb.erb +1 -0
  14. data/app_generators/create_project/templates/library/base_controller.rb.erb +9 -0
  15. data/app_generators/create_project/templates/library/base_view.rb.erb +6 -0
  16. data/app_generators/create_project/templates/library/configuration.rb.erb +6 -0
  17. data/app_generators/create_project/templates/library/core_libraries.rb.erb +9 -0
  18. data/app_generators/create_project/templates/library/loader.rb.erb +23 -0
  19. data/app_generators/create_project/templates/library/page_load_checker.rb.erb +11 -0
  20. data/app_generators/create_project/templates/library/post_errors_checker.rb.erb +23 -0
  21. data/app_generators/create_project/templates/library/project_require_file.rb.erb +8 -0
  22. data/app_generators/create_project/templates/library/search_controller.rb.erb +12 -0
  23. data/app_generators/create_project/templates/library/workflows.rb.erb +0 -0
  24. data/app_generators/create_project/templates/project/config.yml.erb +3 -0
  25. data/app_generators/create_project/templates/project/gemfile.rb.erb +11 -0
  26. data/app_generators/create_project/templates/project/rakefile.rb.erb +21 -0
  27. data/bin/etapestry/Gemfile +11 -0
  28. data/bin/etapestry/config.yml +3 -0
  29. data/bin/etapestry/features/etapestry_home.feature +5 -0
  30. data/bin/etapestry/features/step_definitions/model_steps.rb +9 -0
  31. data/bin/etapestry/features/step_definitions/post_error_steps.rb +15 -0
  32. data/bin/etapestry/features/step_definitions/site_steps.rb +7 -0
  33. data/bin/etapestry/features/support/env.rb +8 -0
  34. data/bin/etapestry/generators/mvc/mvc_generator.rb +100 -0
  35. data/bin/etapestry/generators/mvc/rbeautify.rb +212 -0
  36. data/bin/etapestry/generators/mvc/templates/controller.rb.erb +9 -0
  37. data/bin/etapestry/generators/mvc/templates/model.rb.erb +7 -0
  38. data/bin/etapestry/generators/mvc/templates/view.rb.erb +16 -0
  39. data/bin/etapestry/generators/mvc/templates/workflow_loader.rb.erb +1 -0
  40. data/bin/etapestry/lib/etapestry.rb +8 -0
  41. data/bin/etapestry/lib/etapestry/checkers/page_load_checker.rb +11 -0
  42. data/bin/etapestry/lib/etapestry/checkers/post_errors_checker.rb +23 -0
  43. data/bin/etapestry/lib/etapestry/configuration.rb +6 -0
  44. data/bin/etapestry/lib/etapestry/core_libraries.rb +9 -0
  45. data/bin/etapestry/lib/etapestry/loader.rb +23 -0
  46. data/bin/etapestry/lib/etapestry/site/base_controller.rb +9 -0
  47. data/bin/etapestry/lib/etapestry/site/base_view.rb +6 -0
  48. data/bin/etapestry/lib/etapestry/site/search_controller.rb +12 -0
  49. data/bin/etapestry/lib/etapestry/workflows.rb +0 -0
  50. data/bin/etapestry/rakefile.rb +21 -0
  51. data/bin/etapestry/script/generate.rb +9 -0
  52. data/bin/twitter/features/hashtag_search.feature +93 -0
  53. data/bin/twitter/features/step_definitions/hashtag_steps.rb +9 -0
  54. data/bin/twitter/lib/twitter/workflows/search/result_controller.rb +13 -0
  55. data/bin/twitter/lib/twitter/workflows/search/result_model.rb +5 -0
  56. data/bin/twitter/lib/twitter/workflows/search/result_view.rb +19 -0
  57. data/bin/watirmark +10 -0
  58. data/lib/watirmark.rb +26 -0
  59. data/lib/watirmark/at_exit.rb +13 -0
  60. data/lib/watirmark/configuration.rb +201 -0
  61. data/lib/watirmark/controller/actions.rb +172 -0
  62. data/lib/watirmark/controller/assertions.rb +116 -0
  63. data/lib/watirmark/controller/controller.rb +191 -0
  64. data/lib/watirmark/controller/dialogs.rb +33 -0
  65. data/lib/watirmark/controller/matcher.rb +19 -0
  66. data/lib/watirmark/cucumber/cuke_helper.rb +150 -0
  67. data/lib/watirmark/cucumber/email_helper.rb +103 -0
  68. data/lib/watirmark/cucumber/env.rb +9 -0
  69. data/lib/watirmark/cucumber/hooks.rb +16 -0
  70. data/lib/watirmark/cucumber/model_helper.rb +34 -0
  71. data/lib/watirmark/cucumber/transforms.rb +55 -0
  72. data/lib/watirmark/exceptions.rb +15 -0
  73. data/lib/watirmark/extensions/ruby_extensions.rb +129 -0
  74. data/lib/watirmark/extensions/webdriver_extensions.rb +150 -0
  75. data/lib/watirmark/formatters/snapshot_formatter.rb +23 -0
  76. data/lib/watirmark/loader.rb +87 -0
  77. data/lib/watirmark/model.rb +3 -0
  78. data/lib/watirmark/models/cucumber_helper.rb +49 -0
  79. data/lib/watirmark/models/debug_methods.rb +21 -0
  80. data/lib/watirmark/models/default_values.rb +21 -0
  81. data/lib/watirmark/models/factory.rb +168 -0
  82. data/lib/watirmark/models/factory_method_generators.rb +84 -0
  83. data/lib/watirmark/models/factory_methods.rb +72 -0
  84. data/lib/watirmark/models/trait.rb +35 -0
  85. data/lib/watirmark/models/upload_csv.rb +24 -0
  86. data/lib/watirmark/page/keyed_element.rb +63 -0
  87. data/lib/watirmark/page/page.rb +50 -0
  88. data/lib/watirmark/page/page_definition.rb +187 -0
  89. data/lib/watirmark/page/process_page.rb +112 -0
  90. data/lib/watirmark/page/radio_maps.rb +53 -0
  91. data/lib/watirmark/profile.rb +22 -0
  92. data/lib/watirmark/rake/smoketest.rb +17 -0
  93. data/lib/watirmark/screenshot.rb +127 -0
  94. data/lib/watirmark/session.rb +115 -0
  95. data/lib/watirmark/version.rb +5 -0
  96. data/spec/assertions_spec.rb +95 -0
  97. data/spec/config_spec.rb +82 -0
  98. data/spec/controller_actions_spec.rb +91 -0
  99. data/spec/controller_spec.rb +426 -0
  100. data/spec/controllers_and_models_spec.rb +52 -0
  101. data/spec/model_factory_spec.rb +568 -0
  102. data/spec/model_traits_spec.rb +141 -0
  103. data/spec/page_spec.rb +127 -0
  104. data/spec/process_page_spec.rb +163 -0
  105. data/spec/spec_helper.rb +17 -0
  106. metadata +238 -0
@@ -0,0 +1,568 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe "factory" do
4
+ before :all do
5
+ module FactoryTest
6
+ class InitializeModel < Watirmark::Model::Factory
7
+ keywords :username, :password
8
+ end
9
+ end
10
+ end
11
+
12
+ specify "set a value on instantiation" do
13
+ login = FactoryTest::InitializeModel.new(:username => 'username', :password => 'password')
14
+ login.username.should == 'username'
15
+ login.password.should == 'password'
16
+ end
17
+
18
+ specify "set a value after initialized" do
19
+ login = FactoryTest::InitializeModel.new
20
+ login.username.should be_nil
21
+ login.password.should be_nil
22
+ login.username = 'username'
23
+ login.password = 'password'
24
+ login.username.should == 'username'
25
+ login.password.should == 'password'
26
+ end
27
+
28
+ # this is mostly for legacy :(
29
+ specify "should be able to act like an openstruct" do
30
+ login = FactoryTest::InitializeModel.new
31
+ login.foobar.should be_nil
32
+ login.foobar = 'test'
33
+ login.foobar.should == 'test'
34
+ end
35
+
36
+ specify 'to_h' do
37
+ login = FactoryTest::InitializeModel.new(username: 'foo', password: 'bar')
38
+ login.to_h.should == {:username=>"foo", :password=>"bar"}
39
+ end
40
+ end
41
+
42
+ describe "#update" do
43
+ before :all do
44
+ module FactoryTest
45
+ class UpdateModel < Watirmark::Model::Factory
46
+ keywords :username, :password
47
+ end
48
+ end
49
+ end
50
+
51
+ specify "model update should create methods if not in model" do
52
+ login = FactoryTest::UpdateModel.new
53
+ login.update(:foobar=>1)
54
+ login.foobar.should == 1
55
+ login.foobar = 'test'
56
+ login.foobar.should == 'test'
57
+ end
58
+
59
+ specify "keywords should not bleed across instances for defined methods" do
60
+ first = FactoryTest::UpdateModel.new
61
+ first.username = 'username'
62
+ first.username.should == 'username'
63
+ second = FactoryTest::UpdateModel.new
64
+ second.username.should be_nil
65
+ end
66
+
67
+ specify "keywords should not bleed across instances for auto-created methods" do
68
+ first = FactoryTest::UpdateModel.new
69
+ first.update(:foobar=>1)
70
+ second = FactoryTest::UpdateModel.new
71
+ second.respond_to?(:foobar).should be_false
72
+ second.respond_to?(:foobar).should be_false
73
+ end
74
+
75
+ specify "model update should remove empty keys" do
76
+ keys = FactoryTest::UpdateModel.new
77
+ lambda{keys.update(':'=>'') }.should_not raise_error NameError
78
+ lambda{keys.update(nil=>'') }.should_not raise_error NameError
79
+ lambda{keys.update(' '=>'') }.should_not raise_error NameError
80
+ lambda{keys.update(' '.to_sym=>'') }.should_not raise_error NameError
81
+ end
82
+
83
+ end
84
+
85
+ describe "defaults" do
86
+ before :all do
87
+ module FactoryTest
88
+ class DefaultModel < Watirmark::Model::Factory
89
+ keywords :first_name, :last_name, :middle_name, :nickname, :id, :desc
90
+ defaults do
91
+ first_name { 'my_first_name' }
92
+ last_name { 'my_last_name' }
93
+ middle_name { "#{model_name} middle_name".strip }
94
+ id { uuid }
95
+ desc { 'some description' }
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ specify "retrieve a default proc setting" do
102
+ m = FactoryTest::DefaultModel.new
103
+ m.middle_name.should == 'middle_name'
104
+ m.model_name = 'foo'
105
+ m.middle_name.should == 'foo middle_name'
106
+ end
107
+
108
+ specify "update a default setting" do
109
+ m = FactoryTest::DefaultModel.new
110
+ m.first_name.should == 'my_first_name'
111
+ m.first_name = 'fred'
112
+ m.first_name.should == 'fred'
113
+ end
114
+
115
+ specify "retrieve a default setting" do
116
+ FactoryTest::DefaultModel.new.first_name.should == 'my_first_name'
117
+ end
118
+
119
+ specify "workaround for desc as a default when run from rake" do
120
+ FactoryTest::DefaultModel.new.desc.should == 'some description'
121
+ end
122
+
123
+ specify "override default settings on instantiation" do
124
+ module FactoryTest
125
+ class ModelWithDefaults < Watirmark::Model::Factory
126
+ keywords :foo, :bar
127
+ defaults do
128
+ foo { "hello from proc" }
129
+ end
130
+ end
131
+ end
132
+
133
+ m = FactoryTest::ModelWithDefaults.new :foo => 'hello init'
134
+ m.foo.should == 'hello init'
135
+ end
136
+
137
+ specify "defaults can reference each other" do
138
+ module FactoryTest
139
+ class DefaultReference < Watirmark::Model::Factory
140
+ keywords :name, :sort_name
141
+ defaults do
142
+ name { "name" }
143
+ sort_name { name }
144
+ end
145
+ end
146
+
147
+ model = DefaultReference.new
148
+ model.name.should == 'name'
149
+ model.sort_name.should == 'name'
150
+ end
151
+ end
152
+
153
+ specify "should raise error unless a proc is defined" do
154
+ lambda {
155
+ module FactoryTest
156
+ class Test < Watirmark::Model::Factory
157
+ keywords :first_name, :last_name, :middle_name, :nickname, :id
158
+ defaults do
159
+ first_name 'my_first_name'
160
+ end
161
+ end
162
+ end
163
+ FactoryTest::Test.new
164
+ }.should raise_error ArgumentError
165
+ end
166
+ end
167
+
168
+
169
+ describe "model name" do
170
+ before :all do
171
+ class ModelName < Watirmark::Model::Factory
172
+ keywords :middle_name
173
+ defaults do
174
+ middle_name { "#@model_name middle_name".strip }
175
+ end
176
+ end
177
+ end
178
+
179
+ specify "can set the models name" do
180
+ m = ModelName.new
181
+ m.model_name = 'my_model'
182
+ m.model_name.should == 'my_model'
183
+ end
184
+
185
+ specify "can set the models at initialize (used by transforms)" do
186
+ m = ModelName.new(:model_name => 'my_model')
187
+ m.model_name.should == 'my_model'
188
+ end
189
+
190
+ specify "setting the models name changes the defaults" do
191
+ m = ModelName.new
192
+ m.model_name = 'my_model'
193
+ m.middle_name.should =~ /^my_model/
194
+ end
195
+ end
196
+
197
+
198
+ describe "parents" do
199
+ specify "ask for a parent" do
200
+ module FactoryTest
201
+ class ChildModel < Watirmark::Model::Factory
202
+ keywords :name, :value
203
+ defaults do
204
+ name { parent.name }
205
+ end
206
+ end
207
+
208
+ class ParentModel < Watirmark::Model::Factory
209
+ keywords :name
210
+ model ChildModel
211
+ defaults do
212
+ name { 'a' }
213
+ end
214
+ end
215
+ end
216
+ model = FactoryTest::ParentModel.new
217
+ model.child.parent.should == model
218
+ model.child.parent.name.should == 'a'
219
+ model.child.name.should == 'a'
220
+ end
221
+ end
222
+
223
+ describe "children" do
224
+ before :all do
225
+ module FactoryTest
226
+ class Camelize < Watirmark::Model::Factory
227
+ keywords :first_name, :last_name
228
+ end
229
+
230
+ class Login < Watirmark::Model::Factory
231
+ keywords :username, :password
232
+ defaults do
233
+ username { 'username' }
234
+ password { 'password' }
235
+ end
236
+ end
237
+
238
+ class User < Watirmark::Model::Factory
239
+ keywords :first_name, :last_name
240
+ model Login, Camelize
241
+ defaults do
242
+ first_name { 'my_first_name' }
243
+ last_name { 'my_last_name' }
244
+ end
245
+ end
246
+
247
+ class Donor < Watirmark::Model::Factory
248
+ keywords :credit_card
249
+ model User
250
+ end
251
+
252
+ class SDP < Watirmark::Model::Factory
253
+ keywords :name, :value
254
+ end
255
+
256
+ class Config < Watirmark::Model::Factory
257
+ keywords :name
258
+ end
259
+ end
260
+
261
+ end
262
+
263
+ specify "should be able to see the models" do
264
+ model = FactoryTest::User.new
265
+ model.login.username.should == 'username'
266
+ end
267
+
268
+ specify "should be able to see nested models" do
269
+ model = FactoryTest::Donor.new
270
+ model.user.login.username.should == 'username'
271
+ model.users.first.login.username.should == 'username'
272
+ end
273
+
274
+ specify "multiple models of the same class should form a collection" do
275
+ model = FactoryTest::Config.new
276
+ model.add_model FactoryTest::SDP.new(:name => 'a', :value => 1)
277
+ model.add_model FactoryTest::SDP.new(:name => 'b', :value => 2)
278
+ model.sdp.name.should == 'a'
279
+ model.sdps.size.should == 2
280
+ model.sdps.first.name.should == 'a'
281
+ model.sdps.last.name.should == 'b'
282
+ end
283
+
284
+ specify "should raise an exception if the model is not a constant" do
285
+ lambda {
286
+ class Test < Watirmark::Model::Factory
287
+ keywords :name
288
+ model :FactorySDP.new
289
+ end
290
+ }.should raise_error
291
+ end
292
+
293
+ specify "should always instantiate NEW instances of sub-models" do
294
+ module FactoryTest
295
+ class Item < Watirmark::Model::Factory
296
+ keywords :name, :sort_name
297
+ defaults do
298
+ name { "name" }
299
+ end
300
+ end
301
+ class Container < Watirmark::Model::Factory
302
+ keywords :name, :sort_name
303
+ search_term { name }
304
+ model Item
305
+ end
306
+ end
307
+ c = FactoryTest::Container.new
308
+ c.item.name.should == 'name'
309
+ c.item.name = 'foo'
310
+ c.item.name.should == 'foo'
311
+ d = FactoryTest::Container.new
312
+ d.item.name.should_not == 'foo'
313
+ end
314
+
315
+ specify "models containing models in modules should not break model_class_name" do
316
+ module Foo
317
+ module Bar
318
+ class Login < Watirmark::Model::Factory
319
+ keywords :username, :password
320
+ defaults do
321
+ username { 'username' }
322
+ password { 'password' }
323
+ end
324
+ end
325
+
326
+ class User < Watirmark::Model::Factory
327
+ keywords :first_name, :last_name
328
+ model Login
329
+ defaults do
330
+ first_name { 'my_first_name' }
331
+ last_name { 'my_last_name' }
332
+ end
333
+ end
334
+ end
335
+ end
336
+
337
+ model = Foo::Bar::User.new
338
+ model.login.username.should == 'username'
339
+ end
340
+ end
341
+
342
+ describe "search_term" do
343
+ specify "is a string" do
344
+ module FactoryTest
345
+ class SearchIsString < Watirmark::Model::Factory
346
+ keywords :name, :sort_name
347
+ search_term { "name" }
348
+ defaults do
349
+ name { "name" }
350
+ end
351
+ end
352
+ end
353
+ model = FactoryTest::SearchIsString.new
354
+ model.search_term.should == 'name'
355
+ end
356
+
357
+ specify "matches another default" do
358
+ module FactoryTest
359
+ class SearchIsDefault < Watirmark::Model::Factory
360
+ keywords :name, :sort_name
361
+ search_term { name }
362
+ defaults do
363
+ name { "name" }
364
+ end
365
+ end
366
+ end
367
+ model = FactoryTest::SearchIsDefault.new
368
+ model.search_term.should == 'name'
369
+ end
370
+
371
+ specify "is found in a parent" do
372
+ module FactoryTest
373
+ class SearchChild < Watirmark::Model::Factory
374
+ keywords :name, :sort_name
375
+ end
376
+
377
+ class SearchParent < Watirmark::Model::Factory
378
+ keywords :name, :sort_name
379
+ search_term { name }
380
+ model SearchChild
381
+ defaults do
382
+ name { "name" }
383
+ end
384
+ end
385
+ end
386
+ child = FactoryTest::SearchChild.new
387
+ child.search_term.should be_nil
388
+ parent = FactoryTest::SearchParent.new
389
+ parent.search_term.should == 'name'
390
+ parent.search_child.search_term.should == 'name'
391
+ end
392
+ end
393
+
394
+ describe "find" do
395
+ before :all do
396
+ module FactoryTest
397
+ class FirstModel < Watirmark::Model::Factory
398
+ keywords :x
399
+ end
400
+ class SecondModel < Watirmark::Model::Factory
401
+ keywords :x
402
+ end
403
+ class NoAddedModels < Watirmark::Model::Factory
404
+ keywords :x
405
+ end
406
+ class SingleModel < Watirmark::Model::Factory
407
+ keywords :x
408
+ end
409
+ class MultipleModels < Watirmark::Model::Factory
410
+ keywords :x
411
+ end
412
+ end
413
+
414
+
415
+ @first_model = FactoryTest::FirstModel.new
416
+ @second_model = FactoryTest::SecondModel.new
417
+ @no_added_models = FactoryTest::NoAddedModels.new
418
+ @single_model = FactoryTest::SingleModel.new
419
+ @single_model.add_model @first_model
420
+ @multiple_models = FactoryTest::MultipleModels.new
421
+ @multiple_models.add_model @first_model
422
+ @multiple_models.add_model @second_model
423
+ end
424
+
425
+ specify 'should find itself' do
426
+ @no_added_models.find(FactoryTest::NoAddedModels).should == @no_added_models
427
+ @single_model.find(FactoryTest::SingleModel).should == @single_model
428
+ @multiple_models.find(FactoryTest::MultipleModels).should == @multiple_models
429
+ end
430
+
431
+ specify 'should be able to see a sub_model' do
432
+ @single_model.find(FactoryTest::FirstModel).should == @first_model
433
+ @multiple_models.find(FactoryTest::FirstModel).should == @first_model
434
+ @multiple_models.find(FactoryTest::SecondModel).should == @second_model
435
+ end
436
+
437
+ specify 'should be return nil when no model is found' do
438
+ @no_added_models.find(FactoryTest::FirstModel).should be_nil
439
+ @single_model.find(FactoryTest::NoAddedModels).should be_nil
440
+ @multiple_models.find(FactoryTest::NoAddedModels).should be_nil
441
+ end
442
+ end
443
+
444
+ describe "methods in Enumerable should not collide with model defaults" do
445
+ it "#zip" do
446
+ module FactoryTest
447
+ class ZipModel < Watirmark::Model::Factory
448
+ keywords :zip
449
+ defaults do
450
+ zip { 78732 }
451
+ end
452
+ end
453
+ end
454
+ FactoryTest::ZipModel.new.zip.should == 78732
455
+ end
456
+
457
+ it "#zip not in model" do
458
+ module FactoryTest
459
+ class NoZipModel < Watirmark::Model::Factory
460
+ keywords :foo
461
+ defaults do
462
+ end
463
+ end
464
+ end
465
+ FactoryTest::NoZipModel.new.respond_to?(:zip).should_not be_true
466
+ end
467
+
468
+ end
469
+
470
+ describe "keywords" do
471
+ before :all do
472
+ module FactoryTest
473
+ class Element
474
+ attr_accessor :value
475
+
476
+ def initialize(x)
477
+ @value = x
478
+ end
479
+ end
480
+
481
+ class SomeView < Page
482
+ keyword(:first_name) { Element.new :a }
483
+ keyword(:middle_name) { Element.new :b }
484
+ keyword(:last_name) { Element.new :c }
485
+ end
486
+
487
+ class SomeModel < Watirmark::Model::Factory
488
+ keywords SomeView.keywords
489
+ defaults do
490
+ first_name { "First" }
491
+ middle_name { "Middle" }
492
+ last_name { "Last #{uuid}" }
493
+ end
494
+ end
495
+
496
+ class SomeOtherModel < Watirmark::Model::Factory
497
+ keywords SomeView.keywords
498
+ defaults do
499
+ first_name { "First" }
500
+ middle_name { "Middle" }
501
+ last_name { "Last #{uuid}" }
502
+ end
503
+ end
504
+ end
505
+ end
506
+
507
+ specify "should add unpacked keywords as keywords" do
508
+ a = FactoryTest::SomeModel.new
509
+ a.middle_name.should == "Middle"
510
+ a.first_name.should == "First"
511
+ a.last_name.should include "Last"
512
+ end
513
+
514
+ specify "keywords can be specified without the asterisk" do
515
+ a = FactoryTest::SomeOtherModel.new
516
+ a.middle_name.should == "Middle"
517
+ a.first_name.should == "First"
518
+ a.last_name.should include "Last"
519
+ end
520
+
521
+ specify "should be able to list keywords for a model" do
522
+ FactoryTest::SomeModel.new.keywords.sort.should == [:first_name, :middle_name, :last_name].sort
523
+ end
524
+
525
+ end
526
+
527
+ describe "subclassing" do
528
+ before :all do
529
+ module Watirmark::Model
530
+ trait :some_trait do
531
+ full_name { "full_name" }
532
+ end
533
+ end
534
+ module FactoryTest
535
+ class BaseModel < Watirmark::Model::Factory
536
+ keywords :first_name, :last_name, :full_name
537
+ defaults do
538
+ first_name { 'base_first_name' }
539
+ last_name { 'base_last_name' }
540
+ end
541
+ traits :some_trait
542
+ end
543
+
544
+ class SubModel < BaseModel
545
+ defaults do
546
+ first_name { 'sub_first_name' }
547
+ last_name { 'sub_last_name' }
548
+ end
549
+ end
550
+
551
+ class NoDefaultModel < BaseModel
552
+ end
553
+ end
554
+ end
555
+
556
+ specify "submodel should be able to inherit keywords" do
557
+ FactoryTest::SubModel.new.first_name.should == 'sub_first_name'
558
+ end
559
+
560
+ specify "submodel should be able to inherit defaults" do
561
+ FactoryTest::NoDefaultModel.new.first_name.should == 'base_first_name'
562
+ end
563
+
564
+ specify "submodel should be able to inherit defaults" do
565
+ FactoryTest::NoDefaultModel.new.full_name.should == 'full_name'
566
+ end
567
+ end
568
+