Created
September 26, 2012 03:09
-
-
Save blowmage/3785771 to your computer and use it in GitHub Desktop.
Stoopid example of MiniTest Shouldify
This file contains 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
= stoopid |
This file contains 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
=== 1.0.0 / 2012-09-25 | |
* 1 major enhancement | |
* Birthday! | |
This file contains 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
History.txt | |
Manifest.txt | |
README.txt | |
Rakefile | |
bin/stoopid | |
lib/stoopid.rb | |
test/test_stoopid.rb | |
This file contains 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 'rubygems' | |
require 'hoe' | |
Hoe.plugin :minitest | |
Hoe.spec 'stoopid' do | |
developer('mike Moore', '[email protected]') | |
dependency "minitest-shouldify", ">= 1.0", :dev | |
dependency "minitest-matchers", ">= 1.2", :dev | |
end |
This file contains 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
class Stoopid | |
VERSION = '1.0.0' | |
def to_s | |
"stoopid" | |
end | |
end |
This file contains 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" | |
require "minitest/shouldify" | |
require "minitest/matchers" | |
class Stoopid | |
module Matchers | |
class BeEqualTo | |
def initialize expected | |
@expected = expected | |
end | |
def matches? actual | |
@actual = actual | |
@actual == @expected | |
end | |
def failure_message | |
"Expected #{@actual.inspect} " + | |
"to be the same as #{@expected.inspect}" | |
end | |
def negative_failure_message | |
"Expected #{@actual.inspect} " + | |
"to not be the same as #{@expected.inspect}" | |
end | |
end | |
def be_equal_to(attr) | |
BeEqualTo.new(attr) | |
end | |
def self.included(base) | |
instance_methods.each do |name| | |
base.register_matcher name, name | |
end | |
end | |
end | |
end | |
class MiniTest::Unit::TestCase | |
include Stoopid::Matchers | |
end |
This file contains 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 "test_helper" | |
require "stoopid" | |
MiniTest.shouldify! "should", "should_not" | |
MiniTest.shouldify! "would_you_please", "please_o_please_dont" | |
describe Stoopid do | |
it "is stoopid" do | |
Stoopid.new.to_s.should_equal "stoopid" | |
Stoopid.new.to_s.should_not_equal "smart" | |
end | |
subject { Stoopid.new.to_s } | |
it { would_you_please be_equal_to "stoopid" } | |
please_o_please_dont { be_equal_to "nothing" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment