Sha256: 48423cbc6d2364d971d8fba9077d76c04d4aba3b898a74bea054b0a6d33108ae

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe Danica::PositiveNegative do
  let(:value) { Danica::Number.new(10) }
  subject { described_class.new(value) }

  it_behaves_like 'an object that respond to basic_methods'
  it_behaves_like 'an object with basic operation'

  describe '#to_f' do
    it 'returns the float of value' do
      expect(subject.to_f).to eq(10)
    end

    it { expect(subject.to_f).to be_a(Float) }
  end

  describe '#to_tex' do
    context 'when value should be integer' do
      let(:value) { 10.0 }

      it 'returns the positive negative string' do
        expect(subject.to_tex).to eq('\pm 10')
      end
    end

    context 'when value should be float' do
      let(:value) { 10.5 }

      it 'returns the positive negative string' do
        expect(subject.to_tex).to eq('\pm 10.5')
      end
    end
  end

  describe '#to_gnu' do
    context 'when value should be integer' do
      let(:value) { 10.0 }

      it 'returns the value integer string' do
        expect(subject.to_gnu).to eq('+ 10')
      end
    end

    context 'when value should be a float' do
      let(:value) { 10.5 }

      it 'returns the value float string' do
        expect(subject.to_gnu).to eq('+ 10.5')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danica-2.2.1 spec/lib/danica/positive_negative_spec.rb
danica-2.2.0 spec/lib/danica/positive_negative_spec.rb
danica-2.1.1 spec/lib/danica/positive_negative_spec.rb
danica-2.1.0 spec/lib/danica/positive_negative_spec.rb