howitzer 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +32 -0
  4. data/.travis.yml +1 -4
  5. data/.yardopts +1 -2
  6. data/CHANGELOG.md +28 -1
  7. data/Gemfile +6 -0
  8. data/LICENSE +1 -1
  9. data/README.md +55 -85
  10. data/Rakefile +7 -7
  11. data/bin/howitzer +56 -31
  12. data/features/cli_new.feature +162 -79
  13. data/features/cli_update.feature +114 -21
  14. data/features/step_definitions/common_steps.rb +29 -9
  15. data/features/support/env.rb +1 -1
  16. data/features/support/transformers.rb +2 -2
  17. data/generators/base_generator.rb +121 -49
  18. data/generators/config/config_generator.rb +8 -5
  19. data/generators/config/templates/boot.rb +14 -0
  20. data/generators/config/templates/capybara.rb +156 -0
  21. data/generators/config/templates/custom.yml +2 -3
  22. data/generators/config/templates/default.yml +50 -82
  23. data/generators/cucumber/cucumber_generator.rb +9 -9
  24. data/generators/cucumber/templates/common_steps.rb +4 -4
  25. data/generators/cucumber/templates/cucumber.rake +63 -54
  26. data/generators/cucumber/templates/env.rb +24 -23
  27. data/generators/cucumber/templates/transformers.rb +23 -15
  28. data/generators/emails/emails_generator.rb +4 -2
  29. data/generators/emails/templates/example_email.rb +4 -4
  30. data/generators/prerequisites/prerequisites_generator.rb +24 -0
  31. data/generators/prerequisites/templates/base.rb +22 -0
  32. data/generators/prerequisites/templates/factory_girl.rb +30 -0
  33. data/generators/prerequisites/templates/user.rb +7 -0
  34. data/generators/prerequisites/templates/users.rb +12 -0
  35. data/generators/root/root_generator.rb +11 -7
  36. data/generators/root/templates/.rubocop.yml +32 -0
  37. data/generators/root/templates/Gemfile.erb +27 -0
  38. data/generators/root/templates/Rakefile +6 -8
  39. data/generators/rspec/rspec_generator.rb +7 -7
  40. data/generators/rspec/templates/example_spec.rb +1 -1
  41. data/generators/rspec/templates/rspec.rake +48 -29
  42. data/generators/rspec/templates/spec_helper.rb +33 -32
  43. data/generators/tasks/tasks_generator.rb +4 -2
  44. data/generators/tasks/templates/common.rake +1 -16
  45. data/generators/turnip/templates/.rspec +1 -0
  46. data/generators/turnip/templates/common_steps.rb +25 -0
  47. data/generators/turnip/templates/example.feature +8 -0
  48. data/generators/turnip/templates/spec_helper.rb +56 -0
  49. data/generators/turnip/templates/turnip.rake +61 -0
  50. data/generators/turnip/templates/turnip_helper.rb +6 -0
  51. data/generators/turnip/turnip_generator.rb +26 -0
  52. data/generators/web/templates/example_page.rb +15 -0
  53. data/generators/web/templates/menu_section.rb +13 -0
  54. data/generators/web/web_generator.rb +22 -0
  55. data/howitzer.gemspec +14 -21
  56. data/lib/howitzer.rb +47 -7
  57. data/lib/howitzer/cache.rb +70 -0
  58. data/lib/howitzer/capybara_helpers.rb +194 -0
  59. data/lib/howitzer/email.rb +96 -104
  60. data/lib/howitzer/exceptions.rb +10 -6
  61. data/lib/howitzer/log.rb +120 -0
  62. data/lib/howitzer/mail_adapters.rb +7 -0
  63. data/lib/howitzer/mail_adapters/abstract.rb +84 -0
  64. data/lib/howitzer/mail_adapters/mailgun.rb +115 -0
  65. data/lib/howitzer/mailgun_api.rb +9 -0
  66. data/lib/howitzer/mailgun_api/client.rb +79 -0
  67. data/lib/howitzer/mailgun_api/connector.rb +37 -0
  68. data/lib/howitzer/mailgun_api/response.rb +28 -0
  69. data/lib/howitzer/tasks/framework.rake +2 -2
  70. data/lib/howitzer/utils.rb +7 -1
  71. data/lib/howitzer/utils/string_extensions.rb +66 -0
  72. data/lib/howitzer/version.rb +2 -1
  73. data/lib/howitzer/web.rb +11 -0
  74. data/lib/howitzer/web/base_section.rb +27 -0
  75. data/lib/howitzer/web/blank_page.rb +12 -0
  76. data/lib/howitzer/web/capybara_methods_proxy.rb +29 -0
  77. data/lib/howitzer/web/element_dsl.rb +109 -0
  78. data/lib/howitzer/web/iframe_dsl.rb +93 -0
  79. data/lib/howitzer/web/page.rb +173 -0
  80. data/lib/howitzer/web/page_dsl.rb +64 -0
  81. data/lib/howitzer/web/page_validator.rb +118 -0
  82. data/lib/howitzer/web/section.rb +27 -0
  83. data/lib/howitzer/web/section_dsl.rb +154 -0
  84. data/spec/config/custom.yml +10 -1
  85. data/spec/spec_helper.rb +37 -19
  86. data/spec/support/generator_helper.rb +12 -11
  87. data/spec/support/logger_helper.rb +10 -9
  88. data/spec/support/mailgun_unit_client.rb +52 -44
  89. data/spec/support/shared_examples/capybara_context_holder.rb +33 -0
  90. data/spec/support/shared_examples/capybara_methods_proxy.rb +94 -0
  91. data/spec/support/shared_examples/dynamic_section_methods.rb +35 -0
  92. data/spec/support/shared_examples/element_dsl.rb +119 -0
  93. data/spec/unit/generators/base_generator_spec.rb +64 -33
  94. data/spec/unit/generators/config_generator_spec.rb +11 -7
  95. data/spec/unit/generators/cucumber_generator_spec.rb +26 -17
  96. data/spec/unit/generators/emails_generator_spec.rb +10 -6
  97. data/spec/unit/generators/prerequisites_generator_spec.rb +53 -0
  98. data/spec/unit/generators/root_generator_spec.rb +50 -13
  99. data/spec/unit/generators/rspec_generator_spec.rb +9 -9
  100. data/spec/unit/generators/tasks_generator_spec.rb +6 -6
  101. data/spec/unit/generators/turnip_generator_spec.rb +52 -0
  102. data/spec/unit/generators/web_generator_spec.rb +52 -0
  103. data/spec/unit/lib/cache_spec.rb +85 -0
  104. data/spec/unit/lib/capybara_helpers_spec.rb +696 -0
  105. data/spec/unit/lib/email_spec.rb +104 -91
  106. data/spec/unit/lib/howitzer.rb +31 -0
  107. data/spec/unit/lib/init_spec.rb +0 -1
  108. data/spec/unit/lib/log_spec.rb +122 -0
  109. data/spec/unit/lib/mail_adapters/abstract_spec.rb +62 -0
  110. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +163 -0
  111. data/spec/unit/lib/mailgun_api/client_spec.rb +58 -0
  112. data/spec/unit/lib/mailgun_api/connector_spec.rb +54 -0
  113. data/spec/unit/lib/mailgun_api/response_spec.rb +28 -0
  114. data/spec/unit/lib/utils/string_extensions_spec.rb +77 -0
  115. data/spec/unit/lib/web/base_section_spec.rb +41 -0
  116. data/spec/unit/lib/web/element_dsl_spec.rb +17 -0
  117. data/spec/unit/lib/web/iframe_dsl_spec.rb +99 -0
  118. data/spec/unit/lib/web/page_dsl_spec.rb +52 -0
  119. data/spec/unit/lib/web/page_spec.rb +304 -0
  120. data/spec/unit/lib/web/page_validator_spec.rb +218 -0
  121. data/spec/unit/lib/web/section_dsl_spec.rb +165 -0
  122. data/spec/unit/lib/web/section_spec.rb +61 -0
  123. data/spec/unit/version_spec.rb +1 -1
  124. metadata +116 -203
  125. data/GETTING_STARTED.md +0 -774
  126. data/generators/cucumber/templates/cucumber.yml +0 -10
  127. data/generators/pages/pages_generator.rb +0 -21
  128. data/generators/pages/templates/example_menu.rb +0 -15
  129. data/generators/pages/templates/example_page.rb +0 -15
  130. data/generators/root/templates/Gemfile +0 -7
  131. data/generators/root/templates/boot.rb +0 -10
  132. data/lib/howitzer/blank_page.rb +0 -6
  133. data/lib/howitzer/capybara/dsl_ex.rb +0 -15
  134. data/lib/howitzer/capybara/settings.rb +0 -343
  135. data/lib/howitzer/helpers.rb +0 -230
  136. data/lib/howitzer/init.rb +0 -1
  137. data/lib/howitzer/mailgun/client.rb +0 -65
  138. data/lib/howitzer/mailgun/connector.rb +0 -34
  139. data/lib/howitzer/mailgun/response.rb +0 -28
  140. data/lib/howitzer/patches/rawler_patched.rb +0 -86
  141. data/lib/howitzer/settings.rb +0 -27
  142. data/lib/howitzer/utils/data_generator/data_storage.rb +0 -88
  143. data/lib/howitzer/utils/data_generator/gen.rb +0 -135
  144. data/lib/howitzer/utils/locator_store.rb +0 -217
  145. data/lib/howitzer/utils/log.rb +0 -139
  146. data/lib/howitzer/utils/page_validator.rb +0 -133
  147. data/lib/howitzer/vendor/firebug-1.12.1-fx.xpi +0 -0
  148. data/lib/howitzer/vendor/firepath-0.9.7-fx.xpi +0 -0
  149. data/lib/howitzer/web_page.rb +0 -253
  150. data/spec/active_resource.rb +0 -0
  151. data/spec/config/default.yml +0 -26
  152. data/spec/support/boot_helper.rb +0 -15
  153. data/spec/unit/generators/pages_generator_spec.rb +0 -33
  154. data/spec/unit/lib/capybara/dsl_ex_spec.rb +0 -60
  155. data/spec/unit/lib/capybara/settings_spec.rb +0 -441
  156. data/spec/unit/lib/helpers_spec.rb +0 -1129
  157. data/spec/unit/lib/mailgun/client_spec.rb +0 -36
  158. data/spec/unit/lib/mailgun/connector_spec.rb +0 -70
  159. data/spec/unit/lib/mailgun/response_spec.rb +0 -28
  160. data/spec/unit/lib/settings_spec.rb +0 -17
  161. data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +0 -80
  162. data/spec/unit/lib/utils/data_generator/gen_spec.rb +0 -90
  163. data/spec/unit/lib/utils/locator_store_spec.rb +0 -157
  164. data/spec/unit/lib/utils/log_spec.rb +0 -107
  165. data/spec/unit/lib/utils/page_validator_spec.rb +0 -265
  166. data/spec/unit/lib/web_page_spec.rb +0 -346
