kelp 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.yardopts +6 -0
- data/Gemfile +4 -9
- data/Gemfile.lock +8 -0
- data/History.md +22 -0
- data/README.md +154 -7
- data/kelp.gemspec +1 -1
- data/lib/kelp.rb +8 -1
- data/lib/kelp/attribute.rb +31 -0
- data/lib/kelp/checkbox.rb +31 -0
- data/lib/kelp/dropdown.rb +109 -0
- data/lib/kelp/field.rb +159 -0
- data/lib/kelp/helper.rb +14 -0
- data/lib/kelp/navigation.rb +63 -0
- data/lib/kelp/scoping.rb +45 -0
- data/lib/kelp/visibility.rb +176 -0
- data/lib/kelp/xpath.rb +14 -0
- data/spec/attribute_spec.rb +56 -0
- data/spec/checkbox_spec.rb +69 -0
- data/spec/dropdown_spec.rb +176 -0
- data/spec/field_spec.rb +290 -0
- data/spec/navigation_spec.rb +89 -0
- data/spec/scoping_spec.rb +0 -0
- data/spec/{capybara/spec_helper.rb → spec_helper.rb} +9 -5
- data/spec/test_app/views/form.erb +24 -0
- data/spec/visibility_spec.rb +315 -0
- data/spec/xpath_spec.rb +0 -0
- data/step_definitions/capybara_steps.rb +132 -0
- metadata +25 -32
- data/docs/Makefile +0 -130
- data/docs/_static/custom.css +0 -9
- data/docs/conf.py +0 -217
- data/docs/development.rst +0 -27
- data/docs/future.rst +0 -9
- data/docs/index.rst +0 -33
- data/docs/make.bat +0 -155
- data/docs/testing.rst +0 -15
- data/docs/usage.rst +0 -85
- data/lib/kelp/capybara.rb +0 -2
- data/lib/kelp/capybara/capybara_steps.rb +0 -225
- data/lib/kelp/capybara/form_helper.rb +0 -131
- data/lib/kelp/capybara/web_helper.rb +0 -148
- data/spec/capybara/click_link_in_row_spec.rb +0 -24
- data/spec/capybara/dropdown_spec.rb +0 -112
- data/spec/capybara/field_should_be_empty_spec.rb +0 -44
- data/spec/capybara/field_should_contain_spec.rb +0 -143
- data/spec/capybara/fill_in_fields_spec.rb +0 -67
- data/spec/capybara/follow_spec.rb +0 -35
- data/spec/capybara/page_should_have_spec.rb +0 -48
- data/spec/capybara/page_should_not_have_spec.rb +0 -53
- data/spec/capybara/press_spec.rb +0 -33
- data/spec/capybara/should_be_disabled_spec.rb +0 -28
- data/spec/capybara/should_be_enabled_spec.rb +0 -29
- data/spec/capybara/should_not_see_spec.rb +0 -97
- data/spec/capybara/should_see_in_same_row_spec.rb +0 -41
- data/spec/capybara/should_see_spec.rb +0 -80
@@ -1,143 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe FormHelper, "#field_should_contain" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/form')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
context "field with id" do
|
10
|
-
it "has the given value" do
|
11
|
-
fill_in "first_name", :with => "Brian"
|
12
|
-
field_should_contain "first_name", "Brian"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "field with label" do
|
17
|
-
it "has the given value" do
|
18
|
-
fill_in "First name", :with => "Brian"
|
19
|
-
field_should_contain "First name", "Brian"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "fails when" do
|
25
|
-
context "field with id" do
|
26
|
-
it "is empty" do
|
27
|
-
lambda do
|
28
|
-
field_should_contain "first_name", "Brian"
|
29
|
-
end.should raise_error
|
30
|
-
end
|
31
|
-
|
32
|
-
it "has a different value" do
|
33
|
-
fill_in "first_name", :with => "Judith"
|
34
|
-
lambda do
|
35
|
-
field_should_contain "first_name", "Brian"
|
36
|
-
end.should raise_error
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "field with label" do
|
41
|
-
it "is empty" do
|
42
|
-
lambda do
|
43
|
-
field_should_contain "First name", "Brian"
|
44
|
-
end.should raise_error
|
45
|
-
end
|
46
|
-
|
47
|
-
it "has a different value" do
|
48
|
-
fill_in "First name", :with => "Judith"
|
49
|
-
lambda do
|
50
|
-
field_should_contain "First name", "Brian"
|
51
|
-
end.should raise_error
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
describe FormHelper, "#fields_should_contain" do
|
61
|
-
before(:each) do
|
62
|
-
visit('/form')
|
63
|
-
end
|
64
|
-
|
65
|
-
context "passes when" do
|
66
|
-
context "fields with ids" do
|
67
|
-
it "all match" do
|
68
|
-
fill_in "first_name", :with => "Terry"
|
69
|
-
fill_in "last_name", :with => "Jones"
|
70
|
-
fields_should_contain "first_name" => "Terry", "last_name" => "Jones"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "all match with some empty" do
|
74
|
-
fill_in "first_name", :with => "Terry"
|
75
|
-
fields_should_contain "first_name" => "Terry", "last_name" => ""
|
76
|
-
end
|
77
|
-
|
78
|
-
it "all match with some dropdowns" do
|
79
|
-
fill_in "first_name", :with => "Terry"
|
80
|
-
fill_in "last_name", :with => "Jones"
|
81
|
-
select "Average", :from => "height"
|
82
|
-
fields_should_contain "first_name" => "Terry", "last_name" => "Jones", "height" => "Average"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "fields with labels" do
|
87
|
-
it "all match" do
|
88
|
-
fill_in "First name", :with => "Terry"
|
89
|
-
fill_in "Last name", :with => "Jones"
|
90
|
-
fields_should_contain "First name" => "Terry", "Last name" => "Jones"
|
91
|
-
end
|
92
|
-
|
93
|
-
it "all match with some empty" do
|
94
|
-
fill_in "First name", :with => "Terry"
|
95
|
-
fields_should_contain "First name" => "Terry", "Last name" => ""
|
96
|
-
end
|
97
|
-
|
98
|
-
it "all match with some dropdowns" do
|
99
|
-
fill_in "First name", :with => "Terry"
|
100
|
-
fill_in "Last name", :with => "Jones"
|
101
|
-
select "Average", :from => "Height"
|
102
|
-
fields_should_contain "First name" => "Terry", "Last name" => "Jones", "Height" => "Average"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "fails when" do
|
108
|
-
context "fields with ids" do
|
109
|
-
it "are empty" do
|
110
|
-
lambda do
|
111
|
-
fields_should_contain "first_name" => "Terry", "last_name" => "Jones"
|
112
|
-
end.should raise_error
|
113
|
-
end
|
114
|
-
|
115
|
-
it "do not all match" do
|
116
|
-
fill_in "first_name", :with => "Terry"
|
117
|
-
fill_in "last_name", :with => "Gilliam"
|
118
|
-
lambda do
|
119
|
-
fields_should_contain "first_name" => "Terry", "last_name" => "Jones"
|
120
|
-
end.should raise_error
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context "fields with labels" do
|
125
|
-
it "are empty" do
|
126
|
-
lambda do
|
127
|
-
fields_should_contain "First name" => "Terry", "Last name" => "Jones"
|
128
|
-
end.should raise_error
|
129
|
-
end
|
130
|
-
|
131
|
-
it "do not all match" do
|
132
|
-
fill_in "First name", :with => "Terry"
|
133
|
-
fill_in "Last name", :with => "Gilliam"
|
134
|
-
lambda do
|
135
|
-
fields_should_contain "First name" => "Terry", "Last name" => "Jones"
|
136
|
-
end.should raise_error
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe FormHelper, "#fill_in_fields" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/form')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
it "filling a single field by id" do
|
10
|
-
fill_in_fields "first_name" => "Mel"
|
11
|
-
field_should_contain "first_name", "Mel"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "filling a single field by label" do
|
15
|
-
fill_in_fields "First name" => "Mel"
|
16
|
-
field_should_contain "First name", "Mel"
|
17
|
-
end
|
18
|
-
|
19
|
-
it "filling multiple fields by id" do
|
20
|
-
fill_in_fields \
|
21
|
-
"first_name" => "Mel",
|
22
|
-
"last_name" => "Brooks"
|
23
|
-
field_should_contain "first_name", "Mel"
|
24
|
-
field_should_contain "last_name", "Brooks"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "filling multiple fields by label" do
|
28
|
-
fill_in_fields \
|
29
|
-
"First name" => "Mel",
|
30
|
-
"Last name" => "Brooks"
|
31
|
-
field_should_contain "First name", "Mel"
|
32
|
-
field_should_contain "Last name", "Brooks"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "filling a single field by id within a scope" do
|
36
|
-
fill_in_fields_within "#person_form", "first_name" => "Mel"
|
37
|
-
field_should_contain "first_name", "Mel"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "filling multiple fields by id within a scope" do
|
41
|
-
fill_in_fields_within "#person_form",
|
42
|
-
"first_name" => "Mel",
|
43
|
-
"last_name" => "Brooks"
|
44
|
-
fields_should_contain_within "#person_form",
|
45
|
-
"first_name" => "Mel",
|
46
|
-
"last_name" => "Brooks"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "fails when" do
|
51
|
-
it "filling a nonexistent field" do
|
52
|
-
lambda do
|
53
|
-
fill_in_fields "Middle name" => "Kaminsky"
|
54
|
-
end.should raise_error
|
55
|
-
end
|
56
|
-
|
57
|
-
it "filling a field in the wrong scope" do
|
58
|
-
lambda do
|
59
|
-
fill_in_fields_within "#other_form",
|
60
|
-
"First name" => "Mel"
|
61
|
-
end.should raise_error
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe WebHelper, "#follow" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/home')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
it "link exists" do
|
10
|
-
follow "About Us"
|
11
|
-
should_see "We're a small company with an even smaller webpage"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "link is within the scope" do
|
15
|
-
follow "About Us", :within => "#links"
|
16
|
-
should_see "We're a small company with an even smaller webpage"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "fails when" do
|
21
|
-
it "link does not exist" do
|
22
|
-
lambda do
|
23
|
-
follow "About Them"
|
24
|
-
end.should raise_error
|
25
|
-
end
|
26
|
-
|
27
|
-
it "link is not within the scope" do
|
28
|
-
lambda do
|
29
|
-
follow "About Us", :within => "#invalid_scope"
|
30
|
-
end.should raise_error
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe WebHelper, "#page_should_have" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/home')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
context "String" do
|
10
|
-
it "exists" do
|
11
|
-
page_should_have "Hello world"
|
12
|
-
page_should_have "Goodbye world"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
context "Regexp" do
|
16
|
-
it "matches" do
|
17
|
-
page_should_have /(Hello|Goodbye) world/
|
18
|
-
page_should_have /\d\d\d-\d\d\d\d/
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "fails when" do
|
24
|
-
context "String" do
|
25
|
-
it "does not exist" do
|
26
|
-
lambda do
|
27
|
-
page_should_have "Wazzup world"
|
28
|
-
end.should raise_error
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "Regexp" do
|
33
|
-
it "does not match" do
|
34
|
-
lambda do
|
35
|
-
page_should_have /(Foo|Bar|Baz) world/
|
36
|
-
end.should raise_error
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it "not a String or Regexp" do
|
41
|
-
lambda do
|
42
|
-
page_should_have 123
|
43
|
-
end.should raise_error
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe WebHelper, "#page_should_not_have" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/home')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
context "String" do
|
10
|
-
it "does not exist" do
|
11
|
-
page_should_not_have "Wazzup world"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "Regexp" do
|
16
|
-
it "does not match" do
|
17
|
-
page_should_not_have /(Foo|Bar|Baz) world/
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "fails when" do
|
23
|
-
context "String" do
|
24
|
-
it "exists" do
|
25
|
-
lambda do
|
26
|
-
page_should_not_have "Hello world"
|
27
|
-
end.should raise_error
|
28
|
-
lambda do
|
29
|
-
page_should_not_have "Goodbye world"
|
30
|
-
end.should raise_error
|
31
|
-
end
|
32
|
-
end
|
33
|
-
context "Regexp" do
|
34
|
-
it "matches" do
|
35
|
-
lambda do
|
36
|
-
page_should_not_have /(Hello|Goodbye) world/
|
37
|
-
end.should raise_error
|
38
|
-
lambda do
|
39
|
-
page_should_not_have /\d\d\d-\d\d\d\d/
|
40
|
-
end.should raise_error
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "not a String or Regexp" do
|
45
|
-
lambda do
|
46
|
-
page_should_not_have 123
|
47
|
-
end.should raise_error
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
data/spec/capybara/press_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe WebHelper, "#press" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/home')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
it "button exists" do
|
10
|
-
press "Submit"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "button exists within the scope" do
|
14
|
-
press "Submit", :within => "#fields"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "fails when" do
|
19
|
-
it "button does not exist" do
|
20
|
-
lambda do
|
21
|
-
press "Poke"
|
22
|
-
end.should raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
it "button exists but is not within the scope" do
|
26
|
-
lambda do
|
27
|
-
press "Submit", :within => "#greeting"
|
28
|
-
end.should raise_error
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe WebHelper, "#should_be_disabled" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/form')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
it "element has the disabled attribute" do
|
10
|
-
should_be_disabled "readonly"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "fails when" do
|
15
|
-
it "element does not exist" do
|
16
|
-
lambda do
|
17
|
-
should_be_disabled "nonexistent"
|
18
|
-
end.should raise_error
|
19
|
-
end
|
20
|
-
|
21
|
-
it "element does not have the disabled attribute" do
|
22
|
-
lambda do
|
23
|
-
should_be_disabled "first_name"
|
24
|
-
end.should raise_error
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe WebHelper, "#should_be_enabled" do
|
4
|
-
before(:each) do
|
5
|
-
visit('/form')
|
6
|
-
end
|
7
|
-
|
8
|
-
context "passes when" do
|
9
|
-
it "element does not have the disabled attribute" do
|
10
|
-
should_be_enabled "first_name"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "fails when" do
|
15
|
-
it "element does not exist" do
|
16
|
-
lambda do
|
17
|
-
should_be_enabled "nonexistent"
|
18
|
-
end.should raise_error
|
19
|
-
end
|
20
|
-
|
21
|
-
it "element has the disabled attribute" do
|
22
|
-
lambda do
|
23
|
-
should_be_enabled "readonly"
|
24
|
-
end.should raise_error
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|