Sha256: 2f3e6eec812b58fa35616d95770daa4baa5cd142b205749ef18fc096cbc474cc

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Rpub::Commands::Clean do
  before do
    Dir.chdir File.join(FIXTURES_DIRECTORY, 'clean')
  end

  after do
    FileUtils.touch 'preview.html'
    FileUtils.touch 'example.epub'
  end

  it 'should remove example.epub file' do
    expect {
      described_class.new.invoke
    }.to remove_file('example.epub')
  end

  it 'should remove preview.html file' do
    expect {
      described_class.new.invoke
    }.to remove_file('preview.html')
  end

  context 'when in dry run mode' do
    let(:buffer) { StringIO.new }
    let(:subject) { described_class.new(['-d'], buffer) }

    it 'should print preview.html' do
      subject.invoke
      buffer.string.should include('preview.html')
    end

    it 'should not print non-existant files' do
      FileUtils.rm 'preview.html'
      subject.invoke
      buffer.string.should_not include('preview.html')
    end

    it 'should not remove existing files' do
      expect {
        subject.invoke
      }.to_not remove_file('preview.html')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rpub-0.4.0 spec/rpub/commands/clean_spec.rb
rpub-0.3.0 spec/rpub/commands/clean_spec.rb
rpub-0.2.1 spec/rpub/commands/clean_spec.rb
rpub-0.2.0 spec/rpub/commands/clean_spec.rb
rpub-0.1.0 spec/rpub/commands/clean_spec.rb