我刚刚在github上发布了一个gem,并编写了与aruba gem的集成测试。但是,我不能运行特性,因为它的行为与命令行不同。
如果我运行这些功能,rails就无法找到我的生成器,如果我在命令行上重复相同的步骤,它们就会完美地运行。
这是一个失败的特性
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 install更改bundle check命令并捕获输出,那么我的gem不会列在包中。因此,如果我编写一个rails g --help步骤,我的生成器就不在那里了。然而,devise gem和生成器在那里(devise在我的gem中被列为要求。因此,似乎bundler/rails并没有加载aruba中的所有步骤。
我认为这是一个错误与阿鲁巴或捆绑,我打开an issue for aruba,但仍然没有答案。
完整的代码在Github上
我已经看到并尝试过this solution的最后一件事,但没有成功
发布于 2012-01-26 20:39:35
而不是你写的那些步骤,这些步骤在cucumber中有点过时。
尝试如下所示:
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您必须创建一个指向目录的链接。这比进行捆绑安装更有意义,因为您不应该尝试使用cucumber进行测试。
https://stackoverflow.com/questions/6574616
复制相似问题