Coder Social home page Coder Social logo

describe's People

Contributors

groner avatar jeffh avatar mortonfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

groner

describe's Issues

Mocks should assert access counts.

Similar to RSpec's recieve counts:

my_mock.should_receive(:msg).once
my_mock.should_receive(:msg).exactly(n).times
my_mock.should_receive(:msg).at_least(:once)

# An exception is raised if the message is never received or is received only once.
my_mock.should_receive(:msg).at_least(:twice)

# An exception is raised if the message is received fewer than n times.
my_mock.should_receive(:msg).at_least(n).times

# An exception is raised if the message is received more than once
# (does not raise if message is never receieved).
my_mock.should_receive(:msg).at_most(:once)

# An exception is raised if the message is received more than twice
# (does not raise if message is never receieved).
my_mock.should_receive(:msg).at_most(:twice)

# An exception is raised if the message is received more than n times
# (does not raise if message is never receieved).
my_mock.should_receive(:msg).at_most(n).times

#Explicitly Imprecise Counts
my_mock.should_receive(:msg).any_number_of_times

A direct mapping in describe seems the most intuitive.

Mock method invocation ordering.

See the RSpec ordering calls.

Example RSpec code:

my_mock.should_receive(:flip).once.ordered
my_mock.should_receive(:flop).once.ordered

flip should be called before flop.

Only methods marked with order should be concerned with order:

my_mock.should_receive(:zero)
my_mock.should_receive(:one).ordered
my_mock.should_receive(:two).ordered
my_mock.should_receive(:one_and_a_half)

# This will pass:
my_mock.one
my_mock.one_and_a_half
my_mock.zero
my_mock.two

This seems to still be the most intuitive method. Perhaps an optional argument to explicitly specify the order.

It does not explain how to run it

I have define a class with several mehotds, so now Im trying to execute it from the command line (terminal) but I can't find anywhere in your documentation how to run this.

Mocks should be able to yield multiple values.

From RSpec's section on yielding:

my_mock.should_receive(:msg).once.and_yield(<value-1>, <value-2>, ..., <value-n>)

When the expected message is received, the mock will yield the values to the passed block.

To mock a method which yields values multiple times, and_yield can be chained.

my_mock.should_receive(:msg).once.and_yield(<value-0-1>, <value-0-2>, ..., <value-0-n>).
                                  and_yield(<value-1-1>, <value-1-2>, ..., <value-1-n>).
                                  and_yield(<value-2-1>, <value-2-2>, ..., <value-2-n>)

For python we should accept one of a view things:

  • a list of return values (like rspec's and_yield)
  • a list of functions that returns an iterable or generator
mock.should_access.foo().and_yield(1,2,3)

# or
def generation():
    [1,2,3]
mock.should_access.foo().and_generate(generation)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.