Sha256: 81fd3a668689590e9fedde79f64c066e88d72e4b00bac629e150bd8a80691df7
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Rating::Rating, ':data' do subject { described_class.data article_1 } let!(:user_1) { create :user } let!(:user_2) { create :user } let!(:article_1) { create :article } let!(:article_2) { create :article } let!(:article_3) { create :article } before do create :rating_rate, author: user_1, resource: article_1, value: 100 create :rating_rate, author: user_1, resource: article_2, value: 11 create :rating_rate, author: user_1, resource: article_3, value: 10 create :rating_rate, author: user_2, resource: article_1, value: 1 end it 'returns the average of value for a resource' do expect(subject[:average]).to eq 50.5 end it 'returns the sum of values for a resource' do expect(subject[:sum]).to eq 101 end it 'returns the count of votes for a resource' do expect(subject[:total]).to eq 2 end it 'returns the estimate for a resource' do expect(subject[:estimate]).to eq 42.50000000000001 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rating-0.1.0 | spec/models/rating/data_spec.rb |