Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:59:50+00:00 2026-05-22T23:59:50+00:00

I want both, testing Ajax Content and normal toggled content through Javascript. My Setup

  • 0

I want both, testing Ajax Content and normal toggled content through Javascript.

My Setup is:

- Rails 3.1
- Rspec (Edge)
- Cucumber (Edge)
- Capybara (Edge)

For expample, I want to have a Form, which shows particular fields only, if a certain type of this model is selected:

Article can be an external article (url)
or an internal.
Type “externa_url” should show 2 input fields and 2 checkboxes more then Type “article”,
which has a body textarea instead.

Whats the best way to implement this, also with testing?

Should it be Server sided, so that partials are loaded, if a certain article type is selected,
or with javascript, toggle the needed html?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:59:50+00:00Added an answer on May 22, 2026 at 11:59 pm

    Actually inspired by Fransico (in the comments), I write down my knowledge.
    I write my own answer, it may helps others too….

    First I want to mention, I answer my question with – do integration testing only.
    With cucumber and selenium.
    And specific javascript testing with jasmine.

    But, when integration testing with cucumber (edge) rails (3.1), capybara and selenium you have to be aware of some things:

    Look, that you have all your gems updated!

    1) Activate your driver, if you haven’t already

    features/support/capybara.rb

    Capybara.javascript_driver = :selenium
    

    2) At the moment only Firefox <=4 works with webdriver selenium for rails, as I found out hardly after hours of configuring and installing each component from scratch, like rack etc.

    3) Capybara itself not handles much, which serves you for klicking e.g. on lists, jquery-tokeninput especially.

    3.1) I use this for selecting an Item from the tokens in the list:

    When(/^I select the option containing "([^\"]*)" in the Tag List/) do |text|
      find("li:contains('#{text}')").click
    end
    

    You may find this method with “locate” instead of find, don’t try this, api / driver has changed to find.
    Find waits automatically and check for a Ajax respond in addition of dom finding elements.

    4) Add your own helper / finder / click routines for your JS / Ajax responded code,
    keep in mind, it is “only” an integration test, you may want to test your JS code with yasmine or another js test framework.

    For furthter information also check Screencasts from Ryan Bates (http://railscasts.com), he covers several Topics on Testing Rails; check the latest one for Javascript e.g.

    Or this blog: http://openmonkey.com/2010/04/09/javascript-testing-with-cucumber-capybara/
    (thnx francisco)

    hope this helps someone else as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an input element, and i want bind both change and keypress event
I want to cast both MenuItem objects and Button control objects to an object
in my application i want to support both mass memory and memory card. but
I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7
I want to use CodeDOM to both declare and initialize my static field in
We want to be able to advance our business by utilizing both of the
I want to create a game that will work both locally and online. My
I have a WCF service and I want to expose it as both a
I want to increase the I/O priority of a process. Answers for both .NET
I want to union, merge in a List that contains both references, so this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.