Sha256: 902563e4a45094aae0ff719b33da07761c45a419053090332698667a8f015f67

Contents?: true

Size: 912 Bytes

Versions: 19

Compression:

Stored size: 912 Bytes

Contents

require "spec_helper"

class MyModel
  include Frenchy::Model
end

class MyModelDecorator
  def self.decorate_collection(collection, options={})
    return "DECORATED"
  end
end

describe Frenchy::Collection do
  describe "#decorate" do
    describe "when there are no items" do
      it "returns an empty array" do
        coll = Frenchy::Collection.new
        expect(coll.decorate).to eql([])
      end
    end

    describe "when there are model items" do
      it "decorates using the named convention" do
        m1 = MyModel.new
        m2 = MyModel.new
        coll = Frenchy::Collection.new([m1, m2])
        expect(coll.decorate).to eql("DECORATED")
      end

      it "supports a hash of options" do
        m1 = MyModel.new
        m2 = MyModel.new
        coll = Frenchy::Collection.new([m1, m2])
        expect(coll.decorate({"a" => 1})).to eq("DECORATED") # test arity
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
frenchy-0.7.0 spec/lib/frenchy/collection_spec.rb
frenchy-0.6.3 spec/lib/frenchy/collection_spec.rb
frenchy-0.6.2 spec/lib/frenchy/collection_spec.rb
frenchy-0.6.1 spec/lib/frenchy/collection_spec.rb
frenchy-0.6.0 spec/lib/frenchy/collection_spec.rb
frenchy-0.5.2 spec/lib/frenchy/collection_spec.rb
frenchy-0.5.1 spec/lib/frenchy/collection_spec.rb
frenchy-0.5.0 spec/lib/frenchy/collection_spec.rb
frenchy-0.4.0 spec/lib/frenchy/collection_spec.rb
frenchy-0.3.0 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.9 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.8 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.7 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.6 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.5 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.4 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.3 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.2 spec/lib/frenchy/collection_spec.rb
frenchy-0.2.1 spec/lib/frenchy/collection_spec.rb