Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

should not include

Tags:

ruby

rspec

How can I describe RSpec test to check if the array doesn't include some value? Something like this:

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

I can rewrite my condition:

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

but I'm looking for more beautiful solution.

like image 674
ceth Avatar asked Mar 28 '12 17:03

ceth


2 Answers

for Rspec v3:

expect(my_string).to include "some value"


expect(my_string).not_to include "some value"
like image 149
AlekseiPetrovski Avatar answered Oct 06 '22 15:10

AlekseiPetrovski


RSpec has should_not as well as should.

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

Here some more examples of the include matcher.

like image 42
BaronVonBraun Avatar answered Oct 06 '22 16:10

BaronVonBraun