Sha256: 3775a523c6ee89eb6731282c448ca007b5db0d39f1d4fc905d462486196a23a0
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
# encoding: UTF-8 require File.join(File.dirname(__FILE__), %w[.. spec_helper]) include TwitterCldr::Shared describe Resources do before(:each) do @resource = Resources.new end describe "#resource_for" do it "loads the requested resource from disk only once" do # note that it should convert the string "de" into a symbol mock(@resource).data_for(:de, "racehorse").once { "german racehorse resource" } # do it twice - the second one shouldn't call data_for @resource.resource_for("de", "racehorse").should == "german racehorse resource" @resource.resource_for("de", "racehorse").should == "german racehorse resource" end end describe "#data_for" do it "loads the correct file for the given locale and resource" do mock(YAML).load("data") { { "key" => "value" } } mock(File).read(File.join(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))), "resources", "de", "racehorse.yml")) { "data" } @resource.resource_for("de", "racehorse").should == { :key => "value" } end end describe "#deep_symbolize_keys" do it "should work with a regular hash" do result = @resource.send(:deep_symbolize_keys, { "twitter" => "rocks", "my" => "socks" }) result.should == { :twitter => "rocks", :my => "socks"} end it "should work with nested hashes" do result = @resource.send(:deep_symbolize_keys, { "twitter" => { "rocks" => "my socks" } }) result.should == { :twitter => { :rocks => "my socks" } } end it "should work with nested hashes and arrays" do result = @resource.send(:deep_symbolize_keys, { "twitter" => { "rocks_my" => [{ "socks" => "and mind" }, { "hard" => "core" }] } }) result.should == { :twitter => { :rocks_my => [{ :socks => "and mind" }, { :hard => "core" }] } } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter_cldr-1.0.1 | spec/shared/resources_spec.rb |