Sha256: 6faeb4667c7574173dafef1d7a663faf604a9221463249c62dfa5ebc5131540d
Contents?: true
Size: 1.1 KB
Versions: 11
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Arstotzka::HashReader do subject(:reader) { described_class.new(options) } describe '#hash' do let(:klass) { Arstotzka::Fetcher::Dummy } let(:json) { { key: 'value' } } let(:instance) { klass.new(json) } let(:options) { { instance: instance } } context 'when no extra options are given' do it 'reads hash from instance json method' do expect(reader.hash).to eq(json) end end context 'when fetching from instance variable' do let(:klass) { Arstotzka::Fetcher::NoAccessor } let(:options) { { instance: instance, json: :@hash } } it 'reads hash from instance variable' do expect(reader.hash).to eq(json) end end context 'when fetching from class variable' do let(:klass) { Arstotzka::Fetcher::ClassVariable } let(:options) { { instance: instance, json: :@@json } } let(:instance) { klass.new } before { klass.json = json } it 'reads hash from class variable' do expect(reader.hash).to eq(json) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems