You said that you are writing a specification for validation validation, but I see that you are testing in capybara (or similar) with "fill_in"
Instead, I highly recommend writing unit tests to test your models.
Specification / Models / your_model_spec.rb
require 'spec_helper' describe YourModel do it "should not allow a blank name" do subject.name = "" subject.should_not be_valid subject.should have(1).error_on(:name) end end
Thus, you test in isolation - only what you need to check is whether the controller, or the view, or even the loop through the flash is working correctly.
Thus, your test is fast, durable and isolated.
source share