Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update factory girl syntax style to avoid deprecation warnings

  • Loading branch information...
commit 842f4a33a9ab5d6f0db06522ebeb7988d349eb06 1 parent 9c503b6
@mjankowski mjankowski authored
View
2  Gemfile
@@ -2,7 +2,7 @@ source "http://rubygems.org"
gemspec
gem "capybara", "~> 1.1.1"
-gem "factory_girl_rails"
+gem "factory_girl_rails", "1.7.0"
gem "shoulda-matchers", :git => "git://github.com/thoughtbot/shoulda-matchers.git"
gem "database_cleaner"
gem "launchy"
View
10 Gemfile.lock
@@ -81,10 +81,10 @@ GEM
railties
diff-lcs (1.1.3)
erubis (2.7.0)
- factory_girl (2.5.0)
- activesupport
- factory_girl_rails (1.6.0)
- factory_girl (~> 2.5.0)
+ factory_girl (2.6.4)
+ activesupport (>= 2.3.9)
+ factory_girl_rails (1.7.0)
+ factory_girl (~> 2.6.0)
railties (>= 3.0.0)
ffi (1.0.11)
gherkin (2.7.6)
@@ -178,7 +178,7 @@ DEPENDENCIES
clearance!
cucumber-rails (~> 1.1.1)
database_cleaner
- factory_girl_rails
+ factory_girl_rails (= 1.7.0)
launchy
rspec-rails (~> 2.9.0)
shoulda-matchers!
View
4 features/step_definitions/engine/clearance_steps.rb
@@ -1,11 +1,11 @@
# Existing users
Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)"$/ do |email|
- Factory(:user, :email => email)
+ FactoryGirl.create(:user, :email => email)
end
Given /^a user "([^"]*)" exists without a salt, remember token, or password$/ do |email|
- user = Factory(:user, :email => email)
+ user = FactoryGirl.create(:user, :email => email)
sql = "update users set salt = NULL, encrypted_password = NULL, remember_token = NULL where id = #{user.id}"
ActiveRecord::Base.connection.update(sql)
end
View
6 gemfiles/3.0.12.gemfile
@@ -2,12 +2,12 @@
source "http://rubygems.org"
+gem "rails", "3.0.12"
gem "capybara", "~> 1.1.1"
-gem "factory_girl_rails"
gem "shoulda-matchers", :git=>"git://github.com/thoughtbot/shoulda-matchers.git"
gem "database_cleaner"
-gem "launchy"
gem "aruba", "~> 0.4.2"
-gem "rails", "3.0.12"
+gem "factory_girl_rails", "1.7.0"
+gem "launchy"
gemspec :path=>"../"
View
10 gemfiles/3.0.12.gemfile.lock
@@ -79,10 +79,10 @@ GEM
diff-lcs (1.1.3)
erubis (2.6.6)
abstract (>= 1.0.0)
- factory_girl (3.0.0)
- activesupport (>= 3.0.0)
- factory_girl_rails (3.0.0)
- factory_girl (~> 3.0.0)
+ factory_girl (2.6.4)
+ activesupport (>= 2.3.9)
+ factory_girl_rails (1.7.0)
+ factory_girl (~> 2.6.0)
railties (>= 3.0.0)
ffi (1.0.11)
gherkin (2.9.3)
@@ -167,7 +167,7 @@ DEPENDENCIES
clearance!
cucumber-rails (~> 1.1.1)
database_cleaner
- factory_girl_rails
+ factory_girl_rails (= 1.7.0)
launchy
rails (= 3.0.12)
rspec-rails (~> 2.9.0)
View
6 gemfiles/3.1.4.gemfile
@@ -2,12 +2,12 @@
source "http://rubygems.org"
+gem "rails", "3.1.4"
gem "capybara", "~> 1.1.1"
-gem "factory_girl_rails"
gem "shoulda-matchers", :git=>"git://github.com/thoughtbot/shoulda-matchers.git"
gem "database_cleaner"
-gem "launchy"
gem "aruba", "~> 0.4.2"
-gem "rails", "3.1.4"
+gem "factory_girl_rails", "1.7.0"
+gem "launchy"
gemspec :path=>"../"
View
10 gemfiles/3.1.4.gemfile.lock
@@ -79,10 +79,10 @@ GEM
railties
diff-lcs (1.1.3)
erubis (2.7.0)
- factory_girl (3.0.0)
- activesupport (>= 3.0.0)
- factory_girl_rails (3.0.0)
- factory_girl (~> 3.0.0)
+ factory_girl (2.6.4)
+ activesupport (>= 2.3.9)
+ factory_girl_rails (1.7.0)
+ factory_girl (~> 2.6.0)
railties (>= 3.0.0)
ffi (1.0.11)
gherkin (2.9.3)
@@ -177,7 +177,7 @@ DEPENDENCIES
clearance!
cucumber-rails (~> 1.1.1)
database_cleaner
- factory_girl_rails
+ factory_girl_rails (= 1.7.0)
launchy
rails (= 3.1.4)
rspec-rails (~> 2.9.0)
View
2  lib/clearance/testing/helpers.rb
@@ -7,7 +7,7 @@ def sign_in_as(user)
end
def sign_in
- sign_in_as Factory(:user)
+ sign_in_as FactoryGirl.create(:user)
end
def sign_out
View
12 spec/clearance/session_spec.rb
@@ -5,7 +5,7 @@
after { Timecop.return }
it "finds a user from a cookie" do
- user = Factory(:user)
+ user = create(:user)
env = env_with_remember_token(user.remember_token)
session = Clearance::Session.new(env)
@@ -14,7 +14,7 @@
end
it "returns nil for an unknown user" do
- user = Factory(:user)
+ user = create(:user)
env = env_with_remember_token("bogus")
session = Clearance::Session.new(env)
@@ -30,14 +30,14 @@
end
it "signs in a given user" do
- user = Factory(:user)
+ user = create(:user)
session = Clearance::Session.new(env_without_remember_token)
session.sign_in user
session.current_user.should == user
end
it "sets a remember token cookie with a default expiration of 1 year from now" do
- user = Factory(:user)
+ user = create(:user)
headers = {}
session = Clearance::Session.new(env_without_remember_token)
session.sign_in user
@@ -48,7 +48,7 @@
it "sets a remember token cookie with a custom expiration" do
custom_expiration = 1.day.from_now
with_custom_expiration 1.day.from_now do
- user = Factory(:user)
+ user = create(:user)
headers = {}
session = Clearance::Session.new(env_without_remember_token)
session.sign_in user
@@ -66,7 +66,7 @@
end
it "signs out a user" do
- user = Factory(:user)
+ user = create(:user)
old_remember_token = user.remember_token
env = env_with_remember_token(old_remember_token)
View
2  spec/controllers/forgeries_controller_spec.rb
@@ -21,7 +21,7 @@ def create
match 'sign_in' => 'clearance/sessions#new', :as => 'sign_in'
end
- @user = Factory(:user)
+ @user = create(:user)
@user.update_attribute(:remember_token, "old-token")
@request.cookies["remember_token"] = "old-token"
@request.session[:_csrf_token] = "golden-ticket"
View
8 spec/controllers/passwords_controller_spec.rb
@@ -8,7 +8,7 @@
describe "a signed up user" do
before do
- @user = Factory(:user)
+ @user = create(:user)
end
describe "on GET to #new" do
@@ -60,7 +60,7 @@
describe "a signed up user and forgotten password" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@user.forgot_password!
end
@@ -157,8 +157,8 @@
describe "given two users and user one signs in" do
before do
- @user_one = Factory(:user)
- @user_two = Factory(:user)
+ @user_one = create(:user)
+ @user_two = create(:user)
sign_in_as @user_one
end
end
View
10 spec/controllers/sessions_controller_spec.rb
@@ -11,7 +11,7 @@
describe "on POST to #create with good credentials" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@user.update_attribute(:remember_token, "old-token")
post :create, :session => {
:email => @user.email,
@@ -31,7 +31,7 @@
describe "on POST to #create with good credentials and a session return url" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@return_url = '/url_in_the_session'
@request.session[:return_to] = @return_url
post :create, :session => {
@@ -46,7 +46,7 @@
describe "on POST to #create with good credentials and a request return url" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@return_url = '/url_in_the_request'
post :create, :session => {
:email => @user.email,
@@ -61,7 +61,7 @@
describe "on POST to #create with good credentials and a session return url and request return url" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@return_url = '/url_in_the_session'
@request.session[:return_to] = @return_url
post :create, :session => {
@@ -85,7 +85,7 @@
describe "on DELETE to #destroy with a cookie" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@user.update_attribute(:remember_token, "old-token")
@request.cookies["remember_token"] = "old-token"
delete :destroy
View
6 spec/controllers/users_controller_spec.rb
@@ -25,7 +25,7 @@
describe "on POST to #create with valid attributes" do
before do
- user_attributes = Factory.attributes_for(:user)
+ user_attributes = FactoryGirl.attributes_for(:user)
@old_user_count = User.count
post :create, :user => user_attributes
end
@@ -41,7 +41,7 @@
describe "on POST to #create with valid attributes and a session return url" do
before do
- user_attributes = Factory.attributes_for(:user)
+ user_attributes = FactoryGirl.attributes_for(:user)
@old_user_count = User.count
@return_url = '/url_in_the_session'
@request.session[:return_to] = @return_url
@@ -60,7 +60,7 @@
describe "A signed-in user" do
before do
- @user = Factory(:user)
+ @user = create(:user)
sign_in_as @user
end
View
2  spec/mailers/clearance_mailer_spec.rb
@@ -2,7 +2,7 @@
describe ClearanceMailer do
before do
- @user = Factory(:user)
+ @user = create(:user)
@user.forgot_password!
@email = ClearanceMailer.change_password(@user)
end
View
20 spec/models/user_spec.rb
@@ -16,19 +16,19 @@
it { should_not allow_value("example.com").for(:email) }
it "should store email in down case" do
- user = Factory(:user, :email => "John.Doe@example.com")
+ user = create(:user, :email => "John.Doe@example.com")
user.email.should == "john.doe@example.com"
end
end
describe "When multiple users have signed up" do
- before { Factory(:user) }
+ before { create(:user) }
it { should validate_uniqueness_of(:email) }
end
describe "A user" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@password = @user.password
end
@@ -50,7 +50,7 @@
describe "When resetting authentication with reset_remember_token!" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@user.remember_token = "old-token"
@user.reset_remember_token!
end
@@ -62,7 +62,7 @@
describe "An email confirmed user" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@old_encrypted_password = @user.encrypted_password
end
@@ -80,15 +80,15 @@
it "should not generate the same remember token for users with the same password at the same time" do
Time.stubs(:now => Time.now)
password = 'secret'
- first_user = Factory(:user, :password => password)
- second_user = Factory(:user, :password => password)
+ first_user = create(:user, :password => password)
+ second_user = create(:user, :password => password)
second_user.remember_token.should_not == first_user.remember_token
end
describe "An user" do
before do
- @user = Factory(:user)
+ @user = create(:user)
@old_encrypted_password = @user.encrypted_password
end
@@ -168,13 +168,13 @@ def password_optional?
describe "user factory" do
it "should create a valid user with just an overridden password" do
- Factory.build(:user, :password => "test").should be_valid
+ build(:user, :password => "test").should be_valid
end
end
describe "when user exists before Clearance was installed" do
before do
- @user = Factory(:user)
+ @user = create(:user)
sql = "update users set salt = NULL, encrypted_password = NULL, remember_token = NULL where id = #{@user.id}"
ActiveRecord::Base.connection.update(sql)
@user.reload.salt.should be_nil
View
1  spec/spec_helper.rb
@@ -20,4 +20,5 @@
RSpec.configure do |config|
config.mock_with :mocha
config.use_transactional_fixtures = true
+ config.include FactoryGirl::Syntax::Methods
end
Please sign in to comment.
Something went wrong with that request. Please try again.