diff options
| author | Tom Black <[email protected]> | 2018-09-26 17:21:34 -0700 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2018-09-26 17:21:34 -0700 |
| commit | e2fb9c34d6f56ec833e0451b26a02c304afaf71b (patch) | |
| tree | 35029a30d2d0074ad783926fcd83e6dfe1401a37 /test/text_spec.rb | |
| parent | 6351fe4b374000ba78e3a7795f0f05e63cbdbc29 (diff) | |
| download | ruby2d-e2fb9c34d6f56ec833e0451b26a02c304afaf71b.tar.gz ruby2d-e2fb9c34d6f56ec833e0451b26a02c304afaf71b.zip | |
Documentation and style updates
Diffstat (limited to 'test/text_spec.rb')
| -rw-r--r-- | test/text_spec.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/test/text_spec.rb b/test/text_spec.rb index a787380..3e15435 100644 --- a/test/text_spec.rb +++ b/test/text_spec.rb @@ -1,20 +1,21 @@ require 'ruby2d' RSpec.describe Ruby2D::Text do - describe '#new' 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(font: "bad_font.ttf") }.to raise_error(Ruby2D::Error) end end - describe '#text=' do + describe "#text=" 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" end - it 'maps Number to string' do + it "maps Number to string" do t = Text.new(font: "test/media/bitstream_vera/vera.ttf") t.text = 0 expect(t.text).to eq "0" @@ -24,7 +25,8 @@ RSpec.describe Ruby2D::Text do describe "#width" do it "is known after creation" do t = Text.new(font: "test/media/bitstream_vera/vera.ttf") - expect(t.width).to eq(123) + # expect(t.width).to eq(123) + expect(t.width).to eq(116) end it "is known after updating" do @@ -47,14 +49,14 @@ RSpec.describe Ruby2D::Text do end end - describe '#contains?' do - it "returns true if point is inside 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 = "Hello world!" expect(t.contains?(t.width / 2, t.height / 2)).to be true end - it "returns true if point is not inside text" do + it "returns false if point is outside the text" do t = Text.new(font: "test/media/bitstream_vera/vera.ttf") t.text = "Hello world!" expect(t.contains?( - t.width / 2, t.height / 2)).to be false @@ -63,4 +65,5 @@ RSpec.describe Ruby2D::Text do expect(t.contains?( t.width / 2, 3 * t.height / 2)).to be false end end + end |
