我剛剛在github上發佈了一個gem,並且我用aruba gem寫了集成測試。但是我無法運行功能,因爲它的行爲與命令行不同。用黃瓜和阿魯巴測試發電機
如果我運行的功能軌道找不到我的發電機,如果我重複命令行上的相同步驟,他們完美地運行。
這是一個失敗的功能
Background: A new rails application has been created with my gem
Given a rails application named "my_app" exists
And this gem is installed in that application
@announce
Scenario: Installation using default values
When I successfully run `rails generate google_authentication:install`
# this is needed because rails g returns 0 when can't find the generator
And the output should not contain "Could not find generator"
這是實現背景步驟
Given /^a rails application named "([^\"]*)" exists$/ do |app_name|
@app_name = app_name
Given "I successfully run `rm -rf #{app_name}`" # added to ensure that the working directory is clean
And "a directory named \"#{app_name}\" should not exist"
And "I successfully run `rails new #{app_name}`"
And "I cd to \"#{app_name}\""
end
When /^this gem is installed in that application$/ do
gempath = File.expand_path('../../../', __FILE__)
Given "I append to \"Gemfile\" with \"gem 'gem-name', :path => '#{gempath}'\""
And "I successfully run `bundle check`"
end
我試圖調試,我發現的代碼,如果我改變bundle check
命令bundle install
和我捕獲輸出,我的寶石沒有在捆綁中列出。因此,如果我編寫rails g --help
步驟,我的發生器不在那裏。然而,設計寶石和發電機在那裏(設計被列爲需求在我的寶石。因此,似乎bundler/rails是不是加載所有內部阿魯巴臺階。
我認爲這是一個錯誤與阿魯巴或Bundler,我打開an issue for aruba但仍然沒有答案。
完整的代碼上Github
最後一件事我已經看到,並試圖this solution,但沒有運氣
如果由於某些原因#{app_name}變成空白字符串,我不願意看到測試失敗... – corroded
遇到類似問題。我保持一個古老的寶石來支持導軌3.1>。問題是bundle install命令失敗。雖然輸出顯示它已安裝,但當我檢查Gemfile.lock時,它不存在!這也不是一個阿魯巴問題,因爲我沒有使用阿魯巴寶石。 – kgpdeveloper
我意識到我一直在做錯誤的方式。看看我寫我的測試:https://github.com/bridgeutopia/textile_editor_helper。謝謝。 – kgpdeveloper