Sha256: 13c80cb417adaffe1b7496c0ac2ea711fa680130c9c04cf41069a8adc0d41c7e

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true

require 'tataru'

describe Tataru::Instruction do
  it 'can be made' do
    Tataru::Instruction.new
  end

  it 'checks parameters' do
    instr = Class.new(Tataru::Instruction)
    instr.class_eval do
      expects :param1
    end

    mem = Tataru::Memory.new
    mem.hash[:temp] = {}

    expect { instr.new.execute(mem) }.to raise_error 'required param param1 not found'
  end

  it 'allows execution to occur if param exists' do
    instr = Class.new(Tataru::Instruction)
    instr.class_eval do
      expects :param1
    end

    mem = Tataru::Memory.new
    mem.hash[:temp] = { param1: 'hello' }

    instruction = instr.new
    expect(instruction).to receive(:run)

    instruction.execute(mem)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tataru-0.2.0 spec/instruction_spec.rb