2013-06-04 11 views
7

में * _spec.rb फ़ाइल उत्पन्न नहीं कर रहा है। मैं पहले से ही आरएसपीसी-रेल मणि स्थापित कर चुका हूं। जब मैं rails g model movie showtime_date:date showtime_time:time मुझे लगता है कि चलाने के लिए, मैंरेलवे 4 * बीएस

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 

मिल मेरे मणि पैकेज के साथ एक समस्या है? मैं 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 
+0

क्या आपने शुरुआत में आरएसपीईसी: इंस्टॉल 'उत्पन्न किया था? –

उत्तर

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 
+0

मैंने पहली बार ओमिट टेस्ट यूनिट विकल्प (-टी, [--स्किप-टेस्ट-यूनिट]) का उपयोग करने का प्रयास किया था [Aaron ] मेरी नई रेल परियोजना बनाते समय सुझाव दिया। वह अकेला काम नहीं करता जब तक कि मैंने उपरोक्त कोड को मेरे आवेदन में नहीं जोड़ा। आरबी। – Jeremiah

+0

यह महान काम करता है सिवाय इसके कि g.fixture_replacement ने "factory_girl [नहीं मिला]" संदेश में परिणाम दिया है, मैं वर्तमान चश्मा के लिए factory_girl का उपयोग करता हूं ताकि जेम स्थापित हो और यह काम कर रहा हो; निश्चित नहीं है कि इसका परिणाम एक त्रुटि संदेश क्यों हुआ। – Greg

+0

इस https: // github की समीक्षा की।com/thoughtbot/factory_girl_rails/issues/53 और Gemfile – Greg

0

ध्वनि के बाद आप पहले से ही रेल प्रोजेक्ट बनाया है जैसे आप RSpec जोड़ा है। आपको परीक्षण इकाई जनरेटर संदर्भ को हटाने की आवश्यकता होगी। सुनिश्चित करें कि आप rails g rspec:install चलने तथा जो निम्न में नहीं है अपने config/application.rb (http://edgeguides.rubyonrails.org/generators.html#customizing-your-workflow):

g.test_framework :test_unit, fixture: true 

जब एक नया रेल बनाने परियोजना आप -T, [--skip-test-unit] ध्वज के साथ परीक्षण इकाई को छोड़ सकते हैं।

+0

हे, जैसा आपने कहा है। मैं इसे का पालन करें और एक बार फिर से नया बना लेकिन परिणाम इस रेल की तरह जी मॉडल फिल्म showtime_date है: तिथि showtime_time: समय आह्वान active_record बनाने db/विस्थापित/20130607172805_create_movies.rb बनाने एप्लिकेशन/मॉडल/movie.rb –

+0

@ अमृतदीप दुनगाना ने आपके रन 'रेल जी आरएसपीसी: इंस्टॉल' किया था? यदि ऐसा है तो आउटपुट क्या था? –

+0

बाहर था रेल जी rspec का पालन के रूप में: .rspec बनाने कल्पना बनाने यह बनाने कल्पना/spec_helper.rb –

3

खैर में मेरे लिए इस कोड रखना चाहिए, मैं भी 4.1 के साथ एक समान समस्या का सामना करना पड़ा। लेकिन अंत में, टिकट के बाद मुझे इस मुद्दे को हल करने में मदद मिली। https://github.com/rspec/rspec-rails/issues/439

संक्षेप में, आप यह सुनिश्चित करें कि rspec-railsdevelopment समूह में है और न केवल test समूह में करना होता है। उस छोटे बदलाव और bundle install के साथ, मुझे स्वचालित रूप से जेनरेट की गई सभी spec फ़ाइलें मिल गईं।

+1

पर factory_girl_rails जोड़ा या आप 'RAILS_ENV = परीक्षण रेल जी मॉडल जो कुछ भी कर सकते हैं। –

संबंधित मुद्दे