datastax_rails 2.0.12 → 2.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -5
  3. data/lib/blankslate.rb +8 -11
  4. data/lib/cql-rb_extensions.rb +5 -3
  5. data/lib/datastax_rails/associations/association.rb +93 -101
  6. data/lib/datastax_rails/associations/association_scope.rb +7 -7
  7. data/lib/datastax_rails/associations/belongs_to_association.rb +46 -48
  8. data/lib/datastax_rails/associations/builder/association.rb +32 -31
  9. data/lib/datastax_rails/associations/builder/belongs_to.rb +19 -20
  10. data/lib/datastax_rails/associations/builder/collection_association.rb +32 -32
  11. data/lib/datastax_rails/associations/builder/has_and_belongs_to_many.rb +21 -21
  12. data/lib/datastax_rails/associations/builder/has_many.rb +39 -40
  13. data/lib/datastax_rails/associations/builder/has_one.rb +30 -31
  14. data/lib/datastax_rails/associations/builder/singular_association.rb +31 -33
  15. data/lib/datastax_rails/associations/collection_association.rb +129 -135
  16. data/lib/datastax_rails/associations/collection_proxy.rb +21 -21
  17. data/lib/datastax_rails/associations/has_and_belongs_to_many_association.rb +26 -26
  18. data/lib/datastax_rails/associations/has_many_association.rb +38 -38
  19. data/lib/datastax_rails/associations/has_one_association.rb +31 -32
  20. data/lib/datastax_rails/associations/singular_association.rb +31 -30
  21. data/lib/datastax_rails/associations.rb +27 -24
  22. data/lib/datastax_rails/attribute_assignment.rb +17 -17
  23. data/lib/datastax_rails/attribute_methods/definition.rb +4 -4
  24. data/lib/datastax_rails/attribute_methods/dirty.rb +34 -33
  25. data/lib/datastax_rails/attribute_methods/primary_key.rb +3 -8
  26. data/lib/datastax_rails/attribute_methods/read.rb +10 -12
  27. data/lib/datastax_rails/attribute_methods/typecasting.rb +36 -35
  28. data/lib/datastax_rails/attribute_methods/write.rb +5 -6
  29. data/lib/datastax_rails/attribute_methods.rb +52 -56
  30. data/lib/datastax_rails/base.rb +122 -125
  31. data/lib/datastax_rails/callbacks.rb +15 -9
  32. data/lib/datastax_rails/cassandra_only_model.rb +6 -6
  33. data/lib/datastax_rails/collection.rb +5 -7
  34. data/lib/datastax_rails/column.rb +130 -118
  35. data/lib/datastax_rails/connection/statement_cache.rb +3 -3
  36. data/lib/datastax_rails/connection.rb +42 -33
  37. data/lib/datastax_rails/cql/alter_column_family.rb +19 -21
  38. data/lib/datastax_rails/cql/base.rb +8 -11
  39. data/lib/datastax_rails/cql/column_family.rb +11 -10
  40. data/lib/datastax_rails/cql/consistency.rb +2 -2
  41. data/lib/datastax_rails/cql/create_column_family.rb +15 -15
  42. data/lib/datastax_rails/cql/create_index.rb +5 -5
  43. data/lib/datastax_rails/cql/create_keyspace.rb +7 -7
  44. data/lib/datastax_rails/cql/delete.rb +16 -29
  45. data/lib/datastax_rails/cql/drop_column_family.rb +2 -2
  46. data/lib/datastax_rails/cql/drop_index.rb +2 -2
  47. data/lib/datastax_rails/cql/drop_keyspace.rb +2 -2
  48. data/lib/datastax_rails/cql/insert.rb +10 -16
  49. data/lib/datastax_rails/cql/select.rb +21 -33
  50. data/lib/datastax_rails/cql/truncate.rb +2 -2
  51. data/lib/datastax_rails/cql/update.rb +16 -24
  52. data/lib/datastax_rails/cql/use_keyspace.rb +2 -2
  53. data/lib/datastax_rails/cql.rb +2 -2
  54. data/lib/datastax_rails/dynamic_model.rb +32 -29
  55. data/lib/datastax_rails/errors.rb +6 -6
  56. data/lib/datastax_rails/grouped_collection.rb +3 -3
  57. data/lib/datastax_rails/inheritance.rb +9 -9
  58. data/lib/datastax_rails/payload_model.rb +24 -20
  59. data/lib/datastax_rails/persistence.rb +116 -110
  60. data/lib/datastax_rails/railtie.rb +7 -7
  61. data/lib/datastax_rails/reflection.rb +61 -59
  62. data/lib/datastax_rails/relation/batches.rb +12 -13
  63. data/lib/datastax_rails/relation/facet_methods.rb +44 -33
  64. data/lib/datastax_rails/relation/finder_methods.rb +95 -91
  65. data/lib/datastax_rails/relation/modification_methods.rb +5 -5
  66. data/lib/datastax_rails/relation/search_methods.rb +102 -102
  67. data/lib/datastax_rails/relation/spawn_methods.rb +25 -24
  68. data/lib/datastax_rails/relation/stats_methods.rb +9 -8
  69. data/lib/datastax_rails/relation.rb +165 -170
  70. data/lib/datastax_rails/rsolr_client_wrapper.rb +3 -3
  71. data/lib/datastax_rails/schema/cassandra.rb +44 -43
  72. data/lib/datastax_rails/schema/migrator.rb +52 -52
  73. data/lib/datastax_rails/schema/solr.rb +55 -47
  74. data/lib/datastax_rails/schema_cache.rb +1 -3
  75. data/lib/datastax_rails/scoping/default.rb +2 -3
  76. data/lib/datastax_rails/scoping/named.rb +3 -5
  77. data/lib/datastax_rails/scoping.rb +11 -12
  78. data/lib/datastax_rails/serialization.rb +34 -31
  79. data/lib/datastax_rails/serializers/xml_serializer.rb +178 -175
  80. data/lib/datastax_rails/timestamps.rb +4 -4
  81. data/lib/datastax_rails/types/dirty_collection.rb +57 -57
  82. data/lib/datastax_rails/types/dynamic_list.rb +1 -1
  83. data/lib/datastax_rails/types/dynamic_map.rb +5 -7
  84. data/lib/datastax_rails/types/dynamic_set.rb +2 -2
  85. data/lib/datastax_rails/util/solr_repair.rb +3 -3
  86. data/lib/datastax_rails/validations/associated.rb +8 -6
  87. data/lib/datastax_rails/validations/uniqueness.rb +8 -8
  88. data/lib/datastax_rails/validations.rb +9 -10
  89. data/lib/datastax_rails/version.rb +2 -1
  90. data/lib/datastax_rails/wide_storage_model.rb +6 -6
  91. data/lib/datastax_rails.rb +13 -9
  92. data/lib/schema_migration.rb +3 -3
  93. data/spec/datastax_rails/associations/belongs_to_association_spec.rb +2 -2
  94. data/spec/datastax_rails/associations/collection_association_spec.rb +14 -14
  95. data/spec/datastax_rails/associations/has_many_association_spec.rb +20 -20
  96. data/spec/datastax_rails/associations_spec.rb +11 -11
  97. data/spec/datastax_rails/attribute_methods_spec.rb +25 -25
  98. data/spec/datastax_rails/base_spec.rb +24 -24
  99. data/spec/datastax_rails/callbacks_spec.rb +21 -21
  100. data/spec/datastax_rails/column_spec.rb +133 -132
  101. data/spec/datastax_rails/connection/statement_cache_spec.rb +2 -2
  102. data/spec/datastax_rails/cql/base_spec.rb +4 -4
  103. data/spec/datastax_rails/cql/delete_spec.rb +19 -0
  104. data/spec/datastax_rails/cql/select_spec.rb +8 -8
  105. data/spec/datastax_rails/cql/update_spec.rb +8 -10
  106. data/spec/datastax_rails/dynamic_model_spec.rb +36 -22
  107. data/spec/datastax_rails/inheritance_spec.rb +11 -14
  108. data/spec/datastax_rails/persistence_spec.rb +73 -74
  109. data/spec/datastax_rails/relation/batches_spec.rb +13 -13
  110. data/spec/datastax_rails/relation/facet_methods_spec.rb +43 -35
  111. data/spec/datastax_rails/relation/finder_methods_spec.rb +77 -78
  112. data/spec/datastax_rails/relation/modification_methods_spec.rb +19 -19
  113. data/spec/datastax_rails/relation/search_methods_spec.rb +160 -160
  114. data/spec/datastax_rails/relation/spawn_methods_spec.rb +18 -18
  115. data/spec/datastax_rails/relation_spec.rb +119 -116
  116. data/spec/datastax_rails/schema/migrator_spec.rb +30 -30
  117. data/spec/datastax_rails/schema/solr_spec.rb +15 -15
  118. data/spec/datastax_rails/scoping/default_spec.rb +9 -9
  119. data/spec/datastax_rails/types/dynamic_list_spec.rb +12 -12
  120. data/spec/datastax_rails/types/dynamic_map_spec.rb +10 -10
  121. data/spec/datastax_rails/types/dynamic_set_spec.rb +22 -10
  122. data/spec/datastax_rails/validations/uniqueness_spec.rb +25 -25
  123. data/spec/datastax_rails/wide_storage_model_spec.rb +11 -0
  124. data/spec/datastax_rails_spec.rb +2 -2
  125. data/spec/dummy/config/application.rb +2 -3
  126. data/spec/dummy/config/boot.rb +1 -1
  127. data/spec/dummy/config/environments/development.rb +3 -3
  128. data/spec/dummy/config/environments/test.rb +1 -1
  129. data/spec/dummy/config/initializers/session_store.rb +1 -1
  130. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
  131. data/spec/factories/audit_logs.rb +6 -0
  132. data/spec/factories/hobbies.rb +6 -0
  133. data/spec/factories/people.rb +5 -0
  134. data/spec/feature/dynamic_fields_spec.rb +4 -4
  135. data/spec/feature/overloaded_tables_spec.rb +11 -12
  136. data/spec/spec_helper.rb +17 -14
  137. data/spec/support/datastax_test_hook.rb +2 -2
  138. data/spec/support/default_consistency_shared_examples.rb +11 -11
  139. data/spec/support/models.rb +31 -32
  140. metadata +40 -6
  141. data/lib/datastax_rails/attribute_methods/before_type_cast.rb +0 -71
  142. data/lib/datastax_rails/log_subscriber.rb +0 -0
  143. data/spec/dummy/ks/migrate/20111117224534_models.rb +0 -20
@@ -2,27 +2,27 @@ require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Relation do
4
4
  before(:each) do
5
- @relation = DatastaxRails::Relation.new(Hobby, "hobbies")
5
+ @relation = DatastaxRails::Relation.new(Hobby, 'hobbies')
6
6
  end
7
-
8
- describe "#merge" do
9
- it "should merge two relations" do
10
- r1 = @relation.where("name" => "biking")
11
- r2 = @relation.order("name" => :desc)
12
- r1.merge(r2).should == @relation.where("name" => "biking").order("name" => :desc)
7
+
8
+ describe '#merge' do
9
+ it 'should merge two relations' do
10
+ r1 = @relation.where('name' => 'biking')
11
+ r2 = @relation.order('name' => :desc)
12
+ expect(r1.merge(r2)).to eq(@relation.where('name' => 'biking').order('name' => :desc))
13
13
  end
14
-
15
- it "should merge where conditions into a single hash" do
16
- r1 = @relation.where("name" => "biking")
17
- r2 = @relation.where("complexity" => 1.0)
18
- r1.merge(r2).where_values.should == [{"name" => "biking", "complexity" => 1.0}]
14
+
15
+ it 'should merge where conditions into a single hash' do
16
+ r1 = @relation.where('name' => 'biking')
17
+ r2 = @relation.where('complexity' => 1.0)
18
+ expect(r1.merge(r2).where_values).to eq([{ 'name' => 'biking', 'complexity' => 1.0 }])
19
19
  end
