pose 1.3.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/README.md +11 -0
  2. data/Rakefile +4 -2
  3. data/app/models/pose/assignment.rb +34 -0
  4. data/app/models/pose/word.rb +24 -0
  5. data/db/migrate/20130308144915_pose_install.rb +18 -0
  6. data/lib/generators/pose/remove/templates/remove_migration.rb +3 -5
  7. data/lib/generators/pose/upgrade/templates/upgrade_migration.rb +9 -0
  8. data/lib/generators/pose/upgrade/upgrade_generator.rb +35 -0
  9. data/lib/pose/activerecord_base_additions.rb +5 -2
  10. data/lib/pose/engine.rb +5 -0
  11. data/lib/pose/internal_helpers.rb +13 -7
  12. data/lib/pose/{model_additions.rb → model_class_additions.rb} +8 -8
  13. data/lib/pose/railtie.rb +1 -2
  14. data/lib/pose/static_api.rb +5 -6
  15. data/lib/pose/version.rb +1 -1
  16. data/lib/pose.rb +5 -7
  17. data/lib/tasks/pose_tasks.rake +27 -29
  18. data/spec/dummy/Rakefile +7 -0
  19. data/spec/{support/models.rb → dummy/app/models/posable_one.rb} +1 -4
  20. data/spec/dummy/app/models/posable_two.rb +5 -0
  21. data/spec/dummy/config/application.rb +59 -0
  22. data/spec/dummy/config/boot.rb +10 -0
  23. data/spec/dummy/config/database.yml +25 -0
  24. data/spec/dummy/config/environment.rb +5 -0
  25. data/spec/dummy/config/environments/development.rb +37 -0
  26. data/spec/dummy/config/environments/production.rb +67 -0
  27. data/spec/dummy/config/environments/test.rb +37 -0
  28. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/spec/dummy/config/initializers/inflections.rb +15 -0
  30. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  31. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  32. data/spec/dummy/config/initializers/session_store.rb +8 -0
  33. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  34. data/spec/dummy/config/locales/en.yml +5 -0
  35. data/spec/dummy/config/routes.rb +2 -0
  36. data/spec/dummy/config.ru +4 -0
  37. data/spec/dummy/db/migrate/20130308054001_create_posable_one.rb +8 -0
  38. data/spec/dummy/db/migrate/20130308054142_create_posable_two.rb +9 -0
  39. data/spec/dummy/db/schema.rb +41 -0
  40. data/spec/dummy/script/rails +6 -0
  41. data/spec/factories/assignments.rb +8 -0
  42. data/spec/factories/posable_one.rb +5 -0
  43. data/spec/factories/words.rb +7 -0
  44. data/spec/internal_helpers_spec.rb +40 -42
  45. data/spec/models/assignment_spec.rb +46 -0
  46. data/spec/models/word_spec.rb +42 -0
  47. data/spec/pose_api_spec.rb +198 -196
  48. data/spec/spec_helper.rb +21 -77
  49. data/spec/support/matchers.rb +0 -1
  50. metadata +83 -102
  51. data/doc/Pose/InstanceMethods.html +0 -341
  52. data/doc/Pose.html +0 -774
  53. data/doc/PoseAssignment.html +0 -125
  54. data/doc/PoseGenerator.html +0 -255
  55. data/doc/PoseMigrations.html +0 -261
  56. data/doc/PoseWord.html +0 -125
  57. data/doc/_index.html +0 -134
  58. data/doc/class_list.html +0 -47
  59. data/doc/css/common.css +0 -1
  60. data/doc/css/full_list.css +0 -55
  61. data/doc/css/style.css +0 -322
  62. data/doc/file_list.html +0 -46
  63. data/doc/frames.html +0 -13
  64. data/doc/index.html +0 -134
  65. data/doc/js/app.js +0 -205
  66. data/doc/js/full_list.js +0 -167
  67. data/doc/js/jquery.js +0 -16
  68. data/doc/method_list.html +0 -150
  69. data/doc/top-level-namespace.html +0 -172
  70. data/lib/generators/pose/install/install_generator.rb +0 -56
  71. data/lib/generators/pose/install/templates/install_migration.rb +0 -24
  72. data/lib/pose/models/pose_assignment.rb +0 -31
  73. data/lib/pose/models/pose_word.rb +0 -28
  74. data/spec/factories.rb +0 -15
  75. data/spec/pose_assignment_spec.rb +0 -45
  76. data/spec/pose_word_spec.rb +0 -26
@@ -2,280 +2,282 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Pose do
6
- subject { PosableOne.new }
7
-
8
- describe 'associations' do
9
- it 'allows to access the associated words of a posable object directly' do
10
- subject.should have(0).pose_words
11
- subject.pose_words << PoseWord.new(text: 'one')
12
- subject.should have_pose_words 'one'
5
+ module Pose
6
+ describe Pose do
7
+ subject { PosableOne.new }
8
+
9
+ describe 'associations' do
10
+ it 'allows to access the associated words of a posable object directly' do
11
+ expect(subject).to have(0).pose_words
12
+ subject.pose_words << Word.new(text: 'one')
13
+ expect(subject).to have_pose_words 'one'
14
+ end
13
15
  end
14
- end
15
16
 
16
17
 
17
- describe '#update_pose_index' do
18
+ describe '#update_pose_index' do
18
19
 
19
- before :each do
20
- Pose::CONFIGURATION[:perform_search] = perform_search
21
- end
20
+ before :each do
21
+ Pose::CONFIGURATION[:perform_search] = perform_search
22
+ end
22
23
 
23
- after :each do
24
- Pose::CONFIGURATION.delete :perform_search
25
- end
24
+ after :each do
25
+ Pose::CONFIGURATION.delete :perform_search
26
+ end
26
27
 
27
- context "search_in_tests flag is not enabled" do
28
- let(:perform_search) { false }
28
+ context "search_in_tests flag is not enabled" do
29
+ let(:perform_search) { false }
29
30
 
30
- it "doesn't call update_pose_words" do
31
- subject.should_not_receive :update_pose_words
32
- subject.update_pose_index
31
+ it "doesn't call update_pose_words" do
32
+ subject.should_not_receive :update_pose_words
33
+ subject.update_pose_index
34
+ end
33
35
  end
34
- end
35
36
 
36
- context "search_in_tests flag is enabled" do
37
- let(:perform_search) { true }
37
+ context "search_in_tests flag is enabled" do
38
+ let(:perform_search) { true }
38
39
 
39
- it "calls update_pose_words" do
40
- subject.should_receive :update_pose_words
41
- subject.update_pose_index
40
+ it "calls update_pose_words" do
41
+ subject.should_receive :update_pose_words
42
+ subject.update_pose_index
43
+ end
42
44
  end
43
45
  end
44
- end
45
46
 
46
47
 
47
- describe '#update_pose_words' do
48
+ describe '#update_pose_words' do
48
49
 
49
- it 'saves the words for search' do
50
- subject.text = 'foo bar'
51
- subject.update_pose_words
52
- subject.should have_pose_words 'foo', 'bar'
53
- end
50
+ it 'saves the words for search' do
51
+ subject.text = 'foo bar'
52
+ subject.update_pose_words
53
+ expect(subject).to have_pose_words 'foo', 'bar'
54
+ end
54
55
 
55
- it 'updates the search index when the text is changed' do
56
- subject.text = 'foo'
57
- subject.save!
56
+ it 'updates the search index when the text is changed' do
57
+ subject.text = 'foo'
58
+ subject.save!
58
59
 
59
- subject.text = 'other text'
60
- subject.update_pose_words
60
+ subject.text = 'other text'
61
+ subject.update_pose_words
61
62
 
