aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/chouette/loader_spec.rb
diff options
context:
space:
mode:
authorXinhui2016-02-22 14:17:18 +0100
committerXinhui2016-02-22 14:17:18 +0100
commitd49f47b4ac1db2cd88b96d830772bb7773924601 (patch)
tree191c7b9cda9edf939792e7780df4e7460d685a4a /spec/models/chouette/loader_spec.rb
parent633004afc5861a6e8158948ddfecd73bf4dd86a8 (diff)
downloadchouette-core-d49f47b4ac1db2cd88b96d830772bb7773924601.tar.bz2
Merge model from ninoxe gem
Diffstat (limited to 'spec/models/chouette/loader_spec.rb')
-rw-r--r--spec/models/chouette/loader_spec.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/models/chouette/loader_spec.rb b/spec/models/chouette/loader_spec.rb
new file mode 100644
index 000000000..d359c443e
--- /dev/null
+++ b/spec/models/chouette/loader_spec.rb
@@ -0,0 +1,69 @@
+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
+