Reputation: 4895
I'm having problems with a report (covering models with spec tests). My gems:
group :development, :test do
gem 'factory_girl_rails', '3.4.0'
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '1.2.0'
gem 'guard-bundler', '1.0.0'
gem 'guard-cucumber'
gem "shoulda-matchers", '1.1.0'
end
group :test do
gem 'simplecov', :require => false
#gem "simplecov-rcov", "~> 0.2.3"
gem 'cucumber-rails', require: false
gem 'database_cleaner'
gem "capybara"
gem 'json_spec'
end
Error message:
Finished in 1.21 seconds
9 examples, 0 failures
/var/lib/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:285:in `encode': "\xD1" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
from /var/lib/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:285:in `generate'
from /var/lib/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:285:in `pretty_generate'
from /var/lib/gems/1.9.1/gems/simplecov-0.6.4/lib/simplecov/result_merger.rb:77:in `block in store_result'
from /var/lib/gems/1.9.1/gems/simplecov-0.6.4/lib/simplecov/result_merger.rb:75:in `open'
from /var/lib/gems/1.9.1/gems/simplecov-0.6.4/lib/simplecov/result_merger.rb:75:in `store_result'
from /var/lib/gems/1.9.1/gems/simplecov-0.6.4/lib/simplecov.rb:48:in `result'
from /var/lib/gems/1.9.1/gems/simplecov-0.6.4/lib/simplecov/configuration.rb:133:in `block in at_exit'
from /var/lib/gems/1.9.1/gems/simplecov-0.6.4/lib/simplecov/defaults.rb:51:in `call'
from /var/lib/gems/1.9.1/gems/simplecov-0.6.4/lib/simplecov/defaults.rb:51:in `block in <top (required)>'
How this can be solved? Please help!
Update
What i've done:
1) uninstalled & reinstalled all gems http://axonflux.com/uninstalling-and-reinstalling-all-ruby-gems
2) deleted the .rvn dir
3) commented out some gems
group :development do
# gem 'growl'
group :test do
# gem 'json_spec'
gem 'simplecov', :require => false
#gem "simplecov-rcov", "~> 0.2.3"
4)installed rvn
no luck on any of those stages ....
have to find where those offending characters are exactly!
UPDATE
Tried setting Encoding.default_external = :'ASCII-8BIT' | :'UTF-8' in boot.rb. no luck
UPDATE Trying to solve problem by running a script
#!/bin/bash
FROM=us-ascii
TO=UTF-8
ICONV="iconv -f $FROM -t $TO"
# Convert
find gazsev32/ -type f -name "*" | while read fn; do
cp ${fn} ${fn}.bak
$ICONV < ${fn}.bak > ${fn}
rm ${fn}.bak
done
UPDATE
In the end i'm afraid it's time to reinstall my system. System errors followed
Upvotes: 1
Views: 1424
Reputation: 84343
Your trace says:
/var/lib/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:285:in `encode': "\xD1" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
This is clearly an encoding error, which is a common problem under Ruby 1.9. It can sometimes be solved by ensuring that you have:
# encoding: utf-8
at the top of your source files, but if not you may need to resort to using /usr/bin/iconv from the shell or some Ruby brute force to remove offending characters before trying to convert your code to JSON. The problem is clearly in your JSON library, but the offending characters are probably elsewhere in your source.
Upvotes: 1