summaryrefslogtreecommitdiffhomepage
path: root/test/text_spec.rb
diff options
context:
space:
mode:
authorTom Black <[email protected]>2018-10-05 22:44:13 -0700
committerTom Black <[email protected]>2018-10-08 17:34:17 -0700
commit4a4df9831003e0c9f51278b968a78d1900b9a3d9 (patch)
tree9c3ea4774243a48e07ee75f18da77b2ba1c1bf6f /test/text_spec.rb
parent13821e171daa52e2b9c4d35320eee0492b727bb7 (diff)
downloadruby2d-4a4df9831003e0c9f51278b968a78d1900b9a3d9.tar.gz
ruby2d-4a4df9831003e0c9f51278b968a78d1900b9a3d9.zip
Reorganize Image, Sprite, and Text args
Start with the required argument first as positional, followed by optional ones as keyword arguments Co-Authored-By: Andrew Havens <[email protected]>
Diffstat (limited to 'test/text_spec.rb')
-rw-r--r--test/text_spec.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/text_spec.rb b/test/text_spec.rb
index 67afe0e..63acec7 100644
--- a/test/text_spec.rb
+++ b/test/text_spec.rb
@@ -4,24 +4,24 @@ RSpec.describe Ruby2D::Text do
describe "#new" do
it "raises exception if font file doesn't exist" do
- expect { Text.new(font: "bad_font.ttf") }.to raise_error(Ruby2D::Error)
+ expect { Text.new("hello", font: "bad_font.ttf") }.to raise_error(Ruby2D::Error)
end
it "uses the system default font if one is not provided" do
- t = Text.new
+ t = Text.new("hello")
expect(t.font).to eq(Font.default)
end
end
describe "#text=" do
it "maps Time to string" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("hello", font: "test/media/bitstream_vera/vera.ttf")
t.text = Time.new(1, 1, 1, 1, 1, 1, 1)
expect(t.text).to eq("0001-01-01 01:01:01 +0000")
end
it "maps Number to string" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("hello", font: "test/media/bitstream_vera/vera.ttf")
t.text = 0
expect(t.text).to eq("0")
end
@@ -29,12 +29,12 @@ RSpec.describe Ruby2D::Text do
describe "#width" do
it "is known after creation" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("Hello Ruby!", font: "test/media/bitstream_vera/vera.ttf")
expect(t.width).to be_between(110, 120)
end
it "is known after updating" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("hello", font: "test/media/bitstream_vera/vera.ttf")
t.text = "Hello!"
expect(t.width).to eq(59)
end
@@ -42,12 +42,12 @@ RSpec.describe Ruby2D::Text do
describe "#height" do
it "is known after creation" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("hello", font: "test/media/bitstream_vera/vera.ttf")
expect(t.height).to eq(24)
end
it "is known after updating" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("hello", font: "test/media/bitstream_vera/vera.ttf")
t.text = "Good morning world!"
expect(t.height).to eq(24)
end
@@ -55,13 +55,13 @@ RSpec.describe Ruby2D::Text do
describe "#contains?" do
it "returns true if point is inside the text" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("hello", font: "test/media/bitstream_vera/vera.ttf")
t.text = "Hello world!"
expect(t.contains?(t.width / 2, t.height / 2)).to be true
end
it "returns false if point is outside the text" do
- t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t = Text.new("hello", font: "test/media/bitstream_vera/vera.ttf")
t.text = "Hello world!"
expect(t.contains?( - t.width / 2, t.height / 2)).to be false
expect(t.contains?( t.width / 2, - t.height / 2)).to be false