Skip to content

Instantly share code, notes, and snippets.

@haru01
Created August 1, 2012 22:36
Show Gist options
  • Save haru01/3231321 to your computer and use it in GitHub Desktop.
Save haru01/3231321 to your computer and use it in GitHub Desktop.
and
# -*- 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