By Developers, For Developers

Historical errata for Rails Test Prescriptions

<% end %>

PDF PgPaper PgTypeDescriptionFixed onComments
11TYPO

Who’s Burt? ;) (4th paragraph down, next to the burrito)

2010-04-26Sheesh.
14TYPO

2nd line of “What is TDD good for?”, one to too many ;)

2010-04-26
23TYPO

return line missing between assert_instance_of and assert_kind_of, just for eye candy ;)

2010-05-16This is a layout issue that needs to be worked out. UPDATE -- tried something different, let me know
73TYPO

Colon missing in symbol name (“active”) at bottom of page:

should_have_named_scope :active_only { active == true }

2010-04-26
76SUGGEST

Sample fixture data uses @slate.com for e-mail domain name. Is it better to use a domain that will most likely never exist, to avoid having someone’s misconfigured test suite somehow spam the Washington Post-affiliated news organization?

fred: first_name: Fred last_name: Flintstone email: fflint@slate.com
barney: first_name: Barney last_name: Rubble email: brubble@slate.com

2010-04-26Okay, it's slaterockandgravel.com
13TYPO

In the third paragraph, “Bert” becomes “Burt”

2010-04-26
19TYPO

2nd p
“the” for “then”:

But there are definitely cases where the cost of testing a feature like this is higher the the value of the tests.

2010-04-26
20TYPO

A word is missing:
With the basics covered, we’ll then talk about RSpec and Shoulda, which are two large frameworks that ??? lots of power and flexibility to your tests.

2010-04-26Pretty sure the word is "add"
37SUGGEST

Unfortunately, the Appendix A is empty and the code provided on pragprog does not contain an satrting project in order to be able to follow the process. The huddle one already has the tests implemented.

Moreover, it may be Rails 2.3.5 compliant.

2010-05-11Yes, Appendix A was inadvertently left out of the beta, this will be corrected in the next beta.
56TYPO

[…]although if you use RSpec you can test view partials directly directly […] There are 2 “directly”

2010-05-04
17TYPO

Repeated words: “…feature like this is higher the the value of the tests.” I believe it should be “higher than the value of the tests.”

2010-05-04
20TYPO

“There’s Always Some Version Confusion” breakout.

Last sentence, “Test::Unit 2.0 doesn’t seem to have much of constituency at the moment” should be “much constituency” or “much of a constituency”?

2010-05-04
32TYPO

double “the”

3. Run … encountered. If neither of those happens, the the test method passes. Yay!

2010-05-04
36TYPO

top of page.
“they” for “the”
in …Ruby code <> way …

(meaning that they can’t be arbitrary methods in the Ruby code they way they can be when calling new( ) or create( )).

2010-05-04
182TYPO

“James Golic” is “James Golick” (ck)

2010-05-04Well, that's embarrassing...
25TYPO

Last paragraph: -

“you can multiple setup blocks or methods” is missing a word. Use? Declare?

2010-05-04
29TYPO

In the footnote, 2nd line: -

“and IDE, for example” should read “an IDE, for example”

2010-05-04
211ERROR

Unfortunately the tests do not pass due to the “before_filter :require_user” as the generic functional tests were not updated. There may be an additional instruction there to fake a current logged in user.

2010-05-16Yes, this is true, and I'm not sure what the clearest way to resolve it is. It'll be fixed one way or another in the next beta
206TYPO

“Inside the migration, will put …” should be “Inside the migration, we’ll put …”

2010-05-16
143TYPO

on the second paragraph there are two “the”
“[…] (which allows you to directly verify the keys that will be in the the ensuing POST call)[…]”

2010-05-16
99TYPO

“[…]This test is a lot more difficult to write if you don’t explicitly know the value of the the project’s start_date. But keep reading…[…]”
there are two “the”

2010-05-16
174TYPO

“[…]Certainly there is much less online chatter about how and when to use the the built-in integration tests[…]”
There are 2 “the”

2010-05-16
204SUGGEST

the order of the commands-events should be
% rails huddle
«many lines of response»
% cd huddle

2010-05-16
27SUGGEST

You can mention the Bob Martin’s SOLID butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod that are a nice recompilation of design principles. In
blog.objectmentor.com/articles/2009/02/12/getting-a-solid-start also is a very paint metaphor

2010-07-26I'm not sure what this comment refers to?
41ERROR

“This particular fixture data was added to the project by Authlogic.” I’m afraid it wasn’t for me. I’m using Rails 2.3.5 and Authlogic 2.1.3.

