howitzer 2.2.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -1
  3. data/LICENSE +1 -1
  4. data/README.md +16 -17
  5. data/generators/base_generator.rb +4 -6
  6. data/generators/config/config_generator.rb +2 -4
  7. data/generators/config/templates/boot.rb +1 -1
  8. data/generators/config/templates/capybara.rb +3 -5
  9. data/generators/config/templates/default.yml +19 -20
  10. data/generators/config/templates/drivers/browserstack.rb +31 -4
  11. data/generators/config/templates/drivers/crossbrowsertesting.rb +9 -11
  12. data/generators/config/templates/drivers/headless_chrome.rb +1 -1
  13. data/generators/config/templates/drivers/headless_firefox.rb +1 -1
  14. data/generators/config/templates/drivers/lambdatest.rb +30 -0
  15. data/generators/config/templates/drivers/sauce.rb +30 -2
  16. data/generators/config/templates/drivers/selenium.rb +1 -1
  17. data/generators/config/templates/drivers/selenium_grid.rb +3 -3
  18. data/generators/config/templates/drivers/testingbot.rb +29 -2
  19. data/generators/cucumber/templates/env.rb +1 -1
  20. data/generators/cucumber/templates/hooks.rb +9 -3
  21. data/generators/cucumber/templates/transformers.rb +1 -1
  22. data/generators/prerequisites/templates/factory_bot.rb +1 -1
  23. data/generators/root/templates/Gemfile.erb +4 -14
  24. data/generators/rspec/templates/spec_helper.rb +5 -5
  25. data/generators/turnip/templates/spec_helper.rb +5 -5
  26. data/generators/web/templates/example_page.rb +1 -1
  27. data/lib/howitzer/cache.rb +1 -1
  28. data/lib/howitzer/capybara_helpers.rb +46 -9
  29. data/lib/howitzer/email.rb +2 -2
  30. data/lib/howitzer/exceptions.rb +21 -21
  31. data/lib/howitzer/gmail_api/client.rb +13 -4
  32. data/lib/howitzer/log.rb +6 -6
  33. data/lib/howitzer/mail_adapters/mailgun.rb +1 -1
  34. data/lib/howitzer/mail_adapters/mailtrap.rb +3 -3
  35. data/lib/howitzer/mail_adapters/onesecmail.rb +80 -0
  36. data/lib/howitzer/mail_adapters/testmail.rb +102 -0
  37. data/lib/howitzer/mailgun_api/client.rb +3 -2
  38. data/lib/howitzer/mailgun_api/response.rb +1 -2
  39. data/lib/howitzer/mailtrap_api/client.rb +19 -1
  40. data/lib/howitzer/meta/actions.rb +13 -16
  41. data/lib/howitzer/meta/element.rb +12 -10
  42. data/lib/howitzer/onesecmail_api/client.rb +44 -0
  43. data/lib/howitzer/onesecmail_api.rb +7 -0
  44. data/lib/howitzer/testmail_api/client.rb +44 -0
  45. data/lib/howitzer/testmail_api.rb +7 -0
  46. data/lib/howitzer/utils/string_extensions.rb +6 -2
  47. data/lib/howitzer/version.rb +1 -1
  48. data/lib/howitzer/web/base_section.rb +1 -1
  49. data/lib/howitzer/web/capybara_methods_proxy.rb +11 -5
  50. data/lib/howitzer/web/element_dsl.rb +104 -45
  51. data/lib/howitzer/web/iframe_dsl.rb +2 -2
  52. data/lib/howitzer/web/page.rb +4 -14
  53. data/lib/howitzer/web/page_dsl.rb +15 -6
  54. data/lib/howitzer/web/page_validator.rb +25 -26
  55. data/lib/howitzer/web/section.rb +5 -2
  56. data/lib/howitzer/web/section_dsl.rb +64 -30
  57. data/lib/howitzer.rb +2 -2
  58. metadata +29 -165
  59. data/.coveralls.yml +0 -1
  60. data/.gitignore +0 -14
  61. data/.rspec +0 -3
  62. data/.rubocop.yml +0 -60
  63. data/.ruby-gemset +0 -1
  64. data/.travis.yml +0 -8
  65. data/Gemfile +0 -14
  66. data/ISSUE_TEMPLATE.md +0 -16
  67. data/MAINTENANCE.md +0 -32
  68. data/Rakefile +0 -38
  69. data/features/cli_help.feature +0 -31
  70. data/features/cli_new.feature +0 -393
  71. data/features/cli_unknown.feature +0 -17
  72. data/features/cli_update.feature +0 -223
  73. data/features/cli_version.feature +0 -14
  74. data/features/step_definitions/common_steps.rb +0 -34
  75. data/features/support/env.rb +0 -1
  76. data/generators/config/templates/drivers/appium.rb +0 -25
  77. data/generators/config/templates/drivers/poltergeist.rb +0 -11
  78. data/generators/config/templates/drivers/webkit.rb +0 -6
  79. data/generators/root/templates/.gitignore +0 -21
  80. data/generators/root/templates/.rubocop.yml.erb +0 -56
  81. data/generators/turnip/templates/.rspec +0 -1
  82. data/howitzer.gemspec +0 -39
  83. data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
  84. data/spec/config/custom.yml +0 -9
  85. data/spec/spec_helper.rb +0 -73
  86. data/spec/support/generator_helper.rb +0 -21
  87. data/spec/support/logger_helper.rb +0 -13
  88. data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
  89. data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
  90. data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
  91. data/spec/support/shared_examples/element_dsl.rb +0 -242
  92. data/spec/support/shared_examples/meta_highlight_xpath.rb +0 -41
  93. data/spec/unit/generators/base_generator_spec.rb +0 -283
  94. data/spec/unit/generators/config_generator_spec.rb +0 -61
  95. data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
  96. data/spec/unit/generators/emails_generator_spec.rb +0 -35
  97. data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
  98. data/spec/unit/generators/root_generator_spec.rb +0 -86
  99. data/spec/unit/generators/rspec_generator_spec.rb +0 -36
  100. data/spec/unit/generators/tasks_generator_spec.rb +0 -31
  101. data/spec/unit/generators/templates/cucumber_spec.rb +0 -97
  102. data/spec/unit/generators/templates/rspec_spec.rb +0 -88
  103. data/spec/unit/generators/templates/turnip_spec.rb +0 -98
  104. data/spec/unit/generators/turnip_generator_spec.rb +0 -52
  105. data/spec/unit/generators/web_generator_spec.rb +0 -52
  106. data/spec/unit/lib/cache_spec.rb +0 -85
  107. data/spec/unit/lib/capybara_helpers_spec.rb +0 -730
  108. data/spec/unit/lib/email_spec.rb +0 -186
  109. data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
  110. data/spec/unit/lib/howitzer_spec.rb +0 -92
  111. data/spec/unit/lib/init_spec.rb +0 -2
  112. data/spec/unit/lib/log_spec.rb +0 -122
  113. data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
  114. data/spec/unit/lib/mail_adapters/gmail_spec.rb +0 -128
  115. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
  116. data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
  117. data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
  118. data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
  119. data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
  120. data/spec/unit/lib/mailtrap_api/client_spec.rb +0 -67
  121. data/spec/unit/lib/meta/element_spec.rb +0 -59
  122. data/spec/unit/lib/meta/entry_spec.rb +0 -77
  123. data/spec/unit/lib/meta/iframe_spec.rb +0 -66
  124. data/spec/unit/lib/meta/section_spec.rb +0 -43
  125. data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
  126. data/spec/unit/lib/web/base_section_spec.rb +0 -43
  127. data/spec/unit/lib/web/element_dsl_spec.rb +0 -31
  128. data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
  129. data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
  130. data/spec/unit/lib/web/page_spec.rb +0 -385
  131. data/spec/unit/lib/web/page_validator_spec.rb +0 -276
  132. data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
  133. data/spec/unit/lib/web/section_spec.rb +0 -70
  134. data/spec/unit/version_spec.rb +0 -8
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Howitzer::BaseGenerator do
4
- describe 'Template rendering' do
5
- context 'when cucumber' do
6
- subject { ERB.new(template, nil, '-').result(binding) }
7
- let(:cucumber) { true }
8
- let(:rspec) { false }
9
- let(:turnip) { false }
10
- let(:template) { File.open(source_path, 'r').read }
11
-
12
- context '.rubocop.yml' do
13
- let(:source_path) { File.join('generators', 'root', 'templates', '.rubocop.yml.erb') }
14
- it do
15
- res = <<~EXPECTED_CONTENT
16
- # See full list of defaults here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
17
- # To see all cops used see here: https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
18
-
19
- AllCops:
20
- DisplayCopNames: true
21
- TargetRubyVersion: 2.4
22
-
23
- Layout/CaseIndentation:
24
- Enabled: false
25
-
26
- Lint/AmbiguousBlockAssociation:
27
- Enabled: false
28
-
29
- Lint/AmbiguousRegexpLiteral:
30
- Enabled: false
31
-
32
- Metrics/BlockLength:
33
- Enabled: false
34
-
35
- Metrics/LineLength:
36
- Max: 120
37
-
38
- Metrics/ModuleLength:
39
- Max: 150
40
-
41
- Style/CaseEquality:
42
- Enabled: false
43
-
44
- Style/Documentation:
45
- Enabled: false
46
-
47
- Style/EmptyElse:
48
- Enabled: false
49
-
50
- Style/FrozenStringLiteralComment:
51
- Enabled: false
52
-
53
- Style/SymbolProc:
54
- Exclude:
55
- - 'features/step_definitions/**/*.rb'
56
- EXPECTED_CONTENT
57
- is_expected.to eq(res)
58
- end
59
- end
60
-
61
- context 'Gemfile' do
62
- let(:source_path) { File.join('generators', 'root', 'templates', 'Gemfile.erb') }
63
- it do
64
- res = <<~EXPECTED_CONTENT
65
- source 'https://rubygems.org'
66
-
67
- gem 'capybara-screenshot'
68
- gem 'cucumber', '~>3.0'
69
- gem 'cuke_sniffer', require: false
70
- gem 'factory_bot'
71
- gem 'howitzer'
72
- gem 'pry'
73
- gem 'pry-byebug'
74
- gem 'repeater'
75
- gem 'rest-client'
76
- gem 'rubocop'
77
- gem 'syntax'
78
-
79
- # Uncomment it if you are going to use 'appium' driver. Appium and Android SDK should be installed.
80
- # See https://appium.io/docs/en/about-appium/getting-started/
81
- # gem 'appium_capybara'
82
-
83
- # Uncomment it if you are going to use 'webkit' driver. QT library should be installed.
84
- # See https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
85
- #
86
- # gem 'capybara-webkit'
87
-
88
- # Uncomment it if you are going to use 'poltergeist' driver. PhantomJS should be installed.
89
- # See https://github.com/jnicklas/capybara#poltergeist
90
- # gem 'poltergeist', git: 'https://github.com/teampoltergeist/poltergeist.git', branch: :master
91
- EXPECTED_CONTENT
92
- is_expected.to eq(res)
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,88 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Howitzer::BaseGenerator do
4
- describe 'Template rendering' do
5
- context 'when rspecr' do
6
- subject { ERB.new(template, nil, '-').result(binding) }
7
- let(:cucumber) { false }
8
- let(:rspec) { true }
9
- let(:turnip) { false }
10
- let(:template) { File.open(source_path, 'r').read }
11
-
12
- context '.rubocop.yml' do
13
- let(:source_path) { File.join('generators', 'root', 'templates', '.rubocop.yml.erb') }
14
- it do
15
- res = <<~EXPECTED_CONTENT
16
- # See full list of defaults here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
17
- # To see all cops used see here: https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
18
-
19
- AllCops:
20
- DisplayCopNames: true
21
- TargetRubyVersion: 2.4
22
-
23
- Layout/CaseIndentation:
24
- Enabled: false
25
-
26
- Lint/AmbiguousRegexpLiteral:
27
- Enabled: false
28
-
29
- Metrics/BlockLength:
30
- Enabled: false
31
-
32
- Metrics/LineLength:
33
- Max: 120
34
-
35
- Metrics/ModuleLength:
36
- Max: 150
37
-
38
- Style/CaseEquality:
39
- Enabled: false
40
-
41
- Style/Documentation:
42
- Enabled: false
43
-
44
- Style/EmptyElse:
45
- Enabled: false
46
-
47
- Style/FrozenStringLiteralComment:
48
- Enabled: false
49
- EXPECTED_CONTENT
50
- is_expected.to eq(res)
51
- end
52
- end
53
-
54
- context 'Gemfile' do
55
- let(:source_path) { File.join('generators', 'root', 'templates', 'Gemfile.erb') }
56
- it do
57
- res = <<~EXPECTED_CONTENT
58
- source 'https://rubygems.org'
59
-
60
- gem 'capybara-screenshot'
61
- gem 'factory_bot'
62
- gem 'howitzer'
63
- gem 'pry'
64
- gem 'pry-byebug'
65
- gem 'repeater'
66
- gem 'rest-client'
67
- gem 'rspec', '~>3.2'
68
- gem 'rubocop'
69
-
70
- # Uncomment it if you are going to use 'appium' driver. Appium and Android SDK should be installed.
71
- # See https://appium.io/docs/en/about-appium/getting-started/
72
- # gem 'appium_capybara'
73
-
74
- # Uncomment it if you are going to use 'webkit' driver. QT library should be installed.
75
- # See https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
76
- #
77
- # gem 'capybara-webkit'
78
-
79
- # Uncomment it if you are going to use 'poltergeist' driver. PhantomJS should be installed.
80
- # See https://github.com/jnicklas/capybara#poltergeist
81
- # gem 'poltergeist', git: 'https://github.com/teampoltergeist/poltergeist.git', branch: :master
82
- EXPECTED_CONTENT
83
- is_expected.to eq(res)
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Howitzer::BaseGenerator do
4
- describe 'Template rendering' do
5
- context 'when turnip' do
6
- subject { ERB.new(template, nil, '-').result(binding) }
7
- let(:cucumber) { false }
8
- let(:rspec) { false }
9
- let(:turnip) { true }
10
- let(:template) { File.open(source_path, 'r').read }
11
-
12
- context '.rubocop.yml' do
13
- let(:source_path) { File.join('generators', 'root', 'templates', '.rubocop.yml.erb') }
14
- it do
15
- res = <<~EXPECTED_CONTENT
16
- # See full list of defaults here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
17
- # To see all cops used see here: https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
18
-
19
- AllCops:
20
- DisplayCopNames: true
21
- TargetRubyVersion: 2.4
22
-
23
- Layout/CaseIndentation:
24
- Enabled: false
25
-
26
- Lint/AmbiguousRegexpLiteral:
27
- Enabled: false
28
-
29
- Metrics/BlockLength:
30
- Enabled: false
31
-
32
- Metrics/LineLength:
33
- Max: 120
34
-
35
- Metrics/ModuleLength:
36
- Max: 150
37
-
38
- Style/CaseEquality:
39
- Enabled: false
40
-
41
- Style/Documentation:
42
- Enabled: false
43
-
44
- Style/EmptyElse:
45
- Enabled: false
46
-
47
- Style/FrozenStringLiteralComment:
48
- Enabled: false
49
-
50
- Style/MixinGrouping:
51
- EnforcedStyle: separated
52
- Exclude:
53
- - '**/*_steps.rb'
54
-
55
- Style/SymbolProc:
56
- Exclude:
57
- - 'spec/steps/**/*.rb'
58
- EXPECTED_CONTENT
59
- is_expected.to eq(res)
60
- end
61
- end
62
-
63
- context 'Gemfile' do
64
- let(:source_path) { File.join('generators', 'root', 'templates', 'Gemfile.erb') }
65
- it do
66
- res = <<~EXPECTED_CONTENT
67
- source 'https://rubygems.org'
68
-
69
- gem 'capybara-screenshot'
70
- gem 'factory_bot'
71
- gem 'howitzer'
72
- gem 'pry'
73
- gem 'pry-byebug'
74
- gem 'repeater'
75
- gem 'rest-client'
76
- gem 'rspec', '~>3.2'
77
- gem 'rubocop'
78
- gem 'turnip'
79
-
80
- # Uncomment it if you are going to use 'appium' driver. Appium and Android SDK should be installed.
81
- # See https://appium.io/docs/en/about-appium/getting-started/
82
- # gem 'appium_capybara'
83
-
84
- # Uncomment it if you are going to use 'webkit' driver. QT library should be installed.
85
- # See https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
86
- #
87
- # gem 'capybara-webkit'
88
-
89
- # Uncomment it if you are going to use 'poltergeist' driver. PhantomJS should be installed.
90
- # See https://github.com/jnicklas/capybara#poltergeist
91
- # gem 'poltergeist', git: 'https://github.com/teampoltergeist/poltergeist.git', branch: :master
92
- EXPECTED_CONTENT
93
- is_expected.to eq(res)
94
- end
95
- end
96
- end
97
- end
98
- 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
- "#{ColorizedString.new(' * Turnip integration to the framework ...').light_cyan}
41
- #{ColorizedString.new('Added').light_green} '.rspec' file
42
- #{ColorizedString.new('Added').light_green} 'spec/spec_helper.rb' file
43
- #{ColorizedString.new('Added').light_green} 'spec/turnip_helper.rb' file
44
- #{ColorizedString.new('Added').light_green} 'spec/acceptance/example.feature' file
45
- #{ColorizedString.new('Added').light_green} 'spec/steps/common_steps.rb' file
46
- #{ColorizedString.new('Added').light_green} '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
- "#{ColorizedString.new(' * PageOriented pattern structure generation ...').light_cyan}
45
- #{ColorizedString.new('Added').light_green} 'web/pages/example_page.rb' file
46
- #{ColorizedString.new('Added').light_green} '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
@@ -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