spec/integration/yard/arstotzka/crawler_spec.rb in arstotzka-1.0.3 vs spec/integration/yard/arstotzka/crawler_spec.rb in arstotzka-1.0.4

- old
+ new

@@ -2,11 +2,11 @@ require 'spec_helper' describe Arstotzka::Crawler do describe 'yard' do - subject do + subject(:crawler) do described_class.new(path: path, **options) end let(:options) { {} } let(:path) { %w[person information first_name] } @@ -19,17 +19,17 @@ } } end it 'crawls to find the value' do - expect(subject.value(hash)).to eq('John') + expect(crawler.value(hash)).to eq('John') end describe '#value' do context 'when hash contains the path' do it 'crawls to find the value' do - expect(subject.value(hash)).to eq('John') + expect(crawler.value(hash)).to eq('John') end end context 'when we have an array of arrays' do let(:path) { %w[companies games hero_name] } @@ -49,27 +49,27 @@ }] } end it 'crawls to find the value' do - expect(subject.value(hash)).to eq([['Rakhar']]) + expect(crawler.value(hash)).to eq([['Rakhar']]) end - context 'and we set a default value' do + context 'with default value' do let(:options) { { compact: true, case_type: :snake, default: 'NO HERO' } } it 'return default value for missed keys' do - expect(subject.value(hash)).to eq([['NO HERO', 'Rakhar'], 'NO HERO']) + expect(crawler.value(hash)).to eq([['NO HERO', 'Rakhar'], 'NO HERO']) end end - context 'and we give a block' do - subject do + context 'when block is given' do + subject(:crawler) do described_class.new(path: path, **options) { |value| value&.to_sym } end it 'returns the post processed values' do - expect(subject.value(hash)).to eq([[:Rakhar]]) + expect(crawler.value(hash)).to eq([[:Rakhar]]) end end end end end