Created
March 30, 2013 23:25
-
-
Save allaire/5278796 to your computer and use it in GitHub Desktop.
Minitest setup and exemple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Environment | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path('../../config/environment', __FILE__) | |
# Factories | |
require File.expand_path('../factories', __FILE__) | |
# Minitest | |
require 'minitest/autorun' | |
require 'turn/autorun' | |
Turn.config.format = :outline | |
# Sidekiq integration | |
require 'sidekiq/testing' | |
# Base class | |
class Spec < Minitest::Spec | |
def t(*args) | |
I18n.t(*args) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative '../spec_helper' | |
class UserSpec < Spec | |
it 'must create a new user' do | |
user = FactoryGirl.create(:user) | |
user.first_name.wont_be_empty | |
user.last_name.wont_be_empty | |
user.email.wont_be_empty | |
end | |
it 'must require first name' do | |
user = FactoryGirl.build(:user, :first_name => nil) | |
user.valid?.must_equal false | |
end | |
it 'must require last name' do | |
user = FactoryGirl.build(:user, :last_name => nil) | |
user.valid?.must_equal false | |
end | |
it 'must validate email uniqueness' do | |
user = FactoryGirl.create(:user) | |
user = FactoryGirl.build(:user, email: user.email) | |
user.valid?.must_equal false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment