0

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?

borisano
  • 1,270
  • 1
  • 16
  • 28

2 Answers2

2

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.

Jan Klimo
  • 4,643
  • 2
  • 36
  • 42
0

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.

Midwire
  • 1,090
  • 8
  • 25