Sha256: 4482081461d8a2bf3e0d945504896bd1ff3e764e277d20f37ffe3c21b1b611d9

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require 'capybara/rspec'
require 'capybara/poltergeist'
require 'rspec-html-matchers'
require 'active_support/all'
require 'erector'
require 'dvl/flashes'
require_relative '../preview/app'

Capybara.app = App
Capybara.javascript_driver = :poltergeist

def take_screenshot(error_type, filename, res_x = 900, res_y = 150)
  describe "taking screenshot: #{filename}.png" do
    before do
      page.driver.resize(res_x, res_y)
    end

    it 'works' do
      visit '/'
      click_link error_type
      page.save_screenshot "screenshots/#{filename}.png"
    end
  end
end

describe Dvl::Flashes do

  describe 'Integration', type: :feature, js: true do
    it 'Flashes properly' do
      visit '/'
      page.execute_script "DvlFlash('error', 'Yeah!')"
      expect(page).to have_selector '.flash.flash_error', text: 'Yeah!'
      sleep 4
      expect(page).to_not have_selector '.flash.flash_error', text: 'Yeah!'
    end
  end

  describe 'Screenshots', type: :feature, js: true do
    take_screenshot 'Error', 'error'
    take_screenshot 'Success', 'success'
    take_screenshot 'Info', 'info'
    take_screenshot 'Error', 'error_mobile', 320, 150
  end

  describe Dvl::Flashes::Views::Flashes do
    let!(:success_html) do
      described_class.new(
        flash: { 'success' => 'Yeah!' }
      ).to_html
    end

    let!(:error_html) do
      described_class.new(
        flash: { 'error' => 'No!' }
      ).to_html
    end

    it 'renders the proper html' do
      expect(success_html).to have_tag('div.flash_success', content: 'Yeah!')
    end

    it 'renders the proper html' do
      expect(error_html).to have_tag('div.flash_error', content: 'No!')
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dvl-flashes-0.0.4 spec/dvl_flashes_spec.rb
dvl-flashes-0.0.3 spec/dvl_flashes_spec.rb
dvl-flashes-0.0.2 spec/dvl_flashes_spec.rb