Sha256: d497b6e4b1eb2a35f4c6a32ca93d51e9700cf2019d93198420fefe130da34b41

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

RSpec.describe Percy::Client::Snapshots, :vcr do
  let(:content) { "hello world! #{described_class.name}" }
  let(:sha) { Digest::SHA256.hexdigest(content) }

  describe '#create_snapshot' do
    it 'creates a snapshot' do
      build = Percy.create_build('fotinakis/percy-examples')
      resources = []
      resources << Percy::Client::Resource.new('/foo/test.html', sha: sha, is_root: true)
      resources << Percy::Client::Resource.new('/css/test.css', sha: sha)
      snapshot = Percy.create_snapshot(
        build['data']['id'],
        resources,
        name: 'homepage',
        enable_javascript: true,
      )

      expect(snapshot['data']).to be
      expect(snapshot['data']['id']).to be
      expect(snapshot['data']['type']).to eq('snapshots')
      expect(snapshot['data']['attributes']['name']).to eq('homepage')
      expect(snapshot['data']['relationships']['missing-resources']).to be
    end
    it 'fails if no resources are given' do
      build = Percy.create_build('fotinakis/percy-examples')
      expect do
        Percy.create_snapshot(build['data']['id'], [])
      end.to raise_error(Percy::Client::HttpError)
    end
  end
  describe '#finalize_snapshot' do
    it 'finalizes a snapshot' do
      build = Percy.create_build('fotinakis/percy-examples')
      resources = []
      resources << Percy::Client::Resource.new('/foo/test.html', sha: sha, is_root: true)
      resources << Percy::Client::Resource.new('/css/test.css', sha: sha)
      snapshot = Percy.create_snapshot(build['data']['id'], resources, name: 'homepage')

      result = Percy.finalize_snapshot(snapshot['data']['id'])
      expect(result).to eq({'success' => true})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percy-client-1.3.0 spec/lib/percy/client/snapshots_spec.rb
percy-client-1.2.0 spec/lib/percy/client/snapshots_spec.rb