Integration Testing Backbone.js application with cucumber and Capybara

I am trying to test a Backbone application running on top of Rails 3.2.8 using Cucumber, capybara, capybara-webkit, selenium-webdriver, rspec and jasmine. I use eco as a template engine for a basic template.

My problem is when I run the script using the @javascript tag using capybara-webkit or selenium, the page displayed does not contain all the model attribute data.

Here is the scenario:

@javascript Scenario : first scenario Given There is Model with "name" as name and "What is it about ?" as associated questions When I want to fill the questionnaire Then I should be on the SPA form And I should see "name" And I should see "What is it about?" 

The script crashes to β€œAnd should I see what it is?”, Step, the page does not display the question, but shows the β€œname”, I put several debug statements in my base code using console.log, and I see that the model is true with all its attributes. In addition, it works live without any problems.

The template looks like this: 'show.jst.eco'

 <p class="text-info"><%= @model.name %></p> <form id="quidget-form" class="form-vertical"> <% for question in @model.questions: %> <div class="issue_field"> <label class="string optional control-label"><%= question.question.question_text %></label> <div class="control-group text"> <textarea class="text answer" name="question-<%= question.question.id %>" id="question_<%= question.question.id %>" data-question="<%= question.question.question_text %>" rows="3"> </textarea> </div> </div> <% end %> <div class="controls"> <input type="submit" value="Additional Informations" id="quidget-step-one" class="btn btn-success"> 


A text box is displayed, but not the caption above with the question text

Any idea? I would like to see this passage so that I can test more complex logic with many steps.

thanks

+4
source share
1 answer

I also did research on these kinds of things. Most of them were centered around Ember.js instead of Backbone, but Pamela Fox just wrote a blog post about testing the Backbone.js interface for Coursera, this can be useful http://blog.pamelafox.org/2013/06/testing-backbone -frontends.html Also, have you tried testing with capybara in the same way as a general rails application with :js => true ? Maybe worth a try.

0
source

Source: https://habr.com/ru/post/1443305/


All Articles