Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./spec/section_spec.rb:11:in `block (2 levels) in <module:BookBot>'
Finished in 0.01556 seconds (files took 0.12718 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/section_spec.rb:10 # A section should count contractions
I don't think your challenge is with `scan`, but with the Tools.scrub
method which modifies the string argument using `gsub!`. The Section
initializer will pass the string variable to Tools.build_report which in
turn passes it to Tools.scrub which modifies it. To see the effect of this,
print the @string in the Section initializer before and after you call
build_report.
A more idiomatic pattern would be to have utility methods treat string
arguments as immutable, preferring instead to return a modified copy of the
string. Hope that makes sense.
···
On Wed, Aug 5, 2020 at 7:36 AM Leam Hall <leamhall@gmail.com> wrote:
I could use some help with "scan", since I seem to be doing something
wrong.
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./spec/section_spec.rb:11:in `block (2 levels) in <module:BookBot>'
Finished in 0.01556 seconds (files took 0.12718 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/section_spec.rb:10 # A section should count contractions
I think that's going to work. The first test passed. More to thing through though, and ensure I make the code simpler and more robust.
···
On 8/5/20 7:58 AM, Mike Dalessio wrote:
Hi Leam,
I don't think your challenge is with `scan`, but with the Tools.scrub
method which modifies the string argument using `gsub!`. The Section
initializer will pass the string variable to Tools.build_report which in
turn passes it to Tools.scrub which modifies it. To see the effect of this,
print the @string in the Section initializer before and after you call
build_report.
A more idiomatic pattern would be to have utility methods treat string
arguments as immutable, preferring instead to return a modified copy of the
string. Hope that makes sense.
On Wed, Aug 5, 2020 at 7:36 AM Leam Hall <leamhall@gmail.com> wrote:
I could use some help with "scan", since I seem to be doing something
wrong.
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./spec/section_spec.rb:11:in `block (2 levels) in <module:BookBot>'
Finished in 0.01556 seconds (files took 0.12718 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/section_spec.rb:10 # A section should count contractions