Sha256: 35c04d0df4246ac02f330377f33340788a87078a8912ea36481846f411ea887b

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'
require 'warp/dir/store'

RSpec.describe Warp::Dir::Command::Add do
  include_context :fake_serializer

  let(:store) { double }
  let(:command_class) { Warp::Dir::Command::Add }
  let(:commander) { Warp::Dir::Commander.instance }

  let(:wp_path) { ENV['HOME'] + '/workspace/tinker-mania' }
  let(:wp_name) { 'harro' }
  let(:point) { Warp::Dir::Point.new(wp_name, wp_path) }

  let(:add_command) { command_class.new(store, wp_name, wp_path) }

  before do
    expect(store).to receive(:config).and_return(config).at_least(:once)
  end

  it 'should have the commander defined' do
    expect(add_command.store).to_not be_nil
  end

  describe '#help' do
    it 'should define a help message' do
      expect(add_command.command_name).to eql(:add)
      expect(add_command.description).to match(%r(Adds the current directory)i)
      expect(add_command.help).to match /add/
      expect(add_command.help).to match /Adds the current directory/
    end
  end

  describe '#run' do
    it 'should call #save! on store after adding new wp' do
      expect(store).to receive(:insert).with(point_name: wp_name, point_path: wp_path, overwrite: false).and_return(point)
      add_command.run
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
warp-dir-1.1.3 spec/warp/dir/commands/add_spec.rb
warp-dir-1.1.2 spec/warp/dir/commands/add_spec.rb
warp-dir-1.1.1 spec/warp/dir/commands/add_spec.rb
warp-dir-1.1.0 spec/warp/dir/commands/add_spec.rb