20
-
21
- it "should overwrite conditions on the same attribute" do
22
- r1 = @relation.where("name" => "biking")
23
- r2 = @relation.where("name" => "swimming")
24
- r1.merge(r2).where_values.should == [{"name" => "swimming"}]
25
- r2.merge(r1).where_values.should == [{"name" => "biking"}]
20
+
21
+ it 'should overwrite conditions on the same attribute' do
22
+ r1 = @relation.where('name' => 'biking')
23
+ r2 = @relation.where('name' => 'swimming')
24
+ expect(r1.merge(r2).where_values).to eq([{ 'name' => 'swimming' }])
25
+ expect(r2.merge(r1).where_values).to eq([{ 'name' => 'biking' }])
26
26
  end
27
27
  end
28
28
  end
@@ -2,175 +2,178 @@ require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Relation do
4
4
  before(:each) do
5
- @relation = DatastaxRails::Relation.new(Hobby, "hobbies")
5
+ @relation = DatastaxRails::Relation.new(Hobby, 'hobbies')
6
6
  @relation.default_scoped = true
7
7
  @relation.commit_solr
8
8
  end
9
-
10
- describe "#==" do
11
- it "should count two relations with the same parameters as equal" do
12
- @relation.where("name" => "jason").should == @relation.where("name" => "jason")
9
+
10
+ describe '#==' do
11
+ it 'should count two relations with the same parameters as equal' do
12
+ expect(@relation.where('name' => 'jason')).to eq(@relation.where('name' => 'jason'))
13
13
  end
