Possibility to use the assertions.Model instance in the to_have_field assertion.

This commit is contained in:
Rafael Caricio 2011-08-26 11:06:54 -03:00
parent 5816271f50
commit 3e3c0bd2ac
3 changed files with 7 additions and 1 deletions

View file

@ -23,6 +23,9 @@ class Model(object):
def to_have_field(topic, field_name, field_class=None, **kwargs):
from django.db import models
if isinstance(topic, Model):
topic = topic.model
if isinstance(topic, models.Model):
topic = topic.__class__

View file

@ -8,4 +8,4 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 Rafael Caricio rafael@caricio.com
__version__ = (0, 3, 5)
__version__ = (0, 3, 6)

View file

@ -32,6 +32,9 @@ class ModelVows(DjangoContext):
'name': 'something'
})
def should_be_possible_to_use_the_assertion_in_model_instance(self, topic):
expect(topic).to_have_field('name')
def should_have_a_method_to_call(self, topic):
expect(hasattr(topic, '__call__')).to_be_true()