rating/spec/models/extension/rate_for_spec.rb
Washington Botelho cd51130143
add scope support
2017-11-02 23:35:08 -02:00

27 lines
671 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Rating::Extension, ':rate_for' do
let!(:user) { create :user }
let!(:article) { create :article }
context 'with no scopeable' do
it 'delegates to rate object' do
expect(Rating::Rate).to receive(:rate_for).with author: user, resource: article, scopeable: nil
user.rate_for article
end
end
context 'with scopeable' do
let!(:category) { build :category }
it 'delegates to rate object' do
expect(Rating::Rate).to receive(:rate_for).with author: user, resource: article, scopeable: category
user.rate_for article, scope: category
end
end
end