Sha256: f30937df527e34d29c4a46d18b55c2102c291b1e8a1bf0512df6093b3cb62d41

Contents?: true

Size: 1.42 KB

Versions: 1

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!(/^\s*/, '').chomp!
      subject.dependencies.gsub(/^\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

1 entries across 1 versions & 1 rubygems

Version Path
magic_reveal-2.6.1.4 spec/magic_reveal/project_config_spec.rb