Я создал макрос для моего rails create_post_spec.rb v-5.2 ruby v-2.5.1 capybara v-3.2 '
мой макрос
spec / support / features / session.rb
module Features
def sign_in(user)
visit new_user_session_path
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_on "Log in"
end
end
затем включите в мой rails_helper
Rspec.confifure do |config|
config.include Feature, type: feature
end
в мой
spec / feature / create_post_spec.rb
require "rails_helper"
RSpec.describe"Создать пост" сделать
let(:user){ User.create(email: "example@mail.com", password: "password",
password_confirmation: "password")}
scenario "successfuly creating post" do
sign_in user
visit root_path
click_on "Create post"
fill_in "Title", with: "Awesome title"
fill_in "Body", with: "My rspec test"
click_on "Publish"
expect(page).to have_current_path root_path
end
scenario "unsuccessful creating post" do
sign_in user
visit root_path
click_on "Create post"
fill_in "Title", with: "Awesome title"
fill_in "Body", with: ""
click_on "Publish"
expect(page).to have_css ".error"
end
scenario "non-logged in user cant create post" do
end
end
я получаю неопределенный метод sign_in, но если я использую "функцию" в моем блоке
RSpec.feature "Create post....." do
, она работает
Интереснопочему это не сработает, если я использую «описать»
RSpec.describe "Create post....." do