Sha256: e01b875cf3d909614b6abee77dedebbd716e2d90456064afb3e8b95b47ecabe5

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

Bogus let's you stub methods on any object, not just fakes, which makes this feature usable even in scenarios when you don't follow the Inversion of Control Principle.

When you stub/mock a method in Bogus, it will automatically ensure that:

1. The method actually exists
2. It can take the number of arguments you passed

Those of you familiar with RR stubbing syntax, will fill right at home with Bogus:

    stub(object).method_name(*arguments) { return_value }

One key difference is for when you want to stub a method for any arguments:

    # RR syntax
    stub(object).method_name { return_value }

    # Bogus syntax
    stub(object).method_name(any_args) { return_value }

One other, quite important thing, is that Bogus does not erase the method signature when stubbing:

    class Library
      def self.checkout(book)
      end
    end

The following would be OK in RR:

    stub(Library).checkout { "foo" }
    Library.checkout("a", "b") # returns "foo"

But not in Bogus:

    stub(Library).checkout(any_args) { "foo" }
    Library.checkout("a", "b") # raises an error

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bogus-0.0.3.rc.2 features/safe_stubbing/readme.md
bogus-0.0.3.rc.1 features/safe_stubbing/readme.md