Commit 695c512 1 parent 31b3e9d commit 695c512 Copy full SHA for 695c512
File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ def initialize(radians)
70
70
else
71
71
BigDecimal ( radians , PRECISION )
72
72
end
73
+ freeze
73
74
end
74
75
75
76
def degrees
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
RSpec . describe Astronoby ::Angle do
4
+ describe "object immutability" do
5
+ context "when a mutable method is added" do
6
+ it "raises a FrozenError when immutability is broken" do
7
+ described_class . class_eval do
8
+ def clear
9
+ @radians = 0
10
+ end
11
+ end
12
+
13
+ expect { described_class . as_degrees ( 180 ) . clear } . to raise_error ( FrozenError )
14
+ end
15
+ end
16
+ end
17
+
4
18
describe "::as_radians" do
5
19
it "returns an Angle object" do
6
20
expect ( described_class . as_radians ( described_class ::PI ) )
You can’t perform that action at this time.
0 commit comments