Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Created May 15, 2015 13:57
Show Gist options
  • Save tbuehlmann/f28e401ed33e5eed9e56 to your computer and use it in GitHub Desktop.
Save tbuehlmann/f28e401ed33e5eed9e56 to your computer and use it in GitHub Desktop.
class Category < ActiveRecord::Base
has_many :categorizations
has_many :posts, through: :categorizations
end
require 'rails_helper'
RSpec.describe Category, :type => :model do
it {should validate_presence_of :category }
end
FactoryGirl.define do
factory :category do
name "MyString"
end
end
[1] guard(main)>
15:47:11 - INFO - Run all
15:47:12 - INFO - Bundle already up-to-date
15:47:12 - INFO - Running all specs
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Post
should require body to be set
should require title to be set
Category
should require category to be set (FAILED - 1)
Categorization
add some examples to (or delete) /Users/batu/boilerplate/spec/models/categorization_spec.rb (PENDING: Not yet implemented)
User
should require email to be set
should require last_name to be set
should require first_name to be set
when a user does not have an encryted password
validates the password and password_confirmation
UserPolicy
update?
allows an admin to make updates
prevents updates if not an admin
show?
allows an admin to see any profile
allows you to see your own profile
prevents other users from seeing your profile
destroy?
allows an admin to delete any user
prevents deleting yourself
index?
allows access for an admin
denies access if not an admin
Pending:
Categorization add some examples to (or delete) /Users/batu/boilerplate/spec/models/categorization_spec.rb
# Not yet implemented
# ./spec/models/categorization_spec.rb:4
Failures:
1) Category should require category to be set
Failure/Error: it {should validate_presence_of :category }
NoMethodError:
undefined method `category=' for #<Category id: nil, name: nil, created_at: nil, updated_at: nil>
# ./spec/models/category_spec.rb:4:in `block (2 levels) in <top (required)>'
Deprecation Warnings:
Using `should` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` instead. Called from /Users/batu/boilerplate/spec/models/user_spec.rb:14:in `block (3 levels) in <top (required)>'.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
1 deprecation warning total
Finished in 0.21159 seconds (files took 5.6 seconds to load)
17 examples, 1 failure, 1 pending
Failed examples:
rspec ./spec/models/category_spec.rb:4 # Category should require category to be set
Randomized with seed 34173
[1] guard(main)>
class CreateCategories < ActiveRecord::Migration
def change
create_table :categories do |t|
t.string :name
t.timestamps
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment