Sha256: 51e3136ef178cca6671157a90989060d4cf6f7b2057a5f7165ce39284e0fdfcb

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 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>/) }
    it { should match(/<style>/) }
  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

4 entries across 4 versions & 1 rubygems

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