Sha256: ae387556ffae3754c1c942ecd3d69d8c1ff0ff29358be19ad611f7b267ce8503

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

require "spec_helper"

require "support/object_store_setup"
require "support/seed_data_setup"
require "terrestrial"

RSpec.describe "Querying" do
  include_context "object store setup"
  include_context "seed data setup"

  subject(:user_store) { object_store[:users] }

  let(:user) {
    user_store.where(id: "users/1").first
  }

  let(:query_criteria) {
    {
      body: "I do it three times purrr day",
    }
  }

  let(:filtered_posts) {
    user.posts.where(query_criteria)
  }

  describe "arbitrary where query" do
    it "returns a filtered version of the association" do
      expect(filtered_posts.map(&:id)).to eq(["posts/2"])
    end

    it "returns another collection" do
      expect(filtered_posts).not_to be(user.posts)
    end

    it "returns an immutable collection" do
      expect(filtered_posts.public_methods).not_to include(:push, :<<, :delete)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
terrestrial-0.5.0 spec/querying_spec.rb
terrestrial-0.3.0 spec/querying_spec.rb