Sha256: c7476d58b67119efbb730b4bb17bfbb60027718fc0d168099d38748263ac7e29

Contents?: true

Size: 937 Bytes

Versions: 6

Compression:

Stored size: 937 Bytes

Contents

require 'spec_helper'

describe Zertico::Accessor do
  let(:user) { User.new }
  let(:user_accessor) { UserAccessor.new(user) }

  describe '.initialize' do
    it 'should initialize the interface object on a instance variable' do
      UserAccessor.new(user).instance_variable_get('@user').should == user
    end
  end

  describe '.find' do
    before :each do
      User.stub(:find => user)
      UserAccessor.stub(:new => user_accessor)
    end

    it 'should return an accessor' do
      UserAccessor.find(3).should == user_accessor
    end
  end

  describe '#interface' do
    before :each do
      User.stub(:find => user)
    end

    it 'should return the interface object' do
      UserAccessor.find(3).interface.should == user
    end
  end

  describe '#method_missing' do
    it 'should pass the method to the interface model if it responds to it' do
      UserAccessor.new(user).should respond_to(:name)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zertico-0.5.3 spec/zertico/accessor_spec.rb
zertico-0.5.2 spec/zertico/accessor_spec.rb
zertico-0.5.1 spec/zertico/accessor_spec.rb
zertico-0.5.0 spec/zertico/accessor_spec.rb
zertico-0.4.0 spec/zertico/accessor_spec.rb
zertico-0.3.1 spec/zertico/accessor_spec.rb