Permalink
Browse files

speccing dumper aborting on non-activerecord errors (load and dump)

so if you hit ctrl-c it will scrap the transaction
  • Loading branch information...
1 parent fdf7ec8 commit ebff0338e7dd51561e1930fde3770d551da7be12 @ianwhite committed Aug 11, 2010
Showing with 53 additions and 1 deletion.
  1. +53 −1 spec/lib/git_friendly_dumper_spec.rb
@@ -202,6 +202,32 @@ def connection
end
end
end
+
+
+ describe "dumping when RAISE_ERROR=false" do
+ let(:dumper) {GitFriendlyDumper.new(:include_schema => true, :raise_error => false, :path => @path)}
+ subject{ dumper }
+
+ describe "when #dump_records raises a runtime error" do
+ before(:each) do
+ dumper.should_receive(:dump_records).and_raise(RuntimeError)
+ end
+
+ it "#dump should raise a runtime error" do
+ lambda { dumper.dump }.should raise_error(RuntimeError)
+ end
+ end
+
+ describe "when #dump_records raises an ActiveRecord::Error" do
+ before(:each) do
+ dumper.should_receive(:dump_records).at_least(1).times.and_raise(ActiveRecord::ActiveRecordError)
+ end
+
+ it "#dump should not raise a runtime error" do
+ lambda { dumper.dump }.should_not raise_error
+ end
+ end
+ end
end
describe "when fixtures exist" do
@@ -261,8 +287,34 @@ def connection
it_should_behave_like "when db data exists"
end
+ end
+
+
+
+
+ describe "loading when RAISE_ERROR=false" do
+ let(:dumper) {GitFriendlyDumper.new(:include_schema => true, :raise_error => false, :path => @path)}
+ subject{ dumper }
+
+ describe "when connection raises a runtime error" do
+ before(:each) do
+ dumper.connection.should_receive(:insert_fixture).and_raise(RuntimeError)
+ end
+
+ it "#load should raise a runtime error" do
+ lambda { dumper.load }.should raise_error(RuntimeError)
+ end
+ end
-
+ describe "when connection raises an ActiveRecord::Error" do
+ before(:each) do
+ dumper.connection.should_receive(:insert_fixture).at_least(1).times.and_raise(ActiveRecord::ActiveRecordError)
+ end
+
+ it "#load should not raise a runtime error" do
+ lambda { dumper.load }.should_not raise_error
+ end
+ end
end
end
end

0 comments on commit ebff033

Please sign in to comment.