Sha256: 5677505b24cd260dbf7937cef1ed7a8f4b007b892977b2f886023c1c81be2047

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Danica::Division do
  let(:variables) { [2, 4] }
  subject { described_class.new(*variables) }

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

  it_behaves_like 'a operator that has two terms', :division, {
    values: [ 2, 4 ],
    calculated: 1.0 / 2.0,
    to_tex: {
      string_expected: '\frac{X1}{X2}',
      numeric_string_expected: '\frac{2}{4}',
      partial_string_expected: '\frac{2}{X2}'
    },
    to_gnu: {
      string_expected: '(X1)/(X2)',
      numeric_string_expected: '(2)/(4)',
      partial_string_expected: '(2)/(X2)'
    }
  }

  describe 'more complex division' do
    describe 'of two sums' do
      subject do
        Danica::Division.new(
          Danica::Sum.new(2, :x),
          Danica::Sum.new(3, :y)
        )
      end

      describe 'to_gnu' do
        let(:expected) do
          '(2 + x)/(3 + y)'
        end

        it 'groups sum' do
          expect(subject.to_gnu).to eq(expected)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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