Sha256: 12adeb1ae997037837191966308e3a5e422208addeff35f3e6ce8535a7c89fdb

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe Sdbport do
  before do
    @logger_stub = logger_stub
    @sdb_mock = sdb_mock
    @file_mock = mock 'file'
    @export = Sdbport::Domain::Export.new :name       => 'name',
                                          :logger     => @logger_stub,
                                          :access_key => 'the-key',
                                          :secret_key => 'the-secret',
                                          :region     => 'us-west-1'
  end

  it "should export the domain to the given output" do
    File.should_receive(:open).with('/tmp/file', 'w').
                               and_return @file_mock
    data = { 'item1' => 
             { 'attribute' => [ 'value' ] },
             'item2' =>
             { 'attribute' => [ 'different' ] }
           }
    @sdb_mock.should_receive(:select).
              with('select * from `name`').
              and_return data
    @file_mock.should_receive(:write).with("[\"item1\",{\"attribute\":[\"value\"]}]")
    @file_mock.should_receive(:write).with("[\"item2\",{\"attribute\":[\"different\"]}]")
    @file_mock.should_receive(:write).with("\n").exactly(2).times
    @file_mock.should_receive(:close).and_return nil
    @export.export('/tmp/file').should be_true
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sdbport-0.1.0 spec/domain/export_spec.rb