<commit_before>require_relative '../app/lib/direction'
require_relative '../app/lib/direction_calculator'
require_relative 'mocks'

include Mocks
include Direction

describe DirectionCalculator do
	it 'stands still if on target' do
		direction = get_direction 1, 1, 1, 1
		direction.should eq(STILL)
	end

	it 'north' do
		direction = get_direction 1, 0, 1, 1
		direction.should eq(NORTH)
	end

	it 'north east' do
		get_direction(0, 0, 1, 1).should eq(NORTH_EAST)		
	end

	it 'north west' do
		get_direction(1, 0, 0, 1).should eq(NORTH_WEST)
	end

	it 'south' do
		get_direction(0, 1, 0, 0).should eq(SOUTH)
	end

	it 'set a west direction' do
		get_direction(1, 0, 0, 0).should eq WEST
	end
end

def get_direction(x1, y1, x2, y2)
	first = CGPoint.new x1, y1
	second = CGPoint.new x2, y2

	DirectionCalculator.direction first, second
end<commit_msg>More specs<commit_after>require_relative '../app/lib/direction'
require_relative '../app/lib/direction_calculator'
require_relative 'mocks'

include Mocks
include Direction

describe DirectionCalculator do
	describe '#direction' do
		it 'stands still if on target' do
			direction = get_direction 1, 1, 1, 1
			direction.should eq(STILL)
		end

		it 'goes north' do
			direction = get_direction 1, 0, 1, 1
			direction.should eq(NORTH)
		end

		it 'goes north east' do
			get_direction(0, 0, 1, 1).should eq(NORTH_EAST)		
		end

		it 'goes north west' do
			get_direction(1, 0, 0, 1).should eq(NORTH_WEST)
		end

		it 'goes south' do
			get_direction(0, 1, 0, 0).should eq(SOUTH)
		end

		it 'goes west' do
			get_direction(1, 0, 0, 0).should eq WEST
		end

		it 'goes east' do
			get_direction(0, 0, 1, 0).should eq EAST
		end

		context 'when close still find it (fuzzy)' do
			it 'goes east' do
				get_direction(0.4, 0.2, 1.1, 0.9).should eq EAST
			end			
		end
	end
end

def get_direction(x1, y1, x2, y2)
	first = CGPoint.new x1, y1
	second = CGPoint.new x2, y2

	DirectionCalculator.direction first, second
end
{'fraction_non_alphanumeric': 0.10320284697508897, 'fraction_numerical': 0.03863751906456533, 'mean_word_length': 3.652482269503546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3202531', 'n_tokens_mistral': 883, 'n_tokens_neox': 744, 'n_words': 239}