Sha256: d13b2ea54c8f9f7b75c5ba9b498243c48bb32034eb0977ed255fae91dec28b8c

Contents?: true

Size: 614 Bytes

Versions: 9

Compression:

Stored size: 614 Bytes

Contents

require 'spec_helper'
require 'rotp/cli'

RSpec.describe ROTP::CLI do
  let(:cli)    { described_class.new('executable', argv) }
  let(:output) { cli.output }
  let(:now)    { Time.utc 2012,1,1 }

  before do
    Timecop.freeze now
  end

  context 'generating a TOTP' do
    let(:argv) { %w(--secret JBSWY3DPEHPK3PXP) }

    it 'prints the corresponding token' do
      expect(output).to eq '068212'
    end
  end

  context 'generating a HOTP' do
    let(:argv) { %W(--hmac --secret #{'a' * 32} --counter 1234) }

    it 'prints the corresponding token' do
      expect(output).to eq '161024'
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rotp-3.3.1 spec/lib/rotp/cli_spec.rb
rotp-3.3.0 spec/lib/rotp/cli_spec.rb
rotp-3.2.0 spec/lib/rotp/cli_spec.rb
rotp-3.1.0 spec/lib/rotp/cli_spec.rb
rotp-3.0.1 spec/lib/rotp/cli_spec.rb
rotp-3.0.0 spec/lib/rotp/cli_spec.rb
rotp-2.1.2 spec/lib/rotp/cli_spec.rb
rotp-2.1.1 spec/lib/rotp/cli_spec.rb
rotp-2.1.0 spec/lib/rotp/cli_spec.rb