Sha256: a7abd5ac163b9d43737992f9c72618ab798997e43dcfcb702fd7270f8f648228
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
describe Casino::Store do let(:key) { "collection_name" } let(:store) { Casino::Store.new(key) } subject { store } it { subject.must_respond_to :collection_name } it "establishes a connection to the default session" do store.collection.database.session.must_equal Mongoid.default_session end it "establishes a connection to the correct collection" do store.collection.name.must_equal key end describe '#criteria' do it "provides a criteria interface" do store.criteria.must_be_instance_of Mongoid::Criteria end end describe '#merge' do let(:womens_boots) do { '_id' => { 'date' => "mm/dd/yyyy", 'label' => "women's boots" } } end let(:mens_boots) do { '_id' => { 'date' => "mm/dd/yyyy", 'label' => "men's boots" } } end let(:value_hash) do { 'value' => { 'signups' => 10850, 'uniques' => 9822 } } end let(:document) { womens_boots.merge(value_hash) } let(:document_two) { mens_boots.merge(value_hash) } it "adds new documents to the collection" do store.merge(document) store.first.must_equal document end it "updates documents" do store.merge(document) store.merge(document.merge(value: { signups: 2 })) store.first['value']['signups'].must_equal 2 end it "does not replace the wrong document" do store.merge(document) store.merge(document_two) store.find.count.wont_equal 1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid-casino-0.0.2 | spec/lib/casino/store_spec.rb |
mongoid-casino-0.0.1 | spec/lib/casino/store_spec.rb |