I am updating some specs to bring them into line with the latest rspec and capybara. These specs used to work and the application itself works.
The pages under test are built with Knockout JS and we bind the values during a document ready event handler. I am getting several failures that are consistent with the idea that the document ready event is not getting processed.
Here's a bit of the spec:
describe 'Create new User', :driver => :webkit, :focus => true do
before do
admin = FactoryGirl.create(:koan_admin)
sign_in admin
visit users_path
click_link 'New User'
end
it ('should have a New User legend') {should have_selector('legend', text: 'New user')}
it {should have_field('First Name', text: 'New')}
it {should have_field('Last Name', text: 'User')}
it {should have_field('Email', text: '')}
it ('should not show a Superuser checkbox') {should_not have_selector('#superuser', visible: true)}
# ...
Here's the result of running this set:
1) User pages Create new User
Failure/Error: it {should have_field('First Name', text: 'New')}
Capybara::ExpectationNotMet:
expected to find field "First Name" with text "New" but there were no matches. Also found "", which matched the selector but not all filters.
# ./spec/features/user_pages_spec.rb:43:in `block (3 levels) in <top (required)>'
2) User pages Create new User
Failure/Error: it {should have_field('Last Name', text: 'User')}
Capybara::ExpectationNotMet:
expected to find field "Last Name" with text "User" but there were no matches. Also found "", which matched the selector but not all filters.
# ./spec/features/user_pages_spec.rb:44:in `block (3 levels) in <top (required)>'
The First and Last name fields are failing. They should have their values set by the binding process in the document ready handler, but this does not seem to be happening. There are other tests further along that would not pass if javascript were not being processed and they are running correctly.
I did find one entry in Stack Overflow, but no responses. Hard to imagine that I'm the only one having this issue, but it seems real.
I am running:
capybara-webkit (1.0.0)
capybara (2.1.0)
rspec (2.13.0)
Any thought or hints would be appreciated.
Andy