Where body
is this:
<img src='/Users/test/Documents/cd-rum/whatever/spec/factories/images/rda.jpg' />Et qui incidunt provident sed nemo modi pariatur quia.
Why does this:
parsed_body = Nokogiri::HTML(body).search('img').first.remove
parsed_body.to_html
Return only the image tag?
Failure/Error: specify { expect(post.parsed_body).to_not include('<img') }
expected "<img src=\"/Users/test/Documents/cd-rum/whatever/spec/factories/images/rda.jpg\">" not to include "<img"
Because you're assigning the result of .remove
to that variable - just remove the assignment
body = "<img src='/Users/test/Documents/cd-rum/whatever/spec/factories/images/rda.jpg' />Et qui incidunt provident sed nemo modi pariatur quia."
parsed_body = Nokogiri::HTML::fragment(body)
parsed_body.search('img').first.remove
parsed_body.to_html # => "Et qui incidunt provident sed nemo modi pariatur quia."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.