【问题标题】:ruby rspec in `block (2 levels) in <top (required)>'ruby rspec 在 <top (required)> 中的 `block (2 levels)'
【发布时间】:2016-12-19 11:17:53
【问题描述】:

我在每个 rspec 测试中遇到错误消息 ./spec/models/lib/parsers/s_reality_cz/matcher_spec.rb:12:in `block (2 levels) in ' 的问题。我做错了什么?使用 rspec-rails 3.5。谢谢

代码: 需要'rails_helper'

RSpec.describe Parsers::SRealityCz::Matcher, :type=> :model do
  before do
    @doc = File.open("spec/fixtures/srealitycz_profile.html") { |f| Nokogiri::HTML(f) }
  end

  let(:parser) { described_class }

  it "returns total price" do
    expect(parser.title(@doc)).to eq "Prodej bytu 1+kk 40 m²"
  end
end

Rspec 输出:

Randomized with seed 37464


expected: "Prodej bytu 1+kk 40 m²"
     got: "Prodej bytu 1+kk 40 m²"

(compared using ==)

./spec/models/lib/parsers/s_reality_cz/matcher_spec.rb:12:in `block (2 levels) in <top (required)>'
-e:1:in `load'
-e:1:in `<main>'

1 example, 1 failure, 0 passed

Finished in 0.139173354 seconds

【问题讨论】:

    标签: ruby-on-rails ruby parsing rspec


    【解决方案1】:

    您的字符串看起来相同,但它们可能具有不同的编码。 将它们都转换为相同的编码(例如UTF-8),然后比较它们。

    【讨论】:

    • 多么容易:) 谢谢你
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    • 2011-09-13
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    相关资源
    最近更新 更多