rspec test failures with present to non-English symbols - ruby-on-rails

I'm comparing multiple files containing russian characters, and that's a result of getting. I replaced the symbols and the tests were properly
My environments: Rails 5.0.0.1 and ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Files use utf-8 encoding.
Failure/Error: Feror::AppGenerator.start args, { destination_root: spec_path }
Encoding::CompatibilityError:
incompatible character encodings: ASCII-8BIT and UTF-8

Related

ruby encoding error on windows

Wondering if anyone has ever come across the error
Caught Encoding::CompatibilityError at '{"command_id":"cc8bf': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (JSON::ParserError)
I get this the following is called
expect(page.element.text.to_s.force_encoding("UTF-8").match msg).to be_true
As you can see, I have added "to_s.force_encoding("UTF-8")" but i still get the error.
My version of ruby is 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Running on a mac and the tests pass with no errors.

Jekyll Installation Fails

I'm trying to install Jekyll on my mac, it was not happening at all so I tried to reinstall my rvm 1.9.3. But I am getting following error now. It will be great if some one can help me to fix this.
...
e.rb, skipping
Installing ri documentation for parslet-1.5.0
unable to convert U+00E5 from UTF-8 to US-ASCII for test/test_child.rb, skipping
Installing ri documentation for posix-spawn-0.3.8
unable to convert U+2014 from UTF-8 to US-ASCII for lib/pygments/popen.rb, skipping
unable to convert U+00F8 from UTF-8 to US-ASCII for test/test_pygments.rb, skipping
unable to convert "\xC5" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for vendor/pygments-main/AUTHORS, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for vendor/pygments-main/CHANGES, skipping
unable to convert U+2219 from UTF-8 to US-ASCII for vendor/pygments- main/tests/examplefiles/coq_RelationClasses, skipping
unable to convert "\xE9" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for vendor/pygments-main/tests/examplefiles/example.cpp, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for vendor/pygments-main/tests/examplefiles/fucked_up.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for vendor/pygments-main/tests/examplefiles/py3_test.txt, skipping
RDoc::Parser::Ruby failure around line 1 of
vendor/pygments-main/tests/examplefiles/ruby_func_def.rb
Before reporting this, could you check that the file you're documenting
has proper syntax:
/Users/mauliks/.rvm/rubies/ruby-1.9.3-p484/bin/ruby -c vendor/pygments- main/tests/examplefiles/ruby_func_def.rb
RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.
The internal error was:
(NoMethodError) undefined method `name' for # <RDoc::RubyToken::TkLPAREN:0x007fa58bfdcf68>
ERROR: While executing gem ... (NoMethodError)
undefined method `name' for #<RDoc::RubyToken::TkLPAREN:0x007fa58bfdcf68>
Thanks in advance.
Finally I fixed that,
gem install rdoc --pre

output_safety.rb:34 warning: regexp match /.../n against to UTF-8 string

When starting up my WEBrick server, I get next warning when calling the home page:
c:/Program Files/jruby-1.6.7/lib/ruby/gems/1.8/gems/activesupport-
3.2.2.rc1/lib/active_support/core_ext/string/output_safety.rb:34
warning: regexp match /.../n against to UTF-8 string
Can someone tell me why I'm getting this warning?
+
I'm running JRuby in 1.9 mode, but here I'm getting an error from a gem in 1.8 folder. Why is that? Shouldn't the gems from the 1.9 folder be used?
this issue is discussed here github.com/rails/rails/issues/3927

Documentation generated by Yard and spanish accents

I'm generating documentation with Yard, and all my comments have been written in Spanish. The problem is that the documentation generated by Yard contains � instead of Spanish accents.
I've used "yardoc" command.
I'm using ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32] and Rails 3.0.7
Running on Windows 7
Probably your source files are encoded in ISO Latin 1 while Yard expects them to be in UTF-8.
You could instruct Yard to read your files in ISO Latin 1 instead of the default UTF-8, but I strongly suggest you to re-encode your source files as UTF-8 files. Any decent text editor should be able to do that with one or two clicks.

Gem update: unable to convert "\xE7" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII

just ran gem update on a light use server machine that hadn't been updated in a while... and am getting loads of 'unable to convert "\x??" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for..." errors. Included is an except from console. anyone know what's going on?
$ sudo gem update
Installing ri documentation for railties-3.0.4...
Installing ri documentation for minitest-2.0.2...
Installing ri documentation for net-ssh-2.1.0...
unable to convert "\xE7" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/net/ssh/authentication/pageant.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/net/ssh/buffered_io.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/net/ssh/service/forward.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for THANKS.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for CHANGELOG.rdoc, skipping
Installing ri documentation for rails-3.0.4...
file 'lib' not found
Installing ri documentation for rails3-generators-0.17.4...
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.rdoc, skipping
Installing ri documentation for rdoc-3.5.3...
unable to convert U+201D from UTF-8 to US-ASCII for lib/rdoc/text.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for History.txt, skipping
Installing ri documentation for rspec-core-2.5.1...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/rspec/core/subject.rb, skipping
Installing ri documentation for rspec-expectations-2.5.0...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/rspec/matchers.rb, skipping
Installing ri documentation for rspec-mocks-2.5.0...
Installing ri documentation for rspec-2.5.0...
Installing ri documentation for rspec-rails-2.5.0...
I have had a similar issue on my Mac OS X using iTerm2 instead of the default OS X Terminal.app.
The LC_CTYPE is not set properly by iTerm2, once I have added export LC_CTYPE="utf-8" to ~/.bash_profile the gem installation goes smoothly.
note: of course you can add the export to any of the other profile files
The combination of Daniel and werm's answers worked for me, once I also unset LC_ALL. I ended up with this:
export LC_CTYPE=en_US.UTF-8
export LANG=en_US.UTF-8
unset LC_ALL
Try running locale in your SSH terminal. This problem just started popping up for me. When I do locale I get this:
LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=
The only fix I know of is to type LANG=en_US.UTF-8 every time I login through SSH.
I was getting this same issue w/ installing another gem and didn't know how to get around it even after adding export LC_CTYPE="utf-8" to my ~/.bash_profile. It wasn't until I ran sudo gem update after that was able to install the gem.
Note that I wanted to contribute this to the original accepted answer, however not enough points yet. :( Nonetheless I hope this helps someone else.

Resources