|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -require "ostruct" |
4 | 3 | require "bigdecimal" |
5 | 4 | require "securerandom" |
6 | 5 | require "hanami/utils/kernel" |
7 | | - |
8 | | -# rubocop:disable Style/OpenStructUse |
9 | 6 | RSpec.describe Hanami::Utils::Kernel do |
10 | 7 | describe ".Array" do |
11 | 8 | describe "successful operations" do |
@@ -613,7 +610,7 @@ def to_int |
613 | 610 | end |
614 | 611 |
|
615 | 612 | describe "when a an object that doesn't implement any integer interface" do |
616 | | - let(:input) { OpenStruct.new(color: "purple") } |
| 613 | + let(:input) { Data.define(:color).new(color: "purple") } |
617 | 614 |
|
618 | 615 | it "raises error" do |
619 | 616 | expect { Hanami::Utils::Kernel.Integer(input) }.to raise_error(TypeError) |
@@ -1175,7 +1172,7 @@ def to_f |
1175 | 1172 | end |
1176 | 1173 |
|
1177 | 1174 | describe "when a an object that doesn't implement any float interface" do |
1178 | | - let(:input) { OpenStruct.new(color: "purple") } |
| 1175 | + let(:input) { Data.define(:color).new(color: "purple") } |
1179 | 1176 |
|
1180 | 1177 | it "raises error" do |
1181 | 1178 | expect { Hanami::Utils::Kernel.Float(input) }.to raise_error(TypeError) |
@@ -1424,11 +1421,11 @@ def to_str |
1424 | 1421 | end |
1425 | 1422 | end |
1426 | 1423 |
|
1427 | | - describe "when an open struct is given" do |
1428 | | - let(:input) { OpenStruct.new(title: "DDD") } |
| 1424 | + describe "when a data object is given" do |
| 1425 | + let(:input) { Data.define(:title).new(title: "DDD") } |
1429 | 1426 |
|
1430 | 1427 | it "returns the string representation" do |
1431 | | - expect(@result).to eq '#<OpenStruct title="DDD">' |
| 1428 | + expect(@result).to eq '#<data title="DDD">' |
1432 | 1429 | end |
1433 | 1430 | end |
1434 | 1431 |
|
@@ -2510,4 +2507,3 @@ def to_sym |
2510 | 2507 | end |
2511 | 2508 | end |
2512 | 2509 | end |
2513 | | -# rubocop:enable Style/OpenStructUse |
0 commit comments