spec/query_spec.rb in fauna-2.1.2 vs spec/query_spec.rb in fauna-2.2.0

- old
+ new

@@ -318,24 +318,10 @@ # Sanity check expect { client.query { get ref } }.to raise_error(Fauna::NotFound) end end - describe '#count' do - before do - @x_value = random_number - @x_refs = (1..3).collect { create_instance(x: @x_value)[:ref] } - end - - it 'performs count' do - set = Fauna::Query.match(@test_by_x, @x_value) - - # Count is only approximate; should be equal to @x_refs.length - expect(client.query { count set }).to be_a(Integer) - end - end - describe '#create' do it 'performs create' do instance = client.query { create(@test_class, {}) } expect(instance[:class]).to eq(@test_class) @@ -404,10 +390,52 @@ # Assert it changed expect(client.query { get(ref) }).to eq(instance) end end + describe '#create_class' do + it 'creates a class' do + # Create a class + ref = client.query { create_class(name: random_string) }[:ref] + + # Assert it was created + expect(client.query { exists(ref) }).to be(true) + end + end + + describe '#create_index' do + it 'creates an index' do + # Create an index + class_ref = client.query { create(ref('classes'), name: random_string) }[:ref] + ref = client.query { create_index(name: random_string, source: class_ref) }[:ref] + + # Assert it was created + expect(client.query { exists(ref) }).to be(true) + end + end + + describe '#create_database' do + it 'creates a database' do + # Create a database + ref = admin_client.query { create_database(name: random_string) }[:ref] + + # Assert it was created + expect(admin_client.query { exists(ref) }).to be(true) + end + end + + describe '#create_key' do + it 'creates a key' do + # Create a key + db_ref = admin_client.query { create(ref('databases'), name: random_string) }[:ref] + ref = admin_client.query { create_key(database: db_ref, role: 'server') }[:ref] + + # Assert it was created + expect(admin_client.query { exists(ref) }).to be(true) + end + end + describe 'sets' do before do @x_value = random_number @y_value = random_number @@ -588,9 +616,43 @@ end describe '#next_id' do it 'gets a new id' do expect(client.query { next_id }).to be_a(String) + end + end + + describe '#database' do + it 'gets an existing database' do + # Create a database + name = random_string + ref = admin_client.query { create_database(name: name) }[:ref] + + # Get the database ref + expect(admin_client.query { database(name) }).to eq(ref) + end + end + + describe '#class' do + it 'gets an existing class' do + # Create a class + name = random_string + ref = client.query { create_class(name: name) }[:ref] + + # Get the class ref + expect(client.query { class_(name) }).to eq(ref) + end + end + + describe '#index' do + it 'gets an existing index' do + # Create an index + class_ref = client.query { create_class(name: random_string) }[:ref] + name = random_string + ref = client.query { create_index(name: name, source: class_ref) }[:ref] + + # Get the index ref + expect(client.query { index(name) }).to eq(ref) end end describe '#equals' do it 'performs equals' do