14
14
  end
15
-
16
- describe "#any?" do
17
- it "should return true if there are records" do
18
- Hobby.create(:name => "fishing")
15
+
16
+ describe '#any?' do
17
+ it 'should return true if there are records' do
18
+ Hobby.create(name: 'fishing')
19
19
  @relation.commit_solr
20
- @relation.any?.should be_true
20
+ expect(@relation.any?).to be_truthy
21
21
  end
22
-
23
- it "should return false if there are no records" do
24
- @relation.any?.should be_false
22
+
23
+ it 'should return false if there are no records' do
24
+ expect(@relation.any?).to be_falsey
25
25
  end
26
26
  end
27
-
28
- describe "#count" do
29
- it "should use the cached count if it is available" do
27
+
28
+ describe '#count' do
29
+ it 'should use the cached count if it is available' do
30
30
  @relation.instance_variable_set(:@count, 42)
31
- @relation.count.should == 42
31
+ expect(@relation.count).to eq(42)
32
32
  end
33
-
34
- it "should cache the total count on any solr query" do
33
+
34
+ it 'should cache the total count on any solr query' do
35
35
  @relation = @relation.with_solr
36
- @relation.should_receive(:query_via_solr).and_return(double("ResultSet", :total_entries => 42))
36
+ expect(@relation).to receive(:query_via_solr).and_return(double('ResultSet', total_entries: 42))
37
37
  @relation.all
38
- @relation.count.should == 42
38
+ expect(@relation.count).to eq(42)
39
39
  end
40
-
41
- it "should execute a fast search to determine the count" do
40
+
41
+ it 'should execute a fast search to determine the count' do
42
42
  mock_relation = double(DatastaxRails::Relation)
43
- mock_relation.stub_chain(:select, :to_a, :total_entries).and_return(37)
43
+ allow(mock_relation).to receive_message_chain(:select, :to_a, :total_entries).and_return(37)
44
44
  @relation = @relation.with_solr
45
- @relation.should_receive(:limit).with(1).and_return(mock_relation)
46
- @relation.count.should == 37
47
- end
48
-
49
- it "should return the count regardless of limit" do
50
- Hobby.create(:name => "hiking")
51
- Hobby.create(:name => "boxing")
52
- Hobby.create(:name => "fishing")
53
- Hobby.create(:name => "running")
45
+ expect(@relation).to receive(:limit).with(1).and_return(mock_relation)
46
+ expect(@relation.count).to eq(37)
47
+ end
48
+
49
+ it 'should return the count regardless of limit' do
50
+ Hobby.create(name: 'hiking')
51
+ Hobby.create(name: 'boxing')
52
+ Hobby.create(name: 'fishing')
53
+ Hobby.create(name: 'running')
54
54
  @relation.commit_solr
55
- @relation.count.should == 4
56
-
57
- @relation.limit(2).count.should == 4
55
+ expect(@relation.count).to eq(4)
56
+
57
+ expect(@relation.limit(2).count).to eq(4)
58
58
  end
59
59
  end
60
-
61
- describe "#default_scope" do
62
- it "should return a relation that has no scope set" do
63
- Hobby.create(:name => "fishing")
60
+
61
+ describe '#default_scope' do
62
+ it 'should return a relation that has no scope set' do
63
+ Hobby.create(name: 'fishing')
64
64
  @relation.commit_solr