2010-05-16Okay, that was a mistake -- the fixture actually comes from the authlogic example http://github.com/binarylogic/authlogic_example. \n \nI clarified that in the book, but I might look for a different way to set up that test.
96ERROR

In the last paragraph, the descriptions for Factory.build and Factory.create methods are interchanged. It should go like this:

Create and save an object:
Factory.create(:project, :name => “New Project”)

Create but don’t save:
Factory.build(:project, :name => “New Project”)

2010-05-16
204ERROR

I’m not sure if the issue is mine, but I’ve been through Appendix A and followed all the steps. However, when I run ‘rake’, all the tests fail:

1) Failure:
test_should_create_project(ProjectsControllerTest)
[(eval):3:in `each_with_index’
/test/functional/projects_controller_test.rb:16:in `test_should_create_project’]:
“Project.count” didn’t change by 1.
<3> expected but was
<2>.

…

15 tests, 13 assertions, 12 failures, 2 errors
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test “/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb”
Errors running test:functionals!

Is this expected?

I have downloaded the sample code, but it is the completed version, and obviously I would prefer to go through the process of building the tests in along with the book.

2010-06-05I've seen the code now: \n \nOkay, I see the problem now, I ask you to add the "before_filter :require_user" line to the application_controller.rb -- that's requiring logged in users, but the tests don't provide logged in users at first. \n \nTake that line out, and everything should be fine. See section 3.4 to show how logins need to be handled in controller tests. I'll fix the appendix for the next beta. \n
17TYPO

4th paragraph: “Still, it’s useful to keep this mind as a goal, and most” I believe it should be: “Still, it’s useful to keep this goal in mind, and most”

2010-05-21
92TYPO

FixtureReplacement, Machinist and ObjectDaddy examples printed twice

2010-05-21
78SUGGEST

It is not obvious what the name of the YAML file in first piece of code should be. It would be nice to know if it should be users.yml or user.yml, and why.

2010-06-05
80SUGGEST

In the description of has many relationship, it would be nice to see an example of how to set up has many attributes in a YAML file.

2010-07-05
92TYPO

In “Creating an individual Factory”, there is duplication of the code for FixtureReplacement, Machinist and Object Daddy.

2010-06-05
225ERROR

The “script/generate session user_session” command does not work in Rails 3 and no work around is mentioned for it in book… This entire section is very confusing as the author keeps skipping around from Rails 2 to Rails 3. There probably should be a different section for installing Authlogic with Rails 3 and one for Rails 2.3.5.

2010-07-05My understanding is that there is no current workaround for generating the Authlogic session in Rails 3. \n \nThe appendix will be re-structured once all the Rails 3 pieces are in place and it's more clear how different the steps are.
28TYPO

What’s particularly nice about this is that—as with before filters—you can haven multiple setup blocks or methods, and they will all be exe- cuted before each test:

You probably meant to write “you can have multiple setup blocks”…

2010-06-05
227TYPO

as a call -> is a call

“All the User class itself needs as a call to the acts_as_authentic( ) method.”

Could be interesting to explain exactly what the acts_as_authentic( ) method does, too.

2010-07-26I'll see what I can do, but I think that's kind of out of scope, also the switch to devise causes this text to be removed
37TYPO

Extra closing paren on page 37:

If the key is an association, the value represents the name of a fixture in the related table (or a comma-separated list of fixture names for a one-to-many relationship). If we do specify an id in the YAML file, the nifty auto- association feature will not work).

2010-06-05
13TYPO

In paragraph 4, lines 4 and 5, Bert gets misspelled Burt twice.

2010-07-05
224ERROR

After following the instructions for the app in Appendix A, running rake gave me:
3 tests, 0 assertions, 0 failures, 3 errors
15 tests, 0 assertions, 0 failures, 15 errors

All errors were of the “ActiveRecord::StatementInvalid:” type. Moseying around on the internets this is an issue that was fixed with this patch: in Rails 2.3.8 which I am running. I believe the problem had been with quotation marks. Further investigation turned up this thread: which seems to show that setting null to false may play a role.

While going through the prior reported errata I saw #43242 which recommended the removal of before_filter :require_user in application_controller.rb which I tried but this did not alter my rake output in any discernible way.

I am running Ubuntu Lynx with:
Ruby-1.8.7-p249 installed via rvm
Rubygems 1.3.7
Rails 2.3.8
sqlite3 3.6.22
sqlite3-ruby 1.3.0

2010-07-05Anita told me in private email that this is a Rails error.
13TYPO

In footnote 5, “Bert’s” should be “Bert” instead.

2010-07-05
24SUGGEST

