require 'spec_helper'

module LetMeKnow
  describe Mailer do
    describe "#notify" do
      let(:notification) { Notification.new(subject: notification_subject, notification_preference: preference) }
      let(:recipient) { Recipient.create!(email: 'foo@bar.com', name: 'Foo Bar') }
      let(:preference) { recipient.notification_preference }
      let(:notification_subject) { Subject.create!(owner: recipient) }

      subject { described_class.notify(notification) }

      its(:subject) { should == "New subject added" }
      its(:from) { should == %w(photos@greggandjen.com) }
      its(:to) { should == [recipient.email] }

      context "dynamicness of subject" do
        let(:notification_subject) do
          CrazySubject = Class.new(Subject)
          CrazySubject.new(owner: recipient)
        end
        its(:subject) { should == "New crazy subject added" }
      end
    end
  end
end