@@ -0,0 +1,194 @@
1
+ require 'rest-client'
2
+ require 'howitzer/exceptions'
3
+
4
+ module Howitzer
5
+ # This module holds capybara helpers methods
6
+ module CapybaraHelpers
7
+ CHECK_YOUR_SETTINGS_MSG = 'Please check your settings'.freeze
8
+
9
+ # @return [Boolean] true if current driver related with SauceLab,
10
+ # Testingbot or Browserstack cloud service
11
+
12
+ def cloud_driver?
13
+ [:sauce, :testingbot, :browserstack].include?(Howitzer.driver.to_sym)
14
+ end
15
+
16
+ # @return [Boolean] whether or not current browser is
17
+ # Internet Explorer.
18
+ # @raise [CloudBrowserNotSpecifiedError] if cloud driver and missing browser name
19
+ # @raise [SelBrowserNotSpecifiedError] if selenium driver and missing browser name
20
+
21
+ def ie_browser?
22
+ browser? :ie, :iexplore
23
+ end
24
+
25
+ # @return [Boolean] whether or not current browser is FireFox.
26
+ # @raise [CloudBrowserNotSpecifiedError] if cloud driver and missing browser name
27
+ # @raise [SelBrowserNotSpecifiedError] if selenium driver and missing browser name
28
+
29
+ def ff_browser?
30
+ browser? :ff, :firefox
31
+ end
32
+
33
+ # @return [Boolean] whether or not current browser is Google Chrome.
34
+ # @raise [CloudBrowserNotSpecifiedError] if cloud driver and missing browser name
35
+ # @raise [SelBrowserNotSpecifiedError] if selenium driver and missing browser name
36
+
37
+ def chrome_browser?
38
+ browser? :chrome
39
+ end
40
+
41
+ # @return [Boolean] whether or not current browser is Safari.
42
+ # @raise [CloudBrowserNotSpecifiedError] if cloud driver and missing browser name
43
+ # @raise [SelBrowserNotSpecifiedError] if selenium driver and missing browser name
44
+
45
+ def safari_browser?
46
+ browser? :safari
47
+ end
48
+
49
+ # @param time_in_numeric [Integer] number of seconds
50
+ # @return [String] formatted duration time
51
+
52
+ def duration(time_in_numeric)
53
+ secs = time_in_numeric.to_i
54
+ mins = secs / 60
55
+ hours = mins / 60
56
+ return "[#{hours}h #{mins % 60}m #{secs % 60}s]" if hours.positive?
57
+ return "[#{mins}m #{secs % 60}s]" if mins.positive?
58
+ return "[0m #{secs}s]" if secs >= 0
59
+ end
60
+
61
+ # Updates a job status on the job cloud
62
+ # @note SauceLabs is currently supported only
63
+ # @param json_data [String] (for example, {passed: true})
64
+
65
+ def update_cloud_job_status(json_data = {})
66
+ case Howitzer.driver.to_sym
67
+ when :sauce then update_sauce_job_status(json_data)
68
+ else
69
+ '[NOT IMPLEMENTED]'
70
+ end
71
+ end
72
+
73
+ # Tries to load appropriate driver gem
74
+ # @param driver [String] a driver name
75
+ # @param lib [String] what is required to load
76
+ # @param gem [String] a gem name
77
+ # @raise [LoadError] if the gem is missing in a bunder context
78
+
79
+ def load_driver_gem!(driver, lib, gem)
80
+ require lib
81
+ rescue LoadError
82
+ raise LoadError,
83
+ "`:#{driver}` driver is unable to load `#{lib}`, please add `gem '#{gem}'` to your Gemfile."
84
+ end
85
+
86
+ # @return [Hash] selenium capabilities required for a cloud driver
87
+
88
+ def required_cloud_caps
89
+ {
90
+ platform: Howitzer.cloud_platform,
91
+ browserName: Howitzer.cloud_browser_name,
92
+ version: Howitzer.cloud_browser_version,
93
+ name: "#{prefix_name} #{Howitzer.cloud_browser_name}"
94
+ }
95
+ end
96
+
97
+ # Buids selenium driver for a cloud service
98
+ # @param app [<Rack>] a rack application that this server will contain
99
+ # @param caps [Hash] remote capabilities
100
+ # @param url [String] a remote hub url
101
+ # @return [Capybara::Selenium::Driver]
102
+
103
+ def cloud_driver(app, caps, url)
104
+ http_client = ::Selenium::WebDriver::Remote::Http::Default.new
105
+ http_client.timeout = Howitzer.cloud_http_idle_timeout
106
+
107
+ options = {
108
+ url: url,
109
+ desired_capabilities: ::Selenium::WebDriver::Remote::Capabilities.new(caps),
110
+ http_client: http_client,
111
+ browser: :remote
112
+ }
113
+ driver = Capybara::Selenium::Driver.new(app, options)
114
+ driver.browser.file_detector = remote_file_detector
115
+ driver
116
+ end
117
+
118
+ # @return [String] path to cloud resources (logs, videos, etc.)
119
+ # @note Currently SauceLabs is supported only
120
+ # @raise [ArgumentError] if unknown kind
121
+
122
+ def cloud_resource_path(kind)
123
+ case Howitzer.driver.to_sym
124
+ when :sauce then sauce_resource_path(kind)
125
+ else
126
+ '[NOT IMPLEMENTED]'
127
+ end
128
+ end
129
+
130
+ private
131
+
132
+ def browser?(*browser_aliases)
133
+ return cloud_browser?(*browser_aliases) if cloud_driver?
134
+ return selenium_browser?(*browser_aliases) if selenium_driver? || selenium_grid_driver?
135
+ end
136
+
137
+ def cloud_browser?(*browser_aliases)
138
+ unless Howitzer.cloud_browser_name.nil?
139
+ return browser_aliases.include?(Howitzer.cloud_browser_name.to_s.to_sym)
140
+ end
141
+ raise Howitzer::CloudBrowserNotSpecifiedError, CHECK_YOUR_SETTINGS_MSG
142
+ end
143
+
144
+ def selenium_browser?(*browser_aliases)
145
+ unless Howitzer.selenium_browser.nil?
146
+ return browser_aliases.include?(Howitzer.selenium_browser.to_s.to_sym)
147
+ end
148
+ raise Howitzer::SelBrowserNotSpecifiedError, CHECK_YOUR_SETTINGS_MSG
149
+ end
150
+
151
+ def selenium_driver?
152
+ Howitzer.driver.to_sym == :selenium
153
+ end
154
+
155
+ def selenium_grid_driver?
156
+ Howitzer.driver.to_sym == :selenium_grid
157
+ end
158
+
159
+ def prefix_name
160
+ (Howitzer.current_rake_task || 'ALL').upcase
161
+ end
162
+
163
+ def sauce_resource_path(kind)
164
+ name =
165
+ case kind
166
+ when :video then 'video.flv'
167
+ when :server_log then 'selenium-server.log'
168
+ else
169
+ raise ArgumentError, "Unknown '#{kind}' kind"
170
+ end
171
+ host = "https://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@saucelabs.com"
172
+ path = "/rest/#{Howitzer.cloud_auth_login}/jobs/#{session_id}/results/#{name}"
173
+ "#{host}#{path}"
174
+ end
175
+
176
+ def update_sauce_job_status(json_data = {})
177
+ host = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@saucelabs.com"
178
+ path = "/rest/v1/#{Howitzer.cloud_auth_login}/jobs/#{session_id}"
179
+ url = "#{host}#{path}"
180
+ ::RestClient.put url, json_data.to_json, content_type: :json, accept: :json
181
+ end
182
+
183
+ def session_id
184
+ Capybara.current_session.driver.browser.instance_variable_get(:@bridge).session_id
185
+ end
186
+
187
+ def remote_file_detector
188
+ lambda do |args|
189
+ str = args.first.to_s
190
+ str if File.exist?(str)
191
+ end
192
+ end
193
+ end
194
+ end
@@ -1,134 +1,126 @@
1
1
  require 'rspec/matchers'
