Satchel
Satchel

Reputation: 16724

how do I use Rspec to check if something is an Array?

I tried the following and got the associated error:

Failure/Error: reminders_array.should be_an(Array)
     NoMethodError:
       undefined method `should' for #<Array:0x0000000202c9a0>

reminders_array should be an Array and I would like to check for it with an Rspec test. How should I do it differently from the tested assertion above?

Upvotes: 4

Views: 1048

Answers (1)

pangpang
pangpang

Reputation: 8821

should is old syntax, you should do like this:

expect(reminders_array).to be_an(Array) 

or:

expect(reminders_array).to be_an_instance_of(Array)

You can get more info from rspec-expectations

Upvotes: 5

Related Questions