spec/integration_spec.rb in nyara-0.1.pre.0 vs spec/integration_spec.rb in nyara-0.1.pre.1

- old
+ new

@@ -1,6 +1,7 @@ require_relative "spec_helper" +require 'logger' class TestController < Nyara::Controller attr_reader :before_invoked before ":delete" do @@ -13,11 +14,11 @@ send_string '初めまして from test' end meta '#create' post '/create' do - set_header 'partial', partial('_partial').strip + set_header 'partial', partial('_partial', locals: { a: '1' }).strip redirect_to '#index' end post '/upload' do params @@ -84,17 +85,25 @@ assert_equal 'text/plain; charset=UTF-8', @test.response.header['Content-Type'] end it "redirect" do @test.post @test.path_to('test#create') - assert_equal 'This is a partial', @test.response.header['Partial'] + assert_equal 'This is a partial 1', @test.response.header['Partial'] assert @test.response.success? assert_equal 'http://localhost:3000/', @test.redirect_location @test.follow_redirect assert_equal '/', @test.request.path end + it "post params log output" do + data = { name: 1, sex: 0 } + Nyara.config.stub(:logger).and_return(Logger.new($stdout)) + out = capture(:stdout) { @test.post @test.path_to('test#create'), {}, data } + # puts out + assert_include out, 'params: {"name"=>"1", "sex"=>"0"}' + end + it "session continuation" do @test.session['a'] = '3' @test.get "/" assert_equal '3', @test.session['a'] @test.session['b'] = '4' @@ -159,9 +168,26 @@ end it "found but directory" do @test.get "/empty" assert_equal 404, @test.response.status + end + + it "found test.css and text/css content_type" do + @test.get "/test.css" + assert_equal "test css", @test.response.body + assert_include @test.response.header['Content-Type'],"text/css" + end + + it "found test.js" do + @test.get "/test.js" + assert_equal "test js", @test.response.body + assert_include @test.response.header['Content-Type'],"application/javascript" + end + + it "found test.jpg" do + @test.get "/test.jpg" + assert_include @test.response.header['Content-Type'],"image/jpeg" end end context "before / after" do it "invokes lifecycle callback" do