mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
few components with rspec3 syntax
This commit is contained in:
@@ -4,7 +4,7 @@ require_dependency "common_passwords/common_passwords"
|
||||
describe CommonPasswords do
|
||||
|
||||
it "the passwords file should exist" do
|
||||
File.exists?(described_class::PASSWORD_FILE).should eq(true)
|
||||
expect(File.exists?(described_class::PASSWORD_FILE)).to eq(true)
|
||||
end
|
||||
|
||||
describe "#common_password?" do
|
||||
@@ -15,25 +15,25 @@ describe CommonPasswords do
|
||||
it "returns false if password isn't in the common passwords list" do
|
||||
described_class.stubs(:password_list).returns(stub_everything(:include? => false))
|
||||
@password = 'uncommonPassword'
|
||||
subject.should eq(false)
|
||||
expect(subject).to eq(false)
|
||||
end
|
||||
|
||||
it "returns false if password is nil" do
|
||||
described_class.expects(:password_list).never
|
||||
@password = nil
|
||||
subject.should eq(false)
|
||||
expect(subject).to eq(false)
|
||||
end
|
||||
|
||||
it "returns false if password is blank" do
|
||||
described_class.expects(:password_list).never
|
||||
@password = ""
|
||||
subject.should eq(false)
|
||||
expect(subject).to eq(false)
|
||||
end
|
||||
|
||||
it "returns true if password is in the common passwords list" do
|
||||
described_class.stubs(:password_list).returns(stub_everything(:include? => true))
|
||||
@password = "password"
|
||||
subject.should eq(true)
|
||||
expect(subject).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +45,7 @@ describe CommonPasswords do
|
||||
described_class.stubs(:redis).returns(mock_redis)
|
||||
described_class.expects(:load_passwords).returns(['password'])
|
||||
list = described_class.password_list
|
||||
list.should respond_to(:include?)
|
||||
expect(list).to respond_to(:include?)
|
||||
end
|
||||
|
||||
it "doesn't load the passwords file if redis has it" do
|
||||
@@ -55,7 +55,7 @@ describe CommonPasswords do
|
||||
described_class.stubs(:redis).returns(mock_redis)
|
||||
described_class.expects(:load_passwords).never
|
||||
list = described_class.password_list
|
||||
list.should respond_to(:include?)
|
||||
expect(list).to respond_to(:include?)
|
||||
end
|
||||
|
||||
it "loads the passwords file if redis has an empty list" do
|
||||
@@ -65,7 +65,7 @@ describe CommonPasswords do
|
||||
described_class.stubs(:redis).returns(mock_redis)
|
||||
described_class.expects(:load_passwords).returns(['password'])
|
||||
list = described_class.password_list
|
||||
list.should respond_to(:include?)
|
||||
expect(list).to respond_to(:include?)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ describe CommonPasswords do
|
||||
it "tolerates it" do
|
||||
described_class.stubs(:redis).returns(stub_everything(sismember: false, exists: false, scard: 0))
|
||||
File.stubs(:readlines).with(described_class::PASSWORD_FILE).raises(Errno::ENOENT)
|
||||
described_class.common_password?("password").should eq(false)
|
||||
expect(described_class.common_password?("password")).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user