howitzer 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +1 -4
- data/.yardopts +1 -2
- data/CHANGELOG.md +28 -1
- data/Gemfile +6 -0
- data/LICENSE +1 -1
- data/README.md +55 -85
- data/Rakefile +7 -7
- data/bin/howitzer +56 -31
- data/features/cli_new.feature +162 -79
- data/features/cli_update.feature +114 -21
- data/features/step_definitions/common_steps.rb +29 -9
- data/features/support/env.rb +1 -1
- data/features/support/transformers.rb +2 -2
- data/generators/base_generator.rb +121 -49
- data/generators/config/config_generator.rb +8 -5
- data/generators/config/templates/boot.rb +14 -0
- data/generators/config/templates/capybara.rb +156 -0
- data/generators/config/templates/custom.yml +2 -3
- data/generators/config/templates/default.yml +50 -82
- data/generators/cucumber/cucumber_generator.rb +9 -9
- data/generators/cucumber/templates/common_steps.rb +4 -4
- data/generators/cucumber/templates/cucumber.rake +63 -54
- data/generators/cucumber/templates/env.rb +24 -23
- data/generators/cucumber/templates/transformers.rb +23 -15
- data/generators/emails/emails_generator.rb +4 -2
- data/generators/emails/templates/example_email.rb +4 -4
- data/generators/prerequisites/prerequisites_generator.rb +24 -0
- data/generators/prerequisites/templates/base.rb +22 -0
- data/generators/prerequisites/templates/factory_girl.rb +30 -0
- data/generators/prerequisites/templates/user.rb +7 -0
- data/generators/prerequisites/templates/users.rb +12 -0
- data/generators/root/root_generator.rb +11 -7
- data/generators/root/templates/.rubocop.yml +32 -0
- data/generators/root/templates/Gemfile.erb +27 -0
- data/generators/root/templates/Rakefile +6 -8
- data/generators/rspec/rspec_generator.rb +7 -7
- data/generators/rspec/templates/example_spec.rb +1 -1
- data/generators/rspec/templates/rspec.rake +48 -29
- data/generators/rspec/templates/spec_helper.rb +33 -32
- data/generators/tasks/tasks_generator.rb +4 -2
- data/generators/tasks/templates/common.rake +1 -16
- data/generators/turnip/templates/.rspec +1 -0
- data/generators/turnip/templates/common_steps.rb +25 -0
- data/generators/turnip/templates/example.feature +8 -0
- data/generators/turnip/templates/spec_helper.rb +56 -0
- data/generators/turnip/templates/turnip.rake +61 -0
- data/generators/turnip/templates/turnip_helper.rb +6 -0
- data/generators/turnip/turnip_generator.rb +26 -0
- data/generators/web/templates/example_page.rb +15 -0
- data/generators/web/templates/menu_section.rb +13 -0
- data/generators/web/web_generator.rb +22 -0
- data/howitzer.gemspec +14 -21
- data/lib/howitzer.rb +47 -7
- data/lib/howitzer/cache.rb +70 -0
- data/lib/howitzer/capybara_helpers.rb +194 -0
- data/lib/howitzer/email.rb +96 -104
- data/lib/howitzer/exceptions.rb +10 -6
- data/lib/howitzer/log.rb +120 -0
- data/lib/howitzer/mail_adapters.rb +7 -0
- data/lib/howitzer/mail_adapters/abstract.rb +84 -0
- data/lib/howitzer/mail_adapters/mailgun.rb +115 -0
- data/lib/howitzer/mailgun_api.rb +9 -0
- data/lib/howitzer/mailgun_api/client.rb +79 -0
- data/lib/howitzer/mailgun_api/connector.rb +37 -0
- data/lib/howitzer/mailgun_api/response.rb +28 -0
- data/lib/howitzer/tasks/framework.rake +2 -2
- data/lib/howitzer/utils.rb +7 -1
- data/lib/howitzer/utils/string_extensions.rb +66 -0
- data/lib/howitzer/version.rb +2 -1
- data/lib/howitzer/web.rb +11 -0
- data/lib/howitzer/web/base_section.rb +27 -0
- data/lib/howitzer/web/blank_page.rb +12 -0
- data/lib/howitzer/web/capybara_methods_proxy.rb +29 -0
- data/lib/howitzer/web/element_dsl.rb +109 -0
- data/lib/howitzer/web/iframe_dsl.rb +93 -0
- data/lib/howitzer/web/page.rb +173 -0
- data/lib/howitzer/web/page_dsl.rb +64 -0
- data/lib/howitzer/web/page_validator.rb +118 -0
- data/lib/howitzer/web/section.rb +27 -0
- data/lib/howitzer/web/section_dsl.rb +154 -0
- data/spec/config/custom.yml +10 -1
- data/spec/spec_helper.rb +37 -19
- data/spec/support/generator_helper.rb +12 -11
- data/spec/support/logger_helper.rb +10 -9
- data/spec/support/mailgun_unit_client.rb +52 -44
- data/spec/support/shared_examples/capybara_context_holder.rb +33 -0
- data/spec/support/shared_examples/capybara_methods_proxy.rb +94 -0
- data/spec/support/shared_examples/dynamic_section_methods.rb +35 -0
- data/spec/support/shared_examples/element_dsl.rb +119 -0
- data/spec/unit/generators/base_generator_spec.rb +64 -33
- data/spec/unit/generators/config_generator_spec.rb +11 -7
- data/spec/unit/generators/cucumber_generator_spec.rb +26 -17
- data/spec/unit/generators/emails_generator_spec.rb +10 -6
- data/spec/unit/generators/prerequisites_generator_spec.rb +53 -0
- data/spec/unit/generators/root_generator_spec.rb +50 -13
- data/spec/unit/generators/rspec_generator_spec.rb +9 -9
- data/spec/unit/generators/tasks_generator_spec.rb +6 -6
- data/spec/unit/generators/turnip_generator_spec.rb +52 -0
- data/spec/unit/generators/web_generator_spec.rb +52 -0
- data/spec/unit/lib/cache_spec.rb +85 -0
- data/spec/unit/lib/capybara_helpers_spec.rb +696 -0
- data/spec/unit/lib/email_spec.rb +104 -91
- data/spec/unit/lib/howitzer.rb +31 -0
- data/spec/unit/lib/init_spec.rb +0 -1
- data/spec/unit/lib/log_spec.rb +122 -0
- data/spec/unit/lib/mail_adapters/abstract_spec.rb +62 -0
- data/spec/unit/lib/mail_adapters/mailgun_spec.rb +163 -0
- data/spec/unit/lib/mailgun_api/client_spec.rb +58 -0
- data/spec/unit/lib/mailgun_api/connector_spec.rb +54 -0
- data/spec/unit/lib/mailgun_api/response_spec.rb +28 -0
- data/spec/unit/lib/utils/string_extensions_spec.rb +77 -0
- data/spec/unit/lib/web/base_section_spec.rb +41 -0
- data/spec/unit/lib/web/element_dsl_spec.rb +17 -0
- data/spec/unit/lib/web/iframe_dsl_spec.rb +99 -0
- data/spec/unit/lib/web/page_dsl_spec.rb +52 -0
- data/spec/unit/lib/web/page_spec.rb +304 -0
- data/spec/unit/lib/web/page_validator_spec.rb +218 -0
- data/spec/unit/lib/web/section_dsl_spec.rb +165 -0
- data/spec/unit/lib/web/section_spec.rb +61 -0
- data/spec/unit/version_spec.rb +1 -1
- metadata +116 -203
- data/GETTING_STARTED.md +0 -774
- data/generators/cucumber/templates/cucumber.yml +0 -10
- data/generators/pages/pages_generator.rb +0 -21
- data/generators/pages/templates/example_menu.rb +0 -15
- data/generators/pages/templates/example_page.rb +0 -15
- data/generators/root/templates/Gemfile +0 -7
- data/generators/root/templates/boot.rb +0 -10
- data/lib/howitzer/blank_page.rb +0 -6
- data/lib/howitzer/capybara/dsl_ex.rb +0 -15
- data/lib/howitzer/capybara/settings.rb +0 -343
- data/lib/howitzer/helpers.rb +0 -230
- data/lib/howitzer/init.rb +0 -1
- data/lib/howitzer/mailgun/client.rb +0 -65
- data/lib/howitzer/mailgun/connector.rb +0 -34
- data/lib/howitzer/mailgun/response.rb +0 -28
- data/lib/howitzer/patches/rawler_patched.rb +0 -86
- data/lib/howitzer/settings.rb +0 -27
- data/lib/howitzer/utils/data_generator/data_storage.rb +0 -88
- data/lib/howitzer/utils/data_generator/gen.rb +0 -135
- data/lib/howitzer/utils/locator_store.rb +0 -217
- data/lib/howitzer/utils/log.rb +0 -139
- data/lib/howitzer/utils/page_validator.rb +0 -133
- data/lib/howitzer/vendor/firebug-1.12.1-fx.xpi +0 -0
- data/lib/howitzer/vendor/firepath-0.9.7-fx.xpi +0 -0
- data/lib/howitzer/web_page.rb +0 -253
- data/spec/active_resource.rb +0 -0
- data/spec/config/default.yml +0 -26
- data/spec/support/boot_helper.rb +0 -15
- data/spec/unit/generators/pages_generator_spec.rb +0 -33
- data/spec/unit/lib/capybara/dsl_ex_spec.rb +0 -60
- data/spec/unit/lib/capybara/settings_spec.rb +0 -441
- data/spec/unit/lib/helpers_spec.rb +0 -1129
- data/spec/unit/lib/mailgun/client_spec.rb +0 -36
- data/spec/unit/lib/mailgun/connector_spec.rb +0 -70
- data/spec/unit/lib/mailgun/response_spec.rb +0 -28
- data/spec/unit/lib/settings_spec.rb +0 -17
- data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +0 -80
- data/spec/unit/lib/utils/data_generator/gen_spec.rb +0 -90
- data/spec/unit/lib/utils/locator_store_spec.rb +0 -157
- data/spec/unit/lib/utils/log_spec.rb +0 -107
- data/spec/unit/lib/utils/page_validator_spec.rb +0 -265
- data/spec/unit/lib/web_page_spec.rb +0 -346
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/mailgun/client'
|
3
|
-
|
4
|
-
RSpec.describe Mailgun::Client do
|
5
|
-
let(:mg_obj) { Mailgun::Client.new('Fake-API-Key') }
|
6
|
-
describe '.new' do
|
7
|
-
subject { mg_obj }
|
8
|
-
it { expect { subject }.not_to raise_error }
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#get' do
|
12
|
-
let(:query_string){ {'skip' => '10', 'limit' => '5'} }
|
13
|
-
subject { mg_obj.get('test.com/bounces', query_string) }
|
14
|
-
context 'when simulation of client' do
|
15
|
-
before do
|
16
|
-
expect(RestClient::Resource).to receive(:new).once { Mailgun::UnitClient::new('Fake-API-Key', 'api.mailgun.net', 'v2') }
|
17
|
-
end
|
18
|
-
it do
|
19
|
-
expect(subject.body).to include('total_count')
|
20
|
-
expect(subject.body).to include('items')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
context 'when real client' do
|
24
|
-
let(:resource) { double }
|
25
|
-
before do
|
26
|
-
allow(resource).to receive('[]'){ resource }
|
27
|
-
allow(resource).to receive(:get).and_raise(StandardError, '401 Unauthorized: Forbidden')
|
28
|
-
allow(RestClient::Resource).to receive(:new) { resource }
|
29
|
-
end
|
30
|
-
it do
|
31
|
-
expect(log).to receive(:error).with(Howitzer::CommunicationError, '401 Unauthorized: Forbidden').once.and_call_original
|
32
|
-
expect { subject }.to raise_error(Howitzer::CommunicationError)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/mailgun/connector'
|
3
|
-
|
4
|
-
RSpec.describe Mailgun::Connector do
|
5
|
-
let(:connector) { Mailgun::Connector.instance }
|
6
|
-
let(:domain_name) { 'test@domain.com' }
|
7
|
-
describe '#client' do
|
8
|
-
subject { connector.client }
|
9
|
-
context 'when api_key is default' do
|
10
|
-
context 'when client is not initialized' do
|
11
|
-
it { is_expected.to be_an_instance_of Mailgun::Client }
|
12
|
-
end
|
13
|
-
context 'when client is already initialized' do
|
14
|
-
it do
|
15
|
-
object_id = connector.client.object_id
|
16
|
-
expect(subject.object_id).to eq(object_id)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
context 'when api_key is custom' do
|
21
|
-
let(:key) { 'some api key' }
|
22
|
-
subject { connector.client(key) }
|
23
|
-
it { is_expected.to be_an_instance_of Mailgun::Client }
|
24
|
-
end
|
25
|
-
context 'when api_key is nil' do
|
26
|
-
let(:key) { nil }
|
27
|
-
subject { connector.client(key) }
|
28
|
-
it do
|
29
|
-
expect(log).to receive(:error).with(Howitzer::InvalidApiKeyError, 'Api key can not be blank').once.and_call_original
|
30
|
-
expect { subject }.to raise_error(Howitzer::InvalidApiKeyError)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
context 'when api_key is blank string' do
|
34
|
-
let(:key) { '' }
|
35
|
-
subject { connector.client(key) }
|
36
|
-
it do
|
37
|
-
expect(log).to receive(:error).with(Howitzer::InvalidApiKeyError, 'Api key can not be blank').once.and_call_original
|
38
|
-
expect { subject }.to raise_error(Howitzer::InvalidApiKeyError)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
describe '#domain' do
|
43
|
-
subject { connector.domain }
|
44
|
-
context 'when domain is not set' do
|
45
|
-
before { connector.instance_variable_set(:@domain, nil)}
|
46
|
-
it do
|
47
|
-
expect(connector).to receive(:change_domain).once{ domain_name }
|
48
|
-
is_expected.to eq(domain_name)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
context 'when domain is already set' do
|
52
|
-
before do
|
53
|
-
expect(connector).to receive(:change_domain).never
|
54
|
-
connector.instance_variable_set(:@domain, domain_name)
|
55
|
-
end
|
56
|
-
it { is_expected.to eql(domain_name) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#change_domain' do
|
61
|
-
context 'when default' do
|
62
|
-
before { connector.change_domain }
|
63
|
-
it { expect(connector.instance_variable_get(:@domain)).to eq(settings.mailgun_domain)}
|
64
|
-
end
|
65
|
-
context 'when custom' do
|
66
|
-
before { connector.change_domain(domain_name) }
|
67
|
-
it { expect(connector.instance_variable_get(:@domain)).to eq(domain_name) }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/mailgun/client'
|
3
|
-
require 'howitzer/exceptions'
|
4
|
-
|
5
|
-
RSpec.describe Mailgun::Response do
|
6
|
-
let(:body) { {foo: 'bar'}.to_json }
|
7
|
-
let(:response) { double(:response, body: body, code: 201)}
|
8
|
-
describe '#body' do
|
9
|
-
subject { Mailgun::Response.new(response).body }
|
10
|
-
it { is_expected.to eq("{\"foo\":\"bar\"}")}
|
11
|
-
end
|
12
|
-
describe '#code' do
|
13
|
-
subject { Mailgun::Response.new(response).code }
|
14
|
-
it { is_expected.to eq(201)}
|
15
|
-
end
|
16
|
-
describe '#to_h' do
|
17
|
-
subject { Mailgun::Response.new(response).to_h }
|
18
|
-
context 'when possible parse body' do
|
19
|
-
it { is_expected.to eq({'foo' => 'bar'})}
|
20
|
-
end
|
21
|
-
context 'when impossible parse body' do
|
22
|
-
let(:body) { "123" }
|
23
|
-
it do
|
24
|
-
expect { subject }.to raise_error(Howitzer::ParseError)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'Settings' do
|
4
|
-
context '#settings' do
|
5
|
-
subject { settings }
|
6
|
-
context 'when method called two times' do
|
7
|
-
let(:other_settings) { settings }
|
8
|
-
it { is_expected.to equal(other_settings) }
|
9
|
-
it { expect(other_settings).to be_a_kind_of(SexySettings::Base) }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
context 'SexySettings configuration' do
|
13
|
-
subject { SexySettings.configuration }
|
14
|
-
it { expect(subject.path_to_custom_settings).to include('config/custom.yml') }
|
15
|
-
it { expect(subject.path_to_default_settings).to include('config/default.yml') }
|
16
|
-
end
|
17
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/utils/data_generator/data_storage'
|
3
|
-
|
4
|
-
RSpec.describe 'DataGenerator' do
|
5
|
-
describe 'DataStorage' do
|
6
|
-
before { DataGenerator::DataStorage.data.clear }
|
7
|
-
describe '.store' do
|
8
|
-
subject { DataGenerator::DataStorage.store(ns, 7, :halt) }
|
9
|
-
context 'when namespace specified' do
|
10
|
-
let(:ns) { :user }
|
11
|
-
it 'should return value' do
|
12
|
-
is_expected.to eql(:halt)
|
13
|
-
end
|
14
|
-
it 'should store namespace value' do
|
15
|
-
subject
|
16
|
-
expect(DataGenerator::DataStorage.data[:user]).to eql({7 => :halt})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
context 'when namespace empty' do
|
20
|
-
let(:ns) { nil }
|
21
|
-
it { expect {subject}.to raise_error(RuntimeError, 'Data storage namespace can not be empty') }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
describe '.extract' do
|
25
|
-
subject { DataGenerator::DataStorage.extract(ns, key) }
|
26
|
-
before { DataGenerator::DataStorage.data[:user] = {7 => :exit} }
|
27
|
-
describe 'when namespace specified' do
|
28
|
-
let(:ns) { :user }
|
29
|
-
context 'and namespace key found' do
|
30
|
-
let(:key) { 7 }
|
31
|
-
it { is_expected.to eql(:exit) }
|
32
|
-
end
|
33
|
-
context 'and namespace key not found' do
|
34
|
-
let(:key) { 5 }
|
35
|
-
it { is_expected.to be_nil }
|
36
|
-
end
|
37
|
-
context 'but namespace key not specified' do
|
38
|
-
let(:key) { nil }
|
39
|
-
it { is_expected.to eql({ 7 => :exit }) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
context 'when namespace not found' do
|
43
|
-
let(:ns) { :guest }
|
44
|
-
let(:key) { 11 }
|
45
|
-
it { is_expected.to be_nil }
|
46
|
-
end
|
47
|
-
context 'when namespace not specified' do
|
48
|
-
let(:ns) { nil }
|
49
|
-
let(:key) { nil }
|
50
|
-
it { expect {subject}.to raise_error(RuntimeError, 'Data storage namespace can not be empty') }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
describe '.clear_ns' do
|
54
|
-
subject { DataGenerator::DataStorage.clear_ns(:user) }
|
55
|
-
before { DataGenerator::DataStorage.data[:user]= {7 => :exit}}
|
56
|
-
it 'should return empty hash' do
|
57
|
-
subject
|
58
|
-
adata = DataGenerator::DataStorage.instance_variable_get(:@data)
|
59
|
-
expect(adata[:user]).to eql({})
|
60
|
-
end
|
61
|
-
end
|
62
|
-
describe '.clear_all_ns' do
|
63
|
-
before do
|
64
|
-
DataGenerator::DataStorage.store('sauce', :status, false)
|
65
|
-
DataGenerator::DataStorage.store(:foo, 'foo', 'some value1')
|
66
|
-
DataGenerator::DataStorage.store(:bar, 'bar', 'some value2')
|
67
|
-
DataGenerator::DataStorage.store(:baz, 'baz', 'some value3')
|
68
|
-
end
|
69
|
-
context 'when default argument' do
|
70
|
-
before { DataGenerator::DataStorage.clear_all_ns }
|
71
|
-
it { expect(DataGenerator::DataStorage.data).to eq({'sauce' =>{:status=>false}, :foo=>{}, :bar=>{}, :baz=>{}}) }
|
72
|
-
end
|
73
|
-
context 'when custom argument' do
|
74
|
-
let(:exception_list) { [:foo, :bar] }
|
75
|
-
before { DataGenerator::DataStorage.clear_all_ns(exception_list) }
|
76
|
-
it { expect(DataGenerator::DataStorage.data).to eq({'sauce' =>{}, :foo=>{'foo' => 'some value1'}, :bar=>{'bar' => 'some value2'}, :baz=>{}}) }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/utils/data_generator/gen'
|
3
|
-
|
4
|
-
RSpec.describe 'DataGenerator' do
|
5
|
-
describe 'Gen' do
|
6
|
-
describe '.user' do
|
7
|
-
subject { DataGenerator::Gen.user(params) }
|
8
|
-
before do
|
9
|
-
allow(settings).to receive(:def_test_pass) { 'test_pass' }
|
10
|
-
allow(settings).to receive(:mailgun_domain) { 'mail.com' }
|
11
|
-
allow(DataGenerator::Gen).to receive(:serial) { '012345678abcde' }
|
12
|
-
end
|
13
|
-
context 'when params specified' do
|
14
|
-
let(:params) { { login: 'alex', password: 'pa$$w0rd', mailbox: 'member@test.com' } }
|
15
|
-
it { is_expected.to be_an_instance_of DataGenerator::Gen::User }
|
16
|
-
it { expect(subject.email).to eql 'u012345678abcde@mail.com' }
|
17
|
-
it do
|
18
|
-
email_nm = subject.instance_variable_get(:@email_name)
|
19
|
-
expect(email_nm).to eql 'u012345678abcde'
|
20
|
-
end
|
21
|
-
it { expect(subject.domain).to eql 'mail.com' }
|
22
|
-
it { expect(subject.login).to eql 'alex' }
|
23
|
-
it { expect(subject.password).to eql 'pa$$w0rd' }
|
24
|
-
it { expect(subject.first_name).to eql 'FirstName012345678abcde' }
|
25
|
-
it { expect(subject.last_name).to eql 'LastName012345678abcde' }
|
26
|
-
end
|
27
|
-
context 'with empty params' do
|
28
|
-
let(:params) { {} }
|
29
|
-
it { is_expected.to be_an_instance_of DataGenerator::Gen::User }
|
30
|
-
it { expect(subject.email).to eql 'u012345678abcde@mail.com' }
|
31
|
-
it do
|
32
|
-
email_nm = subject.instance_variable_get(:@email_name)
|
33
|
-
expect(email_nm).to eql 'u012345678abcde'
|
34
|
-
end
|
35
|
-
it { expect(subject.domain).to eql 'mail.com' }
|
36
|
-
it { expect(subject.login).to eql 'u012345678abcde' }
|
37
|
-
it { expect(subject.password).to eql 'test_pass' }
|
38
|
-
it { expect(subject.first_name).to eql 'FirstName012345678abcde' }
|
39
|
-
it { expect(subject.last_name).to eql 'LastName012345678abcde' }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
describe '.given_user_by_number' do
|
43
|
-
subject { DataGenerator::Gen.given_user_by_number(7) }
|
44
|
-
before { stub_const('DataGenerator::DataStorage', double) }
|
45
|
-
context 'when namespace key found' do
|
46
|
-
before { expect(DataGenerator::DataStorage).to receive(:extract).with('user', 7) { :namespace_value } }
|
47
|
-
it { is_expected.to eql(:namespace_value) }
|
48
|
-
end
|
49
|
-
context 'when namespace key not found' do
|
50
|
-
let(:dat) { :data_store }
|
51
|
-
before do
|
52
|
-
allow(DataGenerator::Gen).to receive(:user) { dat }
|
53
|
-
expect(DataGenerator::DataStorage).to receive(:extract).with('user', 7) { nil }
|
54
|
-
allow(DataGenerator::DataStorage).to receive(:store).with('user', 7, dat)
|
55
|
-
end
|
56
|
-
it { is_expected.to eql :data_store }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
describe '.serial' do
|
60
|
-
subject { DataGenerator::Gen.serial }
|
61
|
-
let(:ser) { 1 }
|
62
|
-
context 'received value should conform to template' do
|
63
|
-
let(:ser) { subject }
|
64
|
-
it { expect(ser).to match /\d{9}\w{5}/ }
|
65
|
-
end
|
66
|
-
context 'received values should be different' do
|
67
|
-
it { is_expected.to_not eql ser }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
describe 'User' do
|
71
|
-
describe '#initialize' do
|
72
|
-
subject { DataGenerator::Gen::User.new(params) }
|
73
|
-
let(:params) { { email: 'alex.petrenko@mail.com', login: 'alex', password: 'pa$$w0rd',
|
74
|
-
first_name: 'Alexey', last_name: 'Petrenko', mailbox: 'member@test.com' } }
|
75
|
-
it { is_expected.to be_an_instance_of DataGenerator::Gen::User }
|
76
|
-
it { expect(subject.email).to eql 'alex.petrenko@mail.com' }
|
77
|
-
it do
|
78
|
-
email_nm = subject.instance_variable_get(:@email_name)
|
79
|
-
expect(email_nm).to eql 'alex.petrenko'
|
80
|
-
end
|
81
|
-
it { expect(subject.domain).to eql 'mail.com' }
|
82
|
-
it { expect(subject.login).to eql 'alex' }
|
83
|
-
it { expect(subject.password).to eql 'pa$$w0rd' }
|
84
|
-
it { expect(subject.first_name).to eql 'Alexey' }
|
85
|
-
it { expect(subject.last_name).to eql 'Petrenko' }
|
86
|
-
it { expect(subject.full_name).to eql 'Alexey Petrenko' }
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/utils/locator_store'
|
3
|
-
|
4
|
-
RSpec.describe 'Locator store' do
|
5
|
-
let(:bad_name) { 'name' }
|
6
|
-
let(:error) { Howitzer::LocatorNotDefinedError }
|
7
|
-
|
8
|
-
shared_examples 'locator methods' do |prefix, web_page|
|
9
|
-
describe "#{prefix}locator" do
|
10
|
-
context 'when bad locator given' do
|
11
|
-
subject { web_page.locator(bad_name) }
|
12
|
-
it do
|
13
|
-
expect(log).to receive(:error).with(error, bad_name).once.and_call_original
|
14
|
-
expect { subject }.to raise_error(error)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
context 'when CSS locator given' do
|
18
|
-
before { web_page.add_locator :base_locator, 'base_locator' }
|
19
|
-
subject { web_page.locator(:base_locator) }
|
20
|
-
it { is_expected.to eq('base_locator') }
|
21
|
-
end
|
22
|
-
context 'when XPATH locator given' do
|
23
|
-
before { web_page.add_locator :test_xpath, xpath: "//select[@id='modelOptions']/option[@value='m6']" }
|
24
|
-
subject { web_page.locator(:test_xpath) }
|
25
|
-
it { is_expected.to eq([:xpath, "//select[@id='modelOptions']/option[@value='m6']"]) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#{prefix}link_locator" do
|
30
|
-
context 'when bad locator given' do
|
31
|
-
subject { web_page.link_locator(bad_name) }
|
32
|
-
it { expect {subject}. to raise_error(error) }
|
33
|
-
end
|
34
|
-
context 'when correct locator given' do
|
35
|
-
before { web_page.add_link_locator :link_locator, 'link_locator' }
|
36
|
-
subject { web_page.link_locator(:link_locator) }
|
37
|
-
it { is_expected.to eq('link_locator') }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#{prefix}field_locator" do
|
42
|
-
context 'when bad locator given' do
|
43
|
-
subject { web_page.field_locator(bad_name) }
|
44
|
-
it { expect {subject}. to raise_error(error) }
|
45
|
-
end
|
46
|
-
context 'when correct locator given' do
|
47
|
-
before { web_page.add_field_locator :field_locator, 'field_locator' }
|
48
|
-
subject { web_page.field_locator(:field_locator) }
|
49
|
-
it { is_expected.to eq('field_locator') }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#{prefix}button_locator" do
|
54
|
-
context 'when bad locator given' do
|
55
|
-
subject { web_page.button_locator(bad_name) }
|
56
|
-
it { expect {subject}. to raise_error(error) }
|
57
|
-
end
|
58
|
-
context 'when correct locator given' do
|
59
|
-
before { web_page.add_button_locator :button_locator, 'button_locator' }
|
60
|
-
subject { web_page.button_locator(:button_locator) }
|
61
|
-
it { is_expected.to eq('button_locator') }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "#{prefix}find_element" do
|
66
|
-
context 'when existing locator name given' do
|
67
|
-
context 'of base type' do
|
68
|
-
before { web_page.add_locator :test_locator, '.foo' }
|
69
|
-
subject { web_page.find_element(name) }
|
70
|
-
context 'as string' do
|
71
|
-
let(:name) { 'test_locator' }
|
72
|
-
it do
|
73
|
-
expect(web_page.is_a?(Class) ? web_page : web_page.class).to receive(:find).with('.foo')
|
74
|
-
subject
|
75
|
-
end
|
76
|
-
end
|
77
|
-
context 'as symbol' do
|
78
|
-
let(:name) { :test_locator }
|
79
|
-
it do
|
80
|
-
expect(web_page.is_a?(Class) ? web_page : web_page.class).to receive(:find).with('.foo')
|
81
|
-
subject
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
context 'when link locator or other' do
|
86
|
-
before { web_page.add_link_locator :test_link_locator, 'foo' }
|
87
|
-
subject { web_page.find_element(:test_link_locator) }
|
88
|
-
it do
|
89
|
-
expect(web_page.is_a?(Class) ? web_page : web_page.class).to receive(:find_link).with('foo')
|
90
|
-
subject
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
context 'when not existing locator name' do
|
95
|
-
subject { web_page.find_element(:unknown_locator) }
|
96
|
-
it { expect{ subject }.to raise_error(Howitzer::LocatorNotDefinedError, 'unknown_locator') }
|
97
|
-
end
|
98
|
-
end
|
99
|
-
describe "#{prefix}first_element" do
|
100
|
-
context 'when existing locator name given' do
|
101
|
-
context 'of base type' do
|
102
|
-
before { web_page.add_locator :test_locator, '.foo' }
|
103
|
-
subject { web_page.first_element(name) }
|
104
|
-
context 'as string' do
|
105
|
-
let(:name) { 'test_locator' }
|
106
|
-
it do
|
107
|
-
expect(web_page.is_a?(Class) ? web_page : web_page.class).to receive(:first).with('.foo')
|
108
|
-
subject
|
109
|
-
end
|
110
|
-
end
|
111
|
-
context 'as symbol' do
|
112
|
-
let(:name) { :test_locator }
|
113
|
-
it do
|
114
|
-
expect(web_page.is_a?(Class) ? web_page : web_page.class).to receive(:first).with('.foo')
|
115
|
-
subject
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
context 'when link locator or other' do
|
120
|
-
before { web_page.add_link_locator :test_link_locator, 'foo' }
|
121
|
-
subject { web_page.first_element(:test_link_locator) }
|
122
|
-
it do
|
123
|
-
expect(web_page.is_a?(Class) ? web_page : web_page.class).to receive(:first).with(:link, 'foo')
|
124
|
-
subject
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
context 'when not existing locator name' do
|
129
|
-
subject { web_page.first_element(:unknown_locator) }
|
130
|
-
it { expect{ subject }.to raise_error(Howitzer::LocatorNotDefinedError, 'unknown_locator') }
|
131
|
-
end
|
132
|
-
end
|
133
|
-
describe "#{prefix}apply" do
|
134
|
-
context 'when bad locator given' do
|
135
|
-
before { web_page.add_locator :test_locator, lambda{|test| test} }
|
136
|
-
let(:locator) { lambda{|test| test} }
|
137
|
-
subject { web_page.apply(locator, 'test') }
|
138
|
-
it { expect {subject}.to raise_error(NoMethodError) }
|
139
|
-
end
|
140
|
-
context 'when correct locator given' do
|
141
|
-
before { web_page.add_locator :test_locator, lambda{|location_name| {xpath: ".//a[contains(.,'#{location_name}')]"}} }
|
142
|
-
let(:locator) { lambda{|location_name| {xpath: ".//a[contains(.,'#{location_name}')]"}} }
|
143
|
-
subject { web_page.apply(locator, 'Kiev') }
|
144
|
-
it { is_expected.to eq([:xpath, ".//a[contains(.,'Kiev')]"]) }
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'Class methods' do
|
150
|
-
it_behaves_like 'locator methods', '.', Class.new{ include LocatorStore }
|
151
|
-
end
|
152
|
-
|
153
|
-
context 'Instance methods' do
|
154
|
-
it_behaves_like 'locator methods', '#', Class.new{ include LocatorStore }.new
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|