Ruby 在RSpec中没有实际断言的代码?

Ruby 在RSpec中没有实际断言的代码?,ruby,rspec,Ruby,Rspec,我是Ruby新手,在各种开源软件中,我注意到一些RSpec描述中的一些“语句”似乎没有达到他们的目的,比如他们想做一个断言,但没有。是这些编码错误还是我缺少了一些RSpec或Ruby魔法?(异常重载运算符的可能性?) 示例,带#???添加到可疑行: (rubinius/spec/ruby/core/array/permutation\u spec.rb) (chef/spec/unit/chef_fs/parallelizer.rb) context”With:ordered=>false(无序

我是Ruby新手,在各种开源软件中,我注意到一些RSpec描述中的一些“语句”似乎没有达到他们的目的,比如他们想做一个断言,但没有。是这些编码错误还是我缺少了一些RSpec或Ruby魔法?(异常重载运算符的可能性?)

示例,带#???添加到可疑行:

(rubinius/spec/ruby/core/array/permutation\u spec.rb)

(chef/spec/unit/chef_fs/parallelizer.rb)

context”With:ordered=>false(无序输出)“do
它“一个空的输入产生一个空的输出”吗
并行化([],:ordered=>false)do
睡眠10
end.to_a=[]#???
预计(经过的时间)。小于0.1
结束
(bosh/spec/external/aws_bootstrap_spec.rb)

它“配置ELBs”do
load_balancer=elb.load_balancers.detect{| lb | lb.name==“cfrouter”}
期望(负载均衡器)。而不是零
期望(load|balancer.subnets.sort{s1,s2 | s1.id s2.id})。到eq([cf|elb1_子网,cf|elb2_子网]。sort{s1,s2 | s1.id s2.id})
expect(load_balancer.security_groups.map(&:name))到eq([“web”])
config=Bosh::AwsCliPlugin::AwsConfig.new(aws\u配置\u模板)
hosted_zone=route53.hosted_zones.detect{| zone | zone.name=“{config.vpc_生成的_domain}.”
record_set=hosted_zone.resource_record_set[“\\052.{config.vpc_generated_domain}.”,“CNAME”]#例如“*.midway.cf app.com”
期望(记录集)。不为零
record_set.resource_records.first[:value]==负载_balancer.dns_name#???
expect(record_set.ttl.)至等式(60)
结束

我认为没有任何特殊行为。我认为您在测试代码中发现了错误。

这不起作用,因为没有断言,只有比较:

@numbers.permutation(9).entries.size==0

它需要写成:

@numbers.permutation(9).entries.size.should==0

或者使用较新的RSpec语法:


expect(@numbers.permutation(9.entries.size.))to eq(0)

很难确定这些行的目的是什么(调试遗留下来的?有人想创建断言,但没有完成?)。它们不是真正的bug,因为它们对示例是否会失败或通过没有任何影响(只要它们引用的方法存在)。但除此之外,这些行只是无用的代码。。。
it "returns no permutations when the given length has no permutations" do
  @numbers.permutation(9).entries.size == 0        #???
  @numbers.permutation(9) { |n| @yielded << n }
  @yielded.should == []
end
it 'works' do
  # ensure other_topic has a post
  post

  url = "http://#{test_uri.host}/t/#{other_topic.slug}/#{other_topic.id}"

  topic.posts.create(user: user, raw: 'initial post')
  linked_post = topic.posts.create(user: user, raw: "Link to another topic: #{url}")

  TopicLink.extract_from(linked_post)

  link = topic.topic_links.first
  expect(link).to be_present
  expect(link).to be_internal
  expect(link.url).to eq(url)
  expect(link.domain).to eq(test_uri.host)

  link.link_topic_id == other_topic.id       #???
  expect(link).not_to be_reflection

  ...
context "With :ordered => false (unordered output)" do
  it "An empty input produces an empty output" do
    parallelize([], :ordered => false) do
      sleep 10
    end.to_a == []                        #???
    expect(elapsed_time).to be < 0.1
  end
it "configures ELBs" do
  load_balancer = elb.load_balancers.detect { |lb| lb.name == "cfrouter" }
  expect(load_balancer).not_to be_nil
  expect(load_balancer.subnets.sort {|s1, s2| s1.id <=> s2.id }).to eq([cf_elb1_subnet, cf_elb2_subnet].sort {|s1, s2| s1.id <=> s2.id })
  expect(load_balancer.security_groups.map(&:name)).to eq(["web"])

  config = Bosh::AwsCliPlugin::AwsConfig.new(aws_configuration_template)
  hosted_zone = route53.hosted_zones.detect { |zone| zone.name == "#{config.vpc_generated_domain}." }
  record_set = hosted_zone.resource_record_sets["\\052.#{config.vpc_generated_domain}.", 'CNAME'] # E.g. "*.midway.cf-app.com."
  expect(record_set).not_to be_nil
  record_set.resource_records.first[:value] == load_balancer.dns_name   #???
  expect(record_set.ttl).to eq(60)
end