Sha256: 1ebf0ad6ae31670d764776cbe4fa92e8884a240bbf9d52c94397ee0584da766e

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require 'fileutils'
require 'tmpdir'

describe Marksman::Watcher do

  before do
    @test_dir = Dir.mktmpdir
    @markdown_file = Pathname.new(@test_dir).join('example.md')
    @theme_dir = Pathname.new(@test_dir).join('plain')
    FileUtils.copy 'spec/data/example.md', @markdown_file
    FileUtils.cp_r 'themes/plain', @test_dir
  end

  after do
    FileUtils.rm_r @test_dir
  end

  subject do 
    converter = double(Marksman::Converter)
    expect(Marksman::Converter).to receive(:new).with(anything).and_return(converter).exactly(2).times
    expect(converter).to receive(:write).exactly(2).times

    Marksman::Watcher.new(@markdown_file, 'output', @theme_dir)
  end

  it 'should monitor changes on the markdown file' do
    expect(subject).to receive(:sleep)
    subject.watch
    sleep 1
    File.write(@markdown_file, 'more example text')
    sleep 1
    subject.stop
  end

  it 'should monitor changes on the theme files' do
    expect(subject).to receive(:sleep)
    subject.watch
    sleep 1
    File.write(@theme_dir.join('index.haml'), 'haml')
    sleep 1
    subject.stop
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marksman-0.1 spec/marksman/watcher_spec.rb