Cześć,
przerabiam od nowa tutorial Hartl’a (najbardziej aktualna wersja). W rozdziale 11 mam problem z przejście testów Micropost Interface.
require 'test_helper'
class MicropostsInterfaceTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
end
test "micropost interface" do
log_in_as(@user)
get root_path
assert_select 'div.pagination'
# Invalid submission
assert_no_difference 'Micropost.count' do
post microposts_path, micropost: { content: "" }
end
assert_select 'div#error_explanation'
# Valid submission
content = "This micropost really ties the room together"
assert_difference 'Micropost.count', 1 do
post microposts_path, micropost: { content: content }
end
assert_redirected_to root_url
follow_redirect!
assert_match content, response.body
# Delete a post.
assert_select 'a', text: 'delete'
first_micropost = @user.microposts.paginate(page: 1).first
assert_difference 'Micropost.count', -1 do
delete micropost_path(first_micropost)
end
# Visit a different user.
get user_path(users(:archer))
assert_select 'a', text: 'delete', count: 0
end
end
Komunikat błędu:
FAIL["test_micropost_interface", MicropostsInterfaceTest, 1.501454597]
test_micropost_interface#MicropostsInterfaceTest (1.50s)
Expected at least 1 element matching "div.pagination", found 0..
Expected 0 to be >= 1.
test/integration/microposts_interface_test.rb:12:in `block in <class:MicropostsInterfaceTest
_feed.html.erb
<% if @feed_items.any? %>
-
<%= render @feed_items %>
users_controller.rb :
def show
@user = User.find(params[:id])
@microposts = @user.microposts.paginate(page: params[:page])
end
static_pages_controller.rb :
def home
if logged_in?
@micropost = current_user.microposts.build if logged_in?
@feed_items = current_user.feed.paginate(page: params[:page])
end
end
Nie mam pojęcia gdzie szukać błędu. Z góry dzięki za pomoc.
M.
PS. w pewnym momencie kod źródłowy przestał być wstawiany poprawnie - nie wyświetla go jako kod.