2
- require 'howitzer/mailgun/connector'
3
2
  require 'howitzer/exceptions'
4
3
 
5
- class Email
6
- include RSpec::Matchers
4
+ module Howitzer
5
+ # This class describes single email
6
+ class Email
7
+ include ::RSpec::Matchers
7
8
 
8
- ##
9
- #
10
- # Creates new email with message
11
- #
12
- # *Parameters:*
13
- # * +message+ - email message
14
- #
9
+ attr_reader :message
15
10
 
16
- def initialize(message)
17
- @message = message
18
- end
11
+ # @return [<MailAdapters::Abstract>] a mail adapter class
12
+
13
+ def self.adapter
14
+ return @adapter if @adapter
15
+ self.adapter = Howitzer.mail_adapter.to_sym
16
+ @adapter
17
+ end
19
18
 
20
- ##
21
- #
22
- # Search mail by recepient
23
- #
24
- # *Parameters:*
25
- # * +recepient+ - recepient's email address
26
- #
19
+ class << self
20
+ attr_reader :adapter_name
27
21
 
28
- def self.find_by_recipient(recipient)
29
- find(recipient, self::SUBJECT)
30
- end
22
+ protected
31
23
 
32
- ##
33
- #
34
- # Search mail by recepient and subject.
35
- #
36
- # *Parameters:*
37
- # * +recepient+ - recepient's email address
38
- # * +subject+ - email subject
39
- #
40
-
41
- def self.find(recipient, subject)
42
- message = {}
43
- retryable(timeout: settings.timeout_small, sleep: settings.timeout_short, silent: true, logger: log, on: Howitzer::EmailNotFoundError) do
44
- events = Mailgun::Connector.instance.client.get("#{Mailgun::Connector.instance.domain}/events", event: 'stored')
45
- event = events.to_h['items'].find do |hash|
46
- hash['message']['recipients'].first == recipient && hash['message']['headers']['subject'] == subject
24
+ # DSL method to specify a subject pattern directly in an email class
25
+ # @param value [String] an email subject with optional placeholders (strings started with : symbol)
26
+ # @example
27
+ # class WelcomeEmail < Howitzer::Email
28
+ # subject 'Welcome on board :name'
29
+ # end
30
+ #
31
+ # WelcomeEmail.find_by_recipient('john.smith@example.com', name: 'John')
32
+ # @!visibility public
33
+
34
+ def subject(value)
35
+ @subject = value
47
36
  end
