2016-05-03 5 views
3

私はRubyと様々なオープンソースソフトウェアに慣れていますRSpecの記述では、意図したとおりの目的を達成できないと思われるいくつかの "文"に気付きました。これらのコーディングエラーですか?またはRSpecやRubyの魔法がありますか? (奇妙なオーバーロードされた演算子の可能性?)コードはRSpecで実際にアサートしていませんか?

例は#???

(Rubiniusの/スペック/ルビー/コア/アレイ/ permutation_spec.rb)

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 

(談話/スペック/モデル/ topic_link_spec.rb)

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 

    ... 

:疑わしいラインに追加(シェフ/スペック/ユニット/ chef_fs/parallelizer.rb)

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 

(ボッシュ/スペック/外部/ aws_bootstrap_spec.rb)

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 
+0

これらの行の目的は何かを判断するのは難しいです(デバッグから残されていますか?誰かがアサーションを作りたがっていませんでしたか?)。それらは実際にはバグではありません。なぜなら、それらが参照するメソッドが存在する限り、そのサンプルが失敗するかどうかに影響を与えないからです。しかしそれに加えて、それらの行はちょうど役に立たないコードです... –

答えて

1

私は特別な行動はないと思います。私はあなたがテストコードでエラーを見つけたと思います。

0

何ら表明はありませんので、これは、比較のみ動作しません:

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

以降RSpecの構文を使用して:

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

をそれはように記述する必要があるであろう:

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

関連する問題