How do I run the test suite just for one plugin?

I’m trying to run the test suite for discourse-canned replies however instead any time I try it runs the entire discourse test suite (this takes a very long time and doesn’t work well for me when making lots of tiny changes and needing to test them). Can someone provide information on how to do this? Thanks :slight_smile:

EDIT: After some digging maybe this works

Nathaniels-MacBook-Pro:discourse nathanielsuchy$ LOAD_PLUGINS=1 bin/rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb

Randomized with seed 22318
DEPRECATION WARNING: The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful? as provided by Rack::Response::Helpers. (called from block (4 levels) in <top (required)> at /Users/nathanielsuchy/discourse/plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:100)
F.FF.DEPRECATION WARNING: The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful? as provided by Rack::Response::Helpers. (called from block (4 levels) in <top (required)> at /Users/nathanielsuchy/discourse/plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:36)
FFF.DEPRECATION WARNING: The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful? as provided by Rack::Response::Helpers. (called from block (4 levels) in <top (required)> at /Users/nathanielsuchy/discourse/plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:70)
F

Failures:

  1) CannedReply::CannedRepliesController editing a canned reply as a staff should be able to edit a reply
     Failure/Error: expect(response).to be_success
       expected `#<ActionDispatch::TestResponse:0x00007f8da0862970 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::..., @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil>>.success?` to return true, got false
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:100:in `block (4 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `each' for nil:NilClass
     #   ./plugins/discourse-canned-replies/plugin.rb:32:in `add'

  2) CannedReply::CannedRepliesController recording canned replies usages as a staff should be able to record a usage
     Failure/Error: let(:canned_reply) { CannedReply::Reply.add(moderator, 'some title', 'some content') }
     
     NoMethodError:
       undefined method `each' for nil:NilClass
     # ./plugins/discourse-canned-replies/plugin.rb:32:in `add'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:131:in `block (4 levels) in <top (required)>'

  3) CannedReply::CannedRepliesController recording canned replies usages as a normal user should raise the right error
     Failure/Error: let(:canned_reply) { CannedReply::Reply.add(moderator, 'some title', 'some content') }
     
     NoMethodError:
       undefined method `each' for nil:NilClass
     # ./plugins/discourse-canned-replies/plugin.rb:32:in `add'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:121:in `block (4 levels) in <top (required)>'

  4) CannedReply::CannedRepliesController listing canned replies as a staff should list all replies correctly
     Failure/Error: expect(response).to be_success
       expected `#<ActionDispatch::TestResponse:0x00007f8d85808fa8 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::..., @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil>>.success?` to return true, got false
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:36:in `block (4 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `each' for nil:NilClass
     #   ./plugins/discourse-canned-replies/plugin.rb:32:in `add'

  5) CannedReply::CannedRepliesController retrieving a canned reply as a normal user should raise the right error
     Failure/Error: let(:canned_reply) { CannedReply::Reply.add(moderator, 'some title', 'some content') }
     
     NoMethodError:
       undefined method `each' for nil:NilClass
     # ./plugins/discourse-canned-replies/plugin.rb:32:in `add'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:145:in `block (4 levels) in <top (required)>'

  6) CannedReply::CannedRepliesController retrieving a canned reply as a staff should fetch the right canned reply
     Failure/Error: let(:canned_reply) { CannedReply::Reply.add(moderator, 'some title', 'some content') }
     
     NoMethodError:
       undefined method `each' for nil:NilClass
     # ./plugins/discourse-canned-replies/plugin.rb:32:in `add'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:155:in `block (4 levels) in <top (required)>'

  7) CannedReply::CannedRepliesController removing canned replies as a staff should be able to remove reply
     Failure/Error: expect(response).to be_success
       expected `#<ActionDispatch::TestResponse:0x00007f8d876af308 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::..., @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil>>.success?` to return true, got false
     # ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:70:in `block (4 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `each' for nil:NilClass
     #   ./plugins/discourse-canned-replies/plugin.rb:32:in `add'

Finished in 45.5 seconds (files took 6.85 seconds to load)
10 examples, 7 failures

Failed examples:

rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:93 # CannedReply::CannedRepliesController editing a canned reply as a staff should be able to edit a reply
rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:130 # CannedReply::CannedRepliesController recording canned replies usages as a staff should be able to record a usage
rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:120 # CannedReply::CannedRepliesController recording canned replies usages as a normal user should raise the right error
rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:29 # CannedReply::CannedRepliesController listing canned replies as a staff should list all replies correctly
rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:144 # CannedReply::CannedRepliesController retrieving a canned reply as a normal user should raise the right error
rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:154 # CannedReply::CannedRepliesController retrieving a canned reply as a staff should fetch the right canned reply
rspec ./plugins/discourse-canned-replies/spec/integration/canned_reply/canned_replies_spec.rb:63 # CannedReply::CannedRepliesController removing canned replies as a staff should be able to remove reply

Randomized with seed 22318
3 Likes

It looks like you found a solution, but there is also a magic shortcut you can use:

rake plugin:spec[discourse-canned-replies]
9 Likes

This topic was automatically closed after 3 hours. New replies are no longer allowed.