summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/testcard.rb3
-rw-r--r--test/text_spec.rb7
2 files changed, 9 insertions, 1 deletions
diff --git a/test/testcard.rb b/test/testcard.rb
index c433aa4..2b182cf 100644
--- a/test/testcard.rb
+++ b/test/testcard.rb
@@ -243,6 +243,9 @@ flash = 0
time_start = Time.now
+# Default font for text
+Text.new(x: 150, y: 470, text: "Default font", size: 20)
+
# Text size
created_text = Text.new(x: 10, y: 270, text: "Created text", font: font)
created_text_background = Rectangle.new(
diff --git a/test/text_spec.rb b/test/text_spec.rb
index 9a79532..67afe0e 100644
--- a/test/text_spec.rb
+++ b/test/text_spec.rb
@@ -6,10 +6,15 @@ RSpec.describe Ruby2D::Text do
it "raises exception if font file doesn't exist" do
expect { Text.new(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
+ expect(t.font).to eq(Font.default)
+ end
end
describe "#text=" do
- it 'maps Time to string' do
+ it "maps Time to string" do
t = Text.new(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")