Sha256: f9f7db18754cbb5adfceca3a1143f11e6001178ddd24a6ef74d1692a2b2c055e

Contents?: true

Size: 922 Bytes

Versions: 5

Compression:

Stored size: 922 Bytes

Contents

require "rails_helper"

describe "All fixtures js erb" do
  subject do
    sprockets_env = Sprockets::Environment.new
    sprockets_env.append_path("app/assets/javascripts/")
    sprockets_env["magic_lamp/all_fixtures.js"].to_s
  end

  it "sets cache only to true" do
    expect(subject).to match(/MagicLamp.genie.cacheOnly = true/)
  end

  it "provides all of the fixtures as json in the cache" do
    excaped_json = Regexp.escape(MagicLamp.generate_all_fixtures.to_json)
    expect(subject).to match(/MagicLamp.genie.cache = #{excaped_json}/)
  end

  it "does not throw an error" do
    expect(subject).to_not match(/throw new Error\(MagicLamp.genericError\)/)
  end

  context "errors" do
    before do
      allow(MagicLamp).to receive(:generate_all_fixtures).and_raise("Some error")
    end

    it "throws an error" do
      expect(subject).to match(/throw new Error\(MagicLamp.genericError\)/)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
magic_lamp-1.8.0 spec/lib/all_fixtures_spec.rb
magic_lamp-1.7.0 spec/lib/all_fixtures_spec.rb
magic_lamp-1.6.2 spec/lib/all_fixtures_spec.rb
magic_lamp-1.6.1 spec/lib/all_fixtures_spec.rb
magic_lamp-1.6.0 spec/lib/all_fixtures_spec.rb