require 'spec_helper'

RSpec.configure do |config|
  config.include Rack::Test::Methods
  DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/test.db")
  DataMapper.finalize
  Post.auto_migrate!
end

describe 'Sinatra App' do
  it 'should respond to GET' do
    get '/'
    last_response.should be_ok
  end
end

describe "post /posts/create" do
  it "should insert the post in the database" do
    lambda do
      post "/posts/create", params = {
        :title => 'title',
        :body => 'body'
      }
    end.should {
      change(Post, :count).by(1)
    }
  end
end
require 'spec_helper'

describe "post" do
  
  it "should require title" do
    post = Post.new
    post.should_not be_valid
    post.errors[:title].first.should match "Title must not be blank"
  end

  it "should require slug" do
    post = Post.new
    post.should_not be_valid
    post.errors[:slug].first.should match "Slug must not be blank"
  end
end
Add spec for Post validation
Add spec for Post validation
