Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding setters for a Position block's height and width. Added tests f…
…or the getters.
- Loading branch information
Showing
2 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
require 'test_helper' | ||
|
||
class PositionTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
|
||
# Test the height and width getters | ||
test "width reads correctly" do | ||
p = positions(:one) | ||
assert_equal p.width-p.right+p.left, 0 | ||
end | ||
|
||
test "height reads correctly" do | ||
p = positions(:one) | ||
assert_equal p.height-p.bottom+p.top, 0 | ||
end | ||
|
||
# Test the height and width setters | ||
test "width sets correctly" do | ||
p = Position.new(:left => 0.1) | ||
p.width = 0.5 | ||
assert_equal p.right, 0.6 | ||
assert_equal p.width, 0.5 | ||
end | ||
|
||
test "height sets correctly" do | ||
p = Position.new(:top => 0.1) | ||
p.height = 0.5 | ||
assert_equal p.bottom, 0.6 | ||
assert_equal p.height, 0.5 | ||
end | ||
|
||
end |