kameleon 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/kameleon/dsl/act.rb +73 -22
- data/lib/kameleon/dsl/see.rb +101 -20
- data/lib/kameleon/session/capybara.rb +11 -0
- data/lib/kameleon/user/abstract.rb +78 -6
- data/spec/sample_rack_app/hey.rb +11 -4
- data/spec/spec_helper.rb +12 -0
- data/spec/support/deferred_garbage_collection.rb +20 -0
- data/spec/unit/act/click_spec.rb +52 -0
- data/spec/unit/act/fill_in/attach_file_spec.rb +27 -0
- data/spec/unit/act/fill_in/checkbox_spec.rb +87 -0
- data/spec/unit/act/fill_in/date_ranges_spec.rb +24 -0
- data/spec/unit/act/fill_in/multiple_select_spec.rb +42 -0
- data/spec/unit/act/fill_in/radio_button_spec.rb +35 -0
- data/spec/unit/act/fill_in/select_spec.rb +35 -0
- data/spec/unit/act/fill_in/text_area_spec.rb +52 -0
- data/spec/unit/act/fill_in/text_input_spec.rb +52 -0
- data/spec/unit/act/on_hover_spec.rb +34 -0
- data/spec/unit/dsl/not_see/form_elements/fields/empty_spec.rb +38 -0
- data/spec/unit/dsl/not_see/form_elements/fields/readonly_spec.rb +38 -0
- data/spec/unit/dsl/not_see/form_elements/fields_spec.rb +24 -0
- data/spec/unit/dsl/not_see/form_elements/textareas_spec.rb +25 -0
- data/spec/unit/dsl/not_see/form_elements/texts_spec.rb +26 -0
- data/spec/unit/dsl/not_see/in_scopes_spec.rb +61 -0
- data/spec/unit/dsl/not_see/special_elements/buttons_spec.rb +24 -0
- data/spec/unit/dsl/not_see/special_elements/error_message_for_spec.rb +24 -0
- data/spec/unit/dsl/not_see/special_elements/images_spec.rb +24 -0
- data/spec/unit/dsl/not_see/special_elements/links_spec.rb +46 -0
- data/spec/unit/dsl/not_see/special_elements/ordered_texts_spec.rb +21 -0
- data/spec/unit/dsl/not_see/special_selectors_spec.rb +35 -0
- data/spec/unit/dsl/not_see/texts_spec.rb +24 -0
- data/spec/unit/dsl/see/counted_elements_spec.rb +26 -0
- data/spec/unit/dsl/see/form_elements/checkboxes_spec.rb +45 -0
- data/spec/unit/dsl/see/form_elements/fields/disabled_spec.rb +30 -0
- data/spec/unit/dsl/see/form_elements/fields/empty_spec.rb +28 -0
- data/spec/unit/dsl/see/form_elements/fields/readonly_spec.rb +38 -0
- data/spec/unit/dsl/see/form_elements/fields_spec.rb +28 -0
- data/spec/unit/dsl/see/form_elements/multiple_selects_spec.rb +47 -0
- data/spec/unit/dsl/see/form_elements/radio_buttons_spec.rb +35 -0
- data/spec/unit/dsl/see/form_elements/selects_spec.rb +40 -0
- data/spec/unit/dsl/see/form_elements/textareas_spec.rb +29 -0
- data/spec/unit/dsl/see/form_elements/texts_spec.rb +29 -0
- data/spec/unit/dsl/see/in_scopes_spec.rb +83 -0
- data/spec/unit/dsl/see/special_elements/buttons_spec.rb +28 -0
- data/spec/unit/dsl/see/special_elements/error_message_for_spec.rb +24 -0
- data/spec/unit/dsl/see/special_elements/images_spec.rb +28 -0
- data/spec/unit/dsl/see/special_elements/links_spec.rb +55 -0
- data/spec/unit/dsl/see/special_elements/ordered_texts_spec.rb +21 -0
- data/spec/unit/dsl/see/special_selectors_spec.rb +53 -0
- data/spec/unit/dsl/see/texts_spec.rb +24 -0
- data/spec/unit/guest_spec.rb +24 -45
- data/spec/unit/user_base_spec.rb +1 -1
- metadata +78 -13
- data/spec/unit/act_spec.rb +0 -99
- data/spec/unit/see_spec.rb +0 -242
data/spec/unit/act_spec.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Act" do
|
4
|
-
include ::Capybara::DSL
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
Capybara.app = Hey.new(%q{
|
8
|
-
<h1>This is simple app</h1>
|
9
|
-
<a href="next_page.html">Load Next Page</a>
|
10
|
-
<form>
|
11
|
-
<label for="xlInput">X-Large input</label>
|
12
|
-
<input type="text" size="30" name="xlInput" id="xlInput" value="this is great value" class="xlarge">
|
13
|
-
|
14
|
-
|
15
|
-
<label for="prependedInput2">
|
16
|
-
Prepended Checkbox
|
17
|
-
<input type="checkbox" size="16" name="prependedInput2" id="prependedInput2" class="mini">
|
18
|
-
</label>
|
19
|
-
<label class="add-on"></label>
|
20
|
-
|
21
|
-
|
22
|
-
<label for="prependedInput3">Awesome Checkbox</label>
|
23
|
-
<input type="checkbox" size="16" name="prependedInput3" id="prependedInput3" class="mini">
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
<label for="appendedInput">Appended checkbox</label>
|
29
|
-
<label class="add-on active"><input type="checkbox" value="" id="appendedInput" name="">
|
30
|
-
|
31
|
-
<label for="some_checkbox_one">Some checkbox</label>
|
32
|
-
<input type="checkbox" checked="checked" value="" id="some_checkbox_one" name="">
|
33
|
-
<label for="some_checkbox_two">Another checkbox</label>
|
34
|
-
<input type="checkbox" checked="checked" value="" id="some_checkbox_two" name="">
|
35
|
-
<label for="some_checkbox_three">And One More Checkbox</label>
|
36
|
-
<input type="checkbox" checked="checked" value="" id="some_checkbox_three" name="">
|
37
|
-
|
38
|
-
<input type="submit" value="Save changes" class="btn primary">
|
39
|
-
|
40
|
-
<button class="btn" type="reset">Cancel</button>
|
41
|
-
|
42
|
-
</form>
|
43
|
-
|
44
|
-
})
|
45
|
-
@user = Kameleon::User::Guest.new(self)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "clicks on link" do
|
49
|
-
@user.click "Load Next Page"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "clicks on buttons" do
|
53
|
-
@user.click "Save changes"
|
54
|
-
end
|
55
|
-
|
56
|
-
it "allow to chain many clicks - with success" do
|
57
|
-
@user.click "Save changes", "Load Next Page", "Save changes"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "allow to chain many clicks - raise error, if at least one of them not found" do
|
61
|
-
lambda {
|
62
|
-
@user.click "Save changes", "Load Next Page", "Submit", "Load Next Page"
|
63
|
-
}.should raise_error(Capybara::ElementNotFound)
|
64
|
-
end
|
65
|
-
|
66
|
-
context "fill in form" do
|
67
|
-
it "set field value by id" do
|
68
|
-
@user.not_see 'WoW' => 'xlInput'
|
69
|
-
@user.fill_in 'WoW' => 'xlInput'
|
70
|
-
@user.see 'WoW' => 'xlInput'
|
71
|
-
end
|
72
|
-
|
73
|
-
it "set field value by Label title" do
|
74
|
-
@user.not_see 'WoW' => 'xlInput'
|
75
|
-
@user.fill_in 'WoW' => 'X-Large input'
|
76
|
-
@user.see 'WoW' => 'xlInput'
|
77
|
-
end
|
78
|
-
|
79
|
-
context "check box" do
|
80
|
-
it "selecting" do
|
81
|
-
@user.will do
|
82
|
-
see :unchecked => ["Prepended Checkbox", "Appended checkbox", "Awesome Checkbox"]
|
83
|
-
fill_in :check => ["Appended checkbox", "Awesome Checkbox"]
|
84
|
-
see :checked => ["Appended checkbox", "Awesome Checkbox"],
|
85
|
-
:unchecked => "Prepended Checkbox"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it "unselecting" do
|
90
|
-
@user.will do
|
91
|
-
see :checked => ["Some checkbox", "Another checkbox", "And One More Checkbox"]
|
92
|
-
fill_in :uncheck => ["And One More Checkbox", "Some checkbox"]
|
93
|
-
see :unchecked => ["And One More Checkbox", "Some checkbox"],
|
94
|
-
:checked => "Another checkbox"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
data/spec/unit/see_spec.rb
DELETED
@@ -1,242 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "See" do
|
4
|
-
include ::Capybara::DSL
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
Capybara.app = Hey.new(%q{
|
8
|
-
<h1>This is simple app</h1>
|
9
|
-
<p>and there is many lines</p>
|
10
|
-
<p>i that app</p>
|
11
|
-
|
12
|
-
<a href="/i-want/to">What you want</a>
|
13
|
-
|
14
|
-
<a href="/what-i/need">What I need</a>
|
15
|
-
|
16
|
-
<form>
|
17
|
-
<fieldset>
|
18
|
-
<legend>Example form legend</legend>
|
19
|
-
<label for="xlInput">X-Large input</label>
|
20
|
-
<input type="text" size="30" name="xlInput" id="xlInput" value="this is great value" class="xlarge">
|
21
|
-
<input type="text" size="30" name="xlInput" id="xlInput_two" value="" class="xlarge">
|
22
|
-
<input type="text" size="30" name="xlInput" id="xlInput_three" value="" class="xlarge">
|
23
|
-
|
24
|
-
<label for="normalSelect">Select</label>
|
25
|
-
<select id="normalSelect" name="normalSelect">
|
26
|
-
<option>1</option>
|
27
|
-
<option>2</option>
|
28
|
-
<option>3</option>
|
29
|
-
<option>4</option>
|
30
|
-
<option>5</option>
|
31
|
-
</select>
|
32
|
-
|
33
|
-
<label for="mediumSelect">Select</label>
|
34
|
-
<select id="mediumSelect" name="mediumSelect" class="medium">
|
35
|
-
<option>1</option>
|
36
|
-
<option>2</option>
|
37
|
-
<option>3</option>
|
38
|
-
<option>4</option>
|
39
|
-
<option>5</option>
|
40
|
-
</select>
|
41
|
-
<label for="multiSelect">Multiple select</label>
|
42
|
-
<select id="multiSelect" name="multiSelect" multiple="multiple" size="5" class="medium">
|
43
|
-
<option>1</option>
|
44
|
-
<option>2</option>
|
45
|
-
<option>3</option>
|
46
|
-
<option>4</option>
|
47
|
-
<option>5</option>
|
48
|
-
</select>
|
49
|
-
|
50
|
-
<label for="disabledInput">Disabled input</label>
|
51
|
-
<input type="text" disabled="" placeholder="Disabled input here carry on." size="30" name="disabledInput" id="disabledInput" class="xlarge disabled">
|
52
|
-
|
53
|
-
<label for="disabledInput">Disabled textarea</label>
|
54
|
-
<textarea disabled="" rows="3" id="textarea" name="textarea" class="xxlarge"></textarea>
|
55
|
-
</fieldset>
|
56
|
-
|
57
|
-
<fieldset>
|
58
|
-
<label for="prependedInput">Prepended text</label>
|
59
|
-
<input type="text" size="16" name="prependedInput" id="prependedInput" class="medium">
|
60
|
-
|
61
|
-
<label for="prependedInput2">Prepended checkbox</label>
|
62
|
-
<label class="add-on"><input type="checkbox" value="" id="" name=""></label>
|
63
|
-
<input type="text" size="16" name="prependedInput2" id="prependedInput2" class="mini">
|
64
|
-
|
65
|
-
<label for="appendedInput">Appended checkbox</label>
|
66
|
-
<input type="text" size="16" name="appendedInput" id="appendedInput" checked="checked" class="mini">
|
67
|
-
<label class="add-on active"><input type="checkbox" checked="checked" value="" id="" name=""></label>
|
68
|
-
|
69
|
-
<label for="fileInput">File input</label>
|
70
|
-
<input type="file" name="fileInput" id="fileInput" class="input-file">
|
71
|
-
</fieldset>
|
72
|
-
|
73
|
-
<fieldset>
|
74
|
-
<label id="optionsCheckboxes">List of options</label>
|
75
|
-
|
76
|
-
<label>
|
77
|
-
<input type="checkbox" value="option1" name="optionsCheckboxes_one">
|
78
|
-
<span>Option one is this and that—be sure to include why it's great</span>
|
79
|
-
</label>
|
80
|
-
|
81
|
-
<label>
|
82
|
-
<input type="checkbox" value="option2" checked="checked" name="optionsCheckboxes_two">
|
83
|
-
<span>Option two can also be checked and included in form results</span>
|
84
|
-
</label>
|
85
|
-
|
86
|
-
<label>
|
87
|
-
<input type="checkbox" value="option2" name="optionsCheckboxes">
|
88
|
-
<span>Option three can—yes, you guessed it—also be checked and included in form results. Let's make it super long so that everyone can see how it wraps, too.</span>
|
89
|
-
</label>
|
90
|
-
|
91
|
-
<label class="disabled">
|
92
|
-
<input type="checkbox" disabled="" value="option2" name="optionsCheckboxes">
|
93
|
-
<span>Option four cannot be checked as it is disabled.</span>
|
94
|
-
</label>
|
95
|
-
|
96
|
-
<label>Date range</label>
|
97
|
-
<div class="inline-inputs">
|
98
|
-
<input type="text" value="May 1, 2011" class="small">
|
99
|
-
<input type="text" value="12:00am" class="mini">
|
100
|
-
to
|
101
|
-
<input type="text" value="May 8, 2011" class="small">
|
102
|
-
<input type="text" value="11:59pm" class="mini">
|
103
|
-
<span class="help-block">All times are shown as Pacific Standard Time (GMT -08:00).</span>
|
104
|
-
</div>
|
105
|
-
|
106
|
-
<label for="textarea">Textarea</label>
|
107
|
-
<textarea rows="3" name="textarea2" id="textarea2" class="xxlarge"></textarea>
|
108
|
-
|
109
|
-
<label id="optionsRadio">List of options</label>
|
110
|
-
<div class="input">
|
111
|
-
<label>
|
112
|
-
<input type="radio" value="option1" name="optionsRadios" checked="">
|
113
|
-
<span>Option one is this and that—be sure to include why it's great</span>
|
114
|
-
</label>
|
115
|
-
|
116
|
-
<label>
|
117
|
-
<input type="radio" value="option2" name="optionsRadios">
|
118
|
-
<span>Option two can is something else and selecting it will deselect options 1</span>
|
119
|
-
</label>
|
120
|
-
</div>
|
121
|
-
|
122
|
-
<input type="submit" value="Save changes" class="btn primary"> <button class="btn" type="reset">Cancel</button>
|
123
|
-
|
124
|
-
</fieldset>
|
125
|
-
</form>
|
126
|
-
})
|
127
|
-
@user = Kameleon::User::Guest.new(self)
|
128
|
-
end
|
129
|
-
|
130
|
-
context "and can judge that there is no text on site" do
|
131
|
-
it "with single param" do
|
132
|
-
@user.not_see "cool rails app"
|
133
|
-
end
|
134
|
-
|
135
|
-
it "with multiple params at once" do
|
136
|
-
@user.not_see "sinatra app",
|
137
|
-
"padrino app"
|
138
|
-
end
|
139
|
-
|
140
|
-
it "it will fail if at least one text is visibile" do
|
141
|
-
lambda {
|
142
|
-
@user.not_see "sinatra app",
|
143
|
-
"This is simple app"
|
144
|
-
}.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context "text in site" do
|
149
|
-
it "when single parameter" do
|
150
|
-
@user.see "This is simple app"
|
151
|
-
end
|
152
|
-
|
153
|
-
it "when many strings" do
|
154
|
-
@user.see "This is simple app",
|
155
|
-
"and there is many lines",
|
156
|
-
"i that app"
|
157
|
-
end
|
158
|
-
|
159
|
-
it "when many strings should fail if there is at least one missing" do
|
160
|
-
lambda {
|
161
|
-
@user.see("sinatra app",
|
162
|
-
"and there is many lines",
|
163
|
-
"i that app")
|
164
|
-
}.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
165
|
-
end
|
166
|
-
|
167
|
-
context "that are value for form" do
|
168
|
-
it "by input id" do
|
169
|
-
@user.see 'this is great value' => 'xlInput'
|
170
|
-
end
|
171
|
-
|
172
|
-
it "by input label" do
|
173
|
-
@user.see 'this is great value' => 'X-Large input'
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context "that are not value for form" do
|
178
|
-
it "by input id" do
|
179
|
-
@user.not_see 'this is not such a great value' => 'xlInput'
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context "values for checkbox'es" do
|
184
|
-
context "veirfy status for single checkbox'es'" do
|
185
|
-
context "is checked" do
|
186
|
-
it "by Label" do
|
187
|
-
@user.see :checked => "Appended checkbox"
|
188
|
-
end
|
189
|
-
it "by dom id" do
|
190
|
-
@user.see :checked => "appendedInput"
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context "is unchecked" do
|
195
|
-
it "by Label" do
|
196
|
-
@user.see :unchecked => "Prepended checkbox"
|
197
|
-
end
|
198
|
-
it "by dom id" do
|
199
|
-
@user.see :unchecked => "prependedInput"
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
context "should understand status for multiple checkbox'es'" do
|
205
|
-
it "checked" do
|
206
|
-
@user.see :checked => ["Appended checkbox", "appendedInput", "optionsCheckboxes_two"]
|
207
|
-
end
|
208
|
-
it "when unchecked" do
|
209
|
-
@user.see :unchecked => ["Prepended checkbox", "optionsCheckboxes", "optionsCheckboxes_one"]
|
210
|
-
end
|
211
|
-
|
212
|
-
it "when not all are checked" do
|
213
|
-
lambda {
|
214
|
-
@user.see :checked => ["Appended checkbox", "appendedInput", "optionsCheckboxes_one"]
|
215
|
-
}.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
context "see empty fields should validate many at once" do
|
221
|
-
it "and fails when at least one input are not empty" do
|
222
|
-
lambda {
|
223
|
-
@user.see :empty => ["xlInput_two", "X-Large input"]
|
224
|
-
}.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
225
|
-
end
|
226
|
-
|
227
|
-
it "succeed when all fields are empty" do
|
228
|
-
@user.see :empty => ["xlInput_two", "xlInput_three"]
|
229
|
-
end
|
230
|
-
end
|
231
|
-
context "I can recognize links" do
|
232
|
-
it "see when they are placed" do
|
233
|
-
@user.see :link => {'What you want' => '/i-want/to'}
|
234
|
-
end
|
235
|
-
it "throw error if not found" do
|
236
|
-
lambda {
|
237
|
-
@user.see :link => {'What I need' => '/no-way'}
|
238
|
-
}.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|