Sha256: 0a28e29fa6bb6dfee766c9c983b3c8fd11cc183d4597ab4695a484632f0a0d7d

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

RSpec.describe Magick::Image, '#properties' do
  let(:img) { Magick::Image.new(20, 20) }
  let(:freeze_error) { RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError }

  before(:each) do
    img['a'] = 'str_1'
    img['b'] = 'str_2'
    img['c'] = 'str_3'
  end

  it 'allows assignment of arbitrary properties' do
    expect(img['a']).to eq 'str_1'
    expect(img['b']).to eq 'str_2'
    expect(img['c']).to eq 'str_3'
    expect(img['d']).to be nil
  end

  it 'returns a hash of assigned properties' do
    expected_properties = { 'a' => 'str_1', 'b' => 'str_2', 'c' => 'str_3' }
    expect(img.properties).to eq(expected_properties)
  end

  it 'raises an error when trying to assign properties to a frozen image' do
    img.freeze
    expect { img['d'] = 'str_4' }.to raise_error(freeze_error)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rmagick-3.0.0 spec/rmagick/image/properties_spec.rb