spec/file_spec.rb in ase-1.0.3 vs spec/file_spec.rb in ase-2.0.0
- old
+ new
@@ -37,22 +37,23 @@
expect(doc['Simple'].colors).to have_key('Black')
end
it 'correctly reads the color values' do
doc = ASE.from_file('spec/files/control.ase')
- expect(doc['Simple']['White'].to_rgb).to eq([255, 255, 255])
- expect(doc['Simple']['Black'].to_rgb).to eq([0, 0, 0])
+ expect(doc['Simple']['White'].to_a).to eq([255, 255, 255])
+ expect(doc['Simple']['Black'].to_a).to eq([0, 0, 0])
end
end
describe 'Writing' do
before(:each) do
doc = ASE.new
palette = ASE::Palette.new('Test')
- palette.add 'Red', ASE::Color.new(255, 0, 0)
- palette.add 'Blue', ASE::Color.new(0, 0, 255)
+ palette.add 'Red', ASE::Color::RGB.new(255, 0, 0)
+ palette.add 'Blue', ASE::Color::CMYK.new(0.91, 0.68, 0.2, 0)
+ palette.add 'Blah', ASE::Color::Gray.new(0.5)
doc << palette
@output = Tempfile.new('output.ase')
doc.to_file @output.path
@@ -71,21 +72,29 @@
expect(d.palettes).to have_key('Test')
end
it 'writes the correct number of colors' do
d = ASE.from_file(@output.path)
- expect(d['Test'].size).to be 2
+ expect(d['Test'].size).to be 3
end
it 'writes the correct color names' do
d = ASE.from_file(@output.path)
expect(d['Test'].colors).to have_key('Red')
expect(d['Test'].colors).to have_key('Blue')
end
it 'writes the correct color values' do
d = ASE.from_file(@output.path)
- expect(d['Test']['Red'].to_rgb).to eq([255, 0, 0])
- expect(d['Test']['Blue'].to_rgb).to eq([0, 0, 255])
+ expect(d['Test']['Red'].to_a).to eq([255, 0, 0])
+ expect(d['Test']['Blue'].to_a).to eq([0.91, 0.68, 0.2, 0])
+ expect(d['Test']['Blah'].to_a).to eq([0.5])
+ end
+
+ it 'writes the correct color types' do
+ d = ASE.from_file(@output.path)
+ expect(d['Test']['Red']).to be_an_instance_of(ASE::Color::RGB)
+ expect(d['Test']['Blue']).to be_an_instance_of(ASE::Color::CMYK)
+ expect(d['Test']['Blah']).to be_an_instance_of(ASE::Color::Gray)
end
end
end
\ No newline at end of file