Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created October 19, 2016 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/ca673b3ce18460890cfd18e09bb1657c to your computer and use it in GitHub Desktop.
Save tenderlove/ca673b3ce18460890cfd18e09bb1657c to your computer and use it in GitHub Desktop.
module ExecutionMethods
def curry_one x
curry[x].extend ExecutionMethods
end
alias :to :curry_one
alias :on_event :curry_one
alias :on :curry_one
end
class Execution < Proc
include ExecutionMethods
end
class Expectation < Proc
alias :to :call
end
def expect object
Expectation.new do |exec|
exec.call object
end
end
def transition_from from
Execution.new do |to, event, on, thing|
p [from, to, event, on, thing]
end
end
multiple = Object.new
expect(multiple).to transition_from(:standing).to(:walking).on_event(:walk).on(:move)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment