Launchy :: ApplicationNotFoundError:

时间:2013-04-21 23:43:49

标签: ruby-on-rails rspec capybara integration-testing

试图让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

3 个答案:

答案 0 :(得分: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 )

答案 1 :(得分:5)

我是Launchy的作者,刚刚获悉此问题。我通常通过GitHub进行错误修复并将此问题放在那里。 Issue #65

每次遇到Launchy问题时,请启用launchy debugging和file an issue with the project on github

您可以通过设置环境变量LAUNCHY_DEBUG=true来启用launchy调试。您可以从shell执行此操作,或者如果要在应用程序中嵌入launchy,则可以通过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

或者如果你要嵌入launchy:

% 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

答案 2 :(得分:1)

我必须这样做:

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

Launchy.open(fileUri)

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