Sha256: f6a4e70ae3f34b440ab0571120845607f81185123af8fac25642043f54b2df02

Contents?: true

Size: 1.03 KB

Versions: 24

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/immutable'

::RSpec.describe ::EacRubyUtils::Immutable::ArrayAccessor do
  let(:stub_class) do
    ::Class.new do
      include ::EacRubyUtils::Immutable

      immutable_accessor :array_attr, type: :array
    end
  end

  let(:initial_instance) { stub_class.new }

  it do
    expect(initial_instance.array_attrs).to eq([])
  end

  context 'when array_attr pushs for' do
    let(:change1_instance) { initial_instance.array_attr('A') }

    it { expect(change1_instance).to be_a(initial_instance.class) }
    it { expect(change1_instance.object_id).not_to eq(initial_instance.object_id) }
    it { expect(change1_instance.array_attrs).to eq(%w[A]) }

    context 'when array_attrs sets for' do
      let(:change2_instance) { initial_instance.array_attrs(%w[B]) }

      it { expect(change2_instance).to be_a(initial_instance.class) }
      it { expect(change2_instance.object_id).not_to eq(change1_instance.object_id) }
      it { expect(change2_instance.array_attrs).to eq(%w[B]) }
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
eac_tools-0.66.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.65.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.65.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.64.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.63.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.62.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.62.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.61.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.61.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.60.3 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.60.2 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.60.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.60.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.59.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.58.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.57.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.56.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.56.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.55.7 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb
eac_tools-0.55.6 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable/array_accessor_spec.rb