dachary
(Loïc Dachary)
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)
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)
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)
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)
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)
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)
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)
13 يوليو 2016، 9:16م
8
This does not work for me but
bundle exec rake plugin:spec poll
does.
dachary
(Loïc Dachary)
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)
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)
19 نوفمبر 2019، 6:24م
12
@sam أضاف سحرًا هنا، لذا إذا نفذت RAILS_ENV=test /bin/rake db:migrate فسيتم تحميل الإضافات تلقائيًا. لكنني أعتقد أن معظم الأشخاص لا يستخدمون بدائل bin، لذا تستمر هذه المشكلة في الحدوث لأشخاص مختلفين. ربما نحتاج إلى تضمين المنطق في مهمة rake db:migrate، بدلاً من وجوده في بديل bin
عند تشغيل مجموعة الاختبارات بشكل طبيعي، لا نريد تحميل الإضافات؛ فغالبًا ما تقوم الإضافات بتجاوز الوظائف مما يتسبب في فشل الاختبارات الأساسية.
sam
(Sam Saffron)
19 نوفمبر 2019، 11:35م
13
هذا يجعلني حزينًا جدًا … فبدائل الثُبات تُسهّل الحياة كثيرًا، فمثلاً يحتوي bin/unicorn على الكثير من السحر.
david
(David Taylor)
20 نوفمبر 2019، 12:20ص
14
أعتقد أن معظم الناس (على الأقل أنا) يستخدمون الأمر القياسي
rails s
لحسن الحظ، يتم تشغيل rails binstub بفضل بعض سحر Rails
# 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:
يطلق binstub الخاص بـ Rails في Discourse binstub الخاص بـ unicorn:
# 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 نقرات إضافية (لكن نعم، يمكنني إضافة alias، أو استخدام شيء مثل direnv)