Sha256: 338f1b5fb77f63f2493931ccc2f13c4b76ffd277d23d1c827731b291611ef594
Contents?: true
Size: 1022 Bytes
Versions: 3
Compression:
Stored size: 1022 Bytes
Contents
# frozen_string_literal: true require 'rails_helper' require 'support/shared_context/with_database_records' RSpec.describe Rating::Rating, ':averager_data' do include_context 'with_database_records' context 'with no scopeable' do subject(:result) { described_class.averager_data article_1, nil } it 'returns the values average of given resource type' do expect(result.as_json['rating_avg'].to_f.to_s).to eq '30.5' end it 'returns the average of number of records for the given resource type' do expect(result.as_json['count_avg'].to_s).to eq '1.333333333333333333' end end context 'with scopeable' do subject(:result) { described_class.averager_data article_1, category } it 'returns the values average of given resource type' do expect(result.as_json['rating_avg'].to_f.to_s).to eq '1.5' end it 'returns the average of number of records for the given resource type' do expect(result.as_json['count_avg'].to_f.to_s).to eq '2.0' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rating-0.11.0 | spec/models/rating/averager_data_spec.rb |
rating-0.10.0 | spec/models/rating/averager_data_spec.rb |
rating-0.9.0 | spec/models/rating/averager_data_spec.rb |