Sha256: 28c6d6a27830a2e640e00923461b639ce32bc62b18c2bb2b3144cc36a261d8ca
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require "spec_helper" require "support/mapper_setup" require "support/sequel_persistence_setup" require "support/have_persisted_matcher" RSpec.describe "Persist a new graph in empty datastore" do include_context "mapper setup" include_context "sequel persistence setup" context "given a graph of new objects" do it "persists the root node" do user_mapper.save(hansel) expect(datastore).to have_persisted(:users, { id: hansel.id, first_name: hansel.first_name, last_name: hansel.last_name, email: hansel.email, }) end it "persists one to many related nodes 1 level deep" do user_mapper.save(hansel) expect(datastore).to have_persisted(:posts, hash_including( id: "posts/1", subject: "Biscuits", body: "I like them", author_id: "users/1", )) expect(datastore).to have_persisted(:posts, hash_including( id: "posts/2", subject: "Sleeping", body: "I do it three times purrr day", author_id: "users/1", )) end it "persists one to many related nodes 2 levels deep" do user_mapper.save(hansel) expect(datastore).to have_persisted(:comments, { id: "comments/1", body: "oh noes", post_id: "posts/1", commenter_id: "users/1", }) end it "persists many to many related nodes" do user_mapper.save(hansel) expect(datastore).to have_persisted(:categories, { id: "categories/1", name: "Cat biscuits", }) end it "persists a 'join table' to faciliate many to many" do user_mapper.save(hansel) expect(datastore).to have_persisted(:categories_to_posts, { category_id: "categories/1", post_id: "posts/1", }) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sequel_mapper-0.0.3 | spec/new_graph_persistence_spec.rb |