Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (70 sloc) 2.06 KB
require 'spec_helper'
# Marker class specs
module Codebreaker
describe Marker do
describe '#exact_match_count' do
context 'with no matches' do
it 'returns 0' do
marker = Marker.new('1234', '5555')
expect(marker.exact_match_count).to eql(0)
end
end
context 'with 1 exact match' do
it 'returns 1' do
marker = Marker.new('1234', '1555')
expect(marker.exact_match_count).to eql(1)
end
end
context 'with 2 exact matches' do
it 'returns 2' do
marker = Marker.new('1234', '1535')
expect(marker.exact_match_count).to eql(2)
end
end
context 'with 3 exact matches' do
it 'returns 3' do
marker = Marker.new('1234', '1254')
expect(marker.exact_match_count).to eql(3)
end
end
context 'with 1 exact match and 1 number match' do
it 'returns 1' do
marker = Marker.new('1234', '1455')
expect(marker.exact_match_count).to eql(1)
end
end
end
describe '#number_match_count' do
context 'with no matches' do
it 'returns 0' do
marker = Marker.new('1234', '5555')
expect(marker.number_match_count).to eql(0)
end
end
context 'with 1 number match' do
it 'returns 1' do
marker = Marker.new('1234', '4555')
expect(marker.number_match_count).to eql(1)
end
end
context 'with 1 exact match' do
it 'returns 0' do
marker = Marker.new('1234', '1555')
expect(marker.number_match_count).to eql(0)
end
end
context 'with 1 exact matche amd 1 number match' do
it 'returns 1' do
marker = Marker.new('1234', '1355')
expect(marker.number_match_count).to eql(1)
end
end
context 'with 1 exact match duplicated in guess' do
it 'returns 0' do
marker = Marker.new('1234', '1155')
expect(marker.number_match_count).to eql(0)
end
end
end
end
end