62
- subject.should have_pose_words 'other', 'text'
63
- end
63
+ expect(subject).to have_pose_words 'other', 'text'
64
+ end
64
65
 
65
- it "doesn't create duplicate words" do
66
- subject.text = 'foo foo'
67
- subject.save!
68
- subject.should have(1).pose_words
66
+ it "doesn't create duplicate words" do
67
+ subject.text = 'foo foo'
68
+ subject.save!
69
+ expect(subject).to have(1).pose_words
70
+ end
69
71
  end
70
- end
71
72
 
72
73
 
73
- describe 'search' do
74
+ describe 'search' do
74
75
 
75
- it 'works' do
76
- pos = PosableOne.create text: 'foo'
77
- result = Pose.search 'foo', PosableOne
78
- result.should == { PosableOne => [pos] }
79
- end
76
+ it 'works' do
77
+ pos = PosableOne.create text: 'foo'
78
+ result = Pose.search 'foo', PosableOne
79
+ expect(result).to eq({ PosableOne => [pos] })
80
+ end
80
81
 
81
- describe 'classes parameter' do
82
+ describe 'classes parameter' do
82
83
 
83
- before :each do
84
- @pos1 = PosableOne.create text: 'foo'
85
- @pos2 = PosableTwo.create text: 'foo'
86
- end
84
+ before :each do
85
+ @pos1 = PosableOne.create text: 'foo'
86
+ @pos2 = PosableTwo.create text: 'foo'
87
+ end
87
88
 
88
- it 'returns all requested classes' do
89
- result = Pose.search 'foo', [PosableOne, PosableTwo]
89
+ it 'returns all requested classes' do
90
+ result = Pose.search 'foo', [PosableOne, PosableTwo]
90
91
 
91
- result.keys.should have(2).items
92
- result.keys.should include PosableOne
93
- result.keys.should include PosableTwo
94
- end
92
+ expect(result.keys).to have(2).items
93
+ expect(result.keys).to include PosableOne
94
+ expect(result.keys).to include PosableTwo
95
+ end
95
96
 
96
- it 'returns all matching instances of each requested class' do
97
- result = Pose.search 'foo', [PosableOne, PosableTwo]
97
+ it 'returns all matching instances of each requested class' do
98
+ result = Pose.search 'foo', [PosableOne, PosableTwo]
98
99
 
99
- result[PosableOne].should == [@pos1]
100
- result[PosableTwo].should == [@pos2]
101
- end
100
+ expect(result[PosableOne]).to eq [@pos1]
101
+ expect(result[PosableTwo]).to eq [@pos2]
102
+ end
102
103
 
103
- it 'returns only instances of the given classes' do
104
- result = Pose.search 'foo', PosableOne
105
- result.keys.should include PosableOne
106
- result.keys.should_not include PosableTwo
104
+ it 'returns only instances of the given classes' do
105
+ result = Pose.search 'foo', PosableOne
106
+ expect(result.keys).to include PosableOne
107
+ result.keys.should_not include PosableTwo
108
+ end
107
109
  end
108
- end
109
110
 
110
- describe 'query parameter' do
111
+ describe 'query parameter' do
111
112
 
112
- it 'returns an empty array if nothing matches' do
113
- pos1 = PosableOne.create text: 'one'
114
- result = Pose.search 'two', PosableOne
115
- result[PosableOne].should be_empty
116
- end
113
+ it 'returns an empty array if nothing matches' do
114
+ pos1 = PosableOne.create text: 'one'
115
+ result = Pose.search 'two', PosableOne
116
+ expect(result[PosableOne]).to be_empty
117
+ end
117
118
 
118
- it 'returns only objects that match all given query words' do
119
- pos1 = PosableOne.create text: 'one two'
120
- pos2 = PosableOne.create text: 'one three'
121
- pos3 = PosableOne.create text: 'two three'
119
+ it 'returns only objects that match all given query words' do
120
+ pos1 = PosableOne.create text: 'one two'
121
+ pos2 = PosableOne.create text: 'one three'
122
+ pos3 = PosableOne.create text: 'two three'
122
123
 
