Update
This commit is contained in:
parent
24414bbdb6
commit
febdc2ef39
|
@ -86,7 +86,7 @@
|
||||||
{%comment%}<!-- google analytics -->{%endcomment%}
|
{%comment%}<!-- google analytics -->{%endcomment%}
|
||||||
{% if site.analytics %}<script>if(~location.hostname.indexOf("{{site.analytics.hostname}}")){var _gaq=_gaq||[];_gaq.push(["_setAccount","{{ site.analytics.id }}"]);_gaq.push(["_trackPageview"]);(function(){var ga=document.createElement("script");ga.async=true;ga.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga,s)})()}</script>{% endif %}
|
{% if site.analytics %}<script>if(~location.hostname.indexOf("{{site.analytics.hostname}}")){var _gaq=_gaq||[];_gaq.push(["_setAccount","{{ site.analytics.id }}"]);_gaq.push(["_trackPageview"]);(function(){var ga=document.createElement("script");ga.async=true;ga.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga,s)})()}</script>{% endif %}
|
||||||
|
|
||||||
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
|
<meta content='IE=edge' http-equiv='X-UA-Compatible'>
|
||||||
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
|
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
|
||||||
<link href='{{ base }}/assets/favicon.png' rel='shortcut icon'>
|
<link href='{{ base }}/assets/favicon.png' rel='shortcut icon'>
|
||||||
|
|
||||||
|
|
|
@ -10,40 +10,19 @@ layout: default
|
||||||
test/factories/*.rb
|
test/factories/*.rb
|
||||||
spec/factories/*.rb
|
spec/factories/*.rb
|
||||||
|
|
||||||
### Defining stuff
|
|
||||||
|
|
||||||
FactoryGirl.define do
|
|
||||||
factory ...
|
|
||||||
end
|
|
||||||
|
|
||||||
### Factories
|
### Factories
|
||||||
|
|
||||||
# This will guess the User class
|
FactoryGirl.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
first_name "John"
|
first_name "John"
|
||||||
last_name { %w[Doe Smith Doyle].shuffle }
|
last_name "Doe"
|
||||||
|
birthdate { 21.years.ago }
|
||||||
admin false
|
admin false
|
||||||
|
|
||||||
# Sequences
|
profile # assuming there's a factory :profile
|
||||||
sequence(:username) { |n| "user#{n}" }
|
|
||||||
|
|
||||||
# Associations
|
|
||||||
association :author
|
|
||||||
association :author, factory: user, last_name: "Ho"
|
|
||||||
author
|
|
||||||
|
|
||||||
# Traits
|
|
||||||
trait :admin do
|
|
||||||
admin true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after :create do |user, evaluator| ... end
|
|
||||||
after :build
|
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :user, aliases: [:author, :commenter] do ... end
|
|
||||||
factory :admin_user, parent: :user do .. end
|
|
||||||
|
|
||||||
### Using
|
### Using
|
||||||
|
|
||||||
FactoryGirl.build(:user)
|
FactoryGirl.build(:user)
|
||||||
|
@ -58,3 +37,53 @@ layout: default
|
||||||
create_list(:user, 3)
|
create_list(:user, 3)
|
||||||
build_list(:user, 3)
|
build_list(:user, 3)
|
||||||
|
|
||||||
|
### Associations
|
||||||
|
|
||||||
|
factory :post do
|
||||||
|
after :create do |post|
|
||||||
|
create :theme, post: post # has_one
|
||||||
|
create_list :comment, 3, post: post # has_many
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
### Ignores
|
||||||
|
|
||||||
|
factory :user do
|
||||||
|
ignore do
|
||||||
|
likes 30
|
||||||
|
end
|
||||||
|
|
||||||
|
after :create do |user, options|
|
||||||
|
create_list :like, options.likes, user: user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
create(:user, likes: 10)
|
||||||
|
|
||||||
|
### Traits
|
||||||
|
|
||||||
|
factory :user do
|
||||||
|
trait :admin do
|
||||||
|
admin true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
create :user, :admin
|
||||||
|
|
||||||
|
### Etc
|
||||||
|
|
||||||
|
# Sequences
|
||||||
|
sequence(:username) { |n| "user#{n}" }
|
||||||
|
|
||||||
|
# Associations
|
||||||
|
association :author
|
||||||
|
association :author, factory: user, last_name: "Ho"
|
||||||
|
author
|
||||||
|
|
||||||
|
after :create do |user, evaluator| ... end
|
||||||
|
after :build
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :user, aliases: [:author, :commenter] do ... end
|
||||||
|
factory :admin_user, parent: :user do .. end
|
||||||
|
|
||||||
|
|
9
sinon.md
9
sinon.md
|
@ -80,5 +80,10 @@ layout: default
|
||||||
|
|
||||||
### Sandbox
|
### Sandbox
|
||||||
|
|
||||||
beforeEach -> global.sinon = require('sinon').sandbox.create()
|
beforeEach(function() {
|
||||||
afterEach -> global.sinon.restore()
|
global.sinon = require('sinon').sandbox.create();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
global.sinon.restore();
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue