From 71f31e09eafe3ed6e702b7d53074b0bb41353cd7 Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Mon, 15 Jan 2018 22:04:05 -0200 Subject: [PATCH] spec: move out wrong nested context --- spec/models/extension/order_by_rating_spec.rb | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/spec/models/extension/order_by_rating_spec.rb b/spec/models/extension/order_by_rating_spec.rb index a265b82..ccb0170 100644 --- a/spec/models/extension/order_by_rating_spec.rb +++ b/spec/models/extension/order_by_rating_spec.rb @@ -144,39 +144,39 @@ RSpec.describe Rating::Extension, ':order_by_rating' do end end end + end - context 'filtering by :total' do - context 'as asc' do - it 'works' do - result = Article.order_by_rating(:total, :asc) + context 'filtering by :total' do + context 'as asc' do + it 'works' do + result = Article.order_by_rating(:total, :asc) - expect(result[0..1]).to match_array [article_2, article_3] - expect(result.last).to eq article_1 - end - - context 'with scope' do - it 'works' do - expect(Article.order_by_rating(:total, :asc, scope: category)).to eq [ - article_1 - ] - end - end + expect(result[0..1]).to match_array [article_2, article_3] + expect(result.last).to eq article_1 end - context 'as desc' do + context 'with scope' do it 'works' do - result = Article.order_by_rating(:total, :desc) - - expect(result.first).to eq article_1 - expect(result[1..2]).to match_array [article_2, article_3] + expect(Article.order_by_rating(:total, :asc, scope: category)).to eq [ + article_1 + ] end + end + end - context 'with scope' do - it 'works' do - expect(Article.order_by_rating(:total, :desc, scope: category)).to eq [ - article_1 - ] - end + context 'as desc' do + it 'works' do + result = Article.order_by_rating(:total, :desc) + + expect(result.first).to eq article_1 + expect(result[1..2]).to match_array [article_2, article_3] + end + + context 'with scope' do + it 'works' do + expect(Article.order_by_rating(:total, :desc, scope: category)).to eq [ + article_1 + ] end end end