Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Created November 10, 2008 02:12
Show Gist options
  • Save dchelimsky/23406 to your computer and use it in GitHub Desktop.
Save dchelimsky/23406 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spec'
require 'spec/mocks'
require "synthesis/util/mock_instance/rspec"
class Person; end
describe "synthesis" do
it "accepts a greeting (non-existent method)" do
person = Person.new
person.should_receive(:hello)
person.hello
end
it "accepts a greeting (method defined at runtime)" do
person = Person.new
greetings = Module.new do
def hello; "hello"; end
end
person.extend greetings
person.hello.should == "hello"
end
end
require 'rubygems'
require 'synthesis/task'
Synthesis::Task.new do |t|
t.adapter = :rspec
t.pattern = '**/*.rb'
end
$ rake synthesis:test
(in /Users/david/projects/ruby/tmp/synth)
[Synthesis] Collecting expectations...
..
Finished in 0.003435 seconds
2 examples, 0 failures
[Synthesis] Verifying expectation invocations...
..
Finished in 0.001284 seconds
2 examples, 0 failures
[Synthesis]
[Synthesis] Tested Expectations:
[Synthesis]
[Synthesis] Untested Expectations:
() Person.new.hello() in ./example.rb:11
[Synthesis] Ignoring:
[Synthesis]
[Synthesis] FAILED.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment