rspec 3-ify spec_helper

refs CNVS-16239

Change-Id: I60538bd7bc190ae32c527500d85ecdd5360f35f4
Reviewed-on: https://gerrit.instructure.com/42869
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <braden@instructure.com>
Product-Review: Braden Anderson <braden@instructure.com>
QA-Review: Braden Anderson <braden@instructure.com>
This commit is contained in:
Cody Cutrer 2014-10-16 13:02:40 -06:00
parent 997f4d4280
commit 0651f7e4e4
2 changed files with 22 additions and 23 deletions

View File

@ -23,9 +23,10 @@ class ProtectAttributes
@target = target
!(@target.accessible_attributes.nil? && @target.protected_attributes.nil?)
end
def failure_message_for_should
def failure_message
"expected #{@target} to protect attributes"
end
# alias_method :failure_message_for_should, :failure_message
end
def protect_attributes

View File

@ -130,11 +130,11 @@ module RSpec::Rails
end
end
def failure_message_for_should
def failure_message
@msg
end
def failure_message_for_should_not
def failure_message_when_negated
@msg
end
end
@ -700,7 +700,7 @@ RSpec.configure do |config|
course = opts[:course] || @course || course(opts)
@fake_student = course.student_view_student
post "/users/#{@fake_student.id}/masquerade"
session[:become_user_id].should == @fake_student.id.to_s
expect(session[:become_user_id]).to eq @fake_student.id.to_s
end
def account_notification(opts={})
@ -795,7 +795,7 @@ RSpec.configure do |config|
"pseudonym_session[unique_id]" => username,
"pseudonym_session[password]" => password
assert_response :success
request.fullpath.should eql("/?login_success=1")
expect(request.fullpath).to eq "/?login_success=1"
end
def assignment_quiz(questions, opts={})
@ -983,13 +983,12 @@ RSpec.configure do |config|
end
def assert_status(status=500)
response.status.to_i.should eql(status)
expect(response.status.to_i).to eq status
end
def assert_unauthorized
assert_status(401) #unauthorized
# response.headers['Status'].should eql('401 Unauthorized')
response.should render_template("shared/unauthorized")
expect(response).to render_template("shared/unauthorized")
end
def assert_page_not_found(&block)
@ -998,8 +997,8 @@ RSpec.configure do |config|
end
def assert_require_login
response.should be_redirect
flash[:warning].should eql("You must be logged in to access this page")
expect(response).to be_redirect
expect(flash[:warning]).to eq "You must be logged in to access this page"
end
def fixture_file_upload(path, mime_type=nil, binary=false)
@ -1050,8 +1049,8 @@ RSpec.configure do |config|
def process_csv_data_cleanly(*lines_or_opts)
importer = process_csv_data(*lines_or_opts)
importer.errors.should == []
importer.warnings.should == []
expect(importer.errors).to eq []
expect(importer.warnings).to eq []
end
def enable_cache(new_cache=:memory_store)
@ -1203,8 +1202,8 @@ RSpec.configure do |config|
pending "Please put valid S3 credentials in config/amazon_s3.yml"
end
end
Attachment.s3_storage?.should eql(true)
Attachment.local_storage?.should eql(false)
expect(Attachment.s3_storage?).to be true
expect(Attachment.local_storage?).to be false
end
def local_storage!
@ -1216,9 +1215,8 @@ RSpec.configure do |config|
model.stubs(:local_storage?).returns(true)
end
Attachment.local_storage?.should eql(true)
Attachment.s3_storage?.should eql(false)
Attachment.local_storage?.should eql(true)
expect(Attachment.local_storage?).to be true
expect(Attachment.s3_storage?).to be false
end
def run_job(job)
@ -1247,7 +1245,7 @@ RSpec.configure do |config|
track_jobs do
yield
end
created_jobs.count { |j| j.tag == tag }.should == count
expect(created_jobs.count { |j| j.tag == tag }).to eq count
end
# send a multipart post request in an integration spec post_params is
@ -1287,16 +1285,16 @@ RSpec.configure do |config|
def verify_post_matches(post_lines, expected_post_lines)
# first lines should match
post_lines[0].should == expected_post_lines[0]
expect(post_lines[0]).to eq expected_post_lines[0]
# now extract the headers
post_headers = post_lines[1..post_lines.index("")]
expected_post_headers = expected_post_lines[1..expected_post_lines.index("")]
expected_post_headers << "User-Agent: Ruby"
post_headers.sort.should == expected_post_headers.sort
expect(post_headers.sort).to eq expected_post_headers.sort
# now check payload
post_lines[post_lines.index(""), -1].should ==
expect(post_lines[post_lines.index(""), -1]).to eq
expected_post_lines[expected_post_lines.index(""), -1]
end
@ -1312,9 +1310,9 @@ RSpec.configure do |config|
end
else
if actual.is_a?(Fixnum) || actual.is_a?(Float)
actual.should == expected
expect(actual).to eq expected
else
actual.to_json.should == expected.to_json
expect(actual.to_json).to eq expected.to_json
end
end
end