Sha256: bee3072759482b40946ad671f4373dbb689e0b0bdfface7ab3b5e55d103f207c

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))

module Hoth
  
  describe ServiceModule do
  
    it "should have a name" do
      service_module = ServiceModule.new :name => :my_service_module
      service_module.name.should equal(:my_service_module)
    end
  
    it "should have an environment" do
      service_module = ServiceModule.new(:name => "service_module_name")
      block = Proc.new {}
      service_module.env :test, &block
      service_module[:test].should be_a(ServiceModule::Environment)
    end
  
    it "should have multiple environments" do
      service_module = ServiceModule.new(:name => "service_module_name")
      block = Proc.new {}
      service_module.env :test, :development, &block
      service_module[:test].should be_a(ServiceModule::Environment)
      service_module[:development].should be_a(ServiceModule::Environment)
    end
  
    it "should be able to add services" do
      service_module = ServiceModule.new(:name => "service_module_name")
      block = Proc.new {}
      
      service_module.env :test, &block
      
      ServiceRegistry.should_receive(:locate_service).with(:service_name).and_return(service = mock("ServiceMock"))
      service.should_receive(:module=).with(service_module)
      service.should_receive(:via_endpoint).with(:special_endpoint)
      
      service_module.add_service("service_name", :via => :special_endpoint)
    end
  
    describe ServiceModule::Environment do

      it "should have an endpoint" do
        endpoint_mock = mock("Endpoint").as_null_object
      
        endpoint_block = Proc.new do
          endpoint :development do
            host 'localhost'
          end
        end
        
        env = ServiceModule::Environment.new(&endpoint_block)      
        env[:development].should_not be(nil)
      end
    
    end
  
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hoth-0.4.2 spec/unit/service_module_spec.rb
hoth-0.4.1 spec/unit/service_module_spec.rb
hoth-0.4.0 spec/unit/service_module_spec.rb