The last example on the page is introduced with a paragraph ending with, “You can negate this assertion with the converse method assert_not_equal():”, but the example uses assert_equal(). That seems dissonant. Moving the example to, e.g., after the first sentence in the paragraph (“The most commonly used assertion is assert_equal()…”), might cure that dissonance.

2010-07-05
24TYPO

The next-to-last paragraph ends with a colon, but there is now example following it.

2010-07-26
245SUGGEST

On section A.1 Basic Rails after “Let’s start with the basics”

we have the command to create the huddle example application:
% rails huddle

Running that on Rails 3, gives the usage of the command rails, as it has changed from versions 2.x.
Shouldn’t it have a note that it should be:

% rails new huddle

2010-07-26The appendix is not fully Rails 3 compatible yet.
246SUGGEST

Just after the line:

gem “authlogic”, :git => “git://github.com/binarylogic/authlogic.git”

Don’t we need a line to describe briefly how to use bundler to install the gems, after modifiying the Gemfile?

as in:

bundle install

2010-07-26The appendix is not fully Rails 3 compatible yet.
21SUGGEST

When dealing with the declarative syntax of a test
(In the newer style (Rails 2.2 and up), a more declarative syntax can be
used with the method test( ) :)

it could be useful to mention that using non-ascii character in the name will cause the test not to be executed. It will just silently not run.

I noticed this when testing the “saving a status report that has a date doesn’t override”, because I renamed the test in french.

This might be caused by my particular setup, though : rails 3 beta 4 with Jruby.

2010-07-26
47TYPO

The examples are dealing with reports, not tests.
I guess

test “a test with both blank is not valid”

should read

test “a report with both blank is not valid”

2010-07-26
47SUGGEST

could be useful to mention that in rails 3, the third test does not fail. The autogenerated test is
" test “should create status_report” do
assert_difference(‘StatusReport.count’) do
post :create, :status_report => @status_report.attributes
end

@status_report.attributes is added, in contrary to rails2.3

2010-07-26Fixed in Rails 3 update
47SUGGEST

On the second line of the test “saving a status report saves the status date”, there is fix to the test by adding:

actual=StatusReport.new(:today => “t”, :yesterday => “y”)

Testing with Rails beta 4, the test passes without the fix, as the scaffold code has the following:

post :create, :status_report => @status_report.attributes

Should it be a mention about the difference?

2010-07-26
49SUGGEST

In the validate_has_at_least_one_status method the line:

errors.add_to_base(“Must have at least one status set”)

when using Rails 3 should become:

errors[:base] << “Must have at least one status set”

2010-07-23
89TYPO

Missing comma in the last paragraph, between “… placing them in the ActiveRecord class” and “reopening the class by…”

2010-07-26
250SUGGEST

In method store_location the line:

session[:return_to]= request.request_uri

when used in Rails 3, should be replaced with:

session[:return_to] = request.fullpath

2010-07-26This is authlogic boilerplate that is out of the text in beta 5
51TYPO

The line:

Despited not adding any new tests, …

should be:

Despite not adding any new tests, ….

2010-07-26
52SUGGEST

In the line that adds the setup method login_as_ben, ie :

setup :login_as_ben

to be added in top of the two controller tests, projects_controller_test and status_reports_controller_test

when used in Rails 3, there is already a setup method added so it should be:

setup do
@status_report = status_report(:one)
login_as_ben <— line added
end

and similarly in the projects controller test:

setup do
@project = projects(:one)
login_as_ben <—- line added
end

2010-07-26I actually prefer to keep them as separate setup commands.
65SUGGEST

Line :

named_scope :by_user_name …

should be:

scope :by_user_name

in Rails 3

2010-07-26
220SUGGEST

We used rcov on our previous (1st) rails project, and it was great. But when we moved to using ruby 1.9.1 along with rvm, I find I can’t run rcov in this environment. The relevance rcov site claims they are still working on 1.9.1 compatability. I think you need to write a big box about this, as other people will also get stuck.

2010-08-11
42TYPO

There is no user defined as :ben, so either the test symbol should change or the fixtures definition on the next page( and in the appendix.)

2010-08-11
57TYPO

In the code example there is a duplicate line of code

2010-08-11
61ERROR

I think you’re missing trailing _id for both the user and project dom IDs.

2010-08-11
67TYPO

instead of:
include ActionView::Helpers::RecordIdentificationHelper

use:
include ActionController::RecordIdentifier

2010-08-11
87TYPO

