Stworzyłem nową aplikację Rails 3.2.x z opcją -T bez testów, ponieważ chciałem użyć Rspec do testowania.
Teraz chcę przywrócić go do Test :: Unit. Jak mogę to zrobić, że wszystkie zadania rake działają, a nowe scaffolds są generowane z Test :: Unit zamiast powłok testowych RSpec?
Odpowiedzi:
3 dla odpowiedzi № 1Po przeszukiwaniu i hakowaniu, oto, co sprawiło, że zadziałało to dla mnie.
- Usuń rspec i rspec-rails z Gemfile
- Uruchom "gem list rspec --local" i wykonaj "gem uninstall" dla każdego z tych klejnotów rspec.
- Usuń Gemfile.lock
- rm -r spec /
- instalacja pakietu
- test mkdir /
- Dodaj "require" rail / all "" do config / application.rb
Utwórz test pliku / test_helper.rb i umieść w nim następujący kod:
ENV["RAILS_ENV"] = "test" require File.expand_path("../../config/environment", __FILE__) require "active_support" require "rails/test_help" # require "factory_girl_rails" #use if you are using FactoryGirl for fixtures class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You"ll currently still have to declare fixtures explicitly in integration tests # -- they do not yet inherit this setting fixtures :all # Add more helper methods to be used by all tests here... end
Następnie możesz wygenerować testy za pomocą
rails g integration_test SomeStories
Lub możesz po prostu dodać testy jednostkowe w ramach testu / jednostki, a następnie je uruchomić
rake test
rake test:recent