Class: Spring::Test::AcceptanceTest

Inherits:
ActiveSupport::TestCase
  • Object
show all
Defined in:
lib/spring/test/acceptance_test.rb

Constant Summary collapse

DEFAULT_SPEEDUP =
0.8

Instance Method Summary collapse

Instance Method Details

#appObject



28
29
30
# File 'lib/spring/test/acceptance_test.rb', line 28

def app
  @app ||= Spring::Test::Application.new("#{Spring::Test.root}/apps/tmp")
end

#assert_failure(command, expected_output = nil) ⇒ Object



45
46
47
48
49
# File 'lib/spring/test/acceptance_test.rb', line 45

def assert_failure(command, expected_output = nil)
  artifacts = app.run(*Array(command))
  assert !artifacts[:status].success?, "expected unsuccessful exit status\n\n#{app.debug(artifacts)}"
  assert_output artifacts, expected_output if expected_output
end

#assert_output(artifacts, expected) ⇒ Object



32
33
34
35
36
37
# File 'lib/spring/test/acceptance_test.rb', line 32

def assert_output(artifacts, expected)
  expected.each do |stream, output|
    assert artifacts[stream].include?(output),
           "expected #{stream} to include '#{output}'.\n\n#{app.debug(artifacts)}"
  end
end

#assert_speedup(ratio = DEFAULT_SPEEDUP) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/spring/test/acceptance_test.rb', line 51

def assert_speedup(ratio = DEFAULT_SPEEDUP)
  if ENV['CI']
    yield
  else
    app.with_timing do
      yield
      assert app.timing_ratio < ratio, "#{app.last_time} was not less than #{ratio} of #{app.first_time}"
    end
  end
end

#assert_success(command, expected_output = nil) ⇒ Object



39
40
41
42
43
# File 'lib/spring/test/acceptance_test.rb', line 39

def assert_success(command, expected_output = nil)
  artifacts = app.run(*Array(command))
  assert artifacts[:status].success?, "expected successful exit status\n\n#{app.debug(artifacts)}"
  assert_output artifacts, expected_output if expected_output
end

#generatorObject



24
25
26
# File 'lib/spring/test/acceptance_test.rb', line 24

def generator
  @@generator ||= generator_klass.new(rails_version)
end

#generator_klassObject

Extension point for spring-watchers-listen



20
21
22
# File 'lib/spring/test/acceptance_test.rb', line 20

def generator_klass
  Spring::Test::ApplicationGenerator
end

#rails_versionObject



15
16
17
# File 'lib/spring/test/acceptance_test.rb', line 15

def rails_version
  ENV['RAILS_VERSION'] || '~> 4.2.0'
end