gpt4 book ai didi

ruby-on-rails - Rspec 未在 Rails 4 beta 中生成 *_spec.rb 文件

转载 作者:行者123 更新时间:2023-12-04 10:18:57 24 4
gpt4 key购买 nike

我已经安装了 rspec-rails gem。当我跑 rails g model movie showtime_date:date showtime_time:time我想,我应该得到

invoke  active_record
create db/migrate/20130604010556_create_movies.rb
create app/models/movie.rb
invoke rspec
create spec/models/movie_spec.rb

但是当我运行 rails g model movie showtime_date:date showtime_time:time我得到
invoke  active_record
create db/migrate/xxxxxxxxxxx_create_movies.rb
create app/models/movie.rb
invoke test_unit
create test/models/movie_test.rb
create test/fixtures/movies.yml

我的 gem 包有问题吗?我正在使用 Rails4 测试版。这个版本有错误还是别的什么?

我的应用程序的 BDD 是这样的 app/features/show_descripitons.feature
Feature: Showtime Descriptions
As a movie goer
I want to see accurate and concise showtimes
So that I can find movies that fit my schedule

@wip
Scenario: Show minutes for times ending with 00
Given a movie
When I set the showtime to "2013-05-04" at "2:15pm"
Then the showtime description should be "June 04, 2013(2pm)"

Scenario: Hide minutes for times ending with 00
Given a movie
When I set the showtime to "2013-05-04" at "2:00pm"
Then the showtime description should be "June 04, 2013(2pm)"

和我的 app/features/step_definition/showtime_descriptions.rb这是
Given(/^a movie$/) do
@movie = Movie.create!
end

When(/^I set the showtime to "(.*?)" at "(.*?)"$/) do |date, time|
@movie.update_attribute(:showtime_date, Date.parse(date))
@movie.update_attribute(:showtime_time, time)
end

Then(/^the showtime description should be "(.*?)"$/) do |showtime|
@movie.showtime.showtime eq(showtime)
end

最佳答案

我应该把我的这段代码放在 config/application.rb

    config.generators do |g|
g.template_engine :erb
g.test_framework :rspec, :fixture => true, :views => false
g.integration_tool :rspec, :fixture => true, :views => true
g.fixture_replacement :factory_girl, :dir => "spec/support/factories"
end

关于ruby-on-rails - Rspec 未在 Rails 4 beta 中生成 *_spec.rb 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16908469/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com