Skip to content

Commit

Permalink
Converted stub! to stub.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveyken committed Aug 13, 2013
1 parent 19c9801 commit da75a34
Show file tree
Hide file tree
Showing 27 changed files with 140 additions and 135 deletions.
35 changes: 20 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ GEM
debugger-ruby_core_source (~> 1.2.0)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.2.0)
diff-lcs (1.2.1)
diff-lcs (1.2.4)
dynamic_form (1.1.4)
email_reply_parser_ffcrm (0.5.0)
erubis (2.7.0)
Expand All @@ -117,7 +117,7 @@ GEM
thor (>= 0.14.6)
guard-rails (0.4.2)
guard (>= 0.2.2)
guard-rspec (2.5.3)
guard-rspec (2.5.4)
guard (>= 1.1)
rspec (~> 2.11)
haml (3.1.7)
Expand All @@ -133,14 +133,17 @@ GEM
json (1.8.0)
kgio (2.7.4)
libv8 (3.3.10.4)
listen (0.7.3)
listen (1.2.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.7.1)
mime-types (1.23)
multi_json (1.7.7)
multi_json (1.7.9)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
Expand Down Expand Up @@ -221,26 +224,28 @@ GEM
rb-fsevent (0.9.3)
rb-inotify (0.9.0)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
responds_to_parent (1.1.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.4)
rspec-expectations (2.14.1)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.0)
rspec-rails (2.13.0)
rspec-mocks (2.14.3)
rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rubyzip (0.9.9)
sass (3.2.1)
sass-rails (3.2.5)
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/admin/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

it "assigns a newly created user as @user and renders [create] template" do
@user = FactoryGirl.build(:user, :username => @username, :email => @email)
User.stub!(:new).and_return(@user)
User.stub(:new).and_return(@user)

xhr :post, :create, :user => { :username => @username, :email => @email, :password => @password, :password_confirmation => @password }
assigns[:user].should == @user
Expand All @@ -140,7 +140,7 @@
describe "with invalid params" do
it "assigns a newly created but unsaved user as @user and re-renders [create] template" do
@user = FactoryGirl.build(:user, :username => "", :email => "")
User.stub!(:new).and_return(@user)
User.stub(:new).and_return(@user)

xhr :post, :create, :user => {}
assigns[:user].should == @user
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/applications_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end

it "should return [6, 9] when related is 'campaigns/7'" do
controller.stub!(:controller_name).and_return('opportunities')
controller.stub(:controller_name).and_return('opportunities')
campaign = mock(Campaign, :opportunities => [mock(:id => 6), mock(:id => 9)])
Campaign.should_receive(:find_by_id).with('7').and_return(campaign)
controller.send(:auto_complete_ids_to_exclude, 'campaigns/7').sort.should == [6, 9]
Expand All @@ -34,7 +34,7 @@
end

it "should return [] when related object association is not found" do
controller.stub!(:controller_name).and_return('not_a_method_that_exists')
controller.stub(:controller_name).and_return('not_a_method_that_exists')
campaign = mock(Campaign)
Campaign.should_receive(:find_by_id).with('7').and_return(campaign)
controller.send(:auto_complete_ids_to_exclude, 'campaigns/7').should == []
Expand Down
28 changes: 14 additions & 14 deletions spec/controllers/authentications_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
describe "user must not be logged in" do
before(:each) do
@user = FactoryGirl.create(:user, :username => "user", :password => "pass", :password_confirmation => "pass")
@controller.stub!(:current_user).and_return(@user)
@controller.stub(:current_user).and_return(@user)
end

describe "GET authentication (login form)" do
Expand Down Expand Up @@ -68,13 +68,13 @@

describe "successful authentication " do
before(:each) do
@authentication.stub!(:save).and_return(true)
Authentication.stub!(:new).and_return(@authentication)
@authentication.stub(:save).and_return(true)
Authentication.stub(:new).and_return(@authentication)
end

it "displays welcome message and redirects to the home page" do
@user = FactoryGirl.create(:user, :username => "user", :password => "pass", :password_confirmation => "pass", :login_count => 0)
@authentication.stub!(:user).and_return(@user)
@authentication.stub(:user).and_return(@user)

post :create, :authentication => @login
flash[:notice].should_not == nil
Expand All @@ -84,7 +84,7 @@

it "displays last login time if it's not the first login" do
@user = FactoryGirl.create(:user, :username => "user", :password => "pass", :password_confirmation => "pass", :login_count => 42)
@authentication.stub!(:user).and_return(@user)
@authentication.stub(:user).and_return(@user)

post :create, :authentication => @login
flash[:notice].should =~ /last login/
Expand All @@ -96,9 +96,9 @@
describe "user is not suspended" do
it "redirects to login page if username or password are invalid" do
@user = FactoryGirl.create(:user, :username => "user", :password => "pass", :password_confirmation => "pass")
@authentication.stub!(:user).and_return(@user)
@authentication.stub!(:save).and_return(false) # <--- Authentication failure.
Authentication.stub!(:new).and_return(@authentication)
@authentication.stub(:user).and_return(@user)
@authentication.stub(:save).and_return(false) # <--- Authentication failure.
Authentication.stub(:new).and_return(@authentication)

