Sha256: b625672129124f8f9c70541b86d2839698d899aa29979ac681bc562c378ff969

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

require 'integration/spec_helper'

describe "Integration" do
  with_environment
  with_http
  with_load_path spec_dir
  
  before :all do
    HttpController = Rad::HttpController
    load 'rad/profiles/web.rb'
  end
  
  after :all do        
    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, env, and session" do
    class ::RequestAndSessionSpec
      inherit HttpController
            
      inject workspace: :workspace
      def action
        workspace.should_not == nil
        workspace.env.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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rad_core-0.0.13 spec/integration/basic_spec.rb