[rspec-users] Controller/View User Agent Strings

David Chelimsky dchelimsky at gmail.com
Tue Feb 13 19:40:42 EST 2007


On 2/13/07, s.ross <cwdinfo at gmail.com> wrote:
> I have conditional logic in my view (I know, obligatory slap on the
> wrist) so that an add-on stylesheet is linked in for IE users. The
> code is:
>
>      <%= stylesheet_link_tag('ie', :media => 'screen') if
> request.user_agent && request.user_agent =~ /msie/i %>
>
> The spec is:
>
>    specify "should display index page" do
>      get :index
>      response.should_be_success
>    end
>
> There is no user_agent in the request object passed to the view. Now,
> I can change all of this by simply:
>
> setup do
>      request.stub!(:user_agent).and_return('msie')
> end
>
> but I was wondering if there was a better way?

That seems pretty simple to me. What is bugging you about it?

>
> Thanks,
>
> Steve
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list