Forum: RSpec Simple code dosn't work

Posted by Tom Brady (larsm)
on 2012-02-02 14:58
This is my 1st post. So please don't mess with me, if I did something
wrong.
Really need help on this one.
Thx!

using Ruby 1.9.3, Rails 3.2.1, RSpec 2.8.0


require 'rubygems'
require 'rspec'

test_array = [1,2,3,4,5]

describe "test" do
  for j in test_array do
    if j.even?
      it "#{j} should be even" do
        j.even?should be true     #throws an error on j == 2, j == 4
      end
    else
      it "#{j} shouldn't be even" do
        j.even?.should be false
      end
    end
  end
end
Posted by Bradley Symons (snomys)
on 2012-04-05 00:02
I think you have a syntactical error on the line thats throwing the 
error, you state:

>         j.even?should be true     #throws an error on j == 2, j == 4

should this line not read as:

j.even?.should be true
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.