Sha256: 7c9ab952ae67b507dd5a69ab38fba9b10c7cd6a26846facc7a755761cdba73b0

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require 'commands/build_command'
require 'commands/tweet_command'
require 'commands/new_command'
require 'commands/import_tweet_command'
require 'pry'
require 'ignoramos'

RSpec.describe Ignoramos do
  shared_examples_for "a command executer" do
    let(:command) { double() }

    it 'instantiates a command and calls execute' do
      expect(command_class).
          to receive(:new).with(*args[1..-1]).and_return(command)
      expect(command).to receive(:execute)

      Ignoramos.new(args)
    end
  end

  shared_examples_for 'a command executer with no args' do
    let(:command) { double() }

    it 'instantiates a command and calls execute' do
      expect(command_class).to receive(:new).with(no_args).and_return(command)
      expect(command).to receive(:execute)

      Ignoramos.new(args)
    end
  end

  describe '#initialize' do
    describe 'when the command passed is "new"' do
      let(:args) { ['new', 'tempsite'] }
      let(:command_class) { NewCommand }

      it_behaves_like "a command executer"
    end

    describe 'when the command passed is "tweet"' do
      let(:args) { ['tweet', 'this is a tweet'] }
      let(:command_class) { TweetCommand }

      it_behaves_like "a command executer"
    end

    describe 'when the command passed is "build"' do
      let(:args) { ['build'] }
      let(:command_class) { BuildCommand }

      it_behaves_like "a command executer with no args"
    end

    describe 'when the command passed is "import_tweet"' do
      let(:args) { ['import_tweet', '1234'] }
      let(:command_class) { ImportTweetCommand }

      it_behaves_like "a command executer"
    end

    describe 'when the command is unsupported' do
      let(:args) { ['asdasfsdfsd'] }
      let(:command_class) { Ignoramos::NilCommand }

      it_behaves_like "a command executer with no args"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ignoramos-1.1.0 spec/ignoramos_spec.rb