watir_drops 0.1.1 → 0.3.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: 6510cd26391a9257fe3c3cb6eb2957fed55831be
4
- data.tar.gz: 112fbc8732ba85e0a9a55579441c699616faeb04
3
+ metadata.gz: 299a92e87b3d647d0607b8494ebb96530d288dc6
4
+ data.tar.gz: 864b1daef08f0d67bf59cf3f73aaa06e0a85411f
5
5
  SHA512:
6
- metadata.gz: fc1cd499b7a87cc25bb9968736c04c9aae5d771c3a0c43ec4068ee09ffc570afad2ae1b9c80edb29e12ada3d5409af24334aacfcadba515118fe6d3d744d3958
7
- data.tar.gz: 9af9603efc5a85053434e121c764ff1cbf886e628a11504f63257c940e2d7dd420b1ca30cb29f5ee1e671528c3e6387df810b4713f6b220fc917d390c8e45576
6
+ metadata.gz: 14f394a58a009bcd29ddddae1510a6bb054830b9b632ce7634f9df3f802119075cf697cca32e1242b8e8866709512af02084ec229ecac751e9abd79c82f316d0
7
+ data.tar.gz: 7ad1570992eca4938bb2a9b6b425952eda61dd3109593347c03a32b178442b3e617bac343a7336494e232c1c0b6a632de03045fd16086b12b677f2b7bc21ee8f
data/lib/watir_drops.rb CHANGED
@@ -1,7 +1,6 @@
1
- require 'watir-webdriver'
1
+ require 'watir_session'
2
+ require 'require_all'
2
3
 
3
- require "watir_drops/version"
4
- require "watir_drops/session"
5
- require "watir_drops/page_object"
4
+ require_all 'lib'
6
5
 
7
6
  include WatirDrops
@@ -1,10 +1,12 @@
1
+ require "active_support/inflector"
2
+
1
3
  module WatirDrops
2
4
  class PageObject
3
5
 
4
6
  class << self
5
- def page_url url
6
- define_method("goto") do
7
- browser.goto url
7
+ def page_url
8
+ define_method("goto") do |*args|
9
+ browser.goto yield(*args)
8
10
  end
9
11
  end
10
12
 
@@ -17,11 +19,18 @@ module WatirDrops
17
19
  self.instance_exec(*args, &block)
18
20
  end
19
21
 
22
+ define_method(name.to_s.pluralize) do |*args|
23
+ selector = self.instance_exec(*args, &block).instance_variable_get('@selector')
24
+ element_type = selector.delete :tag_name
25
+ browser.send(element_type.pluralize, selector)
26
+ end
27
+
28
+
20
29
  define_method("#{name}=") do |val|
21
30
  watir_element = self.instance_exec &block
22
31
  case watir_element
23
32
  when Watir::Radio
24
- watir_element.set val
33
+ watir_element.set if val
25
34
  when Watir::CheckBox
26
35
  val ? watir_element.set : watir_element.clear
27
36
  when Watir::Select
@@ -36,22 +45,39 @@ module WatirDrops
36
45
  elements << {name.to_sym => block}
37
46
  end
38
47
 
48
+ def visit(*args)
49
+ new.tap do |page|
50
+ page.goto(*args)
51
+ yield if block_given?
52
+ end
53
+ end
54
+
55
+ def use
56
+ new.tap { yield if block_given? }
57
+ end
58
+
39
59
  end
40
60
 
41
61
  attr_reader :browser
42
62
 
43
- def initialize(browser=nil)
44
- @browser = browser || WatirDrops::Session.instance.browser
63
+ def initialize
64
+ @browser = WatirSession.browser
45
65
  end
46
66
 
47
- def visit
48
- goto if self.respond_to? :goto
49
- self
67
+ def submit_form(model)
68
+ intersect = self.class.elements.map(&:keys).flatten & model.keys
69
+ intersect.each do |val|
70
+ self.send("#{val}=", model.send(val))
71
+ end
50
72
  end
51
73
 
52
74
  def title
53
75
  browser.title
54
76
  end
55
77
 
78
+ def url
79
+ browser.url
80
+ end
81
+
56
82
  end
57
83
  end
data/watir_drops.gemspec CHANGED
@@ -1,11 +1,8 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'watir_drops/version'
5
2
 
6
3
  Gem::Specification.new do |spec|
7
4
  spec.name = "watir_drops"
8
- spec.version = WatirDrops::VERSION
5
+ spec.version = '0.3.0'
9
6
  spec.authors = ["Titus Fortner"]
10
7
  spec.email = ["titusfortner@gmail.com"]
11
8
 
@@ -23,5 +20,9 @@ application information, allowing it to be decoupled from the tests}
23
20
  spec.add_development_dependency "bundler", "~> 1.10"
24
21
  spec.add_development_dependency "rake", "~> 10.0"
25
22
  spec.add_development_dependency "rspec"
26
- spec.add_development_dependency "watir-webdriver", "~> 0.8.0"
23
+ spec.add_development_dependency "require_all"
24
+ spec.add_development_dependency "test-model"
25
+ spec.add_development_dependency "watir-webdriver"
26
+ spec.add_development_dependency "watir_session"
27
+ spec.add_development_dependency "activesupport", "~> 3.0"
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir_drops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,76 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: require_all
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-model
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: watir-webdriver
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: watir_session
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
57
113
  requirement: !ruby/object:Gem::Requirement
58
114
  requirements:
59
115
  - - "~>"
60
116
  - !ruby/object:Gem::Version
61
- version: 0.8.0
117
+ version: '3.0'
62
118
  type: :development
63
119
  prerelease: false
64
120
  version_requirements: !ruby/object:Gem::Requirement
65
121
  requirements:
66
122
  - - "~>"
67
123
  - !ruby/object:Gem::Version
68
- version: 0.8.0
124
+ version: '3.0'
69
125
  description: |-
70
126
  This gem leverages the Watir test framework to allow for easy modeling of specific web
71
127
  application information, allowing it to be decoupled from the tests
@@ -82,8 +138,6 @@ files:
82
138
  - Rakefile
83
139
  - lib/watir_drops.rb
84
140
  - lib/watir_drops/page_object.rb
85
- - lib/watir_drops/session.rb
86
- - lib/watir_drops/version.rb
87
141
  - watir_drops.gemspec
88
142
  homepage: https://github.com/titusfortner/watir_drops
89
143
  licenses:
@@ -105,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
159
  version: '0'
106
160
  requirements: []
107
161
  rubyforge_project:
108
- rubygems_version: 2.4.8
162
+ rubygems_version: 2.4.5.1
109
163
  signing_key:
110
164
  specification_version: 4
111
165
  summary: Page Object Framework for use with Watir
@@ -1,17 +0,0 @@
1
- require 'singleton'
2
-
3
- module WatirDrops
4
- class Session
5
- include Singleton
6
-
7
- def browser
8
- @browser ||= Watir::Browser.new :chrome
9
- end
10
-
11
- def quit
12
- @browser.quit
13
- @browser = nil
14
- end
15
-
16
- end
17
- end
@@ -1,3 +0,0 @@
1
- module WatirDrops
2
- VERSION = "0.1.1"
3
- end