howitzer 2.0.3 → 2.3.0
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +69 -11
- data/LICENSE +1 -1
- data/README.md +21 -17
- data/bin/howitzer +7 -6
- data/generators/base_generator.rb +31 -17
- data/generators/config/config_generator.rb +11 -3
- data/generators/config/templates/boot.rb +3 -3
- data/generators/config/templates/capybara.rb +6 -131
- data/generators/config/templates/default.yml +34 -13
- data/generators/config/templates/drivers/appium.rb +25 -0
- data/generators/config/templates/drivers/browserstack.rb +23 -0
- data/generators/config/templates/drivers/crossbrowsertesting.rb +29 -0
- data/generators/config/templates/drivers/headless_chrome.rb +15 -0
- data/generators/config/templates/drivers/headless_firefox.rb +23 -0
- data/generators/config/templates/drivers/sauce.rb +25 -0
- data/generators/config/templates/drivers/selenium.rb +24 -0
- data/generators/config/templates/drivers/selenium_grid.rb +31 -0
- data/generators/config/templates/drivers/testingbot.rb +24 -0
- data/generators/cucumber/cucumber_generator.rb +2 -2
- data/generators/cucumber/templates/common_steps.rb +3 -3
- data/generators/cucumber/templates/cucumber.rake +5 -13
- data/generators/cucumber/templates/cuke_sniffer.rake +2 -2
- data/generators/cucumber/templates/env.rb +9 -1
- data/generators/cucumber/templates/hooks.rb +8 -2
- data/generators/cucumber/templates/transformers.rb +11 -25
- data/generators/emails/emails_generator.rb +2 -2
- data/generators/emails/templates/example_email.rb +1 -1
- data/generators/prerequisites/prerequisites_generator.rb +3 -3
- data/generators/prerequisites/templates/base.rb +1 -1
- data/generators/prerequisites/templates/{factory_girl.rb → factory_bot.rb} +7 -6
- data/generators/prerequisites/templates/users.rb +1 -1
- data/generators/root/root_generator.rb +3 -3
- data/generators/root/templates/Gemfile.erb +16 -22
- data/generators/rspec/rspec_generator.rb +2 -2
- data/generators/rspec/templates/rspec.rake +8 -8
- data/generators/rspec/templates/spec_helper.rb +6 -5
- data/generators/tasks/tasks_generator.rb +2 -2
- data/generators/turnip/templates/spec_helper.rb +6 -5
- data/generators/turnip/turnip_generator.rb +2 -2
- data/generators/web/templates/example_page.rb +1 -1
- data/generators/web/web_generator.rb +2 -2
- data/lib/howitzer/cache.rb +20 -19
- data/lib/howitzer/capybara_helpers.rb +58 -13
- data/lib/howitzer/email.rb +3 -2
- data/lib/howitzer/exceptions.rb +21 -20
- data/lib/howitzer/gmail_api/client.rb +31 -0
- data/lib/howitzer/gmail_api.rb +7 -0
- data/lib/howitzer/log.rb +6 -6
- data/lib/howitzer/mail_adapters/gmail.rb +96 -0
- data/lib/howitzer/mail_adapters/mailgun.rb +4 -2
- data/lib/howitzer/mail_adapters/mailtrap.rb +108 -0
- data/lib/howitzer/mailgun_api/client.rb +3 -2
- data/lib/howitzer/mailgun_api/connector.rb +1 -0
- data/lib/howitzer/mailgun_api/response.rb +1 -2
- data/lib/howitzer/mailtrap_api/client.rb +52 -0
- data/lib/howitzer/mailtrap_api.rb +7 -0
- data/lib/howitzer/meta/actions.rb +35 -0
- data/lib/howitzer/meta/element.rb +40 -0
- data/lib/howitzer/meta/entry.rb +62 -0
- data/lib/howitzer/meta/iframe.rb +41 -0
- data/lib/howitzer/meta/section.rb +30 -0
- data/lib/howitzer/meta.rb +11 -0
- data/lib/howitzer/utils/string_extensions.rb +6 -2
- data/lib/howitzer/version.rb +1 -1
- data/lib/howitzer/web/base_section.rb +1 -1
- data/lib/howitzer/web/capybara_context_holder.rb +1 -0
- data/lib/howitzer/web/capybara_methods_proxy.rb +15 -6
- data/lib/howitzer/web/element_dsl.rb +104 -44
- data/lib/howitzer/web/iframe_dsl.rb +23 -3
- data/lib/howitzer/web/page.rb +16 -4
- data/lib/howitzer/web/page_dsl.rb +19 -7
- data/lib/howitzer/web/page_validator.rb +27 -26
- data/lib/howitzer/web/section.rb +13 -2
- data/lib/howitzer/web/section_dsl.rb +65 -30
- data/lib/howitzer.rb +66 -10
- metadata +67 -133
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -44
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -7
- data/Gemfile +0 -13
- data/MAINTENANCE.md +0 -32
- data/Rakefile +0 -22
- data/features/cli_help.feature +0 -31
- data/features/cli_new.feature +0 -349
- data/features/cli_unknown.feature +0 -17
- data/features/cli_update.feature +0 -178
- data/features/cli_version.feature +0 -14
- data/features/step_definitions/common_steps.rb +0 -29
- data/features/support/env.rb +0 -1
- data/features/support/transformers.rb +0 -3
- data/generators/root/templates/.gitignore +0 -21
- data/generators/root/templates/.rubocop.yml +0 -35
- data/generators/turnip/templates/.rspec +0 -1
- data/howitzer.gemspec +0 -37
- data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
- data/spec/config/custom.yml +0 -9
- data/spec/spec_helper.rb +0 -72
- data/spec/support/generator_helper.rb +0 -21
- data/spec/support/logger_helper.rb +0 -13
- data/spec/support/mailgun_unit_client.rb +0 -68
- data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
- data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
- data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
- data/spec/support/shared_examples/element_dsl.rb +0 -242
- data/spec/unit/generators/base_generator_spec.rb +0 -272
- data/spec/unit/generators/config_generator_spec.rb +0 -38
- data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
- data/spec/unit/generators/emails_generator_spec.rb +0 -35
- data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
- data/spec/unit/generators/root_generator_spec.rb +0 -72
- data/spec/unit/generators/rspec_generator_spec.rb +0 -36
- data/spec/unit/generators/tasks_generator_spec.rb +0 -31
- data/spec/unit/generators/turnip_generator_spec.rb +0 -52
- data/spec/unit/generators/web_generator_spec.rb +0 -52
- data/spec/unit/lib/cache_spec.rb +0 -85
- data/spec/unit/lib/capybara_helpers_spec.rb +0 -696
- data/spec/unit/lib/email_spec.rb +0 -186
- data/spec/unit/lib/howitzer_spec.rb +0 -40
- data/spec/unit/lib/init_spec.rb +0 -2
- data/spec/unit/lib/log_spec.rb +0 -122
- data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
- data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -163
- data/spec/unit/lib/mailgun_api/client_spec.rb +0 -58
- data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
- data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
- data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
- data/spec/unit/lib/web/base_section_spec.rb +0 -43
- data/spec/unit/lib/web/element_dsl_spec.rb +0 -22
- data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -144
- data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
- data/spec/unit/lib/web/page_spec.rb +0 -349
- data/spec/unit/lib/web/page_validator_spec.rb +0 -276
- data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
- data/spec/unit/lib/web/section_spec.rb +0 -63
- data/spec/unit/version_spec.rb +0 -8
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe 'Generators' do
|
|
4
|
-
let(:destination) { Howitzer::BaseGenerator.destination }
|
|
5
|
-
let(:output) { StringIO.new }
|
|
6
|
-
subject { file_tree_info(destination) }
|
|
7
|
-
before do
|
|
8
|
-
Howitzer::BaseGenerator.logger = output
|
|
9
|
-
generator_name.new({})
|
|
10
|
-
end
|
|
11
|
-
after { FileUtils.rm_r(destination) }
|
|
12
|
-
|
|
13
|
-
describe Howitzer::PrerequisitesGenerator do
|
|
14
|
-
let(:generator_name) { described_class }
|
|
15
|
-
let(:expected_result) do
|
|
16
|
-
[
|
|
17
|
-
{ name: '/prerequisites', is_directory: true },
|
|
18
|
-
{ name: '/prerequisites/factories', is_directory: true },
|
|
19
|
-
{
|
|
20
|
-
name: '/prerequisites/factories/users.rb',
|
|
21
|
-
is_directory: false, size: template_file_size('prerequisites', 'users.rb')
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: '/prerequisites/factory_girl.rb',
|
|
25
|
-
is_directory: false, size: template_file_size('prerequisites', 'factory_girl.rb')
|
|
26
|
-
},
|
|
27
|
-
{ name: '/prerequisites/models', is_directory: true },
|
|
28
|
-
{
|
|
29
|
-
name: '/prerequisites/models/base.rb',
|
|
30
|
-
is_directory: false,
|
|
31
|
-
size: template_file_size('prerequisites', 'base.rb')
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: '/prerequisites/models/user.rb',
|
|
35
|
-
is_directory: false,
|
|
36
|
-
size: template_file_size('prerequisites', 'user.rb')
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
end
|
|
40
|
-
it { is_expected.to eql(expected_result) }
|
|
41
|
-
describe 'output' do
|
|
42
|
-
let(:expected_output) do
|
|
43
|
-
" * Pre-requisites integration to the framework ...
|
|
44
|
-
Added 'prerequisites/factory_girl.rb' file
|
|
45
|
-
Added 'prerequisites/factories/users.rb' file
|
|
46
|
-
Added 'prerequisites/models/base.rb' file
|
|
47
|
-
Added 'prerequisites/models/user.rb' file\n"
|
|
48
|
-
end
|
|
49
|
-
subject { output.string }
|
|
50
|
-
it { is_expected.to eql(expected_output) }
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe 'Generators' do
|
|
4
|
-
let(:destination) { Howitzer::BaseGenerator.destination }
|
|
5
|
-
let(:output) { StringIO.new }
|
|
6
|
-
subject { file_tree_info(destination) }
|
|
7
|
-
before do
|
|
8
|
-
Howitzer::BaseGenerator.logger = output
|
|
9
|
-
generator_name.new(options)
|
|
10
|
-
end
|
|
11
|
-
after { FileUtils.rm_r(destination) }
|
|
12
|
-
|
|
13
|
-
describe Howitzer::RootGenerator do
|
|
14
|
-
let(:generator_name) { described_class }
|
|
15
|
-
let(:expected_result) do
|
|
16
|
-
[
|
|
17
|
-
{ name: '/.gitignore', is_directory: false, size: 196 },
|
|
18
|
-
{ name: '/.rubocop.yml', is_directory: false, size: 634 },
|
|
19
|
-
{ name: '/Gemfile', is_directory: false, size: 625 },
|
|
20
|
-
{ name: '/Rakefile', is_directory: false, size: template_file_size('root', 'Rakefile') }
|
|
21
|
-
]
|
|
22
|
-
end
|
|
23
|
-
let(:options) { {} }
|
|
24
|
-
it { is_expected.to eql(expected_result) }
|
|
25
|
-
describe 'output' do
|
|
26
|
-
subject { output.string }
|
|
27
|
-
context 'when options is empty' do
|
|
28
|
-
let(:expected_output) do
|
|
29
|
-
" * Root files generation ...
|
|
30
|
-
Added '.gitignore' file
|
|
31
|
-
Added '.rubocop.yml' file
|
|
32
|
-
Added 'Rakefile' file
|
|
33
|
-
Added template 'Gemfile.erb' with params '{}' to destination 'Gemfile'\n"
|
|
34
|
-
end
|
|
35
|
-
it { is_expected.to eql(expected_output) }
|
|
36
|
-
end
|
|
37
|
-
context 'when options is rspec => true' do
|
|
38
|
-
let(:expected_output) do
|
|
39
|
-
" * Root files generation ...
|
|
40
|
-
Added '.gitignore' file
|
|
41
|
-
Added '.rubocop.yml' file
|
|
42
|
-
Added 'Rakefile' file
|
|
43
|
-
Added template 'Gemfile.erb' with params '{:rspec=>true}' to destination 'Gemfile'\n"
|
|
44
|
-
end
|
|
45
|
-
let(:options) { { rspec: true } }
|
|
46
|
-
it { is_expected.to eql(expected_output) }
|
|
47
|
-
end
|
|
48
|
-
context 'when options is cucumber => cucumber' do
|
|
49
|
-
let(:expected_output) do
|
|
50
|
-
" * Root files generation ...
|
|
51
|
-
Added '.gitignore' file
|
|
52
|
-
Added '.rubocop.yml' file
|
|
53
|
-
Added 'Rakefile' file
|
|
54
|
-
Added template 'Gemfile.erb' with params '{:cucumber=>true}' to destination 'Gemfile'\n"
|
|
55
|
-
end
|
|
56
|
-
let(:options) { { cucumber: true } }
|
|
57
|
-
it { is_expected.to eql(expected_output) }
|
|
58
|
-
end
|
|
59
|
-
context 'when options is turnip => true' do
|
|
60
|
-
let(:expected_output) do
|
|
61
|
-
" * Root files generation ...
|
|
62
|
-
Added '.gitignore' file
|
|
63
|
-
Added '.rubocop.yml' file
|
|
64
|
-
Added 'Rakefile' file
|
|
65
|
-
Added template 'Gemfile.erb' with params '{:turnip=>true}' to destination 'Gemfile'\n"
|
|
66
|
-
end
|
|
67
|
-
let(:options) { { turnip: true } }
|
|
68
|
-
it { is_expected.to eql(expected_output) }
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe 'Generators' do
|
|
4
|
-
let(:destination) { Howitzer::BaseGenerator.destination }
|
|
5
|
-
let(:output) { StringIO.new }
|
|
6
|
-
subject { file_tree_info(destination) }
|
|
7
|
-
before do
|
|
8
|
-
Howitzer::BaseGenerator.logger = output
|
|
9
|
-
generator_name.new(rspec: true)
|
|
10
|
-
end
|
|
11
|
-
after { FileUtils.rm_r(destination) }
|
|
12
|
-
|
|
13
|
-
describe Howitzer::RspecGenerator do
|
|
14
|
-
let(:generator_name) { described_class }
|
|
15
|
-
let(:expected_result) do
|
|
16
|
-
[
|
|
17
|
-
{ name: '/spec', is_directory: true },
|
|
18
|
-
{ name: '/spec/example_spec.rb', is_directory: false, size: template_file_size('rspec', 'example_spec.rb') },
|
|
19
|
-
{ name: '/spec/spec_helper.rb', is_directory: false, size: template_file_size('rspec', 'spec_helper.rb') },
|
|
20
|
-
{ name: '/tasks', is_directory: true },
|
|
21
|
-
{ name: '/tasks/rspec.rake', is_directory: false, size: template_file_size('rspec', 'rspec.rake') }
|
|
22
|
-
]
|
|
23
|
-
end
|
|
24
|
-
it { is_expected.to eql(expected_result) }
|
|
25
|
-
describe 'output' do
|
|
26
|
-
let(:expected_output) do
|
|
27
|
-
" * RSpec integration to the framework ...
|
|
28
|
-
Added 'spec/spec_helper.rb' file
|
|
29
|
-
Added 'spec/example_spec.rb' file
|
|
30
|
-
Added 'tasks/rspec.rake' file\n"
|
|
31
|
-
end
|
|
32
|
-
subject { output.string }
|
|
33
|
-
it { is_expected.to eql(expected_output) }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe 'Generators' do
|
|
4
|
-
let(:destination) { Howitzer::BaseGenerator.destination }
|
|
5
|
-
let(:output) { StringIO.new }
|
|
6
|
-
subject { file_tree_info(destination) }
|
|
7
|
-
before do
|
|
8
|
-
Howitzer::BaseGenerator.logger = output
|
|
9
|
-
generator_name.new({})
|
|
10
|
-
end
|
|
11
|
-
after { FileUtils.rm_r(destination) }
|
|
12
|
-
|
|
13
|
-
describe Howitzer::TasksGenerator do
|
|
14
|
-
let(:generator_name) { described_class }
|
|
15
|
-
let(:expected_result) do
|
|
16
|
-
[
|
|
17
|
-
{ name: '/tasks', is_directory: true },
|
|
18
|
-
{ name: '/tasks/common.rake', is_directory: false, size: template_file_size('tasks', 'common.rake') }
|
|
19
|
-
]
|
|
20
|
-
end
|
|
21
|
-
it { is_expected.to eql(expected_result) }
|
|
22
|
-
describe 'output' do
|
|
23
|
-
let(:expected_output) do
|
|
24
|
-
" * Base rake task generation ...
|
|
25
|
-
Added 'tasks/common.rake' file\n"
|
|
26
|
-
end
|
|
27
|
-
subject { output.string }
|
|
28
|
-
it { is_expected.to eql(expected_output) }
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe 'Generators' do
|
|
4
|
-
let(:destination) { Howitzer::BaseGenerator.destination }
|
|
5
|
-
let(:output) { StringIO.new }
|
|
6
|
-
subject { file_tree_info(destination) }
|
|
7
|
-
before do
|
|
8
|
-
Howitzer::BaseGenerator.logger = output
|
|
9
|
-
generator_name.new(turnip: true)
|
|
10
|
-
end
|
|
11
|
-
after { FileUtils.rm_r(destination) }
|
|
12
|
-
|
|
13
|
-
describe Howitzer::TurnipGenerator do
|
|
14
|
-
let(:generator_name) { described_class }
|
|
15
|
-
let(:expected_result) do
|
|
16
|
-
[
|
|
17
|
-
{ name: '/.rspec', is_directory: false, size: 15 },
|
|
18
|
-
{ name: '/spec', is_directory: true },
|
|
19
|
-
{ name: '/spec/acceptance', is_directory: true },
|
|
20
|
-
{
|
|
21
|
-
name: '/spec/acceptance/example.feature',
|
|
22
|
-
is_directory: false,
|
|
23
|
-
size: template_file_size('turnip', 'example.feature')
|
|
24
|
-
},
|
|
25
|
-
{ name: '/spec/spec_helper.rb', is_directory: false, size: template_file_size('turnip', 'spec_helper.rb') },
|
|
26
|
-
{ name: '/spec/steps', is_directory: true },
|
|
27
|
-
{
|
|
28
|
-
name: '/spec/steps/common_steps.rb',
|
|
29
|
-
is_directory: false,
|
|
30
|
-
size: template_file_size('turnip', 'common_steps.rb')
|
|
31
|
-
},
|
|
32
|
-
{ name: '/spec/turnip_helper.rb', is_directory: false, size: template_file_size('turnip', 'turnip_helper.rb') },
|
|
33
|
-
{ name: '/tasks', is_directory: true },
|
|
34
|
-
{ name: '/tasks/turnip.rake', is_directory: false, size: template_file_size('turnip', 'turnip.rake') }
|
|
35
|
-
]
|
|
36
|
-
end
|
|
37
|
-
it { is_expected.to eql(expected_result) }
|
|
38
|
-
describe 'output' do
|
|
39
|
-
let(:expected_output) do
|
|
40
|
-
" * Turnip integration to the framework ...
|
|
41
|
-
Added '.rspec' file
|
|
42
|
-
Added 'spec/spec_helper.rb' file
|
|
43
|
-
Added 'spec/turnip_helper.rb' file
|
|
44
|
-
Added 'spec/acceptance/example.feature' file
|
|
45
|
-
Added 'spec/steps/common_steps.rb' file
|
|
46
|
-
Added 'tasks/turnip.rake' file\n"
|
|
47
|
-
end
|
|
48
|
-
subject { output.string }
|
|
49
|
-
it { is_expected.to eql(expected_output) }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe 'Generators' do
|
|
4
|
-
let(:destination) { Howitzer::BaseGenerator.destination }
|
|
5
|
-
let(:output) { StringIO.new }
|
|
6
|
-
subject { file_tree_info(destination) }
|
|
7
|
-
before do
|
|
8
|
-
Howitzer::BaseGenerator.logger = output
|
|
9
|
-
generator_name.new({})
|
|
10
|
-
end
|
|
11
|
-
after { FileUtils.rm_r(destination) }
|
|
12
|
-
|
|
13
|
-
describe Howitzer::WebGenerator do
|
|
14
|
-
let(:generator_name) { described_class }
|
|
15
|
-
let(:expected_result) do
|
|
16
|
-
[
|
|
17
|
-
{
|
|
18
|
-
name: '/web',
|
|
19
|
-
is_directory: true
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: '/web/pages',
|
|
23
|
-
is_directory: true
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: '/web/pages/example_page.rb',
|
|
27
|
-
is_directory: false,
|
|
28
|
-
size: template_file_size('web', 'example_page.rb')
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: '/web/sections',
|
|
32
|
-
is_directory: true
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: '/web/sections/menu_section.rb',
|
|
36
|
-
is_directory: false,
|
|
37
|
-
size: template_file_size('web', 'menu_section.rb')
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
end
|
|
41
|
-
it { is_expected.to eql(expected_result) }
|
|
42
|
-
describe 'output' do
|
|
43
|
-
let(:expected_output) do
|
|
44
|
-
" * PageOriented pattern structure generation ...
|
|
45
|
-
Added 'web/pages/example_page.rb' file
|
|
46
|
-
Added 'web/sections/menu_section.rb' file\n"
|
|
47
|
-
end
|
|
48
|
-
subject { output.string }
|
|
49
|
-
it { is_expected.to eql(expected_output) }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
data/spec/unit/lib/cache_spec.rb
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'howitzer/cache'
|
|
3
|
-
|
|
4
|
-
RSpec.describe Howitzer::Cache do
|
|
5
|
-
before { described_class.data.clear }
|
|
6
|
-
describe '.store' do
|
|
7
|
-
subject { described_class.store(ns, 7, :halt) }
|
|
8
|
-
context 'when namespace specified' do
|
|
9
|
-
let(:ns) { :user }
|
|
10
|
-
it 'should return value' do
|
|
11
|
-
is_expected.to eql(:halt)
|
|
12
|
-
end
|
|
13
|
-
it 'should store namespace value' do
|
|
14
|
-
subject
|
|
15
|
-
expect(described_class.data[:user]).to eql(7 => :halt)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
context 'when namespace empty' do
|
|
19
|
-
let(:ns) { nil }
|
|
20
|
-
it { expect { subject }.to raise_error(Howitzer::NoDataError, 'Data storage namespace can not be empty') }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
describe '.extract' do
|
|
24
|
-
subject { described_class.extract(ns, key) }
|
|
25
|
-
before { described_class.data[:user] = { 7 => :exit } }
|
|
26
|
-
describe 'when namespace specified' do
|
|
27
|
-
let(:ns) { :user }
|
|
28
|
-
context 'and namespace key found' do
|
|
29
|
-
let(:key) { 7 }
|
|
30
|
-
it { is_expected.to eql(:exit) }
|
|
31
|
-
end
|
|
32
|
-
context 'and namespace key not found' do
|
|
33
|
-
let(:key) { 5 }
|
|
34
|
-
it { is_expected.to be_nil }
|
|
35
|
-
end
|
|
36
|
-
context 'but namespace key not specified' do
|
|
37
|
-
let(:key) { nil }
|
|
38
|
-
it { is_expected.to eql(7 => :exit) }
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
context 'when namespace not found' do
|
|
42
|
-
let(:ns) { :guest }
|
|
43
|
-
let(:key) { 11 }
|
|
44
|
-
it { is_expected.to be_nil }
|
|
45
|
-
end
|
|
46
|
-
context 'when namespace not specified' do
|
|
47
|
-
let(:ns) { nil }
|
|
48
|
-
let(:key) { nil }
|
|
49
|
-
it { expect { subject }.to raise_error(Howitzer::NoDataError, 'Data storage namespace can not be empty') }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
describe '.clear_ns' do
|
|
53
|
-
subject { described_class.clear_ns(:user) }
|
|
54
|
-
before { described_class.data[:user] = { 7 => :exit } }
|
|
55
|
-
it 'should return empty hash' do
|
|
56
|
-
subject
|
|
57
|
-
data = described_class.instance_variable_get(:@data)
|
|
58
|
-
expect(data[:user]).to eql({})
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
describe '.clear_all_ns' do
|
|
62
|
-
before do
|
|
63
|
-
described_class.store(:cloud, :status, false)
|
|
64
|
-
described_class.store(:foo, 'foo', 'some value1')
|
|
65
|
-
described_class.store(:bar, 'bar', 'some value2')
|
|
66
|
-
described_class.store(:baz, 'baz', 'some value3')
|
|
67
|
-
end
|
|
68
|
-
context 'when default argument' do
|
|
69
|
-
before { described_class.clear_all_ns }
|
|
70
|
-
it { expect(described_class.data).to eq(cloud: { status: false }, foo: {}, bar: {}, baz: {}) }
|
|
71
|
-
end
|
|
72
|
-
context 'when custom argument' do
|
|
73
|
-
let(:exception_list) { %i[foo bar] }
|
|
74
|
-
before { described_class.clear_all_ns(exception_list) }
|
|
75
|
-
it do
|
|
76
|
-
expect(described_class.data).to eq(
|
|
77
|
-
cloud: {},
|
|
78
|
-
foo: { 'foo' => 'some value1' },
|
|
79
|
-
bar: { 'bar' => 'some value2' },
|
|
80
|
-
baz: {}
|
|
81
|
-
)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|