Rspec Selenium. Test to check certain Ajax functions passes when i expect it to fail.

Posted by alokswain on Stack Overflow See other posts from Stack Overflow or by alokswain
Published on 2010-03-31T09:51:17Z Indexed on 2010/03/31 9:53 UTC
Read the original article Hit count: 312

Filed under:
|
|

I am testing a Ajax action using Rspec and Selenium. My story is as follows:

it "should create a new User with any input" do

@browser.open "/people"
@browser.wait_for_page_to_load "2000"
@browser.type "user_name", "Alok Swain"
@browser.click "user_submit"
@browser.text?("Alok Swain").should be_true

end

The action i am testing is: def add_user @users = User.all User.create(params[:user])

render :update do |page|
  page.alert "Created User"
  page.replace_html "users", :partial => '/people/users_list', :locals => {:users => @users}
end

end

The test fails and the error I get is: 'User should create a new User with any input' FAILED expected false to be true.

This test should pass right ? I also kept an alert and tried @browser.is_alert_present.should be_true but i got the same error.

I tried @browser.is_text_present("test") and this test succeeded. In the test database a record was created for Alok Swain but when I tried the above assertion it passed when i expected it to fail.

Is there any thing else to be done here. What am I missing ?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about selenium