Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Classic-style Post model and spec

  • Loading branch information...
commit dc0f5b697a3fd98d166b90c5037f1ba9d0c588c0 1 parent 03970db
@leshill authored
View
2  app/models/post.rb
@@ -0,0 +1,2 @@
+class Post < ActiveRecord::Base
+end
View
10 db/migrate/20111023214144_create_posts.rb
@@ -0,0 +1,10 @@
+class CreatePosts < ActiveRecord::Migration
+ def change
+ create_table :posts do |t|
+ t.string :title
+ t.text :body
+
+ t.timestamps
+ end
+ end
+end
View
23 db/schema.rb
@@ -0,0 +1,23 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20111023214144) do
+
+ create_table "posts", :force => true do |t|
+ t.string "title"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
View
4 spec/fabricators/post_fabricator.rb
@@ -0,0 +1,4 @@
+Fabricator(:post) do
+ title "MyString"
+ body "MyText"
+end
View
9 spec/models/post_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe Post do
+ it "creates a post" do
+ expect do
+ Post.create(title: 'a title', body: 'some body text')
+ end.to change(Post, :count).from(0).to(1)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.