a bit faster rspec tests
Just disable all you observers and run them when necessary.
In the spec_helper.rb file:
RSpec.configure do |config|
ActiveRecord::Base.observers.disable :all
end
and then on those specs where you need to run the observers do the following:
it "should test something" do
ModelName.observers.enable :model_name_observer do
# the code run here will use the observer
end
end
Written by Miguel
Related protips
1 Response
Nice and clean. Thanks.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rspec
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#