Sha256: ea4a409f48df03391bdd7ed627690386d3599b7c445cfc3925ecf14c21bf23c4

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'
require 'magic_reveal/project_config'

describe MagicReveal::ProjectConfig do
  subject { described_class.new io }
  let(:io) { MagicReveal::ProjectConfig::DEFAULT_TEMPLATE }
  let(:data_ruby) { { "random" => rand(99) }.to_json }
  let(:data_json) { data_ruby.to_json }

  describe "#new" do
    it "calls io_or_path.read" do
      io.should_receive(:read).with().and_return("{}")
      subject
    end

    context "with a string" do
      it "converts strings to Pathname" do
        pio = Pathname.new(io)
        Pathname.should_receive(:new).with(io).and_return(pio)
        subject
      end
    end
  end

  describe ".dependencies" do
    it "should look like the example" do
      example = <<-EOF
      "dependencies": [
      { src: "lib/js/classList.js", condition: function() { return !document.body.classList; } },
      { src: "plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
      { src: "plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } },
      { src: "plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }
      ]
      EOF
      example.gsub!(%r{^\s*}, '').chomp!
      subject.dependencies.gsub(%r{^\s*}, '').should eq(example)
    end
  end

  describe ".to_js" do
    it "returns a string" do
      expect(subject.to_js).to be_kind_of(String)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
magic_reveal-2.6.1.2 spec/magic_reveal/project_config_spec.rb
magic_reveal-2.6.1.1 spec/magic_reveal/project_config_spec.rb
magic_reveal-2.4.0.5 spec/magic_reveal/project_config_spec.rb
magic_reveal-2.4.0.4 spec/magic_reveal/project_config_spec.rb