pageify 0.1.2 → 0.2.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 +46 -0
- data/lib/pageify.rb +5 -7
- data/lib/pageify/element.rb +8 -3
- data/lib/pageify/string.rb +4 -4
- data/spec/pages/sample.page +11 -0
- data/spec/sample_spec.rb +48 -0
- data/spec/spec_helper.rb +7 -0
- metadata +44 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d21aa14b7f880ca329b8ca5062400711cd9b414
|
4
|
+
data.tar.gz: f617f59a06c6f7dbf308d8c7276d2a0c2a9adc59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e5c75dfb031ef3dce726ed4bcfe35eb96ca75c300b59a381ba41c684f8fc675fb6f87de079d2b239b2b7a0162634df26594be30da54c4403a8d740fb85df1ac
|
7
|
+
data.tar.gz: 3a7cb6709aa29dc03edcce762f5d724054abc7cb3d86f3b06b475af385aee3a092b980fa4abc98cf0f70d987a431aea9c66e5a0149f6a6ef54a5fa121df1bc76
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#Pageify
|
2
|
+
|
3
|
+
Lets you define page objects for your UI tests, written in Ruby.
|
4
|
+
|
5
|
+
##Example
|
6
|
+
|
7
|
+
Page definition looks like this
|
8
|
+
```yaml
|
9
|
+
home_page: ".home"
|
10
|
+
login: "div.login"
|
11
|
+
user_name: "input.user"
|
12
|
+
password: "input.password"
|
13
|
+
submit: "[name='submit']"
|
14
|
+
profile_name: "a.profile"
|
15
|
+
settings: "a.settings"
|
16
|
+
sign_up: "a.sign_up"
|
17
|
+
```
|
18
|
+
Test steps looks like this
|
19
|
+
```ruby
|
20
|
+
fill_in home_page.login.user_name :with => "hi"
|
21
|
+
fill_in home_page.login.password :with => "bla"
|
22
|
+
click_on home_page.login.submit
|
23
|
+
|
24
|
+
home_page.profile_name.should match_text "hi"
|
25
|
+
hoem_pafe.settings.should be_visible
|
26
|
+
```
|
27
|
+
|
28
|
+
## Key benefits
|
29
|
+
|
30
|
+
- Your test will be more **readable**.
|
31
|
+
- **Eliminates duplicate** definition of selectors across test.
|
32
|
+
- **Easy Maintenance**.
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
In your project Gemfile add
|
36
|
+
```ruby
|
37
|
+
gem 'pageify'
|
38
|
+
```
|
39
|
+
###Cucumber
|
40
|
+
In env.rb
|
41
|
+
```ruby
|
42
|
+
include Pageify
|
43
|
+
pageify("features/pages")
|
44
|
+
```
|
45
|
+
Place all the page defenitions under "features/pages"
|
46
|
+
|
data/lib/pageify.rb
CHANGED
@@ -5,17 +5,15 @@ module Pageify
|
|
5
5
|
def pageify(base_dir)
|
6
6
|
base_dir.chomp! '/'
|
7
7
|
all_pages = []
|
8
|
-
Dir["#{base_dir}
|
9
|
-
|
10
|
-
to_page_objects file
|
11
|
-
end
|
8
|
+
Dir["#{base_dir}/**/*.page"].each do |file|
|
9
|
+
to_page_objects file
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
13
|
def createElement(raw_row)
|
16
14
|
element = PageObject.create(raw_row)
|
17
|
-
define_method(element.name) do
|
18
|
-
$selector = element.selector
|
15
|
+
define_method(element.name) do
|
16
|
+
$selector = element.selector.strip_quotes.strip
|
19
17
|
element
|
20
18
|
end
|
21
19
|
element
|
@@ -30,7 +28,7 @@ module Pageify
|
|
30
28
|
until rawArray.empty? do
|
31
29
|
thisElement = rawArray.first
|
32
30
|
nextElement = rawArray[1]
|
33
|
-
until parent.last.intend < thisElement.lspace do
|
31
|
+
until parent.last.intend < thisElement.lspace do
|
34
32
|
parent.pop
|
35
33
|
end
|
36
34
|
element = parent.last.createChild(thisElement)
|
data/lib/pageify/element.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
class PageObject
|
1
|
+
class PageObject
|
2
2
|
attr_accessor :name,:parent,:selector,:intend
|
3
3
|
|
4
4
|
def createChild (raw_row)
|
5
5
|
child = PageObject.create(raw_row)
|
6
6
|
child.parent = self
|
7
7
|
define_singleton_method(child.name) do |*arguments|
|
8
|
-
|
8
|
+
child_selector = (child.selector % arguments).strip_quotes.strip
|
9
|
+
if child_selector.start_with? "&"
|
10
|
+
$selector += child_selector.gsub(/^&/, "")
|
11
|
+
else
|
12
|
+
$selector += " " + child_selector
|
13
|
+
end
|
9
14
|
child
|
10
15
|
end
|
11
16
|
return child
|
@@ -19,7 +24,7 @@ class PageObject
|
|
19
24
|
end
|
20
25
|
|
21
26
|
def p
|
22
|
-
$selector.
|
27
|
+
$selector.strip
|
23
28
|
end
|
24
29
|
|
25
30
|
def initialize (name,selector,intend)
|
data/lib/pageify/string.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
root: ".root"
|
2
|
+
simple: ".simple"
|
3
|
+
complex: ".complex"
|
4
|
+
nested: ".nested"
|
5
|
+
whitespace: " .whitespace "
|
6
|
+
whitespace_nested: " .whitespace_nested "
|
7
|
+
arg: ".arg:nth-of-type(%s)"
|
8
|
+
arg_nested: ".arg_nested"
|
9
|
+
nth: "&:nth-of-type(%d)"
|
10
|
+
nth_variant: "&.nth_variant"
|
11
|
+
nth_nested: ".nth_nested"
|
data/spec/sample_spec.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pageify do
|
4
|
+
before :each do
|
5
|
+
base_dir = File.expand_path File.join __FILE__, '..', 'pages'
|
6
|
+
@pageModule = Module.new.extend(Pageify)
|
7
|
+
@pageModule.pageify base_dir
|
8
|
+
@page = Class.new.send(:include, @pageModule).new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have root" do
|
12
|
+
@page.root.p.should == ".root"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have simple page" do
|
16
|
+
@page.root.simple.p.should == ".root .simple"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have nested pages" do
|
20
|
+
@page.root.complex.p.should == ".root .complex"
|
21
|
+
@page.root.complex.nested.p.should == ".root .complex .nested"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should check arguments" do
|
25
|
+
@page.root.complex.arg(1).p.should == ".root .complex .arg:nth-of-type(1)"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should check pages nested inside arguments" do
|
29
|
+
@page.root.complex.arg(1).arg_nested.p.should == ".root .complex .arg:nth-of-type(1) .arg_nested"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "does not support multiple pages at the same time" do
|
33
|
+
p1 = @page.root.simple
|
34
|
+
p2 = @page.root.complex.nested
|
35
|
+
|
36
|
+
p1.p.should == ".root .complex .nested"
|
37
|
+
p2.p.should == ".root .complex .nested"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should normalize whitespace" do
|
41
|
+
@page.root.complex.whitespace.p.should == ".root .complex .whitespace"
|
42
|
+
@page.root.complex.whitespace.whitespace_nested.p.should == ".root .complex .whitespace .whitespace_nested"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "& should add to previous selector" do
|
46
|
+
@page.root.complex.nth(1).nth_variant.nth_nested.p.should == ".root .complex:nth-of-type(1).nth_variant .nth_nested"
|
47
|
+
end
|
48
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,24 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pageify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
12
|
-
dependencies:
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.10.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.10.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: Simplify page object definition for UI tests
|
14
42
|
email: anandhadeepak@gmail.com
|
15
43
|
executables: []
|
16
44
|
extensions: []
|
17
45
|
extra_rdoc_files: []
|
18
46
|
files:
|
47
|
+
- README.md
|
48
|
+
- lib/pageify.rb
|
19
49
|
- lib/pageify/element.rb
|
20
50
|
- lib/pageify/string.rb
|
21
|
-
-
|
51
|
+
- spec/pages/sample.page
|
52
|
+
- spec/sample_spec.rb
|
53
|
+
- spec/spec_helper.rb
|
22
54
|
homepage: https://github.com/paramadeep/pageify
|
23
55
|
licenses:
|
24
56
|
- MIT
|
@@ -29,18 +61,21 @@ require_paths:
|
|
29
61
|
- lib
|
30
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
31
63
|
requirements:
|
32
|
-
- -
|
64
|
+
- - ">="
|
33
65
|
- !ruby/object:Gem::Version
|
34
66
|
version: '0'
|
35
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
68
|
requirements:
|
37
|
-
- -
|
69
|
+
- - ">="
|
38
70
|
- !ruby/object:Gem::Version
|
39
71
|
version: '0'
|
40
72
|
requirements: []
|
41
73
|
rubyforge_project:
|
42
|
-
rubygems_version: 2.
|
74
|
+
rubygems_version: 2.2.2
|
43
75
|
signing_key:
|
44
76
|
specification_version: 4
|
45
|
-
summary:
|
46
|
-
test_files:
|
77
|
+
summary: Simplify page object definition for UI tests
|
78
|
+
test_files:
|
79
|
+
- spec/pages/sample.page
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
- spec/sample_spec.rb
|