howitzer 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -1
  3. data/LICENSE +1 -1
  4. data/README.md +16 -16
  5. data/generators/base_generator.rb +1 -1
  6. data/generators/config/config_generator.rb +1 -4
  7. data/generators/config/templates/boot.rb +1 -1
  8. data/generators/config/templates/capybara.rb +1 -3
  9. data/generators/config/templates/default.yml +5 -19
  10. data/generators/config/templates/drivers/browserstack.rb +1 -1
  11. data/generators/config/templates/drivers/crossbrowsertesting.rb +1 -1
  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/sauce.rb +1 -1
  15. data/generators/config/templates/drivers/selenium.rb +1 -1
  16. data/generators/config/templates/drivers/selenium_grid.rb +2 -2
  17. data/generators/config/templates/drivers/testingbot.rb +1 -1
  18. data/generators/cucumber/templates/env.rb +1 -1
  19. data/generators/cucumber/templates/hooks.rb +8 -2
  20. data/generators/cucumber/templates/transformers.rb +1 -1
  21. data/generators/prerequisites/templates/factory_bot.rb +1 -1
  22. data/generators/root/templates/Gemfile.erb +4 -10
  23. data/generators/rspec/templates/spec_helper.rb +4 -4
  24. data/generators/turnip/templates/spec_helper.rb +4 -4
  25. data/generators/web/templates/example_page.rb +1 -1
  26. data/lib/howitzer/cache.rb +1 -1
  27. data/lib/howitzer/capybara_helpers.rb +27 -7
  28. data/lib/howitzer/email.rb +2 -2
  29. data/lib/howitzer/exceptions.rb +21 -21
  30. data/lib/howitzer/gmail_api/client.rb +13 -4
  31. data/lib/howitzer/log.rb +6 -6
  32. data/lib/howitzer/mailgun_api/client.rb +3 -2
  33. data/lib/howitzer/mailgun_api/response.rb +1 -2
  34. data/lib/howitzer/mailtrap_api/client.rb +1 -1
  35. data/lib/howitzer/meta/actions.rb +13 -16
  36. data/lib/howitzer/meta/element.rb +12 -10
  37. data/lib/howitzer/utils/string_extensions.rb +6 -2
  38. data/lib/howitzer/version.rb +1 -1
  39. data/lib/howitzer/web/base_section.rb +1 -1
  40. data/lib/howitzer/web/capybara_methods_proxy.rb +11 -5
  41. data/lib/howitzer/web/element_dsl.rb +104 -45
  42. data/lib/howitzer/web/iframe_dsl.rb +2 -2
  43. data/lib/howitzer/web/page.rb +4 -14
  44. data/lib/howitzer/web/page_dsl.rb +15 -6
  45. data/lib/howitzer/web/page_validator.rb +25 -26
  46. data/lib/howitzer/web/section.rb +5 -2
  47. data/lib/howitzer/web/section_dsl.rb +64 -30
  48. data/lib/howitzer.rb +2 -2
  49. metadata +24 -161
  50. data/.coveralls.yml +0 -1
  51. data/.gitignore +0 -14
  52. data/.rspec +0 -3
  53. data/.rubocop.yml +0 -60
  54. data/.ruby-gemset +0 -1
  55. data/.travis.yml +0 -8
  56. data/Gemfile +0 -14
  57. data/ISSUE_TEMPLATE.md +0 -16
  58. data/MAINTENANCE.md +0 -32
  59. data/Rakefile +0 -38
  60. data/features/cli_help.feature +0 -31
  61. data/features/cli_new.feature +0 -393
  62. data/features/cli_unknown.feature +0 -17
  63. data/features/cli_update.feature +0 -223
  64. data/features/cli_version.feature +0 -14
  65. data/features/step_definitions/common_steps.rb +0 -34
  66. data/features/support/env.rb +0 -1
  67. data/generators/config/templates/drivers/poltergeist.rb +0 -11
  68. data/generators/config/templates/drivers/webkit.rb +0 -6
  69. data/generators/root/templates/.gitignore +0 -21
  70. data/generators/root/templates/.rubocop.yml.erb +0 -56
  71. data/generators/turnip/templates/.rspec +0 -1
  72. data/howitzer.gemspec +0 -39
  73. data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
  74. data/spec/config/custom.yml +0 -9
  75. data/spec/spec_helper.rb +0 -73
  76. data/spec/support/generator_helper.rb +0 -21
  77. data/spec/support/logger_helper.rb +0 -13
  78. data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
  79. data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
  80. data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
  81. data/spec/support/shared_examples/element_dsl.rb +0 -242
  82. data/spec/support/shared_examples/meta_highlight_xpath.rb +0 -41
  83. data/spec/unit/generators/base_generator_spec.rb +0 -283
  84. data/spec/unit/generators/config_generator_spec.rb +0 -61
  85. data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
  86. data/spec/unit/generators/emails_generator_spec.rb +0 -35
  87. data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
  88. data/spec/unit/generators/root_generator_spec.rb +0 -86
  89. data/spec/unit/generators/rspec_generator_spec.rb +0 -36
  90. data/spec/unit/generators/tasks_generator_spec.rb +0 -31
  91. data/spec/unit/generators/templates/cucumber_spec.rb +0 -97
  92. data/spec/unit/generators/templates/rspec_spec.rb +0 -88
  93. data/spec/unit/generators/templates/turnip_spec.rb +0 -98
  94. data/spec/unit/generators/turnip_generator_spec.rb +0 -52
  95. data/spec/unit/generators/web_generator_spec.rb +0 -52
  96. data/spec/unit/lib/cache_spec.rb +0 -85
  97. data/spec/unit/lib/capybara_helpers_spec.rb +0 -730
  98. data/spec/unit/lib/email_spec.rb +0 -186
  99. data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
  100. data/spec/unit/lib/howitzer_spec.rb +0 -92
  101. data/spec/unit/lib/init_spec.rb +0 -2
  102. data/spec/unit/lib/log_spec.rb +0 -122
  103. data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
  104. data/spec/unit/lib/mail_adapters/gmail_spec.rb +0 -128
  105. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
  106. data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
  107. data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
  108. data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
  109. data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
  110. data/spec/unit/lib/mailtrap_api/client_spec.rb +0 -67
  111. data/spec/unit/lib/meta/element_spec.rb +0 -59
  112. data/spec/unit/lib/meta/entry_spec.rb +0 -77
  113. data/spec/unit/lib/meta/iframe_spec.rb +0 -66
  114. data/spec/unit/lib/meta/section_spec.rb +0 -43
  115. data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
  116. data/spec/unit/lib/web/base_section_spec.rb +0 -43
  117. data/spec/unit/lib/web/element_dsl_spec.rb +0 -31
  118. data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
  119. data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
  120. data/spec/unit/lib/web/page_spec.rb +0 -385
  121. data/spec/unit/lib/web/page_validator_spec.rb +0 -276
  122. data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
  123. data/spec/unit/lib/web/section_spec.rb +0 -70
  124. data/spec/unit/version_spec.rb +0 -8
