7

すでに 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
4

3 に答える 3

10

このコードを 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
于 2013-06-27T08:41:47.130 に答える
4

そうですね、私も 4.1 で同様の問題に直面しました。しかし、最終的には、次のチケットが問題の解決に役立ちました。https://github.com/rspec/rspec-rails/issues/439

つまり、それがグループ内だけでなくrspec-rails、グループ内にあることを確認する必要があります。その小さな変更とで、すべてのスペック ファイルが自動的に生成されました。developmenttestbundle install

于 2014-06-23T01:48:44.513 に答える