65
- relation = @relation.where("name" => "hiking")
66
- relation.count.should == 0
67
- relation.default_scope.count.should == 1
65
+ relation = @relation.where('name' => 'hiking')
66
+ expect(relation.count).to eq(0)
67
+ expect(relation.default_scope.count).to eq(1)
68
68
  end
69
-
70
- it "should return a relation that has a default scope set" do
71
- relation = DatastaxRails::Relation.new(Boat, "boats")
69
+
70
+ it 'should return a relation that has a default scope set' do
71
+ relation = DatastaxRails::Relation.new(Boat, 'boats')
72
72
  relation.default_scoped = true
73
- relation.default_scope.order_values.should_not be_empty
73
+ expect(relation.default_scope.order_values).not_to be_empty
74
74
  end
75
75
  end
76
-
77
- describe "#empty?" do
78
- it "should use the loaded result set to determine emptiness" do
79
- a_record = mock_model(Hobby)
80
- @relation.stub(:loaded? => true)
76
+
77
+ describe '#empty?' do
78
+ it 'should use the loaded result set to determine emptiness' do
79
+ a_record = build_stubbed(:hobby)
80
+ allow(@relation).to receive(:loaded?).and_return(true)
81
81
  @relation.instance_variable_set(:@results, [])
82
- @relation.should be_empty
82
+ expect(@relation).to be_empty
83
83
  @relation.instance_variable_set(:@results, [a_record])
84
- @relation.should_not be_empty
84
+ expect(@relation).not_to be_empty
85
85
  end
86
86
  end
87
-
88
- describe "#many?" do
89
- it "should return true if there are multiple records matching" do
90
- Hobby.create(:name => "hiking")
91
- Hobby.create(:name => "swimming")
87
+
88
+ describe '#many?' do
89
+ it 'should return true if there are multiple records matching' do
90
+ Hobby.create(name: 'hiking')
91
+ Hobby.create(name: 'swimming')
92
92
  @relation.commit_solr
93
- @relation.should be_many
93
+ expect(@relation).to be_many
94
94
  end
95
-
96
- it "should return false if there are zero or one records matching" do
97
- @relation.should_not be_many
98
- Hobby.create(:name => "hiking")
99
- @relation.should_not be_many
95
+
96
+ it 'should return false if there are zero or one records matching' do
97
+ expect(@relation).not_to be_many
98
+ Hobby.create(name: 'hiking')
99
+ expect(@relation).not_to be_many
100
100
  end
101
101
  end
102
-
103
- describe "#new" do
104
- it "should instantiate a new instance of the class" do
105
- hiking = @relation.new(:name => "hiking")
106
- hiking.should be_a_kind_of(Hobby)
107
- hiking.name.should == "hiking"
102
+
103
+ describe '#new' do
104
+ it 'should instantiate a new instance of the class' do
105
+ hiking = @relation.new(name: 'hiking')
106
+ expect(hiking).to be_a_kind_of(Hobby)
107
+ expect(hiking.name).to eq('hiking')
108
108
  end
109
109
  end
110
-
111
- describe "#reload" do
112
- it "should reload the results" do
113
- @relation.all.should be_empty
114
- Hobby.create(:name => "hiking")
110
+
111
+ describe '#reload' do
112
+ it 'should reload the results' do
113
+ expect(@relation.all).to be_empty
114
+ Hobby.create(name: 'hiking')
115
115
  @relation.commit_solr
116
- @relation.all.should be_empty
117
- @relation.reload.all.should_not be_empty
116
+ expect(@relation.all).to be_empty
117
+ expect(@relation.reload.all).not_to be_empty
118
118
  end
119
119
  end
120
-
121
- describe "#size" do
122
- it "should return the size of the current result set (including limit setting)" do
123
- Hobby.create(:name => "hiking")
124
- Hobby.create(:name => "boxing")
125
- Hobby.create(:name => "fishing")
126
- Hobby.create(:name => "running")
120
+
121
+ describe '#size' do
122
+ it 'should return the size of the current result set (including limit setting)' do
123
+ Hobby.create(name: 'hiking')
124
+ Hobby.create(name: 'boxing')
125
+ Hobby.create(name: 'fishing')
126
+ Hobby.create(name: 'running')
127
127
  @relation.commit_solr
