Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 819 Bytes

rails.md

File metadata and controls

45 lines (35 loc) · 819 Bytes

Rails

Common commands

rails db:migrate
rails routes

# Run a script in the context of a rails app
rails runner script.rb

Debugging

Testing

# Run a test script
$ rails test --verbose test/test_pr.rb

# Run a test script in Rails.env='development' instead of 'test'
$ cat <<-EOF > test.rb
class TestFoo < MiniTest::Test
  def test_bar
    assert false
  end
end
MiniTest.autorun
EOF
$ rails runner test.rb

# Run a test from stdin in Rails.env='development' instead of 'test'
$ cat <<-EOF | rails runner -
class TestFoo < MiniTest::Test
  def test_bar
    assert false
  end
end
MiniTest.autorun
EOF