Skip to content

Instantly share code, notes, and snippets.

@Thomascountz
Last active March 28, 2018 15:54
Show Gist options
  • Save Thomascountz/1efd2054153ea1026fb9adb9af727c42 to your computer and use it in GitHub Desktop.
Save Thomascountz/1efd2054153ea1026fb9adb9af727c42 to your computer and use it in GitHub Desktop.
Initial Spec for a Perceptron Class
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment