Created
May 15, 2015 13:57
-
-
Save tbuehlmann/f28e401ed33e5eed9e56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Category < ActiveRecord::Base | |
has_many :categorizations | |
has_many :posts, through: :categorizations | |
end |
This file contains hidden or 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
require 'rails_helper' | |
RSpec.describe Category, :type => :model do | |
it {should validate_presence_of :category } | |
end |
This file contains hidden or 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
FactoryGirl.define do | |
factory :category do | |
name "MyString" | |
end | |
end |
This file contains hidden or 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
[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)> |
This file contains hidden or 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
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