diff --git a/.travis.yml b/.travis.yml index 070206d..43be365 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ install: - pip install coveralls - pip install -r requirements.txt python: - - "2.6" - "2.7" - "3.5" - "3.6" diff --git a/robber/expect.py b/robber/expect.py index bb36ff8..72370c7 100644 --- a/robber/expect.py +++ b/robber/expect.py @@ -24,6 +24,9 @@ def __init__(self, obj): self.not_to_flag = False self.__setup_chaining() + def __repr__(self): + return str(isinstance(self, expect)) + @classmethod def fail_with(cls, message): cls.message = message diff --git a/robber/matchers/base.py b/robber/matchers/base.py index 35141b7..ea545db 100644 --- a/robber/matchers/base.py +++ b/robber/matchers/base.py @@ -1,4 +1,5 @@ from robber.bad_expectation import BadExpectation +from robber.expect import expect class Base: @@ -23,7 +24,7 @@ def fail_with(self, message): def match(self): if self.matches() is not self.is_negative: - return True + return expect(self.actual) message = self.message or self.explanation.message raise BadExpectation(message) diff --git a/tests/matchers/test_base.py b/tests/matchers/test_base.py index d62a760..81d7e0f 100644 --- a/tests/matchers/test_base.py +++ b/tests/matchers/test_base.py @@ -9,8 +9,8 @@ class TestBase(unittest.TestCase): def test_it_stores_actual_and_expected(self): base = Base('actual', 'expected') - expect(base.actual) == 'actual' - expect(base.expected) == 'expected' + expect(base.actual).to.eq('actual') + expect(base.expected).to.eq('expected') def test_it_calls_matches(self): matcher = TestWillMatch('actual', 'expected') @@ -36,4 +36,4 @@ def test_negative_message(self): def test_match(self): matcher = TestWillMatch('actual', 'expected') - expect(matcher.match()).to.eq(True) + expect(matcher.match()).to.eq('actual') diff --git a/tests/test_expect.py b/tests/test_expect.py index c344026..a2a4072 100644 --- a/tests/test_expect.py +++ b/tests/test_expect.py @@ -44,6 +44,9 @@ def test_chaining(self): expectation = expect(object) expect(expectation.to).to.equal(expectation.to.be) + def test_chaining_readme(self): + expect(1 + 1).to.be.an.integer().to.be.within(1, 3) + def test_multiple_not_to_success(self): expect(1).eq(1) expect(1).not_to.not_to.eq(1) diff --git a/tox.ini b/tox.ini index 8e4d296..3c0e669 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,7 @@ [tox] -envlist = py26,py27,py34,py35,py36 +envlist = py27,py34,py35,py36 [testenv] basepython = - py26: python2.6 py27: python2.7 py34: python3.4 py35: python3.5