Sha256: 595d6de3acd52dba1115aa9d99348050c4feef1260158b4506707f8ee605dcea

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 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 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 eq 1.3333333333333333
    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 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 eq 2
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rating-0.3.0 spec/models/rating/averager_data_spec.rb