spec/unit/cassanity/column_family_spec.rb in cassanity-0.2.1 vs spec/unit/cassanity/column_family_spec.rb in cassanity-0.2.2

- old
+ new

@@ -78,9 +78,41 @@ subject.schema }.to raise_error(Cassanity::Error, "No schema found to create #{column_family_name} column family. Please set :schema during initialization or include it as a key in #create call.") end end + shared_examples_for "column family existence" do |method_name| + it "returns true if column family name included in column families" do + executor.should_receive(:call).with({ + command: :column_families, + arguments: {keyspace_name: keyspace.name}, + }).and_return([ + {'columnfamily' => column_family_name}, + ]) + + subject.send(method_name).should be_true + end + + it "returns false if column family name not included in column families" do + executor.should_receive(:call).with({ + command: :column_families, + arguments: {keyspace_name: keyspace.name}, + }).and_return([ + {'columnfamily' => 'boo'}, + ]) + + subject.send(method_name).should be_false + end + end + + describe "#exists?" do + include_examples "column family existence", :exists? + end + + describe "#exist?" do + include_examples "column family existence", :exist? + end + describe "#create" do context "with schema set during initialization" do subject { described_class.new(required_arguments.merge({ schema: schema,