cequel 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +19 -12
- data/Rakefile +5 -1
- data/lib/cequel/record/data_set_builder.rb +9 -2
- data/lib/cequel/record/record_set.rb +16 -2
- data/lib/cequel/record/tasks.rb +6 -2
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/metal/data_set_spec.rb +113 -106
- data/spec/examples/metal/keyspace_spec.rb +7 -15
- data/spec/examples/record/associations_spec.rb +30 -30
- data/spec/examples/record/callbacks_spec.rb +25 -25
- data/spec/examples/record/dirty_spec.rb +11 -10
- data/spec/examples/record/list_spec.rb +33 -33
- data/spec/examples/record/map_spec.rb +57 -41
- data/spec/examples/record/mass_assignment_spec.rb +5 -5
- data/spec/examples/record/naming_spec.rb +2 -2
- data/spec/examples/record/persistence_spec.rb +23 -23
- data/spec/examples/record/properties_spec.rb +19 -19
- data/spec/examples/record/record_set_spec.rb +155 -151
- data/spec/examples/record/schema_spec.rb +7 -7
- data/spec/examples/record/scoped_spec.rb +2 -2
- data/spec/examples/record/serialization_spec.rb +2 -2
- data/spec/examples/record/set_spec.rb +27 -23
- data/spec/examples/record/validations_spec.rb +13 -13
- data/spec/examples/schema/table_reader_spec.rb +85 -79
- data/spec/examples/schema/table_synchronizer_spec.rb +9 -9
- data/spec/examples/schema/table_updater_spec.rb +17 -17
- data/spec/examples/schema/table_writer_spec.rb +33 -33
- data/spec/examples/type_spec.rb +55 -55
- data/spec/support/helpers.rb +18 -10
- metadata +18 -5
- data/spec/shared/readable_dictionary.rb +0 -192
@@ -21,7 +21,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
21
21
|
after { cequel.schema.drop_table(:posts) }
|
22
22
|
|
23
23
|
it 'should create table' do
|
24
|
-
table.column(:title).type.
|
24
|
+
expect(table.column(:title).type).to eq(Cequel::Type[:text]) #etc.
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -58,35 +58,35 @@ describe Cequel::Schema::TableSynchronizer do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should rename keys' do
|
61
|
-
table.clustering_columns.first.name.
|
61
|
+
expect(table.clustering_columns.first.name).to eq(:post_permalink)
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should add new columns' do
|
65
|
-
table.column(:published_at).type.
|
65
|
+
expect(table.column(:published_at).type).to eq(Cequel::Type[:timestamp])
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should add new collections' do
|
69
|
-
table.column(:categories).
|
69
|
+
expect(table.column(:categories)).to be_a(Cequel::Schema::List)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'should add new column with index' do
|
73
|
-
table.column(:primary_author_id).
|
73
|
+
expect(table.column(:primary_author_id)).to be_indexed
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should add index to existing columns' do
|
77
|
-
table.column(:created_at).
|
77
|
+
expect(table.column(:created_at)).to be_indexed
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'should drop index from existing columns' do
|
81
|
-
table.column(:title).
|
81
|
+
expect(table.column(:title)).not_to be_indexed
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should change column type' do
|
85
|
-
table.column(:body).type.
|
85
|
+
expect(table.column(:body).type).to eq(Cequel::Type[:text])
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should change properties' do
|
89
|
-
table.property(:comment).
|
89
|
+
expect(table.property(:comment)).to eq('Test Table 2.0')
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
@@ -23,7 +23,7 @@ describe Cequel::Schema::TableUpdater do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should add the column with the given type' do
|
26
|
-
table.data_column(:published_at).type.
|
26
|
+
expect(table.data_column(:published_at).type).to eq(Cequel::Type[:timestamp])
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -35,11 +35,11 @@ describe Cequel::Schema::TableUpdater do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should add the list' do
|
38
|
-
table.data_column(:author_names).
|
38
|
+
expect(table.data_column(:author_names)).to be_a(Cequel::Schema::List)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should set the given type' do
|
42
|
-
table.data_column(:author_names).type.
|
42
|
+
expect(table.data_column(:author_names).type).to eq(Cequel::Type[:text])
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -51,11 +51,11 @@ describe Cequel::Schema::TableUpdater do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should add the list' do
|
54
|
-
table.data_column(:author_names).
|
54
|
+
expect(table.data_column(:author_names)).to be_a(Cequel::Schema::Set)
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should set the given type' do
|
58
|
-
table.data_column(:author_names).type.
|
58
|
+
expect(table.data_column(:author_names).type).to eq(Cequel::Type[:text])
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -67,17 +67,17 @@ describe Cequel::Schema::TableUpdater do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should add the list' do
|
70
|
-
table.data_column(:trackbacks).
|
70
|
+
expect(table.data_column(:trackbacks)).to be_a(Cequel::Schema::Map)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should set the key type' do
|
74
|
-
table.data_column(:trackbacks).key_type.
|
75
|
-
|
74
|
+
expect(table.data_column(:trackbacks).key_type).
|
75
|
+
to eq(Cequel::Type[:timestamp])
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'should set the value type' do
|
79
|
-
table.data_column(:trackbacks).value_type.
|
80
|
-
|
79
|
+
expect(table.data_column(:trackbacks).value_type).
|
80
|
+
to eq(Cequel::Type[:ascii])
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -89,7 +89,7 @@ describe Cequel::Schema::TableUpdater do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should change the type' do
|
92
|
-
table.data_column(:title).type.
|
92
|
+
expect(table.data_column(:title).type).to eq(Cequel::Type[:text])
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -101,8 +101,8 @@ describe Cequel::Schema::TableUpdater do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should change the name' do
|
104
|
-
table.clustering_column(:slug).
|
105
|
-
table.clustering_column(:permalink).
|
104
|
+
expect(table.clustering_column(:slug)).to be
|
105
|
+
expect(table.clustering_column(:permalink)).to be_nil
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -114,7 +114,7 @@ describe Cequel::Schema::TableUpdater do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'should change properties' do
|
117
|
-
table.properties[:comment].value.
|
117
|
+
expect(table.properties[:comment].value).to eq('Test Comment')
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -126,7 +126,7 @@ describe Cequel::Schema::TableUpdater do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'should add the index' do
|
129
|
-
table.data_column(:title).
|
129
|
+
expect(table.data_column(:title)).to be_indexed
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -139,7 +139,7 @@ describe Cequel::Schema::TableUpdater do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it 'should drop the index' do
|
142
|
-
table.data_column(:title).
|
142
|
+
expect(table.data_column(:title)).not_to be_indexed
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
@@ -152,7 +152,7 @@ describe Cequel::Schema::TableUpdater do
|
|
152
152
|
end
|
153
153
|
|
154
154
|
it 'should remove the column' do
|
155
|
-
table.data_column(:body).
|
155
|
+
expect(table.data_column(:body)).to be_nil
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -20,16 +20,16 @@ describe Cequel::Schema::TableWriter do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should create key alias' do
|
23
|
-
table.partition_key_columns.map(&:name).
|
23
|
+
expect(table.partition_key_columns.map(&:name)).to eq([:permalink])
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should set key validator' do
|
27
|
-
table.partition_key_columns.map(&:type).
|
27
|
+
expect(table.partition_key_columns.map(&:type)).to eq([Cequel::Type[:ascii]])
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should set non-key columns' do
|
31
|
-
table.columns.find { |column| column.name == :title }.type.
|
32
|
-
|
31
|
+
expect(table.columns.find { |column| column.name == :title }.type).
|
32
|
+
to eq(Cequel::Type[:text])
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -43,19 +43,19 @@ describe Cequel::Schema::TableWriter do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should create key alias' do
|
46
|
-
table.partition_key_columns.map(&:name).
|
46
|
+
expect(table.partition_key_columns.map(&:name)).to eq([:blog_subdomain])
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should set key validator' do
|
50
|
-
table.partition_key_columns.map(&:type).
|
50
|
+
expect(table.partition_key_columns.map(&:type)).to eq([Cequel::Type[:ascii]])
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should create non-partition key components' do
|
54
|
-
table.clustering_columns.map(&:name).
|
54
|
+
expect(table.clustering_columns.map(&:name)).to eq([:permalink])
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should set type for non-partition key components' do
|
58
|
-
table.clustering_columns.map(&:type).
|
58
|
+
expect(table.clustering_columns.map(&:type)).to eq([Cequel::Type[:ascii]])
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -69,12 +69,12 @@ describe Cequel::Schema::TableWriter do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should create all partition key components' do
|
72
|
-
table.partition_key_columns.map(&:name).
|
72
|
+
expect(table.partition_key_columns.map(&:name)).to eq([:blog_subdomain, :permalink])
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should set key validators' do
|
76
|
-
table.partition_key_columns.map(&:type).
|
77
|
-
|
76
|
+
expect(table.partition_key_columns.map(&:type)).
|
77
|
+
to eq([Cequel::Type[:ascii], Cequel::Type[:ascii]])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -89,21 +89,21 @@ describe Cequel::Schema::TableWriter do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should create all partition key components' do
|
92
|
-
table.partition_key_columns.map(&:name).
|
93
|
-
|
92
|
+
expect(table.partition_key_columns.map(&:name)).
|
93
|
+
to eq([:blog_subdomain, :permalink])
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'should set key validators' do
|
97
|
-
table.partition_key_columns.map(&:type).
|
98
|
-
|
97
|
+
expect(table.partition_key_columns.map(&:type)).
|
98
|
+
to eq([Cequel::Type[:ascii], Cequel::Type[:ascii]])
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should create non-partition key components' do
|
102
|
-
table.clustering_columns.map(&:name).
|
102
|
+
expect(table.clustering_columns.map(&:name)).to eq([:month])
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'should set type for non-partition key components' do
|
106
|
-
table.clustering_columns.map(&:type).
|
106
|
+
expect(table.clustering_columns.map(&:type)).to eq([Cequel::Type[:timestamp]])
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -119,33 +119,33 @@ describe Cequel::Schema::TableWriter do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'should create list' do
|
122
|
-
table.data_column(:authors).
|
122
|
+
expect(table.data_column(:authors)).to be_a(Cequel::Schema::List)
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'should set correct type for list' do
|
126
|
-
table.data_column(:authors).type.
|
126
|
+
expect(table.data_column(:authors).type).to eq(Cequel::Type[:blob])
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'should create set' do
|
130
|
-
table.data_column(:tags).
|
130
|
+
expect(table.data_column(:tags)).to be_a(Cequel::Schema::Set)
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'should set correct type for set' do
|
134
|
-
table.data_column(:tags).type.
|
134
|
+
expect(table.data_column(:tags).type).to eq(Cequel::Type[:text])
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'should create map' do
|
138
|
-
table.data_column(:trackbacks).
|
138
|
+
expect(table.data_column(:trackbacks)).to be_a(Cequel::Schema::Map)
|
139
139
|
end
|
140
140
|
|
141
141
|
it 'should set correct key type' do
|
142
|
-
table.data_column(:trackbacks).key_type.
|
143
|
-
|
142
|
+
expect(table.data_column(:trackbacks).key_type).
|
143
|
+
to eq(Cequel::Type[:timestamp])
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'should set correct value type' do
|
147
|
-
table.data_column(:trackbacks).value_type.
|
148
|
-
|
147
|
+
expect(table.data_column(:trackbacks).value_type).
|
148
|
+
to eq(Cequel::Type[:ascii])
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -162,14 +162,14 @@ describe Cequel::Schema::TableWriter do
|
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'should set simple properties' do
|
165
|
-
table.property(:comment).
|
165
|
+
expect(table.property(:comment)).to eq('Blog posts')
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'should set map collection properties' do
|
169
|
-
table.property(:compression).
|
169
|
+
expect(table.property(:compression)).to eq({
|
170
170
|
:sstable_compression => 'DeflateCompressor',
|
171
171
|
:chunk_length_kb => 64
|
172
|
-
}
|
172
|
+
})
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -183,7 +183,7 @@ describe Cequel::Schema::TableWriter do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
it 'should have compact storage' do
|
186
|
-
table.
|
186
|
+
expect(table).to be_compact_storage
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
@@ -197,7 +197,7 @@ describe Cequel::Schema::TableWriter do
|
|
197
197
|
end
|
198
198
|
|
199
199
|
it 'should set clustering order' do
|
200
|
-
table.clustering_columns.map(&:clustering_order).
|
200
|
+
expect(table.clustering_columns.map(&:clustering_order)).to eq([:desc])
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
@@ -208,7 +208,7 @@ describe Cequel::Schema::TableWriter do
|
|
208
208
|
key :id, :uuid, :desc
|
209
209
|
column :title, :text, :index => true
|
210
210
|
end
|
211
|
-
table.data_column(:title).
|
211
|
+
expect(table.data_column(:title)).to be_indexed
|
212
212
|
end
|
213
213
|
|
214
214
|
it 'should create indices with specified name' do
|
@@ -217,7 +217,7 @@ describe Cequel::Schema::TableWriter do
|
|
217
217
|
key :id, :uuid, :desc
|
218
218
|
column :title, :text, :index => :silly_idx
|
219
219
|
end
|
220
|
-
table.data_column(:title).index_name.
|
220
|
+
expect(table.data_column(:title).index_name).to eq(:silly_idx)
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
data/spec/examples/type_spec.rb
CHANGED
@@ -10,8 +10,8 @@ describe Cequel::Type do
|
|
10
10
|
should == 'org.apache.cassandra.db.marshal.AsciiType' }
|
11
11
|
|
12
12
|
describe '#cast' do
|
13
|
-
specify { subject.cast('hey'.encode('UTF-8')).encoding.name.
|
14
|
-
|
13
|
+
specify { expect(subject.cast('hey'.encode('UTF-8')).encoding.name).
|
14
|
+
to eq('US-ASCII') }
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -22,9 +22,9 @@ describe Cequel::Type do
|
|
22
22
|
should == 'org.apache.cassandra.db.marshal.BytesType' }
|
23
23
|
|
24
24
|
describe '#cast' do
|
25
|
-
specify { subject.cast(123).
|
26
|
-
specify { subject.cast(123).encoding.name.
|
27
|
-
specify { subject.cast('2345').encoding.name.
|
25
|
+
specify { expect(subject.cast(123)).to eq(123.to_s(16)) }
|
26
|
+
specify { expect(subject.cast(123).encoding.name).to eq('ASCII-8BIT') }
|
27
|
+
specify { expect(subject.cast('2345').encoding.name).to eq('ASCII-8BIT') }
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -35,9 +35,9 @@ describe Cequel::Type do
|
|
35
35
|
should == 'org.apache.cassandra.db.marshal.BooleanType' }
|
36
36
|
|
37
37
|
describe '#cast' do
|
38
|
-
specify { subject.cast(true).
|
39
|
-
specify { subject.cast(false).
|
40
|
-
specify { subject.cast(1).
|
38
|
+
specify { expect(subject.cast(true)).to eq(true) }
|
39
|
+
specify { expect(subject.cast(false)).to eq(false) }
|
40
|
+
specify { expect(subject.cast(1)).to eq(true) }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -48,8 +48,8 @@ describe Cequel::Type do
|
|
48
48
|
should == 'org.apache.cassandra.db.marshal.CounterColumnType' }
|
49
49
|
|
50
50
|
describe '#cast' do
|
51
|
-
specify { subject.cast(1).
|
52
|
-
specify { subject.cast('1').
|
51
|
+
specify { expect(subject.cast(1)).to eq(1) }
|
52
|
+
specify { expect(subject.cast('1')).to eq(1) }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -60,10 +60,10 @@ describe Cequel::Type do
|
|
60
60
|
should == 'org.apache.cassandra.db.marshal.DecimalType' }
|
61
61
|
|
62
62
|
describe '#cast' do
|
63
|
-
specify { subject.cast(1).
|
64
|
-
specify { subject.cast(1.0).
|
65
|
-
specify { subject.cast(1.0.to_r).
|
66
|
-
specify { subject.cast('1').
|
63
|
+
specify { expect(subject.cast(1)).to eql(BigDecimal.new('1.0')) }
|
64
|
+
specify { expect(subject.cast(1.0)).to eql(BigDecimal.new('1.0')) }
|
65
|
+
specify { expect(subject.cast(1.0.to_r)).to eql(BigDecimal.new('1.0')) }
|
66
|
+
specify { expect(subject.cast('1')).to eql(BigDecimal.new('1.0')) }
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -74,11 +74,11 @@ describe Cequel::Type do
|
|
74
74
|
should == 'org.apache.cassandra.db.marshal.DoubleType' }
|
75
75
|
|
76
76
|
describe '#cast' do
|
77
|
-
specify { subject.cast(1.0).
|
78
|
-
specify { subject.cast(1).
|
79
|
-
specify { subject.cast(1.0.to_r).
|
80
|
-
specify { subject.cast('1.0').
|
81
|
-
specify { subject.cast(BigDecimal.new('1.0')).
|
77
|
+
specify { expect(subject.cast(1.0)).to eql(1.0) }
|
78
|
+
specify { expect(subject.cast(1)).to eql(1.0) }
|
79
|
+
specify { expect(subject.cast(1.0.to_r)).to eql(1.0) }
|
80
|
+
specify { expect(subject.cast('1.0')).to eql(1.0) }
|
81
|
+
specify { expect(subject.cast(BigDecimal.new('1.0'))).to eql(1.0) }
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -89,11 +89,11 @@ describe Cequel::Type do
|
|
89
89
|
should == 'org.apache.cassandra.db.marshal.FloatType' }
|
90
90
|
|
91
91
|
describe '#cast' do
|
92
|
-
specify { subject.cast(1.0).
|
93
|
-
specify { subject.cast(1).
|
94
|
-
specify { subject.cast(1.0.to_r).
|
95
|
-
specify { subject.cast('1.0').
|
96
|
-
specify { subject.cast(BigDecimal.new('1.0')).
|
92
|
+
specify { expect(subject.cast(1.0)).to eql(1.0) }
|
93
|
+
specify { expect(subject.cast(1)).to eql(1.0) }
|
94
|
+
specify { expect(subject.cast(1.0.to_r)).to eql(1.0) }
|
95
|
+
specify { expect(subject.cast('1.0')).to eql(1.0) }
|
96
|
+
specify { expect(subject.cast(BigDecimal.new('1.0'))).to eql(1.0) }
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -111,11 +111,11 @@ describe Cequel::Type do
|
|
111
111
|
should == 'org.apache.cassandra.db.marshal.Int32Type' }
|
112
112
|
|
113
113
|
describe '#cast' do
|
114
|
-
specify { subject.cast(1).
|
115
|
-
specify { subject.cast('1').
|
116
|
-
specify { subject.cast(1.0).
|
117
|
-
specify { subject.cast(1.0.to_r).
|
118
|
-
specify { subject.cast(BigDecimal.new('1.0')).
|
114
|
+
specify { expect(subject.cast(1)).to eql(1) }
|
115
|
+
specify { expect(subject.cast('1')).to eql(1) }
|
116
|
+
specify { expect(subject.cast(1.0)).to eql(1) }
|
117
|
+
specify { expect(subject.cast(1.0.to_r)).to eql(1) }
|
118
|
+
specify { expect(subject.cast(BigDecimal.new('1.0'))).to eql(1) }
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -126,11 +126,11 @@ describe Cequel::Type do
|
|
126
126
|
should == 'org.apache.cassandra.db.marshal.LongType' }
|
127
127
|
|
128
128
|
describe '#cast' do
|
129
|
-
specify { subject.cast(1).
|
130
|
-
specify { subject.cast('1').
|
131
|
-
specify { subject.cast(1.0).
|
132
|
-
specify { subject.cast(1.0.to_r).
|
133
|
-
specify { subject.cast(BigDecimal.new('1.0')).
|
129
|
+
specify { expect(subject.cast(1)).to eql(1) }
|
130
|
+
specify { expect(subject.cast('1')).to eql(1) }
|
131
|
+
specify { expect(subject.cast(1.0)).to eql(1) }
|
132
|
+
specify { expect(subject.cast(1.0.to_r)).to eql(1) }
|
133
|
+
specify { expect(subject.cast(BigDecimal.new('1.0'))).to eql(1) }
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -138,14 +138,14 @@ describe Cequel::Type do
|
|
138
138
|
subject { Cequel::Type[:text] }
|
139
139
|
its(:cql_name) { should == :text }
|
140
140
|
its(:internal_name) { should == 'org.apache.cassandra.db.marshal.UTF8Type' }
|
141
|
-
it {
|
141
|
+
it { is_expected.to eq(Cequel::Type[:varchar]) }
|
142
142
|
|
143
143
|
describe '#cast' do
|
144
|
-
specify { subject.cast('cql').
|
145
|
-
specify { subject.cast(1).
|
146
|
-
specify { subject.cast('cql').encoding.name.
|
147
|
-
specify { subject.cast('cql'.force_encoding('US-ASCII')).
|
148
|
-
encoding.name.
|
144
|
+
specify { expect(subject.cast('cql')).to eq('cql') }
|
145
|
+
specify { expect(subject.cast(1)).to eq('1') }
|
146
|
+
specify { expect(subject.cast('cql').encoding.name).to eq('UTF-8') }
|
147
|
+
specify { expect(subject.cast('cql'.force_encoding('US-ASCII')).
|
148
|
+
encoding.name).to eq('UTF-8') }
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -156,11 +156,11 @@ describe Cequel::Type do
|
|
156
156
|
|
157
157
|
describe '#cast' do
|
158
158
|
let(:now) { Time.at(Time.now.to_i) }
|
159
|
-
specify { subject.cast(now).
|
160
|
-
specify { subject.cast(now.to_i).
|
161
|
-
specify { subject.cast(now.to_s).
|
162
|
-
specify { subject.cast(now.to_datetime).
|
163
|
-
specify { subject.cast(now.to_date).
|
159
|
+
specify { expect(subject.cast(now)).to eq(now) }
|
160
|
+
specify { expect(subject.cast(now.to_i)).to eq(now) }
|
161
|
+
specify { expect(subject.cast(now.to_s)).to eq(now) }
|
162
|
+
specify { expect(subject.cast(now.to_datetime)).to eq(now) }
|
163
|
+
specify { expect(subject.cast(now.to_date)).to eq(now.to_date.to_time) }
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -179,12 +179,12 @@ describe Cequel::Type do
|
|
179
179
|
|
180
180
|
describe '#cast' do
|
181
181
|
let(:uuid) { Cequel.uuid }
|
182
|
-
specify { subject.cast(uuid).
|
183
|
-
specify { subject.cast(uuid.to_s).
|
184
|
-
specify { subject.cast(uuid.value).
|
182
|
+
specify { expect(subject.cast(uuid)).to eq(uuid) }
|
183
|
+
specify { expect(subject.cast(uuid.to_s)).to eq(uuid) }
|
184
|
+
specify { expect(subject.cast(uuid.value)).to eq(uuid) }
|
185
185
|
if defined? SimpleUUID::UUID
|
186
|
-
specify { subject.cast(SimpleUUID::UUID.new(uuid.value))
|
187
|
-
.
|
186
|
+
specify { expect(subject.cast(SimpleUUID::UUID.new(uuid.value)))
|
187
|
+
.to eq(uuid) }
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
@@ -196,11 +196,11 @@ describe Cequel::Type do
|
|
196
196
|
should == 'org.apache.cassandra.db.marshal.IntegerType' }
|
197
197
|
|
198
198
|
describe '#cast' do
|
199
|
-
specify { subject.cast(1).
|
200
|
-
specify { subject.cast('1').
|
201
|
-
specify { subject.cast(1.0).
|
202
|
-
specify { subject.cast(1.0.to_r).
|
203
|
-
specify { subject.cast(BigDecimal.new('1.0')).
|
199
|
+
specify { expect(subject.cast(1)).to eql(1) }
|
200
|
+
specify { expect(subject.cast('1')).to eql(1) }
|
201
|
+
specify { expect(subject.cast(1.0)).to eql(1) }
|
202
|
+
specify { expect(subject.cast(1.0.to_r)).to eql(1) }
|
203
|
+
specify { expect(subject.cast(BigDecimal.new('1.0'))).to eql(1) }
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|