Sha256: 81bf6e8b58762e3e0bbd9dc4e36fc2c2a69c2f755f11a3eaf73ab284af513fd6

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Danica::Constant do
  subject { described_class.new(2.5, :M, :m) }
  let(:other) { described_class.new(3, :N, :n) }

  it_behaves_like 'an object with + operation'

  describe '#to_f' do
    it 'has a value' do
      expect(subject.to_f).to eq(2.5)
    end
  end

  describe '#to_tex' do
    it 'has a string for latex' do
      expect(subject.to_tex).to eq('M')
    end
  end

  describe '#to_gnu' do
    it 'has a string for gnu' do
      expect(subject.to_gnu).to eq('m')
    end
  end

  describe 'variables' do
    it { expect(subject).not_to respond_to(:value=) }
    it { expect(subject).not_to respond_to(:latex=) }
    it { expect(subject).not_to respond_to(:gnu=) }
  end

  describe '==' do
    context 'when comparing with the same object' do
      it { expect(subject).to eq(subject) }
    end

    context 'when comparing with a diferent object' do
      context 'with diferent values' do
        it { expect(subject).not_to eq(other) }
      end

      context 'with same values' do
        let(:other) { described_class.new(2.5, :M, :m) }
        it { expect(subject).to eq(other) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danica-2.0.3 spec/lib/danica/constant_spec.rb
danica-2.0.2 spec/lib/danica/constant_spec.rb