Sha256: f5883defdc57f9019dfb500185d678c008ce16ad8abe99a3329d3d6e8dc72063

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Numeric do
  describe '#as_percentage_of(number)' do
    context 'as an integer' do
      subject(:as_percentage_of) { 2.as_percentage_of(10) }

      it { is_expected.to eq(20.0) }
    end
    context 'as a float' do
      subject(:as_percentage_of) { 2.0.as_percentage_of(10) }

      it { is_expected.to eq(20.0) }
    end
  end

  describe '#percent_of(number)' do
    context 'as an integer' do
      subject(:percent_of) { 2.percent_of(10) }

      it { is_expected.to eq(0.2) }
    end
    context 'as a float' do
      subject(:percent_of) { 2.0.percent_of(10) }

      it { is_expected.to eq(0.2) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percentify-0.1.1 spec/numeric_spec.rb
percentify-0.1.0 spec/numeric_spec.rb