Sha256: 560727f895730bcac614f30e0b2d4462f6f989409dc1edba7dc6aafde6520ca0

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Danica::Wrapper::Variable do
  it_behaves_like 'an object that respond to basic_methods'

  it_behaves_like 'an object with basic operation' do
    subject { described_class.new(value: 100) }
  end

  it 'can be initialize from nil value' do
    expect do
      described_class.new(nil)
    end.not_to raise_error
  end

  it 'can be initialize from nil name' do
    expect do
      described_class.new(name: nil)
    end.not_to raise_error
  end

  describe '#to_f' do
    context 'when variable has no value' do
      it { expect { subject.to_f }.to raise_error(Danica::Exception::NotDefined) }
    end

    context 'when variable has value' do
      subject { described_class.new(value: value) }

      let(:value) { 100 }

      it 'returns the value' do
        expect(subject.to_f).to eq(value)
      end
    end
  end

  describe '#to_tex' do
    it_behaves_like 'a variable method to formated string', :to_tex, :latex
  end

  describe '#to_gnu' do
    it_behaves_like 'a variable method to formated string', :to_gnu, :gnuplot
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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