Skip to content

Commit

Permalink
Starts tests and initiates Password class
Browse files Browse the repository at this point in the history
  • Loading branch information
philnash committed Mar 5, 2018
1 parent 0895dc0 commit deb712b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@

# rspec failure tracking
.rspec_status

Gemfile.lock
1 change: 1 addition & 0 deletions lib/pwned.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "pwned/version"
require "pwned/password"

module Pwned
# Your code goes here...
Expand Down
15 changes: 15 additions & 0 deletions lib/pwned/password.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "digest"

module Pwned
class Password
attr_reader :password

def initialize(password)
@password = password
end

def hashed_password
Digest::SHA1.hexdigest(password).upcase
end
end
end
15 changes: 3 additions & 12 deletions pwned.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@ Gem::Specification.new do |spec|
spec.authors = ["Phil Nash"]
spec.email = ["[email protected]"]

spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.}
spec.description = %q{TODO: Write a longer description or delete this line.}
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.summary = %q{Tools to use the Pwned Passwords API.}
spec.description = %q{Tools to use the Pwned Passwords API.}
spec.homepage = "https://github.com/philnash/pwned"
spec.license = "MIT"

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end

spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
Expand Down
11 changes: 11 additions & 0 deletions spec/pwned/password_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RSpec.describe Pwned::Password do
let(:pwned) { Pwned::Password.new("password") }

it "initializes with a password" do
expect(pwned.password).to eq("password")
end

it "has a hashed version of the password" do
expect(pwned.hashed_password).to eq("5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8")
end
end
4 changes: 0 additions & 4 deletions spec/pwned_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@
it "has a version number" do
expect(Pwned::VERSION).not_to be nil
end

it "does something useful" do
expect(false).to eq(true)
end
end

0 comments on commit deb712b

Please sign in to comment.