Sha256: e90da679ae652ee6d5d6508c1ae6876e800fe4f1d8024672fe6fd3e5bb5d151f

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'
require 'usblamp/cli'
require 'slop'

# Usblamp tests
module Usblamp
  # CLI tests
  module CLI
    describe 'CLI' do
      it 'should return options' do
        options = CLI.slop
        expect(options).to be_a(::Slop)
        expect(options.config[:strict]).to be_truthy
        expect(options.config[:banner])
          .to eq('Usage: usblamp [COMMAND] [OPTIONS]')
        expect(options.to_s)
          .to match(/-v, --version(\s+)Shows the current version/)
        expect(options.to_s)
          .to match(/-h, --help(\s+)Display this help message./)

        version = options.fetch_option(:v)
        expect(version.short).to eq('v')
        expect(version.long).to eq('version')
        expect { version.call }.to output(/usblamp v.* on ruby/).to_stdout
      end

      it 'should retrieve version information' do
        expect(CLI.version_information).to eq(
          "usblamp v#{VERSION} on #{RUBY_DESCRIPTION}"
        )
      end

      it 'should change color' do
        controller = double(open: true,
                            switch_off: true,
                            parse: { c: 'blue' },
                            send_color: true)
        allow(Controller).to receive(:new).and_return(controller)
        expect(CLI.slop.parse(c: 'blue')).to eq(c: 'blue')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
usblamp-0.2.0 spec/usblamp/cli_spec.rb
usblamp-0.1.1 spec/usblamp/cli_spec.rb