Hartl rails tutorial need help - regd "Test-driven development" introduction

36 views
Skip to first unread message

Arup Rakshit

unread,
Jan 11, 2014, 1:56:13 AM1/11/14
to rubyonra...@googlegroups.com
Hi,

I am getting some unexpected error which is not mentioned in the rails
tutorials(http://ruby.railstutorial.org/chapters/static-pages#sec-TDD) I
am following :


(arup~>sample_app)$ bundle exec rspec spec/requests/static_pages_spec.rb
F

Failures:

1) Static pages Home page should have the content 'Sample App'
Failure/Error: expect(page).to have_content('Sample App')
expected #has_content?("Sample App") to return true, got false
# ./spec/requests/static_pages_spec.rb:9:in `block (3 levels) in
<top (required)>'

Finished in 0.04079 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:7 # Static pages Home page
should have the content 'Sample App'

Randomized with seed 23303

=================

**expected #has_content?("Sample App") to return true, got false** is
not mentioned in the tutorial. What did I wrong?

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

Max

unread,
Jan 11, 2014, 1:30:09 PM1/11/14
to rubyonra...@googlegroups.com
please post the test code you're trying to run.  also, unless it's a lot of text, add the html for the page you're testing.

the test is looking at the html being returned by the rails controller to see if it has the text "Sample App" in it and it's failing because it's not finding that text.  the code for the test is around:  /spec/requests/static_pages_
spec.rb:7

The initial exercise shows text for a failing test - that text isn't exactly what you've posted in your results but the meaning is the same - it can't find "Sample App" in the response.  have you written the code to make the test pass yet?  you may be trying to be too literal in the tutorial and sometimes different versions of testing frameworks or versions of rails/ruby etc can affect some of those details.  not sure if that's what's happening here but i don't see a huge disconnect from what you've reported and what the tutorial is expressing.

hth,

Max


James Turley

unread,
Jan 11, 2014, 1:52:38 PM1/11/14
to rubyonra...@googlegroups.com
Boot up the server and look at the page in your browser. See if the phrase "Sample App" is on it (case sensitive), or if there's a nice big red error message.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0fba04c7-ca02-4d12-8a7d-8e8b4e34297e%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Arup Rakshit

unread,
Jan 11, 2014, 2:40:34 PM1/11/14
to rubyonra...@googlegroups.com
Max Maxwell wrote in post #1132841:
> please post the test code you're trying to run. also, unless it's a lot
> of

> hth,
>
> Max

Sorry! For the confusions.

I expect it to fail. What made me confused is - *expected
#has_content?("Sample App") to return true, got false*. Because the
tutorial is not showing this in the fail results. why does it come for
my case. That was my question. See the error as attached which was
mentioned in tutorial.

Attachments:
http://www.ruby-forum.com/attachment/9125/Screenshot_from_2014-01-12_01_09_44.png
Reply all
Reply to author
Forward
0 new messages