Facing a issue when i am testing this validates length with shoulda_matchers ensure_length_of
Model
class Plant < ActiveRecord::Base
validates :code, :length => { :in => 2..6 }
end
Rspec
require 'spec_helper'
describe Plant do
before { @plant = FactoryGirl.create(:plant) }
it { should ensure_length_of(:code).is_at_least(2).with_message("is too short (minimum is 2 characters)")}
end
Error:
Failures:
1) Plant
Failure/Error: it { should ensure_length_of(:code).is_at_least(2).with_message("is too short (minimum is 2 characters)")}
Did not expect errors to include "is too short (minimum is 2 characters)" when naics_code is set to "xx", got error: is too short (minimum is 2 characters)
# ./spec/models/plant_spec.rb:11:in `block (2 levels) in <top (required)>'
Thanks!