任何人都可以向我解释为什么会发生这种情况吗?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