Sha256: 47e599dc3c038250f5897fb9113fcccd02de022fe84a8ad09ffb5b7f1af7828b
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
module Mobylette # Mobylette::Helmet provides helper methods to help you when testing your controllers # for a mobile request. # # You must include Mobylette::Helmet into your test case, in the README there is more # documentation about how to make this test wide. module Helmet extend ActiveSupport::Concern # Force the request for the user_agent # # Remember to add it BEFORE the request # # Example: # # it "should render the mobile_device view on mobile request" do # force_mobile_request_agent("Android") # get :index # response.should render_template(:mobile_device) # end def force_mobile_request_agent(user_agent = "Android") request.user_agent = user_agent end # Reset the user_agent to the default ("Rails Testing") # # Remember to add it BEFORE the request # # Example: # # it "should render the normal_view view on mobile request" do # reset_test_request_agent # get :index # response.should render_template(:normal_view) # end def reset_test_request_agent request.user_agent = "Rails Testing" end # set_session_override will set the 'value' to the session override control # value may be: # * :ignore_mobile -> This will disable mobile checking, and the original format will be rendered # * :force_mobile -> This will force to all requests for this session be mobile (except xhr) # * nil -> This will disable session override def set_session_override(value) session[:mobylette_override] = value end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mobylette-3.5 | lib/mobylette/helmet.rb |
mobylette-3.4.1 | lib/mobylette/helmet.rb |
mobylette-3.3.2 | lib/mobylette/helmet.rb |