Module: Veneer::Lint::Adapter::InstanceWrapperLint

Defined in:
lib/veneer/lint/adapter.rb

Instance Method Summary collapse

Instance Method Details

#test_should_implement_count_with_argumentsObject



215
216
217
218
219
220
221
# File 'lib/veneer/lint/adapter.rb', line 215

def test_should_implement_count_with_arguments
  create_valid_items(3)
  Veneer(@klass).create(@valid_attributes)
  assert_equal 1, Veneer(@klass).count(:conditions => @valid_attributes)
ensure
  _veneer_teardown
end

#test_should_implement_count_without_argumentsObject

Aggregations



208
209
210
211
212
213
# File 'lib/veneer/lint/adapter.rb', line 208

def test_should_implement_count_without_arguments
  create_valid_items(3)
  assert_equal 3, Veneer(@klass).count
ensure
  _veneer_teardown
end

#test_should_implement_destroyObject



178
179
180
181
182
183
184
185
186
# File 'lib/veneer/lint/adapter.rb', line 178

def test_should_implement_destroy
  item = Veneer(@klass).create(@valid_attributes)
  assert Veneer(@klass).all.size > 0
  assert item.kind_of?(Veneer::Base::InstanceWrapper)
  item.destroy
  assert Veneer(@klass).all.size == 0
ensure
  _veneer_teardown
end

#test_should_implement_max_with_argumentsObject



270
271
272
273
274
275
276
277
278
# File 'lib/veneer/lint/adapter.rb', line 270

def test_should_implement_max_with_arguments
  create_valid_items(3)
  attrs = @valid_attributes.merge(:integer_field => 99999)
  Veneer(@klass).create(attrs)
  results = Veneer(@klass).all(:conditions => attrs)
  assert_equal 99999, Veneer(@klass).max(:integer_field)
ensure
  _veneer_teardown
end

#test_should_implement_max_without_argumentsObject



261
262
263
264
265
266
267
268
# File 'lib/veneer/lint/adapter.rb', line 261

def test_should_implement_max_without_arguments
  create_valid_items(3)
  Veneer(@klass).create(@valid_attributes.merge(:integer_field => 99999))
  results = Veneer(@klass).all
  assert_equal 99999, Veneer(@klass).max(:integer_field)
ensure
  _veneer_teardown
end

#test_should_implement_min_with_argumentsObject



251
252
253
254
255
256
257
258
259
# File 'lib/veneer/lint/adapter.rb', line 251

def test_should_implement_min_with_arguments
  create_valid_items(3)
  attrs = @valid_attributes.merge(:integer_field => -5)
  Veneer(@klass).create(attrs)
  results = Veneer(@klass).all(:conditions => attrs)
  assert_equal(-5, Veneer(@klass).min(:integer_field))
ensure
  _veneer_teardown
end

#test_should_implement_min_without_argumentsObject



242
243
244
245
246
247
248
249
# File 'lib/veneer/lint/adapter.rb', line 242

def test_should_implement_min_without_arguments
  create_valid_items(3)
  Veneer(@klass).create(@valid_attributes.merge(:integer_field => -5))
  results = Veneer(@klass).all
  assert_equal(-5, Veneer(@klass).min(:integer_field))
ensure
  _veneer_teardown
end

#test_should_implement_new_record?Boolean

Returns:

  • (Boolean)


188
189
190
191
192
193
194
195
# File 'lib/veneer/lint/adapter.rb', line 188

def test_should_implement_new_record?
  item = Veneer(@klass).new(@valid_attributes)
  assert item.new_record?
  assert item.save
  assert !item.new_record?
ensure
  _veneer_teardown
end

#test_should_implement_save!Object



197
198
199
200
201
# File 'lib/veneer/lint/adapter.rb', line 197

def test_should_implement_save!
  assert_raises Veneer::Errors::NotSaved do
    Veneer(@klass).create!(@invalid_attributes)
  end
end

#test_should_implement_sum_with_argumentsObject



232
233
234
235
236
237
238
239
240
# File 'lib/veneer/lint/adapter.rb', line 232

def test_should_implement_sum_with_arguments
  create_valid_items(3)
  Veneer(@klass).create(@valid_attributes)
  results = Veneer(@klass).all(:conditions => @valid_attributes)
  results.inject(0){ |sum, i| (i.send(:integer_field) ||0) + sum }
  assert_equal 1, Veneer(@klass).sum(:integer_field, :conditions => @valid_attributes)
ensure
  _veneer_teardown
end

#test_should_implement_sum_without_argumentsObject



223
224
225
226
227
228
229
230
# File 'lib/veneer/lint/adapter.rb', line 223

def test_should_implement_sum_without_arguments
  create_valid_items(3)
  results = Veneer(@klass).all
  results.inject(0){ |sum, i| (i.send(:integer_field) ||0) + sum }
  assert_equal 3, Veneer(@klass).sum(:integer_field)
ensure
  _veneer_teardown
end

#test_should_list_model_classesObject



203
204
205
# File 'lib/veneer/lint/adapter.rb', line 203

def test_should_list_model_classes
  assert Veneer.model_classes.size > 0
end