2017-04-24 15 views
1

うまく動作する次のrspecモックを作成しましたが、実行すると警告が表示されます。Rspec:廃止予定の警告

Using `stub` from rspec-mocks' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` instead. called from /file/path.rb:26:in `block (3 levels) in <top (required)>'. 

ここは私の単体テストです。私のユニットテストでは、ライン26はuser_health_condition.stub(:user_condition_flag) do |user_id|です。私はこの警告を得る理由を期待して使用しているので、警告ごとに?

describe '.user_condition_flag' do 
    let(:expected_result_with_diabetes) { 'Y' } 
    let(:expected_result_without_diabetes) { 'N' } 
    let(:user_id_1) { 38 } 
    let(:user_id_2) { 39 } 

    context 'with entries in table' do 
    it 'returns expected results' do 
     user_health_condition = double(user_health_condition) 
     allow(user_health_condition).to receive(:user_condition_flag).and_return(expected_result_with_diabetes) 
     user_health_condition.stub(:user_condition_flag) do |user_id| 
     if user_id == :user_id_1 
      'Y' 
     elsif user_id == :user_id_2 
      'N' 
     end 
     end 

     expect(user_health_condition.user_condition_flag(:user_id_1)).to eq(expected_result_with_diabetes) 
     expect(user_health_condition.user_condition_flag(:user_id_2)).to eq(expected_result_without_diabetes) 
    end 
    end 
end 

答えて

関連する問題