Ruby on Rails Tutorial Chapter 5.3

115 views
Skip to first unread message

Binu A.

unread,
May 20, 2015, 7:57:20 PM5/20/15
to rubyonra...@googlegroups.com
CODE site_layout_test.rb

require 'test_helper'

class SiteLayoutTest < ActionDispatch::IntegrationTest

test "layout links" do
get root_path
assert_template 'static_pages/home'
assert_select "a[href=?]", root_path, count: 2
assert_select "a[href=?]", help_path
assert_select "a[href=?]", about_path
assert_select "a[href=?]", contact_path
end
end



ERROR

This is what I see when I try to run the test :



FAIL["test_layout_links", SiteLayoutTest, 2015-05-19 22:21:27 +0530]
test_layout_links#SiteLayoutTest (1432054287.74s)
Expected exactly 2 elements matching "a[href="/"]", found 0..
Expected: 2
Actual: 0
test/integration/site_layout_test.rb:8:in `block in
<class:SiteLayoutTest>'

6/6: [===================================] 100% Time: 00:00:04, Time:
00:00:04

Finished in 4.45208s
6 tests, 11 assertions, 1 failures, 0 errors, 0 skips






What could be be the error ?

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
May 21, 2015, 3:10:07 AM5/21/15
to rubyonra...@googlegroups.com
Do you see the two links to "/" when you go to the page in a browser?

Colin

Shijie Xin

unread,
Jun 2, 2015, 10:16:57 PM6/2/15
to rubyonra...@googlegroups.com
inside app/views/layouts please check these two files

_header.html.erb
_footer.html.erb

add following code to both files

<li><%= link_to "Home", root_path %></li>

Binu A.

unread,
Jun 2, 2015, 10:20:04 PM6/2/15
to rubyonra...@googlegroups.com
Shijie Xin wrote in post #1174447:
> inside app/views/layouts please check these two files
>
> _header.html.erb
> _footer.html.erb
>
> add following code to both files
>
> <li><%= link_to "Home", root_path %></li>



Thanks its working

Hernan Baranda

unread,
Jun 15, 2016, 9:51:45 AM6/15/16
to rubyonra...@googlegroups.com
Shijie Xin wrote in post #1174447:
> inside app/views/layouts please check these two files
>
> _header.html.erb
> _footer.html.erb
>
> add following code to both files
>
> <li><%= link_to "Home", root_path %></li>

thanks, it worked for me too
Reply all
Reply to author
Forward
0 new messages