-
-
Save takai/740240 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
# coding: utf-8 | |
require 'rspec' | |
describe Array do | |
class << self | |
alias それは it | |
alias なにって subject | |
alias 状況が context | |
end | |
なにって { [] } | |
それは { いわゆる 空であること } | |
それは { いわゆる 配列であること } | |
状況が '空じゃないとき' do | |
なにって { [1] } | |
それは { ありえないのが 空であること } | |
end | |
end | |
RSpec::Core::Subject::InstanceMethods.class_eval do | |
alias いわゆる should | |
alias ありえないのが should_not | |
end | |
RSpec::Matchers.define :空であること do | |
match {|obj| obj.empty? } | |
failure_message_for_should do |obj| | |
"#{obj}は空じゃないです" | |
end | |
failure_message_for_should_not do |obj| | |
"#{obj}は空です" | |
end | |
end | |
RSpec::Matchers.define :配列であること do | |
match {|obj| obj.instance_of? Array } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment