Testing Rack Routing Using rSpec

余生颓废 提交于 2019-11-28 10:35:10

Ok, answered my own question. Request spec:

describe SeoDispatcher do
  describe "seo parsing" do
    it "GET /insurance/charters-and-guides/how-to-buy-charter-boat-insurance displays how-to-buy-charter-boat-insurance (3-part path)" do
      p = Page.make(:title => "how-to-buy-charter-boat-insurance")
      p.save
      get "/insurance/charters-and-guides/how-to-buy-charter-boat-insurance"
      request.path.should == "/insurance/charters-and-guides/how-to-buy-charter-boat-insurance"
      assigns[:page].slug.should == "how-to-buy-charter-boat-insurance"
    end

    it "GET /insurance/charters-and-guides displays guides (2-part path)" do
      p = Page.make(:title => "charters and guides")
      p.save
      get "/insurance/charters-and-guides"
      request.path.should == "/insurance/charters-and-guides"
      assigns[:page].slug.should == "charters-and-guides"
    end

    it "GET /insurance displays insurance (1-part path)" do
      p = Page.make(:title => "insurance")
      p.save
      get "/insurance"
      request.path.should == "/insurance"
      assigns[:page].slug.should == "insurance"
    end
  end
end

If anyone knows a better way, feel free to let me know!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!