48
- if event
49
- message = Mailgun::Connector.instance.client.get_url(event['storage']['url']).to_h
50
- else
51
- raise Howitzer::EmailNotFoundError.new('Message not received yet, retry...')
37
+ end
38
+
39
+ # Specifies a mail adapter
40
+ # @param adapter_name [String, Symbol] an email adapter name
41
+ # @raise [NoMailAdapterError] when the adapter name is not String or Symbol
42
+
43
+ def self.adapter=(adapter_name)
44
+ @adapter_name = adapter_name
45
+ case adapter_name
46
+ when Symbol, String
47
+ require "howitzer/mail_adapters/#{adapter_name}"
48
+ @adapter = MailAdapters.const_get(adapter_name.to_s.capitalize.to_s)
49
+ else
50
+ raise Howitzer::NoMailAdapterError
52
51
  end
53
52
  end
54
- log.error Howitzer::EmailNotFoundError, "Message with subject '#{subject}' for recipient '#{recipient}' was not found." if message.empty?
55
- new(message)
56
- end
57
53
 
58
- ##
59
- #
60
- # Returns plain text body of email message
61
- #
54
+ # Searches a mail by a recepient
55
+ # @param recepient [String] recepient's email address
56
+ # @param params [Hash] placeholders with appropriate values
57
+ # @raise [NoEmailSubjectError] when a subject is not specified for the email class
58
+ # @return [Email] an instance of the email message
59
+ # @see .subject
60
+
61
+ def self.find_by_recipient(recipient, params = {})
62
+ raise Howitzer::NoEmailSubjectError, "Please specify email subject. For example:\n" \
63
+ "class SomeEmail < Howitzer::Email\n" \
64
+ " subject ‘some subject text’\nend" if @subject.nil?
65
+ new(adapter.find(recipient, expand_subject(params)))
66
+ end
62
67
 
63
- def plain_text_body
64
- @message['body-plain']
65
- end
68
+ def initialize(message)
69
+ @message = message
70
+ end
66
71
 
67
- ##
68
- #
69
- # Returns html body of email message
70
- #
72
+ # @return [String, nil] a plain text of the email message
71
73
 
72
- def html_body
73
- @message['stripped-html']
74
- end
74
+ def plain_text_body
75
+ message.plain_text_body
76
+ end
75
77
 
76
- ##
77
- #
78
- # Returns mail text
79
- #
78
+ # @return [String, nil] a html body of the email message
80
79
 
81
- def text
82
- @message['stripped-text']
83
- end
80
+ def html_body
81
+ message.html_body
82
+ end
84
83
 
85
- ##
86
- #
87
- # Returns who has send email data in format: User Name <user@email>
88
- #
84
+ # @return [String, nil] a mail text
89
85
 
90
- def mail_from
91
- @message['From']
92
- end
86
+ def text
87
+ message.text
88
+ end
93
89
 
94
- ##
95
- #
96
- # Returns array of recipients who has received current email
97
- #
90
+ # @return [String] who has sent the email data in format: User Name <user@email>
98
91
 
99
- def recipients
100
- @message['To'].split ', '
101
- end
92
+ def mail_from
93
+ message.mail_from
94
+ end
102
95
 