post :create, :authentication => @login
flash[:warning].should_not == nil
Expand All @@ -108,14 +108,14 @@

describe "user has been suspended" do
before(:each) do
@authentication.stub!(:save).and_return(true)
Authentication.stub!(:new).and_return(@authentication)
@authentication.stub(:save).and_return(true)
Authentication.stub(:new).and_return(@authentication)
end

# This tests :before_save update_info callback in Authentication model.
it "keeps user login attributes intact" do
@user = FactoryGirl.create(:user, :username => "user", :password => "pass", :password_confirmation => "pass", :suspended_at => Date.yesterday, :login_count => 0, :last_login_at => nil, :last_login_ip => nil)
@authentication.stub!(:user).and_return(@user)
@authentication.stub(:user).and_return(@user)

post :create, :authentication => @login
@authentication.user.login_count.should == 0
Expand All @@ -125,7 +125,7 @@

it "redirects to login page if user is suspended" do
@user = FactoryGirl.create(:user, :username => "user", :password => "pass", :password_confirmation => "pass", :suspended_at => Date.yesterday)
@authentication.stub!(:user).and_return(@user)
@authentication.stub(:user).and_return(@user)

post :create, :authentication => @login
flash[:warning].should_not == nil # Invalid username/password.
Expand All @@ -134,9 +134,9 @@
end

it "redirects to login page with the message if signup needs approval and user hasn't been activated yet" do
Setting.stub!(:user_signup).and_return(:needs_approval)
Setting.stub(:user_signup).and_return(:needs_approval)
@user = FactoryGirl.create(:user, :username => "user", :password => "pass", :password_confirmation => "pass", :suspended_at => Date.yesterday, :login_count => 0)
@authentication.stub!(:user).and_return(@user)
@authentication.stub(:user).and_return(@user)

post :create, :authentication => @login
flash[:warning].should == nil # Invalid username/password.
Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
it "should expose the requested comment as @commment and render [edit] template" do
@asset = FactoryGirl.create(asset)
@comment = FactoryGirl.create(:comment, :id => 42, :commentable => @asset, :user => current_user)
Comment.stub!(:new).and_return(@comment)
Comment.stub(:new).and_return(@comment)

xhr :get, :edit, :id => 42
assigns[:comment].should == @comment
Expand All @@ -104,7 +104,7 @@
it "should expose a newly created comment as @comment for the #{asset}" do
@asset = FactoryGirl.create(asset)
@comment = FactoryGirl.build(:comment, :commentable => @asset, :user => current_user)
Comment.stub!(:new).and_return(@comment)
Comment.stub(:new).and_return(@comment)

xhr :post, :create, :comment => { :commentable_type => asset.to_s.classify, :commentable_id => @asset.id, :user_id => current_user.id, :comment => "Hello" }
assigns[:comment].should == @comment
Expand All @@ -118,7 +118,7 @@
it "should expose a newly created but unsaved comment as @comment for #{asset}" do
@asset = FactoryGirl.create(asset)
@comment = FactoryGirl.build(:comment, :commentable => @asset, :user => current_user)
Comment.stub!(:new).and_return(@comment)
Comment.stub(:new).and_return(@comment)

xhr :post, :create, :comment => {}
assigns[:comment].should == @comment
Expand All @@ -142,13 +142,13 @@
# end
#
# it "should expose the requested comment as @comment" do
# Comment.stub!(:find).and_return(mock_comment(:update_attributes => true))
# Comment.stub(:find).and_return(mock_comment(:update_attributes => true))
# put :update, :id => "1"
# assigns(:comment).should equal(mock_comment)
# end
#
# it "should redirect to the comment" do
# Comment.stub!(:find).and_return(mock_comment(:update_attributes => true))
# Comment.stub(:find).and_return(mock_comment(:update_attributes => true))
# put :update, :id => "1"
# response.should redirect_to(comment_path(mock_comment))
# end
Expand All @@ -162,13 +162,13 @@
# end
#
# it "should expose the comment as @comment" do
# Comment.stub!(:find).and_return(mock_comment(:update_attributes => false))
# Comment.stub(:find).and_return(mock_comment(:update_attributes => false))
# put :update, :id => "1"
# assigns(:comment).should equal(mock_comment)
# end
#
# it "should re-render the 'edit' template" do
# Comment.stub!(:find).and_return(mock_comment(:update_attributes => false))
# Comment.stub(:find).and_return(mock_comment(:update_attributes => false))
# put :update, :id => "1"
# response.should render_template('edit')
# end
Expand All @@ -186,7 +186,7 @@
it "should destroy the requested comment and render [destroy] template" do
@asset = FactoryGirl.create(asset)
@comment = FactoryGirl.create(:comment, :commentable => @asset, :user => current_user)
Comment.stub!(:new).and_return(@comment)
Comment.stub(:new).and_return(@comment)

