-
François Sarradin authoredFrançois Sarradin authored
intersection_rect_question_spec.rb 1.25 KiB
require 'spec_helper'
require 'extreme_startup/question_factory'
require 'extreme_startup/player'
module ExtremeStartup
describe RectangleIntersectionQuestion do
let(:question) { RectangleIntersectionQuestion.new(Player.new) }
it "converts to a string" do
question.as_text.should =~ /give the intersection of those rectangles \(x0,y0,width,height\): \(\d+,\d+,\d+,\d+\) x \(\d+,\d+,\d+,\d+\)/i
end
context "when the numbers and known" do
let(:question) { RectangleIntersectionQuestion.new(Player.new, 1,1,10,10, 5,5,20,20) }
it "converts to the right string" do
question.as_text.should =~ /give the intersection of those rectangles \(x0,y0,width,height\): \(1,1,10,10\) x \(5,5,20,20\)/i
end
it "identifies a correct answer" do
question.answered_correctly?("( 5, 5, 6, 6 )").should be_true
end
it "identifies an incorrect answer" do
question.answered_correctly?("(5,5,6,20)").should be_false
end
end
context "when the rectangles does not intersect" do
let(:question) { RectangleIntersectionQuestion.new(Player.new, 1,1,2,2, 5,5,2,2) }
it "identifies empty answer as correct" do
question.answered_correctly?("").should be_true
end
end
end
end