103
- ##
104
- #
105
- # Returns email received time in format:
106
- #
96
+ # @return [Array<String>] array of recipients who has received current email
107
97
 
108
- def received_time
109
- @message['Received'][/\w+, \d+ \w+ \d+ \d+:\d+:\d+ -\d+ \(\w+\)$/]
110
- end
98
+ def recipients
99
+ message.recipients
100
+ end
111
101
 
112
- ##
113
- #
114
- # Returns sender user email
115
- #
102
+ # @return [String] email received time
116
103
 
117
- def sender_email
118
- @message['sender']
119
- end
104
+ def received_time
105
+ message.received_time
106
+ end
120
107
 
121
- ##
122
- #
123
- # Allows to get email MIME attachment
124
- #
108
+ # @return [String] a sender user email
109
+
110
+ def sender_email
111
+ message.sender_email
112
+ end
113
+
114
+ # Allows to get email MIME attachment
115
+
116
+ def mime_part
117
+ message.mime_part
118
+ end
125
119
 
126
- def get_mime_part
127
- files = @message['attachments']
128
- if files.empty?
129
- log.error Howitzer::NoAttachmentsError, 'No attachments where found.'
130
- return
120
+ def self.expand_subject(params)
121
+ params.each { |k, v| @subject.sub!(":#{k}", v.to_s) }
122
+ @subject
131
123
  end
