I'm using rails 4 and rspec with capybara for testing. I want to disable css in my test environment. How can I do that? Can anyone help me.
2 Answers
Capybara allows you to blacklist specific URLs from being loaded. You can utilize this feature to block the loading of your CSS files. For example if your CSS is loaded from /assets/application.css:
RSpec.configure do |config|
config.before(:each, js: true) do
page.driver.browser.url_blacklist = [
"http://127.0.0.1:#{page.server.port}/assets/application.css"
]
end
end
You can confirm what assets are getting loaded by turning on Capybara's debugging. To enable debugging simply set the driver to :webkit_debug instead of :webkit
Capybara.javascript_driver = :webkit_debug
2 Comments
user3655415
But I'm using poltergeist driver for capybara.
user3655415
I found this marcgg.com/blog/2015/01/05/…. But not getting how to add this file to disable css in specs. Any ideas from you for this please.