kameleon 0.0.9 → 0.2.0.alpha.2
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/LICENCE +1 -1
- data/README.textile +157 -0
- data/lib/kameleon.rb +3 -18
- data/lib/kameleon/dsl.rb +98 -0
- data/lib/kameleon/dsl/act/form.rb +106 -0
- data/lib/kameleon/dsl/act/mouse.rb +59 -0
- data/lib/kameleon/dsl/context/scope.rb +95 -0
- data/lib/kameleon/dsl/utils/debug.rb +10 -0
- data/lib/kameleon/dsl/verify/absence.rb +151 -0
- data/lib/kameleon/dsl/verify/presence.rb +327 -0
- data/lib/kameleon/ext/active_record/shared_single_connection.rb +42 -0
- data/lib/kameleon/ext/capybara/server.rb +21 -0
- data/lib/kameleon/ext/capybara/session_pool.rb +63 -0
- data/lib/kameleon/ext/rspec/all.rb +4 -0
- data/lib/kameleon/ext/rspec/dsl.rb +39 -0
- data/lib/kameleon/ext/rspec/garbage_collector.rb +11 -0
- data/lib/kameleon/ext/rspec/headless.rb +12 -0
- data/lib/kameleon/ext/rspec/pool.rb +7 -0
- data/lib/kameleon/ext/rspec/transactional_examples.rb +10 -0
- data/{spec/support/deferred_garbage_collection.rb → lib/kameleon/ext/ruby/deferred_garbage_collector.rb} +0 -0
- data/lib/kameleon/ext/session/devise.rb +28 -0
- data/lib/kameleon/session.rb +23 -0
- data/lib/kameleon/utils/configuration.rb +5 -5
- data/lib/kameleon/utils/debug_console.rb +31 -0
- metadata +73 -77
- data/lib/kameleon/dsl/act.rb +0 -107
- data/lib/kameleon/dsl/see.rb +0 -155
- data/lib/kameleon/session/capybara.rb +0 -33
- data/lib/kameleon/session/server.rb +0 -21
- data/lib/kameleon/session/session_pool.rb +0 -45
- data/lib/kameleon/user/abstract.rb +0 -142
- data/lib/kameleon/user/base.rb +0 -36
- data/lib/kameleon/user/guest.rb +0 -10
- data/lib/kameleon/utils/helpers.rb +0 -11
- data/lib/patch/capybara_selenium_driver.rb +0 -7
- data/spec/sample_rack_app/hey.rb +0 -24
- data/spec/spec_helper.rb +0 -41
- data/spec/unit/act/click_spec.rb +0 -52
- data/spec/unit/act/fill_in/attach_file_spec.rb +0 -36
- data/spec/unit/act/fill_in/checkbox_spec.rb +0 -87
- data/spec/unit/act/fill_in/date_ranges_spec.rb +0 -24
- data/spec/unit/act/fill_in/multiple_select_spec.rb +0 -42
- data/spec/unit/act/fill_in/radio_button_spec.rb +0 -35
- data/spec/unit/act/fill_in/select_spec.rb +0 -35
- data/spec/unit/act/fill_in/text_area_spec.rb +0 -52
- data/spec/unit/act/fill_in/text_input_spec.rb +0 -52
- data/spec/unit/act/on_hover_spec.rb +0 -34
- data/spec/unit/dsl/not_see/form_elements/fields/empty_spec.rb +0 -38
- data/spec/unit/dsl/not_see/form_elements/fields/readonly_spec.rb +0 -38
- data/spec/unit/dsl/not_see/form_elements/fields_spec.rb +0 -24
- data/spec/unit/dsl/not_see/form_elements/textareas_spec.rb +0 -25
- data/spec/unit/dsl/not_see/form_elements/texts_spec.rb +0 -26
- data/spec/unit/dsl/not_see/in_scopes_spec.rb +0 -63
- data/spec/unit/dsl/not_see/special_elements/buttons_spec.rb +0 -24
- data/spec/unit/dsl/not_see/special_elements/error_message_for_spec.rb +0 -24
- data/spec/unit/dsl/not_see/special_elements/images_spec.rb +0 -24
- data/spec/unit/dsl/not_see/special_elements/links_spec.rb +0 -46
- data/spec/unit/dsl/not_see/special_elements/ordered_texts_spec.rb +0 -21
- data/spec/unit/dsl/not_see/special_selectors_spec.rb +0 -39
- data/spec/unit/dsl/not_see/texts_spec.rb +0 -24
- data/spec/unit/dsl/see/counted_elements_spec.rb +0 -26
- data/spec/unit/dsl/see/form_elements/checkboxes_spec.rb +0 -45
- data/spec/unit/dsl/see/form_elements/fields/disabled_spec.rb +0 -30
- data/spec/unit/dsl/see/form_elements/fields/empty_spec.rb +0 -28
- data/spec/unit/dsl/see/form_elements/fields/readonly_spec.rb +0 -38
- data/spec/unit/dsl/see/form_elements/fields_spec.rb +0 -28
- data/spec/unit/dsl/see/form_elements/multiple_selects_spec.rb +0 -47
- data/spec/unit/dsl/see/form_elements/radio_buttons_spec.rb +0 -35
- data/spec/unit/dsl/see/form_elements/selects_spec.rb +0 -40
- data/spec/unit/dsl/see/form_elements/textareas_spec.rb +0 -29
- data/spec/unit/dsl/see/form_elements/texts_spec.rb +0 -29
- data/spec/unit/dsl/see/in_scopes_spec.rb +0 -85
- data/spec/unit/dsl/see/special_elements/buttons_spec.rb +0 -28
- data/spec/unit/dsl/see/special_elements/error_message_for_spec.rb +0 -24
- data/spec/unit/dsl/see/special_elements/images_spec.rb +0 -28
- data/spec/unit/dsl/see/special_elements/links_spec.rb +0 -55
- data/spec/unit/dsl/see/special_elements/ordered_texts_spec.rb +0 -21
- data/spec/unit/dsl/see/special_selectors_spec.rb +0 -57
- data/spec/unit/dsl/see/texts_spec.rb +0 -24
- data/spec/unit/guest_spec.rb +0 -46
- data/spec/unit/user_base_spec.rb +0 -13
data/lib/kameleon/user/base.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Kameleon
|
2
|
-
module User
|
3
|
-
class Base < Abstract
|
4
|
-
|
5
|
-
attr_accessor :user
|
6
|
-
|
7
|
-
def initialize(rspec_world, options={}, &block)
|
8
|
-
super do
|
9
|
-
login
|
10
|
-
end
|
11
|
-
instance_eval(&block) if block_given?
|
12
|
-
end
|
13
|
-
|
14
|
-
def login
|
15
|
-
visit user_login_path
|
16
|
-
fill_in user_login => 'Email',
|
17
|
-
user_password => 'Password'
|
18
|
-
click 'Login'
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def user_login
|
24
|
-
user.email
|
25
|
-
end
|
26
|
-
|
27
|
-
def user_password
|
28
|
-
user.password
|
29
|
-
end
|
30
|
-
|
31
|
-
def user_login_path
|
32
|
-
new_session_path
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/kameleon/user/guest.rb
DELETED
data/spec/sample_rack_app/hey.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
class Hey
|
2
|
-
def call(env)
|
3
|
-
if env["PATH_INFO"] == "/"
|
4
|
-
[200, {"Content-Type" => "text"}, ['welcome on homepage']]
|
5
|
-
else
|
6
|
-
[200, {"Content-Type" => "text/html"}, [get_body(env['PATH_INFO'])]]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def get_body(filename)
|
13
|
-
file = File.open(file_path(filename))
|
14
|
-
body = file.read
|
15
|
-
file.close
|
16
|
-
body
|
17
|
-
rescue
|
18
|
-
filename
|
19
|
-
end
|
20
|
-
|
21
|
-
def file_path(filename)
|
22
|
-
File.dirname(__FILE__) + "/../dummy/#{filename}"
|
23
|
-
end
|
24
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'kameleon'
|
2
|
-
require 'capybara/dsl'
|
3
|
-
require 'capybara/rspec/matchers'
|
4
|
-
|
5
|
-
require 'capybara/selenium/driver'
|
6
|
-
# one server on all sessions for selenium
|
7
|
-
# require 'patch/capybara_selenium_driver'
|
8
|
-
require 'headless'
|
9
|
-
|
10
|
-
Dir["#{File.expand_path("../", __FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
-
|
12
|
-
require 'sample_rack_app/hey'
|
13
|
-
|
14
|
-
RSpec.configure do |config|
|
15
|
-
config.before(:suite) do
|
16
|
-
@headless = Headless.new(:display => '100')
|
17
|
-
@headless.start
|
18
|
-
end
|
19
|
-
|
20
|
-
config.before(:all) do
|
21
|
-
DeferredGarbageCollection.start
|
22
|
-
end
|
23
|
-
|
24
|
-
config.after(:each) do
|
25
|
-
::SessionPool.release_all
|
26
|
-
end
|
27
|
-
|
28
|
-
config.after(:all) do
|
29
|
-
DeferredGarbageCollection.reconsider
|
30
|
-
end
|
31
|
-
|
32
|
-
config.after(:suite) do
|
33
|
-
@headless.stop if defined?(@headless)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
Capybara.app = Hey.new
|
38
|
-
|
39
|
-
Capybara.configure do |c|
|
40
|
-
c.default_driver= (ENV['CAPYBARA_DEFAULT_DRIVER']||:rack_test).to_sym
|
41
|
-
end
|
data/spec/unit/act/click_spec.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe '#click' do
|
4
|
-
before do
|
5
|
-
@user = Kameleon::User::Guest.new(self)
|
6
|
-
@user.debug.visit('/click.html')
|
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
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'fill in attach file' do
|
4
|
-
before do
|
5
|
-
@user = Kameleon::User::Guest.new(self)
|
6
|
-
@user.debug.visit('/form_elements.html')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should attach file' do
|
10
|
-
@user.will do
|
11
|
-
see :empty => 'File input'
|
12
|
-
fill_in :attach => { 'click.html' => 'Active File input' }
|
13
|
-
see Kameleon::Utils::Helpers.default_path_for_file('click.html') => 'File input'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when disabled' do
|
18
|
-
it 'should not attach file' do
|
19
|
-
@user.will do
|
20
|
-
see :empty => 'Disable File input'
|
21
|
-
fill_in :attach => { 'click.html' => 'Disable File input' }
|
22
|
-
see :empty => 'Disable File input'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'when file does not exist' do
|
28
|
-
it 'should raise error' do
|
29
|
-
expect do
|
30
|
-
@user.will do
|
31
|
-
fill_in :attach => { 'path' => 'Active File input' }
|
32
|
-
end
|
33
|
-
end.to_not raise_error(RuntimeError, %w{Sorry but we didn't found that file in: path'})
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
#ecoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe 'fill in checkbox' do
|
5
|
-
before do
|
6
|
-
@user = Kameleon::User::Guest.new(self)
|
7
|
-
@user.debug.visit('/form_elements.html')
|
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
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'fill in date ranges' do
|
4
|
-
before do
|
5
|
-
@user = Kameleon::User::Guest.new(self)
|
6
|
-
@user.debug.visit('/form_elements.html')
|
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
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'fill in multiple select' do
|
4
|
-
before do
|
5
|
-
@user = Kameleon::User::Guest.new(self)
|
6
|
-
@user.debug.visit('/form_elements.html')
|
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
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe 'fill in radio button' do
|
5
|
-
before do
|
6
|
-
@user = Kameleon::User::Guest.new(self)
|
7
|
-
@user.debug.visit('/form_elements.html')
|
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
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'fill in select' do
|
4
|
-
before do
|
5
|
-
@user = Kameleon::User::Guest.new(self)
|
6
|
-
@user.debug.visit('/form_elements.html')
|
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
|