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,45 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe '#see form elements - checkboxes' do
|
5
|
+
before do
|
6
|
+
Capybara.app = Hey.new('form_elements.html')
|
7
|
+
@user = Kameleon::User::Guest.new(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when status checked' do
|
11
|
+
it 'should verify by label' do
|
12
|
+
@user.see :checked => 'Option two can also be checked and included in form results'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should verify by name' do
|
16
|
+
@user.see :checked => 'optionsCheckboxes_two'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should verify many at once' do
|
20
|
+
@user.see :checked => ['Appended checkbox', 'appendedInput', 'optionsCheckboxes_two']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when status unchecked' do
|
25
|
+
it 'should verify by label' do
|
26
|
+
@user.see :unchecked => "Option one is this and that—be sure to include why it's great"
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should verify by name' do
|
30
|
+
@user.see :unchecked => 'optionsCheckboxes_one'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should verify many at once' do
|
34
|
+
@user.see :unchecked => ['Prepended checkbox', 'optionsCheckboxes', 'optionsCheckboxes_one']
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when at least one has other status than other checkboxes' do
|
39
|
+
it 'should raise error' do
|
40
|
+
expect do
|
41
|
+
@user.see :checked =>['Appended checkbox', 'appendedInput', 'optionsCheckboxes_one']
|
42
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see disabled fields' 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 verify status for id' do
|
10
|
+
@user.see :disabled => 'disabledInput'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should verify status for label' do
|
14
|
+
@user.see :disabled => 'Disabled input'
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when many disabled fields at once' do
|
18
|
+
it 'should verify status' do
|
19
|
+
@user.see :disabled => ['Disabled input', 'Disabled textarea']
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when at least one is enabled' do
|
23
|
+
it 'should raise error' do
|
24
|
+
expect do
|
25
|
+
@user.see :disabled => ['Disabled input', 'Disabled textarea', 'X-Large input']
|
26
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see empty fields' 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 verify status for id' do
|
10
|
+
@user.see :empty => 'prependedInput'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should verify status for label' do
|
14
|
+
@user.see :empty => 'Prepended text'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should verify status for many fields' do
|
18
|
+
@user.see :empty => ['Prepended text', 'Textarea']
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when at least one is not empty' do
|
22
|
+
it 'should raise error' do
|
23
|
+
expect do
|
24
|
+
@user.see :empty => ['Prepended text', 'Sample Input']
|
25
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see readonly fields' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'when text inside fields is not provied' do
|
10
|
+
it 'should verify status for id' do
|
11
|
+
@user.see :readonly => 'readonlyInput'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should verify status for label' do
|
15
|
+
@user.see :readonly => 'Readonly input'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should verify many fields at once' do
|
19
|
+
@user.see :readonly => ['Readonly input', 'Readonly textarea']
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when field does not exist' do
|
23
|
+
it 'should raise error' do
|
24
|
+
expect do
|
25
|
+
@user.see :readonly => 'DoesNotExist'
|
26
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when at least one is not readonly' do
|
31
|
+
it 'should raise error' do
|
32
|
+
expect do
|
33
|
+
@user.see :readonly => ['Readonly input', 'X-Large input']
|
34
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see form elements - fields' 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 see by label' do
|
10
|
+
@user.see :field => 'X-Large input'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should see by id' do
|
14
|
+
@user.see :field => 'xlInput'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should see many at once' do
|
18
|
+
@user.see :fields => ['xlInput', 'multiSelect']
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when at least one does not exist' do
|
22
|
+
it 'should raise error' do
|
23
|
+
expect do
|
24
|
+
@user.see :field => 'doestNotExist'
|
25
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see form elements - multiple selects' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'when status "selected"' do
|
10
|
+
it 'should verify by id' do
|
11
|
+
@user.see :selected => {'3' => 'normalSelect'}
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should verify by label' do
|
15
|
+
@user.see :selected => {'3' => 'Select one option'}
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should verify many at once' do
|
19
|
+
@user.see :selected => {'3' => 'Select one option',
|
20
|
+
'second option' => 'Disabled select one option'}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when status "unselected"' do
|
25
|
+
it 'should verify by id' do
|
26
|
+
@user.see :unselected => {'1' => 'Select one option'}
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should verify by label' do
|
30
|
+
@user.see :unselected => {'5' => 'normalSelect'}
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should verify many status at once' do
|
34
|
+
@user.see :unselected => {'5' => 'Select one option',
|
35
|
+
'2' => 'Select one option'}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'at least one has other status' do
|
40
|
+
it 'should raise error' do
|
41
|
+
expect do
|
42
|
+
@user.see :selected => {'5' => 'Select one option',
|
43
|
+
'3' => 'Select one option'}
|
44
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe '#see form elements - radio buttons' do
|
5
|
+
before do
|
6
|
+
Capybara.app = Hey.new('form_elements.html')
|
7
|
+
@user = Kameleon::User::Guest.new(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'status "checked"' do
|
11
|
+
it 'should verify checked status' do
|
12
|
+
@user.see :checked => "Option one is this and that—be sure to include why it's great"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'status "unchecked"' do
|
17
|
+
it 'should verify unchecked status' do
|
18
|
+
@user.see :unchecked => "Option two can is something else and selecting it will deselect options 1"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should verify many radio buttons at once' do
|
22
|
+
@user.see :unchecked => ["Option two can is something else and selecting it will deselect options 1",
|
23
|
+
"Option three can is something else and selecting it will deselect options 1"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'at least one has other status' do
|
28
|
+
it 'should raise error' do
|
29
|
+
expect do
|
30
|
+
@user.see :checked => ["Option one is this and that—be sure to include why it's great",
|
31
|
+
"Option two can is something else and selecting it will deselect options 1"]
|
32
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see form elements - selects' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('form_elements.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'status "selected"' do
|
10
|
+
it 'should verify by id' do
|
11
|
+
@user.see :selected => { '3' => 'normalSelect' }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should verify by label' do
|
15
|
+
@user.see :selected => { '3' => 'Select' }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'status "unselected"' do
|
20
|
+
it 'should verify by id' do
|
21
|
+
@user.see :unselected => { '2' => 'normalSelect' }
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should verify by label' do
|
25
|
+
@user.see :unselected => { '4' => 'Select' }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should verify many options at once' do
|
29
|
+
@user.see :unselected => { '1' => 'Select', '2' => 'Select' }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'at least one has other status' do
|
34
|
+
it 'should raise error' do
|
35
|
+
expect do
|
36
|
+
@user.see :selected => { '1' => 'Select', '3' => 'Select', '2' => 'Select' }
|
37
|
+
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see form elements - textareas' 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 see by id' do
|
10
|
+
@user.see 'sample text in textarea' => 'textarea3'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should see by label' do
|
14
|
+
@user.see 'sample text in textarea' => 'Textarea 3'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should see many at once' do
|
18
|
+
@user.see 'sample text in second textarea 2' => 'secondTextarea2',
|
19
|
+
'sample text in textarea' => 'textarea3'
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when it does not exist' do
|
23
|
+
it 'should raise error' do
|
24
|
+
expect do
|
25
|
+
@user.see 'this is great value' => 'textareaDoesNotExist'
|
26
|
+
end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see form elements - text inputs' 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 see by id' do
|
10
|
+
@user.see 'this is great value' => 'xlInput'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should see by label' do
|
14
|
+
@user.see 'this is great value' => 'X-Large input'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should see many at once' do
|
18
|
+
@user.see 'this is great value' => 'xlInput',
|
19
|
+
'sample default value' => 'secondInput'
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when it does not exist' do
|
23
|
+
it 'should raise error' do
|
24
|
+
expect do
|
25
|
+
@user.see 'this is gread value' => 'fieldDoesNotExist'
|
26
|
+
end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#see in scopes' do
|
4
|
+
before do
|
5
|
+
Capybara.app = Hey.new('scopes.html')
|
6
|
+
@user = Kameleon::User::Guest.new(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
# TODO
|
10
|
+
# would be nice to be possible in future
|
11
|
+
# it's hard because of block closing
|
12
|
+
# it "should see within specific selector" do
|
13
|
+
# @user.within("#some_div").see "This is It"
|
14
|
+
# @user.within("#some_div").not_see "Hello"
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# it "should see within default selector" do
|
18
|
+
# @user.stub!(:page_areas).and_return({:main => '#some_div'})
|
19
|
+
# @user.will.see "This is It"
|
20
|
+
# @user.will.not_see "Hello"
|
21
|
+
# end
|
22
|
+
|
23
|
+
context '#will' do
|
24
|
+
context 'when main selector was defined' do
|
25
|
+
before { @user.stub!(:page_areas).and_return({:main => '#main'}) }
|
26
|
+
|
27
|
+
it 'should see in main selector scope' do
|
28
|
+
@user.will do
|
29
|
+
see 'Sample text in main part of page', 'Left side', 'Right side'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'main selector was not defined' do
|
35
|
+
it 'should see in whole page scope' do
|
36
|
+
@user.will do
|
37
|
+
see 'Sample title for page', 'Sample text in top of page', 'Left side'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context '#within' do
|
44
|
+
it 'should see in css scope' do
|
45
|
+
@user.within('#top h1') do
|
46
|
+
see 'Sample title for page'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when scope by xpath' do
|
51
|
+
it 'should see in one selector scope' do
|
52
|
+
@user.within(:xpath, '//div[@id="footer"]/span') do
|
53
|
+
see 'Simple text'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should see in many selctors scope' do
|
58
|
+
@user.within(:xpath, '//div[@id="footer"]/span | //div[@id="main"]/div[@id="left"]', :select_multiple) do
|
59
|
+
see 'Simple text', 'Left side'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when scope by default selector type' do
|
65
|
+
before do
|
66
|
+
@user.stub!(:page_areas).and_return({:top => '#top',
|
67
|
+
:footer => [:xpath, '//div[@id="footer"]']})
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should see in top selector scope' do
|
71
|
+
@user.within(:top) do
|
72
|
+
see 'Sample title for page', 'Sample text in top of page'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should see in footer selector scope' do
|
77
|
+
@user.within(:footer) do
|
78
|
+
see 'Sample text in footer', 'Simple text'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|