Skip to content

Instantly share code, notes, and snippets.

@samflores
Created December 2, 2011 17:32
Show Gist options
  • Save samflores/1424100 to your computer and use it in GitHub Desktop.
Save samflores/1424100 to your computer and use it in GitHub Desktop.

Suppose I have a third party lib that uses a DSL to perform its magic like the dsl.rb and runtime.rb files below. My application has a Consumer class that uses that API as shown in the consumer.rb file. How should I spec the say method to ensure the output method receives the correct parameter?

require 'dsl'
class Consumer
def say(message)
DSL.execute do
output message
end
end
end
require 'runtime'
class DSL
def self.execute(&block)
Runtime.new(&block)
end
end
class Runtime
def initialize(&block)
self.instance_eval(&block)
end
def output(message)
puts message
end
end
@samflores
Copy link
Author

I don't think so :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment