Rspec Selenium. Test to check certain Ajax functions passes when i expect it to fail.
- by alokswain
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 ?