From a7e6d17c8f30c463bc02ce10d587d2f1a275d7a8 Mon Sep 17 00:00:00 2001 From: Rany Keddo Date: Mon, 16 Jan 2012 13:54:23 +0100 Subject: [PATCH] added intersection specs --- spec/unit/intersection_spec.rb | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 spec/unit/intersection_spec.rb diff --git a/spec/unit/intersection_spec.rb b/spec/unit/intersection_spec.rb new file mode 100644 index 00000000..8aff3fb8 --- /dev/null +++ b/spec/unit/intersection_spec.rb @@ -0,0 +1,42 @@ +# +# Copyright (c) 2011, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias +# Schmidt +# + +require File.expand_path(File.dirname(__FILE__)) + '/unit_helper' + +require 'lhm/table' +require 'lhm/migrator' + +describe Lhm::Intersection do + include UnitHelper + + it "should not have dropped changes" do + origin = Lhm::Table.new("origin") + origin.columns["dropped"] = varchar + origin.columns["retained"] = varchar + + destination = Lhm::Table.new("destination") + destination.columns["retained"] = varchar + + intersection = Lhm::Intersection.new(origin, destination) + intersection.common.include?("dropped").must_equal(false) + end + + it "should have unchanged columns" do + origin = Lhm::Table.new("origin") + origin.columns["dropped"] = varchar + origin.columns["retained"] = varchar + + destination = Lhm::Table.new("destination") + destination.columns["retained"] = varchar + + intersection = Lhm::Intersection.new(origin, destination) + intersection.common.must_equal(["retained"]) + end + + def varchar + { :metadata => "VARCHAR(255)"} + end +end +