Sha256: 49bcfa735247eb1e0781b5e3c456555ece608dd754e5ea9ff7dff1e724c5ffad

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe "Remote Basic" do  
  before :all do    
    class ::AnRemote
      def call; end
    end
  end  
  
  isolate :conveyors, :router
  
  after :all do
    remove_constants %w(AnRemote)
  end
  
  before do
    rad.conveyors.web.use Rad::Router::Processors::Router, :class_variable, :method_variable
    rad.router.routers = [
      [:simple_router, Rad::Router::SimpleRouter.new]
    ]
  end
  
  def call_router path, params 
    rad.conveyors.web.call path: path, params: Rad::Conveyors::Params.new(params)
  end
  
  it "basic" do    
    workspace = call_router '/an_remote/call', format: 'json'
    
    expected_result = {      
      path: "/an_remote/call", 
      params: {format: 'json'},
      
      class_variable: AnRemote,       
      method_variable: :call
    }
    workspace.to_h(true).subset(expected_result.keys).should == expected_result
  end
    
  it "params must be casted to string" do
    workspace = call_router '/an_remote/call', a: 'b'
    workspace.params.to_h.subset(:a).should == {a: 'b'}
  end
  
  it "default router should raise error if route is invalid" do
    lambda{call_router '/invalid/call', format: 'json'}.should raise_error(/uninitialized constant Invalid/)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rad_core-0.2.6 spec/router/integration_spec.rb
rad_core-0.2.5 spec/router/integration_spec.rb
rad_core-0.2.4 spec/router/integration_spec.rb
rad_core-0.2.3 spec/router/integration_spec.rb
rad_core-0.2.2 spec/router/integration_spec.rb
rad_core-0.2.1 spec/router/integration_spec.rb
rad_core-0.2.0 spec/router/integration_spec.rb
rad_core-0.0.30 spec/router/integration_spec.rb
rad_core-0.0.29 spec/router/integration_spec.rb
rad_core-0.0.28 spec/router/integration_spec.rb
rad_core-0.0.27 spec/router/integration_spec.rb
rad_core-0.0.26 spec/router/integration_spec.rb