Sha256: 8d62f2bee1fc2ecca4e63e9bae38b610eb18ea69523ab0cb7ce121e16023a207

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

require 'spec_helper'

describe SecretKey::SecretKey do

  let!(:key) { Faker::Number.number(15) }
  let!(:secret) { Faker::Bitcoin.address }
  let!(:test_timestamp) { Time.new(2014, 07, 24, 12, 53).to_i }
  let!(:generated_token) { Digest::SHA1.hexdigest("#{key}:#{secret}:#{test_timestamp}") }

  describe '.generate_token' do
    context 'when timestamp is valid' do
      let!(:timestamp) { Time.new(2014, 07, 24, 12, 53).to_i }
      it 'produces a token' do
        expect(described_class.generate_token(key, secret, timestamp)).to eq(generated_token)
      end
    end

    context 'when timestamp is invalid' do
      let!(:timestamp) { 'sometext' }
      it 'raises an invalid timestamp error' do
        expect(lambda { described_class.generate_token(key, secret, timestamp) }).to raise_error(ArgumentError, 'Time Stamp is not a valid integer.')
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
secretkey-1.0.0 spec/unit/secretkey_spec.rb