dimanche 26 février 2017

How to write tests for active record scopes?

How can I write tests for active record scopes? for example

class Post < ActiveRecord::Base
  scope :recent, -> { order("posts.created_at DESC") }
  scope :published, -> { where("status = 1") }
end

I'm using Rspec for testing

RSpec.feature Post, :type => :model do
  let(:post) { build(:post) }

  describe 'test scopes' do
  end
end

Aucun commentaire:

Enregistrer un commentaire