2013-04-21 36 views
8

試圖讓save_and_open_page在所有的工作使我有以下錯誤:Launchy :: ApplicationNotFoundError:

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 
+0

有趣的是,我可以將錯誤消息路徑複製並粘貼到瀏覽器中並查看頁面。 – tehfailsafe 2013-04-21 23:46:05

+0

我有同樣的問題。我注意到的一件事是,當我複製網址並在命令行中用'launchy C:/ Sites/...'運行它時,我得到了同樣的錯誤,但是當我在'C:'之前放入'file:///'時, 有用。 – Matt 2013-04-27 20:34:37

+0

有同樣的問題。它在工作之前。不確定錯誤是否與運行軟件包更新有關。 – user938363 2013-04-29 03:09:20

回答

7

這是因爲在文件路徑中的驅動器盤符被錯誤地判定爲URI方案的一部分。

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

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

+1

該解決方案已經過驗證並且可以正常工作。請標記爲答案,以便布拉德可以得到賞金點。謝謝。 – user938363 2013-04-30 20:30:42

+0

不客氣! – 2013-05-01 01:14:30

+0

非常感謝! – tehfailsafe 2013-05-01 17:59:25

5

我Launchy的作者,只是通報了這一問題。我通常通過GitHub進行錯誤修復,並將此問題放在那裏。 Issue #65

您遇到的問題與Launchy任何時間,請打開launchy調試和file an issue with the project on github

您可以通過設置環境變量LAUNCHY_DEBUG=true打開launchy調試。如果你在應用程序中嵌入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=>"https://stackoverflow.com/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=>"https://stackoverflow.com/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 
+0

感謝您的回覆。以下是調試輸出: – user938363 2013-04-30 17:28:00

+0

另外請注意,save_and_open_page不會產生任何錯誤。但是rspec沒有顯示任何頁面。 – user938363 2013-04-30 17:36:26

+0

@copiousfreetime如果launchy無法找到任何鏈接讓我們說有一個拼寫錯誤,那麼請指導我解決這個問題嗎?那麼是否有任何launchy方法可以搜索「給定的單詞或鏈接」 – Abhinay 2014-07-24 17:27:05

1

我只是有:

,可以暫時更改線12 /launchy/lib/launchy/applications/browser.rb修復要做:

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

Launchy.open(fileUri) 

請注意「file:」後面的三個斜槓。這是在Windows 8上使用github-markdown-0.5.5。

相關問題