xhr :delete, :destroy, :id => @comment.id
lambda { Comment.find(@comment) }.should raise_error(ActiveRecord::RecordNotFound)
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/emails_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
it "should destroy the requested email and render [destroy] template" do
@asset = FactoryGirl.create(asset)
@email = FactoryGirl.create(:email, :mediator => @asset, :user => current_user)
Email.stub!(:new).and_return(@email)
Email.stub(:new).and_return(@email)

xhr :delete, :destroy, :id => @email.id
lambda { Email.find(@email) }.should raise_error(ActiveRecord::RecordNotFound)
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/entities/accounts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def get_data_for_sidebar

it "should expose a newly created account as @account and render [create] template" do
@account = FactoryGirl.build(:account, :name => "Hello world", :user => current_user)
Account.stub!(:new).and_return(@account)
Account.stub(:new).and_return(@account)

xhr :post, :create, :account => { :name => "Hello world" }
assigns(:account).should == @account
Expand All @@ -314,23 +314,23 @@ def get_data_for_sidebar
# Note: [Create Account] is shown only on Accounts index page.
it "should reload accounts to update pagination" do
@account = FactoryGirl.build(:account, :user => current_user)
Account.stub!(:new).and_return(@account)
Account.stub(:new).and_return(@account)

xhr :post, :create, :account => { :name => "Hello" }
assigns[:accounts].should == [ @account ]
end

it "should get data to update account sidebar" do
@account = FactoryGirl.build(:account, :name => "Hello", :user => current_user)
Campaign.stub!(:new).and_return(@account)
Campaign.stub(:new).and_return(@account)

xhr :post, :create, :account => { :name => "Hello" }
assigns[:account_category_total].should be_instance_of(HashWithIndifferentAccess)
end

it "should add a new comment to the newly created account when specified" do
@account = FactoryGirl.build(:account, :name => "Hello world", :user => current_user)
Account.stub!(:new).and_return(@account)
Account.stub(:new).and_return(@account)

xhr :post, :create, :account => { :name => "Hello world" }, :comment_body => "Awesome comment is awesome"
assigns[:account].comments.map(&:comment).should include("Awesome comment is awesome")
Expand All @@ -340,7 +340,7 @@ def get_data_for_sidebar
describe "with invalid params" do
it "should expose a newly created but unsaved account as @account and still render [create] template" do
@account = FactoryGirl.build(:account, :name => nil, :user => nil)
Account.stub!(:new).and_return(@account)
Account.stub(:new).and_return(@account)

xhr :post, :create, :account => {}
assigns(:account).should == @account
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/entities/campaigns_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def get_data_for_sidebar

it "should expose a newly created campaign as @campaign and render [create] template" do
@campaign = FactoryGirl.build(:campaign, :name => "Hello", :user => current_user)
Campaign.stub!(:new).and_return(@campaign)
Campaign.stub(:new).and_return(@campaign)

xhr :post, :create, :campaign => { :name => "Hello" }
assigns(:campaign).should == @campaign
Expand All @@ -315,23 +315,23 @@ def get_data_for_sidebar

it "should get data to update campaign sidebar" do
@campaign = FactoryGirl.build(:campaign, :name => "Hello", :user => current_user)
Campaign.stub!(:new).and_return(@campaign)
Campaign.stub(:new).and_return(@campaign)

xhr :post, :create, :campaign => { :name => "Hello" }
assigns[:campaign_status_total].should be_instance_of(HashWithIndifferentAccess)
end

it "should reload campaigns to update pagination" do
@campaign = FactoryGirl.build(:campaign, :user => current_user)
Campaign.stub!(:new).and_return(@campaign)
Campaign.stub(:new).and_return(@campaign)

xhr :post, :create, :campaign => { :name => "Hello" }
assigns[:campaigns].should == [ @campaign ]
end

it "should add a new comment to the newly created campaign when specified" do
@campaign = FactoryGirl.build(:campaign, :name => "Hello world", :user => current_user)
Campaign.stub!(:new).and_return(@campaign)
Campaign.stub(:new).and_return(@campaign)

xhr :post, :create, :campaign => { :name => "Hello world" }, :comment_body => "Awesome comment is awesome"
@campaign.reload.comments.map(&:comment).should include("Awesome comment is awesome")
Expand All @@ -342,7 +342,7 @@ def get_data_for_sidebar

it "should expose a newly created but unsaved campaign as @campaign and still render [create] template" do
@campaign = FactoryGirl.build(:campaign, :id => nil, :name => nil, :user => current_user)
Campaign.stub!(:new).and_return(@campaign)
Campaign.stub(:new).and_return(@campaign)

xhr :post, :create, :campaign => nil
assigns(:campaign).should == @campaign
Expand Down
Loading

0 comments on commit da75a34

Please sign in to comment.