Sha256: 9b2810a621dd3949abcd1a1f40ecca7b0077d923d035379001185b55c5dd4edd

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'integration_spec_helper'

describe 'Folders operations' do

  if account_file_exists?

    before(:all) do
      @storage = login
    end

    let(:name) { "test_folder" }

    context 'when #create_folder is called on a node' do

      before do
        @folder = @storage.root.create_folder(name)
      end

      it 'creates a new folder under that node' do
        expect(@folder.name).to eql name
        expect(@folder.parent_handle).to eq @storage.root.handle
      end

      after do
        @folder.delete
      end
    end

    context 'searching for a folder by its handle' do
      before do
        @folder = @storage.root.create_folder(name)
      end

      it 'returns the matching folder' do
        found_node = @storage.nodes.find { |n| n.handle == @folder.handle }
        expect(found_node).not_to be_nil
      end

      after do
        @folder.delete
      end
    end

    context 'when #create_folder under created folder' do
      before do
        @folder = @storage.root.create_folder(name)
        @sub_folder = @folder.create_folder(name)
      end

      it 'creates a new folder under created folder' do
        found_node = @storage.nodes.find { |n| n.handle == @sub_folder.handle }
        expect(found_node.parent_handle).to eq(@folder.handle)
      end

      after do
        @folder.delete
        found_node = @storage.nodes.find { |n| n.handle == @sub_folder.handle }
        expect(found_node).to be_nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rmega-0.2.0 spec/integration/folder_operations_spec.rb