cells icon indicating copy to clipboard operation
cells copied to clipboard

Cell is rendered as escaped text in Cucumber test

Open lessless opened this issue 10 years ago • 7 comments

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

lessless avatar Feb 14 '16 02:02 lessless

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

apotonick avatar Feb 14 '16 07:02 apotonick

@apotonick it's the later, with visit new_realty_path

lessless avatar Feb 14 '16 11:02 lessless

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

lessless avatar Feb 16 '16 08:02 lessless

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

thedanielhanke avatar Jun 23 '16 03:06 thedanielhanke

same issue here.

chrisyeung1121 avatar Sep 06 '16 06:09 chrisyeung1121

@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?

apotonick avatar Sep 06 '16 16:09 apotonick

@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.

thedanielhanke avatar Oct 04 '16 20:10 thedanielhanke