spec/integration/yard/arstotzka/crawler_spec.rb in arstotzka-1.0.4 vs spec/integration/yard/arstotzka/crawler_spec.rb in arstotzka-1.1.0
- old
+ new
@@ -3,15 +3,15 @@
require 'spec_helper'
describe Arstotzka::Crawler do
describe 'yard' do
subject(:crawler) do
- described_class.new(path: path, **options)
+ described_class.new(keys: keys, **options)
end
let(:options) { {} }
- let(:path) { %w[person information first_name] }
+ let(:keys) { %w[person information first_name] }
let(:hash) do
{
person: {
'information' => {
'firstName' => 'John'
@@ -23,19 +23,19 @@
it 'crawls to find the value' do
expect(crawler.value(hash)).to eq('John')
end
describe '#value' do
- context 'when hash contains the path' do
+ context 'when hash contains the keys' do
it 'crawls to find the value' do
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] }
- let(:options) { { compact: true, case_type: :snake } }
+ let(:keys) { %w[companies games hero_name] }
+ let(:options) { { compact: true, case: :snake } }
let(:hash) do
{
'companies' => [{
name: 'Lucas Pope',
games: [{
@@ -53,19 +53,19 @@
it 'crawls to find the value' do
expect(crawler.value(hash)).to eq([['Rakhar']])
end
context 'with default value' do
- let(:options) { { compact: true, case_type: :snake, default: 'NO HERO' } }
+ let(:options) { { compact: true, case: :snake, default: 'NO HERO' } }
it 'return default value for missed keys' do
expect(crawler.value(hash)).to eq([['NO HERO', 'Rakhar'], 'NO HERO'])
end
end
context 'when block is given' do
subject(:crawler) do
- described_class.new(path: path, **options) { |value| value&.to_sym }
+ described_class.new(keys: keys, **options) { |value| value&.to_sym }
end
it 'returns the post processed values' do
expect(crawler.value(hash)).to eq([[:Rakhar]])
end