rspec-rails

    0熱度

    1回答

    我的任務是創建與我們的應用程序一致的自定義錯誤頁面。我發現https://wearestac.com/blog/dynamic-error-pages-in-rails它工作得很好。我沒有得到任何路由錯誤,並且手動測試顯示每個頁面都正確顯示。 但是,當爲控制器創建控制器規格用於將路由委託給視圖時,我遇到了一個問題。我的意見被命名爲404.html.erb,500.html.erb,422.html

    4熱度

    2回答

    我有一個Rails 5 API唯一的應用程序,並使用敲擊來進行JWT身份驗證。 完成模型和模型規範後,我開始執行請求規範。 但我不知道如何完成以正確的方式要求規範內部認證, 我的用戶控制器, module V1 class UsersController < ApplicationController before_action :authenticate_user, exce

    1熱度

    1回答

    我正在將測試單元中的測試重新寫入Rspec/capybara,我只是想弄清楚正確的語法。我想打root_path並檢查是否有一個指向'/'的鏈接(在標題中)。 老試驗的相關部分是: test 'layout links' do get root_path assert_select 'a[href=?]', root_path, count: 1 end 我可以使用測試使

    2熱度

    1回答

    我用一個簡單的測試 require "rails_helper" RSpec.feature "Home page", :type => :feature do scenario "When a user visit it" do visit "/" expect(page).to have_css('article', count: 10) end end 在我

    0熱度

    1回答

    我有一個Ruby on Rails應用程序,只是增加rspec-rails,我試圖運行: rails generate rspec:install 卻收到這樣的: /usr/local/bin/rails:23:in `load': cannot load such file -- /usr/share /rubygems-integration/all/gems/railties-4.2.6/b

    1熱度

    2回答

    我碰到一些可怕的看着RSpec的2個測試: something.should be 不,我不小心忘剪切+粘貼線, 就是它的休息! 那麼它的確切語義是什麼? should_not be_nil? 請在這爲什麼這是可怕的風格編鐘。 恕我直言,這是馬虎,不精確,並沒有明確表達什麼是必需的。 (它會觸發我的嘔反射;)

    1熱度

    1回答

    我正在爲RSpec測試編寫視圖並在嘗試填寫文本字段時出現以下錯誤。 1) coordinators/new.html.erb populate page name text entry field filled checks for presence of filled in text field Failure/Error: fill_in "coordinator_name", with:

    2熱度

    1回答

    如何爲活動記錄範圍編寫測試?例如 class Post < ActiveRecord::Base scope :recent, -> { order("posts.created_at DESC") } scope :published, -> { where("status = 1") } end 我使用RSpec測試, RSpec.feature Post, :typ

    1熱度

    1回答

    我有一段非常凌亂的Rails應用程序,我前一段時間建立了,目前正在擴展。這涉及Ruby版本(1.9.x到2.3.x),Rails版本(3.2.x到5.0.x)以及許多其他相關更改的一些重大更改。它有很多的瑕疵,我不確定此刻正在進行的很多事情。 爲了理清我爲自己創造的這個可怕的爛攤子,我決定用RSpec和水豚寫一堆功能測試。直到我需要測試使用Javascript的東西時,我才取得了很好的進展(最終我

    0熱度

    2回答

    我嘗試測試我的RoR應用程序。當我測試造成的ActionController :: RoutingError在我的控制器我獲得以下錯誤: 了1個衰竭等1個錯誤: 2.1) Failure/Error: expect(visit meters_path).to raise_error(ActionController::RoutingError) expected ActionContr