Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Faker::Json.shallow_json raises FrozenError #1598

Closed
pboling opened this issue Apr 11, 2019 · 0 comments · Fixed by #1605
Closed

Faker::Json.shallow_json raises FrozenError #1598

pboling opened this issue Apr 11, 2019 · 0 comments · Fixed by #1605

Comments

@pboling
Copy link

pboling commented Apr 11, 2019

Describe the bug

Faker::Json.shallow_json raises an error when using the future proof # frozen_string_literal: true magic.

To Reproduce

Test File:

∴ cat frozen_faker.rb
# frozen_string_literal: true

require 'faker'

puts Faker::Json.shallow_json(2, key: 'RockBand.name', value: 'Seinfeld.quote')

Run:

∴ ruby frozen_faker.rb
Traceback (most recent call last):
	2: from frozen_faker.rb:5:in `<main>'
	1: from /Users/karuna/.rvm/gems/ruby-2.6.0/gems/faker-1.9.3/lib/faker/default/json.rb:7:in `shallow_json'
/Users/karuna/.rvm/gems/ruby-2.6.0/gems/faker-1.9.3/lib/faker/default/json.rb:7:in `prepend': can't modify frozen String (FrozenError)

Expected behavior

Faker::Json.shallow_json should return a string.

Additional context

The example code was lifted from faker docs here:
https://github.com/stympy/faker/blob/master/doc/default/json.md

@pboling pboling changed the title Issue title goes here Faker::Json.shallow_json raises FrozenError Apr 11, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant