Created
August 1, 2012 22:36
-
-
Save haru01/3231321 to your computer and use it in GitHub Desktop.
and
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
# -*- encoding: utf-8 -*- | |
class And | |
def initialize(*node) | |
@node = node | |
end | |
def exec | |
@node.reject{|n| n.call}.size == 0 | |
end | |
end | |
describe "IfThenElse#exec" do | |
context 'and 要素が 3つの場合' do | |
subject do | |
And.new(first, second, third) | |
end | |
context '3つとも trueの場合' do | |
let(:first) { -> { 1==1 } } | |
let(:second) { -> { 1==1 } } | |
let(:third) { -> { 1==1 } } | |
its(:exec) { should == true } | |
end | |
context '1つめが falseの場合' do | |
let(:first) { -> { false } } | |
let(:second) { -> { 1==1 } } | |
let(:third) { -> { 1==1 } } | |
its(:exec) { should == false } | |
end | |
context '3つめが falseの場合' do | |
let(:first) { -> { true } } | |
let(:second) { -> { true } } | |
let(:third) { -> { false } } | |
its(:exec) { should == false } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment