spec/email_spec.rb in maily-0.7.1 vs spec/email_spec.rb in maily-0.7.2
- old
+ new
@@ -29,10 +29,11 @@
expect(email.arguments.size).to eq(email.required_arguments.size)
end
it 'should handle not lazy arguments successfully' do
allow(email).to receive(:email).and_return('foo@foo.com')
+
expect(email.arguments).to be_present
expect(email.arguments.size).to eq(email.required_arguments.size)
end
it ".call" do
@@ -40,24 +41,27 @@
end
end
it "should handle template_path via hook" do
email = mailer.find_email('recommendation')
+
expect(email.template_path).to eq('notifications')
end
it "should handle template_name via hook" do
email = mailer.find_email('custom_template_name')
+
expect(email.template_name).to eq('invitation')
end
it "should handle description via hook" do
email = mailer.find_email('recommendation')
+
expect(email.description).to eq('description')
end
- describe 'validate_arguments' do
+ describe '#validate_arguments' do
it 'emails with no arguments required' do
email = mailer.find_email('welcome')
expect(email.validate_arguments).to eq [true, nil]
email.arguments = ["asd"]
@@ -68,8 +72,24 @@
email = mailer.find_email('invitation')
expect(email.validate_arguments).to eq [true, nil]
email = mailer.find_email('recommendation')
expect(email.validate_arguments[1]).to eq("recommendation email requires at least 1 arguments, passed 0")
+ end
+ end
+
+ describe '#path' do
+ it 'with a multipart email defaults to html' do
+ email = mailer.find_email('multipart')
+
+ expect(email.path).to include('multipart.html.erb')
+ expect(email.path('text')).to include('multipart.text.erb')
+ expect(email.path('foo')).to eq nil
+ end
+
+ it 'with other template engines (e.g. Slim)' do
+ email = mailer.find_email('with_slim_template')
+
+ expect(email.path).to include('with_slim_template.html.slim')
end
end
end