Document Ready Event not processed in integration test

21 views
Skip to first unread message

Andy Davis

unread,
Jun 23, 2013, 7:52:37 PM6/23/13
to capybar...@googlegroups.com
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



Andy Davis

unread,
Jun 24, 2013, 11:08:57 AM6/24/13
to capybar...@googlegroups.com
Not sure that this is actually a capybara-webkit issue.  I loaded in poltergeist last night and saw the same behavior.

I'd still welcome any hints, but I will start looking elsewhere.

Andy


This e-mail, including any attachments, contains information that may be confidential or privileged.  The information is intended to be for the use of the individual or entity named above.  If you are not the intended recipient, be aware that any disclosure, copying, distribution, or use of the contents is prohibited.
 
If you have received this e-mail in error, please notify the sender immediately by a “reply to sender only” message and destroy all electronic and hard copies of the communication, including attachments.

Reply all
Reply to author
Forward
0 new messages