trailblazer / cells

View components for Ruby and Rails.
https://trailblazer.to/2.1/docs/cells.html
3.06k stars 235 forks source link

Cell is rendered as escaped text in Cucumber test #378

Open lessless opened 8 years ago

lessless commented 8 years ago

Hello,

During Cucumber tests cell's content is rendered as escaped string http://cl.ly/0I0G0c3k2c0i. Gem versions are:

cells (4.0.4)
capybara (2.5.0)
cucumber (1.3.20)

May have relation to https://github.com/apotonick/rspec-cells/issues/21 but this happens within cucumber, not RSpec tests

apotonick commented 8 years ago

Is that a Cucumber test that only tests a cell in isolation, or retrieves the page via the controller, e.g. GET /comments?

lessless commented 8 years ago

@apotonick it's the later, with visit new_realty_path

lessless commented 8 years ago

btw, in both development and test environments, i.e. when called during regular navigation with a browser and when called during the visit helper inspired request, cell renders the same string. Also template engine doesn't matter - it's the same for erb and slim.

"<form class=\"simple_form large-9 larger-centered medium-10 medium-centered small-12 columns\" id=\"new_realty\" action=\"/manage/realties\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" />\n  \n\n  <div class=\"form-section small-12 colunms\">\n    <div class=\"row\">\n      \n        <div class=\"input hidden realty_listing_deal\"><input value=\"rent\" class=\"hidden\" type=\"hidden\" name=\"realty[listing_attributes][deal]\" id=\"realty_listing_attributes_deal\" /></div>\n        <div class=\"input string required realty_listing_price medium-6 small-12 columns\"><label class=\"string required\" for=\"realty_listing_attributes_price\">Price <abbr title=\"required\">*</abbr></label><input class=\"string required\" required=\"required\" aria-required=\"true\" placeholder=\"Price\" type=\"text\" name=\"realty[listing_attributes][price]\" id=\"realty_listing_attributes_price\" /></div>\n</div></div>\n</form>"

update: eventually, marking string as html safe helped to put tags on screen

= concept('realty/cell/create', @form).to_s.html_safe

thedanielhanke commented 8 years ago

i had the same issue when calling = cell(:foo, model) instead of (really!) =cell(:foo, model).()

chrisyeung1121 commented 8 years ago

same issue here.

apotonick commented 8 years ago

@thedanielhanke Are you very very very sure that this is the case? This would mean that the override in call works, but the ViewModel#to_s method is not invoked.

Can anyone override the to_s method and raise an exception to see if it is called or not?

thedanielhanke commented 8 years ago

@apotonick sorry for the delay. it does not happen anymore, iirc it was a result of slim, caching and omitting .() but i cannot reproduce it now.