Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sqlite |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Migrations will run automatically. The DSL like wrapper syntax is courtesy | ||
# of sinatra-sequel | ||
# | ||
# For details on sequel's schema modifications, check out: | ||
# http://sequel.rubyforge.org/rdoc/files/doc/schema_rdoc.html | ||
|
||
migration "create the people table" do | ||
database.create_table :people do | ||
primary_key :id | ||
string :name | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Person < Sequel::Model | ||
def validate | ||
errors.add(:name, "can't be empty") if name.nil? || name.empty? | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
|
||
describe Person do | ||
describe "validations" do | ||
it "should require a name" do | ||
Person.new().should_not be_valid | ||
Person.new(:name => '').should_not be_valid | ||
Person.new(:name => "Maggie").should be_valid | ||
end | ||
end | ||
end |