require 'spec_helper'
require 'perceptron'
RSpec.describe Perceptron do
describe '#activation' do
describe 'logic AND' do
bias = -1
weights = [bias, 1, 1]
describe 'when inputs are 0 and 0' do
it 'returns 0 AND 0' do
a = 0
b = 0
inputs = [a, b]
perceptron = Perceptron.new(inputs.count, weights)
expect(perceptron.predict(inputs)).to eq(a & b)
end
end
describe 'when inputs are 0 and 1' do
it 'returns 0 AND 1' do
a = 0
b = 1
inputs = [a, b]
perceptron = Perceptron.new(inputs.count, weights)
expect(perceptron.predict(inputs)).to eq(a & b)
end
end
describe 'when inputs are 1 and 0' do
it 'returns 1 AND 0' do
a = 1
b = 0
inputs = [a, b]
perceptron = Perceptron.new(inputs.count, weights)
expect(perceptron.predict(inputs)).to eq(a & b)
end
end
describe 'when inputs are 1 and 1' do
it 'returns 1 AND 1' do
a = 1
b = 1
inputs = [a, b]
perceptron = Perceptron.new(inputs.count, weights)
expect(perceptron.predict(inputs)).to eq(a & b)
end
end
end
end
end