Test for contact form not working

I’m working with Rails 4 and have developed a test that is failing and I
don’t understand why.

test “message content” do
message = messages(:two)
mail = MessageMailer.new_message(message)
assert_equal “Message from #{message.name}”, mail.subject
assert_equal [“[email protected]”],
mail.to
assert_equal message.email,
mail.from
assert_match message.content,
mail.body.encoded
assert_match CGI::escape(message.email),
mail.body.encoded # Test if it is an escaped email address, which a.o.
means that the @ is converted to browser-friendly code: %40.
end

The last three test lines all three fail. I get the error message:
FAIL[“test_message_content”, MessageMailerTest, 3.994477556]
test_message_content#MessageMailerTest (3.99s)
Expected: nil
Actual: []
test/mailers/message_mailer_test.rb:10:in `block in
class:MessageMailerTest’ (this refers to the assert_equal
message.email
line)

I don’t understand why it is expected nul and actually empty.

My fixtures include:
two:
name: MyString
email: [email protected]
content: MyString

The message mailer is:
default from: “[email protected]
default to: “Website [email protected]
def new_message(message)
@message = message
mail subject: “Message from #{message.name}”, from: message.email
end

Anyone got an idea what is going wrong?

On 17 April 2015 at 17:16, [email protected] wrote:

I’m working with Rails 4 and have developed a test that is failing and I
don’t understand why.

test “message content” do
Try a
puts messages(:two).inspect
at this point to get more clues as to what is happening.

Colin