128
- @relation.size.should == 4
129
- @relation.limit(2).size.should == 2
128
+ expect(@relation.size).to eq(4)
129
+ expect(@relation.limit(2).size).to eq(2)
130
130
  end
131
131
  end
132
-
133
- describe "#total_pages" do
134
- it "should calculate the total number of pages for will_paginate" do
132
+
133
+ describe '#total_pages' do
134
+ it 'should calculate the total number of pages for will_paginate' do
135
135
  relation = @relation.per_page(30)
136
- relation.stub(:count => 100)
137
- relation.total_pages.should == 4
136
+ allow(relation).to receive(:count).and_return(100)
137
+ expect(relation.total_pages).to eq(4)
138
138
  end
139
139
  end
140
-
141
- describe "grouped queries" do
140
+
141
+ describe 'grouped queries' do
142
142
  before(:each) do
143
143
  Person.commit_solr
144
- Person.create(:name => 'John', :nickname => 'J')
145
- Person.create(:name => 'Jason', :nickname => 'J')
146
- Person.create(:name => 'James', :nickname => 'J')
147
- Person.create(:name => 'Kathrine', :nickname => 'Kat')
148
- Person.create(:name => 'Kathy', :nickname => 'Kat')
149
- Person.create(:name => 'Steven', :nickname => 'Steve')
144
+ Person.create(name: 'John', nickname: 'J')
145
+ Person.create(name: 'Jason', nickname: 'J')
146
+ Person.create(name: 'James', nickname: 'J')
147
+ Person.create(name: 'Kathrine', nickname: 'Kat')
148
+ Person.create(name: 'Kathy', nickname: 'Kat')
149
+ Person.create(name: 'Steven', nickname: 'Steve')
150
150
  Person.commit_solr
151
151
  end
152
-
153
- it "should return matching documents grouped by an attribute" do
152
+
153
+ it 'should return matching documents grouped by an attribute' do
154
154
  results = Person.group(:nickname).all
155
- results['j'].should have(3).items
156
- results['kat'].should have(2).items
157
- results['steve'].should have(1).item
155
+ expect(results['j'].size).to eq(3)
156
+ expect(results['kat'].size).to eq(2)
157
+ expect(results['steve'].size).to eq(1)
158
158
  end
159
-
160
- it "should return total_entries as the highest value of any group" do
159
+
160
+ it 'should return total_entries as the highest value of any group' do
161
161
  results = Person.group(:nickname).all
162
- results.total_entries.should eq(3)
162
+ expect(results.total_entries).to eq(3)
163
163
  end
164
-
165
- it "should still return a total count when using the count method" do
166
- results = Person.group(:nickname).count.should eq(6)
164
+
165
+ it 'should still return a total count when using the count method' do
166
+ expect(Person.group(:nickname).count).to eq(6)
167
167
  end
168
168
  end
169
-
170
- describe "#downcase_query" do
171
- it "downcases a solr query while leaving operators untouched" do
172
- solr_query = "This Query needs to be DOWNCASED AND it also searches DATES [2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] OR maybe it just breaks"
173
- expect(@relation.downcase_query(solr_query)).to eq("this query needs to be downcased AND it also searches dates [2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] OR maybe it just breaks")
169
+
170
+ describe '#downcase_query' do
171
+ it 'downcases a solr query while leaving operators untouched' do
172
+ solr_query = 'This Query needs to be DOWNCASED AND it also searches DATES ' \
173
+ '[2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] OR maybe it just breaks'
174
+ expect(@relation.downcase_query(solr_query)).to eq('this query needs to be downcased AND it also searches ' \
175
+ 'dates [2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] ' \
176
+ 'OR maybe it just breaks')
174
177
  end
175
178
  end
176
179
  end
@@ -2,83 +2,83 @@ require 'spec_helper'
2
2
 
3
3
  describe DatastaxRails::Schema::Migrator do
4
4
  subject do
5
- DatastaxRails::Schema::Migrator.new('datastax_rails_test').tap{|m| m.verbose = false}
5
+ DatastaxRails::Schema::Migrator.new('datastax_rails_test').tap { |m| m.verbose = false }
6
6
  end