123
- result = Pose.search 'two one', PosableOne
124
+ result = Pose.search 'two one', PosableOne
124
125
 
125
- result[PosableOne].should == [pos1]
126
- end
126
+ expect(result[PosableOne]).to eq [pos1]
127
+ end
127
128
 
128
- it 'returns nothing if searching for a non-existing word' do
129
- pos1 = PosableOne.create text: 'one two'
130
- result = Pose.search 'one zonk', PosableOne
131
- result[PosableOne].should be_empty
132
- end
129
+ it 'returns nothing if searching for a non-existing word' do
130
+ pos1 = PosableOne.create text: 'one two'
131
+ result = Pose.search 'one zonk', PosableOne
132
+ expect(result[PosableOne]).to be_empty
133
+ end
133
134
 
134
- it 'works if the query is given in uppercase' do
135
- pos1 = PosableOne.create text: 'one two'
136
- result = Pose.search 'OnE TwO', PosableOne
137
- result[PosableOne].should == [pos1]
135
+ it 'works if the query is given in uppercase' do
136
+ pos1 = PosableOne.create text: 'one two'
137
+ result = Pose.search 'OnE TwO', PosableOne
138
+ expect(result[PosableOne]).to eq [pos1]
139
+ end
138
140
  end
139
- end
140
141
 
141
142
 
142
- describe "'limit' parameter" do
143
+ describe "'limit' parameter" do
143
144
 
144
- before :each do
145
- @pos1 = FactoryGirl.create :posable_one, text: 'foo', private: true
146
- @pos2 = FactoryGirl.create :posable_one, text: 'foo', private: true
147
- @pos3 = FactoryGirl.create :posable_one, text: 'foo', private: false
148
- end
145
+ before :each do
146
+ @pos1 = FactoryGirl.create :posable_one, text: 'foo', private: true
147
+ @pos2 = FactoryGirl.create :posable_one, text: 'foo', private: true
148
+ @pos3 = FactoryGirl.create :posable_one, text: 'foo', private: false
149
+ end
149
150
 
150
- context 'with ids and no scope' do
151
- it 'limits the result set to the given number' do
152
- result = Pose.search 'foo', PosableOne, result_type: :ids, limit: 1
153
- result[PosableOne].should have(1).item
151
+ context 'with ids and no scope' do
152
+ it 'limits the result set to the given number' do
153
+ result = Pose.search 'foo', PosableOne, result_type: :ids, limit: 1
154
+ expect(result[PosableOne]).to have(1).item
155
+ end
154
156
  end
155
- end
156
157
 
157
- context 'with ids and scope' do
158
- it 'limits the result set to the given number' do
159
- result = Pose.search 'foo', PosableOne, result_type: :ids, limit: 1, where: [private: false]
160
- result[PosableOne].should have(1).item
158
+ context 'with ids and scope' do
159
+ it 'limits the result set to the given number' do
160
+ result = Pose.search 'foo', PosableOne, result_type: :ids, limit: 1, where: [private: false]
161
+ expect(result[PosableOne]).to have(1).item
162
+ end
161
163
  end
162
- end
163
164
 
164
- context 'with classes and no scope' do
165
- it 'limits the result set to the given number' do
166
- result = Pose.search 'foo', PosableOne, limit: 1
167
- result[PosableOne].should have(1).item
165
+ context 'with classes and no scope' do
166
+ it 'limits the result set to the given number' do
167
+ result = Pose.search 'foo', PosableOne, limit: 1
168
+ expect(result[PosableOne]).to have(1).item
169
+ end
168
170
  end
169
- end
170
171
 
