2012-10-31 53 views
4

我想要測試運行在使用Cucumber,水豚,capybara-webkit,selenium-webdriver,rspec和jasmine的Rails 3.2.8之上的Backbone應用程序。我使用eco作爲骨幹模板的模板引擎。集成使用Cucumber和Capybara測試Backbone.js應用程序

我的問題是當我使用@javascript標籤運行場景時,顯示的頁面不包含所有的模型屬性數據。

下面是這種情況:

@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?" 

在「我看到‘?是什麼樣的’」步驟中的場景發生故障時,頁面不顯示的問題,但它顯示了「名稱「 我用console.log在我的主幹代碼中放了幾個調試語句,我可以看到該模型的所有屬性都是正確的。而且它是在帶電作業沒有問題

模板看起來是這樣的:「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"> 


顯示文本區域而不是上面的問題標籤文字

任何想法?我想看到這個通行證,所以我可以用更多的步驟來測試更復雜的邏輯。

謝謝

+0

這可能不是您希望的答案,但根據我的經驗,webkit和selenium並不太可靠。他們也不會讓您免於跨瀏覽器測試。你可以嘗試調試,但你可能花費更多的時間在它上面,而不是它的價值。我通常使用jasmine進行JS單元測試,然後手動檢查跨瀏覽器兼容性。 – fedenusy

回答

0

我一直在做這方面的一些研究。它大部分都是圍繞Ember.js而不是Backbone,但Pamela Fox只是寫了一篇關於測試Coursera的Backbone.js前端的博客文章,這可能會有所幫助http://blog.pamelafox.org/2013/06/testing-backbone-frontends.html另外,你有沒有試過用與你同樣的方式測試水豚?通用導軌應用程序:js => true?值得嘗試。

相關問題