7
7
 
8
8
  describe 'payload models' do
9
9
  context 'when column family exists' do
10
10
  before(:each) do
11
- subject.stub(:column_family_exists?).and_return(false)
11
+ allow(subject).to receive(:column_family_exists?).and_return(false)
12
12
  end
13
-
14
- it "calls #create_payload_column_family" do
13
+
14
+ it 'calls #create_payload_column_family' do
15
15
  expect(subject).to receive(:create_cql3_column_family).with(CarPayload)
16
16
  subject.migrate_one(CarPayload)
17
17
  end
18
18
  end
19
-
19
+
20
20
  context 'when column family exists' do
21
21
  before(:each) do
22
- subject.stub(:column_family_exists?).and_return(true)
22
+ allow(subject).to receive(:column_family_exists?).and_return(true)
23
23
  end
24
-
25
- it "does not call #create_payload_column_family" do
24
+
25
+ it 'does not call #create_payload_column_family' do
26
26
  expect(subject).not_to receive(:create_cql2_column_family).with(CarPayload)
27
27
  subject.migrate_one(CarPayload)
28
28
  end
29
29
  end
30
30
  end
31
-
31
+
32
32
  describe 'wide storage models' do
33
33
  context 'when column family does not exist' do
34
34
  before(:each) do
35
- subject.stub(:column_family_exists?).and_return(false)
36
- subject.stub(:create_cql3_column_family)
35
+ allow(subject).to receive(:column_family_exists?).and_return(false)
36
+ allow(subject).to receive(:create_cql3_column_family)
37
37
  end
38
-
39
- it "calls #create_wide_storage_column_family" do
38
+
39
+ it 'calls #create_wide_storage_column_family' do
40
40
  expect(subject).to receive(:create_cql3_column_family).with(AuditLog)
41
41
  subject.migrate_one(AuditLog)
42
42
  end
43
-
44
- it "calls #check_missing_schema" do
43
+
44
+ it 'calls #check_missing_schema' do
45
45
  expect(subject).to receive(:check_missing_schema).with(AuditLog).and_return(0)
46
46
  subject.migrate_one(AuditLog)
47
47
  end
48
48
  end
49
-
49
+
50
50
  context 'when column family exists' do
51
51
  before(:each) do
52
- subject.stub(:column_family_exists?).and_return(true)
52
+ allow(subject).to receive(:column_family_exists?).and_return(true)
53
53
  end
54
-
55
- it "does not call #create_wide_storage_column_family" do
54
+
55
+ it 'does not call #create_wide_storage_column_family' do
56
56
  expect(subject).not_to receive(:create_cql3_column_family).with(AuditLog)
57
57
  subject.migrate_one(AuditLog)
58
58
  end
59
-
60
- it "calls #check_missing_schema" do
59
+
60
+ it 'calls #check_missing_schema' do
61
61
  expect(subject).to receive(:check_missing_schema).with(AuditLog).and_return(0)
62
62
  subject.migrate_one(AuditLog)
63
63
  end
64
64
  end
65
65
  end
66
-
67
- describe 'normal models' do
68
- it "calls #check_missing_schema" do
66
+
67
+ describe 'normal models' do
68
+ it 'calls #check_missing_schema' do
69
69
  expect(subject).to receive(:check_missing_schema).with(Person).and_return(0)
70
70
  subject.migrate_one(Person)
71
71
  end
72
-
73
- context "force mode on" do
74
- it "calls #upload_solr_configuation with force true" do
72
+
73
+ context 'force mode on' do
74
+ it 'calls #upload_solr_configuation with force true' do
75
75
  expect(subject).to receive(:upload_solr_configuration).with(Person, true).and_return(0)
76
76
  subject.migrate_one(Person, true)
77
77
  end
78
78
  end
79
-
80
- context "force mode off" do
81
- it "calls #upload_solr_configuation with force false" do
79
+
80
+ context 'force mode off' do
81
+ it 'calls #upload_solr_configuation with force false' do
82
82
  expect(subject).to receive(:upload_solr_configuration).with(Person, false).and_return(0)
83
83
  subject.migrate_one(Person, false)
84
84
  end