Sha256: 52e6f7c3bf71cf10cc4a1621df311facb5a269b47963299cd0f5a292becb36ee

Contents?: true

Size: 687 Bytes

Versions: 2

Compression:

Stored size: 687 Bytes

Contents

describe Spree::Model do
  before do
    @klass = Class.new
    @klass.send(:include, Spree::Model)
  end

  describe ".define_model_attributes" do
    before do
      @klass.define_model_attributes :id, :name
      @object = @klass.new("id" => 1, "name" => "Theodore")
    end

    it "creates the attribute list" do
      @object.attributes.should == [:id, :name]
    end

    it "creates accessors for all attributes" do
      [:id, :"id=", :name, :"name="].each do |accessor|
        @object.respond_to?(accessor).should == true
      end
    end

    it "loads declared attributes on .new" do
      @object.id.should   == 1
      @object.name.should == "Theodore"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree-wrap-0.0.2 spec/spree/model_spec.rb
spree-wrap-0.0.1 spec/spree/model_spec.rb