Skip to content

Commit bdfee46

Browse files
committed
rubocopify
1 parent 261cf55 commit bdfee46

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ Gp/UnsafeYamlMarshal:
2727

2828
Gp/OptArgParameters:
2929
Enabled: false
30+
31+
Gp/SpecNestedDuplicatesLetName:
32+
Enabled: false
33+
34+
Rails/IndexBy:
35+
Enabled: false

spec/enum_machine/active_record_enum_spec.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# frozen_string_literal: true
22

33
RSpec.describe "DriverActiveRecord", :ar do
4-
model =
4+
let(:model) do
55
Class.new(TestModel) do
66
enum_machine :state, %w[choice in_delivery]
77
enum_machine :color, %w[red green blue]
88
end
9+
end
910

1011
it "check answer methods" do
1112
m = model.new(state: "choice", color: "red")
@@ -42,13 +43,15 @@
4243
expect(m.color.human_name).to eq "Красный"
4344
expect(model::COLOR.human_name_for("red")).to eq "Красный"
4445
expect(model::COLOR::RED.human_name).to eq "Красный"
46+
expect(model::COLOR["red"].human_name).to eq "Красный"
4547
end
4648

4749
context "when enum in CamelCase" do
48-
model_camel =
50+
let(:model_camel) do
4951
Class.new(TestModel) do
5052
enum_machine :state, %w[OrderCourier OrderPost]
5153
end
54+
end
5255

5356
it "check answer methods" do
5457
m = model_camel.new(state: "OrderCourier")
@@ -64,12 +67,13 @@
6467
end
6568

6669
context "when enum applied on store field" do
67-
model_store =
70+
let(:model_store) do
6871
Class.new(TestModel) do
6972
store :params, accessors: [:fine_tuning], coder: JSON
7073
enum_machine :fine_tuning, %w[good excellent]
7174
enum_machine :state, %w[choice in_delivery]
7275
end
76+
end
7377

7478
it "set store field" do
7579
m = model_store.new(fine_tuning: "good", state: "choice")
@@ -128,6 +132,7 @@ def am_i_choice?
128132
Class.new do
129133
include decorating_model::STATE.enum_decorator
130134
include decorating_model::COLOR.enum_decorator
135+
131136
attr_accessor :state, :color
132137
end
133138

spec/enum_machine/active_record_machine_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
RSpec.describe "DriverActiveRecord", :ar do
4-
model =
4+
let(:model) do
55
Class.new(TestModel) do
66
enum_machine :color, %w[red green blue]
77

@@ -27,6 +27,7 @@
2727
end
2828
end
2929
end
30+
end
3031

3132
it "before_transition is runnable" do
3233
m = model.create(state: "created", color: "red")

spec/enum_machine/driver_simple_class_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def initialize(state)
9090
decorated_klass =
9191
Class.new do
9292
include TestClassWithDecorator::STATE.enum_decorator
93+
9394
attr_accessor :state
9495
end
9596

@@ -105,6 +106,7 @@ def initialize(state)
105106
let(:invert_definition_class) do
106107
Class.new do
107108
include EnumMachine[state: { enum: %w[choice in_delivery] }]
109+
108110
attr_accessor :state
109111
end
110112
end
@@ -140,6 +142,7 @@ def initialize(state)
140142
decorated_klass =
141143
Class.new do
142144
include TestClassWithDecorator::STATE.enum_decorator
145+
143146
attr_accessor :state
144147
end
145148

0 commit comments

Comments
 (0)