Sha256: 22138ed35f5886121f7b823a69ed84435c0574d9c92e0ea85fff8a46a359ad03

Contents?: true

Size: 1.06 KB

Versions: 10

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 feel 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

10 entries across 10 versions & 1 rubygems

Version Path
bogus-0.1.7 features/safe_stubbing/readme.md
bogus-0.1.6 features/safe_stubbing/readme.md
bogus-0.1.5 features/safe_stubbing/readme.md
bogus-0.1.4 features/safe_stubbing/readme.md
bogus-0.1.3 features/safe_stubbing/readme.md
bogus-0.1.2 features/safe_stubbing/readme.md
bogus-0.1.1 features/safe_stubbing/readme.md
bogus-0.1.0 features/safe_stubbing/readme.md
bogus-0.0.4 features/safe_stubbing/readme.md
bogus-0.0.3 features/safe_stubbing/readme.md