I'm trying to create a ruby rspec with capybara and I'm getting this error when attempting to remove part of a string from a hash: can't modify frozen String
scenario "check doc" do
docs = {
'A doc' => 'a.txt',
'B doc' => 'b.txt',
'C doc' => 'c.txt'
}
random_doc = docs.keys.sample
page.should have_css('.class', :text => 'Document ' + random_doc.gsub!(' doc') + ' was selected')
Any help would be appreciated!
The key name is frozen so you can't modify it in place - just use gsub rather than gsub! so that it returns a modified copy of the string rather than trying to do inplace modification
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With