File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7474
7575Product ::COLOR .values # => ["red", "green"]
7676Product ::COLOR ::RED # => "red"
77+ Product ::COLOR ::RED .red? # => true
78+ Product ::COLOR ::RED .human_name # => "Красный"
7779Product ::COLOR ::RED__GREEN # => ["red", "green"]
7880
7981Product ::COLOR [" red" ].red? # => true
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def self.human_name_for(name)
3636 end
3737
3838 enum_values . each do |enum_value |
39- const_set enum_value . underscore . upcase , enum_value . to_s . freeze
39+ const_set enum_value . underscore . upcase , value_class . new ( enum_value ) . freeze
4040 end
4141
4242 aliases . each_key do |key |
Original file line number Diff line number Diff line change 4141 m = model . new ( color : "red" )
4242 expect ( m . color . human_name ) . to eq "Красный"
4343 expect ( model ::COLOR . human_name_for ( "red" ) ) . to eq "Красный"
44+ expect ( model ::COLOR ::RED . human_name ) . to eq "Красный"
4445 end
4546
4647 context "when enum in CamelCase" do
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ def initialize(state)
3636 it { expect { item . state . last__in_delivery? } . to raise_error ( NoMethodError ) }
3737 it { expect ( item . state ) . to eq "choice" }
3838 it { expect ( item . state . frozen? ) . to be true }
39+ it { expect ( TestClass ::STATE ::IN_DELIVERY . in_delivery? ) . to be true }
40+ it { expect ( TestClass ::STATE ::IN_DELIVERY . choice? ) . to be false }
41+ it { expect ( TestClass ::STATE ::IN_DELIVERY . frozen? ) . to be true }
3942
4043 describe "module" do
4144 it "returns state string" do
You can’t perform that action at this time.
0 commit comments