Sha256: 314014dc1ac8c33cc70918f2c5dadb3612557ad793d46666812ae34451807119

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe IEX::Resources::Resource do
  context 'float number to percent (Positive)' do
    subject do
      IEX::Resources::Resource.float_to_percentage(0.09123)
    end
    it 'converts to percentage' do
      expect(subject).to eq '+9.12%'
    end
  end

  context 'float number to percent (Negative)' do
    subject do
      IEX::Resources::Resource.float_to_percentage(-0.09123)
    end
    it 'converts to percentage' do
      expect(subject).to eq '-9.12%'
    end
  end

  context 'float number to percent (nil)' do
    subject do
      IEX::Resources::Resource.float_to_percentage(nil)
    end
    it 'nil argument does not convert' do
      expect(subject).to eq nil
    end
  end

  context 'float number to percent (0)' do
    subject do
      IEX::Resources::Resource.float_to_percentage(0)
    end
    it 'Zero converts to +0.00%' do
      expect(subject).to eq '+0.00%'
    end
  end

  context 'Unformatted money amount to dollar' do
    subject do
      IEX::Resources::Resource.to_dollar(amount: 123_391)
    end
    it 'converts to dollar' do
      expect(subject).to eq '$123,391'
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iex-ruby-client-1.3.0 spec/iex/resources/resource_spec.rb
iex-ruby-client-1.2.0 spec/iex/resources/resource_spec.rb
iex-ruby-client-1.1.2 spec/iex/resources/resource_spec.rb
iex-ruby-client-1.1.1 spec/iex/resources/resource_spec.rb
iex-ruby-client-1.1.0 spec/iex/resources/resource_spec.rb
iex-ruby-client-1.0.1 spec/iex/resources/resource_spec.rb
iex-ruby-client-1.0.0 spec/iex/resources/resource_spec.rb