メソッドは、クラスメソッドから呼び出しようとしているときにアクセスできないと "予期しています"。しかし、機能仕様から呼び出すときは正常に動作します。基本的に最後のメソッド(i_expect_to_see_article_on_home_page)は機能しません。Capybaraメソッドは、#<ArticleForm:0xb5e98bc>の「期待値」の未定義メソッドから受け入れられません
あなたが使用している構文に慣れ仕様/サポート/ ArticleForm.rb
require 'rails_helper'
class ArticleForm
include Capybara::DSL
def visit_home_page
visit('/')
self
end
def create_an_article
click_on('New Article')
fill_in('Title', with: "My title")
fill_in('Content', with: "My content")
click_on('Create Article')
self
end
def i_expect_to_see_article_on_home_page
visit('/')
expect(page).to have_text("My title")
expect(page).to have_text("My content")
self
end
end
スペック/機能/ article_spec.rb
require 'rails_helper'
require_relative '../support/ArticelForm.rb'
feature "home page" do
article_form = ArticleForm.new
scenario "Visit the home page and post an article" do
article_form.visit_home_page.create_an_article
article_form.visit_home_page.i_expect_to_see_article_on_home_page
end
end
記事の仕様に 'end'が多すぎます。あなたはそれを修正することができます –
あなたは何を得ているのですか? – fabersky
未定義メソッド 'have_content 'または 未定義メソッド' expect' for# 意味はありますか? exec –
Faisal