例のごとく既出だけど今回はattribute of subjectについて。rspec-core(2.5.1)/features/subject/attribute_of_subject.feature参考。「it { subject.first.size.should eq 2 }」とかするのやだよね。そんなときはitsを使えばステキになるよって話。 基本的にはシンボルか文字列で指定する describe Array do context 'when first created' do its(:size) { should eq 0 } its('size') { should eq 0 } end end % rspec -cfs attribute_of_subject_spec_1.rb Array when first created size should == 0 size

