Sha256: 8d9ee35d5df46d3e863e1a42a748f01896682664255cf377246c2f588d469885

Contents?: true

Size: 926 Bytes

Versions: 7

Compression:

Stored size: 926 Bytes

Contents

require 'pathname'
require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'

describe DataMapper::Types::Flag do
  before(:all) do
    class Shirt
      include DataMapper::Resource
      property :id, Serial
      property :sizes, DM::Flag[:xs, :small, :medium, :large, :xl, :xxl]
    end
    Shirt.auto_migrate!
  end

  it "should save with create({:flag_field => [:flags]})" do
    lambda { Shirt.create(:sizes => [:medium, :large]) }.should_not raise_error
    repository do
      Shirt.get(1).sizes.should == [:medium, :large]
    end
  end

  it "should save with flag_field=[:flags]" do
    shirt = Shirt.new
    shirt.sizes = [:small, :xs]
    lambda { shirt.save }.should_not raise_error
    repository do
      Shirt.get(2).sizes.should == [:xs, :small]
    end
  end

  it 'should immediately typecast supplied values' do
    Shirt.new(:sizes => [:large, :xl]).sizes.should == [:large, :xl]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dm-types-0.9.4 spec/integration/flag_spec.rb
dm-types-0.9.5 spec/integration/flag_spec.rb
dm-types-0.9.6 spec/integration/flag_spec.rb
dm-types-0.9.3 spec/integration/flag_spec.rb
dm-types-0.9.7 spec/integration/flag_spec.rb
dm-types-0.9.9 spec/integration/flag_spec.rb
dm-types-0.9.8 spec/integration/flag_spec.rb