borisano
borisano

Reputation: 1376

Rails public_activity gem rspec setting error

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?

Upvotes: 0

Views: 181

Answers (2)

Midwire
Midwire

Reputation: 1100

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.

Upvotes: 0

Jan Klimo
Jan Klimo

Reputation: 4930

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.

Upvotes: 2

Related Questions