Commit 9fcc169
Changed files (2)
db
spec
models
db/schema.rb
@@ -0,0 +1,24 @@
+# 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 that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 20140409034211) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "users", force: true do |t|
+ t.string "email"
+ t.string "password_digest"
+ end
+
+end
spec/models/user_spec.rb
@@ -3,8 +3,20 @@ require "spec_helper"
describe User do
context "#save" do
it "can be saved" do
- User.create!(email: 'mo@mokhan.ca')
+ User.create!(email: 'mo@mokhan.ca', password: 'password', password_confirmation: 'password')
User.count.should == 1
end
end
+
+ context "#authenticate" do
+ let(:user) { User.create!(email: 'blah@example.com', password: 'password', password_confirmation: 'password') }
+
+ it "returns true when the password is correct" do
+ user.authenticate('password').should be_true
+ end
+
+ it "returns false when the password is incorrect" do
+ user.authenticate('wrong').should be_false
+ end
+ end
end