dachary
(Loïc Dachary)
7월 13, 2016, 7:35오후
1
Hi,
I’d like to only run the tests at discourse/plugins/poll/spec instead of the whole suite with bundle exec rake autospec p l=5 . How can I do that ?
Ideally that would not be necessary if autospec detected changes made to plugins but my understanding is that it’s not yet able to do so.
Thanks in advance for your help
gerhard
(Gerhard Schlager)
7월 13, 2016, 7:58오후
2
Not sure how it works with autospec since I’m running the specs manually most of the time.
In order to run the plugin specs I’m always setting an environment variable in my IDE: LOAD_PLUGINS=1
dachary
(Loïc Dachary)
7월 13, 2016, 8:26오후
3
Cool ! How would you manually run the spec of the poll plugin ? My IDE is the CLI
dachary
(Loïc Dachary)
7월 13, 2016, 8:33오후
4
I tried
bundle exec rake autospec plugins/poll/spec/*
but it shows
Randomized with seed 8681 …… …*…
etc. which suggests it runs more than what I’d expect.
gerhard
(Gerhard Schlager)
7월 13, 2016, 8:40오후
5
# this runs just the specs in one file
LOAD_PLUGINS=1 bundle exec rspec plugins/poll/spec/controllers/posts_controller_spec.rb
# this runs all the specs of the poll plugin
LOAD_PLUGINS=1 bundle exec rspec plugins/poll/spec
tgxworld
(Alan Tan)
7월 13, 2016, 9:00오후
6
Another way to do it is via the rake task
bundle exec rake plugin:spec["poll"]
dachary
(Loïc Dachary)
7월 13, 2016, 9:14오후
7
It works, thanks ! Where would be the most relevant topic for this information ? Or maybe there is a file in the git repository that should be updated ? The closest thing I found is the Beginner’s Guide to Creating Discourse Plugins Part 6: Acceptance Tests but it only covers part of the qunit tests.
dachary
(Loïc Dachary)
7월 13, 2016, 9:16오후
8
This does not work for me but
bundle exec rake plugin:spec poll
does.
dachary
(Loïc Dachary)
7월 13, 2016, 9:27오후
9
I proposed a change to the VAGRANT.md file . Not sure it’s right but… here it is anyway
sam
(Sam Saffron)
5월 3, 2019, 3:53오전
10
The best way to do this is use autospec, it now works properly even with symlinked plugins
bin/rake autospec
Save plugin.rb file or plugin spec file and it will run.
Be sure to run all plugin migrations with (which will happen magically if you run)
RAILS_ENV=test bin/rake db:migrate
플러그인 스펙을 실행하기 전에 아래 명령을 실행한 후 문제가 발생했습니다:
RAILS_ENV=test bin/rake db:migrate
테스트 중이던 플러그인의 마이그레이션이 실행되지 않았습니다. 이후 아래 명령을 실행했습니다:
LOAD_PLUGINS=1 RAILS_ENV=test bundle exec rake db:migrate
이제 플러그인 마이그레이션이 정상적으로 실행되었습니다!
흥미로운 점은 LOAD_PLUGINS=1 없이 development 환경에서는 플러그인 마이그레이션이 실행되었지만, testing 환경에서는 마이그레이션이 실행되지 않았다는 것입니다.
david
(David Taylor)
11월 19, 2019, 6:24오후
12
@sam이 여기에 마법을 좀 걸어서, RAILS_ENV=test /bin/rake db:migrate를 실행하면 플러그인이 자동으로 로드됩니다. 하지만 대부분의 사람들은 bin 스텁을 사용하지 않는 것 같아서, 이 문제가 다른 사람들에게도 계속 발생하고 있습니다. bin 스텁이 아니라 db:migrate rake 태스크 안에 로직을 내장해야 하는 것 같습니다.
테스트 스위트를 정상적으로 실행할 때는 플러그인이 로드되지 않아야 합니다. 플러그인이 종종 기능을 오버라이드하여 코어 테스트가 실패하게 만들 수 있기 때문입니다.
sam
(Sam Saffron)
11월 19, 2019, 11:35오후
13
이것은 저를 매우 슬프게 만듭니다 … binstubs는 작업을 훨씬 쉽게 만들어 주거든요. 예를 들어 bin/unicorn에는 많은 마법이 포함되어 있습니다.
david
(David Taylor)
11월 20, 2019, 12:20오전
14
대부분의 사람들(적어도 저의 경우)은 표준적인
rails s
를 사용하는 것 같습니다. 다행히도 이는 rails의 마법 덕분에 rails binstub을 실행합니다.
# frozen_string_literal: true
require "pathname"
require "rails/version"
module Rails
module AppLoader # :nodoc:
extend self
RUBY = Gem.ruby
EXECUTABLES = ["bin/rails", "script/rails"]
BUNDLER_WARNING = <<EOS
Beginning in Rails 4, Rails ships with a `rails` binstub at ./bin/rails that
should be used instead of the Bundler-generated `rails` binstub.
If you are seeing this message, your binstub at ./bin/rails was generated by
Bundler instead of Rails.
You might need to regenerate your `rails` binstub locally and add it to source
control:
Discourse의 rails binstub은 unicorn binstub을 시작합니다:
# frozen_string_literal: true
if !ENV["RAILS_ENV"] && (ARGV[0] == "s" || ARGV[0] == "server") && Process.respond_to?(:fork)
ENV["UNICORN_PORT"] ||= "3000"
if ARGV[1] == "-p" && (port = ARGV[2].to_i) > 0
ENV["UNICORN_PORT"] = port.to_s
end
ENV["RAILS_LOGS_STDOUT"] ||= "1"
exec File.expand_path("pitchfork", __dir__)
end
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
불행히도 rake는 동일한 마법의 혜택을 받지 못합니다.
저는 키를 4번 더 누릅니다 (하지만 네, 별명을 추가하거나 direnv 같은 것을 사용할 수도 있습니다)