capybara-page-object 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +83 -0
- data/VERSION +1 -1
- data/capybara-page-object.gemspec +17 -10
- data/lib/capybara-page-object.rb +4 -4
- data/lib/collections.rb +11 -5
- data/lib/delegators.rb +14 -0
- data/lib/element.rb +14 -11
- data/lib/element/TODO.md +11 -0
- data/lib/element/anchor.rb +1 -5
- data/lib/element/form.rb +6 -10
- data/lib/element/form_field.rb +4 -9
- data/lib/element/head.rb +15 -0
- data/lib/element/image.rb +6 -11
- data/lib/element/input.rb +8 -13
- data/lib/element/list.rb +1 -15
- data/lib/element/list_item.rb +7 -0
- data/lib/element/meta.rb +2 -7
- data/lib/element/select.rb +1 -13
- data/lib/element/table.rb +11 -4
- data/lib/element/table_header.rb +4 -0
- data/lib/element/table_row.rb +7 -0
- data/lib/element/text_based_input.rb +16 -0
- data/lib/element/textarea.rb +5 -11
- data/lib/html5_data.rb +3 -7
- data/lib/key_value.rb +1 -1
- data/lib/node.rb +9 -54
- data/lib/page.rb +40 -0
- data/spec/common_spec.rb +13 -21
- data/spec/element/anchor_spec.rb +2 -2
- data/spec/element/base_spec.rb +2 -2
- data/spec/element/form_field_spec.rb +4 -4
- data/spec/element/form_spec.rb +26 -25
- data/spec/element/head_spec.rb +24 -0
- data/spec/element/image_spec.rb +5 -5
- data/spec/element/input_spec.rb +52 -17
- data/spec/element/list_item_spec.rb +19 -0
- data/spec/element/list_spec.rb +3 -20
- data/spec/element/meta_spec.rb +3 -2
- data/spec/element/select_spec.rb +4 -29
- data/spec/element/table_row_spec.rb +19 -0
- data/spec/element/table_spec.rb +35 -5
- data/spec/element/textarea_spec.rb +14 -4
- data/spec/node_spec.rb +14 -37
- data/spec/page_spec.rb +37 -0
- metadata +31 -24
- data/README.rdoc +0 -18
- data/lib/element/listitem.rb +0 -7
- data/lib/extractor/common.rb +0 -42
- data/lib/extractor/page_level.rb +0 -15
- data/lib/navigation.rb +0 -16
- data/spec/element/listitem_spec.rb +0 -25
data/spec/page_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
class FooPage < CapybaraPageObject::Page
|
2
|
+
def path
|
3
|
+
'/foo'
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Page" do
|
8
|
+
context "#new" do
|
9
|
+
it "visits the appropriate when initialised" do
|
10
|
+
mock_source = mock()
|
11
|
+
mock_source.should_receive(:current_path)
|
12
|
+
mock_source.should_receive(:visit).with('/foo')
|
13
|
+
@page = FooPage.new(nil, mock_source)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "supports key-value pairs" do
|
17
|
+
mock_source = mock()
|
18
|
+
mock_source.should_receive(:current_path)
|
19
|
+
mock_source.should_receive(:visit).with('/foo?a=1&b=2')
|
20
|
+
# intential mix of string and symbol keys below
|
21
|
+
@page = FooPage.new({'a' => 1, :b => 2}, mock_source)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises an exception if revisiting" do
|
25
|
+
s = stub('Capybara', :current_path => '/foo', :visit => nil)
|
26
|
+
lambda do
|
27
|
+
@page = FooPage.new(nil, s)
|
28
|
+
end.should raise_error(RuntimeError, 'Detected repeat of page load - use #reload instead')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "#refresh" do
|
33
|
+
pending "revisits the page" do
|
34
|
+
# TODO implemented but untested
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-page-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157133000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157133000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157129760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157129760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157127200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157127200
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157125680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157125680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &2157121880 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2157121880
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
|
-
requirement: &
|
71
|
+
requirement: &2157115040 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.9.2.2
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2157115040
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rdoc
|
82
|
-
requirement: &
|
82
|
+
requirement: &2157113260 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,59 +87,66 @@ dependencies:
|
|
87
87
|
version: '3.12'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2157113260
|
91
91
|
description: Page Objects for Capybara
|
92
92
|
email: andy@andywaite.com
|
93
93
|
executables: []
|
94
94
|
extensions: []
|
95
95
|
extra_rdoc_files:
|
96
96
|
- LICENSE.txt
|
97
|
-
- README.
|
97
|
+
- README.markdown
|
98
98
|
files:
|
99
99
|
- .document
|
100
100
|
- Gemfile
|
101
101
|
- Gemfile.lock
|
102
102
|
- LICENSE.txt
|
103
|
-
- README.
|
103
|
+
- README.markdown
|
104
104
|
- Rakefile
|
105
105
|
- VERSION
|
106
106
|
- capybara-page-object.gemspec
|
107
107
|
- lib/capybara-page-object.rb
|
108
108
|
- lib/collections.rb
|
109
|
+
- lib/delegators.rb
|
109
110
|
- lib/element.rb
|
111
|
+
- lib/element/TODO.md
|
110
112
|
- lib/element/anchor.rb
|
111
113
|
- lib/element/form.rb
|
112
114
|
- lib/element/form_field.rb
|
115
|
+
- lib/element/head.rb
|
113
116
|
- lib/element/image.rb
|
114
117
|
- lib/element/input.rb
|
115
118
|
- lib/element/list.rb
|
116
|
-
- lib/element/
|
119
|
+
- lib/element/list_item.rb
|
117
120
|
- lib/element/meta.rb
|
118
121
|
- lib/element/select.rb
|
119
122
|
- lib/element/table.rb
|
123
|
+
- lib/element/table_header.rb
|
124
|
+
- lib/element/table_row.rb
|
125
|
+
- lib/element/text_based_input.rb
|
120
126
|
- lib/element/textarea.rb
|
121
|
-
- lib/extractor/common.rb
|
122
|
-
- lib/extractor/page_level.rb
|
123
127
|
- lib/html5_data.rb
|
124
128
|
- lib/key_value.rb
|
125
|
-
- lib/navigation.rb
|
126
129
|
- lib/node.rb
|
130
|
+
- lib/page.rb
|
127
131
|
- spec/common_spec.rb
|
128
132
|
- spec/element/anchor_spec.rb
|
129
133
|
- spec/element/base_spec.rb
|
130
134
|
- spec/element/form_field_spec.rb
|
131
135
|
- spec/element/form_spec.rb
|
136
|
+
- spec/element/head_spec.rb
|
132
137
|
- spec/element/image_spec.rb
|
133
138
|
- spec/element/input_spec.rb
|
139
|
+
- spec/element/list_item_spec.rb
|
134
140
|
- spec/element/list_spec.rb
|
135
|
-
- spec/element/listitem_spec.rb
|
136
141
|
- spec/element/meta_spec.rb
|
137
142
|
- spec/element/select_spec.rb
|
143
|
+
- spec/element/table_row_spec.rb
|
138
144
|
- spec/element/table_spec.rb
|
139
145
|
- spec/element/textarea_spec.rb
|
140
146
|
- spec/fixtures/node.html
|
141
147
|
- spec/helper.rb
|
142
148
|
- spec/node_spec.rb
|
149
|
+
- spec/page_spec.rb
|
143
150
|
homepage: http://github.com/andyw8/capybara-page-object
|
144
151
|
licenses:
|
145
152
|
- MIT
|
@@ -155,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
162
|
version: '0'
|
156
163
|
segments:
|
157
164
|
- 0
|
158
|
-
hash:
|
165
|
+
hash: 4238477011080542478
|
159
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
167
|
none: false
|
161
168
|
requirements:
|
data/README.rdoc
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
= capybara-page-object
|
2
|
-
|
3
|
-
Page Objects for Capybara
|
4
|
-
|
5
|
-
== Contributing to capybara-page-object
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
-
* Fork the project
|
10
|
-
* Start a feature/bugfix branch
|
11
|
-
* Commit and push until you are happy with your contribution
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2012 Andy Waite. See LICENSE.txt for
|
18
|
-
further details.
|
data/lib/element/listitem.rb
DELETED
data/lib/extractor/common.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module Extractor
|
2
|
-
|
3
|
-
module Common
|
4
|
-
def extract(element, attr={}, page_object_class=nil)
|
5
|
-
by = attr[:by]
|
6
|
-
keys = attr[:keys]
|
7
|
-
if keys
|
8
|
-
r = []
|
9
|
-
all(element).each do |t|
|
10
|
-
r << t[keys]
|
11
|
-
end
|
12
|
-
r
|
13
|
-
elsif by
|
14
|
-
r = {}
|
15
|
-
all(element).each do |t|
|
16
|
-
if page_object_class
|
17
|
-
r[t[by]] = page_object_class.new(t)
|
18
|
-
else
|
19
|
-
r[t[by]] = t
|
20
|
-
end
|
21
|
-
end
|
22
|
-
r
|
23
|
-
else
|
24
|
-
if page_object_class
|
25
|
-
all(element).collect{ |e| page_object_class.new(e) }
|
26
|
-
else
|
27
|
-
all(element).collect
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# TODO use method_missing o handle these?
|
33
|
-
def all(*args)
|
34
|
-
source.all(*args)
|
35
|
-
end
|
36
|
-
|
37
|
-
def find(*args)
|
38
|
-
source.find(*args)
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
data/lib/extractor/page_level.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Extractor
|
2
|
-
module PageLevel
|
3
|
-
def title
|
4
|
-
find('title').text
|
5
|
-
end
|
6
|
-
|
7
|
-
def meta_description
|
8
|
-
extract('meta', :by => 'name')['description']['content']
|
9
|
-
end
|
10
|
-
|
11
|
-
def meta_keywords
|
12
|
-
extract('meta', :by => 'name')['keywords']['content'].split(',').collect(&:strip)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/navigation.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../helper'
|
2
|
-
|
3
|
-
describe "Listitem" do
|
4
|
-
before do
|
5
|
-
@listitem = CapybaraPageObject::Listitem.from_string <<-EOF
|
6
|
-
<li id="foo">
|
7
|
-
<span class="description">iPhone</span>
|
8
|
-
<span class="price">$500</span>
|
9
|
-
</li>
|
10
|
-
EOF
|
11
|
-
end
|
12
|
-
|
13
|
-
# TODO better way of handling whitespace
|
14
|
-
context "#text" do
|
15
|
-
it "return the text of the list" do
|
16
|
-
@listitem.text.strip.should == "iPhone\n $500"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "#key" do
|
21
|
-
it "return the id attribute" do
|
22
|
-
@listitem.key.should == 'foo'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|