test/page_spec.rb in trellis-0.0.1 vs test/page_spec.rb in trellis-0.0.2
- old
+ new
@@ -7,23 +7,25 @@
before(:each) do
@application = TestApp::MyApp.new
@request = Rack::MockRequest.new(@application)
end
- it "if the event handler returns self it should render the receiving page" do
- response = @request.get("/home.event1")
- response.body.should == "<html><body><h1>Hello World!</h1></body></html>"
+ it "should redirect to the receiving page if the event handler returns self" do
+ response = @request.get("/home/events/event1")
+ response.status.should be(302)
+ response.headers['Location'].should == '/home'
end
it "should return a response as a string if the event handler returns a String" do
- response = @request.get("/home.event2")
+ response = @request.get("/home/events/event2")
response.body.should == "just some text"
end
- it "should render the injected page as a response if the event handler returns an injected page " do
- response = @request.get("/home.event3")
- response.body.should == "<html><body><p>Goodbye Cruel World </p></body></html>"
+ it "should redirect to the injected page as a response if the event handler returns an injected page " do
+ response = @request.get("/home/events/event3")
+ response.status.should be(302)
+ response.headers['Location'].should == '/other'
end
it "should invoke the before_load method if provided by the page" do
response = @request.get("/before_load")
response.body.should == "<html><body>8675309</body></html>"
@@ -33,14 +35,22 @@
response = @request.get("/after_load")
response.body.should == "<html><body>chunky bacon!</body></html>"
end
end
-describe Trellis::Page, " when calling inject_dependent_pages on an instance of child class of Page" do
+describe Trellis::Page, " when calling inject_dependent_pages on an instance of Page" do
it "should contain instances of the injected pages" do
homepage = TestApp::Home.new
homepage.inject_dependent_pages
injected_page = homepage.instance_eval { @other }
injected_page.should be_an_instance_of(TestApp::Other)
+ end
+end
+
+describe Trellis::Page, " when created with a custom route" do
+ it "should contain an instance of Router" do
+ router = TestApp::RoutedDifferently.router
+ router.should_not be_nil
+ router.should be_an_instance_of(Trellis::Router)
end
end