Sha256: 47495e76fbd1adbe4a80618317936c7e1a37a5bab60336cbd4ed452af5b0f991

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

#encoding: UTF-8

require 'helper/account'
require 'ruby-box'
require 'webmock/rspec'

describe RubyBox::Client do
  before do
    @session = RubyBox::Session.new
  end

  describe '#split_path' do
    it "returns the appropriate path" do
      client = RubyBox::Client.new(@session)
      client.split_path('foo/bar').should == ['foo', 'bar']
    end

    it "leading / is ignored" do
      client = RubyBox::Client.new(@session)
      client.split_path('/foo/bar').should == ['foo', 'bar']
    end

    it "trailing / is ignored" do
      client = RubyBox::Client.new(@session)
      client.split_path('foo/bar/').should == ['foo', 'bar']
    end
  end
  
  describe '#create_folder' do
    it 'doesnt call folder.create_folder if the folder exists' do
      client = RubyBox::Client.new(@session)
      mock_root_folder = mock( Object )
      test_folder = mock( Object )
      mock_root_folder.should_receive(:folders).and_return([test_folder])
      mock_root_folder.should_not_receive(:create_subfolder)
      client.should_receive(:root_folder).and_return(mock_root_folder)
      result = client.create_folder( '/test0')
      result.should == test_folder
    end
    
    it 'calls folder.create_folder if the folder does not exist' do
      client = RubyBox::Client.new(@session)
      mock_root_folder = mock( Object )
      test_folder = mock( Object )
      mock_root_folder.should_receive(:folders).and_return([])
      mock_root_folder.should_receive(:create_subfolder).and_return(test_folder)
      client.should_receive(:root_folder).and_return(mock_root_folder)
      result = client.create_folder( '/test0')
      result.should == test_folder
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-box-1.0.6 spec/client_spec.rb