Sha256: a49d9953dde03a16ae021234a2dab0ea88bce2301646673aa6325b3c784682f4

Contents?: true

Size: 973 Bytes

Versions: 2

Compression:

Stored size: 973 Bytes

Contents

require 'spec_helper'

describe Stroop::CLI do
  let(:seed) { 1234 }

  before do
    allow_any_instance_of(Stroop::Set).to receive(:seed) { seed }
    allow_any_instance_of(Stroop::Set).to receive(:to_s) { '' }
    allow($stdout).to receive(:puts) { '' }
  end

  subject { described_class.new([seed]) }

  [:neutral, :congruent, :incongruent].each do |method|
    it { is_expected.to respond_to method }

    describe "##{method}" do
      let(:columns) { 1 }
      let(:rows) { 1 }
      let(:args) { "#{columns}x#{rows}" }

      it 'prints to the standard output' do
        expect { subject.send(method, args) }.to output.to_stdout
      end

      it 'prints the stroop set' do
        set = Stroop::Set.new(columns: columns, rows: rows, mode: method, seed: seed)
        output = capture(:stdout) { subject.send(method, args) }

        expect(output).to include set.to_s
        expect(output).to include "Generated with seed: #{seed}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stroop-1.2.0 spec/stroop/cli_spec.rb
stroop-1.1.0 spec/stroop/cli_spec.rb