Permalink
Browse files

avoid factory girl syntax deprecation warnings

  • Loading branch information...
1 parent 58e505a commit a61918798c046b806261b7b9e470b0bb1107d03b @mjankowski mjankowski committed Apr 2, 2012
View
22 spec/associations_spec.rb
@@ -3,18 +3,18 @@
describe 'Associations', 'has recent records' do
before do
- @comment_user = Factory :user
- @post_user = Factory :user
- @both_user = Factory :user
- Factory :comment, :user => @comment_user, :created_at => 10.days.ago
- Factory :comment, :user => @comment_user, :created_at => 3.days.ago
- Factory :post, :owner => @post_user, :created_at => 10.days.ago
- Factory :post, :owner => @post_user, :created_at => 3.days.ago
+ @comment_user = create :user
+ @post_user = create :user
+ @both_user = create :user
+ create :comment, :user => @comment_user, :created_at => 10.days.ago
+ create :comment, :user => @comment_user, :created_at => 3.days.ago
+ create :post, :owner => @post_user, :created_at => 10.days.ago
+ create :post, :owner => @post_user, :created_at => 3.days.ago
- Factory :comment, :user => @both_user, :created_at => 10.days.ago
- Factory :comment, :user => @both_user, :created_at => 3.days.ago
- Factory :post, :owner => @both_user, :created_at => 10.days.ago
- Factory :post, :owner => @both_user, :created_at => 3.days.ago
+ create :comment, :user => @both_user, :created_at => 10.days.ago
+ create :comment, :user => @both_user, :created_at => 3.days.ago
+ create :post, :owner => @both_user, :created_at => 10.days.ago
+ create :post, :owner => @both_user, :created_at => 3.days.ago
end
it "should set the correct options for a recent methods for one association" do
View
12 spec/boolean_spec.rb
@@ -3,11 +3,11 @@
describe 'Boolean' do
before do
- @one = Factory :user, :admin => true
- @two = Factory :user, :admin => true
- @three = Factory :user, :admin => true
- @four = Factory :user, :admin => false
- @five = Factory :user, :admin => false
+ @one = create :user, :admin => true
+ @two = create :user, :admin => true
+ @three = create :user, :admin => true
+ @four = create :user, :admin => false
+ @five = create :user, :admin => false
end
it "should set the correct expected values for a boolean column method" do
@@ -23,7 +23,7 @@
end
it "should return correct value for balance class method when true less than false" do
- 3.times { Factory :user, :admin => false }
+ 3.times { create :user, :admin => false }
User.admin_balance.should == -2
end
View
6 spec/datetime_spec.rb
@@ -4,13 +4,13 @@
before do
date = DateTime.parse '2000-01-01'
- @abe = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
+ @abe = create :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
date = DateTime.parse '2005-05-05'
- @bob = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
+ @bob = create :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
date = DateTime.parse '2010-10-10'
- @fox = Factory :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
+ @fox = create :user, :created_at => date, :rejected_at => date, :updated_at => date, :last_posted_on => date, :approved_at => date
end
[:created_at, :rejected_at, :updated_at, :last_posted_on, :approved_at].each do |column|
View
4 spec/duration_spec.rb
@@ -3,8 +3,8 @@
describe 'Duration' do
before do
- @same_user = Factory :user, :created_at => 15.days.ago.midnight, :updated_at => 15.days.ago.midnight
- @updated_user = Factory :user, :created_at => 15.days.ago.midnight, :updated_at => 1.days.ago.midnight
+ @same_user = create :user, :created_at => 15.days.ago.midnight, :updated_at => 15.days.ago.midnight
+ @updated_user = create :user, :created_at => 15.days.ago.midnight, :updated_at => 1.days.ago.midnight
end
it "should set the correct expected values for a with_duration_of datetime column method" do
View
4 spec/factories.rb
@@ -19,8 +19,8 @@
end
factory :user do
- age { Factory.next :age }
- rating { Factory.next :rating }
+ age
+ rating
end
end
View
2 spec/limit_spec.rb
@@ -3,7 +3,7 @@
describe 'Limit' do
before do
- 50.times { Factory :user }
+ 50.times { create :user }
end
it "should set the correct expected values for a by_ column method" do
View
6 spec/numeric_spec.rb
@@ -3,9 +3,9 @@
describe 'Numeric' do
before do
- @young = Factory :user, :age => 11, :rating => 10.0
- @legal = Factory :user, :age => 21, :rating => 7.5
- @older = Factory :user, :age => 31, :rating => 5.0
+ @young = create :user, :age => 11, :rating => 10.0
+ @legal = create :user, :age => 21, :rating => 7.5
+ @older = create :user, :age => 31, :rating => 5.0
end
it "should set the correct expected values for a _greater_than column method for an integer column" do
View
4 spec/order_spec.rb
@@ -3,8 +3,8 @@
describe 'Order' do
before do
- @first = Factory :user, :first_name => 'Abe'
- @last = Factory :user, :first_name => 'Zed'
+ @first = create :user, :first_name => 'Abe'
+ @last = create :user, :first_name => 'Zed'
end
it "should set the correct expected values for a by_ column method with no args" do
View
4 spec/polymorph_spec.rb
@@ -3,8 +3,8 @@
describe 'Polymorph' do
before do
- @owned_by_user = Factory :post, :owner_type => 'User'
- @owned_by_mammal = Factory :post, :owner_type => 'Mammal'
+ @owned_by_user = create :post, :owner_type => 'User'
+ @owned_by_mammal = create :post, :owner_type => 'Mammal'
end
it "should set the correct expected values on a _for column method with Class" do
View
4 spec/presence_spec.rb
@@ -3,8 +3,8 @@
describe 'Presence' do
before do
- @not_null = Factory :user, :first_name => 'Fake'
- @null = Factory :user, :first_name => nil
+ @not_null = create :user, :first_name => 'Fake'
+ @null = create :user, :first_name => nil
end
it "should set the correct expected values for a _present column method" do
View
24 spec/ranking_spec.rb
@@ -3,11 +3,11 @@
describe 'Ranking', 'has ranking' do
before do
- @many = Factory :user
- 5.times { Factory :comment, :user => @many }
- @few = Factory :user
- 2.times { Factory :comment, :user => @few }
- @none = Factory :user
+ @many = create :user
+ 5.times { create :comment, :user => @many }
+ @few = create :user
+ 2.times { create :comment, :user => @few }
+ @none = create :user
end
it "should set the correct expected values on a maximum_ column method" do
@@ -28,13 +28,13 @@
describe 'Ranking', 'has calculated records' do
before do
- @user_one = Factory :user
- @user_two = Factory :user
- Factory :comment, :user => @user_one, :rating => 8
- Factory :comment, :user => @user_one, :rating => 6
- Factory :comment, :user => @user_two, :rating => 4
- Factory :comment, :user => @user_two, :rating => 3
- Factory :comment, :user => @user_two, :rating => 2
+ @user_one = create :user
+ @user_two = create :user
+ create :comment, :user => @user_one, :rating => 8
+ create :comment, :user => @user_one, :rating => 6
+ create :comment, :user => @user_two, :rating => 4
+ create :comment, :user => @user_two, :rating => 3
+ create :comment, :user => @user_two, :rating => 2
end
it "should order records based on association column highest average" do
output = User.by_comments_highest_rating_average
View
18 spec/search_spec.rb
@@ -3,15 +3,15 @@
describe 'Search' do
before do
- @abe = Factory :user, :first_name => 'Abe', :last_name => 'Anderson', :description => 'Apple'
- @bob = Factory :user, :first_name => 'Bob', :last_name => 'Babson', :description => 'Banana'
- @cindy = Factory :user, :first_name => 'Cindy', :last_name => 'Clarkson', :description => 'Cookie'
- @dave = Factory :user, :first_name => 'Dave'
- @ed = Factory :user, :last_name => 'Dave'
- @frank = Factory :user, :description => 'Dave'
- @george = Factory :user, :first_name => 'Dave', :last_name => 'Dave', :description => 'Dave'
-
- @null = Factory :user, :first_name => nil, :last_name => nil, :description => nil
+ @abe = create :user, :first_name => 'Abe', :last_name => 'Anderson', :description => 'Apple'
+ @bob = create :user, :first_name => 'Bob', :last_name => 'Babson', :description => 'Banana'
+ @cindy = create :user, :first_name => 'Cindy', :last_name => 'Clarkson', :description => 'Cookie'
+ @dave = create :user, :first_name => 'Dave'
+ @ed = create :user, :last_name => 'Dave'
+ @frank = create :user, :description => 'Dave'
+ @george = create :user, :first_name => 'Dave', :last_name => 'Dave', :description => 'Dave'
+
+ @null = create :user, :first_name => nil, :last_name => nil, :description => nil
end
it "should set the correct expected values for a _equals column method" do
View
8 spec/spec_helper.rb
@@ -22,6 +22,9 @@
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
+require 'factory_girl'
+require 'factories'
+
RSpec.configure do |config|
# Remove this line if you don't want RSpec's should and should_not
# methods or matchers
@@ -32,7 +35,6 @@
config.mock_with :mocha
config.use_transactional_fixtures = true
-end
-require 'factory_girl'
-require 'factories'
+ config.include FactoryGirl::Syntax::Methods
+end
View
8 spec/state_spec.rb
@@ -3,10 +3,10 @@
describe 'State' do
before do
- @draft_post = Factory :post, :publication_state => 'Draft'
- @final_post = Factory :post, :publication_state => 'Final'
- @free_post = Factory :post, :post_type => 'Free'
- @open_post = Factory :post, :post_type => 'Open'
+ @draft_post = create :post, :publication_state => 'Draft'
+ @final_post = create :post, :publication_state => 'Final'
+ @free_post = create :post, :post_type => 'Free'
+ @open_post = create :post, :post_type => 'Open'
@post = Post.new
Post::PUBLICATION_STATES.should_not be_nil

0 comments on commit a619187

Please sign in to comment.