howitzer 2.1.1 → 2.4.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 (129) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +44 -1
  3. data/LICENSE +1 -1
  4. data/README.md +19 -17
  5. data/generators/base_generator.rb +5 -7
  6. data/generators/config/config_generator.rb +3 -4
  7. data/generators/config/templates/boot.rb +2 -2
  8. data/generators/config/templates/capybara.rb +4 -5
  9. data/generators/config/templates/default.yml +21 -11
  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 +23 -0
  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/cuke_sniffer.rake +2 -2
  20. data/generators/cucumber/templates/env.rb +8 -0
  21. data/generators/cucumber/templates/hooks.rb +9 -3
  22. data/generators/cucumber/templates/transformers.rb +1 -1
  23. data/generators/prerequisites/templates/factory_bot.rb +2 -1
  24. data/generators/root/root_generator.rb +1 -1
  25. data/generators/root/templates/Gemfile.erb +4 -10
  26. data/generators/rspec/templates/spec_helper.rb +6 -5
  27. data/generators/turnip/templates/spec_helper.rb +6 -5
  28. data/generators/web/templates/example_page.rb +1 -1
  29. data/lib/howitzer/cache.rb +20 -19
  30. data/lib/howitzer/capybara_helpers.rb +59 -14
  31. data/lib/howitzer/email.rb +3 -2
  32. data/lib/howitzer/exceptions.rb +21 -21
  33. data/lib/howitzer/gmail_api/client.rb +13 -4
  34. data/lib/howitzer/log.rb +6 -6
  35. data/lib/howitzer/mail_adapters/gmail.rb +3 -0
  36. data/lib/howitzer/mail_adapters/mailgun.rb +3 -1
  37. data/lib/howitzer/mail_adapters/mailtrap.rb +3 -0
  38. data/lib/howitzer/mailgun_api/client.rb +3 -2
  39. data/lib/howitzer/mailgun_api/connector.rb +1 -0
  40. data/lib/howitzer/mailgun_api/response.rb +1 -2
  41. data/lib/howitzer/mailtrap_api/client.rb +1 -1
  42. data/lib/howitzer/meta/actions.rb +35 -0
  43. data/lib/howitzer/meta/element.rb +40 -0
  44. data/lib/howitzer/meta/entry.rb +62 -0
  45. data/lib/howitzer/meta/iframe.rb +41 -0
  46. data/lib/howitzer/meta/section.rb +30 -0
  47. data/lib/howitzer/meta.rb +11 -0
  48. data/lib/howitzer/utils/string_extensions.rb +6 -2
  49. data/lib/howitzer/version.rb +1 -1
  50. data/lib/howitzer/web/base_section.rb +1 -1
  51. data/lib/howitzer/web/capybara_context_holder.rb +1 -0
  52. data/lib/howitzer/web/capybara_methods_proxy.rb +15 -6
  53. data/lib/howitzer/web/element_dsl.rb +104 -44
  54. data/lib/howitzer/web/iframe_dsl.rb +4 -2
  55. data/lib/howitzer/web/page.rb +14 -14
  56. data/lib/howitzer/web/page_dsl.rb +18 -6
  57. data/lib/howitzer/web/page_validator.rb +27 -26
  58. data/lib/howitzer/web/section.rb +13 -2
  59. data/lib/howitzer/web/section_dsl.rb +65 -30
  60. data/lib/howitzer.rb +40 -0
  61. metadata +31 -157
  62. data/.coveralls.yml +0 -1
  63. data/.gitignore +0 -14
  64. data/.rspec +0 -3
  65. data/.rubocop.yml +0 -51
  66. data/.ruby-gemset +0 -1
  67. data/.travis.yml +0 -7
  68. data/Gemfile +0 -14
  69. data/ISSUE_TEMPLATE.md +0 -16
  70. data/MAINTENANCE.md +0 -32
  71. data/Rakefile +0 -38
  72. data/features/cli_help.feature +0 -31
  73. data/features/cli_new.feature +0 -389
  74. data/features/cli_unknown.feature +0 -17
  75. data/features/cli_update.feature +0 -218
  76. data/features/cli_version.feature +0 -14
  77. data/features/step_definitions/common_steps.rb +0 -34
  78. data/features/support/env.rb +0 -1
  79. data/generators/config/templates/drivers/phantomjs.rb +0 -19
  80. data/generators/config/templates/drivers/poltergeist.rb +0 -11
  81. data/generators/config/templates/drivers/webkit.rb +0 -6
  82. data/generators/root/templates/.gitignore +0 -21
  83. data/generators/root/templates/.rubocop.yml +0 -35
  84. data/generators/turnip/templates/.rspec +0 -1
  85. data/howitzer.gemspec +0 -39
  86. data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
  87. data/spec/config/custom.yml +0 -9
  88. data/spec/spec_helper.rb +0 -73
  89. data/spec/support/generator_helper.rb +0 -21
  90. data/spec/support/logger_helper.rb +0 -13
  91. data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
  92. data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
  93. data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
  94. data/spec/support/shared_examples/element_dsl.rb +0 -242
  95. data/spec/unit/generators/base_generator_spec.rb +0 -283
  96. data/spec/unit/generators/config_generator_spec.rb +0 -59
  97. data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
  98. data/spec/unit/generators/emails_generator_spec.rb +0 -35
  99. data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
  100. data/spec/unit/generators/root_generator_spec.rb +0 -75
  101. data/spec/unit/generators/rspec_generator_spec.rb +0 -36
  102. data/spec/unit/generators/tasks_generator_spec.rb +0 -31
  103. data/spec/unit/generators/turnip_generator_spec.rb +0 -52
  104. data/spec/unit/generators/web_generator_spec.rb +0 -52
  105. data/spec/unit/lib/cache_spec.rb +0 -85
  106. data/spec/unit/lib/capybara_helpers_spec.rb +0 -697
  107. data/spec/unit/lib/email_spec.rb +0 -186
  108. data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
  109. data/spec/unit/lib/howitzer_spec.rb +0 -69
  110. data/spec/unit/lib/init_spec.rb +0 -2
  111. data/spec/unit/lib/log_spec.rb +0 -122
  112. data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
  113. data/spec/unit/lib/mail_adapters/gmail_spec.rb +0 -128
  114. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
  115. data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
  116. data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
  117. data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
  118. data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
  119. data/spec/unit/lib/mailtrap_api/client_spec.rb +0 -67
  120. data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
  121. data/spec/unit/lib/web/base_section_spec.rb +0 -43
  122. data/spec/unit/lib/web/element_dsl_spec.rb +0 -22
  123. data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
  124. data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
  125. data/spec/unit/lib/web/page_spec.rb +0 -378
  126. data/spec/unit/lib/web/page_validator_spec.rb +0 -276
  127. data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
  128. data/spec/unit/lib/web/section_spec.rb +0 -63
  129. data/spec/unit/version_spec.rb +0 -8
