小编ban*_*abr的帖子

RSpec be_equal无效

我正在我的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)

ruby rspec ruby-on-rails

2
推荐指数
1
解决办法
127
查看次数

标签 统计

rspec ×1

ruby ×1

ruby-on-rails ×1