We try to keep our books accurate, but sometimes mistakes creep
in. This page lists the errors submitted by our astute readers.
If you've found a new error, please
submit it.
The latest version of the book is P2.1,
released 8 months ago.
If you've bought a PDF of the book and would like to upgrade
it to this version (for free), visit your
home page.
| PDF |
Paper |
Description |
Found in |
Fixed in |
| 0 |
|
#47920: After location 62 on Kindle, there are some doubled hyphens, which are probably meant to be en-dashes: "Test--Driven". --Ilmari Vacklin
|
P2.0
08-Nov-11
|
|
| 14 |
|
#50476: Last then line missing closing $/--Brian maltzan
|
P2.1
17-Jan-13
|
|
| 16 |
|
#49930: The code sample hello/5/features/step_definitions/greeter_steps.rb appears to be missing a blank line before "Given...".--Wayne Conrad
|
P2.1
06-Oct-12
|
|
| 31 |
|
#46852: checking
|
P1.0
11-Apr-11
|
|
|
42 |
#47436: The code example is shown as
Then /^I should see "([^"]*)"$/ do ...
but in the following paragraph, the regex is shown
as ([^\"]*) - note added backslash.
The presence or absences of the backslash does not make
any difference in the operation of the code. However
Textmate get pretty confused (gets out of phase about which
is the open/closed quotes) without the backslash.
The downloadable code examples do not have the backslash.--Dan Nachbar #47436: The code example is shown as
Then /^I should see "([^"]*)"$/ do ...
but in the following paragraph, the regex is shown
as ([^\"]*) - n ...more...
|
P2.0
25-Aug-11
|
|
| 47 |
|
#47907: The "original narrative" shown with the scenario in the lower half of this page is different from the original narrative as it appeared on the previous page.
--Justin Forder #47907: The "original narrative" shown with the scenario in the lower half of this page is different from the original narrative as it appeared on the ...more...
|
P2.0
06-Nov-11
|
|
| 59 |
|
#46976: A hypen is included in the epub version of the book in the case where the hypen indicated a end of line wrap in the PDF version. The hypen does not occur at the end of the line in the epub version and looks like it is part of the file name (code-breaker.rb)
Cucumber will load features/support/env.rb, which now requires lib/code- breaker.rb, which, in turn, requires lib/codebreaker/game.rb, which is
--Mark Anderson #46976: A hypen is included in the epub version of the book in the case where the hypen indicated a end of line wrap in the PDF version. The hypen do ...more...
|
P1.0
28-Apr-11
|
|
| 60 |
|
#49331: The code in step definition
Then /^I should see "([^"]*)"$/ do |message|
output.messages.should include(message)
end
is using should method. When I followed the book using Ruby 1.9.3-p125 I was running into an error:
undefined method `should' for #<Object:0x007f9580b0bc70> (NoMethodError)
Only when I included RSpec it could use all the 'should' methods. I included RSpec using a Gemfile, but as the book does not say anything about Gemfile, maybe including RSpec in a different way would work as well.
--JjP #49331: The code in step definition
Then /^I should see "([^"]*)"$/ do |message|
output.messages.should include(message)
end
is using shou ...more...
|
P2.0
16-May-12
|
|
| 60 |
|
#49332: The need for including RSpec appeared only when I used Guard for automating running Cucumber acceptance tests. When running Cucumber manually it all works fine.
I'm sorry for the confusion, but in case someone else is using Guard it might be useful. I will also look into Guard to see why it runs Cucumber differently in that case than when Cucumber is run manually.--JjP #49332: The need for including RSpec appeared only when I used Guard for automating running Cucumber acceptance tests. When running Cucumber manually ...more...
|
P2.0
16-May-12
|
|
| 61 |
|
#50499: Section 5.1, first paragraph:
"game_spec.rb). See Shouldn't We Avoid a One-to-One Mapping?, on page 46 for"
should be
"game_spec.rb). See Shouldn't We Avoid a One-to-One Mapping?, on page 62 for"
--Ralph Hoffmann #50499: Section 5.1, first paragraph:
"game_spec.rb). See Shouldn't We Avoid a One-to-One Mapping?, on page 46 for"
should be
"game_spec. ...more...
|
P2.1
20-Jan-13
|
|
| 61 |
|
#49530: [Using ruby 1.9.3-p194] After modifying the line
game = Codebreaker::Game.new(output)
and running Cucumber the book indicates that the test will fail due to the incorrect number of arguments. However, it actually first fails because the variable output is undefined. The error message is:
NameError: undefined local variable or method `output' for #<Object:0x00000002620348>
adding the line output = Output.new (shown below) initializes output so that the call to Codebreaker::Game.new can occur -- at which time it will fail in accordance with the book's text. The step definition change described above is shown here:
When /^I start a new game$/ do
#output = Output.new #<-- added line
Codebreaker::Game.new(output)
game.start
end
--Coby Pachmayr #49530: [Using ruby 1.9.3-p194] After modifying the line
game = Codebreaker::Game.new(output)
and running Cucumber the book indicates that the ...more...
|
P2.0
16-Jul-12
|
|
| 73 |
|
#47338: I suggest that the definition of the let() method to be updated/verified.
let(<name>) { <block> }
i'm beginning to have a suspicion that the "name" which you feed into a call to let() is to be defined as "the name of the resource which the contents of the block are to be assigned to. For example, the generated of a mocked resource object that is to be used throughout a spec".--Gordon Yeong #47338: I suggest that the definition of the let() method to be updated/verified.
let(<name>) { <block> }
i'm beginning to have a suspicion th ...more...
|
P1.0
03-Aug-11
|
|
| 74 |
|
#50507: Chapter 6, introduction, first paragraph
feature we’re going to tackle is to subimt a guess and get feedback from the
"to subimt a" -> "to submit a"
--Ralph Hoffmann #50507: Chapter 6, introduction, first paragraph
feature we’re going to tackle is to subimt a guess and get feedback from the
"to subimt a" -> ...more...
|
P2.1
22-Jan-13
|
|
|
75 |
#47110: "Run the specs, and they should all pass." in 2nd para, line 1
To make this a true statement, number_match? need to be in codebreaker/game.rb, which is missing upto this point.
Feel free to reach me at khan [dot] mohammad [at] acm [dot] org, if you need further clarification.--MOHAMMAD H KHAN #47110: "Run the specs, and they should all pass." in 2nd para, line 1
To make this a true statement, number_match? need to be in codebreaker/game. ...more...
|
P2.0
26-May-11
|
|
| 77 |
|
#49741: This is a dummy. Throw me away.
|
P2.0
25-Aug-12
|
|
| 78 |
|
#49532: [Ruby 1.9.3p194; Cucumber 1.2.1; RSpec 2.11.0]
Running cucumber on codebreaker_submits_guess.feature, shows 5 passing scenarios, not 14 scenarios.
The code for all Scenarios: below the Scenario outline should be changed Examples:
For example:
Scenarios: no matches
| code | guess | mark |
| 1234 | 5555 | |
Becomes..
Examples: no matches
| code | guess | mark |
| 1234 | 5555 | |
--Coby Pachmayr #49532: [Ruby 1.9.3p194; Cucumber 1.2.1; RSpec 2.11.0]
Running cucumber on codebreaker_submits_guess.feature, shows 5 passing scenarios, not 14 scena ...more...
|
P2.0
17-Jul-12
|
|
| 80 |
|
#49169: Earlier in the book "before(:each)" was introduced and the lines were changed to use @output.should_receive. Now in this section the code is back to output.should_receive--NewToRubyRailsCucSpec #49169: Earlier in the book "before(:each)" was introduced and the lines were changed to use @output.should_receive. Now in this section the code is ...more...
|
P2.0
21-Apr-12
|
|
| 80 |
92 |
#51093: undefined method `[]' for nil:NilClass (NoMethodError)
./lib/codebreaker/game.rb:30:in `exact_match?'
./lib/codebreaker/game.rb:17:in `block in guess'
./lib/codebreaker/game.rb:16:in `each'
./lib/codebreaker/game.rb:16:in `map'
./lib/codebreaker/game.rb:16:in `guess'
./features/step_definitions/codebreaker_steps.rb:36:in `/^I guess "(.*?)"$/'
features/codebreaker_submits_guess.feature:18:in `When I guess "<guess>"'
#51093: undefined method `[]' for nil:NilClass (NoMethodError)
./lib/codebreaker/game.rb:30:in `exact_match?'
./lib/codebreaker/game.rb ...more...
|
B13.0
19-Mar-13
|
|
| 81 |
|
#49533: The book states that running the codebreaker_starts_game will fail because of the missing argument... however, it does not fail since a default is provided in the start method of Game.
That is (in the game.rb file):
def start(secret=nil)
..
end
If one removes the default (=nil) from the start arguments it will fail as the book indicates. --Coby Pachmayr #49533: The book states that running the codebreaker_starts_game will fail because of the missing argument... however, it does not fail since a defaul ...more...
|
P2.0
17-Jul-12
|
|
|
88 |
#48857: missing change mark before:
def initialize(secret, guess)--Carlos Silva
|
P2.0
01-Mar-12
|
|
| 91 |
|
#49495: I am using
ruby --version
ruby 1.9.3p194 (2012-04-20) [x86_64-linux]
rspec --version
2.10.1
cucumber --version
1.2.1
The example code fails in This version of cucumber with the error shown below. The error can be resolved by removing the "#" from the #START_HIGHLIGHT & #END_HIGHLIGHT in the Feature section.
The cucumber error message is:
features/codebreaker_submits_guess.feature: Lexing error on line 12: ' Each position in the secret code can only be matched once. For example, a'. See http<colon>//wiki<dot>github<dot>com/cucumber/gherkin/lexingerror for more information. (Gherkin::Lexer::LexingError)
/usr/local/lib/ruby/gems/1.9.1/gems/gherkin-2.11.0/lib/gherkin/lexer/i18n_lexer.rb:22:in `scan'
/usr/local/lib/ruby/gems/1.9.1/gems/gherkin-2.11.0/lib/gherkin/lexer/i18n_lexer.rb:22:in `scan'
/usr/local/lib/ruby/gems/1.9.1/gems/gherkin-2.11.0/lib/gherkin/parser/parser.rb:31:in `parse'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/feature_file.rb:37:in `parse'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:28:in `block in load'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:14:in `features'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:170:in `features'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:46:in `run!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in `execute!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in `execute'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.2.1/bin/cucumber:14:in `<top (required)>'
/usr/local/bin/cucumber:23:in `load'
/usr/local/bin/cucumber:23:in `<main>'
--Kevin Slade #49495: I am using
ruby --version
ruby 1.9.3p194 (2012-04-20) [x86_64-linux]
rspec --version
2.10.1
cucumber --version
1.2.1
The example cod ...more...
|
P2.0
05-Jul-12
|
|
| 92 |
|
#47720: "Ru n t h e s pe c s , an d t h e y s h o u ld all pas s . Ru n t h e s c e n ario s , an d y o u
s h o u ld s e e t h at t we lv e ar e pas s in g , le av in g o n ly t h r e e failin g s c e n ario s
t o g o ". There are 14 tests in total where 11 now are passing (not 12), and 3 fails.--Kjetil Klaussen #47720: "Ru n t h e s pe c s , an d t h e y s h o u ld all pas s . Ru n t h e s c e n ario s , an d y o u
s h o u ld s e e t h at t we lv e ar e pas ...more...
|
P2.0
07-Oct-11
|
|
| 94 |
|
#48835: Chapter 7.3 is all about “Refactor to Express Intent”. A minor improvement could be made to the refactored `number_match?` method to better convey the intent of the code. I suggest changing:
def number_match?(guess, index)
@secret.include?(guess[index]) && !exact_match?(guess, index)
end
...to…
def number_match?(guess, index)
@secret.include?(guess[index]) unless exact_match?(guess, index)
end
While the "a && !b" expression makes sense to programmers familiar with C-style syntax, I would argue that "unless" is not only more appropriate for Ruby, but does a superior job of conveying the intent of the method.--Sean McCann #48835: Chapter 7.3 is all about “Refactor to Express Intent”. A minor improvement could be made to the refactored `number_match?` method to better co ...more...
|
P2.0
28-Feb-12
|
|
|
100 |
#48874: I think that the marker_spec.rb code presented in this page leads to think that there is only one context at this point in the "describe Marker do … end" when that is not true.--Carlos Silva #48874: I think that the marker_spec.rb code presented in this page leads to think that there is only one context at this point in the "describe Marke ...more...
|
P2.0
03-Mar-12
|
|
| 102 |
|
#47526: It's being picky, but following the mantra that readability is paramount, isn't this rather cryptic?
count + (number_match?(guess, index) ? 1 : 0)
I'd write this instead:
count += 1 if number_match?(guess, index)
Or I'm just not a fan of the ternary operator ;)--Martin Svanberg #47526: It's being picky, but following the mantra that readability is paramount, isn't this rather cryptic?
count + (number_match?(guess, index) ? ...more...
|
P2.0
09-Sep-11
|
|
|
103 |
#49046: @guess is a string being passed to Marker, map is not a method available to the String class, so use each_char instead, or convert the String to Array--Andre Dublin
|
P2.0
01-Apr-12
|
|
| 118 |
|
#49079: You do realize that this new implementation could have been achieved by just reversing the order of the checking like this:
@secret.include?(@guess[index]) && !exact_match?(index)
reverse it to
@guess.include?(@secret[index]) && !exact_match?(index)--João Soares #49079: You do realize that this new implementation could have been achieved by just reversing the order of the checking like this:
@secret.include?( ...more...
|
P2.0
07-Apr-12
|
|
| 145 |
|
#50022: In the middle of the page it says:
"Assuming that Thing’s initialize() method does this and set_status() does as well, you can write the previous like this:"
The "and set_status() does as well" should be removed since Thing.new will not return the return value of the initialize method but will return the newly created Thing instance.--Peter Lohmann #50022: In the middle of the page it says:
"Assuming that Thing’s initialize() method does this and set_status() does as well, you can write the prev ...more...
|
P2.1
25-Oct-12
|
|
|
150 |
#49360: `yield Thing.new do; end` binds the block to `yield` instead of `Thing.new`. Need to use `yield Thing.new { ... }` instead.--David Chelimsky
|
P1.0
20-May-12
|
|
|
169 |
#47171: Third paragraph:
Currently Reads:
"...anything that begins with have_ to a predicate on the target object beginning with has_"
have_ and has_ should be switched.
It SHOULD read:
"...anything that begins with has_ to a predicate on the target object beginning with have_" #47171: Third paragraph:
Currently Reads:
"...anything that begins with have_ to a predicate on the target object beginning with has_"
have_ and ...more...
|
P1.0
08-Jun-11
|
|
| 179 |
|
#50335: Book has test-specific subclasspattern
(with no space between subclass and pattern)
--Perry Smith
|
P2.1
08-Dec-12
|
|
|
201 |
#51471: In the first paragraph on the page, the book implies that it is the stub that causes any subsequent calls to log() to be ignored:
<quote>
In the second example, we override that stub with the expectation. Once the expectation is met, any subsequent calls to log() are caught by the stub and essentially ignored.
</quote>
My testing indicates otherwise. It is the '.as_null_object()' that causes any subsequent calls to log() to be ignored. To prove this, simply create code that causes log() twice, observe that everything is ok, and then take out the '.as_null_object()' (and the "@database.(begin|end)" lines if u have them. Observe then that repeated calls to log() will FAIL, and that they are not "caught by the stub and essentially ignored"!--Jeff Lim #51471: In the first paragraph on the page, the book implies that it is the stub that causes any subsequent calls to log() to be ignored:
<quote>
...more...
|
P1.0
07-May-13
|
|
| 203 |
|
#48688: "Article.stub_chain" should be "article.stub_chain"
|
P2.0
09-Feb-12
|
|
| 210 |
|
#50338: 2nd one of these. In the pdf it has:
create an autotestdirectory
autotest is in italics and directory is normal but there is no space between the two.
--Perry Smith #50338: 2nd one of these. In the pdf it has:
create an autotestdirectory
autotest is in italics and directory is normal but there is no space b ...more...
|
P2.1
08-Dec-12
|
|
| 210 |
|
#50339: 2nd one of these. In the pdf it has:
create an autotestdirectory
autotest is in italics and directory is normal but there is no space between the two.
--Perry Smith #50339: 2nd one of these. In the pdf it has:
create an autotestdirectory
autotest is in italics and directory is normal but there is no space b ...more...
|
P2.1
08-Dec-12
|
|
| 215 |
|
#50340: Suggestion to Pragmatic: it would be nice if I could add and edit previous "erratas".
Now to the errata. This is the third one. This isn't a big deal. I'm just trying to give you more samples of what to look for.
The book has:
The output contains the contents of a hash with keys such as:example_group, :description,:location,:caller, and so on.
There is a line wrap just before :description. The :foo words are in italics(?). Again, we see no space before the :foo words. Other examples, like on page 216:
RSpec exposes a configuration object that supports the definition of global before, after, and around hooks, as well as hooks to include modules in examples or extend example group classes.
format nicely (with "before", "after", "around", and "include" in a different font (tt?)
HTH
--Perry Smith #50340: Suggestion to Pragmatic: it would be nice if I could add and edit previous "erratas".
Now to the errata. This is the third one. This isn' ...more...
|
P2.1
08-Dec-12
|
|
|
221 |
#47193: The code presented to add a rspec:rcov rake task is no longer needed as it is added rails rspec gems. This should at least be mentioned for those using rails.--Harry Hornreich #47193: The code presented to add a rspec:rcov rake task is no longer needed as it is added rails rspec gems. This should at least be mentioned for th ...more...
|
P1.0
18-Jun-11
|
|
|
225 |
#47685: To run the example it says to type "rspec group_example.rb" but given the filename shown above this should be "rpsec focused_group.rb"--Nigel Lowry
|
P1.0
04-Oct-11
|
|
|
232 |
#49537: Under the "Matcher Protocol" subsubsection of subsection 16.7, under the "matches?" list item, the second sentence contains a typo: "Return true for a passing expection or false for a failure."
(should be "expectation" not "expection") #49537: Under the "Matcher Protocol" subsubsection of subsection 16.7, under the "matches?" list item, the second sentence contains a typo: "Return tr ...more...
|
P2.0
17-Jul-12
|
|
| 232 |
|
#49397: "spec_opts takes an array of strings" (first sentence right under the "About Code Coverage" sidebar) but the (non-deprecated) option's name is actually "rspec_opts".--Frederic BLANC #49397: "spec_opts takes an array of strings" (first sentence right under the "About Code Coverage" sidebar) but the (non-deprecated) option's name is ...more...
|
P2.0
01-Jun-12
|
|
| 237 |
|
#50153: "pending_count)" missing a parentheses, should be "pending_count()".
I'm really enjoying this book so far. Thanks!--Alex Plescan
|
P2.1
08-Nov-12
|
|
| 238 |
|
#49399: network.rb
require 'ping'
ping has been deprecated after ruby 1.8.7
The book needs to show another way of doing ping for ruby 1.9.x--Jim Oser
|
P2.0
01-Jun-12
|
|
| 251 |
|
#45871: On the Kindle 3, the word "fiancé" in the "Cucumber Seeds" box is rendered as "fiancée". The PDF page # given above is actually the location number.--Shea Levy
|
P1.0
02-Dec-10
|
|
| 253 |
|
#49361: In the footnote, the URL to the Cucumber wiki is wrong. Cucumber has moved to another Github repository.--Ulrich Sossou
|
P2.0
21-May-12
|
|
| 270 |
|
#48498: s/pending/undefined/
"Several things changed when we added the step definition. First, the scenario and step are no longer pending, but passing."
The scenario and step were previously undefined rather than pending. If we had run the cucumber command after pasting the cucumber-provided snippet but before editing it, then they would have temporarily been pending.--ibroadfo #48498: s/pending/undefined/
"Several things changed when we added the step definition. First, the scenario and step are no longer pending, but pas ...more...
|
P2.0
11-Jan-12
|
|
| 273 |
|
#45872: In the Kindle edition, chapter 1 has footnotes 2,3 and 4 not no footnote 1. 2, 3 and 4 correspond to 1, 2, and 3 of the PDF edition. PDF page # given above corresponds to Kindle location.--Shea Levy #45872: In the Kindle edition, chapter 1 has footnotes 2,3 and 4 not no footnote 1. 2, 3 and 4 correspond to 1, 2, and 3 of the PDF edition. PDF page ...more...
|
P1.0
02-Dec-10
|
|
| 274 |
|
#48291: At the beginning of the last sentence of the fifth paragraph (immediately before the "Tagged Hooks" subsection): "When we do,…" is somewhat confusing. Perhaps something like, "We can use a tagged hook if we don't want that hook to run for all scenarios." would be clearer.--Bruce Hobbs #48291: At the beginning of the last sentence of the fifth paragraph (immediately before the "Tagged Hooks" subsection): "When we do,…" is somewhat co ...more...
|
P2.0
15-Dec-11
|
|
| 278 |
|
#49603: The url in the footnote does not work. This form doesn't let me input urls to this box so I can't give you the correct one.
--Joseph Shraibman
|
P2.0
31-Jul-12
|
|
| 287 |
|
#49049: In 19.2 "Setting up a Rails 3 Project", running 'bundle install' gives the following error:
% rails generate rspec:install
WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called.
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
create .rspec
create spec
create spec/spec_helper.rb
This appears to be a change introduced about 6 months ago (see blog post here): See github.com/cucumber/cucumber-rails/pull/171 (can't provide a proper URL because of the submission filter).
Setting up a separate group with :test only and moving 'gem "cucumber-rails"' into this group gets past this issue. e.g.
group :test do
gem "cucumber-rails", ">= 0.3.2"
end
--Doug Morris #49049: In 19.2 "Setting up a Rails 3 Project", running 'bundle install' gives the following error:
% rails generate rspec:install
WARNING: Cucumb ...more...
|
P2.0
02-Apr-12
|
|
| 288 |
|
#47300: Cucumber on rails 3 requires database_cleaner to be added explicitly to the gemfile. Following the steps here gives an error that database_cleaner is uninitialized.--Anand C Ramanathan #47300: Cucumber on rails 3 requires database_cleaner to be added explicitly to the gemfile. Following the steps here gives an error that database_cle ...more...
|
P2.0
21-Jul-11
|
|
|
296 |
#49498: Content of simulated_browser\05\app\models\genre.rb I downloaded from the website should be:
class Genre < ActiveRecord::Base
attr_accessible :name
end
Rather than:
class Genre < ActiveRecord::Base
end
The missing line causes the When step and the scenario to fail.
--Shaun Dashjian #49498: Content of simulated_browser\05\app\models\genre.rb I downloaded from the website should be:
class Genre < ActiveRecord::Base
attr_acces ...more...
|
P1.0
05-Jul-12
|
|
| 326 |
|
#47433: “The Webrat’s default timeout” should probably drop the “the”, agree?
|
P1.0
23-Aug-11
|
|
| 338 |
|
#50135: The book says "The assigns() method returns a hash representing instance variables that were assigned to the view by the controller. Run rake spec:controllers, and the new
example fails with this:
expected #<Message:0x81b0b900 @name="Message_1005">
got nil
however my failure message was:
/Users/akkdio/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -S rspec ./spec/controllers/messages_controller_spec.rb
....F*
Pending:
MessagesController POST create when the message fails to save successfully renders the new template
# Not yet implemented
# ./spec/controllers/messages_controller_spec.rb:38
Failures:
1) MessagesController POST create when the message fails to save successfully assigns @message
Failure/Error: post :create
ActionView::MissingTemplate:
Missing template messages/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "#<RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator:0x00000102174f78>"
# ./spec/controllers/messages_controller_spec.rb:34:in `block (4 levels) in <top (required)>'
Finished in 0.10912 seconds
6 examples, 1 failure, 1 pending
I added the following as the book suggests:
def create
@message = Message.new(params[:message])
if @message.save
flash[:notice] = "The message was saved successfully."
➤ redirect_to :action => "index"
➤
➤ else
➤ render :action => "new"
➤ end
end
and the example passes. I don't know why but I never get the failure the book says I should get.
--akkdio #50135: The book says "The assigns() method returns a hash representing instance variables that were assigned to the view by the controller. Run rake ...more...
|
P2.1
06-Nov-12
|
|
| 340 |
|
#50136: the book text indicates that there is a change on the line:
context "when the message fails to save" do
it "assigns @message" do
➤ message.stub(:save).and_return(false)
post :create
assigns[:message].should eq(message)
end
Yet this is the same code as on page 339:
it "assigns @message" do
message.stub(:save).and_return(false)
post :create
assigns[:message].should eq(message)
end #50136: the book text indicates that there is a change on the line:
context "when the message fails to save" do
it "assigns @message" do
➤ messag ...more...
|
P2.1
06-Nov-12
|
|
|
347 |
#47257: Example rails_controllers/messages/13/spec/controllers/messages_controller_spec.rb is missing the line Message.stub(:new).and_return(message). This winds up being fixed in following examples due to the refactoring in the "Tidy Up" section.--Cailin Nelson #47257: Example rails_controllers/messages/13/spec/controllers/messages_controller_spec.rb is missing the line Message.stub(:new).and_return(message). ...more...
|
P2.0
11-Jul-11
|
|
|
348 |
#47258: In the example rails_controllers/messages/15/spec/controllers/messages_controller_spec.rb the before block needs
job.stub(:save).and_return(true)
to make the "saves the message" test pass.--Cailin Nelson #47258: In the example rails_controllers/messages/15/spec/controllers/messages_controller_spec.rb the before block needs
job.stub(:save).and_retur ...more...
|
P2.0
11-Jul-11
|
|
| 353 |
|
#48650: In this section, the messages_controller is altered so that it stores a notice in flash when the message is successfully saved. In the examples, the #save method has not been stubbed, so we're relying on the behavior of Mock#as_null_object to return a truthy response. In rspec-rails 2.8.1, there is a bug which causes as_null_object to return nil instead (GitHub rspec-rails issue 488). The bug was fixed in commit 7fa15c4157, but has yet to be released. So when you run rspec, the test fails. I checked the book errata and this wasn't mentioned it, and googling eventually let me to the bug and its fix on GitHub. I thought I'd mention it so that you can list it on the errata page while a fixed release is pending.
Thanks!
Justin
Relevant text:
Download rails_controllers/messages/17/app/controllers/messages_controller.rb
def create
message = Message.new(params[:message])
if message.save
flash[:notice] = "The message was saved successfully."
end
redirect_to :action => "index"
end
Run that, and you’ll see that it passes. Now we have two passing exam-
ples that specify the happy path, so let’s move on to examples of what
should happen when the save fails.
--Justin Force #48650: In this section, the messages_controller is altered so that it stores a notice in flash when the message is successfully saved. In the example ...more...
|
P2.0
03-Feb-12
|
|
|
353 |
#49044: First paragraph reads:
"The most obvious bit is the duplication in the past two examples"
"past" should be "last"--Nigel Lowry
|
P1.0
31-Mar-12
|
|
| PDF |
Paper |
Description |
Found in |
Fixed in |
| 1 |
|
#46030: # Quick Thoughts on "The RSpec Book"
My rating: 10/10.
Heavens gift book! Really.
That said, I have a few thoughts...
## On brute-forcing
I somehow felt sad because "disciplined approach" detailed part from previous
versions was omitted/under-emphasized. It was a great value for me to read it,
and definitely helped my career a lot, per se, "you're not silly, you're on
the right path".
## On testing
Test everything that could possibly break. A lot of debate here.
Not even a mention in the book. I know it's hard to talk on this, but it's
worth at least mentioning it.
## On workflow
I'm unaware of the constraints, but I would like to see a section of BDD DVCS
workflow and deployment. I'm not sure if they're on scope, but feature branches,
staging servers, deployment from day one, and a few other topics are often
under-valued or unpracticed on communities, I'm a strong believer that
stuff works better that way, and I was wondering if there are any plans about
it. Agile++.
## On autotesting
Also, although the some implementations are a little bit buggy at this time, I
would also suggest to focus on automated testing on your development machine,
projects such as autotest-[notification], spork and possibly guard, and the
rspec/cucumber support are worth mentioning.
I'd also like to see to some point CI scenarios.
## On mocks
On test doubles, I have almost nothing to say. Great coverage.
What's not clear to me by reading it, it's the role of mock objects on high
level testing, I mean the cucumber part.
I haven't faced this situation, but I do have the doubt.
I mean, a feature is supposed to be integrated, it's supposed to test your
entire stack, but might also be supposed to be contained, isn't?
My doubt here is probably just an indicator of bad design, but what happens
when you feel the need for a mock object on your features? Their role on
rspec is well understood, as a matter of fact, I'm confident with them since
I've got another layer of testing that allows me to see how are the parts
working, that's why it seems a big no-no to me to use of them on cucumber, but
again, what do you when you feel the need?
## On milestones
An excelent part that one about release planning and milestones: This gets in,
that gets out. A little more emphasis could be added into this customer-driven
iteration negotiation, and even if they're other sources that deal with the
topic I would like to see more about reacting to change, new features breaking
schedule, etc. Absolutely awesome the part of one-week iterations, I have to
say I was shocked, I've been ranging on 2-4 weeks iterations, definitely I must
try that in the near future.
## On Cucumber
I've experienced in the past, begginners at BDD have problems with Cucumber,
because they tend to be much specific and they abstract away from the business
requirements on writing the scenarios, they get to deep into implementation,
and they even have problems with Regexps because of that. Although that
though can be extracted from the book, I've felt somehow it lacks a little more
emphasis on this part.
## On Rails BDD
For the rails part, I must only say I was one of the ones that were expecting a real project in the "Agile Web Development with Rails 4" way.
Totally omitted capybara, I assume there's a very good reason on doing that.
What about database_cleaner? Wasn't database_cleaner on the Gemfile sufficient?
On view testing, three state models, only one mentioned: there are factories,
fixtures and mocks. Each with it's own advantages and disavantages,
but certainly each of them are widely used.
Suggest something like "def and; self; end" to rspec authors, allowing:
mock_model("Message").as_new_record.and.as_null_object
# instead of
# mock_model("Message").as_new_record.as_null_object
I don't like script/rails at all, who does that?
rails g controller messages
instead of:
script/rails generate controller Messages
Also, seems like --no-helper is no longer valid.
A rails bug maybe? It displays '--helper', and even that isn't allowed.
Migrations: I feel something missing here.
Shouldn't be possible to explain at least something like nulldb or similar,
can't remember exactly, adding to migrations continously while a model evolves, or generating a model from a set of expectations on what we might need?
Shouldn't we favoring field_id:references instead of a simple field_id:integer?
The shoulda people will feel a little offended, not a single
mention to their matchers ;)
"is valid with valid attributes" <- pointless? This is not behavior.
What makes valid attributes?
On associations, agree you shouldn't spec them directly.
## On Progressive Enhancement (or the lack of)
Based on experience, and in this book's scope, I was sad that progressive
enhancement wasn't mentioned at all in the book.
We aren't all the time building RIAs in the strict sense,
so this model of FE developing actually helps you on testing your app.
It brings a lot of benefits, but from a testing standpoint
(or a lazy standpoint maybe), it allows you to focus on testing your app
entirely without javascript at first, and then adding those automated browser
scenarios only on those enhancements.
Ex. if you've got a file upload field which gets replaced by a drop area on a
drag-drop UX, you just abstract away from that initially, make sure the form is working, the views are rendered and the file is uploaded, then your
selenium tests complements that.
Narrowed down concept, simple enough, but missing from the book.
## Colophon
Finally, I wouldn't expect you to take my suggestions to the line, you're far
better than that, but since this has become (or I expect it to become) the
point of authority for BDD, I believe some of those points will fill the gaps
in such an important book.
Nevertheless, a terrific work, a must-have book, and an amazing source of
knowledge.
Didn't change the way I program, I've been on this for a while now,
but it certainly enhanced the way I do it, I feel a better developer already.
Keep going, since you guys are my model of inspiration.
Thanks ** NaN ;)
On Cucumber part, there are still examples which use b/w instead of +/-.--Adrian Perez #46030: # Quick Thoughts on "The RSpec Book"
My rating: 10/10.
Heavens gift book! Really.
That said, I have a few thoughts...
## On brute-fo ...more...
|
P1.0
16-Dec-10
|
|
| 22 |
|
#45749: In section 1.2, end of the second paragraph: the word "is" should be removed from "...but even then, they generally mean is that it's stored somewhere and they can get it back."--Brian Darrell Green #45749: In section 1.2, end of the second paragraph: the word "is" should be removed from "...but even then, they generally mean is that it's stored s ...more...
|
B16.0
24-Nov-10
|
|
| 34 |
|
#45897: The phrase "go ahead and <x>" is used too much throughout the book. It would improve the writing to remove that part and just state the "<x>". For example, on page 34, the phrase could be removed from the sentence beginning with "Go ahead and add a step_definitions directory."--Jimmy Cuadra #45897: The phrase "go ahead and <x>" is used too much throughout the book. It would improve the writing to remove that part and just state the "<x>". ...more...
|
P1.0
05-Dec-10
|
|
| 43 |
|
#45883: So, now we have our release plan with 3 stories. It’s time to start breaking it down into iterations.
Yet only 2 stories are worked out and page 52 reads: We picked out two stories that will result in working software sufficient to interact with it in a meaningful way.
Poor third story…--Thomas Maas #45883: So, now we have our release plan with 3 stories. It’s time to start breaking it down into iterations.
Yet only 2 stories are worked out and ...more...
|
P1.0
03-Dec-10
|
|
| 59 |
|
#45737: Under section 4.3 Test Double: "A fake object that pretends to be real object..." should be "A fake object that pretends to be a real object...".--John Topley
|
B16.0
24-Nov-10
|
|
| 67 |
|
#45887: Throughout the PDF, output is colored as though it were code. On page 67, in "prompts for the first guess" the "for" is highlighted as a keyword; in "Codebreaker::Game#start", the # is treated as the start of a comment. This could be overlooked were it not for the explicit instruction to "use the --color flag".--Thom Raybold #45887: Throughout the PDF, output is colored as though it were code. On page 67, in "prompts for the first guess" the "for" is highlighted as a keywo ...more...
|
P1.0
03-Dec-10
|
|
|
73 |
#46098: The path cb/325/... threw me for a minute, after seeing a steady progression of 27,28,30,32. I guess you meant 32.5. In the next edition, I would make sure the numbers always progress in sequence.--Dale Visser #46098: The path cb/325/... threw me for a minute, after seeing a steady progression of 27,28,30,32. I guess you meant 32.5. In the next edition, I wo ...more...
|
P1.0
23-Dec-10
|
|
|
85 |
#46559: Recommend Enumerable#count, not enumerable#inject. The #count method does exactly what's required here. Using #inject makes the code harder to read to save a temporary variable. Using #count still gets rid of the temporary variable, and improves readability to boot.--Sheldon Hearn #46559: Recommend Enumerable#count, not enumerable#inject. The #count method does exactly what's required here. Using #inject makes the code harder to ...more...
|
P1.0
10-Mar-11
|
|
| 106 |
|
#45787: "Create a marker.rb file in lib/codebreaker/, open the Codebreaker module, and copy the Marker into that file." This is unclear to me. I think it means simply "Create a marker.rb file in lib/codebreaker and move the Marker class into that file." With no module around it? That works, but I'm not sure it's just what was meant. It's a Ruby-newbie issue but it might be worth trying to clarify a bit.--Mike Blyth #45787: "Create a marker.rb file in lib/codebreaker/, open the Codebreaker module, and copy the Marker into that file." This is unclear to me. I think ...more...
|
B16.0
27-Nov-10
|
|
| 120 |
|
#46580: In Ruby 1.9.2 there isn't a String#map method any more. but in this example you could use String#each_char instead. Perhaps you could mention it in a future print run--Jens Fahnenbruck #46580: In Ruby 1.9.2 there isn't a String#map method any more. but in this example you could use String#each_char instead. Perhaps you could mention ...more...
|
P1.0
14-Mar-11
|
|
| 130 |
|
#45852: The claim that exponential cost increase in later bug fixes comes from civil engineering would be nice to have footnoted with a source--Greg Cox
|
P1.0
01-Dec-10
|
|
| 152 |
|
#46338: Your code snippet formatter has decided that the text following => is ruby code and highlighted "require" and "and" inappropriately in the second line:
describe User, "should require password length between 5 and 40" { ... }
=> User should require password length between 5 and 40
--Jonathon Abbott #46338: Your code snippet formatter has decided that the text following => is ruby code and highlighted "require" and "and" inappropriately in the sec ...more...
|
P1.0
01-Feb-11
|
|
| 167 |
|
#45599: There's a missing space after the comma: "It /is/ DRY,/and/ it's so complicated."--Adam Spiers
|
B16.0
14-Nov-10
|
|
| 170 |
|
#45598: I think "nontechnical" should be hyphenated: "non-technical"--Adam Spiers
|
B16.0
14-Nov-10
|
|
| 176 |
|
#45754: Ruby on RailsRuby on Rails extends ...--Rich Morin
|
B16.0
25-Nov-10
|
|
|
181 |
#46738: In "/... for Aslak/", the word for should not be printed like a keyword.
This occurs on pages 181, 184 and 200(4).--Andreas Kemkes
|
P1.0
03-Apr-11
|
|
| 183 |
|
#45797: There should be no comma in "When it receives a message, it does not understand" on line 2.
|
B16.0
28-Nov-10
|
|
| 193 |
|
#45799: "All of the other patterns we’ll talk about and you’ll read about elsewhere are usually variations of method stubs and method expectations..."
Does this means that *every* other pattern is *usually* (but not always) a variation, or the *nearly every* (but not all) patterns are variations? There is a difference in meaning.--Mike Blyth #45799: "All of the other patterns we’ll talk about and you’ll read about elsewhere are usually variations of method stubs and method expectations..." ...more...
|
B16.0
28-Nov-10
|
|
| 200 |
|
#45770: "The first example specifies that the WidgetsController finds the widget, so we set an expectation that the Widget class should receive the find() method." This should be "find() message" rather than "find() method" because messages are received, not methods.--John Topley #45770: "The first example specifies that the WidgetsController finds the widget, so we set an expectation that the Widget class should receive the fi ...more...
|
B16.0
26-Nov-10
|
|
| 230 |
|
#46054: The autotest command appears to be part of the ZenTest gem, which is not listed on page 18. While autotest appears to have been its own gem for a while, it was also not listed on page 18. Please consider adding the appropriate gem to page 18 or mentioning where to find it on page 230.--Daniel Hedlund #46054: The autotest command appears to be part of the ZenTest gem, which is not listed on page 18. While autotest appears to have been its own gem f ...more...
|
P1.0
19-Dec-10
|
|
| 232 |
|
#45801: RSpec::Core::RakeTask.new do |t|
t.rspec_opts = ["--color"]
end
spec_opts takes an array of strings,...
Should "spec_opts" be "rspec_opts"?--Mike Blyth #45801: RSpec::Core::RakeTask.new do |t|
t.rspec_opts = ["--color"]
end
spec_opts takes an array of strings,...
Should "spec_opt ...more...
|
B16.0
28-Nov-10
|
|
| 238 |
|
#45806: Under the Exclusion heading, "...we tend to try to disable them so we can run rest of the suite..." should be "we tend to try to disable them so we can run the [sic] rest of the suite..."--John Topley #45806: Under the Exclusion heading, "...we tend to try to disable them so we can run rest of the suite..." should be "we tend to try to disable them ...more...
|
B16.0
29-Nov-10
|
|
|
280 |
#46742: In ":require", the word require should not be printed like a keyword.--Andreas Kemkes
|
P1.0
03-Apr-11
|
|
| 287 |
|
#46151: The autotest/discover.rb would not be any more generated since this commit f47e87b39a6f2bc24b71d701c8b509fd6e32acb1 in the rspec-rails repository.--Daniel Spangenberg
|
P1.0
30-Dec-10
|
|
| 300 |
|
#45809: "We’re going to focus on Cucumber with Webrat and Selenium, so we’re going to skip over some of the low-level details that we use RSpec for in practice."
Awkward sentence with "for in practice." Consider rewording at least to "that in practice we use RSpec for," if not the more formal "for which in practice we use RSpec."--Mike Blyth #45809: "We’re going to focus on Cucumber with Webrat and Selenium, so we’re going to skip over some of the low-level details that we use RSpec for in ...more...
|
B16.0
29-Nov-10
|
|
|
313 |
#46743: In "/... logged in as .../", the word in should not be printed like a keyword.--Andreas Kemkes
|
P1.0
03-Apr-11
|
|
| 338 |
|
#45907: The messages example in the rails_view chapter works with rails 3.0.0 but does not work when running on rails 3.0.3. The refactoring of new.html.erb_spec.rb on pdf page 338 results in a an unintended failure:
Failures:
1) messages/new.html.erb renders a text field for the message title
Failure/Error: form.should have_selector("input", type: "text", name: "message[title]", value: "the title")
expected following output to contain a <input type='text' name='message[title]' value='the title'/> tag:
<form accept-charset="UTF-8" action="/messages" class="new_message" id="new_message" method="post">
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
<input id="message_title" name="message[title]" size="30" type="text" value="Message_#<RSpec::Core::ExampleGroup::Nested_1:0x00000102adcd18>"><input id="message_submit" name="commit" type="submit" value="Save">
</form>
--Jeff Hutchison #45907: The messages example in the rails_view chapter works with rails 3.0.0 but does not work when running on rails 3.0.3. The refactoring of new.ht ...more...
|
P1.0
05-Dec-10
|
|
| 344 |
|
#46310: "Use Webrat’s have_xpath( ) and have_selector( ) matchers for view specs." I believe this is misplaced and should be moved to the summary of Chapter 21, where they are actually talked about and used.--Ted Milker #46310: "Use Webrat’s have_xpath( ) and have_selector( ) matchers for view specs." I believe this is misplaced and should be moved to the summary of C ...more...
|
P1.0
25-Jan-11
|
|
| 367 |
|
#45807: The database migration on this page specifies "recipient_id":
"script/rails generate model message title:string text:text recipient_id:integer"
On PDF page 371 and 372, the reference is to "recipient" (no "_id"). Admittedly I'm a beginner in Ruby but for me this example fails.
For context, I'm running Rails 3.0.3 and Ruby 1.9.2p0.--Sully Syed #45807: The database migration on this page specifies "recipient_id":
"script/rails generate model message title:string text:text recipient_id:inte ...more...
|
B16.0
29-Nov-10
|
|