Sha256: 98da505f70b1d724dd139bdbaf2ac22d5dc4159637396be94d251d72378db448

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'tataru'

describe Tataru::Instructions::UpdateInstruction do
  it 'calls update' do
    mem = Tataru::Memory.new
    instr = Tataru::Instructions::UpdateInstruction.new

    mem.hash[:temp] = {
      resource_name: 'thing',
      resource_desc: 'Tataru::BaseResourceDesc',
      properties: { 'someprop' => 'somevalue' }
    }

    mem.hash[:remote_ids] = { 'thing' => 'hello' }
    instr.memory = mem
    expect_any_instance_of(Tataru::BaseResource).to receive(:update).with('someprop' => 'somevalue')
    
    instr.run
  end

  xit 'should throw error if an immutable prop is changed' do
    mem = Tataru::Memory.new
    instr = Tataru::Instructions::UpdateInstruction.new

    expect_any_instance_of(Tataru::BaseResourceDesc).to receive(:immutable_fields) { ['someprop'] }

    mem.hash[:temp] = {
      resource_name: 'thing',
      resource_desc: 'Tataru::BaseResourceDesc',
      properties: { 'someprop' => 'somevalue' }
    }
    mem.hash[:remote_ids] = { 'thing' => 'hello' }
    instr.memory = mem

    expect { instr.run }.to raise_error 'immutable value changed'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tataru-0.2.0 spec/instructions/update_instruction_spec.rb