Sha256: 13a71c6c4d0be183d0a6e54eeb3dd18c1af30694ffed134b7998117047f7a5a3

Contents?: true

Size: 1.85 KB

Versions: 3

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'
require 'magic_reveal/creator'
require 'pathname'

describe MagicReveal::Creator do
  let(:fetcher) { double(MagicReveal::RevealJsFetcher).as_null_object }
  before do
    subject.stub(:system) # This is an integration test thingy.
    subject.reveal_js_fetcher = fetcher
  end

  context "with a temporary directory" do
    subject { described_class.new @tmpdir }
    around { |example| Dir.mktmpdir { |dir| @tmpdir = Pathname.new dir; example.run } }

    its(:directory) { should eq(@tmpdir) }

    describe "create_project" do
      let(:project) { "project#{rand 99}" }
      before do
        FileUtils.stub(:copy_file)
        Pathname.any_instance.stub(:children).and_return([])
      end

      it "makes the project directory" do
        subject.create_project(project)
        expect(@tmpdir + project).to be_directory
      end

      it "fetches and saves reveal.js" do
        subject.create_project(project)
        expect(fetcher).
          to have_received(:save_important_parts_to).
          with(@tmpdir + project)
      end

      it "copies the template_slides" do
        src = subject.template_slides
        dst = @tmpdir + project + 'slides.md'
        FileUtils.should_receive(:copy_file).with(src.to_s, dst.to_s)
        subject.create_project(project)
      end

      it "copies the template_config_ru" do
        src = subject.template_config_ru
        dst = @tmpdir + project + 'config.ru'
        FileUtils.should_receive(:copy_file).with(src.to_s, dst.to_s)
        subject.create_project(project)
      end
    end

    describe ".template_slides" do
      its(:template_slides) { should be_kind_of(Pathname) }
      its(:template_slides) { should be_file }
    end

    describe ".template_config_ru" do
      its(:template_config_ru) { should be_kind_of(Pathname) }
      its(:template_config_ru) { should be_file }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
magic_reveal-2.4.0.5 spec/magic_reveal/creator_spec.rb
magic_reveal-2.4.0.4 spec/magic_reveal/creator_spec.rb
magic_reveal-2.4.0.3 spec/magic_reveal/creator_spec.rb