1

I have a checkbox on a page that sends an AJAX call to a method in a controller. A User checks this box to indicate that they have selected this Item, and the relationship is stored in a join table called UserItems.

How would I go about testing this? I currently have:

check "add-this-item-"+item.id.to_s
@user.user_item.item.should include(item)

The checkbox has a name that is "add-this-item-" plus its ID. Using pry-nav, I have verified that it is finding the checkbox and selecting it - however the test database does not update.

The checkbox does update the database when using the site locally.

I can't seem to figure this out. Any help is appreciated!

1 Answer 1

2

You're going to need to use a Capybara driver that can run Javascript, like PhantomJS. The standard Capybara driver doesn't run Javascript, and thus wouldn't invoke click handlers or AJAX.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.