Module: AuthHelpers::Spec::Notifier

Defined in:
lib/auth_helpers/spec/notifier.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/auth_helpers/spec/notifier.rb', line 6

def self.included(base)
  base.class_eval do
    before(:each) do
      @record = OpenStruct.new(:email            => '[email protected]',
                               :perishable_token => '0123456789')
    end

    it "should deliver new account notification" do
      email = ::AuthHelpers::Notifier.create_create_confirmation(@record)
      email.to.should == [ '[email protected]' ]
      email.body.should match(/#{@record.perishable_token}/)
    end

    it "should deliver email changed notification" do
      email = ::AuthHelpers::Notifier.create_update_confirmation(@record)
      email.to.should == [ '[email protected]' ]
      email.body.should match(/#{@record.perishable_token}/)
    end

    it "should deliver reset password code" do
      email = ::AuthHelpers::Notifier.create_reset_password(@record)
      email.to.should == [ '[email protected]' ]
      email.body.should match(/#{@record.perishable_token}/)
    end

    it "should resend confirmation code" do
      email = ::AuthHelpers::Notifier.create_resend_confirmation(@record)
      email.to.should == [ '[email protected]' ]
      email.body.should match(/#{@record.perishable_token}/)
    end
  end
end