Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improved rspec syntax

  • Loading branch information...
commit 7068023c975899bee708af1fbd7e735265429832 1 parent 69f85de
@dgeb dgeb authored
Showing with 23 additions and 21 deletions.
  1. +23 −21 spec/models/email_spec.rb
View
44 spec/models/email_spec.rb
@@ -4,19 +4,19 @@
let(:email) { DelayedMailhopper::Email.new }
it "should require a from address" do
- assert !email.valid?
+ email.should_not be_valid
email.from_address = 'user@example.com'
- assert email.valid?
+ email.should be_valid
end
describe "generated by a mailer" do
let(:headers) {{
- :from => 'from@example.com',
- :to => 'to@example.com',
- :cc => 'cc@example.com',
- :bcc => 'bcc@example.com',
+ :from => 'from@example.com',
+ :to => 'to@example.com',
+ :cc => 'cc@example.com',
+ :bcc => 'bcc@example.com',
:reply_to => 'reply_to@example.com',
- :subject => 'Hiya!'
+ :subject => 'Hiya!'
}}
let(:content) { 'Papaya' }
@@ -26,39 +26,41 @@
it "should match the intended headers and content" do
email = DelayedMailhopper::Email.first
- assert_equal email.from_address, headers[:from]
- assert_equal email.to_address, headers[:to]
- assert_equal email.cc_address, headers[:cc]
- assert_equal email.bcc_address, headers[:bcc]
- assert_equal email.reply_to_address, headers[:reply_to]
- assert_equal email.subject, headers[:subject]
+ email.from_address.should eq(headers[:from])
+ email.to_address.should eq(headers[:to])
+ email.cc_address.should eq(headers[:cc])
+ email.bcc_address.should eq(headers[:bcc])
+ email.reply_to_address.should eq(headers[:reply_to])
+ email.subject.should eq(headers[:subject])
# Email content will include headers as well as content
- assert email.content.include?(content)
+ email.content.should include(content)
- assert email.sent_at.nil?
+ email.sent_at.should eq(nil)
end
it "should be queued as a delayed job" do
- assert_equal DelayedMailhopper::Email.count, 1
- assert_equal Delayed::Job.count, 1
+ DelayedMailhopper::Email.count.should eq(1)
+ Delayed::Job.count.should eq(1)
end
it "should be delivered via DelayedJob" do
email = DelayedMailhopper::Email.first
- assert email.sent_at.nil?
+ email.sent_at.should eq(nil)
Delayed::Job.first.invoke_job
email.reload
- assert !email.sent_at.nil?
+ email.sent_at.should_not eq(nil)
end
it "should be marked as sent once delivered" do
email = DelayedMailhopper::Email.first
- assert email.sent_at.nil?
+ email.sent_at.should eq(nil)
+
email.send!
- assert !email.sent_at.nil?
+
+ email.sent_at.should_not eq(nil)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.