Created
October 3, 2012 22:44
-
-
Save cableray/3830360 to your computer and use it in GitHub Desktop.
Factory girl traits not working
This file contains 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 :antvatar_part_category do | |
sequence(:name) {|n| "Category #{n}"} | |
trait :current_seasonal do | |
started_on {1.week.ago} | |
stopped_on {1.week.from.now} | |
end | |
trait :sesonal_ended do | |
stopped_on {1.week.ago} | |
end | |
trait :seasonal_future do | |
started_on {1.week.from.now} | |
end | |
end | |
end |
This file contains 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 File.dirname(__FILE__) + '/../spec_helper' | |
describe AntvatarPartCategory do | |
describe "factory" do | |
subject {FactoryGirl.create :antvatar_part_category} | |
it{should be_valid} | |
end | |
… | |
describe "scopes" do | |
describe "#current_seasonal" do | |
let(:start_and_end){FactoryGirl.create( :antvatar_part_category, :current_seasonal)} | |
let(:end_only){FactoryGirl.create :antvatar_part_category, :current_seasonal, stared_on:nil} | |
let(:start_only){FactoryGirl.create :antvatar_part_category, :current_seasonal, stopped_on:nil} | |
let(:nonseasonal){FactoryGirl.create :antvatar_part_category} | |
let(:ended){FactoryGirl.create :antvatar_part_category, :seasonal_ended} | |
let(:future){FactoryGirl.create :antvatar_part_category, :seasonal_future} | |
subject{AntvatarPartCategory.current_seasonal} | |
it {should include(start_and_end)} | |
it {should include(end_only)} | |
it {should include(start_only)} | |
it {should_not include(nonseasonal)} | |
it {should_not include(ended)} | |
it {should_not include(future)} | |
end | |
end | |
end |
This file contains 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 'factory_girl' | |
FactoryGirl.reload |
This file contains 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
Failures: | |
1) AntvatarPartCategory scopes#current_seasonal | |
Failure/Error: let(:start_and_end){FactoryGirl.create( :antvatar_part_category, :current_seasonal)} | |
NoMethodError: | |
undefined method `symbolize_keys' for :current_seasonal:Symbol | |
# ./spec/models/antvatar_part_category_spec.rb:18:in `block (4 levels) in <top (required)>' | |
# ./spec/models/antvatar_part_category_spec.rb:25:in `block (4 levels) in <top (required)>' | |
2) AntvatarPartCategory scopes#current_seasonal | |
Failure/Error: let(:end_only){FactoryGirl.create :antvatar_part_category, :current_seasonal, stared_on:nil} | |
ArgumentError: | |
wrong number of arguments (3 for 2) | |
# ./spec/models/antvatar_part_category_spec.rb:19:in `block (4 levels) in <top (required)>' | |
# ./spec/models/antvatar_part_category_spec.rb:26:in `block (4 levels) in <top (required)>' | |
3) AntvatarPartCategory scopes#current_seasonal | |
Failure/Error: let(:start_only){FactoryGirl.create :antvatar_part_category, :current_seasonal, stopped_on:nil} | |
ArgumentError: | |
wrong number of arguments (3 for 2) | |
# ./spec/models/antvatar_part_category_spec.rb:20:in `block (4 levels) in <top (required)>' | |
# ./spec/models/antvatar_part_category_spec.rb:27:in `block (4 levels) in <top (required)>' | |
4) AntvatarPartCategory scopes#current_seasonal | |
Failure/Error: let(:ended){FactoryGirl.create :antvatar_part_category, :seasonal_ended} | |
NoMethodError: | |
undefined method `symbolize_keys' for :seasonal_ended:Symbol | |
# ./spec/models/antvatar_part_category_spec.rb:22:in `block (4 levels) in <top (required)>' | |
# ./spec/models/antvatar_part_category_spec.rb:29:in `block (4 levels) in <top (required)>' | |
5) AntvatarPartCategory scopes#current_seasonal | |
Failure/Error: let(:future){FactoryGirl.create :antvatar_part_category, :seasonal_future} | |
NoMethodError: | |
undefined method `symbolize_keys' for :seasonal_future:Symbol | |
# ./spec/models/antvatar_part_category_spec.rb:23:in `block (4 levels) in <top (required)>' | |
# ./spec/models/antvatar_part_category_spec.rb:30:in `block (4 levels) in <top (required)>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment