Sha256: 6f22389d219eae227c2a578242cf9b15eaa49706228bc64aa8990088bb0dd92e

Contents?: true

Size: 1016 Bytes

Versions: 3

Compression:

Stored size: 1016 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

class Danica::Operator::Dummy < Danica::Operator
  variables :a, :b

  def to(*_args)
    a + b
  end
end

describe Danica::Operator do
  subject { clazz.new(*variables) }

  let(:variables) { [2, 4] }
  let(:clazz) { described_class::Dummy }

  it_behaves_like 'an object that respond to basic_methods'

  describe 'variables assignment' do
    it 'assignes first variable' do
      expect(subject.a).to eq(Danica::Wrapper::Number.new(2))
    end

    it 'assignes second variable' do
      expect(subject.b).to eq(Danica::Wrapper::Number.new(4))
    end

    context 'when initializing with a hash' do
      let(:variables) { [{ name: :A, value: 2 }, { name: :B, value: 4 }] }

      it 'assignes first variable' do
        expect(subject.a).to eq(Danica::Wrapper::Variable.new(name: :A, value: 2))
      end

      it 'assignes second variable' do
        expect(subject.b).to eq(Danica::Wrapper::Variable.new(name: :B, value: 4))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.7.7 spec/lib/danica/operator_spec.rb
danica-2.7.6 spec/lib/danica/operator_spec.rb
danica-2.7.5 spec/lib/danica/operator_spec.rb