132
- files
124
+ private_class_method :expand_subject
133
125
  end
134
126
  end
@@ -1,18 +1,22 @@
1
+ # This module holds all custom howitzer exceptions
1
2
  module Howitzer
2
3
  CommunicationError = Class.new(StandardError)
3
4
  ParseError = Class.new(StandardError)
4
5
  InvalidApiKeyError = Class.new(StandardError)
5
- LocatorNotDefinedError = Class.new(StandardError)
6
- BadLocatorParamsError = Class.new(StandardError)
7
- WrongOptionError = Class.new(StandardError)
6
+ BadElementParamsError = Class.new(StandardError)
8
7
  NoValidationError = Class.new(StandardError)
9
8
  UnknownValidationError = Class.new(StandardError)
10
9
  EmailNotFoundError = Class.new(StandardError)
11
10
  NoAttachmentsError = Class.new(StandardError)
12
11
  DriverNotSpecifiedError = Class.new(StandardError)
13
- SlBrowserNotSpecifiedError = Class.new(StandardError)
14
- TbBrowserNotSpecifiedError = Class.new(StandardError)
12
+ UnknownDriverError = Class.new(StandardError)
13
+ CloudBrowserNotSpecifiedError = Class.new(StandardError)
15
14
  SelBrowserNotSpecifiedError = Class.new(StandardError)
15
+ UnknownBrowserError = Class.new(StandardError)
16
16
  IncorrectPageError = Class.new(StandardError)
17
17
  AmbiguousPageMatchingError = Class.new(StandardError)
18
- end
18
+ NoMailAdapterError = Class.new(StandardError)
19
+ NoPathForPageError = Class.new(StandardError)
20
+ NoEmailSubjectError = Class.new(StandardError)
21
+ NoDataError = Class.new(StandardError)
22
+ end