Sha256: d36b473d013e331365e59704e601e4d4a9059aec11a483c321bdf60e1b5c7da9
Contents?: true
Size: 1.46 KB
Versions: 13
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' describe 'sape:fetch' do include_context 'rake' its(:prerequisites) { should include('environment') } describe 'Without config file' do it 'should fails with message' do expect { subject.invoke } .to raise_exception(RuntimeError, 'Config file not found (config/sape.yml)') end end describe 'With config file' do # ACTIVATE, THEN SAPE CREATE FAKE URL FOR DISPENSER REQUEST # let(:config) { YAML.load(File.open(Rails.root.join('spec', 'fixtures', 'sape.yml'))) } # let(:response) { File.open(Rails.root.join('spec', 'fixtures', 'response.json')) } # #let(:url) { 'FAKE_LINK_TO_SAPE' } # before do # allow(YAML).to receive(:load_file).with('config/sape.yml').and_return(config) # #FakeWeb.register_uri(:any, url, body: response) # allow_any_instance_of(SapeConfig).to receive(:delete_all).and_return(:true) # allow_any_instance_of(SapeLink).to receive(:delete_all).and_return(:true) # end # it 'should fetch xml file' do # subject.invoke # expect(FakeWeb).to have_requested(:get, url) # end # it 'should fails if could not get file' do # FakeWeb.register_uri(:any, url, status: 404) # expect { subject.invoke } # .to raise_exception(RuntimeError, 'Could not receive data') # end # it 'should add data' do # subject.invoke # expect(SapeConfig.count).to eq 7 # expect(SapeLink.count).to eq 1 # end end end
Version data entries
13 entries across 13 versions & 1 rubygems