我正在我的rails项目中为一个普通的旧ruby类编写一些rspec示例,我遇到了以下问题.我有这个构造函数:
class Server
def initialize(host='localhost',options={:port => 443, :password => '', :vpncmd_bin_path => '/usr/local/bin/vpncmd', :timeout => 5})
@host = host
@port = options[:port].present? ? options[:port] : 443
@password = options[:password].present? ? options[:password] : ''
@vpncmd_bin_path = options[:vpncmd_bin_path].present? ? options[:vpncmd_bin_path] : '/usr/local/bin/vpncmd'
@timeout = options[:timeout].present? ? options[:timeout] : 5
@hubs = {}
@hub_cache_dirty = true
@hub_password_cache = {}
end
...
end
Run Code Online (Sandbox Code Playgroud)
这个测试例子:
it "should have a default constructor that takes no argument" do
s = SoftEther::Server.new()
expect(s.host).to be_equal('localhost')
expect(s.port).to be_equal('443')
expect(s.timeout).to be_equal(5) …Run Code Online (Sandbox Code Playgroud)