Skip to content

Instantly share code, notes, and snippets.

@jnicho02
Last active July 6, 2017 10:58
Show Gist options
  • Save jnicho02/914ea2dae44b879389beeea38e2e990a to your computer and use it in GitHub Desktop.
Save jnicho02/914ea2dae44b879389beeea38e2e990a to your computer and use it in GitHub Desktop.
Take a look at the Rails Guide to Testing: http://guides.rubyonrails.org/testing.html
Rails has unit testing using MiniTest by default.
When you ran the scaffolding it created a controller test /test/controllers/topics_controller_test.rb
Add to /test/models/topic_test.rb:
class TopicTest < ActiveSupport::TestCase
test "set a title" do
t = Topic.new
t.title = "Hi there"
assert t.title == "Hi theres"
end
end
run the tests:
$ rails test
Add to gemfile:
gem 'rspec-rails'
rails g rspec:install
...soem more stuff about rspec testing....
Capybara:
Cloud 9 might need headless https://www.stefanwienert.de/blog/2015/07/24/how-to-install-capybara-webkit-for-ubuntu-12-dot-04/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment