diff --git a/spec/and_spec.rb b/spec/and_spec.rb new file mode 100644 index 0000000..08291ef --- /dev/null +++ b/spec/and_spec.rb @@ -0,0 +1,13 @@ +require_relative "../and.rb" +describe AndGate do + it "should AND together all inputs" do + table=[ + [0,0,0], + [0,1,0], + [1,0,0], + [1,1,1], + ] + ok=AndGate.test_table(table) + expect(ok).to eq true + end +end diff --git a/spec/gate_spec.rb b/spec/gate_spec.rb index 6ef6b23..9865048 100644 --- a/spec/gate_spec.rb +++ b/spec/gate_spec.rb @@ -1,9 +1,6 @@ require_relative "../port.rb" require_relative "../gate.rb" -require_relative "../not.rb" -require_relative "../and.rb" -require_relative "../or.rb" -require_relative "../xor.rb" + describe Gate do let(:klass) do Class.new(Gate) do @@ -34,54 +31,4 @@ describe Gate do b.setval(10) expect(gate.out.val).to eq(18) end - - context "NotGate" do - it "should NOT the input" do - table=[ - [0,1], - [1,0] - ] - ok=NotGate.test_table(table) - expect(ok).to eq true - end - end - - context "AndGate" do - it "should AND together all inputs" do - table=[ - [0,0,0], - [0,1,0], - [1,0,0], - [1,1,1], - ] - ok=AndGate.test_table(table) - expect(ok).to eq true - end - end - - context "OrGate" do - it "should OR together all inputs" do - table=[ - [0,0,0], - [0,1,1], - [1,0,1], - [1,1,1], - ] - ok=OrGate.test_table(table) - expect(ok).to eq true - end - end - - context "XorGate" do - it "should XOR together all inputs" do - table=[ - [0,0,0], - [0,1,1], - [1,0,1], - [1,1,0], - ] - ok=XorGate.test_table(table) - expect(ok).to eq true - end - end end diff --git a/spec/not_spec.rb b/spec/not_spec.rb new file mode 100644 index 0000000..6fd21a8 --- /dev/null +++ b/spec/not_spec.rb @@ -0,0 +1,11 @@ +require_relative "../not.rb" +describe NotGate do + it "should NOT the input" do + table=[ + [0,1], + [1,0] + ] + ok=NotGate.test_table(table) + expect(ok).to eq true + end +end diff --git a/spec/or_spec.rb b/spec/or_spec.rb new file mode 100644 index 0000000..384d121 --- /dev/null +++ b/spec/or_spec.rb @@ -0,0 +1,13 @@ +require_relative "../or.rb" +describe OrGate do + it "should OR together all inputs" do + table=[ + [0,0,0], + [0,1,1], + [1,0,1], + [1,1,1], + ] + ok=OrGate.test_table(table) + expect(ok).to eq true + end +end diff --git a/spec/xor_spec.rb b/spec/xor_spec.rb new file mode 100644 index 0000000..ffad5db --- /dev/null +++ b/spec/xor_spec.rb @@ -0,0 +1,13 @@ +require_relative "../xor.rb" +describe XorGate do + it "should XOR together all inputs" do + table=[ + [0,0,0], + [0,1,1], + [1,0,1], + [1,1,0], + ] + ok=XorGate.test_table(table) + expect(ok).to eq true + end +end