Rails public_activity gem rspec setting error

193 Views Asked by At

I am integrating public_activity (version 1.5) gem to my Rails 4 app.

Trying to set up tests as specified in their wiki, I write the following:

#spec_helper.rb
require 'public_activity/testing'

PublicActivity.enabled = false

However, trying to run my specs I get the following error:

/my_app/spec/spec_helper.rb:24:in <top (required)>': undefined methodenabled=' for PublicActivity:Module (NoMethodError)

Looking at Public Activity module source code I can clearly see enable= method there.

Can you please advise me what am I doing wrong here?

2

There are 2 best solutions below

0
On

Looking at the source, testing.rb does not require PublicActivity where enabled= is defined, so I believe you'll need to do

require 'public_activity'
require 'public_activity/testing'

like it's done in their test_helper.rb.

0
On

The documentation seems to be incorrect.

I was able to get it to work like this:

PublicActivity::Config.instance.enabled = false

Update: Jan Klimo's answer is the correct way.