Sha256: 4ae0700b265478c9ead69631d72041d9eeacb0e230ffbb9ea4523c73d63ecff6

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

Feature: Contract tests with spies

  Background:
    Given a file named "foo.rb" with:
    """ruby
    class Library
      def checkout(book)
      end
    end

    class Student
      def read(book, library = Libarary.new)
        library.checkout(book)
        # ...
      end
    end
    """
    And a spec file named "student_spec.rb" with:
    """ruby
    describe Student do
      fake(:library)

      it "reads books from library" do
        student = Student.new

        student.read("Moby Dick", library)

        library.should have_received.checkout("Moby Dick")
      end
    end
    """

  Scenario: Stubbing methods that exist on real object
    Then spec file with following content should pass:
    """ruby
    describe Library do
      verify_contract(:library)

      it "checks out books" do
        library = Library.new

        library.checkout("Moby Dick")

        # ...
      end
    end
    """

  Scenario: Verifing that stubbed methods are tested
    Then spec file with following content should fail:
    """ruby
    describe Library do
      verify_contract(:library)

    end
    """

  Scenario: Verifying that methods are tested with right arguments
    Then spec file with following content should fail:
    """ruby
    describe Library do
      verify_contract(:library)

      it "checks out books" do
        library = Library.new

        library.checkout("Moby Dick 2: The ulitmate")

        # ...
      end
    end
    """

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bogus-0.0.2 features/contract_tests_spies.feature
bogus-0.0.1 features/contract_tests_spies.feature