howitzer 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.md +25 -5
- data/GETTING_STARTED.md +158 -13
- data/README.md +49 -32
- data/Rakefile +10 -1
- data/bin/howitzer +49 -78
- data/features/cli_help.feature +30 -0
- data/features/cli_new.feature +263 -0
- data/features/cli_unknown.feature +17 -0
- data/features/cli_version.feature +14 -0
- data/features/step_definitions/common_steps.rb +1 -0
- data/features/support/env.rb +1 -0
- data/features/support/transformers.rb +3 -0
- data/generators/base_generator.rb +2 -0
- data/generators/config/config_generator.rb +1 -1
- data/generators/config/templates/default.yml +4 -14
- data/generators/cucumber/cucumber_generator.rb +1 -1
- data/generators/cucumber/templates/cucumber.yml +1 -2
- data/generators/cucumber/templates/env.rb +8 -7
- data/generators/emails/emails_generator.rb +1 -1
- data/generators/pages/pages_generator.rb +1 -1
- data/generators/pages/templates/example_page.rb +2 -2
- data/generators/root/root_generator.rb +1 -1
- data/generators/root/templates/Gemfile +1 -1
- data/generators/rspec/rspec_generator.rb +1 -1
- data/generators/rspec/templates/example_spec.rb +2 -2
- data/generators/rspec/templates/rspec.rake +1 -1
- data/generators/rspec/templates/spec_helper.rb +6 -5
- data/generators/tasks/tasks_generator.rb +1 -1
- data/generators/tasks/templates/common.rake +1 -0
- data/howitzer.gemspec +8 -8
- data/lib/howitzer.rb +4 -1
- data/lib/howitzer/blank_page.rb +6 -0
- data/lib/howitzer/capybara/dsl_ex.rb +15 -0
- data/lib/howitzer/capybara/settings.rb +267 -0
- data/lib/howitzer/email.rb +134 -0
- data/lib/howitzer/exceptions.rb +18 -0
- data/lib/howitzer/helpers.rb +34 -23
- data/lib/howitzer/init.rb +1 -4
- data/lib/howitzer/mailgun/client.rb +48 -0
- data/lib/howitzer/mailgun/connector.rb +34 -0
- data/lib/howitzer/mailgun/response.rb +28 -0
- data/lib/howitzer/utils.rb +2 -2
- data/lib/howitzer/utils/data_generator/data_storage.rb +15 -2
- data/lib/howitzer/utils/data_generator/gen.rb +14 -10
- data/lib/howitzer/utils/locator_store.rb +14 -7
- data/lib/howitzer/utils/log.rb +2 -0
- data/lib/howitzer/utils/page_validator.rb +74 -27
- data/lib/howitzer/version.rb +1 -1
- data/lib/howitzer/web_page.rb +83 -32
- data/spec/config/default.yml +10 -12
- data/spec/spec_helper.rb +12 -0
- data/spec/support/mailgun_unit_client.rb +60 -0
- data/spec/unit/generators/generators_spec.rb +7 -7
- data/spec/unit/lib/capybara/dsl_ex_spec.rb +60 -0
- data/spec/unit/lib/{capybara_settings_spec.rb → capybara/settings_spec.rb} +16 -10
- data/spec/unit/lib/email_spec.rb +129 -0
- data/spec/unit/lib/helpers_spec.rb +160 -34
- data/spec/unit/lib/init_spec.rb +1 -12
- data/spec/unit/lib/mailgun/client_spec.rb +36 -0
- data/spec/unit/lib/mailgun/connector_spec.rb +70 -0
- data/spec/unit/lib/mailgun/response_spec.rb +29 -0
- data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +23 -5
- data/spec/unit/lib/utils/data_generator/gen_spec.rb +2 -63
- data/spec/unit/lib/utils/locator_store_spec.rb +41 -6
- data/spec/unit/lib/utils/log_spec.rb +1 -1
- data/spec/unit/lib/utils/page_validator_spec.rb +149 -25
- data/spec/unit/lib/web_page_spec.rb +127 -53
- metadata +102 -142
- data/lib/howitzer/utils/capybara_patched.rb +0 -23
- data/lib/howitzer/utils/capybara_settings.rb +0 -247
- data/lib/howitzer/utils/email/email.rb +0 -85
- data/lib/howitzer/utils/email/mail_client.rb +0 -132
- data/lib/howitzer/utils/email/mailgun.rb +0 -175
- data/lib/howitzer/utils/email/mailgun_helper.rb +0 -61
- data/spec/unit/bin/howitzer_spec.rb +0 -175
- data/spec/unit/lib/utils/email/email_spec.rb +0 -75
- data/spec/unit/lib/utils/email/mail_client_spec.rb +0 -115
- data/spec/unit/lib/utils/email/mailgun_helper_spec.rb +0 -95
@@ -1,115 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "#{lib_path}/howitzer/utils/log"
|
3
|
-
require "#{lib_path}/howitzer/utils/email/mail_client"
|
4
|
-
|
5
|
-
describe MailClient do
|
6
|
-
|
7
|
-
describe ".default" do
|
8
|
-
subject { MailClient.default }
|
9
|
-
it do
|
10
|
-
expect(log).to receive(:info).with("Connect to default mailbox").once
|
11
|
-
expect(subject).to be_instance_of(MailClient)
|
12
|
-
options = {
|
13
|
-
smtp: {
|
14
|
-
address: "smtp.demo.com",
|
15
|
-
port: 25,
|
16
|
-
domain: "demo.com",
|
17
|
-
user_name: "test_user",
|
18
|
-
password: "mypass",
|
19
|
-
authentication: "plain",
|
20
|
-
enable_starttls_auto: true
|
21
|
-
},
|
22
|
-
pop3: {
|
23
|
-
address: "pop.demo.com",
|
24
|
-
port: 995,
|
25
|
-
user_name: "test_user",
|
26
|
-
password: "mypass"
|
27
|
-
}
|
28
|
-
}
|
29
|
-
expect(subject.instance_variable_get(:@options)).to eql(options)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe ".by_email" do
|
34
|
-
subject { MailClient.by_email("vasya@gmail.com") }
|
35
|
-
it do
|
36
|
-
expect(log).to receive(:info).with("Connect to 'vasya@gmail.com' mailbox").once
|
37
|
-
expect(subject).to be_instance_of(MailClient)
|
38
|
-
options = {
|
39
|
-
smtp: {
|
40
|
-
address: "smtp.demo.com",
|
41
|
-
port: 25,
|
42
|
-
domain: "demo.com",
|
43
|
-
user_name: "test_user",
|
44
|
-
password: "mypass",
|
45
|
-
authentication: "plain",
|
46
|
-
enable_starttls_auto: true
|
47
|
-
},
|
48
|
-
pop3: {
|
49
|
-
address: "pop.demo.com",
|
50
|
-
port: 995,
|
51
|
-
user_name: "vasya@gmail.com",
|
52
|
-
password: "mypass"
|
53
|
-
}
|
54
|
-
}
|
55
|
-
expect(subject.instance_variable_get(:@options)).to eql(options)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe ".merge_opts" do
|
60
|
-
subject { MailClient.merge_opts(*options) }
|
61
|
-
context "when default options" do
|
62
|
-
let(:expected_option) do
|
63
|
-
{
|
64
|
-
smtp: {
|
65
|
-
address: "smtp.demo.com",
|
66
|
-
port: 25,
|
67
|
-
domain: "demo.com",
|
68
|
-
user_name: "test_user",
|
69
|
-
password: "mypass",
|
70
|
-
authentication: "plain",
|
71
|
-
enable_starttls_auto: true
|
72
|
-
},
|
73
|
-
pop3: {
|
74
|
-
address: "pop.demo.com",
|
75
|
-
port: 995,
|
76
|
-
user_name: "test_user",
|
77
|
-
password: "mypass"
|
78
|
-
}
|
79
|
-
}
|
80
|
-
end
|
81
|
-
let(:options) { [] }
|
82
|
-
it { expect(subject).to eql(expected_option) }
|
83
|
-
end
|
84
|
-
context "when custom options" do
|
85
|
-
let(:options) do
|
86
|
-
[{
|
87
|
-
smtp: {
|
88
|
-
address: 'fake_address',
|
89
|
-
port: 1123,
|
90
|
-
domain: 'fake_domain',
|
91
|
-
user_name: "fake_user_name",
|
92
|
-
password: "fake_password",
|
93
|
-
authentication: "plain",
|
94
|
-
enable_starttls_auto: true
|
95
|
-
},
|
96
|
-
pop3: {
|
97
|
-
address: "fake_address",
|
98
|
-
port: 999,
|
99
|
-
user_name: "fake_user_name",
|
100
|
-
password: "fake_password"
|
101
|
-
}
|
102
|
-
}]
|
103
|
-
end
|
104
|
-
it { expect(subject).to eql(options.first)}
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "#find_mail"
|
108
|
-
describe "#send_mail"
|
109
|
-
describe "#empty_inbox"
|
110
|
-
describe "#start"
|
111
|
-
describe "constructor"
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require "#{lib_path}/howitzer/utils/log"
|
3
|
-
require "#{lib_path}/howitzer/utils/email/mailgun_helper"
|
4
|
-
|
5
|
-
describe MailgunHelper do
|
6
|
-
let(:mailgun) { double.extend MailgunHelper }
|
7
|
-
let(:user_name) { 'vasyapupkin' }
|
8
|
-
let(:settings_obj) { double }
|
9
|
-
let(:mbox) { double }
|
10
|
-
before do
|
11
|
-
stub_const('Mailbox', double)
|
12
|
-
end
|
13
|
-
describe "#create_mailbox" do
|
14
|
-
subject { mailgun.create_mailbox(user_name, *opts) }
|
15
|
-
before do
|
16
|
-
expect(log).to receive(:info).with(log_message).once
|
17
|
-
allow(Mailbox).to receive(:new).and_return(mbox)
|
18
|
-
expect(mbox).to receive(:upsert).once
|
19
|
-
end
|
20
|
-
context "when domain and password are present" do
|
21
|
-
let(:log_message) { "Create 'vasyapupkin@mail.ru' mailbox" }
|
22
|
-
let(:opts) { ['mail.ru', '123'] }
|
23
|
-
it { expect(subject).to eql(mbox) }
|
24
|
-
end
|
25
|
-
context "when domain and password are missed" do
|
26
|
-
let(:opts) { [] }
|
27
|
-
let(:log_message) { "Create 'vasyapupkin@test.com' mailbox" }
|
28
|
-
before do
|
29
|
-
allow(mailgun).to receive(:settings).and_return(settings_obj)
|
30
|
-
allow(settings_obj).to receive(:mail_pop3_domain).and_return('test.com')
|
31
|
-
allow(settings_obj).to receive(:mail_pop3_user_pass).and_return('test123')
|
32
|
-
end
|
33
|
-
it { expect(subject).to eql(mbox) }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#delete_mailbox" do
|
38
|
-
subject{ mailgun.delete_mailbox(mbox)}
|
39
|
-
before do
|
40
|
-
allow(mbox).to receive(:user).and_return('vasyapupkin')
|
41
|
-
allow(mbox).to receive(:domain).and_return('mail.ru')
|
42
|
-
expect(log).to receive(:info).with("Delete 'vasyapupkin@mail.ru' mailbox").once
|
43
|
-
end
|
44
|
-
context "when successful result" do
|
45
|
-
before {expect(Mailbox).to receive(:remove).with(mbox).and_return(true)}
|
46
|
-
it { expect(subject).to be_true }
|
47
|
-
end
|
48
|
-
context "when impossible to remove mailbox" do
|
49
|
-
before {expect(Mailbox).to receive(:remove).with(mbox).and_raise('Test error message')}
|
50
|
-
it do
|
51
|
-
expect(log).to receive(:warn).with("Unable to delete 'vasyapupkin' mailbox: Test error message")
|
52
|
-
subject
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#delete_all_mailboxes" do
|
58
|
-
let(:domain) { 'mail.ru' }
|
59
|
-
let(:mailbox1) do
|
60
|
-
m = double
|
61
|
-
allow(m).to receive(:id).and_return(1)
|
62
|
-
allow(m).to receive(:user).and_return('vasyapupkin')
|
63
|
-
allow(m).to receive(:domain).and_return(domain)
|
64
|
-
m
|
65
|
-
end
|
66
|
-
let(:mailbox2) do
|
67
|
-
m = double
|
68
|
-
allow(m).to receive(:id).and_return(2)
|
69
|
-
allow(m).to receive(:user).and_return('postmaster')
|
70
|
-
allow(m).to receive(:domain).and_return(domain)
|
71
|
-
m
|
72
|
-
end
|
73
|
-
let(:mailbox3) do
|
74
|
-
m = double
|
75
|
-
allow(m).to receive(:id).and_return(3)
|
76
|
-
allow(m).to receive(:user).and_return('admin')
|
77
|
-
allow(m).to receive(:domain).and_return(domain)
|
78
|
-
m
|
79
|
-
end
|
80
|
-
let(:mail_for_exception){ 'admin@mail.ru' }
|
81
|
-
subject{mailgun.delete_all_mailboxes(mail_for_exception)}
|
82
|
-
before do
|
83
|
-
allow(settings).to receive(:mail_smtp_domain).and_return("mail.ru")
|
84
|
-
allow(Mailbox).to receive(:find).with(:all).and_return([mailbox1, mailbox2, mailbox3])
|
85
|
-
end
|
86
|
-
it do
|
87
|
-
expect(log).to receive(:info).with("Delete all mailboxes except: \"admin@mail.ru\", \"postmaster@mail.ru\"")
|
88
|
-
expect(Mailbox).to receive(:delete).with(1).once
|
89
|
-
expect(Mailbox).to_not receive(:delete).with(2)
|
90
|
-
expect(Mailbox).to_not receive(:delete).with(3)
|
91
|
-
expect(log).to receive(:info).with("Were deleted '1' mailboxes")
|
92
|
-
subject
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|