开发者

Capybara submit button - incompatible encoding regexp match

开发者 https://www.devze.com 2023-02-23 04:40 出处:网络
form.erb <%= form_for @search do |f| %> <%= f.text_field :name %> <%= f.submit \'submit\' %>

form.erb

<%= form_for @search do |f| %>
  <%= f.text_field :name %>
  <%= f.submit 'submit' %>
<% end %>

searches_spec.rb

require 'spec_helper'

describe SearchesController do 
  it "should do something" do
    visit searches_path

    page.fill_in 'search_name', :with => 'oak'

    click_button 'submit'
  end
end

output

Failure/Error: click_button 'submit'
 Encoding::CompatibilityError:
   incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)
 # ./spec/integration/searches_s开发者_如何学Gopec.rb:16:in `block (2 levels) in <top (required)>'

Trying to simply submit a form in Capybara, but getting this error. Any ideas?

rails 3.1, capybara 0.4.1.2, rspec-rails 2.5.0


As mculp noted in the comments, this is indeed the mentioned bug in Rack.

To fix it locally for now, throw the following into your spec_helper.rb or env.rb for Cucumber (anywhere after Rack has been loaded.)

module Rack::Utils
  def escape(s)
    CGI.escape(s.to_s)
  end
end
0

精彩评论

暂无评论...
验证码 换一张
取 消