Skip to content

Commit

Permalink
Class#name returns a frozen string on ruby 2.7 (#83)
Browse files Browse the repository at this point in the history
* Class#name returns a frozen string on ruby 2.7

* Run specs with ruby 2.7.2
  • Loading branch information
andrehjr authored Jan 4, 2021
1 parent 414831b commit 2ec80f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.4.4
- image: circleci/ruby:2.7.2
environment:
CC_TEST_REPORTER_ID: 03ab83a772148a577d29d4acf438d7ebdc95c632224122d0ba8dbb291eedebe6
COVERAGE: true
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ DEPENDENCIES
upperkut!

BUNDLED WITH
1.17.2
2.1.4
2 changes: 1 addition & 1 deletion lib/upperkut/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Upperkut
module Util
def to_underscore(object)
klass_name = object
klass_name = object.dup
klass_name.gsub!(/::/, '_')
klass_name.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
klass_name.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
Expand Down
10 changes: 10 additions & 0 deletions spec/upperkut/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ module Upperkut
RSpec.describe Util do
include Upperkut::Util

describe '#to_underscore' do
it 'transforms strings into their underscored version' do
expect(to_underscore("Upperkut::BufferedQueue")).to eq('upperkut_buffered_queue')
end

it 'transforms frozen strings into their underscored version properly' do
expect(to_underscore(Upperkut::Util.name)).to eq('upperkut_util')
end
end

describe '#normalize_items' do
it 'transforms hashes into items' do
items_hash = [{ 'my_property' => 1 }]
Expand Down

0 comments on commit 2ec80f7

Please sign in to comment.