Sha256: 0507e0865fe4b9299464ebdffa86e154c02d23f04fd7bc3e440bd8e35d45e4b3
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require "spec_helper" describe Hashtring::Constructor do subject do Hashtring::Constructor.new( "Reports", { marketing: "Marketing Reports" } ) end describe "#[]" do it 'returns a value from the hash' do expect(subject[:marketing]).to eq("Marketing Reports") end context "when the key does not exist" do it "returns nil" do expect(subject[:wrong]).to be_nil end end end describe "#inspect" do it "returns the name" do expect(subject.inspect).to eq("Reports") end end describe "#method_missing" do context "when the hash key exists" do it "returns a value from the hash" do expect(subject.marketing).to eq("Marketing Reports") end end context "when the hash key does not exist" do it "raises a no method error" do expect{ subject.wrong }.to raise_error(NoMethodError) end end end describe "#to_s" do it "returns the name" do expect(subject.to_s).to eq("Reports") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hashtring-0.0.1 | spec/lib/hashtring/constructor_spec.rb |