Sha256: 7331b86a17fc84e8b9910a8c06108bc25fb3be817603e45fac2237b63ae8b6b9

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require 'spec_helper'

describe Draper::ModelSupport do
  subject { Product.new }

  describe '#decorator' do
    its(:decorator) { should be_kind_of(ProductDecorator) }
    its(:decorator) { should be(subject.decorator) }

    it 'should have abillity to pass block' do
      a = Product.new.decorator { |d| d.awesome_title }
      a.should eql "Awesome Title"
    end
    
    it 'should be aliased to .decorate' do
      subject.decorator.model.should == subject.decorate.model
    end
  end

  describe '#decorate - decorate collections of AR objects' do
    subject { Product.limit }
    its(:decorate) { should be_kind_of(Draper::DecoratedEnumerableProxy) }

    it "should decorate the collection" do
      subject.decorate.size.should == 1
      subject.decorate.to_ary[0].model.should be_a(Product)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
draper-0.9.5 spec/draper/model_support_spec.rb