Sha256: 9c87412714b07d6d1bc2d8f8b6ead42860acd493b853f02e852328ee0f828bad

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

require "spec_helper"

describe "spec helper" do
  isolate :conveyors, :router, before: :all
  
  before do
    rad.web
    load 'rad/profiles/web.rb'
    
    class ::Planes
      inherit Rad::Controller::Http
      
      def fly
        render inline: 'all right'
      end
    end
  end
  
  after :all do
    remove_constants :Planes
  end
      
  describe 'wcall' do
    before do
      rad.router.routers = [
        [:simple_router, Rad::Router::SimpleRouter.new]
      ]
    end
    
    it "basic usage" do      
      wcall(Planes, :fly).should =~ /all right/      
      wcall('/planes/fly').should =~ /all right/
    end 
    
    it "with :cycle scope" do
      wcall(Planes, :fly){|c|
        c.call
      }.should =~ /all right/
    end
    
    describe "set_wcall" do
      before :all do
        set_wcall controller: Planes
      end
      
      it "usage with handy shortcut" do
        wcall(:fly).should =~ /all right/
      end
    end
  end
  
  describe "routes" do
    before do
      router = rad[:router]
      router.routers.unshift :restful_router, Rad::Router::RestfulRouter.new
      router.routers[:restful_router].add :planes, class_name: 'Planes'
    end
    
    it "url_for, url_for_path" do
      url_for(Planes, :fly).should == "/planes/fly"
      url_for_path("/path", key: 'value').should == "/path?key=value"            
    end
    
    it "named routes" do
      fly_planes_path.should == "/planes/fly"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rad_core-0.0.29 spec/web/spec_helper_spec.rb
rad_core-0.0.28 spec/web/spec_helper_spec.rb
rad_core-0.0.27 spec/web/spec_helper_spec.rb
rad_core-0.0.26 spec/web/spec_helper_spec.rb