ruby on rails 3 - I get an empty page with capybara visit method, but response object has content -


ok, i'm working capybara + rails 3 + rspect

i'm trying login site, though don't error when use fill_in method, error click_on method, since can't find element i'm trying click.

here html code:

<form accept-charset="utf-8" action="/" class="filter_form" id="login" method="post"> <fieldset> <div class="modal-body"> <div class="clearfix login-fields"> <label for="user_email">email</label> <div class="input login-inputs"> <input class="input-text" id="user_email" name="user[email]" placeholder="email" size="30" type="email" value=""> </div> </div> <div class="clearfix login-fields"> <label for="user_password">password</label> <div class="input login-inputs"> <input class="input-text" id="user_password" name="user[password]" placeholder="password" size="30" type="password"> </div> </div> </div> <div class="modal-footer"> <input class="btn btn-primary login_btn" id="btn_login" name="commit" type="submit" value="sign in"> <a href="/lms/forgot_password" class="btn">forgot password...</a> <a href="#" class="btn close cancel" data-dismiss="modal">cancel</a> </div> </fieldset> </form> 

and here test:

describe "login ", js: true, type: :request "should login correctly if right credentials given" capybara.default_wait_time = 15 capybara.ignore_hidden_elements = false visit new_user_session_path fill_in 'user_email', :with => 'example@test.com' fill_in 'user_password', :with => 'pwd123' p page.body click_on 'sign in' visit '/' save_and_open_page response.should have_content('welcome') end end 

the worst part when p page.body right before click_on see following code:

<html xmlns=\\\"http://www.w3.org/1999/xhtml\\\"><head></head><body></body></html>\ 

but if change p response.body.inspect full html code of page..., shouldn't visit method load content of response on page?

any appreciated, driving me crazy :)

add line:

config.include capybara::dsl 

to spec/spec_helper.rb:

rspec.configure |config| ..... config.include capybara::dsl ..... end 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

c++ - Accessing inactive union member and undefined behavior? -

php - Get uncommon values from two or more arrays -