Sha256: 49917798c0a7dd7dba5553c03d41dca8460a30b0ce007d81c31adb7c8132ced5

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require "#{File.expand_path(File.dirname(__FILE__))}/helper"

describe "Remote Basic" do  
  with_environment :test
  with_router_spec
  
  before :all do
    class ::AnRemote
      def call; end
    end
  end
  
  after :all do
    remove_constants %w(AnRemote)
  end
  
  def call_router path, params 
    crystal.conveyors.web.call :path => path, :params => Crystal::Params.new(params)
  end
  
  it "basic" do    
    workspace = call_router '/an_remote/call', :format => 'json'
    
    expected_result = {      
      :path => "/an_remote/call", 
      :params => {"format" => "json"}, #, 'method_name' => 'call', 'class_name' => 'AnRemote'},
      
      :class_variable => AnRemote,       
      :method_variable => "call"
    }
    workspace.to_h(true).symbolize_keys.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

1 entries across 1 versions & 1 rubygems

Version Path
crystal_ext-0.0.11 spec/router/integration_spec.rb