Ruby返回双引号

时间:2015-10-01 02:37:37

标签: ruby rspec

嗨我有一个从rspec传回的字符串。

应该表明 "alias/public_html/ab1/ab2/"

但我得到了"\"alias/public_html/ab1/ab2/\""

我收到以下rspec错误:

 WebServer::HttpdConf#alias_path returns the aliased path                   
 Failure/Error: expect(httpd_file.alias_path('/ab/')).to eq 'alias/public_html/ab1/ab2/'

   expected: "alias/public_html/ab1/ab2/"
        got: "\"alias/public_html/ab1/ab2/\""

   (compared using ==)
 # ./spec/lib/config/httpd_conf_spec.rb:90:in `(root)'

这是我的实际程序文件

def alias_path(path)
  @hash_httpd['Alias'][path]
end

请帮忙

修改

抱歉,我是RUby的新手,这是httpd_file

def initialize(httpd_file_content)
  @hash_httpd = Hash.new
  httpd_file_content.each_line do | line |
    @commands = line.split
    if @commands.length == 2
      @hash_httpd[@commands[0]] = @commands[1]
    else

      if !@hash_httpd.has_key?(@commands[0])
        al = Hash.new
        @hash_httpd[@commands[0]] = al
      else
        al = @hash_httpd[@commands[0]]
      end

      al[@commands[1]] = @commands[2]
    end
  end
end

1 个答案:

答案 0 :(得分:1)

如果您确定 select c.customerFn, c.customerLn from customers c join orders o where o.customerID = c.customerID join order_contents l where l.orderId = o.orderId join products p where p.productId = l.productId order by p.unitPrice desc limit 1 输出为alias_path,则可以通过从返回的路径中删除引号(如果有)来修改"alias/public_html/ab1/ab2/"方法定义:< / p>

alias_path