171
- context 'with classes and scope' do
172
- it 'limits the result set to the given number' do
173
- result = Pose.search 'foo', PosableOne, limit: 1, where: [private: false]
174
- result[PosableOne].should have(1).item
172
+ context 'with classes and scope' do
173
+ it 'limits the result set to the given number' do
174
+ result = Pose.search 'foo', PosableOne, limit: 1, where: [private: false]
175
+ expect(result[PosableOne]).to have(1).item
176
+ end
175
177
  end
176
178
  end
177
- end
178
179
 
179
180
 
180
- describe "'result_type' parameter" do
181
-
182
- before :each do
183
- @foo_one = FactoryGirl.create :posable_one, text: 'foo one'
184
- end
181
+ describe "'result_type' parameter" do
185
182
 
186
- describe 'default behavior' do
187
- it 'returns full objects' do
188
- result = Pose.search 'foo', PosableOne
189
- result[PosableOne].first.should == @foo_one
183
+ before :each do
184
+ @foo_one = FactoryGirl.create :posable_one, text: 'foo one'
190
185
  end
191
- end
192
186
 
193
- context ':ids given' do
194
- it 'returns ids instead of objects' do
195
- result = Pose.search 'foo', PosableOne, result_type: :ids
196
- result[PosableOne].first.should == @foo_one.id
187
+ describe 'default behavior' do
188
+ it 'returns full objects' do
189
+ result = Pose.search 'foo', PosableOne
190
+ expect(result[PosableOne].first).to eq @foo_one
191
+ end
197
192
  end
198
- end
199
- end
200
-
201
-
202
- describe "'where' parameter" do
203
193
 
204
- before :each do
205
- @one = FactoryGirl.create :posable_one, text: 'foo one', private: true
206
- @bar = FactoryGirl.create :posable_one, text: 'bar one', private: true
207
- @two = FactoryGirl.create :posable_one, text: 'foo two', private: false
194
+ context ':ids given' do
195
+ it 'returns ids instead of objects' do
196
+ result = Pose.search 'foo', PosableOne, result_type: :ids
197
+ expect(result[PosableOne].first).to eq @foo_one.id
198
+ end
199
+ end
208
200
  end
209
201
 
210
- context 'with result type :classes' do
211
202
 
212
- it 'limits the result set by the given conditions' do
213
- result = Pose.search 'foo', PosableOne, where: [ private: true ]
214
- result[PosableOne].should have(1).item
215
- result[PosableOne].should include @one
216
- end
217
-
218
- it 'allows to use the hash syntax for queries' do
219
- result = Pose.search 'foo', PosableOne, where: [ private: true ]
220
- result[PosableOne].should have(1).item
221
- result[PosableOne].should include @one
222
- end
203
+ describe "'where' parameter" do
223
204
 
224
- it 'allows to use the string syntax for queries' do
225
- result = Pose.search 'foo', PosableOne, where: [ ['private = ?', true] ]
226
- result[PosableOne].should have(1).item
227
- result[PosableOne].should include @one
205
+ before :each do
206
+ @one = FactoryGirl.create :posable_one, text: 'foo one', private: true
207
+ @bar = FactoryGirl.create :posable_one, text: 'bar one', private: true
208
+ @two = FactoryGirl.create :posable_one, text: 'foo two', private: false
228
209
  end
229
210
 
