Sha256: 818e2a06d0fe8595c8346924374da001be980496061faa9b4ac3a28882e858d2

Contents?: true

Size: 980 Bytes

Versions: 2

Compression:

Stored size: 980 Bytes

Contents

require 'spec_helper'

describe Sheet::Copy do

  it 'should copy the snippet' do
    cmd = "cat #{Sheet.sheet_path('git')} | pbcopy"
    Sheet.should_receive(:exec).with(cmd, true)

    Sheet.stub(:copy_command) { 'pbcopy' }
    Sheet.stub(:sheet_exists?).with('git') { true }

    Sheet::Copy.new('git').copy
  end

  it 'should show an error if name is nil' do
    Sheet.should_receive(:write).with("Please specify a sheet name!")

    Sheet::Copy.new(nil).copy
  end

  it 'should show an error if snippet is not found' do
    Sheet.should_receive(:write).with("A sheet named git could not be found")
    Sheet.stub(:sheet_exists?).with('git') { false }

    Sheet::Copy.new('git').copy
  end

  it 'should show a message if no copy program was found' do
    Sheet.should_receive(:write).with("Could not copy sheet, no copy command found")

    Sheet.stub(:copy_command) { nil }
    Sheet.stub(:sheet_exists?).with('git') { true }

    Sheet::Copy.new('git').copy
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sheet-0.2.0 spec/sheet/copy_spec.rb
sheet-0.1.5 spec/sheet/copy_spec.rb