howitzer 2.2.0 → 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.
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,165 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/section'
3
-
4
- RSpec.describe Howitzer::Web::SectionDsl do
5
- let(:section_class) do
6
- Class.new(Howitzer::Web::Section) do
7
- me :xpath, './/div'
8
- end
9
- end
10
- let(:web_page_class) do
11
- Class.new do
12
- include Howitzer::Web::SectionDsl
13
-
14
- def capybara_context
15
- Capybara.current_session
16
- end
17
- end
18
- end
19
- before { stub_const('FooSection', section_class) }
20
- describe '.section' do
21
- subject do
22
- web_page_class.class_eval do
23
- section :foo
24
- end
25
- web_page_class
26
- end
27
-
28
- it 'should create public :foo_section instance method' do
29
- expect(subject.new.public_methods(false)).to include(:foo_section)
30
- end
31
- it 'should create public :foo_sections instance method' do
32
- expect(subject.new.public_methods(false)).to include(:foo_sections)
33
- end
34
- it 'should create public :has_foo_section? instance method' do
35
- expect(subject.new.public_methods(false)).to include(:has_foo_section?)
36
- end
37
- it 'should create public :has_no_foo_section? instance method' do
38
- expect(subject.new.public_methods(false)).to include(:has_no_foo_section?)
39
- end
40
- it 'should be protected class method' do
41
- expect { subject.section :bar }.to raise_error(NoMethodError)
42
- expect(subject.protected_methods(true)).to include(:section)
43
- end
44
- end
45
-
46
- describe 'Dsl on section' do
47
- let(:other_section_class) do
48
- Class.new(Howitzer::Web::Section) do
49
- me '#id'
50
- element :baz, '.klass'
51
- end
52
- end
53
- let(:parent) { double }
54
- let(:capybara_context) { double }
55
- let(:nested_capybara_context) { double }
56
- let(:capybara_element) { double }
57
- subject { section_class.new(parent, capybara_context) }
58
- before do
59
- stub_const('BarSection', other_section_class)
60
- section_class.class_eval do
61
- section :bar
62
- end
63
- expect(capybara_context).to receive(:find).with('#id').at_least(:once) { nested_capybara_context }
64
- expect(nested_capybara_context).to receive(:find).with('.klass') { capybara_element }
65
- end
66
- it 'can work with nested section' do
67
- expect(subject.bar_section).to be_a(other_section_class)
68
- expect(subject.bar_section.private_methods(false)).to include(:baz_element)
69
- expect(subject.bar_section.send(:baz_element)).to eq(capybara_element)
70
- end
71
- end
72
-
73
- describe 'Dsl on page' do
74
- let(:session) { double(:session) }
75
- before do
76
- allow(Capybara).to receive(:current_session) { session }
77
- end
78
- context 'when section with single argument without block' do
79
- let(:finder_args) { [:xpath, './/div'] }
80
- let(:section_name) { :foo }
81
- before do
82
- web_page_class.class_eval do
83
- section :foo
84
- end
85
- end
86
- include_examples :dynamic_section_methods
87
- end
88
-
89
- context 'when section with single argument and block' do
90
- subject do
91
- web_page_class.class_eval do
92
- section :unknown do
93
- element :some, :id, 'do_do'
94
- end
95
- end
96
- end
97
- it 'should generate error' do
98
- expect { subject }.to raise_error(ArgumentError, 'Missing finder arguments')
99
- end
100
- end
101
-
102
- context 'when section with 2 arguments without block' do
103
- let(:finder_args) { ['.some_class'] }
104
- let(:section_name) { :foo }
105
- before do
106
- web_page_class.class_eval do
107
- section :foo, '.some_class'
108
- end
109
- end
110
- include_examples :dynamic_section_methods
111
- end
112
-
113
- context 'when section with 2 arguments and block' do
114
- let(:finder_args) { [:xpath, './/div'] }
115
- let(:section_name) { :unknown }
116
- let(:section_class) { Howitzer::Web::BaseSection }
117
- before do
118
- web_page_class.class_eval do
119
- section :unknown, :xpath, './/div' do
120
- element :some, :id, 'do_do'
121
- end
122
- end
123
- end
124
- include_examples :dynamic_section_methods
125
- end
126
-
127
- context 'when nested section with 2 arguments and block' do
128
- let(:finder_args) { [:xpath, './/div'] }
129
- let(:section_name) { :name1 }
130
- let(:section_class) { Howitzer::Web::BaseSection }
131
- before do
132
- web_page_class.class_eval do
133
- section :name1, :xpath, './/div' do
134
- element :some1, :id, 'do_do'
135
-
136
- section :name2, '#klass' do
137
- element :some2, :xpath, './/a'
138
- end
139
- end
140
- end
141
- end
142
-
143
- include_examples :dynamic_section_methods
144
- include_examples :capybara_context_holder
145
-
146
- context 'checking nested level' do
147
- let(:context2) { double }
148
- let(:context3) { double }
149
- let(:capybara_element) { double }
150
- before do
151
- expect(session).to receive(:find).with(*finder_args).once.and_return(context2)
152
- expect(context2).to receive(:find).with('#klass').and_return(context3)
153
- expect(context3).to receive(:find).with(:xpath, './/a').and_return(capybara_element)
154
- end
155
-
156
- it 'can work with nested section' do
157
- nested_section = web_page_class.new.name1_section.name2_section
158
- expect(nested_section).to be_a(section_class)
159
- expect(nested_section.private_methods(false)).to include(:some2_element)
160
- expect(nested_section.send(:some2_element)).to eq(capybara_element)
161
- end
162
- end
163
- end
164
- end
165
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/section_dsl'
3
- require 'howitzer/web/section'
4
- RSpec.describe Howitzer::Web::Section do
5
- describe 'element dsl methods' do
6
- let(:parent) { double }
7
- let(:capybara_context) { double }
8
-
9
- let(:klass) { Class.new(described_class) }
10
- let(:klass_object) { klass.new(parent, capybara_context) }
11
-
12
- it 'returns correct capybara context' do
13
- expect(klass_object.capybara_context).to eq(capybara_context)
14
- end
15
-
16
- include_examples :element_dsl
17
- end
18
-
19
- describe 'DSL' do
20
- describe '.me' do
21
- let(:section_class) { Class.new(described_class) }
22
- context 'when args missing' do
23
- it { expect { section_class.send(:me) }.to raise_error(ArgumentError, 'Finder arguments are missing') }
24
- end
25
-
26
- context 'when args present' do
27
- subject { section_class.send(:me, '.foo') }
28
- it { is_expected.to eq(['.foo']) }
29
- end
30
-
31
- it 'should be private' do
32
- expect { section_class.me('.foo') }.to raise_error(NoMethodError)
33
- end
34
- end
35
- end
36
-
37
- describe '.default_finder_args' do
38
- context 'by default' do
39
- subject { described_class.default_finder_args }
40
- it { is_expected.to be_nil }
41
- end
42
-
43
- context 'when defined via dsl' do
44
- let(:section_class) do
45
- Class.new(described_class) do
46
- me :xpath, './/div'
47
- end
48
- end
49
- subject { section_class.default_finder_args }
50
- it { is_expected.to eq([:xpath, './/div']) }
51
- end
52
- end
53
-
54
- describe '#parent' do
55
- subject { described_class.new(:test, 1).parent }
56
- it { is_expected.to eq(:test) }
57
- end
58
-
59
- describe '#capybara_context' do
60
- subject { described_class.new(1, :test).capybara_context }
61
- it { is_expected.to eq(:test) }
62
- end
63
-
64
- describe '#meta' do
65
- let(:section) { described_class.new(1, :test) }
66
- it { expect(section.meta).to be_an_instance_of(Howitzer::Meta::Entry) }
67
- it { expect(section.meta.context).to eq(section) }
68
- it { expect(section.instance_variable_get(:@meta)).to be_nil }
69
- end
70
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Howitzer do
4
- it { expect(subject.constants).to include(:VERSION) }
5
- it 'should contains VERSION constant with correct format' do
6
- expect(Howitzer::VERSION).to match(/^\d+\.\d+(\.\d+)?$/)
7
- end
8
- end