Sha256: 91f67a4b2b6bfeb305503e7313facca64346f89ce326e138d01fe6df4afab3eb

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Localeapp, "#load_yaml(content)" do
  let(:bad_yaml) { "---\n- 1\n- 2\n- 3\n- !ruby/object:Object\n    foo: 1\n" }

  it "raises an exception if the content contains potentially insecure yaml" do
    with_configuration(:raise_on_insecure_yaml => true) do
      expect { Localeapp.load_yaml(bad_yaml) }.to raise_error(Localeapp::PotentiallyInsecureYaml)
    end
  end

  it "doesn't raise if the raise_on_insecure_yaml setting is false" do
    with_configuration(:raise_on_insecure_yaml => false) do
      expect { Localeapp.load_yaml(bad_yaml) }.to_not raise_error
    end
  end
end

describe Localeapp, "#yaml_data(content, locale_key = nil)" do
  let(:content) { "en:\n   foo: bar" }
  let(:locale_key) { "en" }

  it "raises an exception if the given locale key is missing" do
    with_configuration do
      expect { Localeapp.yaml_data(content, "de") }.to raise_error("Could not find given locale")
    end
  end

  it "finds the given locale key" do
    with_configuration do
      expect(Localeapp.yaml_data(content, locale_key)).to eq({"en" => {"foo" => "bar"}})
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
localeapp-3.3.0 spec/localeapp_spec.rb
localeapp-3.2.0 spec/localeapp_spec.rb
localeapp-3.1.3 spec/localeapp_spec.rb
localeapp-3.1.2 spec/localeapp_spec.rb
localeapp-3.1.1 spec/localeapp_spec.rb
localeapp-3.1.0 spec/localeapp_spec.rb
localeapp-3.0.1 spec/localeapp_spec.rb
localeapp-3.0.0 spec/localeapp_spec.rb
localeapp-2.5.0 spec/localeapp_spec.rb
localeapp-2.4.0 spec/localeapp_spec.rb