diff --git a/django_pyvows/assertions/models.py b/django_pyvows/assertions/models.py index da2db29..09ba856 100644 --- a/django_pyvows/assertions/models.py +++ b/django_pyvows/assertions/models.py @@ -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__ diff --git a/django_pyvows/version.py b/django_pyvows/version.py index 102eb4c..f063762 100644 --- a/django_pyvows/version.py +++ b/django_pyvows/version.py @@ -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) diff --git a/vows/model_vows.py b/vows/model_vows.py index 7d32b70..8f45377 100644 --- a/vows/model_vows.py +++ b/vows/model_vows.py @@ -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()