Sha256: 5d03941effe313601b730501d113b79e6fe81bd5c30545b3a63c1e7e12a42157

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

describe Sufia::Analytics do
  before do
    token = OAuth2::AccessToken.new(nil, nil)
    allow(subject).to receive(:token).and_return(token)
  end

  describe "configuration" do
    context "When the yaml file has values" do
      it 'reads its config from a yaml file' do
        expect(subject.send(:config).keys.sort).to eql ['app_name', 'app_version', 'client_email', 'privkey_path', 'privkey_secret']
      end
    end

    context "When the yaml file has no values" do
      before do
        described_class.send(:remove_instance_variable, :@config)
        allow(File).to receive(:read).and_return("# Just comments\n# and comments\n")
      end
      it 'returns nil' do
        expect(Rails.logger).to receive(:error)
          .with(starting_with("Unable to fetch any keys from"))
        expect(subject.send(:config)).to be nil
      end
    end
  end

  it 'instantiates a user' do
    expect(subject.send(:user)).to be_a(Legato::User)
  end

  it 'responds to :profile' do
    expect(subject).to respond_to(:profile)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sufia-7.1.0 spec/lib/sufia/analytics_spec.rb
sufia-7.0.0 spec/lib/sufia/analytics_spec.rb
sufia-7.0.0.rc2 spec/lib/sufia/analytics_spec.rb
sufia-7.0.0.rc1 spec/lib/sufia/analytics_spec.rb
sufia-7.0.0.beta4 spec/lib/sufia/analytics_spec.rb
sufia-7.0.0.beta3 spec/lib/sufia/analytics_spec.rb
sufia-7.0.0.beta2 spec/lib/sufia/analytics_spec.rb