Sha256: adc50b0963481b6b2037a328d6a29d4270840dda29b0332b66096d1a4d3936c7
Contents?: true
Size: 1.54 KB
Versions: 9
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' describe Pump::Collection do subject { Pump::Collection.new } describe ".new" do it "should not accept any arguments" do subject lambda{ Pump::Collection.new("") }.should raise_error(ArgumentError) end its(:size) { should eql(0) } end describe "#add" do it "should add entry" do subject.add(:set_name, :xml, :value) subject.size.should eql(1) end it "should allow different formats" do subject.add(:set_name, :json, :value) subject.size.should eql(1) end it "should default to :default set" do subject.add(nil, :xml, :value) subject.get(:default, :xml).should eql(:value) end end describe "#get" do it "should return nil on unknown entry" do subject.get(:set_name, :xml).should eql(nil) subject.get(:default, :xml).should eql(nil) subject.get(nil, :xml).should eql(nil) subject.get(:default, :json).should eql(nil) end context "when entries are added" do before{ subject.add(:set_name, :xml, :value); subject.add(:default, :xml, :value2) } it "should return given value" do subject.get(:set_name, :xml).should eql(:value) subject.get(:default, :xml).should eql(:value2) end it "should return nil with wrong format" do subject.get(:set_name, :json).should eql(nil) subject.get(:default, :json).should eql(nil) end it "should default to :default on unknwon set" do subject.get(:unknown, :xml).should eql(:value2) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems