Files
growstuff/spec/views/posts/index.html.haml_spec.rb
milesgould bb6e9e32e6 De-deprecate controller and view specs
We deprecated controller and view specs on the grounds that they were
brittle, and were a poorer measure of user experience than feature
specs. However, feature specs have their own problems: they're much
slower to run, and flakier (see #901). We also ran into a few cases
where feature specs erroneously passed because they were checking for
the presence of a string that occurred in the error page!

Hence, we're cautiously un-deprecating controller and view specs.

Fixes #1132
2017-11-24 19:02:54 +13:00

36 lines
1023 B
Ruby

require 'rails_helper'
describe "posts/index" do
before(:each) do
controller.stub(:current_user) { nil }
@author = FactoryBot.create(:member)
page = 1
per_page = 2
total_entries = 2
posts = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([
FactoryBot.create(:post, author: @author),
FactoryBot.create(:post, author: @author)
])
end
assign(:posts, posts)
render
end
it "renders a list of posts" do
assert_select "div.post", count: 2
assert_select "h3", text: "A Post".to_s, count: 2
assert_select "div.post-body",
text: "This is some text.".to_s, count: 2
end
it "contains two gravatar icons" do
assert_select "img", src: /gravatar\.com\/avatar/, count: 2
end
it "contains RSS feed links for posts and comments" do
assert_select "a", href: posts_path(format: 'rss')
assert_select "a", href: comments_path(format: 'rss')
end
end