Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created December 14, 2010 09:59
Show Gist options
  • Save ukstudio/740217 to your computer and use it in GitHub Desktop.
Save ukstudio/740217 to your computer and use it in GitHub Desktop.
# coding: utf-8
require 'rspec'
describe Array do
class << self
alias それは it
alias なにを subject
alias 状況は context
end
なにを { [] }
それは { should 空であること }
それは { should 配列であること }
状況は '空じゃないとき' do
subject { [1] }
# it { should 空であること }
#=> [1]は空じゃないです
it { should_not 空であること }
end
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