From 69003bd30ccfc8a01e8d36faa536e30e9c64bb4f Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Thu, 3 Oct 2019 20:25:23 -0300 Subject: [PATCH] spec: fix some times comes integer sometime comes float string --- spec/models/rating/averager_data_spec.rb | 6 +++--- spec/models/rating/values_data_spec.rb | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/models/rating/averager_data_spec.rb b/spec/models/rating/averager_data_spec.rb index b17f192..e95e325 100644 --- a/spec/models/rating/averager_data_spec.rb +++ b/spec/models/rating/averager_data_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Rating::Rating, ':averager_data' 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 + 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 @@ -22,11 +22,11 @@ RSpec.describe Rating::Rating, ':averager_data' 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 + 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 eq 2 + expect(result.as_json['count_avg'].to_f.to_s).to eq '2.0' end end end diff --git a/spec/models/rating/values_data_spec.rb b/spec/models/rating/values_data_spec.rb index 82bef04..ac4dee1 100644 --- a/spec/models/rating/values_data_spec.rb +++ b/spec/models/rating/values_data_spec.rb @@ -10,15 +10,15 @@ RSpec.describe Rating::Rating, ':values_data' do subject(:result) { described_class.values_data article_1, nil } it 'returns the average of value for a resource' do - expect(result.as_json['rating_avg']).to eq 50.5 + expect(result.as_json['rating_avg'].to_f.to_s).to eq '50.5' end it 'returns the sum of values for a resource' do - expect(result.as_json['rating_sum']).to eq 101 + expect(result.as_json['rating_sum'].to_f.to_s).to eq '101.0' end it 'returns the count of votes for a resource' do - expect(result.as_json['rating_count']).to eq 2 + expect(result.as_json['rating_count'].to_f.to_s).to eq '2.0' end end @@ -26,15 +26,15 @@ RSpec.describe Rating::Rating, ':values_data' do subject(:result) { described_class.values_data article_1, category } it 'returns the average of value for a resource' do - expect(result.as_json['rating_avg']).to eq 1.5 + expect(result.as_json['rating_avg'].to_f.to_s).to eq '1.5' end it 'returns the sum of values for a resource' do - expect(result.as_json['rating_sum']).to eq 3 + expect(result.as_json['rating_sum'].to_f.to_s).to eq '3.0' end it 'returns the count of votes for a resource' do - expect(result.as_json['rating_count']).to eq 2 + expect(result.as_json['rating_count'].to_f.to_s).to eq '2.0' end end end