Sha256: d774c21c4873591010ffc484cb8e56cb53087a80a95bb8085ca3ce719dc226db

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

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

  after do
    File.unlink 'preview.html' if File.exist?('preview.html')
    File.unlink 'foo.bar' if File.exist?('foo.bar')
  end

  context 'generated content' do
    before { Rpub::Commands::Preview.new.invoke }
    let(:subject) { File.read('preview.html') }

    it { should include('<p>foo</p>') }
    it { should include('<p>bar</p>') }
    it { should match(/foo.*bar/m) }
    it { should match(/<head>/) }
  end

  it 'should create new preview file' do
    expect {
      Rpub::Commands::Preview.new.invoke
    }.to create_file('preview.html')
  end

  it 'should do nothing when there are no files to preview' do
    Dir.chdir File.join(FIXTURES_DIRECTORY, 'no_files')
    expect {
      Rpub::Commands::Preview.new.invoke
    }.to_not create_file('preview.html')
  end

  it 'should allow overriding the filename' do
    expect {
      Rpub::Commands::Preview.new(['-o', 'foo.bar']).invoke
    }.to create_file('foo.bar')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rpub-0.1.0 spec/rpub/commands/preview_spec.rb