Sha256: 616e4a818fc1ae134293d91215edde8418f850e5cb42608f6104b88acdc8987b

Contents?: true

Size: 1.4 KB

Versions: 18

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

RSpec.describe OptimizelyServerSide::DatafileFetcher do

  describe '#fetch' do

    context 'when 200 response' do
      before do
        stub_request(:get, "https://cdn.optimizely.com/json/5960232316.json")
        .to_return(body: '{"experiments": [{"status": "running"}]}',status: 200)
      end

      it 'should fetch the config' do
        expect(described_class.fetch.content).to eq('{"experiments": [{"status": "running"}]}')
      end


      it 'should return stringified datafile' do
        expect(described_class.datafile.content).to eq('{"experiments": [{"status": "running"}]}')
      end

    end


    context 'when 500 response' do
      before do
        stub_request(:get, "https://cdn.optimizely.com/json/5960232316.json")
        .to_return(body: '{"experiments": [{"status": "running"}]}',status: 500)
      end

      it 'should fetch the config' do
        expect(described_class.fetch.content).to eq('{"experiments": [],"version": "1","audiences": [],"dimensions": [],"groups": [],"projectId": "5960232316","accountId": "5955320306","events": [],"revision": "30"}')
      end


      it 'should return stringified datafile' do
        expect(described_class.datafile.content).to eq('{"experiments": [],"version": "1","audiences": [],"dimensions": [],"groups": [],"projectId": "5960232316","accountId": "5955320306","events": [],"revision": "30"}')
      end

    end

  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
optimizely_server_side-1.2.0 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-1.0.1 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-1.0.0 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.18 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.17 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.16 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.15 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.14 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.13 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.12 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.11 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.10 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.9 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.8 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.7 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.6 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.5 spec/optimizely_server_side/datafile_fetcher_spec.rb
optimizely_server_side-0.0.4 spec/optimizely_server_side/datafile_fetcher_spec.rb