Running Specs on Discourse-BCC Plugin

Hello, I am working on a PR for the discourse-bcc plugin, but I have run into some trouble running specs.

After cloning the main repository into my plugins folder, I ran migrations using RAILS_ENV=test /bin/rake db:migrate , and then tried to run specs using bundle exec rake plugin:spec[discourse-bcc]. Doing so resulted in the following error:

An error occurred while loading ./plugins/discourse-bcc/spec/jobs/bcc_post_spec.rb.
  describe ::Jobs::BccPost do
    fab!(:sender) { Fabricate(:moderator) }
    fab!(:user0) { Fabricate(:user) }
    fab!(:user1) { Fabricate(:user) }
    let(:create_params) do
        "raw" => "this is the content I want to send",
        "title" => "this is the title of the PM I want to send",
        "archetype" => Archetype.private_message,

  uninitialized constant Jobs
# ./plugins/discourse-bcc/spec/jobs/bcc_post_spec.rb:3:in `<top (required)>'

An error occurred while loading ./plugins/discourse-bcc/spec/requests/post_controller_spec.rb.
Failure/Error: super

  undefined method `fab!' for RSpec::ExampleGroups::PostsController::WhenLoggedInAsStaff:Class
# ./plugins/discourse-bcc/spec/requests/post_controller_spec.rb:31:in `block (2 levels) in <top (required)>'
# ./plugins/discourse-bcc/spec/requests/post_controller_spec.rb:30:in `block in <top (required)>'
# ./plugins/discourse-bcc/spec/requests/post_controller_spec.rb:5:in `<top (required)>'

Top 0 slowest examples (0 seconds, 0.0% of total time):

Finished in 0.00005 seconds (files took 1.91 seconds to load)
0 examples, 0 failures, 2 errors occurred outside of examples

Any help would be greatly appreciated, thanks!

I ran the same command locally with the latest version of discourse-bcc and it worked:

bundle exec rake plugin:spec[discourse-bcc]
LOAD_PLUGINS=1 /home/robin/.rbenv/versions/2.7.2/bin/ruby -S rspec ./plugins/discourse-bcc/spec/requests/post_controller_spec.rb ./plugins/discourse-bcc/spec/jobs/bcc_post_spec.rb --profile

Randomized with seed 14532

What version of Ruby are you running and what operating system? Did bundle install work?

1 Like

I am using Ruby 2.7.1p83, on a Windows subsystem running Ubuntu 20.04. I also tried this on Pop!_OS, which resulted in a similar error. bundle install works fine.

It honestly should work fine. To be clear you have not modified the files in any way? Can you run specs on the main app? bundle exec rspec?

The error message seems to indicate it’s not loading the application which makes no sense to me.

1 Like

Actually I think we’ve found the cause - rails_helper was not required in the spec. If you update the plugin it should work with this commit:


This resulted in some progress but I think that I messed something else up along the way. I’m going to reinstall Discourse and I’ll get back to you, thanks!

Running specs is working with fresh install. PR has been finalized.