Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird HTML escape in generated update session page when using capybara with JS #2

Closed
nicolasblanco opened this issue Sep 21, 2012 · 5 comments
Assignees

Comments

@nicolasblanco
Copy link

Hi,

when enabling js in my integration test (using js: true) and capybara-webkit like this :

background do
  page.set_rack_session(user_id: @user.id)
end

scenario "It renders", js: true do
  visit "/"
end

The test fails with :

Failure/Error: page.set_rack_session(user_id: @user.id)
   Capybara::ElementNotFound:
     no button with value or id or text 'Update' found
   # (eval):2:in `click_button'

I've taken a look at the generated update session page HTML and it contains some weird HTML escape but only some parts of the form seem escaped (very weird) :

<html><head></head><body>
    <h2>Update rack session</h2>
    <p>Put marshalized and encoded with base64 ruby hash into the form</p>
    <form action="/rack_session" method="post" enctype="application/x-www-form-urlencoded">
      <input type="hidden" name="_method" value="put">
      <textarea cols="40" rows="10" name="data">      &lt;p&gt;
        &lt;input type="submit" value="Update"/&gt;
      &lt;/p&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;
</textarea></form></body></html>

Have you got some ideas?

Thanks.

Using : rails 2.3.8 / capybara 1.1.2 / capybara-screenshot 0.2.2 / capybara-webkit 0.12.1

@ghost ghost assigned ayanko Sep 22, 2012
@ayanko
Copy link
Member

ayanko commented Sep 22, 2012

I'll check & fix

@ayanko
Copy link
Member

ayanko commented Sep 24, 2012

Questions:

  • What builder gem version do you use?
  • Does next snippet produce correct output?
$ cat test_builder.rb 
require 'rubygems'
require 'builder'
builder = Builder::XmlMarkup.new(:indent => 2)
builder.html do |xml|
  xml.body do |xml|
    xml.textarea("", :cols => 40, :rows => 10, :name => 'data')
    xml.p do |xml|
      xml.input(:type => 'submit', :value => "Update")
    end
  end
end
data = builder.target!
puts data

@nicolasblanco
Copy link
Author

Hi and thanks for looking for this strange issue.

The generated output of the test file looks fine. As I said, the HTML output is only bad when using js: true in my test. My tests which don't use JS works great with rack_session_access.

[$]nicolas@MacBook-Air-de-Nicolas-Blanco:[git:master?] /Users/nicolas/projects/simplib-> bundle exec ruby test_builder.rb 
<html>
  <body>
    <textarea cols="40" rows="10" name="data"/>
    <p>
      <input type="submit" value="Update"/>
    </p>
  </body>
</html>

[$]nicolas@MacBook-Air-de-Nicolas-Blanco:[git:master?] /Users/nicolas/projects/simplib-> bundle show builder
/Users/nicolas/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/builder-3.0.3

@nicolasblanco
Copy link
Author

#4 fixes my problem :)

@ayanko
Copy link
Member

ayanko commented Sep 24, 2012

released v0.0.3

@ayanko ayanko closed this as completed Sep 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants