SORU
13 Aralık 2011, Salı


Bunu engellemek ve bir arasındaki fark RSpec blok belirtin

Bunu engellemek ve bir arasındaki fark RSpec blok belirtmek nedir?

subject { MovieList.add_new(10) }

specify { subject.should have(10).items }
it { subject.track_number.should == 10}

Aynı işi yapacak gibi görünüyorlar. Sadece kontrol emin olmak için.

CEVAP
13 Aralık 2011, Salı


Yöntemleri the same; gözlük İngilizce okumak daha güzel yapmak için test vücut dayalı olarak verilmektedir. Bu iki göz önünde bulundurun:

describe Array do
  describe "with 3 items" do
    before { @arr = [1, 2, 3] }

    specify { @arr.should_not be_empty }
    specify { @arr.count.should eq(3) }
  end
end

describe Array do
  describe "with 3 items" do
    subject { [1, 2, 3] }

    it { should_not be_empty }
    its(:count) { should eq(3) }
  end
end

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • CorridorDigital

    CorridorDigi

    17 Mayıs 2010
  • Sergio Lafuente Rubio

    Sergio Lafue

    11 Aralık 2008
  • TheForgottenGamer1

    TheForgotten

    28 AĞUSTOS 2009