Skip to content

Commit

Permalink
Lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerluan committed Nov 16, 2023
1 parent 5f5a9c3 commit 2b3d070
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/arkana/models/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def self.new(string_value:)
# Handles cases like "0001" which should be interpreted as strings
return STRING if string_value.to_i.to_s != string_value
# Handle int overflow
return STRING if string_value.to_i > 2**31 - 1
return INTEGER
return STRING if string_value.to_i > (2**31) - 1
INTEGER
else
STRING
end
Expand Down
12 changes: 6 additions & 6 deletions spec/models/type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,47 @@
end

context "when passing something that looks like a number" do
context "it contains leading zeros" do
context "when it contains leading zeros" do
subject { described_class.new(string_value: "0001") }

it "returns :string" do
expect(subject).to eq :string
end
end

context "its string representation is the same as its integer representation" do
context "when its string representation is the same as its integer representation" do
subject { described_class.new(string_value: "1234567890") }

it "returns :integer" do
expect(subject).to eq :integer
end
end

context "its string representation is different from its integer representation" do
context "when its string representation is different from its integer representation" do
subject { described_class.new(string_value: "1234567890.0") }

it "returns :string" do
expect(subject).to eq :string
end
end

context "it contains a decimal point" do
context "when it contains a decimal point" do
subject { described_class.new(string_value: "3.14") }

it "returns :string" do
expect(subject).to eq :string
end
end

context "it contains a comma" do
context "when it contains a comma" do
subject { described_class.new(string_value: "1,000") }

it "returns :string" do
expect(subject).to eq :string
end
end

context "it contains a massive number" do
context "when it contains a massive number" do
subject { described_class.new(string_value: "123456789012345678901234567890") }

it "returns :string" do
Expand Down

0 comments on commit 2b3d070

Please sign in to comment.