docbrown/spec/system/articles/user_visits_an_article_spec.rb
Mac Siri fc39f24ee3 Migrate feature test to system test (#2301)
* Move all features to system

* Remove database_cleaner & apply use_transactional_fixtures

* Move rspec-retry to :test

* Update Capybara config

* Update rails_helper

* Fix user_visits_a_comments_page_spec.rb

* Fix lint
2019-04-04 12:15:10 -04:00

28 lines
798 B
Ruby

require "rails_helper"
RSpec.describe "Views an article", type: :system do
let(:user) { create(:user) }
let(:dir) { "../../support/fixtures/sample_article.txt" }
let(:template) { File.read(File.join(File.dirname(__FILE__), dir)) }
let!(:article) do
create(:article,
user_id: user.id,
body_markdown: template.gsub("false", "true"),
body_html: "")
end
before do
sign_in user
end
it "shows an article" do
visit "/#{user.username}/#{article.slug}"
expect(page).to have_content(article.title)
end
it "shows comments", js: true, retry: 3 do
create_list(:comment, 3, commentable: article)
visit "/#{user.username}/#{article.slug}"
expect(page).to have_selector(".single-comment-node", visible: true, count: 3)
end
end