Sha256: f4f71ad0eb3e40e9b390bc1bc46d1fb0f461107cc0ee4e462fe5e35b5c73c37d

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

module PlaidRails
  describe Account do
    it { should validate_presence_of(:access_token)}
    it { should validate_presence_of(:plaid_id)}
    it { should validate_presence_of(:plaid_type)}
    it { should validate_presence_of(:name)}
    it { should belong_to(:owner).with_foreign_key(:owner_id)}
    
    let(:account){FactoryGirl.create(:account)}
    
    it "expect to call delete_connect" do
      expect(account).to receive(:delete_connect)
      account.destroy
    end
    
    it "delete connect with error" do
      account = FactoryGirl.create(:account)
      expect(Plaid::User).to receive(:load).with(:connect, "test_wells").and_raise("boom")
      expect(Rails.logger).to receive(:error).exactly(2).times
      account.send(:delete_connect)
    end
    
    it "delete_connect" do
      account = FactoryGirl.create(:account)
      user = double
      expect(Plaid::User).to receive(:load).with(:connect, "test_wells").and_return(user)
      expect(user).to receive(:delete)
      account.send(:delete_connect)
    end
    
    it "does not delete_connect" do
      FactoryGirl.create(:account)
      expect(Plaid::User).to_not receive(:load).with(:connect, "test_wells").and_raise("boom")      
      account.send(:delete_connect)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plaid_rails-0.8.0 spec/models/plaid_rails/account_spec.rb
plaid_rails-0.7.0 spec/models/plaid_rails/account_spec.rb
plaid_rails-0.6.0 spec/models/plaid_rails/account_spec.rb
plaid_rails-0.5.0 spec/models/plaid_rails/account_spec.rb