@@ -1,158 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/email'
3
- require 'howitzer/log'
4
- require 'howitzer/exceptions'
5
- require 'howitzer/mailgun_api/connector'
6
-
7
- RSpec.describe 'Mailgun Email Adapter' do
8
- before do
9
- allow(Howitzer).to receive(:mail_adapter) { 'mailgun' }
10
- Howitzer::Email.adapter = 'mailgun'
11
- end
12
- let(:recipient) { 'first_tester@gmail.com' }
13
- let(:message) do
14
- {
15
- 'body-plain' => 'test body footer',
16
- 'stripped-html' => '<p> test body </p> <p> footer </p>',
17
- 'stripped-text' => 'test body',
18
- 'From' => 'Strong Tester <tester@gmail.com>',
19
- 'To' => recipient,
20
- 'Received' => 'by 10.216.46.75 with HTTP; Sat, 5 Apr 2014 05:10:42 -0700 (PDT)',
21
- 'sender' => 'tester@gmail.com',
22
- 'attachments' => []
23
- }
24
- end
25
- let(:message_subject) { 'test subject' }
26
- let(:mail_address) { double }
27
- let(:email_object) { Howitzer::Email.adapter.new(message) }
28
-
29
- before do
30
- stub_const('Howitzer::Email::SUBJECT', message_subject)
31
- end
32
-
33
- describe '.find' do
34
- let(:mailgun_message) { JSON.generate(message) }
35
- let(:events) { JSON.generate('items' => [event]) }
36
- before do
37
- FakeWeb.register_uri(:any, 'https://api:mailgun_account_private_key@api.mailgun.net/v3/'\
38
- 'mailgun@test.domain/events?event=stored', body: events.to_s)
39
- FakeWeb.register_uri(:any, 'https://api:mailgun_account_private_key@si.api.mailgun.net/v3/'\
40
- 'domains/mg.strongqa.com/messages/1234567890', body: mailgun_message.to_s)
41
- end
42
- subject { Howitzer::MailAdapters::Mailgun.find(recipient, message_subject, wait: 0.01) }
43
-
44
- context 'when message is found' do
45
- let(:event) do
46
- {
47
- 'message' => {
48
- 'recipients' => [recipient],
49
- 'headers' => {
50
- 'subject' => message_subject
51
- }
52
- },
53
- 'storage' => {
54
- 'key' => '1234567890',
55
- 'url' => 'https://si.api.mailgun.net/v3/domains/mg.strongqa.com/messages/1234567890'
56
- }
57
- }
58
- end
59
- it do
60
- expect(Howitzer::Email.adapter).to receive(:new).with(message).once
61
- subject
62
- end
63
- end
64
-
65
- context 'when message is not found' do
66
- let(:event) do
67
- {
68
- 'message' => {
69
- 'recipients' => ['other@test.com'],
70
- 'headers' => {
71
- 'subject' => message_subject
72
- }
73
- },
74
- 'storage' => {
75
- 'key' => '1234567890',
76
- 'url' => 'https://si.api.mailgun.net/v3/domains/mg.strongqa.com/messages/1234567890'
77
- }
78
- }
79
- end
80
- it do
81
- expect { subject }.to raise_error(
82
- Howitzer::EmailNotFoundError,
83
- "Message with subject '#{message_subject}' for recipient '#{recipient}' was not found."
84
- )
85
- end
86
- end
87
- end
88
-
89
- describe '#plain_text_body' do
90
- it { expect(email_object.plain_text_body).to eql message['body-plain'] }
91
- end
92
-
93
- describe '#html_body' do
94
- it { expect(email_object.html_body).to eql message['stripped-html'] }
95
- end
96
-
97
- describe '#text' do
98
- it { expect(email_object.text).to eql message['stripped-text'] }
99
- end
100
-
101
- describe '#mail_from' do
102
- it { expect(email_object.mail_from).to eql message['From'] }
103
- end
104
-
105
- describe '#recipients' do
106
- subject { email_object.recipients }
107
- it { is_expected.to be_a_kind_of Array }
108
-
109
- context 'when one recipient' do
110
- it { is_expected.to include message['To'] }
111
- end
112
-
113
- context 'when more than one recipient' do
114
- let(:second_recipient) { 'second_tester@gmail.com' }
115
- let(:message_with_multiple_recipients) { message.merge('To' => "#{recipient}, #{second_recipient}") }
116
- let(:email_object) { Howitzer::Email.adapter.new(message_with_multiple_recipients) }
117
- it { is_expected.to eql [recipient, second_recipient] }
118
- end
119
- end
120
-
121
- describe '#received_time' do
122
- it { expect(email_object.received_time).to eql message['Received'][27..63] }
123
- end
124
-
125
- describe '#sender_email' do
126
- it { expect(email_object.sender_email).to eql message['sender'] }
127
- end
128
-
129
- describe '#mime_part' do
130
- subject { email_object.mime_part }
131
-
132
- context 'when has attachments' do
133
- let(:files) { [double] }
134
- before { email_object.instance_variable_set(:@message, 'attachments' => files) }
135
- it { is_expected.to eq(files) }
136
- end
137
-
138
- context 'when no attachments' do
139
- it { is_expected.to eq([]) }
140
- end
141
- end
142
-
143
- describe '#mime_part!' do
144
- subject { email_object.mime_part! }
145
-
146
- context 'when has attachments' do
147
- let(:files) { [double] }
148
- before { email_object.instance_variable_set(:@message, 'attachments' => files) }
149
- it { is_expected.to eq(files) }
150
- end
151
-
152
- context 'when no attachments' do
153
- it do
154
- expect { subject }.to raise_error(Howitzer::NoAttachmentsError, 'No attachments were found.')
155
- end
156
- end
157
- end
158
- end
@@ -1,130 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/email'
3
- require 'howitzer/log'
4
- require 'howitzer/exceptions'
5
- RSpec.describe 'Mailtrap Email Adapter' do
6
- before do
7
- allow(Howitzer).to receive(:mail_adapter) { 'mailtrap' }
8
- Howitzer::Email.adapter = 'mailtrap'
9
- allow(Howitzer).to receive(:mailtrap_inbox_id) { 777_777 }
10
- allow(Howitzer).to receive(:mailtrap_api_token) { 'fake_api_token' }
11
- base_url = 'https://mailtrap.io/api/v1/inboxes/777777/messages'
12
- stub_const('Howitzer::MailtrapApi::Client::BASE_URL', base_url.gsub('/messages', ''))
13
- FakeWeb.register_uri(:get, "#{base_url}/475265146/attachments", body: attachment.to_s)
14
- FakeWeb.register_uri(:get, "#{base_url}/32/attachments", body: '[]')
15
- FakeWeb.register_uri(:get, "#{base_url}?search=#{recipient}", body: "[#{message.to_s.gsub('=>', ':')}]")
16
- end
17
- let(:recipient) { 'test@mail.com' }
18
- let(:mail_subject) { 'Confirmation instructions' }
19
- let(:message) do
20
- {
21
- 'id' => 475_265_146,
22
- 'inbox_id' => 777_777,
23
- 'subject' => 'Confirmation instructions',
24
- 'sent_at' => '2017-07-18T08:55:49.389Z',
25
- 'from_email' => 'noreply@test.com',
26
- 'from_name' => '',
27
- 'to_email' => 'test@mail.com',
28
- 'to_name' => '',
29
- 'html_body' => '<p> Test Email! </p>',
30
- 'text_body' => 'Test Email!',
31
- 'created_at' => '2017-07-18T14:14:31.641Z'
32
- }
33
- end
34
- let(:attachment) do
35
- '[{
36
- "id": 1737,
37
- "message_id": 475265146,
38
- "filename": "Photos.png",
39
- "attachment_type": "attachment",
40
- "content_type": "image/png",
41
- "download_path": "/api/v1/inboxes/777777/messages/475265146/attachments/45120545/download"
42
- }]'
43
- end
44
- let(:email_object) { Howitzer::Email.adapter.new(message) }
45
- describe '.find' do
46
- subject { Howitzer::MailAdapters::Mailtrap.find(recipient, mail_subject, wait: 0.01) }
47
- context 'when message is found' do
48
- it do
49
- expect(Howitzer::Email.adapter).to receive(:new).with(message).once
50
- subject
51
- end
52
- end
53
-
54
- context 'when message is not found' do
55
- let(:mail_subject) { 'Wrong subject' }
56
- it do
57
- expect { subject }.to raise_error(
58
- Howitzer::EmailNotFoundError,
59
- "Message with subject '#{mail_subject}' for recipient '#{recipient}' was not found."
60
- )
61
- end
62
- end
63
- end
64
-
65
- describe '#plain_text_body' do
66
- it { expect(email_object.plain_text_body).to eql message['text_body'] }
67
- end
68
-
69
- describe '#html_body' do
70
- it { expect(email_object.html_body).to eql message['html_body'] }
71
- end
72
-
73
- describe '#text' do
74
- it { expect(email_object.text).to eql message['text_body'] }
75
- end
76
-
77
- describe '#mail_from' do
78
- it { expect(email_object.mail_from).to eql message['from_email'] }
79
- end
80
-
81
- describe '#recipients' do
82
- subject { email_object.recipients }
83
- it { is_expected.to be_a_kind_of Array }
84
-
85
- context 'when one recipient' do
86
- it { is_expected.to include message['to_email'] }
87
- end
88
-
89
- context 'when more than one recipient' do
90
- let(:second_recipient) { 'second_tester@gmail.com' }
91
- let(:message_with_multiple_recipients) { message.merge('to_email' => "#{recipient}, #{second_recipient}") }
92
- let(:email_object) { Howitzer::Email.adapter.new(message_with_multiple_recipients) }
93
- it { is_expected.to eql [recipient, second_recipient] }
94
- end
95
- end
96
-
97
- describe '#received_time' do
98
- it { expect(email_object.received_time).to eql Time.parse(message['created_at']).to_s }
99
- end
100
-
101
- describe '#sender_email' do
102
- it { expect(email_object.sender_email).to eql message['from_email'] }
103
- end
104
-
105
- describe '#mime_part' do
106
- context 'when has attachments' do
107
- it { expect(email_object.mime_part).not_to be_empty }
108
- end
109
-
110
- context 'when no attachments' do
111
- let(:another_message) { message.merge('id' => 32) }
112
- let(:email_object) { Howitzer::Email.adapter.new(another_message) }
113
- it { expect(email_object.mime_part).to be_empty }
114
- end
115
- end
116
-
117
- describe '#mime_part!' do
118
- context 'when has attachments' do
119
- it { expect(email_object.mime_part!).not_to be_empty }
120
- end
121
-
122
- context 'when no attachments' do
123
- let(:another_message) { message.merge('id' => 32) }
124
- let(:email_object) { Howitzer::Email.adapter.new(another_message) }
125
- it do
126
- expect { email_object.mime_part! }.to raise_error(Howitzer::NoAttachmentsError, 'No attachments were found.')
127
- end
128
- end
129
- end
130
- end
@@ -1,80 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/mailgun_api/client'
3
-
4
- RSpec.describe Howitzer::MailgunApi::Client do
5
- let(:mg_obj) { described_class.new(api_key: 'Fake-API-Key') }
6
- let(:bounce_msg) do
7
- JSON.generate(
8
- 'total_count' => 1,
9
- 'items' => {
10
- 'created_at' => 'Fri, 21 Oct 2011 11:02:55 GMT',
11
- 'code' => 550,
12
- 'address' => 'baz@example.com',
13
- 'error' => 'Message was not accepted -- invalid mailbox. Local mailbox baz@example.com is" +
14
- " unavailable: user not found'
15
- }
16
- )
17
- end
18
- let(:message) do
19
- {
20
- 'body-plain' => 'test body footer',
21
- 'stripped-html' => '<p> test body </p> <p> footer </p>',
22
- 'stripped-text' => 'test body',
23
- 'From' => 'Strong Tester <tester@gmail.com>',
24
- 'To' => 'baz@example.com',
25
- 'Received' => 'by 10.216.46.75 with HTTP; Sat, 5 Apr 2014 05:10:42 -0700 (PDT)',
26
- 'sender' => 'tester@gmail.com',
27
- 'attachments' => []
28
- }
29
- end
30
- describe '.new' do
31
- subject { mg_obj }
32
- it { expect { subject }.not_to raise_error }
33
- end
34
-
35
- describe '#get' do
36
- let(:query_string) { { 'skip' => '10', 'limit' => '5' } }
37
- subject { mg_obj.get('test.com/bounces', params: query_string) }
38
- context 'when simulation of client' do
39
- before do
40
- FakeWeb.register_uri(:get, 'https://api:Fake-API-Key@api.mailgun.net/v3/test.com/'\
41
- 'bounces?skip=10&limit=5', body: bounce_msg.to_s)
42
- end
43
- it do
44
- expect(subject.body).to include('total_count')
45
- expect(subject.body).to include('items')
46
- end
47
- end
48
- context 'when real client' do
49
- let(:resource) { double }
50
- before do
51
- allow(resource).to receive('[]').and_return(resource)
52
- allow(resource).to receive(:get).and_raise(StandardError, '401 Unauthorized: Forbidden')
53
- allow(RestClient::Resource).to receive(:new).and_return(resource)
54
- end
55
- it do
56
- expect { subject }.to raise_error(Howitzer::CommunicationError, '401 Unauthorized: Forbidden')
57
- end
58
- end
59
- end
60
-
61
- describe '#get_url' do
62
- let(:response_raw) { double }
63
- before do
64
- FakeWeb.register_uri(:any, 'https://api:Fake-API-Key@ci.api.mailgan.com/'\
65
- 'domains/test_domain/messages/asdfasdf', body: JSON.generate(message))
66
- end
67
- subject { mg_obj.get_url('https://ci.api.mailgan.com/domains/test_domain/messages/asdfasdf') }
68
- context 'when success request' do
69
- it { expect(subject.to_h).to eq(message) }
70
- end
71
- context 'when error happens' do
72
- before do
73
- allow(RestClient::Resource).to receive(:new).with(any_args).and_return(response_raw)
74
- mg_obj
75
- allow(RestClient::Request).to receive(:execute).with(any_args).and_raise(StandardError, 'Some message')
76
- end
77
- it { expect { subject }.to raise_error(Howitzer::CommunicationError, 'Some message') }
78
- end
79
- end
80
- end
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/mailgun_api/connector'
3
-
4
- RSpec.describe Howitzer::MailgunApi::Connector do
5
- let(:connector) { described_class.instance }
6
- let(:domain_name) { 'test@domain.com' }
7
- describe '#client' do
8
- subject { connector.client }
9
- context 'when api_key is default' do
10
- context 'when client is not initialized' do
11
- it { is_expected.to be_an_instance_of Howitzer::MailgunApi::Client }
12
- end
13
- context 'when client is already initialized' do
14
- it do
15
- object_id = connector.client.object_id
16
- expect(subject.object_id).to eq(object_id)
17
- end
18
- end
19
- end
20
- context 'when api_key is custom' do
21
- let(:key) { 'some api key' }
22
- subject { connector.client(key) }
23
- it { is_expected.to be_an_instance_of Howitzer::MailgunApi::Client }
24
- end
25
- context 'when api_key is nil' do
26
- let(:key) { nil }
27
- subject { connector.client(key) }
28
- it do
29
- expect { subject }.to raise_error(Howitzer::InvalidApiKeyError, 'Api key can not be blank')
30
- end
31
- end
32
- context 'when api_key is blank string' do
33
- let(:key) { '' }
34
- subject { connector.client(key) }
35
- it do
36
- expect { subject }.to raise_error(Howitzer::InvalidApiKeyError, 'Api key can not be blank')
37
- end
38
- end
39
- end
40
- describe '#domain' do
41
- subject { connector.domain }
42
- context 'when default domain' do
43
- it do
44
- is_expected.to eq(Howitzer.mailgun_domain)
45
- end
46
- end
47
- context 'when domain is already set' do
48
- before do
49
- connector.domain = domain_name
50
- end
51
- it { is_expected.to eql(domain_name) }
52
- end
53
- end
54
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/mailgun_api/client'
3
- require 'howitzer/exceptions'
4
-
5
- RSpec.describe Howitzer::MailgunApi::Response do
6
- let(:body) { { foo: 'bar' }.to_json }
7
- let(:response) { double(:response, body: body, code: 201) }
8
- describe '#body' do
9
- subject { described_class.new(response).body }
10
- it { is_expected.to eq('{"foo":"bar"}') }
11
- end
12
- describe '#code' do
13
- subject { described_class.new(response).code }
14
- it { is_expected.to eq(201) }
15
- end
16
- describe '#to_h' do
17
- subject { described_class.new(response).to_h }
18
- context 'when possible parse body' do
19
- it { is_expected.to eq('foo' => 'bar') }
20
- end
21
- context 'when impossible parse body' do
22
- let(:body) { "'123': '123' :123" }
23
- it do
24
- expect { subject }.to raise_error(Howitzer::ParseError)
25
- end
26
- end
27
- end
28
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/mailtrap_api/client'
3
-
4
- RSpec.describe Howitzer::MailtrapApi::Client do
5
- let(:mailtrap_obj) { described_class.new }
6
- let(:recipient) { 'test@mail.com' }
7
- let(:mail_subject) { 'Confirmation instructions' }
8
- let(:message) do
9
- '[{"id": 475265146,
10
- "inbox_id": 777777,
11
- "subject": "Confirmation instructions",
12
- "sent_at": "2017-07-18T08:55:49.389Z",
13
- "from_email": "noreply@test.com",
14
- "from_name": "",
15
- "to_email": "test@mail.com",
16
- "to_name": "",
17
- "html_body": "<p> Test Email! </p>"}]'
18
- end
19
- let(:attachment) do
20
- '[{
21
- "id": 1737,
22
- "message_id": 475265146,
23
- "filename": "Photos.png",
24
- "attachment_type": "attachment",
25
- "content_type": "image/png"
26
- }]'
27
- end
28
- before do
29
- allow(Howitzer).to receive(:mailtrap_inbox_id) { 777_777 }
30
- allow(Howitzer).to receive(:mailtrap_api_token) { 'fake_api_token' }
31
- stub_const('Howitzer::MailtrapApi::Client::BASE_URL', 'https://mailtrap.io/api/v1/inboxes/777777')
32
- end
33
-
34
- describe '.new' do
35
- subject { mailtrap_obj }
36
- it { expect { subject }.not_to raise_error }
37
- end
38
-
39
- describe '#find_message' do
40
- before do
41
- FakeWeb.register_uri(:get, "https://mailtrap.io/api/v1/inboxes/#{Howitzer.mailtrap_inbox_id}/"\
42
- "messages?search=#{recipient}", body: message.to_s)
43
- end
44
- subject { described_class.new.find_message(recipient, mail_subject) }
45
- it do
46
- expect(subject['to_email']).to eql(recipient)
47
- expect(subject['subject']).to eql(mail_subject)
48
- end
49
- end
50
-
51
- describe '#find_attachements' do
52
- before do
53
- FakeWeb.register_uri(:get, "https://mailtrap.io/api/v1/inboxes/#{Howitzer.mailtrap_inbox_id}/"\
54
- "messages?search=#{recipient}", body: message.to_s)
55
- FakeWeb.register_uri(:get, "https://mailtrap.io/api/v1/inboxes/#{Howitzer.mailtrap_inbox_id}/"\
56
- 'messages/475265146/attachments', body: attachment.to_s)
57
- end
58
- let(:found_message) { described_class.new.find_message(recipient, mail_subject) }
59
- subject { described_class.new.find_attachments(found_message) }
60
- it do
61
- subject.each do |attachment|
62
- expect(attachment['message_id']).to eql found_message['id']
63
- expect(attachment['filename'].to_s).not_to be_empty
64
- end
65
- end
66
- end
67
- end
@@ -1,77 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/utils/string_extensions'
3
-
4
- RSpec.describe Howitzer::Utils::StringExtensions do
5
- String.send(:include, Howitzer::Utils::StringExtensions)
6
-
7
- let(:page_name) { 'my' }
8
- let(:page_object) { double }
9
- before { stub_const('MyPage', page_object) }
10
- describe '#open' do
11
- subject { page_name.open(:exit) }
12
- before do
13
- expect(page_object).to receive(:open).with(:exit).once
14
- end
15
- it { is_expected.to be_nil }
16
- end
17
- describe '#given' do
18
- subject { page_name.given }
19
- before do
20
- allow(page_name).to receive(:as_page_class) { page_object }
21
- expect(page_object).to receive(:given).once
22
- end
23
- it { is_expected.to be_nil }
24
- end
25
- describe '#displayed?' do
26
- subject { page_name.displayed? }
27
- before do
28
- allow(page_name).to receive(:as_page_class) { page_object }
29
- expect(page_object).to receive(:displayed?).once
30
- end
31
- it { is_expected.to be_nil }
32
- end
33
- describe '#as_page_class' do
34
- subject { page_name.as_page_class }
35
- context 'when 1 word' do
36
- it { is_expected.to eql(page_object) }
37
- end
38
- context 'when more 1 word' do
39
- let(:page_name) { 'my super mega' }
40
- before { stub_const('MySuperMegaPage', page_object) }
41
- it { is_expected.to eql(page_object) }
42
- end
43
- context 'when plural word' do
44
- let(:page_name) { 'user notifications' }
45
- before { stub_const('UserNotificationsPage', page_object) }
46
- it { is_expected.to eql(page_object) }
47
- end
48
- end
49
- describe '#as_email_class' do
50
- subject { email_name.as_email_class }
51
- let(:my_email) { double }
52
- context 'when 1 word' do
53
- let(:email_name) { 'my' }
54
- before { stub_const('MyEmail', my_email) }
55
- it { is_expected.to eql(my_email) }
56
- end
57
- context 'when more 1 word' do
58
- let(:email_name) { 'my super mega' }
59
- before { stub_const('MySuperMegaEmail', my_email) }
60
- it { is_expected.to eql(my_email) }
61
- end
62
- context 'when plural word' do
63
- let(:email_name) { 'email notifications' }
64
- before { stub_const('EmailNotificationsEmail', my_email) }
65
- it { is_expected.to eql(my_email) }
66
- end
67
- end
68
- describe '#on' do
69
- let(:block) { -> {} }
70
- subject { page_name.on(&block) }
71
- before do
72
- allow(page_name).to receive(:as_page_class) { page_object }
73
- expect(page_object).to receive(:on).once
74
- end
75
- it { is_expected.to be_nil }
76
- end
77
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/section_dsl'
3
- require 'howitzer/web/base_section'
4
-
5
- RSpec.describe Howitzer::Web::BaseSection do
6
- describe 'element dsl methods' do
7
- let(:parent) { double }
8
- let(:capybara_context) { double }
9
-
10
- let(:klass) { Class.new(described_class) }
11
- let(:klass_object) { klass.new(parent, capybara_context) }
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
- describe 'DSL' do
19
- describe '.me' do
20
- it { expect { described_class.send(:me, '.foo') }.to raise_error(NoMethodError) }
21
- end
22
- end
23
-
24
- describe '.default_finder_args' do
25
- subject { described_class.default_finder_args }
26
- it { is_expected.to be_nil }
27
- end
28
-
29
- describe '#parent' do
30
- subject { described_class.new(:test, 1).parent }
31
- it { is_expected.to eq(:test) }
32
- end
33
-
34
- describe '#capybara_context' do
35
- subject { described_class.new(1, :test).capybara_context }
36
- it { is_expected.to eq(:test) }
37
- end
38
-
39
- describe 'includes proxied capybara methods' do
40
- let(:reciever) { Class.new(described_class).new(:test, 1) }
41
- include_examples :capybara_methods_proxy
42
- end
43
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/element_dsl'
3
-
4
- RSpec.describe Howitzer::Web::ElementDsl do
5
- let(:klass) do
6
- Class.new do
7
- include Howitzer::Web::ElementDsl
8
- def capybara_scopes
9
- @_scopes ||= [Capybara.current_session]
10
- end
11
- end
12
- end
13
- let(:klass_object) { klass.new }
14
-
15
- it 'returns correct capybara context' do
16
- allow(Capybara).to receive(:current_session) { 'session' }
17
- expect(klass_object.capybara_context).to eq('session')
18
- end
19
-
20
- include_examples :element_dsl
21
- include_examples :capybara_context_holder
22
- end