test/test_schmobile.rb in schmobile-0.0.6 vs test/test_schmobile.rb in schmobile-0.0.8

- old
+ new

@@ -42,11 +42,11 @@ @app = Class.new { def call(app); true; end }.new @rack = Rack::Schmobile.new(@app) end should "return an HTTP permanent redirect when given a redirect path and used by a mobile client" do - @rack.stubs(:redirect).returns("/hello") + @rack = Rack::Schmobile.new(@app, :redirect_to => "/hello") @rack.expects(:is_mobile_session?).returns(true) assert_equal [301, {"Location"=>"/hello"}, []], @rack.call(environment) end @@ -124,23 +124,23 @@ assert !@rack.redirect?(request("PATH_INFO" => "/wonderland")) assert !@rack.redirect?(request("PATH_INFO" => "/wonderland/more/stuff")) end should "return false when :if resolves to false" do - @rack = Rack::Schmobile.new(@app, :if => Proc.new { |request| false }) + @rack = Rack::Schmobile.new(@app, :redirect_to => "/wonderland", :redirect_if => Proc.new { |request| false }) assert !@rack.redirect?(request("PATH_INFO" => "/somewhere")) end end context "#redirect" do should "interpolate the argument string" do - @rack = Rack::Schmobile.new(@app, :redirect_to => "/wonderland/{{path}}") - assert_equal "/wonderland/wiffle", @rack.redirect(request("PATH_INFO" => "wiffle")) + @rack = Rack::Schmobile.new(@app, :redirect_to => "/wonderland", :redirect_with => "/{{path}}") + assert_equal "/wonderland/wiffle", @rack.redirect_location(request("PATH_INFO" => "wiffle")) end should "interpolate a multipart argument string" do - @rack = Rack::Schmobile.new(@app, :redirect_to => "/wonderland/{{path}}/lemurs/{{path}}") - assert_equal "/wonderland/wiffle/lemurs/wiffle", @rack.redirect(request("PATH_INFO" => "wiffle")) + @rack = Rack::Schmobile.new(@app, :redirect_to => "/wonderland/", :redirect_with => "{{path}}/lemurs/{{path}}") + assert_equal "/wonderland/wiffle/lemurs/wiffle", @rack.redirect_location(request("PATH_INFO" => "wiffle")) end end end end