任何人都可以向我解釋爲什麼會發生這種情況嗎?Rspec應匹配是錯誤的,但應該是真實的?
get :robots
response.should render_template("no_index")
response.body.should match "User-agent: *\nDisallow: /\n"
Failure/Error: response.body.should match "User-agent: *\nDisallow: /\n"
expected "User-agent: *\nDisallow: /\n" to match "User-agent: *\nDisallow: /\n"
# ./spec/controllers/robots_controller_spec.rb:12:in `block (3 levels) in <top (required)>'
但
get :robots
response.should render_template("no_index")
response.body.should eq "User-agent: *\nDisallow: /\n"
通行證?
這似乎相關(IRB):
1.9.2p318 :001 > "User-agent: *\nDisallow: /\n".match "User-agent: *\nDisallow: /\n"
=> nil