230
- it 'allows to combine several conditions' do
231
- three = FactoryGirl.create :posable_one, text: 'foo two', private: true
232
- result = Pose.search 'foo', PosableOne, where: [ {private: true}, ['text = ?', 'foo two'] ]
233
- result[PosableOne].should have(1).item
234
- result[PosableOne].should include three
211
+ context 'with result type :classes' do
212
+
213
+ it 'limits the result set by the given conditions' do
214
+ result = Pose.search 'foo', PosableOne, where: [ private: true ]
215
+ expect(result[PosableOne]).to have(1).item
216
+ expect(result[PosableOne]).to include @one
217
+ end
218
+
219
+ it 'allows to use the hash syntax for queries' do
220
+ result = Pose.search 'foo', PosableOne, where: [ private: true ]
221
+ expect(result[PosableOne]).to have(1).item
222
+ expect(result[PosableOne]).to include @one
223
+ end
224
+
225
+ it 'allows to use the string syntax for queries' do
226
+ result = Pose.search 'foo', PosableOne, where: [ ['private = ?', true] ]
227
+ expect(result[PosableOne]).to have(1).item
228
+ expect(result[PosableOne]).to include @one
229
+ end
230
+
231
+ it 'allows to combine several conditions' do
232
+ three = FactoryGirl.create :posable_one, text: 'foo two', private: true
233
+ result = Pose.search 'foo', PosableOne, where: [ {private: true}, ['text = ?', 'foo two'] ]
234
+ expect(result[PosableOne]).to have(1).item
235
+ expect(result[PosableOne]).to include three
236
+ end
235
237
  end
236
- end
237
238
 
238
- context 'with result type :ids' do
239
+ context 'with result type :ids' do
239
240
 
240
- it 'limits the result set by the given condition' do
241
- result = Pose.search 'foo', PosableOne, result_type: :ids, where: [ private: true ]
242
- result[PosableOne].should have(1).item
243
- result[PosableOne].should include @one.id
241
+ it 'limits the result set by the given condition' do
242
+ result = Pose.search 'foo', PosableOne, result_type: :ids, where: [ private: true ]
243
+ expect(result[PosableOne]).to have(1).item
244
+ expect(result[PosableOne]).to include @one.id
245
+ end
244
246
  end
245
247
  end
246
248
  end
247
- end
248
249
 
249
250
 
250
- describe 'autocomplete_words' do
251
+ describe 'autocomplete_words' do
251
252
 
252
- it 'returns words that start with the given phrase' do
253
- PosableOne.create text: 'great green pine tree'
253
+ it 'returns words that start with the given phrase' do
254
+ PosableOne.create text: 'great green pine tree'
254
255
 
255
- result = Pose.autocomplete_words 'gr'
256
+ result = Pose.autocomplete_words 'gr'
256
257
 
257
- result.should have(2).words
258
- result.should include 'great'
259
- result.should include 'green'
260
- end
258
+ expect(result).to have(2).words
259
+ expect(result).to include 'great'
260
+ expect(result).to include 'green'
261
+ end
261
262
 
262
- it 'returns words that match the given phrase exactly' do
263
- PoseWord.create text: 'cat'
264
- result = Pose.autocomplete_words 'cat'
265
- result.should == ['cat']
266
- end
263
+ it 'returns words that match the given phrase exactly' do
264
+ Word.create text: 'cat'
265
+ result = Pose.autocomplete_words 'cat'
266
+ expect(result).to eq ['cat']
267
+ end
267
268
 
268
- it 'stems the search query' do
269
- PosableOne.create text: 'car'
270
- result = Pose.autocomplete_words 'cars'
271
- result.should have(1).words
272
- result[0].should == 'car'
273
- end
269
+ it 'stems the search query' do
270
+ PosableOne.create text: 'car'
271
+ result = Pose.autocomplete_words 'cars'
272
+ expect(result).to have(1).words
273
+ expect(result[0]).to eq 'car'
274
+ end
274
275
 
275
- it 'returns nothing if the search query is empty' do
276
- PosableOne.create text: 'foo bar'
277
- result = Pose.autocomplete_words ''
278
- result.should be_empty
276
+ it 'returns nothing if the search query is empty' do
277
+ PosableOne.create text: 'foo bar'
278
+ result = Pose.autocomplete_words ''
279
+ expect(result).to be_empty
280
+ end
279
281
  end
280
282
  end
281
283
  end
