rating/spec/models/extension/rated_question_spec.rb

21 lines
558 B
Ruby
Raw Normal View History

2017-10-30 01:44:23 +00:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Rating::Extension, ':rated?' do
let!(:user) { create :user }
let!(:article) { create :article }
context 'when has no rate for the given resource' do
before { allow(user).to receive(:rate_for).with(article) { nil } }
specify { expect(user.rated?(article)).to eq false }
end
context 'when has rate for the given resource' do
before { allow(user).to receive(:rate_for).with(article) { double } }
specify { expect(user.rated?(article)).to eq true }
end
end