Sha256: 0bdceedd890b0db1dbd951b390fac6bef34c7d71d45298a084576235b93f7bac

Contents?: true

Size: 973 Bytes

Versions: 4

Compression:

Stored size: 973 Bytes

Contents

require "action_dispatch/system_test_case"

require_relative "configures_test_server"

module CypressRails
  class TestCase < ActionDispatch::SystemTestCase
    driven_by :selenium_headless

    def setup
      @@__cypress_rails_configures_test_server ||= ConfiguresTestServer.new.call
    ensure
      super
    end

    def self.test_locator(path_or_globs)
      Dir[path_or_globs].map do |path|
        test_name = "test_#{path.gsub(/[\/\.:\\]/, "_")}"
        define_method test_name do
          bin = FindsBin.new.call
          command = "CYPRESS_BASE_URL=http://#{Capybara.server_host}:#{Capybara.server_port} #{bin} run --spec \"#{path}\""
          unless system(command)
            raise <<~ERROR
              Cypress test failed. Try again with:
                $ rails test test/system --name #{test_name}

              Underlying Cypress command run was:
                $ #{command}
            ERROR
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cypress-rails-0.0.4 lib/cypress-rails/test_case.rb
cypress-rails-0.0.3 lib/cypress-rails/test_case.rb
cypress-rails-0.0.2 lib/cypress-rails/test_case.rb
cypress-rails-0.0.1 lib/cypress-rails/test_case.rb