Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 more models and then associations on factory girl #35

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 77 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,79 @@
# git config --global core.excludesfile '~/.gitignore_global'
/vendor/bundle
# Created by https://www.gitignore.io/api/rails,sublimetext,osx

### Rails ###
*.rbc
capybara-*.html
.rspec
/log
/tmp
!/log/.keep
/db/*.sqlite3
/db/*.sqlite3-journal
/public/system
/coverage/
/spec/tmp
**.orig
rerun.txt
pickle-email-*.html

## Environment normalisation:
/.bundle
#
# Ignore bundler config.
/log
/log/*
# Ignore all logfiles and tempfiles.
# or operating system, you probably want to add a global ignore instead:
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
Gemfile.lock
# If you find yourself ignoring temporary files generated by your text editor
/vendor/bundle

# these should all be checked in to normalise the environment:
# Gemfile.lock, .ruby-version, .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# if using bower-rails ignore default bower_components path bower.json files
/vendor/assets/bower_components
*.bowerrc
bower.json

# Ignore pow environment settings
.powenv


### SublimeText ###
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

# sftp configuration file
sftp-config.json


### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--color
--require spec_helper
--format documentation
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ group :development, :test do
gem 'pry'
gem 'pry-rails'
gem 'spring'
# testing
gem 'airborne'
gem 'rspec-rails', '~> 3.0'
gem 'factory_girl_rails'
end

group :test do
gem 'ffaker', git: "https://github.com/AsianTechInc/ffaker.git"
end
194 changes: 194 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
GIT
remote: https://github.com/AsianTechInc/ffaker.git
revision: 61dfb6075ed65ed7c0dad74d0c836203cf62528f
specs:
ffaker (2.1.0)

GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.4)
actionview (= 4.2.4)
activesupport (= 4.2.4)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.4)
activesupport (= 4.2.4)
globalid (>= 0.3.0)
activemodel (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
activerecord (4.2.4)
activemodel (= 4.2.4)
activesupport (= 4.2.4)
arel (~> 6.0)
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
airborne (0.1.19)
activesupport (>= 3.0.0)
rack-test (~> 0.6, >= 0.6.2)
rest-client (~> 1.7, >= 1.7.3)
rspec (~> 3.1, >= 3.1.0)
arel (6.0.3)
bcrypt (3.1.10)
builder (3.2.2)
coderay (1.1.0)
devise (3.5.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
i18n (0.7.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.6.2)
mini_portile (0.6.2)
minitest (5.8.0)
mysql2 (0.3.20)
netrc (0.10.3)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.4)
actionmailer (= 4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
activemodel (= 4.2.4)
activerecord (= 4.2.4)
activesupport (= 4.2.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.4)
sprockets-rails
rails-api (0.4.0)
actionpack (>= 3.2.11)
railties (>= 3.2.11)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.4)
actionpack (= 4.2.4)
activesupport (= 4.2.4)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-rails (3.3.3)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
slop (3.6.0)
spring (1.4.0)
sprockets (3.3.4)
rack (~> 1.0)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
versionist (1.4.1)
activesupport (>= 3)
railties (>= 3)
yard (~> 0.7)
warden (1.2.3)
rack (>= 1.0)
yard (0.8.7.6)

PLATFORMS
ruby

DEPENDENCIES
airborne
devise
factory_girl_rails
ffaker!
mysql2 (= 0.3.20)
pry
pry-rails
rails (= 4.2.4)
rails-api
rspec-rails (~> 3.0)
spring
versionist

BUNDLED WITH
1.10.6
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class User < ActiveRecord::Base
has_many :comments

before_create :generate_token
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }

private
def time_expire
Expand Down
11 changes: 11 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,16 @@ class Application < Rails::Application
# config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore
# config.middleware.use ActionDispatch::Flash

config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: true,
request_specs: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
end
end
7 changes: 7 additions & 0 deletions spec/factories/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :comment do
association :post
association :user
content { FFaker::Lorem.sentence(3) }
end
end
7 changes: 7 additions & 0 deletions spec/factories/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :post do
association :user
title { FFaker::Food.vegetable }
content { FFaker::Lorem.sentence(3) }
end
end
10 changes: 10 additions & 0 deletions spec/factories/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FactoryGirl.define do
factory :user do
email { FFaker::Internet.email }
password { FFaker::Internet.password(8) }

# after(:build) do |user|
# user.posts << FactoryGirl.build(:post, user: user)
# end
end
end
Loading