Rails 3 + Rspec: Testing that a model has an attribute?

Viewed 9535

Is there a way to test that a model has a specific attribute? Right now I am just using respond_to like this:

describe Category do
  it { should respond_to(:title) }
  ...
end

to test that the Category model has an attribute, but that only really tests that there is an instance method called title. However, I can see how in some situations they would behave synonymously.

3 Answers
Related