# -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__)) + '/helpers.rb' context "a text" do setup { Ray::Text.new "Hello world!" } asserts(:content).equals "Hello world!" asserts(:style).equals Ray::Font::STYLE_NORMAL asserts(:pos).equals Ray::Vector2[0, 0] asserts(:scale).equals Ray::Vector2[1, 1] asserts(:angle).equals 0 asserts(:character_size).equals 12 asserts(:color).equals Ray::Color.white context "after changing style" do hookup { topic.style = [:bold, :italic] } asserts(:style).equals Ray::Font::STYLE_BOLD | Ray::Font::STYLE_ITALIC end context "after changing string" do hookup do topic.encoding = "utf-8" # Would be required in 1.8 (but utf-8 is the default) topic.content = "héllo" end asserts(:encoding).matches /utf-8/i asserts(:content).equals "héllo" end context "after changing position" do hookup { topic.pos = [13, 22] } asserts(:pos).equals Ray::Vector2[13, 22] end context "after changing angle" do hookup { topic.angle = 90 } asserts(:angle).equals 90 end context "after changing scale" do hookup { topic.scale = [2, 10] } asserts(:scale).equals Ray::Vector2[2, 10] end context "after changing character size" do hookup { topic.character_size = 120 } asserts(:character_size).equals 120 end context "with another position and scale" do hookup do topic.pos = [10, 20] topic.scale = [2, 10] end asserts("position of the rect") { topic.rect.pos }.equals Ray::Vector2[10, 20] asserts("size / size without scale") { scaled_size = topic.size topic.scale = [1, 1] size = topic.size topic.scale = [2, 10] scaled_size / size }.equals Ray::Vector2[2, 10] end context "after changing the color" do hookup { topic.color = Ray::Color.red } asserts(:color).equals Ray::Color.red end end run_tests if __FILE__ == $0