require "#{File.expand_path(File.dirname(__FILE__))}/helper" describe "Integration" do with_environment with_http before :all do HttpController = Crystal::HttpController @dir = "#{File.expand_path(File.dirname(__FILE__))}/basic_spec" $LOAD_PATH << @dir load 'crystal/profiles/web.rb' end after :all do $LOAD_PATH.delete @dir remove_constants %w( HttpController SmokeTestSpec JsonFormatSpec RequestAndSessionSpec ) end it "smoke test" do class ::SmokeTestSpec inherit HttpController def action respond_to do |format| format.json{render :json => {:a => 'b'}} format.html{render :inline => "some content"} end end end wcall("/smoke_test_spec/action") response.body.should == %(some content) wcall("/smoke_test_spec/action", :format => 'json') response.body.should == %({"a":"b"}) end it "json" do class ::JsonFormatSpec inherit HttpController def action render :json => {:a => 'b'} end end wcall("/json_format_spec/action.json") response.body.should == %({"a":"b"}) # response.rson.should == {'result' => 'value'} end it "should have workspace, request and session" do class ::RequestAndSessionSpec inherit HttpController inject :workspace => :workspace def action workspace.should_not == nil workspace.request.should_not == nil workspace.request.session.should_not == nil self.class.request_and_session_passed = true render :json => {:a => 'b'} end class << self attr_accessor :request_and_session_passed end end wcall('/request_and_session_spec/action.json') RequestAndSessionSpec.request_and_session_passed.should be_true end end