Sha256: bf1c5562c796c3a22a6587cffede624658c31428d197a33f8825313956f3bcbf
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require 'spec_helper' class WithBitMask attr_accessor :colors_mask, :second_colors_mask include ArrayBitMask as_bit_mask :colors, :source => :subject_colors as_bit_mask :second_colors, :source => [:red, :green, :black, :white] def subject_colors [:red, :green, :black, :white] end end describe ArrayBitMask do subject { WithBitMask.new } it 'should add accessor methods' do should respond_to(:colors) should respond_to(:colors=) end it 'should store bit mask' do subject.colors = [:red, :white] expect(subject.colors_mask).to eq 9 end it 'should restore array from bit mask' do subject.colors_mask = 6 expect(subject.colors).to match_array [:green, :black] end it 'should return empty array for zero mask' do subject.colors_mask = 0 expect(subject.colors).to eq [] end it 'should store array' do subject.colors = [] expect(subject.colors).to eq [] end it 'should return empty array for nil mask' do subject.colors_mask = nil expect(subject.colors).to eq [] end context 'source as array' do it 'should store bit mask' do subject.second_colors = [:red, :white] expect(subject.second_colors_mask).to eq 9 end it 'should restore array from bit mask' do subject.second_colors_mask = 6 expect(subject.second_colors).to match_array [:green, :black] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
array_bit_mask-0.1.0 | spec/array_bit_mask/bit_mask_spec.rb |