Skip to content

Instantly share code, notes, and snippets.

@hmarr
Last active August 29, 2015 14:02
Show Gist options
  • Save hmarr/ca901425d5fa87998b80 to your computer and use it in GitHub Desktop.
Save hmarr/ca901425d5fa87998b80 to your computer and use it in GitHub Desktop.
Encoding issue in elasticsearch-ruby

Steps to reproduce:

  1. git clone https://gist.github.com/ca901425d5fa87998b80.git encoding-issue
  2. cd encoding-issue
  3. bundle install
  4. rspec encoding_error_spec.rb

Example output:

$ rspec encoding_error_spec.rb
F
es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/notifications.rb:198:in `block in fully_formatted': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/notifications.rb:197:in `each'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/notifications.rb:197:in `fully_formatted'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/notifications.rb:88:in `block in fully_formatted_failed_examples'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/notifications.rb:87:in `each'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/notifications.rb:87:in `each_with_index'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/notifications.rb:87:in `fully_formatted_failed_examples'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/formatters/base_text_formatter.rb:35:in `dump_failures'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/reporter.rb:137:in `block in notify'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/reporter.rb:136:in `each'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/reporter.rb:136:in `notify'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/reporter.rb:116:in `finish'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/reporter.rb:56:in `report'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:108:in `run_specs'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:86:in `run'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:70:in `run'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:38:in `invoke'
	from es-encoding-error/.bundle/gems/rspec-core-3.0.0/exe/rspec:4:in `<top (required)>'
	from .bundle/binstubs/rspec:16:in `load'
	from .bundle/binstubs/rspec:16:in `<main>'
require "elasticsearch"
describe "the encoding error" do
it "is no fun" do
client = Elasticsearch::Client.new
client.search(body: { query: { invalid_query: "£4.99" } })
end
end
source 'https://rubygems.org'
gem 'rspec'
gem 'elasticsearch', '~> 1.0.2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment