pageify 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/pageify/capybara/assertions.rb +67 -65
- data/lib/pageify/capybara/base.rb +1 -1
- data/lib/pageify/capybara/bulk_actions.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5ffb5fcbf530a6dac55cec0a1f4f077879e7d87
|
4
|
+
data.tar.gz: c40aee446129c951d11f10c26c1e8836d8cc8e94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcb8bb18f2a6a22129c2fdc18aadb63a3f7207818797227329d37213b39dcbe43242607d115a23a6163e6cdc601f56c11876a18127831742b3d39e1b5e6e9763
|
7
|
+
data.tar.gz: e8a9480bbacf053b34f939fb5f5c39ccd6a20afcac528a9c36e7eb6e3577b62a037599d8d02afcbd05eb13e90e61d8102b805be84439c52f38915fb21e499106
|
data/README.md
CHANGED
@@ -72,12 +72,14 @@ gem 'pageify'
|
|
72
72
|
require 'capybara/session'
|
73
73
|
require 'selenium-webdriver'
|
74
74
|
|
75
|
+
include Capybara::DSL
|
76
|
+
|
75
77
|
#define your capybara driver ... and
|
76
78
|
|
77
79
|
pageify("features/pages")
|
78
80
|
set_session(page)
|
79
81
|
```
|
80
|
-
Place all the page
|
82
|
+
Place all the page definitions under "features/pages"
|
81
83
|
|
82
84
|
## Splitting long page definitions
|
83
85
|
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.
|
@@ -1,85 +1,87 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module Pageify
|
2
|
+
class PageObject
|
3
|
+
extend RSpec::Matchers::DSL
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
matcher :match_text do |expected_text|
|
6
|
+
match_for_should { |node| node.has_text?(/^#{expected_text.escape_specials}$/) }
|
7
|
+
failure_message_for_should { |node| "expected #{expected_text} but was '#{node.text}'"}
|
8
|
+
match_for_should_not { |node| node.has_no_text?(/^#{text.escape_specials}$/) }
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
matcher :match do |expected|
|
12
|
+
match_for_should do |node|
|
13
|
+
case node.tag_name
|
14
|
+
when "select"
|
15
|
+
node.should have_selected expected
|
16
|
+
when "input"
|
17
|
+
node.value.should eq expected
|
18
|
+
when "textArea"
|
19
|
+
node.value.should eq expected
|
20
|
+
else
|
21
|
+
node.has_text?(/^#{expected.escape_specials}$/)
|
22
|
+
end
|
21
23
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
failure_message_for_should do |node|
|
25
|
+
actual = ""
|
26
|
+
case node.tag_name
|
27
|
+
when "select"
|
28
|
+
actual = node.text
|
29
|
+
when "input"
|
30
|
+
actual = node.value
|
31
|
+
when "textArea"
|
32
|
+
actual = node.value
|
33
|
+
else
|
34
|
+
actual = node.text
|
35
|
+
end
|
36
|
+
"expected #{expected} but was '#{actual}'"
|
34
37
|
end
|
35
|
-
"expected #{expected} but was '#{actual}'"
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
matcher :have_selected do |text|
|
41
|
+
match_for_should do |node|
|
42
|
+
node.find("option[selected='']").has_text?(/^#{text}/)
|
43
|
+
end
|
42
44
|
end
|
43
|
-
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
matcher :have_selected_percentage do |text|
|
47
|
+
match_for_should do |node|
|
48
|
+
value = node.value
|
49
|
+
node.find("option[value='#{value}']").has_text?(/^#{text}/)
|
50
|
+
end
|
49
51
|
end
|
50
|
-
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
matcher :be_disabled do
|
54
|
+
match_for_should do |node|
|
55
|
+
(node['disabled'] == "true" or node['class'].include? "disabled").should eq true
|
56
|
+
end
|
57
|
+
failure_message_for_should { |node| "expected #{node.to_s} to be disabled but was enabled"}
|
55
58
|
end
|
56
|
-
failure_message_for_should { |node| "expected #{node.to_s} to be disabled but was enabled"}
|
57
|
-
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
matcher :be_checked do
|
61
|
+
match_for_should do |node|
|
62
|
+
(node['checked'] == "true" or node['class'].include? "checked").should eq true
|
63
|
+
end
|
64
|
+
failure_message_for_should { |node| "expected #{node.to_s} to be checked but not checked"}
|
62
65
|
end
|
63
|
-
failure_message_for_should { |node| "expected #{node.to_s} to be checked but not checked"}
|
64
|
-
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
matcher :not_be_checked do
|
68
|
+
match_for_should do |node|
|
69
|
+
(node['checked'] == "false" or !node['class'].include? "checked").should eq true
|
70
|
+
end
|
71
|
+
failure_message_for_should { |node| "expected #{node.to_s} not to be checked but was checked"}
|
69
72
|
end
|
70
|
-
failure_message_for_should { |node| "expected #{node.to_s} not to be checked but was checked"}
|
71
|
-
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
matcher :be_enabled do
|
75
|
+
match_for_should { |node| node['disabled'].should be_nil }
|
76
|
+
failure_message_for_should { |node| "expected #{node.to_s} to be enabled but was disabled"}
|
77
|
+
end
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
matcher :have_validation_error do
|
80
|
+
match_for_should {|node| node['class'].include? "error" }
|
81
|
+
end
|
81
82
|
|
82
|
-
|
83
|
-
|
83
|
+
matcher :exist do
|
84
|
+
match_for_should_not {|node| page.has_no_css? node.selector}
|
85
|
+
end
|
84
86
|
end
|
85
87
|
end
|
@@ -15,7 +15,7 @@ module Pageify
|
|
15
15
|
get_session.find(selector,*args)
|
16
16
|
end
|
17
17
|
|
18
|
-
node_methods = Capybara::Node::Element.instance_methods - Object.methods - instance_methods
|
18
|
+
node_methods = Capybara::Node::Element.instance_methods - Object.methods - instance_methods - [:click_on]
|
19
19
|
(node_methods).each do |node_method|
|
20
20
|
define_method (node_method) do |*arguments|
|
21
21
|
self.find.send(node_method,*arguments)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pageify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
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: 2016-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|