DMH
DMH

Reputation: 2809

Best way to use Rspec Expect instead of should

I have noticed that I am getting depreciation warnings using should instead of expect with rspec. I cant find the best way to implement expect for the following test

it "is invalid without a goal" do 
  FactoryGirl.build(:project, goal: nil).should_not be_valid 
end 

If any help me out or put me in the right direction it would be much appreciated.

Upvotes: 0

Views: 179

Answers (1)

Малъ Скрылевъ
Малъ Скрылевъ

Reputation: 16507

According the documentation you could use expect.to something as follows:

it "is invalid without a goal" do 
   expect( FactoryGirl.build(:project, goal: nil) ).to_not be_valid 
end

Upvotes: 1

Related Questions