Skip to content

Instantly share code, notes, and snippets.

@psylone
Last active December 25, 2015 15:19
Show Gist options
  • Save psylone/6997215 to your computer and use it in GitHub Desktop.
Save psylone/6997215 to your computer and use it in GitHub Desktop.
RSpec Unit test template.
# RSpec Unit Template
describe Model do
# Factories
describe "has facttories" do
it "model factory" do
end
it "another model factory" do
end
end
# Validations
describe "has validations" do
context "for field" do
it "should present" do
end
it "should be numericality" do
end
end
context "for another field" do
it "should be uniq" do
end
end
end
# Callbacks
describe "has callbacks" do
describe "callback type" do
context "#set_initial_value" do
it "do something" do
end
it "do something else" do
end
end
end
end
# Class methods
describe "has class methods" do
context ".class_method" do
it "return result" do
end
end
context ".another_class_method" do
it "return another result" do
end
end
end
# Instance methods
describe "has instance methods" do
context "#instance_method" do
it "return result" do
end
it "return another result" do
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment