aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorMichel Etienne2012-06-07 14:25:34 +0200
committerMichel Etienne2012-06-07 14:25:34 +0200
commit6e19b591d5ca4304feedd4bc7dbe5e4e9dd5fb5d (patch)
tree35d96ace6fe6ad1f44a4e55cf47ac40b7c4d0fba /spec/models
parent99be0398f6f9826d6250bc061c721854bef07674 (diff)
parentba29325c18776daa28615b88eb6d75e874341b66 (diff)
downloadchouette-core-6e19b591d5ca4304feedd4bc7dbe5e4e9dd5fb5d.tar.bz2
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/export_log_message_spec.rb16
-rw-r--r--spec/models/export_spec.rb63
2 files changed, 79 insertions, 0 deletions
diff --git a/spec/models/export_log_message_spec.rb b/spec/models/export_log_message_spec.rb
new file mode 100644
index 000000000..8aa3cde6e
--- /dev/null
+++ b/spec/models/export_log_message_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe ExportLogMessage do
+
+ describe "#attributes" do
+
+ subject { create :export_log_message }
+
+ it "should read json stored in database" do
+ subject.update_attribute :arguments, { "key" => "value"}
+ subject.raw_attributes.should == { "key" => "value"}.to_json
+ end
+
+ end
+
+end
diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb
new file mode 100644
index 000000000..bccaa4c42
--- /dev/null
+++ b/spec/models/export_spec.rb
@@ -0,0 +1,63 @@
+require 'spec_helper'
+
+describe Export do
+
+ subject { create :export }
+
+ RSpec::Matchers.define :be_log_message do |expected|
+ match do |actual|
+ actual and expected.all? { |k,v| actual[k.to_s] == v }
+ end
+ end
+
+ describe "#export" do
+
+ before(:each) do
+ subject.stub :exporter => mock(:export => true)
+ end
+
+ it "should create a ExportLogmessage :started when started" do
+ subject.export
+ subject.log_messages.first.should be_log_message(:key => "started")
+ end
+
+ it "should create a ExportLogmessage :completed when completed" do
+ subject.export
+ subject.log_messages.last.should be_log_message(:key => "completed")
+ end
+
+ it "should create a ExportLogmessage :failed when failed" do
+ pending
+ # subject.loader.stub(:export).and_raise("export failed")
+ subject.export
+ subject.log_messages.last.should be_log_message(:key => "failed")
+ end
+
+ end
+
+ describe "#options" do
+
+ it "should be empty by default" do
+ subject.options.should be_empty
+ end
+
+ end
+
+ describe ".types" do
+
+ it "should return available Export implementations" do
+ pending
+ Export.types.should =~ %w{NeptuneExport}
+ end
+
+ end
+
+ describe ".new" do
+
+ it "should use type attribute to create a subclass" do
+ Export.new(:type => "NeptuneExport").should be_an_instance_of(NeptuneExport)
+ end
+
+ end
+
+end