Forum: RSpec Problems withe the template...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex (Guest)
on 2009-04-22 20:47
(Received via mailing list)
Hello everybody !

I have in a view something like this :


<% unless (method_name?(id)) then %>
  <span class="active">
      <%= link_to h(t(:BTN)), new_url_path(id) %></span>
   </span>
<% else %>
  <span class="Notactive">
    <%= link_to_function h(t(:BTN)), 'return false;' %>
  </span>
<% end %>


all of this works well ...

and in my spec I try to do this to go in the else part :

@controller.template.stub!(:get_courtier_expire?).and_return (false)



I tried a lot of combinations like ...

@template.stub!(
template.stub!(
@controller.template.should_receive(
template.should_receive(

and it does'nt work ... it always goes in the if not in the else
part ... any suggestions ?
David C. (Guest)
on 2009-04-22 21:59
(Received via mailing list)
On Wed, Apr 22, 2009 at 11:27 AM, Alex <removed_email_address@domain.invalid> 
wrote:
>        <span class="Notactive">
>                <%= link_to_function h(t(:BTN)), 'return false;' %>
>        </span>
> <% end %>
>
>
> all of this works well ...
>
> and in my spec I try to do this to go in the else part :
>
> @controller.template.stub!(:get_courtier_expire?).and_return (false)

So I'm clear - method_name? above is really get_courtier_expire? ??

The statement in the view is unless, not if - so if the method is
returning false, then it's behaving as you would expect. Unless I'm
missing something :)
Alex (Guest)
on 2009-04-22 22:26
(Received via mailing list)
Problem solved!

Sorry about that, turns out it wasn't an error....

Thanks!
This topic is locked and can not be replied to.