Upgrade rspec to 3.4.0.

This commit is contained in:
Guo Xiang Tan 2016-05-30 11:38:04 +08:00
parent e11c83341c
commit cb5be1fe8f
No known key found for this signature in database
GPG Key ID: 19C321C8952B0F72
15 changed files with 40 additions and 44 deletions

View File

@ -125,7 +125,7 @@ group :test do
end end
group :test, :development do group :test, :development do
gem 'rspec', '~> 3.2.0' gem 'rspec'
gem 'mock_redis' gem 'mock_redis'
gem 'listen', '0.7.3', require: false gem 'listen', '0.7.3', require: false
gem 'certified', require: false gem 'certified', require: false

View File

@ -294,33 +294,33 @@ GEM
netrc (~> 0.7) netrc (~> 0.7)
rinku (2.0.0) rinku (2.0.0)
rmmseg-cpp (0.2.9) rmmseg-cpp (0.2.9)
rspec (3.2.0) rspec (3.4.0)
rspec-core (~> 3.2.0) rspec-core (~> 3.4.0)
rspec-expectations (~> 3.2.0) rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.2.0) rspec-mocks (~> 3.4.0)
rspec-core (3.2.3) rspec-core (3.4.4)
rspec-support (~> 3.2.0) rspec-support (~> 3.4.0)
rspec-expectations (3.2.1) rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0) rspec-support (~> 3.4.0)
rspec-given (3.7.1) rspec-given (3.7.1)
given_core (= 3.7.1) given_core (= 3.7.1)
rspec (>= 2.14.0) rspec (>= 2.14.0)
rspec-html-matchers (0.7.0) rspec-html-matchers (0.7.0)
nokogiri (~> 1) nokogiri (~> 1)
rspec (~> 3) rspec (~> 3)
rspec-mocks (3.2.1) rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0) rspec-support (~> 3.4.0)
rspec-rails (3.2.3) rspec-rails (3.4.2)
actionpack (>= 3.0, < 4.3) actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3) railties (>= 3.0, < 4.3)
rspec-core (~> 3.2.0) rspec-core (~> 3.4.0)
rspec-expectations (~> 3.2.0) rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.2.0) rspec-mocks (~> 3.4.0)
rspec-support (~> 3.2.0) rspec-support (~> 3.4.0)
rspec-support (3.2.2) rspec-support (3.4.1)
rtlit (0.0.5) rtlit (0.0.5)
ruby-openid (2.7.0) ruby-openid (2.7.0)
ruby-readability (0.7.0) ruby-readability (0.7.0)
@ -475,7 +475,7 @@ DEPENDENCIES
rest-client rest-client
rinku rinku
rmmseg-cpp rmmseg-cpp
rspec (~> 3.2.0) rspec
rspec-given rspec-given
rspec-html-matchers rspec-html-matchers
rspec-rails rspec-rails

View File

@ -613,7 +613,10 @@ class User < ActiveRecord::Base
# Use this helper to determine if the user has a particular trust level. # Use this helper to determine if the user has a particular trust level.
# Takes into account admin, etc. # Takes into account admin, etc.
def has_trust_level?(level) def has_trust_level?(level)
raise "Invalid trust level #{level}" unless TrustLevel.valid?(level) unless TrustLevel.valid?(level)
raise InvalidTrustLevel.new("Invalid trust level #{level}")
end
admin? || moderator? || staged? || TrustLevel.compare(trust_level, level) admin? || moderator? || staged? || TrustLevel.compare(trust_level, level)
end end
@ -907,7 +910,7 @@ class User < ActiveRecord::Base
end end
def hash_password(password, salt) def hash_password(password, salt)
raise "password is too long" if password.size > User.max_password_length raise StandardError.new("password is too long") if password.size > User.max_password_length
Pbkdf2.hash_password(password, salt, Rails.configuration.pbkdf2_iterations, Rails.configuration.pbkdf2_algorithm) Pbkdf2.hash_password(password, salt, Rails.configuration.pbkdf2_iterations, Rails.configuration.pbkdf2_algorithm)
end end

View File

@ -6,7 +6,7 @@ module Plugin
end end
def register(name, &blk) def register(name, &blk)
raise ArgumentException unless blk && blk.arity == 2 raise ArgumentError unless blk && blk.arity == 2
filters = @map[name] ||= [] filters = @map[name] ||= []
filters << blk filters << blk
end end

View File

@ -20,7 +20,7 @@ describe Plugin::FilterManager do
expect do expect do
instance.register(:test) do instance.register(:test) do
end end
end.to raise_exception end.to raise_error(ArgumentError)
end end
it "should return the original if no filters exist" do it "should return the original if no filters exist" do
@ -30,6 +30,6 @@ describe Plugin::FilterManager do
it "should raise an exception if no block is passed in" do it "should raise an exception if no block is passed in" do
expect do expect do
instance.register(:test) instance.register(:test)
end.to raise_exception end.to raise_error(ArgumentError)
end end
end end

View File

@ -416,7 +416,7 @@ describe TopicQuery do
TopicList.preloaded_custom_fields.clear TopicList.preloaded_custom_fields.clear
# if we attempt to access non preloaded fields explode # if we attempt to access non preloaded fields explode
expect{new_topic.custom_fields["boom"]}.to raise_error expect{new_topic.custom_fields["boom"]}.to raise_error(StandardError)
end end
end end

View File

@ -3,7 +3,7 @@ require 'rails_helper'
describe DirectoryItemsController do describe DirectoryItemsController do
it "requires a `period` param" do it "requires a `period` param" do
expect{ xhr :get, :index }.to raise_error expect{ xhr :get, :index }.to raise_error(ActionController::ParameterMissing)
end end
it "requires a proper `period` param" do it "requires a proper `period` param" do

