Sha256: 2d7231c22a524b029e29b7ca2b614345dfb9b0b23f03991978f61b79c1e11c5e

Contents?: true

Size: 1.76 KB

Versions: 24

Compression:

Stored size: 1.76 KB

Contents

shared_examples 'a operator with a single input value' do |arguments|
  include_context 'variables are initialized', arguments, *%w(variable_value expected_number expected_tex expected_number_tex expected_gnu expected_number_gnu)
  let(:variable) { { name: "X", value: variable_value } }
  subject { described_class.new(variable) }

  describe '#to_f' do
    context 'when variables are not numbers but have value' do
      it 'returns the division of the values' do
        expect(subject.to_f).to eq(expected_number)
      end

      it do
        expect(subject.to_f).to be_a(Float)
      end
    end

    context 'when the variable is a number' do
      let(:variable) { variable_value }

      it 'returns the squared root of the value' do
        expect(subject.to_f).to eq(expected_number)
      end

      it do
        expect(subject.to_f).to be_a(Float)
      end
    end
  end

  describe '#to_tex' do
    context 'when variables have no value' do
      let(:variable) { :X }

      it 'returns a latex format fraction' do
        expect(subject.to_tex).to eq(expected_tex)
      end
    end

    context 'when the variable is numeric' do
      before do
        subject.variables[0].value = variable_value
      end
      it 'prints both numbers' do
        expect(subject.to_tex).to eq(expected_number_tex)
      end
    end
  end

  describe '#to_gnu' do
    context 'when variables have no value' do
      let(:variable) { :X }

      it 'returns a latex format fraction' do
        expect(subject.to_gnu).to eq(expected_gnu)
      end
    end

    context 'when the variable is numeric' do
      before do
        subject.variables[0].value = variable_value
      end
      it 'prints both numbers' do
        expect(subject.to_gnu).to eq(expected_number_gnu)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
danica-2.7.4 spec/support/shared_examples/operator/single_input.rb
danica-2.7.3 spec/support/shared_examples/operator/single_input.rb
danica-2.7.2 spec/support/shared_examples/operator/single_input.rb
danica-2.7.1 spec/support/shared_examples/operator/single_input.rb
danica-2.6.4 spec/support/shared_examples/operator/single_input.rb
danica-2.6.3 spec/support/shared_examples/operator/single_input.rb
danica-2.6.2 spec/support/shared_examples/operator/single_input.rb
danica-2.6.1 spec/support/shared_examples/operator/single_input.rb
danica-2.6.0 spec/support/shared_examples/operator/single_input.rb
danica-2.5.1 spec/support/shared_examples/operator/single_input.rb
danica-2.5.0 spec/support/shared_examples/operator/single_input.rb
danica-2.4.4 spec/support/shared_examples/operator/single_input.rb
danica-2.4.3 spec/support/shared_examples/operator/single_input.rb
danica-2.4.2 spec/support/shared_examples/operator/single_input.rb
danica-2.4.1 spec/support/shared_examples/operator/single_input.rb
danica-2.4.0 spec/support/shared_examples/operator/single_input.rb
danica-2.3.1 spec/support/shared_examples/operator/single_input.rb
danica-2.3.0 spec/support/shared_examples/operator/single_input.rb
danica-2.2.1 spec/support/shared_examples/operator/single_input.rb
danica-2.2.0 spec/support/shared_examples/operator/single_input.rb