pageify 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -93
- data/lib/pageify.rb +3 -1
- data/lib/pageify/capybara.rb +0 -15
- data/lib/pageify/capybara/assertions.rb +85 -0
- data/lib/pageify/capybara/base.rb +39 -0
- data/lib/pageify/capybara/bulk_actions.rb +73 -0
- data/lib/pageify/page_object.rb +43 -31
- data/spec/capybara_spec.rb +33 -17
- data/spec/page_object_spec.rb +1 -2
- data/spec/spec_helper.rb +3 -3
- metadata +64 -36
- data/lib/pageify/capybara_experimental.rb +0 -14
- data/spec/capybara_experimental_spec.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 630e6ce531498364ecae10fa314694ba451f36d4
|
4
|
+
data.tar.gz: 25651100fc86e853d22741c213e9ccd8fd72a51a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7f9e8966aaa5c10ff980196d7a246fb1e169e3651b2aa2ef40ad8a7cff5c361ce72e0b436f167917ae92672f4c00f6106ed033c1b7c0cf551b5e44f60d8a771
|
7
|
+
data.tar.gz: 703e38a7d16e524e2d8c7817262842e6bd62693f8295cea571d6019d62c020d271f4dade0f208a20380f9c6270bfa67da1af20bdba2936723e6b2cb45d17a0b5
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#Pageify
|
1
|
+
# Pageify
|
2
2
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/paramadeep/pageify.png)](https://codeclimate.com/github/paramadeep/pageify) [![Dependency Status](https://gemnasium.com/paramadeep/pageify.svg)](https://gemnasium.com/paramadeep/pageify) [![Build Status](https://travis-ci.org/paramadeep/pageify.svg?branch=master)](https://travis-ci.org/paramadeep/pageify)
|
4
4
|
|
@@ -8,23 +8,34 @@ Simplest way to define page objects. Bonus, tremendously fast tests.
|
|
8
8
|
|
9
9
|
Page definition looks like this
|
10
10
|
```yaml
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
sign_up: ".home"
|
12
|
+
user_name: ".user"
|
13
|
+
password: ".password"
|
14
|
+
age: ".age"
|
15
|
+
male: "radio.male"
|
16
|
+
female: "radio.female"
|
15
17
|
submit: "[name='submit']"
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
profile_page:
|
19
|
+
user_name: ".user"
|
20
|
+
password: ".password"
|
21
|
+
age: ".age"
|
22
|
+
gender: ".gender"
|
19
23
|
```
|
20
24
|
Test steps looks like this
|
21
25
|
```ruby
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
# set textbox, radiobox, checkbox in one shot
|
27
|
+
sign_up.set_fields {:user_name=> "hi",:password=>"bla",:male=>true,:age=>10}
|
28
|
+
sign_up.submit.click
|
29
|
+
# assert multiple fields
|
30
|
+
profile_page.should_match_fields {:user_name=> "hi",:male=>true,:age=>10}
|
31
|
+
```
|
32
|
+
or like this
|
33
|
+
```ruby
|
34
|
+
on sign_up do
|
35
|
+
user_name.set "hi"
|
36
|
+
password.set "bla"
|
37
|
+
submit.click
|
38
|
+
end
|
28
39
|
```
|
29
40
|
|
30
41
|
We will be able element whose locators are dynamic
|
@@ -35,65 +46,35 @@ products_page: ".products"
|
|
35
46
|
cost: ".cost"
|
36
47
|
```
|
37
48
|
```ruby
|
38
|
-
products_page.product("candy").details_row(1).cost.
|
39
|
-
products_page.product("tyres").details_row(2).cost.
|
49
|
+
products_page.product("candy").details_row(1).cost.should have_text "Rs.10"
|
50
|
+
products_page.product("tyres").details_row(2).cost.should have_text "Rs.20"
|
40
51
|
```
|
41
52
|
|
42
|
-
|
43
|
-
## Key benefits
|
44
|
-
|
45
|
-
- [Tests runs tremendously fast.] (https://github.com/paramadeep/pageify#how-tests-gets-faster-with-pageify)
|
46
|
-
- Your test will be more **readable**.
|
47
|
-
- **Eliminates duplicate** definition of selectors across test.
|
48
|
-
- **Easy Maintenance**.
|
49
|
-
|
50
|
-
|
51
53
|
## Usage
|
52
54
|
In your project Gemfile add
|
53
55
|
```ruby
|
54
56
|
gem 'pageify'
|
55
57
|
```
|
56
58
|
###Cucumber
|
57
|
-
In env.rb
|
58
|
-
```ruby
|
59
|
-
require 'pageify'
|
60
|
-
require 'pageify/capybara'
|
61
|
-
include Pageify
|
62
|
-
|
63
|
-
pageify("features/pages")
|
64
|
-
```
|
65
|
-
Place all the page defenitions under "features/pages"
|
66
|
-
|
67
|
-
##Methods
|
68
|
-
|
69
|
-
###Get Element 'f' or 'find'
|
70
|
-
```ruby
|
71
|
-
home_page.login.user_name.f #=> user_name text box
|
72
|
-
home_page.login.user_name.f.set "hi" # set text box value
|
73
|
-
home_page.login.user_name.find.should have_value "hi" # assert value
|
74
|
-
home_page.login.submit.find.click
|
75
|
-
```
|
76
|
-
|
77
|
-
###Get Element Collection 'find_all'
|
78
|
-
```ruby
|
79
|
-
home_page.product.find_all #=> all products in page
|
80
|
-
home_page.product.find_all[0] #=> first product in page
|
81
|
-
```
|
82
59
|
|
83
|
-
###Get Selector 'selector'
|
84
|
-
At times we would need selector of the object
|
85
60
|
```ruby
|
86
|
-
|
61
|
+
# features/support/env.rb
|
62
|
+
require 'pageify'
|
63
|
+
require 'pageify/capybara'
|
64
|
+
require "capybara"
|
65
|
+
require 'capybara/rspec'
|
66
|
+
require 'capybara/dsl'
|
67
|
+
require 'capybara/session'
|
68
|
+
require 'selenium-webdriver'
|
87
69
|
|
88
|
-
#
|
89
|
-
page.should_not have_selector home_page.login.user_name.selector
|
70
|
+
#define your capybara driver ... and
|
90
71
|
|
91
|
-
|
92
|
-
|
93
|
-
click_on home_page.login.submit.selector
|
72
|
+
pageify("features/pages")
|
73
|
+
set_session(page)
|
94
74
|
```
|
75
|
+
Place all the page defenitions under "features/pages"
|
95
76
|
|
96
|
-
##Splitting
|
77
|
+
## Splitting long page definitions
|
97
78
|
Sometimes, your page definition may get quite long. In other cases, you may also have the exact same HTML component (say a product listing) that can be repeated in multiple places (e.g. list, search, etc). In these cases, you can use sections to split your page into multiple files that can be reused.
|
98
79
|
|
99
80
|
The syntax for this is as follows:
|
@@ -113,39 +94,6 @@ search_results: '.search_results'
|
|
113
94
|
:section/product
|
114
95
|
|
115
96
|
```
|
116
|
-
|
117
|
-
## Experimental Feature
|
118
|
-
|
119
|
-
Making the test more readable is a constant persuite. Currently working on removing use of "find" or "f" in every step
|
120
|
-
|
121
|
-
```
|
122
|
-
#currently
|
123
|
-
home_page.login.user_name.find.set "used"
|
124
|
-
home_page.login.user_name.find.click "used"
|
125
|
-
|
126
|
-
#with experimaental work under progress the above will look like
|
127
|
-
home_page.login.user_name.set "used"
|
128
|
-
home_page.login.user_name.click "used"
|
129
|
-
```
|
130
|
-
You can try this in your test suite by
|
131
|
-
```
|
132
|
-
#instead of the adding the below line
|
133
|
-
require 'pageify/capybara'
|
134
|
-
|
135
|
-
# use this
|
136
|
-
require 'pageify/capybara_experimental'
|
137
|
-
```
|
138
|
-
**Note:** There will be a considrable drop in performance, with the use of this experimental feature. Once this performance drop is fixed, this could used in main stream.
|
139
|
-
|
140
97
|
## How tests gets faster with Pageify
|
141
98
|
|
142
|
-
|
143
|
-
|
144
|
-
Since we used entire hirerchy of the selector to locate an element, against specific selector, the identification of element gets really faster.
|
145
|
-
For example,
|
146
|
-
```
|
147
|
-
page.find(".user_name")
|
148
|
-
page.find(".home_page .login .user_name")
|
149
|
-
# The later would be much faster, scope for search is reduced to particular container at every level.
|
150
|
-
```
|
151
|
-
The effect gets magnified when the same is done on each and every step of, hundreds and thousand steps, tests.
|
99
|
+
Unlike other similar tools, irrespective of the depth of the hierarchy, only a single find is fired to the browser, which is considered to be the costliest call in any test execution.
|
data/lib/pageify.rb
CHANGED
@@ -5,7 +5,8 @@ module Pageify
|
|
5
5
|
def pageify(base_dir)
|
6
6
|
base_dir.chomp! '/'
|
7
7
|
all_pages = []
|
8
|
-
|
8
|
+
page_files = Dir["#{base_dir}/**/*.yml"]-Dir["#{base_dir}/**/_*.yml"]
|
9
|
+
page_files.each do |file|
|
9
10
|
to_page_objects file
|
10
11
|
end
|
11
12
|
end
|
@@ -64,3 +65,4 @@ module Pageify
|
|
64
65
|
end
|
65
66
|
end
|
66
67
|
end
|
68
|
+
include Pageify
|
data/lib/pageify/capybara.rb
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
module Assertions
|
2
|
+
extend RSpec::Matchers::DSL
|
3
|
+
|
4
|
+
matcher :match_text do |expected_text|
|
5
|
+
match_for_should { |node| node.has_text?(/^#{expected_text.escape_specials}$/) }
|
6
|
+
failure_message_for_should { |node| "expected #{expected_text} but was '#{node.text}'"}
|
7
|
+
match_for_should_not { |node| node.has_no_text?(/^#{text.escape_specials}$/) }
|
8
|
+
end
|
9
|
+
|
10
|
+
matcher :match do |expected|
|
11
|
+
match_for_should do |node|
|
12
|
+
case node.tag_name
|
13
|
+
when "select"
|
14
|
+
node.should have_selected expected
|
15
|
+
when "input"
|
16
|
+
node.value.should eq expected
|
17
|
+
when "textArea"
|
18
|
+
node.value.should eq expected
|
19
|
+
else
|
20
|
+
node.has_text?(/^#{expected.escape_specials}$/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
failure_message_for_should do |node|
|
24
|
+
actual = ""
|
25
|
+
case node.tag_name
|
26
|
+
when "select"
|
27
|
+
actual = node.text
|
28
|
+
when "input"
|
29
|
+
actual = node.value
|
30
|
+
when "textArea"
|
31
|
+
actual = node.value
|
32
|
+
else
|
33
|
+
actual = node.text
|
34
|
+
end
|
35
|
+
"expected #{expected} but was '#{actual}'"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
matcher :have_selected do |text|
|
40
|
+
match_for_should do |node|
|
41
|
+
node.find("option[selected='']").has_text?(/^#{text}/)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
matcher :have_selected_percentage do |text|
|
46
|
+
match_for_should do |node|
|
47
|
+
value = node.value
|
48
|
+
node.find("option[value='#{value}']").has_text?(/^#{text}/)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
matcher :be_disabled do
|
53
|
+
match_for_should do |node|
|
54
|
+
(node['disabled'] == "true" or node['class'].include? "disabled").should eq true
|
55
|
+
end
|
56
|
+
failure_message_for_should { |node| "expected #{node.to_s} to be disabled but was enabled"}
|
57
|
+
end
|
58
|
+
|
59
|
+
matcher :be_checked do
|
60
|
+
match_for_should do |node|
|
61
|
+
(node['checked'] == "true" or node['class'].include? "checked").should eq true
|
62
|
+
end
|
63
|
+
failure_message_for_should { |node| "expected #{node.to_s} to be checked but not checked"}
|
64
|
+
end
|
65
|
+
|
66
|
+
matcher :not_be_checked do
|
67
|
+
match_for_should do |node|
|
68
|
+
(node['checked'] == "false" or !node['class'].include? "checked").should eq true
|
69
|
+
end
|
70
|
+
failure_message_for_should { |node| "expected #{node.to_s} not to be checked but was checked"}
|
71
|
+
end
|
72
|
+
|
73
|
+
matcher :be_enabled do
|
74
|
+
match_for_should { |node| node['disabled'].should be_nil }
|
75
|
+
failure_message_for_should { |node| "expected #{node.to_s} to be enabled but was disabled"}
|
76
|
+
end
|
77
|
+
|
78
|
+
matcher :have_validation_error do
|
79
|
+
match_for_should {|node| node['class'].include? "error" }
|
80
|
+
end
|
81
|
+
|
82
|
+
matcher :exist do
|
83
|
+
match_for_should_not {|node| page.has_no_css? node.selector}
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'capybara'
|
2
|
+
module Pageify
|
3
|
+
|
4
|
+
def set_session(session_page)
|
5
|
+
@@session = session_page
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_session
|
9
|
+
@@session
|
10
|
+
end
|
11
|
+
|
12
|
+
class PageObject
|
13
|
+
|
14
|
+
def find(*args)
|
15
|
+
get_session.find(selector,*args)
|
16
|
+
end
|
17
|
+
|
18
|
+
node_methods = Capybara::Node::Element.instance_methods - Object.methods - instance_methods
|
19
|
+
(node_methods).each do |node_method|
|
20
|
+
define_method (node_method) do |*arguments|
|
21
|
+
self.find.send(node_method,*arguments)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def all(*args)
|
26
|
+
page.all(selector,*args)
|
27
|
+
end
|
28
|
+
|
29
|
+
alias :find_all :all
|
30
|
+
|
31
|
+
def first(*args)
|
32
|
+
page.first(selector,*args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_text(text)
|
36
|
+
page.find(selector,:text=>text)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "capybara/rspec"
|
2
|
+
module Pageify
|
3
|
+
module BulkActions
|
4
|
+
|
5
|
+
def should_match_fields fields
|
6
|
+
if fields.is_a?(Hash)
|
7
|
+
match_fields fields
|
8
|
+
else
|
9
|
+
fields.hashes.each do |field|
|
10
|
+
match_fields field
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def should_have_enabled fields
|
16
|
+
process_fields(fields,Proc.new{|field| get_child(field).find.should be_enabled})
|
17
|
+
end
|
18
|
+
|
19
|
+
def should_have_disabled fields
|
20
|
+
process_fields(fields,Proc.new{|field| get_child(field).find.should be_disabled})
|
21
|
+
end
|
22
|
+
|
23
|
+
def should_not_have fields
|
24
|
+
process_fields(fields,Proc.new{|field|page.should_not have_css get_selector(field)})
|
25
|
+
end
|
26
|
+
|
27
|
+
def click_on child
|
28
|
+
get_child(child).find.click
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_fields children_with_values_as_hash
|
33
|
+
children_with_values_as_hash.each do |key,value|
|
34
|
+
get_child(key).set value
|
35
|
+
end
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def match_fields field
|
41
|
+
field.each do|key,value|
|
42
|
+
element = page.find(get_selector(key))
|
43
|
+
if element.tag_name == 'input' && element[:type] == 'checkbox'
|
44
|
+
value == 'true' ? element.should(be_checked) : element.should_not(be_checked)
|
45
|
+
else
|
46
|
+
element.should match value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def process_fields fields,block
|
52
|
+
fields = fields.is_a?(Array) ? fields : fields.raw.map{|x|x[0]}
|
53
|
+
fields.each do |field|
|
54
|
+
block.call(field)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_selector children
|
59
|
+
get_child(childeren).selector
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_child children
|
63
|
+
children = children.to_s.gsub(" ","").underscore
|
64
|
+
child_object = self
|
65
|
+
children.split('.').each do |child|
|
66
|
+
method_name = child.split('(')[0]
|
67
|
+
arguments = child.split('(')[1].chomp(')').split(',') if child.include? '('
|
68
|
+
child_object = arguments.present? ? child_object.send(method_name,*[*arguments]) : child_object.send(child)
|
69
|
+
end
|
70
|
+
child_object
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/pageify/page_object.rb
CHANGED
@@ -1,40 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
module Pageify
|
2
|
+
class PageObject
|
3
|
+
attr_accessor :name,:parent,:self_selector,:intend,:full_selector
|
4
|
+
|
5
|
+
def createChild (raw_row)
|
6
|
+
child = PageObject.create(raw_row)
|
7
|
+
child.parent = self
|
8
|
+
define_singleton_method(child.name) do |*arguments|
|
9
|
+
unless arguments.eql? []
|
10
|
+
child_selector = (child.self_selector % arguments).strip_quotes.strip
|
11
|
+
else
|
12
|
+
child_selector = (child.self_selector % '').strip_quotes.strip
|
13
|
+
end
|
14
|
+
if child_selector.start_with? "&"
|
15
|
+
child.full_selector = @full_selector + child_selector.gsub(/^&/, "")
|
16
|
+
else
|
17
|
+
child.full_selector = @full_selector + " " + child_selector
|
18
|
+
end
|
19
|
+
child
|
17
20
|
end
|
18
|
-
child
|
21
|
+
return child
|
19
22
|
end
|
20
|
-
return child
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
def self.create (raw_row)
|
25
|
+
name = raw_row.lstrip.split(":").first
|
26
|
+
self_selector = raw_row.slice(raw_row.index(':')+1..-1)
|
27
|
+
intend = raw_row.lspace
|
28
|
+
PageObject.new(name,self_selector,intend)
|
29
|
+
end
|
30
|
+
|
31
|
+
def selector
|
32
|
+
@full_selector.strip
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize (name,self_selector,intend)
|
36
|
+
@name = name
|
37
|
+
@self_selector = self_selector
|
38
|
+
@intend = intend
|
39
|
+
end
|
40
|
+
|
41
|
+
def run_block (&block)
|
42
|
+
@self_before_instance_eval = eval "self", block.binding
|
43
|
+
instance_eval &block
|
44
|
+
end
|
29
45
|
|
30
|
-
def selector
|
31
|
-
@full_selector.strip
|
32
46
|
end
|
33
47
|
|
34
|
-
def
|
35
|
-
|
36
|
-
@self_selector = self_selector
|
37
|
-
@intend = intend
|
48
|
+
def on (pageObject,&block)
|
49
|
+
pageObject.run_block &block
|
38
50
|
end
|
39
51
|
|
40
52
|
end
|
data/spec/capybara_spec.rb
CHANGED
@@ -1,24 +1,40 @@
|
|
1
|
-
require 'capybara/
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Capybara do
|
1
|
+
require 'pageify/capybara/base'
|
2
|
+
describe Pageify do
|
6
3
|
before :each do
|
7
4
|
base_dir = File.expand_path File.join __FILE__, '..', 'pages'
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
11
|
-
|
5
|
+
@test_page_module = Module.new.extend(Pageify)
|
6
|
+
@test_page_module.pageify base_dir
|
7
|
+
@test_page = Class.new.send(:include, @test_page_module).new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should include node methods of capybara" do
|
11
|
+
expect(@test_page.root.methods).to include(*(Capybara::Node::Element.instance_methods - Object.methods))
|
12
12
|
end
|
13
13
|
|
14
|
-
it "should
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
expect(@
|
21
|
-
expect(@page.root.simple.find_all)
|
14
|
+
it "should redirect relevant methods to capybara elemnt method" do
|
15
|
+
session = instance_double("Capybara::Session")
|
16
|
+
capybara_element = instance_double("Capybara::Node::Element")
|
17
|
+
allow(session).to receive(:find).with(".root").and_return(capybara_element)
|
18
|
+
allow(capybara_element).to receive(:value).and_return(10)
|
19
|
+
set_session(session)
|
20
|
+
expect(@test_page.root.value).to equal(10)
|
22
21
|
end
|
23
22
|
|
23
|
+
it "should support capybara rspec matchers" do
|
24
|
+
session = instance_double("Capybara::Session")
|
25
|
+
capybara_element = instance_double("Capybara::Node::Element")
|
26
|
+
allow(session).to receive(:find).with(".root").and_return(capybara_element)
|
27
|
+
allow(capybara_element).to receive(:has_text?).with("true").and_return(true)
|
28
|
+
set_session(session)
|
29
|
+
@test_page.root.should have_text "true"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should support pageify capybara rspec matchers" do
|
33
|
+
session = instance_double("Capybara::Session")
|
34
|
+
capybara_element = instance_double("Capybara::Node::Element")
|
35
|
+
allow(session).to receive(:find).with(".root").and_return(capybara_element)
|
36
|
+
allow(capybara_element).to receive(:has_text?).with("true").and_return(true)
|
37
|
+
set_session(session)
|
38
|
+
@test_page.root.should have_text "true"
|
39
|
+
end
|
24
40
|
end
|
data/spec/page_object_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe Pageify do
|
4
2
|
before :each do
|
5
3
|
base_dir = File.expand_path File.join __FILE__, '..', 'pages'
|
@@ -59,5 +57,6 @@ describe Pageify do
|
|
59
57
|
end
|
60
58
|
|
61
59
|
it "should not scan sections as page objects" do
|
60
|
+
expect(@page.methods).not_to include(:details)
|
62
61
|
end
|
63
62
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
Bundler.setup
|
3
|
-
|
3
|
+
require 'pry'
|
4
4
|
require 'pageify'
|
5
|
+
require 'rspec/mocks'
|
5
6
|
|
6
7
|
require 'simplecov'
|
7
8
|
SimpleCov.start
|
8
|
-
SimpleCov.
|
9
|
-
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
9
|
+
#SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
10
10
|
|
11
11
|
RSpec.configure do |config|
|
12
12
|
end
|
metadata
CHANGED
@@ -1,99 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pageify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec-mocks
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- -
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: capybara
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
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'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
89
|
+
version: '0'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- -
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rubygems-tasks
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
|
-
- -
|
101
|
+
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
103
|
+
version: '0'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- -
|
108
|
+
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
110
|
+
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: simplecov
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
|
-
- -
|
115
|
+
- - ">="
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0
|
117
|
+
version: '0'
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
|
-
- -
|
122
|
+
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0
|
124
|
+
version: '0'
|
97
125
|
description: Simplify page object definition for UI tests
|
98
126
|
email:
|
99
127
|
executables: []
|
@@ -103,10 +131,11 @@ files:
|
|
103
131
|
- README.md
|
104
132
|
- lib/pageify.rb
|
105
133
|
- lib/pageify/capybara.rb
|
106
|
-
- lib/pageify/
|
134
|
+
- lib/pageify/capybara/assertions.rb
|
135
|
+
- lib/pageify/capybara/base.rb
|
136
|
+
- lib/pageify/capybara/bulk_actions.rb
|
107
137
|
- lib/pageify/page_object.rb
|
108
138
|
- lib/pageify/string.rb
|
109
|
-
- spec/capybara_experimental_spec.rb
|
110
139
|
- spec/capybara_spec.rb
|
111
140
|
- spec/page_object_spec.rb
|
112
141
|
- spec/pages/sample_page.yml
|
@@ -133,15 +162,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
162
|
version: '0'
|
134
163
|
requirements: []
|
135
164
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.4.5
|
137
166
|
signing_key:
|
138
167
|
specification_version: 4
|
139
168
|
summary: Simplify page object definition for UI tests
|
140
169
|
test_files:
|
141
|
-
- spec/spec_helper.rb
|
142
|
-
- spec/pages/section/_initial.yml
|
143
|
-
- spec/pages/section/_details.yml
|
144
|
-
- spec/pages/sample_page.yml
|
145
|
-
- spec/page_object_spec.rb
|
146
170
|
- spec/capybara_spec.rb
|
147
|
-
- spec/
|
171
|
+
- spec/page_object_spec.rb
|
172
|
+
- spec/pages/sample_page.yml
|
173
|
+
- spec/pages/section/_details.yml
|
174
|
+
- spec/pages/section/_initial.yml
|
175
|
+
- spec/spec_helper.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class PageObject
|
2
|
-
include Capybara::DSL
|
3
|
-
|
4
|
-
(Capybara::Driver::Node.public_instance_methods - Object.public_instance_methods ).each do |method|
|
5
|
-
define_method method do |*args|
|
6
|
-
page_element = page.find(self.selector)
|
7
|
-
args.empty? ? page_element.send(method) : page_element.send(method,*args)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def find_all()
|
12
|
-
page.all(self.selector)
|
13
|
-
end
|
14
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'capybara/dsl'
|
2
|
-
require "pageify/capybara_experimental"
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Capybara do
|
6
|
-
before :each do
|
7
|
-
base_dir = File.expand_path File.join __FILE__, '..', 'pages'
|
8
|
-
@pageModule = Module.new.extend(Pageify)
|
9
|
-
@pageModule.pageify base_dir
|
10
|
-
@page = Class.new.send(:include, @pageModule).new
|
11
|
-
@dummy_page = double('dummy_page')
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should select the element in the page" do
|
15
|
-
mock_selected = double('mock selected')
|
16
|
-
expect(@page.root.simple).to receive(:page).and_return(@dummy_page).twice
|
17
|
-
expect(@dummy_page).to receive(:find).with('.root .simple').and_return(mock_selected).twice
|
18
|
-
expect(mock_selected).to receive(:set).with('something')
|
19
|
-
expect(mock_selected).to receive(:click)
|
20
|
-
expect(@page.root.simple.set('something'))
|
21
|
-
expect(@page.root.simple.click)
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|