capypage 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/capypage.gemspec +1 -0
- data/examples/simple/.rspec +2 -0
- data/examples/simple/spec/simple_spec.rb +5 -0
- data/examples/simple/spec/spec_helper.rb +3 -1
- data/lib/capypage/page.rb +12 -4
- data/lib/capypage/version.rb +1 -1
- data/spec/{sample_page.html → html/sample_page.html} +0 -0
- data/spec/spec_helper.rb +18 -3
- data/spec/{element_spec.rb → unit/element_spec.rb} +0 -0
- data/spec/{elements_spec.rb → unit/elements_spec.rb} +0 -0
- data/spec/{page_spec.rb → unit/page_spec.rb} +13 -4
- data/spec/{section_spec.rb → unit/section_spec.rb} +0 -0
- metadata +26 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 625eda3d8239f07436335eef1e3221f48dcafc79
|
4
|
+
data.tar.gz: 7e6557e82447fcce8c99e03bf2a3a74ac865cbf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a7ae43f99bfdc57ca888dc6030542b5e4d3993499be64bfbf7ee96a380d3dd2c6d35c51057bb514611d0c02bd00a622a332ec3855c431ef2e464510e480a688
|
7
|
+
data.tar.gz: 7c1ccb2d083e4920679f7f6fc7efb8677fce845cca1a752eed74217798feec43a95280a7c73a053057c79668a95c0d43c56fdf94990a37ce8899c89a658c64d5
|
data/CHANGELOG.md
CHANGED
data/capypage.gemspec
CHANGED
@@ -12,4 +12,9 @@ describe 'Simple example', :type => :feature do
|
|
12
12
|
expect(capybara_result.link[:href]).to eq('https://github.com/jnicklas/capybara')
|
13
13
|
expect(capybara_result.snippet).to have_text('Capybara helps you test web applications')
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'should load the page with custom url' do
|
17
|
+
page = DuckDuckGo::ResultsPage.visit :query => 'capybara'
|
18
|
+
expect(page.results).to have_text('jnicklas')
|
19
|
+
end
|
15
20
|
end
|
@@ -8,7 +8,7 @@ Capybara.default_driver = :webkit
|
|
8
8
|
|
9
9
|
module DuckDuckGo
|
10
10
|
class HomePage < Capypage::Page
|
11
|
-
|
11
|
+
set_url 'https://duckduckgo.com/'
|
12
12
|
|
13
13
|
element :search_input, 'input[name=q]'
|
14
14
|
element :search_button, 'input#search_button_homepage'
|
@@ -20,6 +20,8 @@ module DuckDuckGo
|
|
20
20
|
end
|
21
21
|
|
22
22
|
class ResultsPage < Capypage::Page
|
23
|
+
set_url 'https://duckduckgo.com/?q=:query'
|
24
|
+
|
23
25
|
elements :results, '#links', '.results_links_deep' do |result|
|
24
26
|
result.element :link, '.links_main a'
|
25
27
|
result.element :snippet, '.snippet'
|
data/lib/capypage/page.rb
CHANGED
@@ -5,9 +5,11 @@ module Capypage
|
|
5
5
|
class Page
|
6
6
|
include Capybara::DSL
|
7
7
|
class_attribute :url
|
8
|
-
attr_reader :finder_options
|
8
|
+
attr_reader :finder_options, :url_options
|
9
9
|
|
10
|
-
def initialize(
|
10
|
+
def initialize(options = {})
|
11
|
+
prefix = options.delete(:prefix)
|
12
|
+
@url_options = options.delete(:url_options) || {}
|
11
13
|
@finder_options = options.merge(:base_element => prefix ? Element.new(prefix, :base_element => Capybara.current_session) : Capybara.current_session)
|
12
14
|
end
|
13
15
|
|
@@ -25,12 +27,18 @@ module Capypage
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def section(name, section, selector, options = {})
|
28
|
-
define_method(name) { section.new(selector
|
30
|
+
define_method(name) { section.new(options.merge :prefix => selector) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def visit(url_options = {})
|
34
|
+
new(:url_options => url_options).tap &:load
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
32
38
|
def load
|
33
|
-
|
39
|
+
url = self.class.url.clone
|
40
|
+
url_options.each { |k, v| url.gsub!(":#{k}", v) }
|
41
|
+
visit url
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
data/lib/capypage/version.rb
CHANGED
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
require 'capypage'
|
2
2
|
require 'capybara/rspec'
|
3
|
+
require 'sinatra/base'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
class TestApp < Sinatra::Base
|
6
|
+
get '/' do
|
7
|
+
File.read(File.join(File.dirname(__FILE__), 'html', 'sample_page.html'))
|
8
|
+
end
|
9
|
+
|
10
|
+
get '/echo/:input' do
|
11
|
+
"<p class='echo'>#{params[:input]}</p>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Capybara.app = TestApp.new
|
7
16
|
|
8
17
|
class PopupSection < Capypage::Section
|
9
18
|
element :title, '.title'
|
@@ -23,3 +32,9 @@ class SamplePage < Capypage::Page
|
|
23
32
|
|
24
33
|
section :popup, PopupSection, '.popup'
|
25
34
|
end
|
35
|
+
|
36
|
+
class EchoPage < Capypage::Page
|
37
|
+
set_url '/echo/:input'
|
38
|
+
|
39
|
+
element :content, 'p.echo'
|
40
|
+
end
|
File without changes
|
File without changes
|
@@ -5,9 +5,19 @@ describe Capypage::Page do
|
|
5
5
|
let(:current_session) { Capybara.current_session }
|
6
6
|
|
7
7
|
context 'page loading' do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
context 'complete url' do
|
9
|
+
it 'should load the page' do
|
10
|
+
current_session.should_receive(:visit).with(SamplePage.url)
|
11
|
+
page.load
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'dynamic url' do
|
16
|
+
it 'should load the page with the options substituted' do
|
17
|
+
page = EchoPage.visit :input => 'Hello'
|
18
|
+
expect(page.current_url).to end_with '/echo/Hello'
|
19
|
+
expect(page.content.text).to eq('Hello')
|
20
|
+
end
|
11
21
|
end
|
12
22
|
end
|
13
23
|
|
@@ -30,7 +40,6 @@ describe Capypage::Page do
|
|
30
40
|
it 'should return the element in the collection and its details' do
|
31
41
|
expect(elements.find_by_index(0).title.text).to eq('Title 1')
|
32
42
|
end
|
33
|
-
|
34
43
|
end
|
35
44
|
end
|
36
45
|
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capypage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Selvakumar Natesan
|
@@ -82,6 +82,20 @@ dependencies:
|
|
82
82
|
- - '>='
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: sinatra
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
85
99
|
description: Page Object Model for Capybara
|
86
100
|
email:
|
87
101
|
- k.n.selvakumar@gmail.com
|
@@ -98,6 +112,7 @@ files:
|
|
98
112
|
- README.md
|
99
113
|
- Rakefile
|
100
114
|
- capypage.gemspec
|
115
|
+
- examples/simple/.rspec
|
101
116
|
- examples/simple/Gemfile
|
102
117
|
- examples/simple/README.md
|
103
118
|
- examples/simple/spec/simple_spec.rb
|
@@ -109,12 +124,12 @@ files:
|
|
109
124
|
- lib/capypage/page.rb
|
110
125
|
- lib/capypage/section.rb
|
111
126
|
- lib/capypage/version.rb
|
112
|
-
- spec/
|
113
|
-
- spec/elements_spec.rb
|
114
|
-
- spec/page_spec.rb
|
115
|
-
- spec/sample_page.html
|
116
|
-
- spec/section_spec.rb
|
127
|
+
- spec/html/sample_page.html
|
117
128
|
- spec/spec_helper.rb
|
129
|
+
- spec/unit/element_spec.rb
|
130
|
+
- spec/unit/elements_spec.rb
|
131
|
+
- spec/unit/page_spec.rb
|
132
|
+
- spec/unit/section_spec.rb
|
118
133
|
homepage: http://github.com/TWChennai/capypage
|
119
134
|
licenses:
|
120
135
|
- MIT
|
@@ -140,9 +155,9 @@ signing_key:
|
|
140
155
|
specification_version: 4
|
141
156
|
summary: Page Object Model for Capybara
|
142
157
|
test_files:
|
143
|
-
- spec/
|
144
|
-
- spec/elements_spec.rb
|
145
|
-
- spec/page_spec.rb
|
146
|
-
- spec/sample_page.html
|
147
|
-
- spec/section_spec.rb
|
158
|
+
- spec/html/sample_page.html
|
148
159
|
- spec/spec_helper.rb
|
160
|
+
- spec/unit/element_spec.rb
|
161
|
+
- spec/unit/elements_spec.rb
|
162
|
+
- spec/unit/page_spec.rb
|
163
|
+
- spec/unit/section_spec.rb
|