Skip to content

Instantly share code, notes, and snippets.

@samflores
Created March 19, 2009 17:22
Show Gist options
  • Save samflores/81949 to your computer and use it in GitHub Desktop.
Save samflores/81949 to your computer and use it in GitHub Desktop.
## task_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Task do
include ValidTaskAttributes
# o módulo ValidTaskAttributes define o método valid_task que retorna
#{
# :name => "Task name",
# :description => "Task description",
# :alias => "task_alias",
# :due_date => Date.today,
# :priority => 1,
# :percentage => 9.99,
#}
describe 'validations' do
before :each do
Task.create(valid_task)
end
subject { Task.new }
end
end
## task.rb
class Task < ActiveRecord::Base
validates_uniqueness_of :name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment