Class: Gitlab::QA::Component::MailHog
- Inherits:
-
Object
- Object
- Gitlab::QA::Component::MailHog
- Includes:
- Scenario::Actable
- Defined in:
- lib/gitlab/qa/component/mail_hog.rb
Constant Summary collapse
- MAILHOG_IMAGE =
'mailhog/mailhog'.freeze
- MAILHOG_IMAGE_TAG =
'v1.0.0'.freeze
Instance Attribute Summary collapse
-
#docker ⇒ Object
readonly
Returns the value of attribute docker.
-
#environment ⇒ Object
Returns the value of attribute environment.
- #name ⇒ Object
-
#network ⇒ Object
Returns the value of attribute network.
Instance Method Summary collapse
- #hostname ⇒ Object
-
#initialize ⇒ MailHog
constructor
A new instance of MailHog.
- #instance ⇒ Object
- #prepare ⇒ Object
- #restart ⇒ Object
- #set_mailhog_hostname ⇒ Object
- #start ⇒ Object
- #teardown ⇒ Object
Methods included from Scenario::Actable
Constructor Details
Instance Attribute Details
#docker ⇒ Object (readonly)
Returns the value of attribute docker.
13 14 15 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 13 def docker @docker end |
#environment ⇒ Object
Returns the value of attribute environment.
14 15 16 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 14 def environment @environment end |
#name ⇒ Object
22 23 24 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 22 def name @name ||= "mailhog" end |
#network ⇒ Object
Returns the value of attribute network.
14 15 16 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 14 def network @network end |
Instance Method Details
#hostname ⇒ Object
26 27 28 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 26 def hostname "#{name}.#{network}" end |
#instance ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 30 def instance raise 'Please provide a block!' unless block_given? prepare start yield self ensure teardown end |
#prepare ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 41 def prepare @docker.pull(MAILHOG_IMAGE, MAILHOG_IMAGE_TAG) return if @docker.network_exists?(network) @docker.network_create(network) end |
#restart ⇒ Object
60 61 62 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 60 def restart @docker.restart(name) end |
#set_mailhog_hostname ⇒ Object
71 72 73 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 71 def set_mailhog_hostname ::Gitlab::QA::Runtime::Env.mailhog_hostname = hostname end |
#start ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 49 def start docker.run(MAILHOG_IMAGE, MAILHOG_IMAGE_TAG) do |command| command << '-d ' command << "--name #{name}" command << "--net #{network}" command << "--hostname #{hostname}" command << "--publish 1025:1025" command << "--publish 8025:8025" end end |
#teardown ⇒ Object
64 65 66 67 68 69 |
# File 'lib/gitlab/qa/component/mail_hog.rb', line 64 def teardown raise 'Invalid instance name!' unless name @docker.stop(name) @docker.remove(name) end |