Sha256: 4ad62e4a9895006d05d12ef73195314a7b11d00cd35c215f7c5f7b0c60b4a9a6

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

Feature: Safe mocking

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

  Scenario: Mocking methods that exist on real object
    Then spec file with following content should pass:
    """ruby
    describe Library do

      it "does something" do
        library = Library.new
        mock(library).checkout("some book") { :checked_out }

        library.checkout("some book").should == :checked_out
      end
    end
    """

  Scenario: Mocking methods that do not exist on real object
    Then spec file with following content should fail:
    """ruby
    describe Library do
      it "does something" do
        library = Library.new
        mock(library).buy("some book") { :bought }
        library.buy("some book")
      end
    end
    """

  Scenario: Mocking methods with wrong number of arguments
    Then spec file with following content should fail:
    """ruby
    describe Library do
      it "does something" do
        library = Library.new
        mock(library).checkout("some book", "another book") { :bought }
        library.checkout("some book", "another book")
      end
    end
    """

  Scenario: Mocks require the methods to be called
    Then spec file with following content should fail:
    """ruby
    describe Library do
      it "does something" do
        library = Library.new
        mock(library).checkout("some book") { :bought }
      end
    end
    """

Version data entries

2 entries across 2 versions & 1 rubygems

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