Sha256: 15f69a685d3d8cae450fa9ce8d4fcd0b3418d9fedaa8f2afdad5a71af67fd9f5

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe DRbQS::Execution::ServerDefinition do
  context "when we call class methods" do
    subject do
      DRbQS.class_variable_get(:@@server_def)
    end

    it "should define server." do
      lambda do
        DRbQS.define_server do |server, argv, opts|
          server.add_hook(:finish) do |serv|
            serv.exit
          end
        end
      end.should change { subject.instance_variable_get(:@default_server_opts) }.from(nil).to({})
    end

    it "should set parser of options." do
      lambda do
        DRbQS.option_parser do |opt, hash|
          opt.on('--test') do |v|
            hash[:test] = true
          end
        end
      end.should change { subject.instance_variable_get(:@option_parse) }.from(nil)
    end

    it "should parse options." do
      lambda do
        DRbQS.parse_option(['--test'])
      end.should change { subject.instance_variable_get(:@argv) }.from(nil)
    end

    it "should start server." do
      DRbQS::Server.should_receive(:new)
      begin
        # After DRbQS::Server.new returns nil, raise error
        DRbQS.start_server(:uri => 'druby://localhost:13500')
      rescue
      end
    end

    it "should return empty help message" do
      DRbQS.clear_definition
      DRbQS.option_help_message.should be_nil
    end

    it "should return help message." do
      DRbQS.option_parser do |opt, hash|
        opt.on('--test') do |v|
          hash[:test] = true
        end
      end
      DRbQS.option_help_message.should be_an_instance_of String
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
drbqs-0.1.1 spec/execute/server_define_spec.rb
drbqs-0.1.0 spec/execute/server_define_spec.rb
drbqs-0.0.19 spec/execute/server_define_spec.rb
drbqs-0.0.18 spec/execute/server_define_spec.rb
drbqs-0.0.17 spec/execute/server_define_spec.rb
drbqs-0.0.16 spec/execute/server_define_spec.rb