Sha256: 144066e21d635aca5f02cc92ba29b5eacc5daebfba841be518a6c52a44a55e41

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

RSpec.describe Percy, type: :feature do
  TEST_CASE_GLOB =  File.join(File.dirname(__FILE__), "./capybara/client/test_data/test-*.html")

  describe '#snapshot', type: :feature, js: true do
    context 'with live sites' do
      it 'snapshots simple HTTPS site' do
        visit 'https://example.com'
        Percy.snapshot(page)
      end
      it 'snapshots complex HTTPS site' do
        visit 'https://polaris.shopify.com/'
        Percy.snapshot(page)
      end
      it 'snapshots site with strict CSP' do
        visit 'https://buildkite.com/'
        Percy.snapshot(page)
      end
    end
    context 'with different options' do
      it 'can get a default name' do
        visit 'http://example.com'
        Percy.snapshot(page)
      end
      it 'uses query params and fragment for default name' do
        visit 'http://example.com/?with_query'
        Percy.snapshot(page)
        visit 'http://example.com/?with_query_params#and-fragment'
        Percy.snapshot(page)
      end
      it 'uses provided name' do
        visit 'http://example.com'
        Percy.snapshot(page, name: 'My very special snapshot 🌟')
      end
      it 'recognizes requested widths' do
        visit 'http://example.com'
        Percy.snapshot(page, { name: 'widths', widths: [768, 992, 1200] })
      end
      it 'recognizes minHeight' do
        visit 'http://example.com'
        Percy.snapshot(page, { name: 'minHeight', minHeight: 2000 })
      end
    end
  end

  describe '_keys_to_json' do
    it 'transforms keys from snake_case to JSON-style' do
      original = { enable_javascript: true, min_height: 2000 }
      transformed = Percy._keys_to_json(original)
      expect(transformed.has_key? 'enableJavascript')
      expect(transformed.has_key? 'minHeight')
      expect(transformed['enableJavascript']).to eq(original[:enable_javascript])
      expect(transformed['minHeight']).to eq(original[:min_height])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
percy-capybara-4.0.0 spec/lib/percy/percy_spec.rb
percy-capybara-4.0.0.pre.beta2 spec/lib/percy/percy_spec.rb
percy-capybara-4.0.0.pre.beta1 spec/lib/percy/percy_spec.rb