Should not include

How can I describe an RSpec test to check if an array contains some value? Something like that:

tags.should include("one")
tags.should not include("two")

      

I can rewrite my condition:

tags.include?("two").should be_false

      

but I am looking for a nicer solution.

+3


source to share


2 answers


RSpec has should_not

as well should

.

tags.should include("one")
tags.should_not include("two")

      



Here are some more examples from the corresponding match.

+8


source


for Rspec v3:



expect(my_string).to include "some value"


expect(my_string).not_to include "some value"

      

+9


source