I've just released a gem on github and I wrote integrations test with aruba gem. However I can't run features because it behaves differently from command line.
If i run the features rails can't find my generator, if I repeat the same steps on the commandline they run flawlessly.
This is a failing feature
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"
And this is the code which implements background steps
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('../..开发者_StackOverflow社区/../', __FILE__)
Given "I append to \"Gemfile\" with \"gem 'gem-name', :path => '#{gempath}'\""
And "I successfully run `bundle check`"
end
I tried to debug and I found that if I change the bundle check
command with bundle install
and I capture the output, my gem is not listed in the bundle. As a consequence if I write a rails g --help
step my generator is not there. However devise gem and generators are there (devise is listed as requirement in my gem. So it seems that bundler/rails is not loading all inside aruba steps.
I think that this is a bug with Aruba or Bundler, I opened an issue for aruba but still no answers.
Full code is on Github
Last thing I've already seen and tried this solution but with no luck
Instead of all of those steps you wrote which are a bit deprecated in cucumber.
Try something like this:
Given /^a rails application named "([^\"]*)" exists$/ do |app_name|
FileUtils.mkdir_p("tmp")
system("rm -rf tmp/#{app_name}")
system("rails new tmp/#{app_name}")
system("ln -s ../../../lib/generators tmp/#{app_name}/lib")
@current_directory = File.expand_path("tmp/#{app_name}")
end
You have to create a link to the directories. It makes more sense than doing bundle install which you shouldn't attempt testing using cucumber.
精彩评论