Search code examples
ruby-on-railsrubyrspecrspec-rails

How to refer to attributes in Ruby/Rails specs?


I'm trying to follow these guidelines to write my specs: Better Specs

In Ruby it is a convention to refer to class methods using .method_name or ::method_name, and use #method_name for instance methods. Does the same convention apply to Rails model attributes?

For instance, should my spec be written like this:

describe ' #exam_code should be unique'?


Solution

  • I use this style guide https://github.com/bbatsov/rails-style-guide#rspec

    describe '#some_attr' do
      it 'is required' do
        #your spec
      end
    end