Sha256: 2f80f855116a5d75d505a2da5f80dd8455d6e4af41b123e385d3eaf59f1c6585
Contents?: true
Size: 1.35 KB
Versions: 8
Compression:
Stored size: 1.35 KB
Contents
require "metamorpher/terms/variable" module Metamorpher module Terms shared_examples "a variable builder" do describe "variable!" do it "should create an instance of Variable" do actual = subject.variable!(:a) expected = Variable.new(name: :a) expect(actual).to eq(expected) end it "should create condition from block" do built = subject.variable!(:a) { |term| term > 0 } expect(built.name).to eq(:a) expect(built.condition.call(1)).to be_truthy expect(built.condition.call(-1)).to be_falsey end it "should not allow children" do expect { subject.variable!(:a, 1) }.to raise_error(ArgumentError) end end describe "variable shorthand" do it "should create an instance of Variable" do actual = subject.A expected = Variable.new(name: :a) expect(actual).to eq(expected) end it "should create condition from block" do built = subject.A { |term| term > 0 } expect(built.name).to eq(:a) expect(built.condition.call(1)).to be_truthy expect(built.condition.call(-1)).to be_falsey end it "should not allow children" do expect { subject.A(1) }.to raise_error(ArgumentError) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems