Class: Spring::Test::AcceptanceTest
- Inherits:
-
ActiveSupport::TestCase
- Object
- ActiveSupport::TestCase
- Spring::Test::AcceptanceTest
- Defined in:
- lib/spring/test/acceptance_test.rb
Constant Summary collapse
- DEFAULT_SPEEDUP =
0.8
Instance Method Summary collapse
- #app ⇒ Object
- #assert_failure(command, expected_output = nil) ⇒ Object
- #assert_output(artifacts, expected) ⇒ Object
- #assert_speedup(ratio = DEFAULT_SPEEDUP) ⇒ Object
- #assert_success(command, expected_output = nil) ⇒ Object
- #generator ⇒ Object
-
#generator_klass ⇒ Object
Extension point for spring-watchers-listen.
- #rails_version ⇒ Object
Instance Method Details
#app ⇒ Object
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 |
#generator ⇒ Object
24 25 26 |
# File 'lib/spring/test/acceptance_test.rb', line 24 def generator @@generator ||= generator_klass.new(rails_version) end |
#generator_klass ⇒ Object
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_version ⇒ Object
15 16 17 |
# File 'lib/spring/test/acceptance_test.rb', line 15 def rails_version ENV['RAILS_VERSION'] || '~> 4.2.0' end |