Sha256: 79f73c92d156fef7dbc925a174f2c7dfb0409bfad3aabb4604da7daed5db5775

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

require 'unit_spec_helper'

shared_examples 'Rpush::Client::Webpush::App' do
  describe 'validates' do
    subject { described_class.new }

    it 'validates presence of name' do
      is_expected.not_to be_valid
      expect(subject.errors[:name]).to eq ["can't be blank"]
    end

    it 'validates presence of vapid_keypair' do
      is_expected.not_to be_valid
      expect(subject.errors[:vapid_keypair]).to eq ["can't be blank"]
    end

    it 'should require the vapid keypair to have subject, public and private key' do
      subject.vapid_keypair = {}.to_json
      is_expected.not_to be_valid
      expect(subject.errors[:vapid_keypair].sort).to eq [
        'must have a private_key entry',
        'must have a public_key entry',
        'must have a subject entry',
      ]
    end

    it 'should require valid json for the keypair' do
      subject.vapid_keypair = 'invalid'
      is_expected.not_to be_valid
      expect(subject.errors[:vapid_keypair].sort).to eq [ 'must be valid JSON' ]
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rpush-9.1.0 spec/unit/client/shared/webpush/app.rb
rpush-9.0.0 spec/unit/client/shared/webpush/app.rb
rpush-8.0.0 spec/unit/client/shared/webpush/app.rb
rpush-7.0.1 spec/unit/client/shared/webpush/app.rb
rpush-7.0.0 spec/unit/client/shared/webpush/app.rb
rpush-6.0.1 spec/unit/client/shared/webpush/app.rb
rpush-6.0.0 spec/unit/client/shared/webpush/app.rb
rpush-5.4.0 spec/unit/client/shared/webpush/app.rb
rpush-5.3.0 spec/unit/client/shared/webpush/app.rb