data/spec/spec_helper.rb CHANGED
@@ -1,95 +1,39 @@
1
- #require "rails/test_help"
2
- #require 'rspec/rails'
3
- require 'rubygems'
4
- require 'bundler/setup'
5
- require 'hashie'
6
- require 'active_record'
7
- require 'active_support/core_ext/module/aliasing'
8
- require 'active_support/core_ext/string'
9
- require 'pose'
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'factory_girl_rails'
10
7
  require 'faker'
11
- require 'factory_girl'
12
- require 'database_cleaner'
13
-
14
- FactoryGirl.find_definitions
15
-
16
- # Configure Rails Environment
17
- ENV["RAILS_ENV"] = "test"
18
- Rails = Hashie::Mash.new({env: 'test'})
19
-
20
- # We have no Railtie in these tests --> load Pose manually.
21
- ActiveRecord::Base.send :extend, Pose::ActiveRecordBaseAdditions
22
-
23
- # Load support files
24
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
25
8
 
9
+ # Requires supporting ruby files with custom matchers and macros, etc,
10
+ # in spec/support/ and its subdirectories.
11
+ Dir["#{File.dirname __FILE__}/support/**/*.rb"].each {|f| require f}
26
12
 
27
13
  RSpec.configure do |config|
28
- # == Mock Framework
14
+ # ## Mock Framework
29
15
  #
30
16
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
31
17
  #
32
18
  # config.mock_with :mocha
33
19
  # config.mock_with :flexmock
34
20
  # config.mock_with :rr
35
- config.mock_with :rspec
36
21
 
37
22
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
38
23
  # examples within a transaction, remove the following line or assign false
39
24
  # instead of true.
40
- # config.use_transactional_fixtures = true
41
-
42
- config.before :suite do
43
- setup_db
44
- DatabaseCleaner.strategy = :deletion
45
- end
46
-
47
- config.before :each do
48
- DatabaseCleaner.start
49
- end
50
-
51
- config.after :each do
52
- DatabaseCleaner.clean
53
- end
54
- end
55
-
56
-
57
- #####################
58
- # DATABASE SETUP
59
- #
60
-
61
- def setup_db
62
- ActiveRecord::Base.establish_connection adapter: 'postgresql',
63
- database: 'pose_test',
64
- min_messages: 'INFO'
65
-
66
- ActiveRecord::Schema.define(version: 1) do
67
- unless table_exists? 'posable_ones'
68
- create_table 'posable_ones' do |t|
69
- t.string 'text'
70
- t.boolean 'private'
71
- end
72
- end
25
+ config.use_transactional_fixtures = true
73
26
 
74
- unless table_exists? 'posable_twos'
75
- create_table 'posable_twos' do |t|
76
- t.string 'text'
77
- t.boolean 'private'
78
- end
79
- end
27
+ # If true, the base class of anonymous controllers will be inferred
28
+ # automatically. This will be the default behavior in future versions of
29
+ # rspec-rails.
30
+ config.infer_base_class_for_anonymous_controllers = false
80
31
 
81
- unless table_exists? 'pose_assignments'
82
- create_table "pose_assignments" do |t|
83
- t.integer "pose_word_id", null: false
84
- t.integer "posable_id", null: false
85
- t.string "posable_type", limit: 20, null: false
86
- end
87
- end
32
+ # Run specs in random order to surface order dependencies. If you find an
33
+ # order dependency and want to debug it, you can fix the order by providing
34
+ # the seed, which is printed after each run.
35
+ # --seed 1234
36
+ config.order = "random"
88
37
 
89
- unless table_exists? 'pose_words'
90
- create_table "pose_words" do |t|
91
- t.string "text", limit: 80, null: false
92
- end
93
- end
94
- end
38
+ config.include FactoryGirl::Syntax::Methods
95
39
  end
@@ -10,4 +10,3 @@ RSpec::Matchers.define :have_pose_words do |*expected|
10
10
  "expected that subject would have pose words [#{expected.join ', '}], but it has [#{texts.join ', '}]"
11
11
  end
12
12
  end
13
-