diff --git a/spec/comparator_spec.rb b/spec/comparator_spec.rb index 2960a85..cc28c75 100644 --- a/spec/comparator_spec.rb +++ b/spec/comparator_spec.rb @@ -97,23 +97,24 @@ def test_for_value(value) end res.class.should eq(Time) end - end - context "with decimal comparator" do - let(:cf_name) { "comparator_cf_decimal" } - before(:each) { create_column_family(cf_name, 'DecimalType') } + if CASSANDRA_VERSION.to_f >= 1.0 + context "with decimal comparator" do + let(:cf_name) { "comparator_cf_decimal" } + before(:each) { create_column_family(cf_name, 'DecimalType') } - def test_for_value(value) - create_and_fetch_column(cf_name, value).should eq(value) - create_and_fetch_column(cf_name, value*-1).should eq(value*-1) - end - - it "should return a small decimal" do - test_for_value(15.333) - end - it "should return a huge decimal" do - test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) + def test_for_value(value) + create_and_fetch_column(cf_name, value).should eq(value) + create_and_fetch_column(cf_name, value*-1).should eq(value*-1) + end + + it "should return a small decimal" do + test_for_value(15.333) + end + it "should return a huge decimal" do + test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) + end end end @@ -151,26 +152,29 @@ def test_for_value(value) end end - context "with int comparator" do - let(:cf_name) { "comparator_cf_int" } - before(:each) { create_column_family(cf_name, 'Int32Type') } + if CASSANDRA_VERSION.to_f >= 1.0 + #Int32Type was added in 1.0 (CASSANDRA-3031) + context "with int comparator" do + let(:cf_name) { "comparator_cf_int" } + before(:each) { create_column_family(cf_name, 'Int32Type') } - def test_for_value(value) - create_and_fetch_column(cf_name, value).should eq(value) - create_and_fetch_column(cf_name, value*-1).should eq(value*-1) - end - - it "should properly convert integer values that fit into 1 byte" do - test_for_value(1) - end - it "should properly convert integer values that fit into 2 bytes" do - test_for_value(2**8 + 80) - end - it "should properly convert integer values that fit into 3 bytes" do - test_for_value(2**16 + 622) - end - it "should properly convert integer values that fit into 4 bytes" do - test_for_value(2**24 + 45820) + def test_for_value(value) + create_and_fetch_column(cf_name, value).should eq(value) + create_and_fetch_column(cf_name, value*-1).should eq(value*-1) + end + + it "should properly convert integer values that fit into 1 byte" do + test_for_value(1) + end + it "should properly convert integer values that fit into 2 bytes" do + test_for_value(2**8 + 80) + end + it "should properly convert integer values that fit into 3 bytes" do + test_for_value(2**16 + 622) + end + it "should properly convert integer values that fit into 4 bytes" do + test_for_value(2**24 + 45820) + end end end diff --git a/spec/rowkey_spec.rb b/spec/rowkey_spec.rb index a9bb84e..e7317d5 100644 --- a/spec/rowkey_spec.rb +++ b/spec/rowkey_spec.rb @@ -56,7 +56,11 @@ def test_for_value(value) context "with blob row_key_validation" do let(:cf_name) { "row_key_validation_cf_blob" } - before(:each) { create_column_family(cf_name, 'blob') } + if CASSANDRA_VERSION.to_f == 0.8 + before(:each) { create_column_family(cf_name, 'bytea') } + else + before(:each) { create_column_family(cf_name, 'blob') } + end it "should return a blob" do bytes = "binary\x00" @@ -78,20 +82,22 @@ def test_for_value(value) end end - context "with decimal row_key_validation" do - let(:cf_name) { "row_key_validation_cf_decimal" } - before(:each) { create_column_family(cf_name, 'decimal') } + if CASSANDRA_VERSION.to_f >= 1.0 + context "with decimal row_key_validation" do + let(:cf_name) { "row_key_validation_cf_decimal" } + before(:each) { create_column_family(cf_name, 'decimal') } - def test_for_value(value) - create_and_fetch_column(cf_name, value*-1).should eq(value*-1) - create_and_fetch_column(cf_name, value).should eq(value) - end - - it "should return a small decimal" do - test_for_value(15.333) - end - it "should return a huge decimal" do - test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) + def test_for_value(value) + create_and_fetch_column(cf_name, value*-1).should eq(value*-1) + create_and_fetch_column(cf_name, value).should eq(value) + end + + it "should return a small decimal" do + test_for_value(15.333) + end + it "should return a huge decimal" do + test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) + end end end @@ -167,7 +173,11 @@ def test_for_value(value) context "with timestamp row_key_validation" do let(:cf_name) { "row_key_validation_cf_timestamp" } - before(:each) { create_column_family(cf_name, 'timestamp') } + if CASSANDRA_VERSION.to_f == 0.8 + before(:each) { create_column_family(cf_name, 'date') } + else + before(:each) { create_column_family(cf_name, 'timestamp') } + end it "should return a timestamp" do uuid = UUID.new diff --git a/spec/validation_spec.rb b/spec/validation_spec.rb index a1b3754..03293b2 100644 --- a/spec/validation_spec.rb +++ b/spec/validation_spec.rb @@ -56,7 +56,11 @@ def test_for_value(value) context "with blob validation" do let(:cf_name) { "validation_cf_blob" } - before(:each) { create_column_family(cf_name, 'blob') } + if CASSANDRA_VERSION.to_f == 0.8 + before(:each) { create_column_family(cf_name, 'bytea') } + else + before(:each) { create_column_family(cf_name, 'blob') } + end it "should return a blob" do bytes = "binary\x00" @@ -102,20 +106,22 @@ def test_for_value(value) end end - context "with decimal validation" do - let(:cf_name) { "validation_cf_decimal" } - before(:each) { create_column_family(cf_name, 'decimal') } + if CASSANDRA_VERSION.to_f >= 1.0 + context "with decimal validation" do + let(:cf_name) { "validation_cf_decimal" } + before(:each) { create_column_family(cf_name, 'decimal') } - def test_for_value(value) - create_and_fetch_column(cf_name, value).should eq(value) - create_and_fetch_column(cf_name, value*-1).should eq(value*-1) - end - - it "should return a small decimal" do - test_for_value(15.333) - end - it "should return a huge decimal" do - test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) + def test_for_value(value) + create_and_fetch_column(cf_name, value).should eq(value) + create_and_fetch_column(cf_name, value*-1).should eq(value*-1) + end + + it "should return a small decimal" do + test_for_value(15.333) + end + it "should return a huge decimal" do + test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) + end end end @@ -195,7 +201,11 @@ def test_for_value(value) context "with timestamp validation" do let(:cf_name) { "validation_cf_timestamp" } - before(:each) { create_column_family(cf_name, 'timestamp') } + if CASSANDRA_VERSION.to_f == 0.8 + before(:each) { create_column_family(cf_name, 'date') } + else + before(:each) { create_column_family(cf_name, 'timestamp') } + end it "should return a timestamp" do ts = Time.new