Created
September 7, 2011 23:32
-
-
Save tenderlove/1202145 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
class Subject < Struct.new(:lol) | |
def render_controls | |
lol.button_to 'Vote' | |
end | |
end | |
describe 'lolwot' do | |
it "should generate a button" do | |
template = Object.new | |
tc = self | |
called = false | |
template.extend Module.new { | |
define_method(:button_to) do |arg| | |
called = true | |
tc.assert_equal "Vote", arg | |
"THE_HTML" | |
end | |
} | |
subject = Subject.new template | |
subject.render_controls.must_equal "THE_HTML" | |
assert called, 'button_to was called' | |
end | |
it "should do it with minitest/mock" do | |
template = MiniTest::Mock.new | |
template.expect :button_to, "THE_HTML", ["Vote"] | |
subject = Subject.new template | |
subject.render_controls.must_equal "THE_HTML" | |
template.verify | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment