This is my validation on a variable
validates :code, presence: true,uniqueness: true, length: { maximum: 6,minimum: 6 }
and this is the factory
factory :event do
name "Oracle"
sequence(:code) do |n|
"ABCDE#{n}"
end
admin
end
factory :question do
body "Hi how are you?"
approved false
event
end
but when i create question 4 times I get
Validation failed: Code is too long (maximum is 6 characters)
Any reasons how? I thought the value n would go from 0 onwards incrementing.
scenario "can vote on a question" do
question = create(:question,approved: true)
fill_in "subscriber_code",with: question.event.code
click_button "Join Event"
page.should have_content question.body
page.should have_button "up"
end
scenario "cannot vote on a question that is still pending with the admin" do
question = create(:question)
fill_in "subscriber_code",with: question.event.code
click_button "Join Event"
page.should_not have_content question.body
page.should_not have_button "up"
end
scenario "cannot vote on a question that is has been rejected by admin" do
question = create(:question)
fill_in "subscriber_code",with: question.event.code
click_button "Join Event"
page.should_not have_content question.body
page.should_not have_button "up"
end