# Different boolean expression evaluation between rspec(view) and rails environments

**URL:** <https://www.ruby-forum.com/t/different-boolean-expression-evaluation-between-rspec-view-and-rails-environments/154227>\
**Category:** Rails\
**Created:** [November 26, 2008, 4:04pm UTC](https://www.ruby-forum.com/t/different-boolean-expression-evaluation-between-rspec-view-and-rails-environments/154227 "2008-11-26T16:04:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pradeepgatram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@pradeepgatram](https://www.ruby-forum.com/u/pradeepgatram)\
**Post date:** [November 26, 2008, 4:04pm UTC](https://www.ruby-forum.com/t/different-boolean-expression-evaluation-between-rspec-view-and-rails-environments/154227/1 "2008-11-26T16:04:41Z")

</div>

Hi,

Maybe its just too late in the day and I should stop :). But I am stuck  
at a  
very weird issue. Here is an excerpt from my erb file

\<% display\_invisible\_content = !icon.nil? or (render\_detach and  
entity.mounted?) %\>

(I have certain, non mountable, entities which do not have mounted?  
method.  
It should not have been a problem because the render\_detach is true only  
for  
mountable entities)

I have tested this writing a view spec and exercising the case where  
icon is  
nil and render\_detach is false. The spec passed w/o calling the mounted?  
method on entity.

When I come across the same scenario on the Rails UI (running in dev  
mode),  
the mounted? method is called on entity despite render\_detach being  
false!!!

How is this possible?

Pradeep

---

<div class="post-metadata">

**Author:** ![pradeepgatram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@pradeepgatram](https://www.ruby-forum.com/u/pradeepgatram)\
**Post date:** [November 27, 2008, 5:59am UTC](https://www.ruby-forum.com/t/different-boolean-expression-evaluation-between-rspec-view-and-rails-environments/154227/2 "2008-11-27T05:59:33Z")

</div>

Ooops. Perils of coding late in the day. render\_detach boolean was  
indeed ‘true’ 🙂
