summaryrefslogtreecommitdiffhomepage
path: root/test/text_spec.rb
diff options
context:
space:
mode:
authorlstrzebinczyk <[email protected]>2017-05-27 20:56:35 +0200
committerTom Black <[email protected]>2017-06-03 20:30:43 -0400
commit3a694ffebcff71305d79c6e8c15246d671ce3888 (patch)
tree0c5ea151fa8ad76aa2e4feb447d6fe9efef1c409 /test/text_spec.rb
parent65187cd5126227778146ec33c2857a391fbab620 (diff)
downloadruby2d-3a694ffebcff71305d79c6e8c15246d671ce3888.tar.gz
ruby2d-3a694ffebcff71305d79c6e8c15246d671ce3888.zip
Use named arguments (#65)
Diffstat (limited to 'test/text_spec.rb')
-rw-r--r--test/text_spec.rb40
1 files changed, 21 insertions, 19 deletions
diff --git a/test/text_spec.rb b/test/text_spec.rb
index 15038d2..d2b8430 100644
--- a/test/text_spec.rb
+++ b/test/text_spec.rb
@@ -4,13 +4,13 @@ RSpec.describe Ruby2D::Text do
describe '#text=' do
it 'maps Time to string' do
- t = Text.new(0, 0, Time.now, 40, "test/media/bitstream_vera/vera.ttf")
+ 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
- t = Text.new(0, 0, 0, 40, "test/media/bitstream_vera/vera.ttf")
+ t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
t.text = 0
expect(t.text).to eq "0"
end
@@ -18,42 +18,44 @@ RSpec.describe Ruby2D::Text do
describe "#width" do
it "is known after creation" do
- t = Text.new(0, 0, "Hello world!", 40, "test/media/bitstream_vera/vera.ttf")
- expect(t.width).to eq(239)
+ t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ expect(t.width).to eq(123)
end
it "is known after updating" do
- t = Text.new(0, 0, "Good morning world!", 40, "test/media/bitstream_vera/vera.ttf")
- t.text = "Hello world!"
- expect(t.width).to eq(239)
+ t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t.text = "Hello!"
+ expect(t.width).to eq(59)
end
end
describe "#height" do
it "is known after creation" do
- t = Text.new(0, 0, "Hello world!", 40, "test/media/bitstream_vera/vera.ttf")
- expect(t.height).to eq(48)
+ t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ expect(t.height).to eq(24)
end
it "is known after updating" do
- t = Text.new(0, 0, "Good morning world!", 40, "test/media/bitstream_vera/vera.ttf")
- t.text = "Hello world!"
- expect(t.height).to eq(48)
+ t = Text.new(font: "test/media/bitstream_vera/vera.ttf")
+ t.text = "Good morning world!"
+ expect(t.height).to eq(24)
end
end
describe '#contains?' do
it "returns true if point is inside text" do
- text = Text.new(0, 0, "Hello world!", 40, "test/media/bitstream_vera/vera.ttf")
- expect(text.contains?(text.width / 2, text.height / 2)).to be true
+ 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
- text = Text.new(0, 0, "Hello world!", 40, "test/media/bitstream_vera/vera.ttf")
- expect(text.contains?( - text.width / 2, text.height / 2)).to be false
- expect(text.contains?( text.width / 2, - text.height / 2)).to be false
- expect(text.contains?(3 * text.width / 2, text.height / 2)).to be false
- expect(text.contains?( text.width / 2, 3 * text.height / 2)).to be false
+ 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
+ expect(t.contains?( t.width / 2, - t.height / 2)).to be false
+ expect(t.contains?(3 * t.width / 2, t.height / 2)).to be false
+ expect(t.contains?( t.width / 2, 3 * t.height / 2)).to be false
end
end
end