@@ -1,62 +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(cucumber: true)
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::CucumberGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/features', is_directory: true },
18
- {
19
- name: '/features/example.feature',
20
- is_directory: false,
21
- size: template_file_size('cucumber', 'example.feature')
22
- },
23
- { name: '/features/step_definitions', is_directory: true },
24
- {
25
- name: '/features/step_definitions/common_steps.rb',
26
- is_directory: false,
27
- size: template_file_size('cucumber', 'common_steps.rb')
28
- },
29
- { name: '/features/support', is_directory: true },
30
- { name: '/features/support/env.rb', is_directory: false, size: template_file_size('cucumber', 'env.rb') },
31
- { name: '/features/support/hooks.rb', is_directory: false, size: template_file_size('cucumber', 'hooks.rb') },
32
- {
33
- name: '/features/support/transformers.rb',
34
- is_directory: false,
35
- size: template_file_size('cucumber', 'transformers.rb')
36
- },
37
- { name: '/tasks', is_directory: true },
38
- { name: '/tasks/cucumber.rake', is_directory: false, size: template_file_size('cucumber', 'cucumber.rake') },
39
- {
40
- name: '/tasks/cuke_sniffer.rake',
41
- is_directory: false,
42
- size: template_file_size('cucumber', 'cuke_sniffer.rake')
43
- }
44
- ]
45
- end
46
- it { is_expected.to eql(expected_result) }
47
- describe 'output' do
48
- let(:expected_output) do
49
- "#{ColorizedString.new(' * Cucumber integration to the framework ...').light_cyan}
50
- #{ColorizedString.new('Added').light_green} 'features/step_definitions/common_steps.rb' file
51
- #{ColorizedString.new('Added').light_green} 'features/support/env.rb' file
52
- #{ColorizedString.new('Added').light_green} 'features/support/hooks.rb' file
53
- #{ColorizedString.new('Added').light_green} 'features/support/transformers.rb' file
54
- #{ColorizedString.new('Added').light_green} 'features/example.feature' file
55
- #{ColorizedString.new('Added').light_green} 'tasks/cucumber.rake' file
56
- #{ColorizedString.new('Added').light_green} 'tasks/cuke_sniffer.rake' file\n"
57
- end
58
- subject { output.string }
59
- it { is_expected.to eql(expected_output) }
60
- end
61
- end
62
- end
@@ -1,35 +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::EmailsGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/emails', is_directory: true },
18
- {
19
- name: '/emails/example_email.rb',
20
- is_directory: false,
21
- size: template_file_size('emails', 'example_email.rb')
22
- }
23
- ]
24
- end
25
- it { is_expected.to eql(expected_result) }
26
- describe 'output' do
27
- let(:expected_output) do
28
- "#{ColorizedString.new(' * Email example generation ...').light_cyan}
29
- #{ColorizedString.new('Added').light_green} '/emails/example_email.rb' file\n"
30
- end
31
- subject { output.string }
32
- it { is_expected.to eql(expected_output) }
33
- end
34
- end
35
- end
@@ -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_bot.rb',
25
- is_directory: false, size: template_file_size('prerequisites', 'factory_bot.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
- "#{ColorizedString.new(' * Pre-requisites integration to the framework ...').light_cyan}
44
- #{ColorizedString.new('Added').light_green} 'prerequisites/factory_bot.rb' file
45
- #{ColorizedString.new('Added').light_green} 'prerequisites/factories/users.rb' file
46
- #{ColorizedString.new('Added').light_green} 'prerequisites/models/base.rb' file
47
- #{ColorizedString.new('Added').light_green} '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,86 +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: 616 },
19
- { name: '/Gemfile', is_directory: false, size: 811 },
20
- { name: '/Rakefile', is_directory: false, size: template_file_size('root', 'Rakefile') }
21
- ]
22
- end
23
- let(:options) { {} }
24
-
25
- it { is_expected.to eql(expected_result) }
26
-
27
- describe 'output' do
28
- subject { output.string }
29
-
30
- context 'when options is empty' do
31
- let(:expected_output) do
32
- added_text = ColorizedString.new('Added').light_green
33
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
34
- #{added_text} '.gitignore' file
35
- #{added_text} 'Rakefile' file
36
- #{added_text} template '.rubocop.yml.erb' with params '{}' to destination '.rubocop.yml'
37
- #{added_text} template 'Gemfile.erb' with params '{}' to destination 'Gemfile'\n"
38
- end
39
-
40
- it { is_expected.to eql(expected_output) }
41
- end
42
-
43
- context 'when options is rspec => true' do
44
- let(:expected_output) do
45
- added_text = ColorizedString.new('Added').light_green
46
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
47
- #{added_text} '.gitignore' file
48
- #{added_text} 'Rakefile' file
49
- #{added_text} template '.rubocop.yml.erb' with params '{:rspec=>true}' to destination '.rubocop.yml'
50
- #{added_text} template 'Gemfile.erb' with params '{:rspec=>true}' to destination 'Gemfile'\n"
51
- end
52
- let(:options) { { rspec: true } }
53
-
54
- it { is_expected.to eql(expected_output) }
55
- end
56
-
57
- context 'when options is cucumber => cucumber' do
58
- let(:expected_output) do
59
- added_text = ColorizedString.new('Added').light_green
60
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
61
- #{added_text} '.gitignore' file
62
- #{added_text} 'Rakefile' file
63
- #{added_text} template '.rubocop.yml.erb' with params '{:cucumber=>true}' to destination '.rubocop.yml'
64
- #{added_text} template 'Gemfile.erb' with params '{:cucumber=>true}' to destination 'Gemfile'\n"
65
- end
66
- let(:options) { { cucumber: true } }
67
-
68
- it { is_expected.to eql(expected_output) }
69
- end
70
-
71
- context 'when options is turnip => true' do
72
- let(:expected_output) do
73
- added_text = ColorizedString.new('Added').light_green
74
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
75
- #{added_text} '.gitignore' file
76
- #{added_text} 'Rakefile' file
77
- #{added_text} template '.rubocop.yml.erb' with params '{:turnip=>true}' to destination '.rubocop.yml'
78
- #{added_text} template 'Gemfile.erb' with params '{:turnip=>true}' to destination 'Gemfile'\n"
79
- end
80
- let(:options) { { turnip: true } }
81
-
82
- it { is_expected.to eql(expected_output) }
83
- end
84
- end
85
- end
86
- 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
- "#{ColorizedString.new(' * RSpec integration to the framework ...').light_cyan}
28
- #{ColorizedString.new('Added').light_green} 'spec/spec_helper.rb' file
29
- #{ColorizedString.new('Added').light_green} 'spec/example_spec.rb' file
30
- #{ColorizedString.new('Added').light_green} '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
- "#{ColorizedString.new(' * Base rake task generation ...').light_cyan}
25
- #{ColorizedString.new('Added').light_green} '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,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