Sha256: a59938a7d6e871b83c5e371dfe66c6f42daed6a962c77c108f1f55c6025a4fba

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

require 'capybara/dsl'

require_relative 'test_helper'

module Nesta
  class App < Sinatra::Base
    set :environment, :test
    set :reload_templates, true
  end

  module IntegrationTest
    include Capybara::DSL

    include ModelFactory
    include TestConfiguration

    def setup
      Capybara.app = App.new
    end

    def teardown
      Capybara.reset_sessions!
      Capybara.use_default_driver

      remove_temp_directory
      Nesta::FileModel.purge_cache
    end

    def assert_has_xpath(query, options = {})
      if ! page.has_xpath?(query, options)
        message = "not found in page: '#{query}'"
        message << ", #{options.inspect}" unless options.empty?
        fail message
      end
    end

    def assert_has_no_xpath(query, options = {})
      if page.has_xpath?(query, options)
        message = "found in page: '#{query}'"
        message << ", #{options.inspect}" unless options.empty?
        fail message
      end
    end

    def assert_has_css(query, options = {})
      if ! page.has_css?(query, options)
        message = "not found in page: '#{query}'"
        message << ", #{options.inspect}" unless options.empty?
        fail message
      end
    end

    def assert_has_no_css(query, options = {})
      if ! page.has_no_css?(query, options)
        message = "found in page: '#{query}'"
        message << ", #{options.inspect}" unless options.empty?
        fail message
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nesta-0.18.0 test/integration_test_helper.rb
nesta-0.17.0 test/integration_test_helper.rb
nesta-0.16.0 test/integration_test_helper.rb
nesta-0.15.0 test/integration_test_helper.rb
nesta-0.14.0 test/integration_test_helper.rb
nesta-0.13.0 test/integration_test_helper.rb
nesta-0.12.0 test/integration_test_helper.rb