View File

@ -7,13 +7,13 @@ describe Users::OmniauthCallbacksController do
SiteSetting.stubs("enable_twitter_logins?").returns(false) SiteSetting.stubs("enable_twitter_logins?").returns(false)
expect(lambda { expect(lambda {
Users::OmniauthCallbacksController.find_authenticator("twitter") Users::OmniauthCallbacksController.find_authenticator("twitter")
}).to raise_error }).to raise_error(Discourse::InvalidAccess)
end end
it "fails for unknown" do it "fails for unknown" do
expect(lambda { expect(lambda {
Users::OmniauthCallbacksController.find_authenticator("twitter1") Users::OmniauthCallbacksController.find_authenticator("twitter1")
}).to raise_error }).to raise_error(Discourse::InvalidAccess)
end end
it "finds an authenticator when enabled" do it "finds an authenticator when enabled" do

View File

@ -5,7 +5,7 @@ describe UserActionsController do
context 'index' do context 'index' do
it 'fails if username is not specified' do it 'fails if username is not specified' do
expect { xhr :get, :index }.to raise_error expect { xhr :get, :index }.to raise_error(ActionController::ParameterMissing)
end end
it 'renders list correctly' do it 'renders list correctly' do

View File

@ -24,7 +24,7 @@ describe UserBadgesController do
let!(:user_badge) { UserBadge.create(badge: badge, user: user, granted_by: Discourse.system_user, granted_at: Time.now) } let!(:user_badge) { UserBadge.create(badge: badge, user: user, granted_by: Discourse.system_user, granted_at: Time.now) }
it 'requires username or badge_id to be specified' do it 'requires username or badge_id to be specified' do
expect { xhr :get, :index }.to raise_error expect { xhr :get, :index }.to raise_error(ActionController::ParameterMissing)
end end
it 'returns user_badges for a user' do it 'returns user_badges for a user' do
@ -54,7 +54,7 @@ describe UserBadgesController do
context 'create' do context 'create' do
it 'requires username to be specified' do it 'requires username to be specified' do
expect { xhr :post, :create, badge_id: badge.id }.to raise_error expect { xhr :post, :create, badge_id: badge.id }.to raise_error(ActionController::ParameterMissing)
end end
it 'does not allow regular users to grant badges' do it 'does not allow regular users to grant badges' do

View File

@ -32,7 +32,7 @@ describe Jobs::Base do
Discourse.expects(:handle_job_exception).times(3) Discourse.expects(:handle_job_exception).times(3)
bad = BadJob.new bad = BadJob.new
expect{bad.perform({})}.to raise_error expect{bad.perform({})}.to raise_error(Jobs::HandledExceptionWrapper)
expect(bad.fail_count).to eq(3) expect(bad.fail_count).to eq(3)
end end

View File

@ -29,7 +29,7 @@ describe PostAction do
expect { expect {
PostAction.act(eviltrout, post, PostActionType.types[:like]) PostAction.act(eviltrout, post, PostActionType.types[:like])
}.to raise_error }.to raise_error(RateLimiter::LimitExceeded)
end end
end end

View File

@ -443,7 +443,7 @@ describe Topic do
expect { expect {
topic.invite(topic.user, "user@example.com") topic.invite(topic.user, "user@example.com")
}.to raise_exception }.to raise_error(RateLimiter::LimitExceeded)
end end
context 'bumping topics' do context 'bumping topics' do
@ -1483,7 +1483,7 @@ describe Topic do
freeze_time(start + 10.minutes) freeze_time(start + 10.minutes)
expect { expect {
create_post(user: user) create_post(user: user)
}.to raise_exception }.to raise_error(RateLimiter::LimitExceeded)
freeze_time(start + 20.minutes) freeze_time(start + 20.minutes)
create_post(user: user, topic_id: topic_id) create_post(user: user, topic_id: topic_id)
@ -1492,7 +1492,7 @@ describe Topic do
expect { expect {
create_post(user: user, topic_id: topic_id) create_post(user: user, topic_id: topic_id)
}.to raise_exception }.to raise_error(RateLimiter::LimitExceeded)
end end
describe ".count_exceeds_minimun?" do describe ".count_exceeds_minimun?" do

View File

@ -204,7 +204,7 @@ describe User do
describe 'has_trust_level?' do describe 'has_trust_level?' do
it "raises an error with an invalid level" do it "raises an error with an invalid level" do
expect { user.has_trust_level?(:wat) }.to raise_error expect { user.has_trust_level?(:wat) }.to raise_error(InvalidTrustLevel)
end end
it "is true for your basic level" do it "is true for your basic level" do
@ -1106,7 +1106,7 @@ describe User do
end end
it "raises an error when passwords are too long" do it "raises an error when passwords are too long" do
expect { hash(too_long, 'gravy') }.to raise_error expect { hash(too_long, 'gravy') }.to raise_error(StandardError)
end end
end end

View File

@ -78,13 +78,6 @@ Spork.prefork do
SiteSetting.defaults[k] = v SiteSetting.defaults[k] = v
end end
# Monkey patch for NoMethodError: undefined method `cache' for nil:NilClass
# https://github.com/rspec/rspec-rails/issues/1532#issuecomment-174679485
# fixed in Rspec 3.4.1
RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator.class_eval do
alias_method :find_all_anywhere, :find_all
end
require_dependency 'site_settings/local_process_provider' require_dependency 'site_settings/local_process_provider'
SiteSetting.provider = SiteSettings::LocalProcessProvider.new SiteSetting.provider = SiteSettings::LocalProcessProvider.new
end end