Sha256: 0f317eff6255e353dd98aaa4159c1caddb2665b44d9bb18669727e6e463883e1

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe Chouette::Loader, :type => :model do

  subject { Chouette::Loader.new("test") }

  before(:each) do
    allow(subject).to receive_messages :execute! => true
  end

  describe "#load_dump" do

  end

  describe "#import" do

    let(:chouette_command) { double :run! => true }

    before(:each) do
      allow(subject).to receive_messages :chouette_command => chouette_command
    end

    it "should use specified file in -inputFile option" do
      expect(chouette_command).to receive(:run!).with(hash_including(:input_file => File.expand_path('file')))
      subject.import "file"
    end
    
    it "should use specified format in -format option" do
      expect(chouette_command).to receive(:run!).with(hash_including(:format => 'DUMMY'))
      subject.import "file", :format => "dummy"
    end
    
  end

  describe "#create" do
    
    it "should quote schema name" do
      expect(subject).to receive(:execute!).with(/"test"/)
      subject.create
    end

  end

  describe "#drop" do

    it "should quote schema name" do
      expect(subject).to receive(:execute!).with(/"test"/)
      subject.drop
    end
    
  end

  describe "#backup" do

    let(:file) { "/dev/null" }

    it "should call pg_dump" do
      expect(subject).to receive(:execute!).with(/^pg_dump/)
      subject.backup file
    end

    it "should dump in specified file" do
      expect(subject).to receive(:execute!).with(/-f #{file}/)
      subject.backup file
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ninoxe-1.2.3 spec/models/chouette/loader_spec.rb
ninoxe-1.2.0 spec/models/chouette/loader_spec.rb