は、だから私は実際にValid name
とValid content
と入力フィールドを記入していない私のRailsアプリRails。カピバラFILL_INは、テキスト入力を見つけたが、
require 'rails_helper'
feature 'As a signed in user' do
let(:user) {create(:user)}
let(:article) { create(:article)}
before {login_as(user, :scope => :user)}
scenario 'I can edit article with valid attributes' do
visit edit_article_path(article)
puts current_path
fill_in 'article_name', with: 'Valid name'
fill_in 'article_content', with: 'Valid content'
# save_and_open_page
click_button 'Update Article'
expect(article.name).to eq 'Valid name'
end
end
とfill_in
に、この機能の仕様を持ってFILL_INしません。私は保存してページを開くことによってそれをデバッグし、値は同じですので、私はそれが私のRailsアプリケーションではなく、Capybaraで何か問題はないと思います。他の将来の仕様では:
require 'rails_helper'
feature 'As a signed in user' do
let(:user) {create(:user)}
let(:article) { build(:article)}
before {login_as(user, :scope => :user)}
scenario 'I can create article with valid attributes' do
visit '/articles/new'
fill_in 'Name', with: article.name
fill_in 'article_content', with: article.content
expect {click_button 'Create Article'}.to change {Article.count}.by(1)
end
end
すべてが期待通りに動作します。私が得ているエラーは次のとおりです:
Failures:
1) As a signed in user I can edit article with valid attributes
Failure/Error: expect(article.name).to eq 'Valid name'
expected: "Valid name"
got: "Name1"
(compared using ==)
# ./spec/features/articles/article_update_spec.rb:15:in `block (2 levels) in <top (required)>'
スペックパスを行う理由は何でしょうか?
素晴らしい!ありがとう、それは問題を解決しました。 –