test: move Postal::RpecHelpers to spec/helpers

This commit is contained in:
Adam Cooke
2024-02-23 22:51:35 +00:00
committed by Adam Cooke
parent 1a4158699c
commit ee86311525
3 changed files with 16 additions and 18 deletions
-17
View File
@@ -1,17 +0,0 @@
# frozen_string_literal: true
module Postal
module RspecHelpers
def create_plain_text_message(server, text, to = "test@example.com", override_attributes = {})
domain = create(:domain, owner: server)
attributes = { from: "test@#{domain.name}", subject: "Test Plain Text Message" }.merge(override_attributes)
attributes[:to] = to
attributes[:plain_body] = text
message = OutgoingMessagePrototype.new(server, "127.0.0.1", "testsuite", attributes)
result = message.create_message(to)
server.message_db.message(result[:id])
end
end
end
+15
View File
@@ -0,0 +1,15 @@
# frozen_string_literal: true
module GeneralHelpers
def create_plain_text_message(server, text, to = "test@example.com", override_attributes = {})
domain = create(:domain, owner: server)
attributes = { from: "test@#{domain.name}", subject: "Test Plain Text Message" }.merge(override_attributes)
attributes[:to] = to
attributes[:plain_body] = text
message = OutgoingMessagePrototype.new(server, "127.0.0.1", "testsuite", attributes)
result = message.create_message(to)
server.message_db.message(result[:id])
end
end
+1 -1
View File
@@ -32,7 +32,7 @@ RSpec.configure do |config|
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.include FactoryBot::Syntax::Methods
config.include Postal::RspecHelpers
config.include GeneralHelpers
config.before(:suite) do
# Test that the factories are working as they should and then clean up before getting started on