29 Jun 2011, 05:55
Generic-user-small

Christian N. (2 posts)

Hi, I’m working through chapter 8 and have modified the generated store_controller_test.rb file as instructed but I get the following failure when running my tests. I’ve verified my generate html doc and it appears that I have the <h3> with the correct value asserted by the functional test. I’ve pasted all of the relevant details below for review. Please advise?

StoreControllerTest: FAIL should get index (0.05s) <”Programming Ruby 1.9”> expected but was <”MyString”>. /Users/calvin_mbp2/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.0.beta1/lib/action_dispatch/testing/assertions/selector.rb:296:in `assert_select’

My test is as follows: class StoreControllerTest < ActionController::TestCase test “should get index” do get :index assert_response :success

# Verify our page and layout is rendered
assert_select '#columns #side a', :minimum => 4
assert_select '#main .entry', 3
assert_select 'h3', 'Programming Ruby 1.9'
assert_select '.price', /\$[,\d]+\.\d{2}/   end end

My Html document source is as follows:

<!DOCTYPE html>

Depot
Logo Pragmatic Bookshelf

Your Pragmatic Catalog

Ruby

Programming Ruby 1.9

Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programs delivered fast, you should add Ruby to your toolbox.

$49.50
Rtp

Rails Test Prescriptions

Rails Test Prescriptions is a comprehensive guide to testing Rails applications, covering Test-Driven Development from both a theoretical perspective (why to test) and from a practical perspective (how to test effectively). It covers the core Rails testing tools and procedures for Rails 2 and Rails 3, and introduces popular add-ons, including Cucumber, Shoulda, Machinist, Mocha, and Rcov.

$43.75
Wd4d

Web Design for Developers, 4th Edition

Awesome Web Design for Developers will show you how to make your web-based application look professionally designed. We'll help you learn how to pick the right colors and fonts, avoid costly interface and accessibility mistakes -- your application will really come alive. We'll also walk you through some common Photoshop and CSS techniques and work through a web site redesign, taking a new design from concept all the way to implementation.

$42.95
11 Nov 2011, 16:02
Faceonly_pragsmall

Jeff Dickey (1 post)

I have the same error.

StoreControllerTest
     test_should_get_index                                                FAIL
        <"Programming Ruby 1.9"> expected but was
        <"MyString">.
        Assertion at /Users/somebody/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_dispatch/testing/assertions/selector.rb:296:in `assert_select'

I find the whole coverage of testing to be one of the more glaring deficiencies in the book; devs coming from other languages/systems who have learned through painful experience that making effective use of your testing and coverage tools as part of the design-understanding and -validation epicycles in an agile process are going to be left confused and downright angry by this book. Nowhere in the Book is RSpec or RCov even mentioned, and the coverage of Test::Unit feels like something that was tacked on at the last minute because someone said “oh, hey, we’re calling this *Agile* Web Development with Rails”. By the fourth edition of a book, I expect the more egregious faults to have been ironed out. That they haven’t been in this case should not encourage anyone to buy more books from this author or publisher. I haven’t been this disappointed by a tech book in a decade.

11 Nov 2011, 17:01
Samr_small_pragsmall

Sam Ruby (584 posts)

Jeff: can you verify for me that you have updated your fixture?

http://media.pragprog.com/titles/rails4/code/rails31/depot_c/test/fixtures/products.yml

The following is the output you should be seeing:

http://intertwingly.net/projects/AWDwR4/checkdepot-192-31/section-8.4.html

As to RSpec and RCov, this book is about Rails and for better or worse Rails ships with test unit, so that’s what this book focuses on. If you want a book that focuses on testing, I suggest Rails Test Prescriptions: Keeping Your Application Healthy.

23 Oct 2013, 11:33
Generic-user-small

axel rigaud (2 posts)

I have the same problem, even though I did exactly what’s being said in the book

‘StoreControllerTest#test_should_get_index [/Users/axelrigaud/rails_projects/depot/test/controllers/store_controller_test.rb:17]: <Programming Ruby 1.9> expected but was <MyString MyText …..’

23 Oct 2013, 11:38
Generic-user-small

axel rigaud (2 posts)

And I also have this failure:

StoreControllerTest#test_should_get_index [/Users/axelrigaud/rails_projects/depot/test/controllers/store_controller_test.rb:16]: Expected exactly 3 elements matching “#main .entry”, found 1.. Expected: 1 Actual: 3

And I downloaded the last fixture file from the url provided in the book Any idea? I don’t like to move on if something is not fixed

13 Nov 2013, 00:23
Generic-user-small

Makis Otman (1 post)

I actually had the same problem and I fixed it by simply copying and pasting the code from the book here and here into my own code and for some reason, which I have yet to figure out, it worked.

I was looking if it could be a possible typo but could not see any. Hope that helps.

  You must be logged in to comment