howitzer 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/LICENSE +1 -1
- data/README.md +16 -16
- data/generators/base_generator.rb +1 -1
- data/generators/config/config_generator.rb +1 -4
- data/generators/config/templates/boot.rb +1 -1
- data/generators/config/templates/capybara.rb +1 -3
- data/generators/config/templates/default.yml +5 -19
- data/generators/config/templates/drivers/browserstack.rb +1 -1
- data/generators/config/templates/drivers/crossbrowsertesting.rb +1 -1
- data/generators/config/templates/drivers/headless_chrome.rb +1 -1
- data/generators/config/templates/drivers/headless_firefox.rb +1 -1
- data/generators/config/templates/drivers/sauce.rb +1 -1
- data/generators/config/templates/drivers/selenium.rb +1 -1
- data/generators/config/templates/drivers/selenium_grid.rb +2 -2
- data/generators/config/templates/drivers/testingbot.rb +1 -1
- data/generators/cucumber/templates/env.rb +1 -1
- data/generators/cucumber/templates/hooks.rb +8 -2
- data/generators/cucumber/templates/transformers.rb +1 -1
- data/generators/prerequisites/templates/factory_bot.rb +1 -1
- data/generators/root/templates/Gemfile.erb +4 -10
- data/generators/rspec/templates/spec_helper.rb +4 -4
- data/generators/turnip/templates/spec_helper.rb +4 -4
- data/generators/web/templates/example_page.rb +1 -1
- data/lib/howitzer/cache.rb +1 -1
- data/lib/howitzer/capybara_helpers.rb +27 -7
- data/lib/howitzer/email.rb +2 -2
- data/lib/howitzer/exceptions.rb +21 -21
- data/lib/howitzer/gmail_api/client.rb +13 -4
- data/lib/howitzer/log.rb +6 -6
- data/lib/howitzer/mailgun_api/client.rb +3 -2
- data/lib/howitzer/mailgun_api/response.rb +1 -2
- data/lib/howitzer/mailtrap_api/client.rb +1 -1
- data/lib/howitzer/meta/actions.rb +13 -16
- data/lib/howitzer/meta/element.rb +12 -10
- 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_methods_proxy.rb +11 -5
- data/lib/howitzer/web/element_dsl.rb +104 -45
- data/lib/howitzer/web/iframe_dsl.rb +2 -2
- data/lib/howitzer/web/page.rb +4 -14
- data/lib/howitzer/web/page_dsl.rb +15 -6
- data/lib/howitzer/web/page_validator.rb +25 -26
- data/lib/howitzer/web/section.rb +5 -2
- data/lib/howitzer/web/section_dsl.rb +64 -30
- data/lib/howitzer.rb +2 -2
- metadata +24 -161
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -60
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -8
- data/Gemfile +0 -14
- data/ISSUE_TEMPLATE.md +0 -16
- data/MAINTENANCE.md +0 -32
- data/Rakefile +0 -38
- data/features/cli_help.feature +0 -31
- data/features/cli_new.feature +0 -393
- data/features/cli_unknown.feature +0 -17
- data/features/cli_update.feature +0 -223
- data/features/cli_version.feature +0 -14
- data/features/step_definitions/common_steps.rb +0 -34
- data/features/support/env.rb +0 -1
- data/generators/config/templates/drivers/poltergeist.rb +0 -11
- data/generators/config/templates/drivers/webkit.rb +0 -6
- data/generators/root/templates/.gitignore +0 -21
- data/generators/root/templates/.rubocop.yml.erb +0 -56
- data/generators/turnip/templates/.rspec +0 -1
- data/howitzer.gemspec +0 -39
- data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
- data/spec/config/custom.yml +0 -9
- data/spec/spec_helper.rb +0 -73
- data/spec/support/generator_helper.rb +0 -21
- data/spec/support/logger_helper.rb +0 -13
- 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/support/shared_examples/meta_highlight_xpath.rb +0 -41
- data/spec/unit/generators/base_generator_spec.rb +0 -283
- data/spec/unit/generators/config_generator_spec.rb +0 -61
- 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 -86
- data/spec/unit/generators/rspec_generator_spec.rb +0 -36
- data/spec/unit/generators/tasks_generator_spec.rb +0 -31
- data/spec/unit/generators/templates/cucumber_spec.rb +0 -97
- data/spec/unit/generators/templates/rspec_spec.rb +0 -88
- data/spec/unit/generators/templates/turnip_spec.rb +0 -98
- 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 -730
- data/spec/unit/lib/email_spec.rb +0 -186
- data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
- data/spec/unit/lib/howitzer_spec.rb +0 -92
- 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/gmail_spec.rb +0 -128
- data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
- data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
- data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
- 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/mailtrap_api/client_spec.rb +0 -67
- data/spec/unit/lib/meta/element_spec.rb +0 -59
- data/spec/unit/lib/meta/entry_spec.rb +0 -77
- data/spec/unit/lib/meta/iframe_spec.rb +0 -66
- data/spec/unit/lib/meta/section_spec.rb +0 -43
- 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 -31
- data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
- data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
- data/spec/unit/lib/web/page_spec.rb +0 -385
- 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 -70
- data/spec/unit/version_spec.rb +0 -8
data/spec/unit/lib/email_spec.rb
DELETED
@@ -1,186 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/email'
|
3
|
-
require 'howitzer/log'
|
4
|
-
require 'howitzer/exceptions'
|
5
|
-
|
6
|
-
RSpec.describe Howitzer::Email do
|
7
|
-
let(:recipient) { 'first_tester@gmail.com' }
|
8
|
-
let(:message_subject) { 'test subject' }
|
9
|
-
let(:message) { double(:message) }
|
10
|
-
let(:email_object) { described_class.new(message) }
|
11
|
-
|
12
|
-
describe '.adapter' do
|
13
|
-
it do
|
14
|
-
expect(described_class.adapter)
|
15
|
-
.to eql(Howitzer::MailAdapters.const_get(Howitzer.mail_adapter.to_s.capitalize))
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '.adapter_name' do
|
20
|
-
it { expect(described_class.adapter_name).to eql Howitzer.mail_adapter.to_sym }
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '.adapter=' do
|
24
|
-
subject { described_class.adapter = name }
|
25
|
-
|
26
|
-
context 'when adapter_name is Symbol or String' do
|
27
|
-
let(:name) { Howitzer.mail_adapter }
|
28
|
-
it { expect(described_class.adapter).to eql Howitzer::MailAdapters.const_get(name.to_s.capitalize) }
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'when adapter_name is not Symbol or String' do
|
32
|
-
let(:name) { nil }
|
33
|
-
it { expect { subject }.to raise_error(Howitzer::NoMailAdapterError) }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '.subject' do
|
38
|
-
it do
|
39
|
-
described_class.send(:subject, message_subject)
|
40
|
-
expect(described_class.send(:subject_value)).to eql message_subject
|
41
|
-
expect(described_class.private_methods(true)).to include(:subject_value)
|
42
|
-
end
|
43
|
-
it 'should be protected' do
|
44
|
-
expect { described_class.subject(message_subject) }.to raise_error(NoMethodError)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '.wait_time' do
|
49
|
-
subject { Class.new(described_class) }
|
50
|
-
it 'should be protected' do
|
51
|
-
expect { subject.wait_time(10) }.to raise_error(NoMethodError)
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when specified' do
|
55
|
-
before { subject.send(:wait_time, 10) }
|
56
|
-
it do
|
57
|
-
expect(subject.send(:wait_time_value)).to eql 10
|
58
|
-
expect(subject.private_methods(true)).to include(:wait_time_value)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when missing' do
|
63
|
-
it do
|
64
|
-
expect(subject.send(:wait_time_value)).to eql 60
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '.find_by_recipient' do
|
70
|
-
let(:recipient) { 'test@user.com' }
|
71
|
-
|
72
|
-
context 'simple subject without parameters' do
|
73
|
-
before { described_class.class_eval { subject 'Some title' } }
|
74
|
-
it do
|
75
|
-
expect(described_class.adapter).to receive(:find).with(recipient, 'Some title', wait: 60).once
|
76
|
-
described_class.find_by_recipient(recipient)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'complex subject with 1 parameter' do
|
81
|
-
subject { described_class.find_by_recipient(recipient, name: 'Vasya') }
|
82
|
-
before { described_class.class_eval { subject 'Some title from :name' } }
|
83
|
-
it do
|
84
|
-
expect(described_class.adapter).to receive(:find).with(recipient, 'Some title from Vasya', wait: 60).once
|
85
|
-
subject
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'complex subject with 2 parameters' do
|
90
|
-
subject { described_class.find_by_recipient(recipient, foo: 1, bar: 2) }
|
91
|
-
before { described_class.class_eval { subject 'Some title with :foo and :bar' } }
|
92
|
-
it do
|
93
|
-
expect(described_class.adapter).to receive(:find).with(recipient, 'Some title with 1 and 2', wait: 60).once
|
94
|
-
subject
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'missing subject' do
|
99
|
-
subject { described_class.find_by_recipient(recipient) }
|
100
|
-
before do
|
101
|
-
described_class.instance_eval { undef :subject_value }
|
102
|
-
end
|
103
|
-
it do
|
104
|
-
expect { subject }.to raise_error(Howitzer::NoEmailSubjectError)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'nil subject' do
|
109
|
-
subject { described_class.find_by_recipient(recipient) }
|
110
|
-
before { described_class.class_eval { subject nil } }
|
111
|
-
it do
|
112
|
-
expect { subject }.to raise_error(Howitzer::NoEmailSubjectError)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe '#new' do
|
118
|
-
context 'when Email instance receive message and add create @message variable that' do
|
119
|
-
it { expect(email_object.instance_variable_get(:@message)).to eql message }
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe '#plain_text_body' do
|
124
|
-
subject { email_object.plain_text_body }
|
125
|
-
it do
|
126
|
-
expect(message).to receive(:plain_text_body).once
|
127
|
-
subject
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe '#html_body' do
|
132
|
-
subject { email_object.html_body }
|
133
|
-
it do
|
134
|
-
expect(message).to receive(:html_body).once
|
135
|
-
subject
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe '#text' do
|
140
|
-
subject { email_object.text }
|
141
|
-
it do
|
142
|
-
expect(message).to receive(:text).once
|
143
|
-
subject
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe '#mail_from' do
|
148
|
-
subject { email_object.mail_from }
|
149
|
-
it do
|
150
|
-
expect(message).to receive(:mail_from).once
|
151
|
-
subject
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
describe '#recipients' do
|
156
|
-
subject { email_object.recipients }
|
157
|
-
it do
|
158
|
-
expect(message).to receive(:recipients).once
|
159
|
-
subject
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe '#received_time' do
|
164
|
-
subject { email_object.received_time }
|
165
|
-
it do
|
166
|
-
expect(message).to receive(:received_time).once
|
167
|
-
subject
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe '#sender_email' do
|
172
|
-
subject { email_object.sender_email }
|
173
|
-
it do
|
174
|
-
expect(message).to receive(:sender_email).once
|
175
|
-
subject
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe '#mime_part' do
|
180
|
-
subject { email_object.mime_part }
|
181
|
-
it do
|
182
|
-
expect(message).to receive(:mime_part).once
|
183
|
-
subject
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/gmail_api/client'
|
3
|
-
|
4
|
-
RSpec.describe Howitzer::GmailApi::Client do
|
5
|
-
let(:gmail_obj) { described_class.new }
|
6
|
-
let(:recipient) { 'test@gmail.com' }
|
7
|
-
let(:mail_subject) { 'Confirmation instructions' }
|
8
|
-
|
9
|
-
describe '.new' do
|
10
|
-
subject { gmail_obj }
|
11
|
-
it { expect { subject }.not_to raise_error }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#find_message' do
|
15
|
-
let(:mailbox) { double(Gmail::Mailbox) }
|
16
|
-
before do
|
17
|
-
allow(mailbox).to receive(:emails).with(
|
18
|
-
to: recipient, subject: mail_subject
|
19
|
-
) { [Gmail::Message.new('INBOX', 30)] }
|
20
|
-
allow(gmail_obj.instance_variable_get(:@client)).to receive(:inbox) { mailbox }
|
21
|
-
end
|
22
|
-
it do
|
23
|
-
expect(gmail_obj.find_message(recipient, mail_subject)).to be_an_instance_of(Gmail::Message)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer'
|
3
|
-
|
4
|
-
RSpec.describe 'Howitzer' do
|
5
|
-
describe 'SexySettings configuration' do
|
6
|
-
subject { SexySettings.configuration }
|
7
|
-
it { expect(subject.path_to_custom_settings).to include('config/custom.yml') }
|
8
|
-
it { expect(subject.path_to_default_settings).to include('config/default.yml') }
|
9
|
-
end
|
10
|
-
describe '.app_uri' do
|
11
|
-
before do
|
12
|
-
allow(Howitzer).to receive(:app_base_auth_login) { app_base_auth_login_setting }
|
13
|
-
allow(Howitzer).to receive(:app_base_auth_pass) { app_base_auth_pass_setting }
|
14
|
-
allow(Howitzer).to receive(:app_protocol) { app_protocol_setting }
|
15
|
-
allow(Howitzer).to receive(:app_host) { app_host_setting }
|
16
|
-
end
|
17
|
-
let(:app_protocol_setting) { nil }
|
18
|
-
let(:app_host_setting) { 'redmine.strongqa.com' }
|
19
|
-
context 'when login and password present' do
|
20
|
-
let(:app_base_auth_login_setting) { 'alex' }
|
21
|
-
let(:app_base_auth_pass_setting) { 'pa$$w0rd' }
|
22
|
-
it { expect(Howitzer.app_uri.site).to eq('http://alex:pa$$w0rd@redmine.strongqa.com') }
|
23
|
-
it { expect(Howitzer.app_uri.origin).to eq('http://redmine.strongqa.com') }
|
24
|
-
end
|
25
|
-
context 'when login and password blank' do
|
26
|
-
let(:app_base_auth_login_setting) { nil }
|
27
|
-
let(:app_base_auth_pass_setting) { nil }
|
28
|
-
it { expect(Howitzer.app_uri.site).to eq('http://redmine.strongqa.com') }
|
29
|
-
end
|
30
|
-
context 'when custom host exist' do
|
31
|
-
before do
|
32
|
-
allow(Howitzer).to receive(:test_app_base_auth_login) { app_base_auth_login_setting }
|
33
|
-
allow(Howitzer).to receive(:test_app_base_auth_pass) { app_base_auth_pass_setting }
|
34
|
-
allow(Howitzer).to receive(:test_app_protocol) { app_protocol_setting }
|
35
|
-
allow(Howitzer).to receive(:test_app_host) { app_host_setting }
|
36
|
-
end
|
37
|
-
let(:app_host_setting) { 'test.strongqa.com' }
|
38
|
-
let(:app_protocol_setting) { nil }
|
39
|
-
context 'when login and password present' do
|
40
|
-
let(:app_base_auth_login_setting) { 'user' }
|
41
|
-
let(:app_base_auth_pass_setting) { 'password' }
|
42
|
-
it { expect(Howitzer.app_uri(:test).site).to eq('http://user:password@test.strongqa.com') }
|
43
|
-
end
|
44
|
-
context 'when login and password blank' do
|
45
|
-
let(:app_base_auth_login_setting) { nil }
|
46
|
-
let(:app_base_auth_pass_setting) { nil }
|
47
|
-
it { expect(Howitzer.app_uri(:test).site).to eq('http://test.strongqa.com') }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
context 'when configuration settings are not specified for particular application' do
|
51
|
-
it do
|
52
|
-
expect { Howitzer.app_uri(:test).site }.to raise_error(
|
53
|
-
Howitzer::UndefinedSexySettingError,
|
54
|
-
"Undefined 'test_app_base_auth_login' setting. Please add the setting to config/default.yml:\n " \
|
55
|
-
"test_app_base_auth_login: some_value\n"
|
56
|
-
)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
describe '.mailgun_idle_timeout' do
|
61
|
-
subject { Howitzer.mailgun_idle_timeout }
|
62
|
-
before do
|
63
|
-
expect_any_instance_of(Object).to receive(:puts).with(
|
64
|
-
"WARNING! 'mailgun_idle_timeout' setting is deprecated. Please replace with 'mail_wait_time' setting."
|
65
|
-
)
|
66
|
-
end
|
67
|
-
it { is_expected.to be_nil }
|
68
|
-
end
|
69
|
-
describe '.session_name' do
|
70
|
-
context 'when default' do
|
71
|
-
subject { Howitzer.session_name }
|
72
|
-
it do
|
73
|
-
is_expected.to be_eql('default')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
context 'when set' do
|
77
|
-
subject { Howitzer.session_name = 'another' }
|
78
|
-
it do
|
79
|
-
expect(Capybara).to receive(:session_name=).with('another')
|
80
|
-
is_expected.to be_eql('another')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
describe 'using_session' do
|
85
|
-
before { Howitzer.session_name = 'default' }
|
86
|
-
it do
|
87
|
-
expect(Capybara).to receive(:using_session).with('another')
|
88
|
-
Howitzer.using_session('another') {}
|
89
|
-
expect(Howitzer.session_name).to be_eql('default')
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
data/spec/unit/lib/init_spec.rb
DELETED
data/spec/unit/lib/log_spec.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/log'
|
3
|
-
include Howitzer::LoggerHelper
|
4
|
-
|
5
|
-
RSpec.describe Howitzer::Log do
|
6
|
-
context '.instance' do
|
7
|
-
subject { described_class.instance }
|
8
|
-
let(:other_log) { described_class.instance }
|
9
|
-
it { is_expected.to be_a_kind_of(described_class) }
|
10
|
-
it { is_expected.to equal(other_log) }
|
11
|
-
end
|
12
|
-
|
13
|
-
context '.debug' do
|
14
|
-
it do
|
15
|
-
expect(described_class.instance).to receive(:debug).with('Foo')
|
16
|
-
described_class.debug('Foo')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context '.info' do
|
21
|
-
it do
|
22
|
-
expect(described_class.instance).to receive(:info).with('Foo')
|
23
|
-
described_class.info('Foo')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context '.warn' do
|
28
|
-
it do
|
29
|
-
expect(described_class.instance).to receive(:warn).with('Foo')
|
30
|
-
described_class.warn('Foo')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context '.fatal' do
|
35
|
-
it do
|
36
|
-
expect(described_class.instance).to receive(:fatal).with('Foo')
|
37
|
-
described_class.fatal('Foo')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context '.error' do
|
42
|
-
it do
|
43
|
-
expect(described_class.instance).to receive(:error).with('Foo')
|
44
|
-
described_class.error('Foo')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context '.print_feature_name' do
|
49
|
-
it do
|
50
|
-
expect(described_class.instance).to receive(:print_feature_name).with('Foo')
|
51
|
-
described_class.print_feature_name('Foo')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context '.settings_as_formatted_text' do
|
56
|
-
it do
|
57
|
-
expect(described_class.instance).to receive(:settings_as_formatted_text).with(no_args)
|
58
|
-
described_class.settings_as_formatted_text
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context '.print_scenario_name' do
|
63
|
-
it do
|
64
|
-
expect(described_class.instance).to receive(:print_scenario_name).with('Foo')
|
65
|
-
described_class.print_scenario_name('Foo')
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#debug' do
|
70
|
-
it do
|
71
|
-
expect(described_class.instance.instance_variable_get(:@logger)).to receive(:debug).with(:foo)
|
72
|
-
described_class.instance.debug :foo
|
73
|
-
end
|
74
|
-
end
|
75
|
-
describe '#info' do
|
76
|
-
it do
|
77
|
-
expect(described_class.instance.instance_variable_get(:@logger)).to receive(:info).with(:foo)
|
78
|
-
described_class.instance.info :foo
|
79
|
-
end
|
80
|
-
end
|
81
|
-
describe '#warn' do
|
82
|
-
it do
|
83
|
-
expect(described_class.instance.instance_variable_get(:@logger)).to receive(:warn).with(:foo)
|
84
|
-
described_class.instance.warn :foo
|
85
|
-
end
|
86
|
-
end
|
87
|
-
describe '#fatal' do
|
88
|
-
it do
|
89
|
-
expect(described_class.instance.instance_variable_get(:@logger)).to receive(:fatal).with(:foo)
|
90
|
-
described_class.instance.fatal :foo
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#error' do
|
95
|
-
it do
|
96
|
-
expect(described_class.instance.instance_variable_get(:@logger)).to receive(:error).with(:foo)
|
97
|
-
described_class.instance.error :foo
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#print_feature_name' do
|
102
|
-
it do
|
103
|
-
expect(described_class.instance).to receive(:log_without_formatting) { |&arg| arg.call }
|
104
|
-
expect(described_class.instance).to receive(:info).with('*** Feature: FOO ***')
|
105
|
-
described_class.instance.print_feature_name('Foo')
|
106
|
-
end
|
107
|
-
end
|
108
|
-
describe '#settings_as_formatted_text' do
|
109
|
-
it do
|
110
|
-
expect(described_class.instance).to receive(:log_without_formatting) { |&arg| arg.call }
|
111
|
-
expect(described_class.instance).to receive(:info).with(SexySettings::Base.instance.as_formatted_text)
|
112
|
-
described_class.instance.settings_as_formatted_text
|
113
|
-
end
|
114
|
-
end
|
115
|
-
describe '#print_scenario_name' do
|
116
|
-
it do
|
117
|
-
expect(described_class.instance).to receive(:log_without_formatting) { |&arg| arg.call }
|
118
|
-
expect(described_class.instance).to receive(:info).with(' => Scenario: Foo')
|
119
|
-
described_class.instance.print_scenario_name('Foo')
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/email'
|
3
|
-
require 'howitzer/mail_adapters/abstract'
|
4
|
-
|
5
|
-
RSpec.describe Howitzer::MailAdapters::Abstract do
|
6
|
-
let(:recipient) { 'first_tester@gmail.com' }
|
7
|
-
let(:message_subject) { 'test subject' }
|
8
|
-
let(:message) { double(:message) }
|
9
|
-
let(:abstract_adapter) { described_class.new(message) }
|
10
|
-
let(:email_object) { Howitzer::Email.adapter.new(message) }
|
11
|
-
|
12
|
-
describe '.find' do
|
13
|
-
subject { described_class.find(recipient, message_subject, _wait: 10) }
|
14
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#new' do
|
18
|
-
context 'when Email instance receive message and add create @message variable that' do
|
19
|
-
it { expect(email_object.instance_variable_get(:@message)).to eql message }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#plain_text_body' do
|
24
|
-
subject { abstract_adapter.plain_text_body }
|
25
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#html_body' do
|
29
|
-
subject { abstract_adapter.html_body }
|
30
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#text' do
|
34
|
-
subject { abstract_adapter.text }
|
35
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#mail_from' do
|
39
|
-
subject { abstract_adapter.mail_from }
|
40
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#recipients' do
|
44
|
-
subject { abstract_adapter.recipients }
|
45
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#received_time' do
|
49
|
-
subject { abstract_adapter.received_time }
|
50
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#sender_email' do
|
54
|
-
subject { abstract_adapter.sender_email }
|
55
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#mime_part' do
|
59
|
-
subject { abstract_adapter.mime_part }
|
60
|
-
it { expect { subject }.to raise_error(NotImplementedError) }
|
61
|
-
end
|
62
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/email'
|
3
|
-
require 'howitzer/log'
|
4
|
-
require 'howitzer/exceptions'
|
5
|
-
RSpec.describe 'Gmail Email Adapter' do
|
6
|
-
before do
|
7
|
-
allow(Howitzer).to receive(:mail_adapter) { 'gmail' }
|
8
|
-
Howitzer::Email.adapter = 'gmail'
|
9
|
-
end
|
10
|
-
let(:email) { 'test@gmail.com' }
|
11
|
-
let(:mail_subject) { 'Confirmation instructions' }
|
12
|
-
let(:message) { double(Gmail::Message) }
|
13
|
-
let(:email_object) { Howitzer::Email.adapter.new(message) }
|
14
|
-
let(:client) { instance_double(Howitzer::GmailApi::Client) }
|
15
|
-
let(:to_msg) { { 'name' => 'test', 'route' => nil, 'mailbox' => 'test', 'host' => 'gmail.com' } }
|
16
|
-
let(:attachment) do
|
17
|
-
'--f403043c3de80c1017055511c33d
|
18
|
-
Content-Type: text/plain; charset="US-ASCII"; name="te.txt"
|
19
|
-
Content-Disposition: attachment; filename="te.txt"
|
20
|
-
Content-Transfer-Encoding: base64
|
21
|
-
X-Attachment-Id: f_j5iaurws0'
|
22
|
-
end
|
23
|
-
before do
|
24
|
-
allow_any_instance_of(Howitzer::GmailApi::Client).to receive(:find_message).with(
|
25
|
-
email,
|
26
|
-
mail_subject
|
27
|
-
) { message }
|
28
|
-
allow_any_instance_of(Howitzer::GmailApi::Client).to receive(:find_message).with(
|
29
|
-
email,
|
30
|
-
'Wrong subject'
|
31
|
-
) { nil }
|
32
|
-
end
|
33
|
-
describe '.find' do
|
34
|
-
subject { Howitzer::MailAdapters::Gmail.find(email, mail_subject, wait: 0.01) }
|
35
|
-
context 'when message is found' do
|
36
|
-
it do
|
37
|
-
expect(Howitzer::Email.adapter).to receive(:new).with(message).once
|
38
|
-
subject
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when message is not found' do
|
43
|
-
let(:mail_subject) { 'Wrong subject' }
|
44
|
-
it do
|
45
|
-
expect { subject }.to raise_error(
|
46
|
-
Howitzer::EmailNotFoundError,
|
47
|
-
"Message with subject '#{mail_subject}' for recipient '#{email}' was not found."
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#plain_text_body' do
|
54
|
-
before { allow(message).to receive(:body) { Mail::Body.new('test body') } }
|
55
|
-
it { expect(email_object.plain_text_body).to eql 'test body' }
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#html_body' do
|
59
|
-
before do
|
60
|
-
html_part = <<-HTML
|
61
|
-
Content-Type: text/html;
|
62
|
-
charset=UTF-8
|
63
|
-
Content-Transfer-Encoding: 7bit
|
64
|
-
<p>test body</p>
|
65
|
-
HTML
|
66
|
-
allow(message).to receive(:html_part) { Mail::Part.new(html_part) }
|
67
|
-
end
|
68
|
-
it { expect(email_object.html_body).to include('<p>test body</p>') }
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '#text' do
|
72
|
-
before { allow(message).to receive(:text_part) { Mail::Part.new('test text part') } }
|
73
|
-
it { expect(email_object.text).to include 'test text part' }
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '#mail_from' do
|
77
|
-
before { allow(message).to receive(:from) { [to_msg] } }
|
78
|
-
it { expect(email_object.mail_from).to eql email }
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#recipients' do
|
82
|
-
context 'when one recipient' do
|
83
|
-
before { allow(message).to receive(:to) { [to_msg] } }
|
84
|
-
it { expect(email_object.recipients).to include email }
|
85
|
-
end
|
86
|
-
context 'when several recipients' do
|
87
|
-
before { allow(message).to receive(:to) { [to_msg, to_msg.merge('mailbox' => 'test2')] } }
|
88
|
-
it { expect(email_object.recipients).to eql [email, 'test2@gmail.com'] }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe '#received_time' do
|
93
|
-
before { allow(message).to receive(:date) { 'Mon, 24 Jul 2017 18:20:58 +0300' } }
|
94
|
-
it { expect(email_object.received_time).to eql Time.parse('Mon, 24 Jul 2017 18:20:58 +0300').strftime('%F %T') }
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#sender_email' do
|
98
|
-
before { allow(message).to receive(:from) { [to_msg] } }
|
99
|
-
it { expect(email_object.mail_from).to eql email }
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#mime_part' do
|
103
|
-
before { allow(message).to receive(:attachments) { Mail::AttachmentsList.new([Mail::Part.new(attachment)]) } }
|
104
|
-
context 'when has attachments'
|
105
|
-
it { expect(email_object.mime_part).not_to be_empty }
|
106
|
-
|
107
|
-
context 'when no attachments' do
|
108
|
-
it do
|
109
|
-
allow(message).to receive(:attachments) { [] }
|
110
|
-
expect(email_object.mime_part).to be_empty
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe '#mime_part!' do
|
116
|
-
before { allow(message).to receive(:attachments) { Mail::AttachmentsList.new([Mail::Part.new(attachment)]) } }
|
117
|
-
context 'when has attachments' do
|
118
|
-
it { expect(email_object.mime_part!).not_to be_empty }
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'when no attachments' do
|
122
|
-
it do
|
123
|
-
allow(message).to receive(:attachments) { [] }
|
124
|
-
expect { email_object.mime_part! }.to raise_error(Howitzer::NoAttachmentsError, 'No attachments were found.')
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|