Sha256: c6ef6059e15a09d62f8270e270dcabc82cea665138517343ace77867b51c21d6
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Geometry::Triangle do # short setting the variables for comparison let(:a) { 3} let(:b) { 4} let(:c) { 6} let(:good_perimeter) { 13} let(:good_area) { 5.332682251925386} let(:good_angles) { [3/4, 9/16, 1/8]} let(:good_validity) {true} subject { Geometry::Triangle.new(a, b, c) } # short way to check perimeter its(:perimeter) { should eq good_perimeter} its(:area) { should eq good_area} # its(:angles) {should eq good_angles} its(:valid?) {should eq good_validity} let(:a) { 2} let(:b) { 1} let(:c) { 1} let(:good_perimeter) { 4} let(:good_area) { 0} # let(:good_angles) { [3/4, 9/16, 1/8]} let(:good_validity) {false} subject { Geometry::Triangle.new(a, b, c) } its(:perimeter) { should eq good_perimeter} its(:area) { should eq good_area} its(:valid?) {should eq good_validity} # checks if the subject is an instance of the correct class it "should be an instance of geometry triangle" do subject.should be_an_instance_of Geometry::Triangle end end describe Geometry::Rectangle do # short setting the variables for comparison let(:length) { 3} let(:width) { 4} let(:good_perimeter) { 14} let(:good_area) { 12} subject { Geometry::Rectangle.new(length, width) } its(:perimeter) { should eq good_perimeter} its(:area) { should eq good_area} end describe Geometry::Circle do # short setting the variables for comparison let(:radius) { 3} let(:good_circ) { Math::PI * 6} subject { Geometry::Circle.new(radius) } its(:circ) { should eq good_circ} end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geometry-mf-0.1.0 | spec/geometry-mf_spec.rb |