Sha256: 7da76f27f955a8bd132b4ee8917b5591ceda4b1624c6fb37c794bc7f63eabc4b

Contents?: true

Size: 1.43 KB

Versions: 8

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[: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

8 entries across 8 versions & 1 rubygems

Version Path
rad_core-0.2.6 spec/web/spec_helper_spec.rb
rad_core-0.2.5 spec/web/spec_helper_spec.rb
rad_core-0.2.4 spec/web/spec_helper_spec.rb
rad_core-0.2.3 spec/web/spec_helper_spec.rb
rad_core-0.2.2 spec/web/spec_helper_spec.rb
rad_core-0.2.1 spec/web/spec_helper_spec.rb
rad_core-0.2.0 spec/web/spec_helper_spec.rb
rad_core-0.0.30 spec/web/spec_helper_spec.rb