Jadam
Jadam

Reputation: 1755

HAML newline issue w/ testing

running an assert_select test for erb to generate page title w/ copy. Haml appears to be pushing the copy portion to a new line. It shows correctly in the view, but my test fails due to the added new line.

test "should get about" do get :about assert_response :success assert_select "title", "About | Ruby on Rails Tutorial Baby Twitter" end

my about view: - provide(:title, "About")

application layout %title = yield (:title) | Title Copy

HTML output

<title> Home | Title Copy </title>

should be <title> Home | Title Copy </title>

Upvotes: 0

Views: 136

Answers (1)

bhugo313
bhugo313

Reputation: 451

In your application layout change:

%title
  #{yield(:title)} | Title Copy

In your view: = provide(:title, 'About')

This will show correct HTML output.

Upvotes: 2

Related Questions