Class: CypressRails::TestCase

Inherits:
ActionDispatch::SystemTestCase
  • Object
show all
Defined in:
lib/cypress-rails/test_case.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.test_locator(path_or_globs) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cypress-rails/test_case.rb', line 15

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

Instance Method Details

#setupObject



9
10
11
12
13
# File 'lib/cypress-rails/test_case.rb', line 9

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