Sha256: 18fefb28079f83387b84357d42c008f8ce8c49ff92decfc5e3ae00947d3ec145

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe(Jekyll::Generators::Opal) do
  let(:output_dir)  { dest_dir("js") }
  let(:output_file) { dest_dir("js", "opal.js") }
  let(:site)        { fixture_site }

  it "knows where to output the file" do
    expect(subject.output_location(site)).to eql(output_file)
  end

  it "can build the opal stdlib" do
    expect(subject.opal_stdlib.to_s).to match("(Opal);")
  end

  context "when ensuring directory is there" do
    before(:each) do
      FileUtils.rm_r(output_dir) if File.directory?(output_dir)
      subject.ensure_directory(subject.output_location(site))
    end

    it "creates the proper output directory" do
      expect(File.directory?(output_dir)).to be_truthy
    end
  end

  context "for a fresh site" do
    before(:each) do
      FileUtils.rm_r(dest_dir) if File.directory?(dest_dir)
    end

    it "writes the file" do
      expect(subject.write_file(subject.output_location(site))).to eql(output_file)
      expect(File.file?(output_file)).to be(true)
    end
  end

  it "adds the outputted file to the site.keep_files list" do
    expect(subject.keep_the_file(site)).to include("js/opal.js")
    expect(site.keep_files).to eql(%w(.git .svn js/opal.js))
  end

  it "adds the 'opal' namespace for liquid" do
    expect(subject.save_lib_file_location_to_config(site)).to eql({
      "version" => Opal::VERSION, "url" => "/js/opal.js"
    })
    expect(site.config.has_key?("opal")).to be_truthy
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-opal-0.3.0 spec/opal_generator_spec.rb
jekyll-opal-0.2.0 spec/opal_generator_spec.rb