Sha256: 2ec08143450126ebb7617cc74f2531fec6ca4503e9dfa3e465e6082ba11c331d
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
describe SimpleFlaggableColumn do with_model :GameModel do table do |t| t.integer :platforms, default: 0, null: false end model do include SimpleFlaggableColumn flag_column :platforms, { win: 0b001, mac: 0b010, linux: 0b100 } end end it 'should be empty by default' do expect(GameModel.new.platforms).to eq [] end it 'should let you save data' do game = GameModel.new game.platforms = [:mac, :linux] expect(game.read_attribute(:platforms)).to eq 0b110 expect(game.platforms).to match_array [:mac, :linux] end it "should ignore items that aren't on the list" do game = GameModel.new game.platforms = [:mac, :linux, :potato] expect(game.read_attribute(:platforms)).to eq 0b110 expect(game.platforms).to match_array [:mac, :linux] end it 'should define the list of flags' do expect(GameModel.platforms_flags).to eq({ win: 0b001, mac: 0b010, linux: 0b100 }) end it 'should let you get a join list of flags' do expect(GameModel.platforms_flags(:win, :linux)).to eq 0b101 end it 'should define the reverse list of flags' do expect(GameModel.flags_platforms).to eq({ 0b001 => :win, 0b010 => :mac, 0b100 => :linux }) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_flaggable_column-0.0.1 | spec/simple_flaggable_column/simple_flaggable_column_spec.rb |