9

试图开始save_and_open_page工作给了我以下错误:

1) index page my first test
 Failure/Error: save_and_open_page
 Launchy::ApplicationNotFoundError:
   No application found to handle 'C:/Sites/Sublist_v2/tmp/capybara/capybara-201304211638563116158687.html'
 # ./spec/features/comics_page_spec.rb:6:in `block (2 levels) in <top (required)>'

规格:

require 'spec_helper'

feature 'index page' do
  scenario "my first test" do
    visit root_path
    save_and_open_page
    # Launchy.open('http://stackoverflow.com')
  end
end

如果我取消注释 Launchy 行它可以正常工作,所以我不确定问题是什么......也许路径有问题c:/

Gemfile

group :development, :test do
  gem 'spork-rails'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
end

group :test do
  gem 'faker'
  gem 'capybara'
  gem 'launchy'
  gem 'database_cleaner'
  gem 'shoulda-matchers'
end
4

3 回答 3

7

这是因为文件路径中的驱动器号被错误地确定为 uri 方案的一部分。

您可以通过更改 /launchy/lib/launchy/applications/browser.rb 中的第 12 行来临时修复它:

return true if File.exist?( uri.path ) and uri.scheme.nil?

return true if File.exist?( uri.path ) && !schemes.include?( uri.scheme )

于 2013-04-30T19:16:24.623 回答
5

我是 Launchy 的作者,刚刚得知这个问题。我通常通过 GitHub 进行错误修复并将这个问题放在那里。问题 #65

任何时候遇到 Launchy 的问题,请打开 launchy 调试并在 github 上提交项目问题

您可以通过设置环境变量来开启启动调试LAUNCHY_DEBUG=true。如果您在应用程序中嵌入launchy,您可以从shell 或通过ruby 代码执行此操作。

% export LAUNCHY_DEBUG=true
% launchy http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror
AUNCHY_DEBUG: URI parsing pass 1 : http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror -> {:scheme=>"http", :user=>nil, :password=>nil, :host=>"stackoverflow.com", :port=>nil, :path=>"/questions/16137410/launchyapplicationnotfounderror", :query=>nil, :fragment=>nil}
LAUNCHY_DEBUG: Checking if class Launchy::Application::Browser is the one for handles?(http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)}
LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : possibility : /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : Using browser value '/usr/bin/open'
LAUNCHY_DEBUG: wet_run: before exec in child process
LAUNCHY_DEBUG: commandline_normalized => /usr/bin/open http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror

或者,如果您正在嵌入启动:

% irb
>> require 'launchy'
>> ENV['LAUNCHY_DEBUG']="true"
>> Launchy.open( "http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror" )
LAUNCHY_DEBUG: URI parsing pass 1 : http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror -> {:scheme=>"http", :user=>nil, :password=>nil, :host=>"stackoverflow.com", :port=>nil, :path=>"/questions/16137410/launchyapplicationnotfounderror", :query=>nil, :fragment=>nil}
LAUNCHY_DEBUG: Checking if class Launchy::Application::Browser is the one for handles?(http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Windows is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::HostOsFamily::Darwin is the one for matches?(darwin12.2.0)}
LAUNCHY_DEBUG: Checking if class Launchy::Detect::RubyEngine::Mri is the one for is_current_engine?(ruby)}
LAUNCHY_DEBUG: Launchy::Application : found executable /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : possibility : /usr/bin/open
LAUNCHY_DEBUG: Launchy::Application::Browser : Using browser value '/usr/bin/open'
LAUNCHY_DEBUG: wet_run: before exec in child process
>> LAUNCHY_DEBUG: commandline_normalized => /usr/bin/open http://stackoverflow.com/questions/16137410/launchyapplicationnotfounderror
于 2013-04-30T16:37:44.340 回答
1

我只需要这样做:

fileUri = 'file:///' + outputFile.path

Launchy.open(fileUri)

注意“file:”后面的三个斜杠。这是 Windows 8 上的 github-markdown-0.5.5。

于 2013-10-15T15:58:17.783 回答