Testing custom validators with rspec. Why do I get Proc?
rspec, ruby, ruby-on-rails, ruby-on-rails-3, tdd
Solution
By using {} in your expect, then you really aren't executing the expect method --- instead you're sending expect a block. So rename to
it "should not validate activity with empty start time" do
expect( Graph.new( {start_time: ''}).valid? ).to eq(false)
end
Problem
As the title suggest I am trying to test a custom validator with Rspec. I get an error and I don't understand why... If you can shed some light I would really appreciate it. Here we go: Validator spec ``` require 'spec_helper' describe GraphDateValidator do it "should not validate activity with empty start time" do expect { Graph.new( {start_time: ''}).valid? }.to eq(false) end end ``` If I print `Graph.new( {start_time: ''}).valid?` it prints `false` However when it goes through the spec it returns a Proc object: ``` expected: false got: #<Proc:0x007fe5853fdd48@/Users/MLP/... ``` Can anybody tell me why I am getting that proc object? Thank you!