gizmo 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -5
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/features/support/env.rb +2 -1
- data/features/support/pages/page_with_github_search.rb +21 -3
- data/gizmo.gemspec +12 -7
- data/lib/gizmo.rb +3 -0
- data/lib/gizmo/helpers.rb +17 -2
- data/lib/gizmo/templates.rb +9 -0
- data/lib/gizmo/templates/page_mixin.erb +27 -0
- data/spec/gizmo/helpers_spec.rb +2 -1
- metadata +44 -7
data/LICENSE
CHANGED
@@ -6,15 +6,23 @@ a copy of this software and associated documentation files (the
|
|
6
6
|
without limitation the rights to use, copy, modify, merge, publish,
|
7
7
|
distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
|
9
|
+
The following conditions:
|
10
10
|
|
11
11
|
The above copyright notice and this permission notice shall be
|
12
12
|
included in all copies or substantial portions of the Software.
|
13
13
|
|
14
|
+
Except as contained in this notice, neither the names of the above
|
15
|
+
copyright holders nor sponsors in relation to the Software (REA Group
|
16
|
+
or its subsidiaries) shall be used in advertising or otherwise to
|
17
|
+
promote the sale, use or other dealings in the Software without prior
|
18
|
+
written authorization.
|
19
|
+
|
14
20
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
21
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
22
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OR
|
24
|
+
SPONSORS IN RELATION TO THE SOFTWARE (REA GROUP LIMITED OR ITS
|
25
|
+
SUBSIDIARIES) OR THEIR RELATED PERSONS BE LIABLE FOR ANY CLAIM, DAMAGES
|
26
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
27
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
28
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -11,13 +11,14 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/icaruswings/gizmo"
|
12
12
|
gem.authors = ["Luke Cunningham", "Steven Holloway", "Sam Weller"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.3.0"
|
14
|
-
gem.add_development_dependency "cucumber", ">= 0.
|
14
|
+
gem.add_development_dependency "cucumber", ">= 0.7.2"
|
15
15
|
gem.add_development_dependency "webrat", ">= 0.7.0"
|
16
16
|
gem.add_development_dependency "capybara", ">= 0.3.5"
|
17
17
|
gem.add_development_dependency "metric_fu", ">= 1.3.0"
|
18
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
19
|
gem.add_dependency "nokogiri", ">= 1.4.1"
|
20
20
|
gem.add_dependency "activesupport", ">= 2.3.5"
|
21
|
+
gem.add_dependency "tilt", ">= 1.0.1"
|
21
22
|
end
|
22
23
|
Jeweler::GemcutterTasks.new
|
23
24
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/features/support/env.rb
CHANGED
@@ -5,7 +5,8 @@ require 'spec/expectations'
|
|
5
5
|
#CAPYBARA
|
6
6
|
require 'capybara/cucumber'
|
7
7
|
require 'capybara/session'
|
8
|
-
|
8
|
+
|
9
|
+
# require 'features/support/patches/capybara'
|
9
10
|
Capybara.default_driver = :selenium
|
10
11
|
Capybara.run_server = false
|
11
12
|
|
@@ -14,10 +14,28 @@ module PageWithGithubSearch
|
|
14
14
|
form.submit = container.css("input[alt=search]")
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
define_action :enter_search_query do |query|
|
19
|
+
# #set is capybaras method for setting a value for an element
|
20
|
+
locate(search_form.input).set(query)
|
21
|
+
end
|
22
|
+
|
23
|
+
define_action :click_element do |element|
|
24
|
+
locate(element).click
|
25
|
+
end
|
26
|
+
|
18
27
|
define_action :search do |query|
|
19
|
-
|
20
|
-
|
28
|
+
perform :enter_search_query, query
|
29
|
+
perform :click_element, search_form.submit
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def locate nokogiri_element
|
35
|
+
# turn a nokogiri element into a capybara element
|
36
|
+
# so we can use capybara's api to perform actions
|
37
|
+
node = nokogiri_element.is_a?(Nokogiri::XML::NodeSet) ? nokogiri_element.first : nokogiri_element
|
38
|
+
find(:xpath, node.path)
|
21
39
|
end
|
22
40
|
|
23
41
|
end
|
data/gizmo.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gizmo}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Luke Cunningham", "Steven Holloway", "Sam Weller"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-08-10}
|
13
13
|
s.default_executable = %q{gizmo}
|
14
14
|
s.description = %q{gizmo is a simple page model testing framework used and sponsored by 'realestate.com.au'. The aim of the project is to DRY up your testing assertions by abstracting code that defines your page resulting in a consistent, easy to maintain test suit}
|
15
15
|
s.email = %q{luke@icaruswings.com}
|
@@ -39,6 +39,8 @@ Gem::Specification.new do |s|
|
|
39
39
|
"lib/gizmo/helpers.rb",
|
40
40
|
"lib/gizmo/page.rb",
|
41
41
|
"lib/gizmo/page_mixin.rb",
|
42
|
+
"lib/gizmo/templates.rb",
|
43
|
+
"lib/gizmo/templates/page_mixin.erb",
|
42
44
|
"spec/github_site_example_spec.rb",
|
43
45
|
"spec/gizmo/configuration_spec.rb",
|
44
46
|
"spec/gizmo/helpers_spec.rb",
|
@@ -51,7 +53,7 @@ Gem::Specification.new do |s|
|
|
51
53
|
s.homepage = %q{http://github.com/icaruswings/gizmo}
|
52
54
|
s.rdoc_options = ["--charset=UTF-8"]
|
53
55
|
s.require_paths = ["lib"]
|
54
|
-
s.rubygems_version = %q{1.3.
|
56
|
+
s.rubygems_version = %q{1.3.7}
|
55
57
|
s.summary = %q{simple page model testing framework}
|
56
58
|
s.test_files = [
|
57
59
|
"spec/github_site_example_spec.rb",
|
@@ -67,31 +69,34 @@ Gem::Specification.new do |s|
|
|
67
69
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
68
70
|
s.specification_version = 3
|
69
71
|
|
70
|
-
if Gem::Version.new(Gem::
|
72
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
71
73
|
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
72
|
-
s.add_development_dependency(%q<cucumber>, [">= 0.
|
74
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.7.2"])
|
73
75
|
s.add_development_dependency(%q<webrat>, [">= 0.7.0"])
|
74
76
|
s.add_development_dependency(%q<capybara>, [">= 0.3.5"])
|
75
77
|
s.add_development_dependency(%q<metric_fu>, [">= 1.3.0"])
|
76
78
|
s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
|
77
79
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
|
80
|
+
s.add_runtime_dependency(%q<tilt>, [">= 1.0.1"])
|
78
81
|
else
|
79
82
|
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
80
|
-
s.add_dependency(%q<cucumber>, [">= 0.
|
83
|
+
s.add_dependency(%q<cucumber>, [">= 0.7.2"])
|
81
84
|
s.add_dependency(%q<webrat>, [">= 0.7.0"])
|
82
85
|
s.add_dependency(%q<capybara>, [">= 0.3.5"])
|
83
86
|
s.add_dependency(%q<metric_fu>, [">= 1.3.0"])
|
84
87
|
s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
|
85
88
|
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
89
|
+
s.add_dependency(%q<tilt>, [">= 1.0.1"])
|
86
90
|
end
|
87
91
|
else
|
88
92
|
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
89
|
-
s.add_dependency(%q<cucumber>, [">= 0.
|
93
|
+
s.add_dependency(%q<cucumber>, [">= 0.7.2"])
|
90
94
|
s.add_dependency(%q<webrat>, [">= 0.7.0"])
|
91
95
|
s.add_dependency(%q<capybara>, [">= 0.3.5"])
|
92
96
|
s.add_dependency(%q<metric_fu>, [">= 1.3.0"])
|
93
97
|
s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
|
94
98
|
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
99
|
+
s.add_dependency(%q<tilt>, [">= 1.0.1"])
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
data/lib/gizmo.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'active_support'
|
3
3
|
require 'nokogiri'
|
4
|
+
require 'tilt'
|
5
|
+
require 'term/ansicolor'
|
4
6
|
|
5
7
|
$LOAD_PATH << File.dirname(__FILE__)
|
6
8
|
|
@@ -9,6 +11,7 @@ module Gizmo
|
|
9
11
|
autoload :Page, "gizmo/page"
|
10
12
|
autoload :Helpers, "gizmo/helpers"
|
11
13
|
autoload :PageMixin, "gizmo/page_mixin"
|
14
|
+
autoload :Templates, "gizmo/templates"
|
12
15
|
|
13
16
|
GizmoError = Class.new(StandardError)
|
14
17
|
MixinNotValidError = Class.new(GizmoError)
|
data/lib/gizmo/helpers.rb
CHANGED
@@ -25,10 +25,25 @@ module Gizmo
|
|
25
25
|
begin
|
26
26
|
mixin_dir = Gizmo.configuration.mixin_dir
|
27
27
|
const_name = "PageWith#{mixin_name.to_s.camelize}"
|
28
|
-
|
28
|
+
mixin = Dir["#{mixin_dir}/**/page_with_#{mixin_name}.rb"].first
|
29
|
+
require (mixin || "#{mixin_dir}/page_with_#{mixin_name}.rb") unless Object.const_defined?(const_name)
|
29
30
|
Object.const_get(const_name)
|
30
31
|
rescue LoadError
|
31
|
-
raise MixinNotFoundError,
|
32
|
+
raise MixinNotFoundError, error_body = <<EOS
|
33
|
+
|
34
|
+
-------------------------------------------------
|
35
|
+
!!! There was no page_with_#{mixin_name} file !!!
|
36
|
+
-------------------------------------------------
|
37
|
+
You can create a new file at:
|
38
|
+
#{mixin_dir}/page_with_#{mixin_name}.rb
|
39
|
+
|
40
|
+
then just copy the mixin code below into it
|
41
|
+
and you'll be ready to gizmo!
|
42
|
+
------------------------------------------------
|
43
|
+
|
44
|
+
#{Gizmo::Templates::PageMixin.render(self, :const_name => const_name, :mixin_name => mixin_name)}
|
45
|
+
|
46
|
+
EOS
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module <%= const_name %>
|
2
|
+
# include the Gizmo::PageMixin extensions
|
3
|
+
# you need this to use the define_action syntax
|
4
|
+
include Gizmo::PageMixin
|
5
|
+
|
6
|
+
def valid?
|
7
|
+
# put your code here to test your page is valid
|
8
|
+
# if this method returns false, the on_page_with helper method will raise a "page did not have <%= mixin_name %>"
|
9
|
+
# example.
|
10
|
+
# document.has_selector?("some-css-selector")
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
# DEFINE YOUR SELECTORS HERE
|
15
|
+
# def search_form
|
16
|
+
# element_struct |form|
|
17
|
+
# form.input = document.css('input[name=search]')
|
18
|
+
# form.input = document.css('input[name=search]')
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
|
22
|
+
#DEFINE YOUR ACTIONS HERE
|
23
|
+
# define_action :search do |query|
|
24
|
+
# fill_in search_form.input.attr('name'), :with => query
|
25
|
+
# end
|
26
|
+
|
27
|
+
end
|
data/spec/gizmo/helpers_spec.rb
CHANGED
@@ -77,7 +77,8 @@ describe "Gizmo" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should raise Gizmo::MixinNotFoundError if the mixin file cannot be loaded from the mixin_path" do
|
80
|
-
|
80
|
+
error_msg = Gizmo::Templates::PageMixin.render(self, { :const_name => "PageWithMyNonExistentMixin", :mixin_name => "page_with_my_non_existent_mixin" })
|
81
|
+
lambda { on_page_with :my_non_existent_mixin }.should raise_error(Gizmo::MixinNotFoundError, /#{ error_msg }/)
|
81
82
|
end
|
82
83
|
|
83
84
|
it "should yield a page object to a block if supplied" do
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gizmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
8
|
+
- 1
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.5
|
10
|
+
version: 0.1.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Luke Cunningham
|
@@ -16,16 +17,18 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2010-
|
20
|
+
date: 2010-08-10 00:00:00 +10:00
|
20
21
|
default_executable: gizmo
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: rspec
|
24
25
|
prerelease: false
|
25
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
26
28
|
requirements:
|
27
29
|
- - ">="
|
28
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 27
|
29
32
|
segments:
|
30
33
|
- 1
|
31
34
|
- 3
|
@@ -37,23 +40,27 @@ dependencies:
|
|
37
40
|
name: cucumber
|
38
41
|
prerelease: false
|
39
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
40
44
|
requirements:
|
41
45
|
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: 7
|
43
48
|
segments:
|
44
49
|
- 0
|
45
|
-
-
|
46
|
-
-
|
47
|
-
version: 0.
|
50
|
+
- 7
|
51
|
+
- 2
|
52
|
+
version: 0.7.2
|
48
53
|
type: :development
|
49
54
|
version_requirements: *id002
|
50
55
|
- !ruby/object:Gem::Dependency
|
51
56
|
name: webrat
|
52
57
|
prerelease: false
|
53
58
|
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
54
60
|
requirements:
|
55
61
|
- - ">="
|
56
62
|
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
57
64
|
segments:
|
58
65
|
- 0
|
59
66
|
- 7
|
@@ -65,9 +72,11 @@ dependencies:
|
|
65
72
|
name: capybara
|
66
73
|
prerelease: false
|
67
74
|
requirement: &id004 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
68
76
|
requirements:
|
69
77
|
- - ">="
|
70
78
|
- !ruby/object:Gem::Version
|
79
|
+
hash: 25
|
71
80
|
segments:
|
72
81
|
- 0
|
73
82
|
- 3
|
@@ -79,9 +88,11 @@ dependencies:
|
|
79
88
|
name: metric_fu
|
80
89
|
prerelease: false
|
81
90
|
requirement: &id005 !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
82
92
|
requirements:
|
83
93
|
- - ">="
|
84
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 27
|
85
96
|
segments:
|
86
97
|
- 1
|
87
98
|
- 3
|
@@ -93,9 +104,11 @@ dependencies:
|
|
93
104
|
name: nokogiri
|
94
105
|
prerelease: false
|
95
106
|
requirement: &id006 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
96
108
|
requirements:
|
97
109
|
- - ">="
|
98
110
|
- !ruby/object:Gem::Version
|
111
|
+
hash: 5
|
99
112
|
segments:
|
100
113
|
- 1
|
101
114
|
- 4
|
@@ -107,9 +120,11 @@ dependencies:
|
|
107
120
|
name: activesupport
|
108
121
|
prerelease: false
|
109
122
|
requirement: &id007 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
110
124
|
requirements:
|
111
125
|
- - ">="
|
112
126
|
- !ruby/object:Gem::Version
|
127
|
+
hash: 9
|
113
128
|
segments:
|
114
129
|
- 2
|
115
130
|
- 3
|
@@ -117,6 +132,22 @@ dependencies:
|
|
117
132
|
version: 2.3.5
|
118
133
|
type: :runtime
|
119
134
|
version_requirements: *id007
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: tilt
|
137
|
+
prerelease: false
|
138
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 21
|
144
|
+
segments:
|
145
|
+
- 1
|
146
|
+
- 0
|
147
|
+
- 1
|
148
|
+
version: 1.0.1
|
149
|
+
type: :runtime
|
150
|
+
version_requirements: *id008
|
120
151
|
description: gizmo is a simple page model testing framework used and sponsored by 'realestate.com.au'. The aim of the project is to DRY up your testing assertions by abstracting code that defines your page resulting in a consistent, easy to maintain test suit
|
121
152
|
email: luke@icaruswings.com
|
122
153
|
executables:
|
@@ -147,6 +178,8 @@ files:
|
|
147
178
|
- lib/gizmo/helpers.rb
|
148
179
|
- lib/gizmo/page.rb
|
149
180
|
- lib/gizmo/page_mixin.rb
|
181
|
+
- lib/gizmo/templates.rb
|
182
|
+
- lib/gizmo/templates/page_mixin.erb
|
150
183
|
- spec/github_site_example_spec.rb
|
151
184
|
- spec/gizmo/configuration_spec.rb
|
152
185
|
- spec/gizmo/helpers_spec.rb
|
@@ -165,23 +198,27 @@ rdoc_options:
|
|
165
198
|
require_paths:
|
166
199
|
- lib
|
167
200
|
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
168
202
|
requirements:
|
169
203
|
- - ">="
|
170
204
|
- !ruby/object:Gem::Version
|
205
|
+
hash: 3
|
171
206
|
segments:
|
172
207
|
- 0
|
173
208
|
version: "0"
|
174
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
|
+
none: false
|
175
211
|
requirements:
|
176
212
|
- - ">="
|
177
213
|
- !ruby/object:Gem::Version
|
214
|
+
hash: 3
|
178
215
|
segments:
|
179
216
|
- 0
|
180
217
|
version: "0"
|
181
218
|
requirements: []
|
182
219
|
|
183
220
|
rubyforge_project:
|
184
|
-
rubygems_version: 1.3.
|
221
|
+
rubygems_version: 1.3.7
|
185
222
|
signing_key:
|
186
223
|
specification_version: 3
|
187
224
|
summary: simple page model testing framework
|