Sha256: 298898ca058142ba4cbe2cfd3c5a3aa7627cde8e32414b685849a77da51b659b

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Reviewed::Base do

  let(:article_id) { '509d166d60de7db97c05ce71' }

  class Example < Reviewed::Base; end

  describe 'Class' do

    it 'responds to model_name' do
      Example.model_name.should eql("Example")
    end
  end

  describe 'initialize' do

    it 'objectifies data' do
      Example.any_instance.should_receive(:objectify).with({})
      obj = Example.new( {} )
    end

    it 'sets the data in the @attributes var' do
      obj = Example.new( { foo: 'bar' } )
      obj.instance_variable_get(:@attributes).should eql( { foo: 'bar' } )
    end
  end

  describe 'path' do

    it 'should the demodulized resource name' do
      Reviewed::Article.path.should eql("articles")
    end
  end

  describe 'association_name' do

    it 'returns the demodulized & pluralized version of itself' do
      Reviewed::Article.association_name.should eql("articles")
    end
  end

  describe 'attributes' do
    it 'returns the named attribute (via method missing)' do
      model = Example.new(id: 'id', super_awesome: 'true')
      model.super_awesome.should == 'true'
    end
  end

  describe 'respond_to?' do
    before(:each) do
      @model = Example.new(id: 'id', super_awesome: 'true')
    end

    it 'takes attributes into consideration' do
      @model.respond_to?(:super_awesome).should be_true
    end

    it 'preserves the original behavior' do
      @model.respond_to?(:fafafa).should be_false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reviewed-0.1.28 spec/base_spec.rb