Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warning when running RSpec tests #50

Open
Dakuan opened this issue Jun 21, 2012 · 7 comments
Open

Deprecation warning when running RSpec tests #50

Dakuan opened this issue Jun 21, 2012 · 7 comments

Comments

@Dakuan
Copy link

Dakuan commented Jun 21, 2012

Am getting this warning....

"DEPRECATION WARNING: You're trying to create an attribute 'game_category'. Writing arbitrary attributes on a model is deprecated. Please just use 'attr_writer' etc. (called from write_enumerated_attribute at /Users/Dom/.rvm/gems/ruby-1.9.3-p194/bundler/gems/enumerated_attribute-56c3506a7778/lib/enumerated_attribute/integrations/active_record.rb:24)"

... when running RSpec tests. Tests do pass okay, and the code works fine. Is it something I am doing?

@calebhearth
Copy link

I just started seeing a similar issue in my specs yesterday. I'll update this when I have tracked down the code causing this.

@Dakuan
Copy link
Author

Dakuan commented Jul 12, 2012

Ah cool, I'm glad it's not me being silly then!

@calebhearth
Copy link

I checked again. It is actually happening in functional tests with Test::Unit:


DEPRECATION WARNING: You're trying to create an attribute `project'. Writing arbitrary attributes on a model is deprecated. Please just use `attr_writer` etc. (called from write_enumerated_attribute at /path/to/vendor/gems/ruby/1.9.1/bundler/gems/enumerated_attribute-56c3506a7778/lib/enumerated_attribute/integrations/active_record.rb:24)
DEPRECATION WARNING: You're trying to create an attribute `investor'. Writing arbitrary attributes on a model is deprecated. Please just use `attr_writer` etc. (called from write_enumerated_attribute at /path/to/vendor/gems/ruby/1.9.1/bundler/gems/enumerated_attribute-56c3506a7778/lib/enumerated_attribute/integrations/active_record.rb:24)

@Dakuan
Copy link
Author

Dakuan commented Jul 13, 2012

Hmm im not using them, only cucumber features and rspec

@calebhearth
Copy link

This code was the culprit. You might have something similar somewhere. A recent update to Rails deprecated specifying models as arguments in mass assignment. I think it may have been a Rails 3 or 3.1 thing.

Interest.create(
  project: @project,
  investor: companies(:invco),
  state: :followed)

The solution, if you need to use mass assignment here, is to do something like this:

Interest.create(
  project_id: @project.id,
  investor_id: companies(:invco).id,
  state: :followed)

or

i = Interest.new
i.project_id = @project.id
i.investor_id = companies(:invco).id
i.state = :followed
i.save

Anyways, I don't think this is an issue with enum_attr, but something that both of us were probably doing wrong. It was on my end at least.

@calebhearth
Copy link

Found the commit in Rails:

rails/rails@b2955ed

@Dakuan
Copy link
Author

Dakuan commented Jul 23, 2012

Yep, that was exactly the problem. I was pumping a mock object in at create. Leaving that until afterwards made the warnings go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants