save_and_open_page已停止提供我的CSS [英] save_and_open_page has stopped serving up my css
问题描述
每当我在测试中调用 save_and_open_page
时,我的测试设置都可以很好地服务于以CSS正确格式化的页面。然后,我设置了一些javascript测试,并对设置进行了一些更改(很抱歉,我无法全部详细介绍-我还没有对文件做足够详尽的记录)。进行更改后,现在我在调用 save_and_open_page
时在浏览器中得到未格式化的html。
My testing setup was working very nicely serving up pages correctly formatted with css whenever I called save_and_open_page
from within a test. I then set up some javascript tests and made a few changes to my setup (sorry I can't detail them all - I haven't documented things well enough). After making changes I now get unformatted html in the browser when I call save_and_open_page
.
这是我的spec / spec_helper。 rb
Here's my spec/spec_helper.rb
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'factory_girl'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.add_setting(:seed_tables)
config.seed_tables = %w(notifications drug_names drug_modes drug_prefs db_tables db_columns column_values)
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy = :truncation, {except: config.seed_tables}
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.infer_base_class_for_anonymous_controllers = false
config.include Features::SessionHelpers, type: :feature
config.order = "random"
end
Spork.each_run do
FactoryGirl.reload
end
end
我在测试环境中安装了以下gem;
I have the following gems installed in my test environment;
gem 'rspec-rails', '2.13.0'
gem 'guard-rspec', '2.4.1'
gem 'rb-fsevent', '0.9.3'
gem 'terminal-notifier-guard', '1.5.3'
gem 'guard-spork', '1.5.0'
gem 'spork', '0.9.2'
gem 'capybara', '2.1.0'
gem 'timecop', '0.5.9.2'
gem 'launchy', '2.2.0'
gem 'factory_girl_rails', '4.2.1'
gem 'shoulda', '3.3.2'
gem 'faker', '1.1.2'
gem 'database_cleaner', '0.9.1'
gem 'selenium-webdriver', '2.32.1'
任何
推荐答案
此操作已从Capybara的拉609
This was removed from Capybara, in pull 609
Jnicklas:
我在这里根据我的身分成为
水豚生活的仁慈独裁者:
I am making an executive decision here by virtue of my status as Benevolent Dictator for Life of Capybara:
必须重写资产。严重地,这是整个Capybara代码库中
代码中最糟糕的部分。这是一个可怕的黑客,一开始从来没有使用过
,它给我们带来的微薄好处可以通过高级调试方法轻松实现
,例如在Selenium中运行相同的测试
并停止通过例如执行
Asset rewriting has got to go. It is seriously the worst part of the entire Capybara code base. It's a terrible hack which has never worked right in the first place and the slim benefit it gives us can easily be achieved by superior debugging methods, like running the same test in Selenium and halting execution via e.g. sleep, gets or binding.pry.
很抱歉,这使你们中的某些人感到烦恼,但这是我的工作,要为
艰难的决定做些什么进去,什么留在外面。如果我不做
的工作而仅仅接受一切,我们将不会以
的良好结果而告终。因此,我希望即使您
可能会不同意此决定。
I'm sorry if this annoys some of you, but it's my job to make the tough decisions about what goes in and what stays out. If I don't do that job and simply accept everything, we will not end up with a good result. So I hope that you can accept this decision even though you may disagree with it.
根据Save_and_open_page没有选择scss标记,您可以考虑使用水豚截图
-宝石。
As per Save_and_open_page not picking up scss markup you could consider making screenshots with the capybara-screenshot
-gem.
此宝石将引入 save_and_open_screenshot
。
但是,正如jnicklas在pull-request的讨论中提到的,有充分的理由完全不希望使用此功能:
However, as jnicklas mentions in the discussion in the pull-request there is a good reason to not want this feature at all:
...因为RackTest没有CSS和JS,所以现在您看到的页面与Capybara的页面不同
...because RackTest doesn't have CSS and JS, so now you're seeing the page differently from how Capybara would
这篇关于save_and_open_page已停止提供我的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!