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
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#click' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('click.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should clicks on links and buttons at once' do
|
10
|
+
@user.click 'Save changes', 'Load Next Page', 'Save changes'
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when buttons' do
|
14
|
+
it 'should click on button' do
|
15
|
+
@user.click 'Save changes'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should click on cancel form' do
|
19
|
+
@user.click 'Cancel'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should click with dismissing pop-up' do
|
23
|
+
@user.click :and_dismiss => 'Confirm button'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should click with accepting pop-up' do
|
27
|
+
@user.click :and_accept => 'Confirm button'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when links' do
|
32
|
+
it 'should click on link' do
|
33
|
+
@user.click 'Load Next Page'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should click with dismissing pop-up' do
|
37
|
+
@user.click :and_dismiss => 'Confirm link'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should click with accepting pop-up' do
|
41
|
+
@user.click :and_accept => 'Confirm link'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when at least one does not exist' do
|
46
|
+
it 'should raise error' do
|
47
|
+
expect do
|
48
|
+
@user.click 'Save changes', 'Load Next Page', 'Submit', 'Load Next Page'
|
49
|
+
end.to raise_error(Capybara::ElementNotFound)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'fill in attach file' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should attach file' do
|
10
|
+
@user.will do
|
11
|
+
see :empty => 'File input'
|
12
|
+
full_path = "#{File.expand_path __FILE__ + '/../../../../dummy'}/click.html"
|
13
|
+
fill_in :attach => { full_path => 'Active File input' }
|
14
|
+
see full_path => 'Active File input'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when disabled' do
|
19
|
+
it 'should not attach file' do
|
20
|
+
@user.will do
|
21
|
+
see :empty => 'Disable File input'
|
22
|
+
fill_in :attach => { 'path' => 'Disable File input' }
|
23
|
+
see :empty => 'Disable File input'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#ecoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'fill in checkbox' do
|
5
|
+
before do
|
6
|
+
Capybara.app = Hey.new('form_elements.html')
|
7
|
+
@user = Kameleon::User::Guest.new(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should check by id' do
|
11
|
+
@user.will do
|
12
|
+
see :unchecked => 'first_unchecked_checkbox'
|
13
|
+
fill_in :check => 'first_unchecked_checkbox'
|
14
|
+
see :checked => 'first_unchecked_checkbox'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should check by label' do
|
19
|
+
@user.will do
|
20
|
+
see :unchecked => 'Sample unchecked checkbox'
|
21
|
+
fill_in :check => 'Sample unchecked checkbox'
|
22
|
+
see :checked => 'Sample unchecked checkbox'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should uncheck by id' do
|
27
|
+
@user.will do
|
28
|
+
see :checked => 'first_checked_checkbox'
|
29
|
+
fill_in :uncheck => 'first_checked_checkbox'
|
30
|
+
see :unchecked => 'first_checked_checkbox'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should uncheck by label' do
|
35
|
+
@user.will do
|
36
|
+
see :checked => 'Sample checked checkbox'
|
37
|
+
fill_in :uncheck => 'Sample checked checkbox'
|
38
|
+
see :unchecked => 'Sample checked checkbox'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when is disabled' do
|
43
|
+
it 'should not do anything with disable checkbox' do
|
44
|
+
@user.will do
|
45
|
+
see :unchecked => 'Option four cannot be checked as it is disabled.'
|
46
|
+
fill_in :check => 'Option four cannot be checked as it is disabled.'
|
47
|
+
see :unchecked => 'Option four cannot be checked as it is disabled.'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when does not exist' do
|
53
|
+
it 'should raise error' do
|
54
|
+
expect do
|
55
|
+
@user.fill_in :check => 'Bad checkbox'
|
56
|
+
end.should raise_error(Capybara::ElementNotFound)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'many checkboxes' do
|
61
|
+
it 'should check many checkboxes' do
|
62
|
+
checkboxes = ['Sample unchecked checkbox', "Option one is this and that—be sure to include why it's great"]
|
63
|
+
@user.will do
|
64
|
+
see :unchecked => checkboxes
|
65
|
+
fill_in :check => checkboxes
|
66
|
+
see :checked => checkboxes
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should uncheck many checkboxes' do
|
71
|
+
checkboxes = ['Sample checked checkbox', 'Option two can also be checked and included in form results']
|
72
|
+
@user.will do
|
73
|
+
see :checked => checkboxes
|
74
|
+
fill_in :uncheck => checkboxes
|
75
|
+
see :unchecked => checkboxes
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'when at least chekbox does not exist' do
|
80
|
+
it 'should raise error' do
|
81
|
+
expect do
|
82
|
+
@user.fill_in :check => ['Sample unchecked checkbox', 'Bad checkbox']
|
83
|
+
end.to raise_error(Capybara::ElementNotFound)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'fill in date ranges' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should fill by label' do
|
10
|
+
pending 'does not implemented in kameleon dsl'
|
11
|
+
@user.will do
|
12
|
+
start_time = Time.now
|
13
|
+
end_time = Time.now
|
14
|
+
see :empty => 'Data ranges'
|
15
|
+
fill_in :data_ranges => { :start_date => start_time, :end_date => end_time }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should fill by id'
|
20
|
+
|
21
|
+
context 'data ranges fields are disabled' do
|
22
|
+
it 'should not fill'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'fill in multiple select' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should select by id' do
|
10
|
+
@user.will do
|
11
|
+
see :unselected => { '2' => 'multiSelect' }
|
12
|
+
fill_in :select => { '2' => 'multiSelect' }
|
13
|
+
see :selected => { '2' => 'multiSelect' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should select by label' do
|
18
|
+
@user.will do
|
19
|
+
see :unselected => { '1' => 'Multiple select' }
|
20
|
+
fill_in :select => { '1' => 'Multiple select' }
|
21
|
+
see :selected => { '1' => 'Multiple select' }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should select multiple values' do
|
26
|
+
@user.will do
|
27
|
+
see :unselected => { '1' => 'Multiple select', '2' => 'Multiple select' }
|
28
|
+
fill_in :select => { '1' => 'Multiple select', '2' => 'Multiple select' }
|
29
|
+
see :selected => { '1' => 'Multiple select', '2' => 'Multiple select' }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when is disabled' do
|
34
|
+
it 'should not select values' do
|
35
|
+
@user.will do
|
36
|
+
see :unselected => { 'first' => 'Disabled Multiple select' }
|
37
|
+
fill_in :select => { 'first' => 'Disabled Multiple select' }
|
38
|
+
see :unselected => { 'first' => 'Disabled Multiple select' }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'fill in radio button' do
|
5
|
+
before do
|
6
|
+
Capybara.app = Hey.new('form_elements.html')
|
7
|
+
@user = Kameleon::User::Guest.new(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should select by label' do
|
11
|
+
@user.will do
|
12
|
+
see :unchecked => "Option one is this and that—be sure to include why it's great"
|
13
|
+
fill_in :check => "Option one is this and that—be sure to include why it's great"
|
14
|
+
see :checked => "Option one is this and that—be sure to include why it's great"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when is disabled' do
|
19
|
+
it 'should not select' do
|
20
|
+
@user.will do
|
21
|
+
see :unchecked => 'Option four - disabled'
|
22
|
+
fill_in :check => 'Option four - disabled'
|
23
|
+
see :unchecked => 'Option four - disabled'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when does not exist' do
|
29
|
+
it 'should raise error' do
|
30
|
+
expect do
|
31
|
+
@user.fill_in :check => 'This radio does not exist'
|
32
|
+
end.to raise_error(Capybara::ElementNotFound)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'fill in select' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should select by id' do
|
10
|
+
@user.will do
|
11
|
+
see :unselected => { '2' => 'normalSelect' }
|
12
|
+
fill_in :select => { '2' => 'normalSelect' }
|
13
|
+
see :selected => { '2' => 'normalSelect' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should select by label' do
|
18
|
+
@user.will do
|
19
|
+
see :unselected => { '1' => 'Select one option' }
|
20
|
+
fill_in :select => { '1' => 'Select one option' }
|
21
|
+
see :selected => { '1' => 'Select one option' }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when is disabled' do
|
26
|
+
#! it should raise excpetions that you are not allowed to modify disabled field
|
27
|
+
it 'should not select value' do
|
28
|
+
@user.will do
|
29
|
+
see :unselected => { 'first option' => 'Disabled select one option' }
|
30
|
+
fill_in :select => { 'first option' => 'Disabled select one option' }
|
31
|
+
see :unselected => { 'first option' => 'Disabled select one option' }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'fill textarea' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should fill by id' do
|
10
|
+
@user.will do
|
11
|
+
see :empty => 'textarea2'
|
12
|
+
fill_in 'Value for textarea2' => 'textarea2'
|
13
|
+
see 'Value for textarea2' => 'textarea2'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should fill by label' do
|
18
|
+
@user.will do
|
19
|
+
see :empty => 'Textarea'
|
20
|
+
fill_in 'Value for Textarea' => 'Textarea'
|
21
|
+
see 'Value for Textarea' => 'Textarea'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when is disabled' do
|
26
|
+
it 'should not fill' do
|
27
|
+
@user.will do
|
28
|
+
see :empty => 'Disabled textarea'
|
29
|
+
fill_in 'Text should not be in this field' => 'Disabled textarea'
|
30
|
+
see :empty => 'Disabled textarea'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when is readonly' do
|
36
|
+
it 'should not fill' do
|
37
|
+
@user.will do
|
38
|
+
see :empty => 'Readonly textarea'
|
39
|
+
fill_in 'Text should not be in this field' => 'Readonly textarea'
|
40
|
+
see :empty => 'Readonly textarea'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when does not exist' do
|
46
|
+
it 'should raise error' do
|
47
|
+
expect do
|
48
|
+
@user.fill_in 'Value for does not exist text area' => 'Bad text area'
|
49
|
+
end.to raise_error(Capybara::ElementNotFound)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'fill text input' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should fill by id' do
|
10
|
+
@user.will do
|
11
|
+
see :empty => 'sampleEmptyInput'
|
12
|
+
fill_in 'Value for sampleEmtyInput' => 'sampleEmptyInput'
|
13
|
+
see 'Value for sampleEmtyInput' => 'sampleEmptyInput'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should fill by label' do
|
18
|
+
@user.will do
|
19
|
+
see :empty => 'Sample empty input'
|
20
|
+
fill_in 'Value for Sample empty input' => 'Sample empty input'
|
21
|
+
see 'Value for Sample empty input' => 'Sample empty input'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when is disabled' do
|
26
|
+
it 'should not fill' do
|
27
|
+
@user.will do
|
28
|
+
see :empty => 'Disabled input'
|
29
|
+
fill_in 'Sample text' => 'Disabled input'
|
30
|
+
see :empty => 'Disabled input'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when is readonly' do
|
36
|
+
it 'should not fill' do
|
37
|
+
@user.will do
|
38
|
+
see :empty => 'Readonly input'
|
39
|
+
fill_in 'Sample text' => 'Readonly input'
|
40
|
+
see :empty => 'Readonly input'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when does not exist' do
|
46
|
+
it 'should raise error' do
|
47
|
+
expect do
|
48
|
+
@user.fill_in 'Value for does not exist field' => 'Bad field'
|
49
|
+
end.to raise_error(Capybara::ElementNotFound)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#on_hover' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('on_hover.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
pending do
|
10
|
+
context 'trigger hover event on element' do
|
11
|
+
it 'should trigger by css selector' do
|
12
|
+
@user.on_hover('#second') do
|
13
|
+
see 'Further information:'
|
14
|
+
not_see 'Second option', 'First option'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should trigger by xpath selector' do
|
19
|
+
@user.on_hover(:xpath, '//p[@id="second"]') do
|
20
|
+
see 'Further information:'
|
21
|
+
not_see 'Second option', 'First option'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when element does not exist' do
|
27
|
+
it 'should raise error' do
|
28
|
+
expect do
|
29
|
+
@user.on_hover('#doesNotExist') {}
|
30
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|