Sha256: b9899df9b78c070667df82dfd4078500aae799015641c665edcf26e6b055687f

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reviewed-0.1.27 spec/base_spec.rb
reviewed-0.1.26 spec/base_spec.rb
reviewed-0.1.25 spec/base_spec.rb
reviewed-0.1.24 spec/base_spec.rb
reviewed-0.1.23 spec/base_spec.rb
reviewed-0.1.22 spec/base_spec.rb
reviewed-0.1.21 spec/base_spec.rb