Instead of:
url { “#{name.downcase}.gsub!(” “, ”_“)” }
it should be:
url { “#{name.downcase.gsub!(” “, ”_“)}” }

2010-08-11
166TYPO

last paragraph
Instead of: rake:javascript
should be: test:javascript

2010-08-11
181TYPO

instead of:
expected_users = initial_user_expectation.map { |sym| users(sym).id }
should be:
expected_users = expected_users.map { |sym| users(sym).id }

2010-08-11
33OK

Figure 2.2: Should it read “Initial Database preset” or “Initial Database reset”? The text describes “clearing” the database of all data on the previous page (p. 32).

2010-09-02
263TYPO

Paragraph after “$ rails generate devise User”:

This creates a user model, with tests, a database migration, and a route that references the devise engine. The fixture file created for a user is invalid – it doesn’t have any data, and the tests are going to changes.

changes > change

2010-09-02
2525TYPO

…assert( ) and all the other Test::Unit assertion methods takes an optional last argument…

Should read:
…assert( ) and all the other Test::Unit assertion methods take an optional last argument…

2010-09-02
50ERROR

Replace the validation line in app/model/status_report.rb with the following:

BEGIN INSERT
validate :validate_has_at_least_one_status

And write the corresponding function:

END INSERT

def validate_has_at_least_one_status
if today.blank? && yesterday.blank?
errors[:base] << “Must have at least one status set”
end
end

NOTE: The current instructions direct the reader to replace the “validate_presence_of :yesterday, :today” line of code with the “def validate_has_at_least_one_status … end” function shown on the page. For anyone new to Ruby and/or Rails (and not just TDD), he won’t easily figure out that he’s missing a “validate :function_name” call, and that the function definition needs to be separate.

2010-09-02
51TYPO

Section 3.4, after the numbered list:

“In order to enforce an Devise login globally throughout the app…”

an > a

2010-09-02
277TYPO

In the following paragraph, towards the end of the page, it’s talking about Devise but it still says “to get the Authlogic gem included”

—
In Rails 3.x, gems are managed in bundler. You need to add the following line to your Gemfile to get the Authlogic gem included.
gem “devise”, “1.1.rc2”
—

2010-09-02
21TYPO

Missing end-of-sentence period. Final sentence of first paragraph.

“The user-facing section will cover controllers, view testing, test- ing your Rails helpers, and testing Ajax calls with Blue Ridge”

2010-09-02
115ERROR

The “any_of(…” code is certainly tangled! I think there may be a misplaced closing parenthesis: should

proj.stubs(:thing).with(any_of(instance_of(String)),
instance_of(Integer)).returns(“Argh” )

actually be

proj.stubs(:thing).with(any_of(instance_of(String),
instance_of(Integer))).returns(“Argh” )

?

IOW, I think any_of() should contain the list of accepted instances.

2010-09-02
112112TYPO

The last para on the page starts “A related gotcha to watch out when using…”

Should that be “… watch out for …” ?

2010-09-02
54TYPO

… noel = User.create!(:email => “railsprescriptions@gmail.con” …

gmail.com, not gmail.con

2010-09-02
263TYPO

In the gray box, last paragraph, second sentence: “… the kind of testing testing weight we want to put in it.” Should “testing testing” be removed?

2010-09-02
252ERROR

original text:
In Rails 3, that first command is:
script/rails generate cucumber:skeleton —testunit —capybara

should be cucumber:install, not cucumber:skeleton

The generators available with cucumber-rails 2.0.0.beta.20 are:

Cucumber:
cucumber:feature
cucumber:install

2010-10-05
52TYPO

The end of the first paragraph on the page reads:

“For Rails 2.x, A similar change needs to be made in test/functional/status_reports_controller_test.rb:”

But there’s no code before the next paragraph begins.

2010-10-05
54TYPO

Last paragraph on page reads:

“In order to enforce an Devise login…”

an > a

2010-10-05
55TYPO

In the middle of the page, the first code snippet’s indentation is off.

2010-10-05
55TYPO

In the middle of the page, between two code snippets, the paragraph reads:

“Then, in the body of the ActiveSupport::TestCase declaration in the same file, add the following methods:”

“Methods” should be singular, or a method is missing.

2010-10-05
64TYPO

The last paragraph on the page reads:

“Our first view test will just validate that the form elements actually exist in as we want them to…”

Remove “in.”

2010-10-05
65ERROR

Lines 4 and 5 refer to project_id and user_id, respectively, but Rails 3 scaffolding generated fields for project and user, not project_id and user_id. Suggested change:

assert_select “#status_report_project”, :count => 0
assert_select “#status_report_user”, :count => 0

2010-10-05
71ERROR

In the view code at the bottom of the page, <%= h … %> is now the default in Rails 3, so the “h” is unnecessary. Can be changed to:

Yesterday I: <%= report.yesterday %>
Today I will: <%= report.today %>

2010-10-05
85TYPO

Fourth line in the last paragraph on the page:

“… fixtures that are available out of the box are a defined in a set of …”

Remove first “a” so it reads: “… fixtures that are available out of the box are defined in a set of …”

2010-10-05
214TYPO

“a little to far” should probably be “a little too far” (double “o” in “to”)

2010-10-05
92SUGGEST

You may want to tell readers (especially Rails newbies) WHERE the “setup { Sham.reset }” code snippet goes inside the test_helper.rb file. I’m assuming it goes inside the ActiveSupport::TestCase class, right?

2010-10-05
92SUGGEST

For the last code snippet on the page, what file does this go in?

2010-10-05
93SUGGEST

Wherever there is a block of code that should be inserted into a file, tell the reader WHAT file the code belongs in and WHERE it goes in that file (e.g., inside or outside a class, before this line, after that line, etc.)

If a code snippet doesn’t belong in any particular file and is for demonstration purposes only, let the reader know, or include a section at the beginning of the book that covers different conventions used throughout and what they mean.

2010-10-05
97TYPO

Section 6.10, end of first paragraph reads:

“… though at at least with factories, new tests can avoid the global data.”

One too many of “at”.

2010-10-05
107SUGGEST

In the Timecop section at the bottom of the page, the end of the first paragraph mentions putting a reference to it in the environment.rb file.

If Rails 3 is what you’re referring to by default (as mentioned at the beginning of the book), then you should change this reference to Gemfile, instead.

2010-10-05
117OK

Adding the “lets stub a class” test breaks the “should be able to retrieve projects based on day” test. The error message is as follows:

<[“2009-01-06”, “2009-01-07”]> expected but was
<[]>.

Running (with rvm 1.0.11):

- ruby 1.9.2-p0

- rails 3.0.0

- factory_girl 1.3.2
- mocha 0.9.8

Can anyone else confirm this?

2010-10-08I can't reproduce this.
267ERROR

Don’t use the :user symbol as a parameter to the create! method. Doing this results in the error:

When they have entered their account information # features/step_definitions/user_signs_up.rb:5
wrong number of arguments (2 for 1) (ArgumentError)
./features/step_definitions/user_signs_up.rb:6:in `create’
./features/step_definitions/user_signs_up.rb:6:in `/^they have entered their account information$/’
features/user_signs_up.feature:9:in `When they have entered their account information’

If you get rid of that parameter, Cucumber won’t complain anymore and move on to the next item that needs to be checked.

2010-11-18
314TYPO

“Auotest on the Mac” should be “Autotest on the Mac”

2010-11-18
23TYPO

The word Javascript has lost its last t and appears as “Javascrip test frameworks”

2010-11-18
33SUGGEST

There is severe margin overlap on the filenames on this page. Also, the figure looks like it has a bounding box on the app/ filestructure.

2010-11-23Overlap will be handled in typesetting
62TYPO

In the phrase “individually test an view partial”, “an” should be “a”.

2010-11-18
31ERROR

Hello,

I have a problem with the following section :
“This is not recommended in Rails 2, though, because the inside of the
block is evaluated in class context—you can initialize global or class
settings, but you can’t create instance variables that are accessible
from your tests. In Rails 3, the block is evaluated in class context.”

This sentence seems to imply that rails 2 and rails 3 are different, but ends up saying that both version of rails evaluate the block in class section. Arent “setup” and “teardown” executed differently in rails 3, like the beggining of the paragraph seem to say ?

Sorry if it’s just me not understanding the paragraph.

Regards,
Thierry

2010-11-18It's a typo, the Rails 3 section should be "instance" context.
69SUGGEST

In app/model/status_report.rb block, while the code for the named scope works, it is the old Rails 2.3 method. The Rails 3 method might read more like this:

scope :by_user_name, includes(:user).where(“user_id IS NOT NULL”).order(“users.email ASC”)

2010-11-18
185SUGGEST

Noel, I’m currently starting a new project, and I decided to use Shoulda for the testing. But I’m half way stuck on testing a destroy controller method. The old test/unit way would be to use assert_difference, but I don’t think that will work with shoulda. So, what I would like is a an example of testing all the usual controller methods (index, new, create, edit, update, show, destroy) using shoulda tests.

At the moment, I am going to do something like:
context “in destroy” do
setup { recs = Model.count; delete :destroy, :id => model.id } should "model count should be one less" do assert_equal recs - 1, Model.count
end
end

2010-11-23This is out of scope for errata, please take it to the forum.
185SUGGEST

Noel, this may actually only be a suggestion. In the second last paragraph on this page, you say redirect_to takes any url-convertible object. Of course, I want to use the handy path and url methods setup for the controller, e.g.
context “on some page” do
should redirect_to(products_path)
end

Sadly, because the one liner is at the class level, products_path is an undefined method. Instead, I had to change the test to:
should(“redirect to products_path”) { redirect_to(products_path) }

Now the test block is executed as an instance method of the controller test, and therefore it can invoke the path and url methods.

Finally, I got myself one of the new Kindles, and have been reading your book on it. You’re doing a great job with the writing, and the Kindle makes it easier to read than a big heavy paper book.

2010-11-23What error did you get? I think this should work, but I think I need to see the entire code snippet. Please take this to the forums.
27TYPO

In the second paragraph, third sentence, you say: “That’s good practice, and is enforced by the structure of Test::Unit or Rails.” Should this read “Test::Unit for Rails,” or “Test::Unit and Rails,” or something else? It’s a minor point, but I find the phrase a bit confusing.

2010-11-18
317SUGGEST

In the Auotest on the Mac block the text says that you need to install both the ‘autotest-growl’ and ‘autotest-fsevent’ gems in order to use the OS X FSEvent library.

However, I found that the ‘autotest-growl’ gem isn’t necessary for this. I have it working with only the ‘autotest-fsevent’ gem installed.

2010-11-23That appears to be correct per the docs.
31ERROR

In the setup method the test users are assigned to local variables and are not available inside the test blocks. They should be assigned to instance variables.

2010-11-23
113OK

“let’s stub a class” test breaks previous “should be able to retrieve projects based on day” test (p. 67) in project_test.rb. It seems like stubbing the find method of the Project class affects other tests.

I went through the book from the beginning twice, now, and ran into this problem each time.

2011-01-19I cannot reproduce this. Could you take this to the forum with the entire test code as you have it and with the exact error?
22TYPO

But there are definitely cases
where the cost of testing a feature like this is higher then…

Should be:

But there are definitely cases
where the cost of testing a feature like this is higher than…

2011-01-07
207TYPO

“but any of application-specific helper modules that you plan on calling need to either be explicit”

should be:

“but any of the application-specific helper modules that you plan on calling need to either be explicit”

2011-01-07
49ERROR

In the “saving a status report saves the status date” test, is there a reason that the dates must be converted to strings in the assertion? They are both Date objects.

It seems that the following would be the correct test:
assert_equal(Date.today, actual.status_date)

The next paragraph then seems incomplete.

“The test, of course, fails. Once again, in line 4, we’re comparing literal string objects rather than the dates.”

It hints at an explanation of the string comparisons but stops short.

It is possible that it is referring to the previous test (StatusRerortsControllerTest) but that wouldn’t apply since it was comparing DateTime and Date objects and thus the string conversion was necessary.

2011-01-07
41SUGGEST

After a generic introduction to fixtures, page 41 of the PDF starts out with what looks like a link to “huddle/test/fixtures/project.yml”. It goes on to say “Add this snippet… (don’t delete the existing fixtures…”. This makes it sound like this is part of an ongoing setup of some project called “huddle”, but I believe this is the first mention of it. It’s kind of confusing…

2011-01-07You are right, that paragraph came from an earlier draft where this section was after the huddle project was introduce
45TYPO

At the bottom of the page, there is a missing word in: “Shoulda and Contexts, on page 171 and Chapter 12, Rspec, on page 187 and .”

2011-01-07
49TYPO

Should the footnote read, “more readable error messages THAN when the values are both dates”?

2011-01-07
198TYPO

“Fair warning, though — there a definitely Ruby”… should be “there ARE definitely…”

Whoops, incorrect “.should” syntax :-)

2011-01-07
200TYPO

“In the line 3, the block is effectively…” Shouldn’t that start out just “In line 3,…”?

2011-01-07
202TYPO

Should “And similarly, for users:” be “And similarly, for status reports:”?

2011-01-07
203TYPO

The text has, “Project.stub!(:find).and_return(mock_project)”. However, on page 196, it says that in RSpec2, the method convention is to use “stub” (no exclamation point).

2011-01-07
207TYPO

“key/value pairs, as in have_selector(have_selector(”form“, …” I think there is an extra “have_selector(” in there.

2011-01-07
213TYPO

“expected = Ingreditent.new(hash” — there is only one “t” in “Ingredient”.

2011-01-07
168TYPO

Line at the top of the page, “save_fixture(response.body…” has an extra close paren.

2011-01-07
90TYPO

“Inside that block, factories can be declared do define default data.” Lovely alliteration :-) but I think you want “be declared TO define default data.”

2011-01-07
91TYPO

The line ‘test “machinist url” do’ perhaps shouldn’t used “machinist”, since you’ve switched to factory_girl?

2011-01-07
40OK

the line
“The directory test/fixtures is expected to contain a YAML file”
we may add “or a CSV” at

2011-01-07That is not a feature that I want to encourage or even acknowledge
323TYPO

Under the section “A.2 Devise,” first paragraph, second sentence: “chose” should be “choose.”

2011-01-07
0SUGGEST

Highlighting the changed lines (added, modified, and maybe removed lines) of code will help follow-up faster with the code.

71TYPO

show.html.erb tags indentation

2011-01-07
40TYPO

…less commonly used and the tools that are used instead…

2011-01-07
71SUGGEST

show.html.erb has lists the users for each project.

However, if you go through the book sequentially, this doesn’t work.

The following needs to be removed as it is not in the downloaded code either:

Users for <%= project.name %></h2> <table border="0" width=""> <% project.users.each do |user| %>

<%= user.login %>

<%= user.email %>

Otherwise, the following errors keep coming up:

1) Error:
test_index_should_display_project_timeline(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users’ for #
app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1178292322_2175232780_0’
app/controllers/projects_controller.rb:19:in `show’
/test/functional/projects_controller_test.rb:63:in `test_index_should_display_project_timeline’

2) Error:
test_project_timeline_index_should_be_sorted_correctly(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users’ for #
app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1178292322_2175232780_0’
app/controllers/projects_controller.rb:19:in `show’
/test/functional/projects_controller_test.rb:55:in `test_project_timeline_index_should_be_sorted_correctly’

3) Error:
test_should_show_project(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users’ for #
app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1178292322_2175232780_0’
app/controllers/projects_controller.rb:19:in `show’
/test/functional/projects_controller_test.rb:31:in `test_should_show_project’

2011-01-07Yeah, that's from the Cucumber chapter, and should only show up there. 89TYPO

In section 6.5, second paragraph, first sentence: “FixtureReplacment” should be “FixtureReplacement.”

2011-01-07 90TYPO

Section 6.7, paragraph 2, last sentence: I think “test/factory.rb” should be “test/factories.rb.”

2011-01-07 96OK

In the “Factories and RESTful Authentication” box, second paragraph, second sentence: “that’s a name crash” should be “that’s a name clash.”

2011-01-07No, I want it to be crash 168TYPO

“It cleans up third party scripts be removing…” should probably have “BY removing…” instead.

2011-01-07 23TYPO

Last paragraph, line beginning “testing, and part…” The word Should seems like it ought to be Shoulda, the name of the testing framework.

2011-01-07 32OK

I think footnote .2 ought to be marked .1 instead, since it is ( in this version of the text) the first and only footnote on the page. Not a big deal, just a minor detail.

2011-01-07Footnotes are numbered by the chapter in the PDF version 34TYPO

In the final sentence on the page, “associate test directory” should be “associated test directory”.

36TYPO

Arguably a matter of taste, but in the first sentence of the third paragraph, “Performance tests are different than” should probably be “Performance tests are different from”.

I’d post a reference if the form didn’t block me from doing so, but “different from” gets more than 13 times the usage of “different than” in written American English.

55SUGGEST

Console output where it refers to a line of code does not correspond to that line in the source code that one downloads from PragProg.com

i.e.(see Pg. 55 in PDF)
1) Failure: test_a_test_with_today_blank_is_valid(StatusReportTest) [/test/unit/status_report_test.rb:36]: is not true.

line 36 is an empty line. i think it’s referring to line 39.

179TYPO

on the third paragraph there are a repetition of the word “ActionMailer”:

Shoulda defines specific one-liners for ActionController, —>ActionMailer<—,
ActionView, ActiveRecord, and —>ActionMailer<—.

48ERROR

Re: the Users fixture, you say:

This particular fixture set was created in Appendix A, on page 323, and it defines the data object accessed as users(:one).

I don’t find that reference on page 323 or anywhere else.

63ERROR

Sentence 2 on the page states that “filter methods can’t take arguments”.

They can, if you use a lambda. For example:

before_filter lambda { redirect_if_not_current_user(params[:status_report][:user_id]) }

76TYPO

The objects created in each of the “full name” tests use variable “u1”. The assert_equal assertions though use variable name “user.” Also, should the User method be “full_name” and not “full name”? For example, maybe the first test should be written:

test “full names” do
u1 = User.create(:first_name => “Fred”, :last_name => “Flintstone”)
assert_equal(“Fred Flintstone”, u1.full_name)
end

This applies to each of the three tests listed at the end of section 5.3.

203TYPO

On first line of page.

… intstance_of?()…

154TYPO

line #2
easer to test;

158TYPO

Bunder should be read Bundler

120TYPO

as as should read as

176TYPO

“Shoulda defines specific one-liners for ActionController, ActionMailer, ActionView, ActiveRecord, and ActionMailer.”

ActionMailer listed twice (ok, so it’s not a biggie ; )

9084SUGGEST

At the bottom of the page, Factory.next(:name) is deprecated.
This can be written as Factory.create(:name) instead.

183180ERROR

gem ‘zebra’ in a rails 3 application didn’t work for me and I couldn’t find it via gem search. Also Google is not helpful.
So either I’m too dump or for that matter there are some additional steps necessary.

73TYPO

“The assert_valid() test, which verifies that an ActiveRecord model is—wait for it—valid according to the rules of that model.”

It appears assert_valid() is deprecated now (I get NoMethodError with Rails 3.0.x, and I see lots of forum posts from people upgrading to Rails 2.3.x and having their tests break).

One person had a good idea: Reimplement it as a test helper which dumps out the error(s) so you can easily see why it didn’t validate:

def assert_valid(record)
assert record.valid?, record.errors.full_messages.join(“\
”)
end

82TYPO

Line 9 of the Fred-and-Barney fixture example has:

email: brubble@slaterockandgravel.com/

There is an extra trailing “/” on the end of the email address.

90SUGGEST

The string defining the :name sequence uses an underscore:

sequence :name do |n|
“Project_#{n}”
end

Since all the previous examples of project names in this section use spaces, not underscores (like “Soups Online”), and since the url method changes spaces to underlines, etc., you probably wanted the sequence for :name to use a space?

sequence :name do |n|
“Project #{n}”
end

88SUGGEST

All the previous chapters have showed how to use the tools being discussed by having you add to the Huddle project, which is a learn-by-doing style that I really like. I suggest in the next edition of the book, you consider doing this for the factories chapter — when I reached the place in this chapter that said “By default, the blueprints go in test/factories.rb” it wasn’t clear to me whether I was supposed to actually be copying the listed code into that file, and expecting it to do something in Huddle.

112TYPO

Project.stub(:find).return(bluebook) should read Project.stubs(:find).returns(bluebook)

112TYPO

In a factory universe, with only a couple of
object defined, that may not be a difficult constraint to live with.

s/object/objects/

111ERROR

bluebook = Project.make(:name => "Project Bluebook") runway = Project.make(:name => “Project Runway”)

s/make/new/

112ERROR

@bluebook = Project.make(:name => “Project Bluebook”)

s/make/new/

54ERROR

include Devise::TestHelpers
needs to be outside “class ActionController::TestCase”, isn’t it ?

105ERROR

Second example cites the following:

bluebook = Project.make(:name => "Project Bluebook") runway = Project.make(:name => “Project Runway”)

What is this ‘make’ method? Did you mean ‘new’?

24TYPO

On line 4, “the standard Ruby library Test:Unit” should be “Test::Unit”.

30TYPO

In the setup method, “project.users << fred” should read “project.users << @fred”.

38TYPO

Near the end of the page, an extraneous “the” in “You will find much more discussion on the why fixture data is less commonly used”.

175TYPO

The line
should “contain things”
is missing its “do”.

177TYPO

Again, the contexts are missing their “do”s.

76SUGGEST

You use `create` to frequently, in my opinion. Why use it when you don’t need to test persistence logic?

1SUGGEST

Location 2026 on Kindle (ipad), the code snippet has the line numbers displaying as ugly black blocks. The PDF version of this is fine.

63TYPO

seventy-eleven?

90ERROR

Factory is no longer available. Factory.next is now FactoryGirl.generate. See github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md

130TYPO

is blocked or diverted. s/is/are/

283TYPO

Missing “with”? First sentence of fourth paragraph:

The second reason … Has to do WITH the often-noted

62TYPO

Walking THROUGH the site, Through, Not though. Second bullet point.

204ERROR

controller action and HTML method -> controller action and HTTP method

Categories: