From 3e3c0bd2acca7dc7fcb2536a216943b9cee9be5b Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Fri, 26 Aug 2011 11:06:54 -0300 Subject: [PATCH] Possibility to use the assertions.Model instance in the to_have_field assertion. --- django_pyvows/assertions/models.py | 3 +++ django_pyvows/version.py | 2 +- vows/model_vows.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) 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()