kameleon 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/lib/kameleon/dsl/act.rb +73 -22
  2. data/lib/kameleon/dsl/see.rb +101 -20
  3. data/lib/kameleon/session/capybara.rb +11 -0
  4. data/lib/kameleon/user/abstract.rb +78 -6
  5. data/spec/sample_rack_app/hey.rb +11 -4
  6. data/spec/spec_helper.rb +12 -0
  7. data/spec/support/deferred_garbage_collection.rb +20 -0
  8. data/spec/unit/act/click_spec.rb +52 -0
  9. data/spec/unit/act/fill_in/attach_file_spec.rb +27 -0
  10. data/spec/unit/act/fill_in/checkbox_spec.rb +87 -0
  11. data/spec/unit/act/fill_in/date_ranges_spec.rb +24 -0
  12. data/spec/unit/act/fill_in/multiple_select_spec.rb +42 -0
  13. data/spec/unit/act/fill_in/radio_button_spec.rb +35 -0
  14. data/spec/unit/act/fill_in/select_spec.rb +35 -0
  15. data/spec/unit/act/fill_in/text_area_spec.rb +52 -0
  16. data/spec/unit/act/fill_in/text_input_spec.rb +52 -0
  17. data/spec/unit/act/on_hover_spec.rb +34 -0
  18. data/spec/unit/dsl/not_see/form_elements/fields/empty_spec.rb +38 -0
  19. data/spec/unit/dsl/not_see/form_elements/fields/readonly_spec.rb +38 -0
  20. data/spec/unit/dsl/not_see/form_elements/fields_spec.rb +24 -0
  21. data/spec/unit/dsl/not_see/form_elements/textareas_spec.rb +25 -0
  22. data/spec/unit/dsl/not_see/form_elements/texts_spec.rb +26 -0
  23. data/spec/unit/dsl/not_see/in_scopes_spec.rb +61 -0
  24. data/spec/unit/dsl/not_see/special_elements/buttons_spec.rb +24 -0
  25. data/spec/unit/dsl/not_see/special_elements/error_message_for_spec.rb +24 -0
  26. data/spec/unit/dsl/not_see/special_elements/images_spec.rb +24 -0
  27. data/spec/unit/dsl/not_see/special_elements/links_spec.rb +46 -0
  28. data/spec/unit/dsl/not_see/special_elements/ordered_texts_spec.rb +21 -0
  29. data/spec/unit/dsl/not_see/special_selectors_spec.rb +35 -0
  30. data/spec/unit/dsl/not_see/texts_spec.rb +24 -0
  31. data/spec/unit/dsl/see/counted_elements_spec.rb +26 -0
  32. data/spec/unit/dsl/see/form_elements/checkboxes_spec.rb +45 -0
  33. data/spec/unit/dsl/see/form_elements/fields/disabled_spec.rb +30 -0
  34. data/spec/unit/dsl/see/form_elements/fields/empty_spec.rb +28 -0
  35. data/spec/unit/dsl/see/form_elements/fields/readonly_spec.rb +38 -0
  36. data/spec/unit/dsl/see/form_elements/fields_spec.rb +28 -0
  37. data/spec/unit/dsl/see/form_elements/multiple_selects_spec.rb +47 -0
  38. data/spec/unit/dsl/see/form_elements/radio_buttons_spec.rb +35 -0
  39. data/spec/unit/dsl/see/form_elements/selects_spec.rb +40 -0
  40. data/spec/unit/dsl/see/form_elements/textareas_spec.rb +29 -0
  41. data/spec/unit/dsl/see/form_elements/texts_spec.rb +29 -0
  42. data/spec/unit/dsl/see/in_scopes_spec.rb +83 -0
  43. data/spec/unit/dsl/see/special_elements/buttons_spec.rb +28 -0
  44. data/spec/unit/dsl/see/special_elements/error_message_for_spec.rb +24 -0
  45. data/spec/unit/dsl/see/special_elements/images_spec.rb +28 -0
  46. data/spec/unit/dsl/see/special_elements/links_spec.rb +55 -0
  47. data/spec/unit/dsl/see/special_elements/ordered_texts_spec.rb +21 -0
  48. data/spec/unit/dsl/see/special_selectors_spec.rb +53 -0
  49. data/spec/unit/dsl/see/texts_spec.rb +24 -0
  50. data/spec/unit/guest_spec.rb +24 -45
  51. data/spec/unit/user_base_spec.rb +1 -1
  52. metadata +78 -13
  53. data/spec/unit/act_spec.rb +0 -99
  54. data/spec/unit/see_spec.rb +0 -242
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_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.not_see :empty => 'xlInput'
11
+ end
12
+
13
+ it 'should verify status for label' do
14
+ @user.not_see :empty => 'X-Large input'
15
+ end
16
+
17
+ context 'when many empty fields at once' do
18
+ it 'should verify status' do
19
+ @user.not_see :empty => ['xlInput', 'X-Large input']
20
+ end
21
+
22
+ context 'when at least one is not empty' do
23
+ it 'should raise error' do
24
+ expect do
25
+ @user.not_see :empty => ['Prepended text', 'Sample Input']
26
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
27
+ end
28
+ end
29
+
30
+ context 'when at least one does not exist' do
31
+ it 'should raise error' do
32
+ expect do
33
+ @user.not_see :empty => ['Prepended text', 'Sample Input']
34
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_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.not_see :readonly => 'xlInput'
12
+ end
13
+
14
+ it 'should verify status for label' do
15
+ @user.not_see :readonly => 'X-Large input'
16
+ end
17
+
18
+ it 'should verify many fields at once' do
19
+ @user.not_see :readonly => ['xlInput', 'X-Large input']
20
+ end
21
+
22
+ context 'when field does not exist' do
23
+ it 'should raise error' do
24
+ expect do
25
+ @user.not_see :readonly => 'DoesNotExist'
26
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
27
+ end
28
+ end
29
+
30
+ context 'when at least one is readonly' do
31
+ it 'should raise error' do
32
+ expect do
33
+ @user.not_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,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_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 not see by label' do
10
+ @user.not_see :field => 'maybeDiv'
11
+ end
12
+
13
+ it 'should not see many at once' do
14
+ @user.not_see :fields => ['maybeDiv', 'maybeSecondDiv']
15
+ end
16
+
17
+ context 'when at least one exists' do
18
+ it 'should raise error' do
19
+ expect do
20
+ @user.not_see :field => ['maybeDiv', 'multiSelect']
21
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_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 not see one' do
10
+ @user.not_see 'another this is great value' => 'textarea3'
11
+ end
12
+
13
+ it 'should not see many at once' do
14
+ @user.not_see 'other this is great value' => 'secondTextarea2',
15
+ 'other sample default value' => 'textarea3'
16
+ end
17
+
18
+ context 'when exists' do
19
+ it 'should raise error' do
20
+ expect do
21
+ @user.not_see 'sample text in second textarea 2' => 'secondTextarea2'
22
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_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 not see one' do
10
+ @user.not_see 'sample other value' => 'maybeSimpleDiv'
11
+ end
12
+
13
+ it 'should not see many at once' do
14
+ @user.not_see 'other this is great value' => 'maybeSimpleDiv',
15
+ 'other sample default value' => 'maybeSimpleDiv'
16
+ end
17
+
18
+ context 'when exists' do
19
+ it 'should raise error' do
20
+ expect do
21
+ @user.not_see 'sample default value' => 'secondInput',
22
+ 'sample value' => 'maybeSimpleDiv'
23
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_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
+ context '#will' do
10
+ context 'when main selector was defined' do
11
+ before { @user.stub!(:page_areas).and_return({:main => '#main'}) }
12
+
13
+ it 'should not see in main selector scope' do
14
+ @user.will do
15
+ not_see 'Sample title for page', 'Sample text in footer'
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ context '#within' do
22
+ it 'should not see in css scope' do
23
+ @user.within('#top h1') do
24
+ not_see 'Sample text in top of page', 'Left side'
25
+ end
26
+ end
27
+
28
+ context 'when scope by xpath' do
29
+ it 'should not see in one selector scope' do
30
+ @user.within(:xpath, '//div[@id="footer"]/span') do
31
+ not_see 'Sample text in footer', 'Sample text in main part of page'
32
+ end
33
+ end
34
+
35
+ it 'should not see in many selctors scope' do
36
+ @user.within(:xpath, '//div[@id="footer"]/span | //div[@id="main"]/div[@id="left"]', :select_multiple) do
37
+ not_see 'Right side', 'Sample text in top of page', 'Sample text in footer'
38
+ end
39
+ end
40
+ end
41
+
42
+ context 'when scope by default selector type' do
43
+ before do
44
+ @user.stub!(:page_areas).and_return({:top => '#top',
45
+ :footer => [:xpath, '//div[@id="footer"]']})
46
+ end
47
+
48
+ it 'should not see in top selector scope' do
49
+ @user.within(:top) do
50
+ not_see 'Sample text in main part of page', 'Sample text in footer'
51
+ end
52
+ end
53
+
54
+ it 'should not see in footer selector scope' do
55
+ @user.within(:footer) do
56
+ not_see 'Sample title for page', 'Sample text in main part of page'
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_see special elements - buttons' do
4
+ before do
5
+ Capybara.app = Hey.new('special_elements.html')
6
+ @user = Kameleon::User::Guest.new(self)
7
+ end
8
+
9
+ it 'should not see one button' do
10
+ @user.not_see :button => 'first'
11
+ end
12
+
13
+ it 'should not see many buttons' do
14
+ @user.not_see :button => ['first button', 'second button']
15
+ end
16
+
17
+ context 'when exists' do
18
+ it 'should raise error' do
19
+ expect do
20
+ @user.not_see :button => 'Super button'
21
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_see special elements - error message for' do
4
+ before do
5
+ Capybara.app = Hey.new('error_message_for.html')
6
+ @user = Kameleon::User::Guest.new(self)
7
+ end
8
+
9
+ it 'should not see one messages' do
10
+ @user.not_see :error_message_for => 'first field'
11
+ end
12
+
13
+ it 'should not see many messages at once' do
14
+ @user.not_see :error_messages_for => ['first field', 'second field']
15
+ end
16
+
17
+ context 'when at least one exist' do
18
+ it 'should raise error' do
19
+ expect do
20
+ @user.not_see :error_messages_for => ['name', 'doesNotExist']
21
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_see special elements - images' do
4
+ before do
5
+ Capybara.app = Hey.new('special_elements.html')
6
+ @user = Kameleon::User::Guest.new(self)
7
+ end
8
+
9
+ it 'should not see one image' do
10
+ @user.not_see :image => 'sample_first'
11
+ end
12
+
13
+ it 'should not see many images' do
14
+ @user.not_see :images => ['sample_first', 'sample_second']
15
+ end
16
+
17
+ context 'when at least one exists' do
18
+ it 'should raise error' do
19
+ expect do
20
+ @user.not_see :image => ['sample_first', 'Logo_diamondmine']
21
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_see special elements - links' do
4
+ before do
5
+ Capybara.app = Hey.new('special_elements.html')
6
+ @user = Kameleon::User::Guest.new(self)
7
+ end
8
+
9
+ context 'when src is provided' do
10
+ it 'should not see one link' do
11
+ @user.not_see :link => { 'Maybe div' => '/i/do/not/know' }
12
+ end
13
+
14
+ it 'should not see many links' do
15
+ @user.not_see :links => { 'Maybe div' => '/i/do/not/know',
16
+ 'Maybe other div' => '/i/do/not/know/too' }
17
+ end
18
+
19
+ context 'when at least one exists' do
20
+ it 'should raise error' do
21
+ expect do
22
+ @user.not_see :link => { 'What you want' => '/i-want/to',
23
+ 'Maybe div' => '/i/do/not/know' }
24
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
25
+ end
26
+ end
27
+ end
28
+
29
+ context 'when src path is not provided' do
30
+ it 'should not see one link' do
31
+ @user.not_see :link => 'Maybe div'
32
+ end
33
+
34
+ it 'should not see many links' do
35
+ @user.not_see :links => ['Maybe div', 'Maybe other div']
36
+ end
37
+
38
+ context 'when at least one exists' do
39
+ it 'should raise error' do
40
+ expect do
41
+ @user.not_see :link => ['What you want', 'Maybe div']
42
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,21 @@
1
+ #encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe '#not_see special elements - ordered texts' do
5
+ before do
6
+ Capybara.app = Hey.new('special_elements.html')
7
+ @user = Kameleon::User::Guest.new(self)
8
+ end
9
+
10
+ it 'should not see text in proper order' do
11
+ @user.not_see :ordered => ['Tomasz Bąk', 'Michał Czyż', 'Rafał Bromirski']
12
+ end
13
+
14
+ context 'when texts is in proper order' do
15
+ it 'should raise error' do
16
+ expect do
17
+ @user.not_see :ordered => ['Michał Czyż', 'Tomasz Bąk', 'Rafał Bromirski']
18
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ #encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe '#not_see special selectors in tables' do
5
+ before do
6
+ Capybara.app = Hey.new('special_elements.html')
7
+ @user = Kameleon::User::Guest.new(self)
8
+ end
9
+
10
+ context 'when in row' do
11
+ it 'should not see text' do
12
+ @user.within(:row => 'Michał Czyż') do
13
+ not_see "17"
14
+ end
15
+ end
16
+ end
17
+
18
+ context 'when in column' do
19
+ context 'when scoped by full text' do
20
+ it 'should not see text' do
21
+ @user.within(:column => 'Selleo') do
22
+ not_see "19.00", "17.00", "5.00"
23
+ end
24
+ end
25
+ end
26
+
27
+ context 'when scoped by partial text' do
28
+ it 'should not see text' do
29
+ @user.within(:column => 'lleo') do
30
+ not_see "19.00", "17.00", "5.00"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#not_see texts' do
4
+ before do
5
+ Capybara.app = Hey.new('texts.html')
6
+ @user = Kameleon::User::Guest.new(self)
7
+ end
8
+
9
+ it 'should not see single text' do
10
+ @user.not_see 'cool rails app'
11
+ end
12
+
13
+ it 'should not see many texts at once' do
14
+ @user.not_see 'sinatra app', 'padrino app'
15
+ end
16
+
17
+ context 'when at least one text is visibile' do
18
+ it 'should raise error' do
19
+ expect do
20
+ @user.not_see 'sinatra app', 'This is simple app'
21
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#see counted elements' do
4
+ before do
5
+ Capybara.app = Hey.new('elements_counter.html')
6
+ @user = Kameleon::User::Guest.new(self)
7
+ end
8
+
9
+ context 'when page areas has attribute' do
10
+ before do
11
+ @user.stub!(:page_areas).and_return(:menu_link => [:xpath, '//ul[@id="menu"]/li/a'])
12
+ end
13
+
14
+ it 'should counted elements from page areas attribute' do
15
+ @user.see 7 => :menu_link
16
+ end
17
+ end
18
+
19
+ it "should see counted elements from css" do
20
+ @user.see 5 => '#fiveElements'
21
+ end
22
+
23
+ it 'should see counted elements from xpath' do
24
+ @user.see 5 => [:xpath, '//div[@id="fiveElements"]']
25
+ end
26
+ end