Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests on bucket for backward compatibility #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions spec/bucket_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true, encoding: ASCII-8BIT

require File.expand_path("../support", __FILE__)

class BucketTest < CouchbaseOrm::Base
attribute :name, :job
end

describe CouchbaseOrm::Base do
it "should return bucket name" do
name = BucketTest.bucket.name
expect(name).to eq("default")
end

it "should retrieve document from bucket" do
base = BucketTest.create!(name: 'joe')
resp = BucketTest.bucket.get(base.id, extended: true)
expect(resp.key).to eq(base.id)
end

it "should retrieve document from bucket" do
base = BucketTest.create!(name: 'joe')
resp = BucketTest.bucket.n1ql.select('RAW meta(ui).id').from('default').where('name="joe"').order_by('name DESC')
expect(resp.to_s).to eq("SELECT RAW meta(ui).id FROM default WHERE name=\"joe\" ORDER BY name DESC ")
end

it "should expose functions" do
functions = [
:build_index, :create_index, :drop_index, :create_primary_index,
:drop_primary_index, :grant, :on, :to, :infer, :select, :insert_into,
:delete_from, :update, :from, :with, :use_keys, :unnest, :join, :where,
:group_by,
]
resp = BucketTest.bucket.n1ql.methods
expect(resp).to include(*functions)
end
end