Commit 6c505b307a8afcab6398a29b7198be39b9b9c711
Switch to rspec2
Aman Gupta committed on 12/20/2010, 6:39:30 PMParent: 1965feb04521deb88687096017f69da1bd59d952
Files changed
Rakefile | changed |
spec/bcrypt/engine_spec.rb | changed |
spec/bcrypt/password_spec.rb | changed |
spec/spec_helper.rb | changed |
.rspec | added |
Rakefile | ||
---|---|---|
@@ -1,12 +1,12 @@ | ||
1 | -require "spec/rake/spectask" | |
1 | +require 'rspec/core/rake_task' | |
2 | 2 | require 'rake/gempackagetask' |
3 | 3 | require 'rake/extensiontask' |
4 | 4 | require 'rake/javaextensiontask' |
5 | 5 | require 'rake/contrib/rubyforgepublisher' |
6 | 6 | require 'rake/clean' |
7 | 7 | require 'rake/rdoctask' |
8 | -require "benchmark" | |
8 | +require 'benchmark' | |
9 | 9 | |
10 | 10 | PKG_NAME = "bcrypt-ruby" |
11 | 11 | PKG_VERSION = "2.1.2" |
12 | 12 | PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" |
@@ -33,19 +33,17 @@ | ||
33 | 33 | |
34 | 34 | task :default => [:compile, :spec] |
35 | 35 | |
36 | 36 | desc "Run all specs" |
37 | -Spec::Rake::SpecTask.new do |t| | |
38 | - t.spec_files = FileList['spec/**/*_spec.rb'] | |
39 | - t.spec_opts = ['--color','--backtrace','--diff'] | |
37 | +RSpec::Core::RakeTask.new do |t| | |
38 | + t.pattern = 'spec/**/*_spec.rb' | |
40 | 39 | end |
41 | 40 | |
42 | 41 | desc "Run all specs, with coverage testing" |
43 | -Spec::Rake::SpecTask.new(:rcov) do |t| | |
44 | - t.spec_files = FileList['spec/**/*_spec.rb'] | |
45 | - t.spec_opts = ['--color','--backtrace','--diff'] | |
42 | +RSpec::Core::RakeTask.new(:rcov) do |t| | |
43 | + t.pattern = 'spec/**/*_spec.rb' | |
46 | 44 | t.rcov = true |
47 | - t.rcov_dir = 'doc/coverage' | |
45 | + t.rcov_path = 'doc/coverage' | |
48 | 46 | t.rcov_opts = ['--exclude', 'rspec,diff-lcs,rcov,_spec,_helper'] |
49 | 47 | end |
50 | 48 | |
51 | 49 | desc 'Generate RDoc' |
spec/bcrypt/engine_spec.rb | ||
---|---|---|
@@ -1,15 +1,15 @@ | ||
1 | 1 | require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper")) |
2 | 2 | |
3 | -context "The BCrypt engine" do | |
3 | +describe "The BCrypt engine" do | |
4 | 4 | specify "should calculate the optimal cost factor to fit in a specific time" do |
5 | 5 | first = BCrypt::Engine.calibrate(100) |
6 | 6 | second = BCrypt::Engine.calibrate(400) |
7 | 7 | second.should > first |
8 | 8 | end |
9 | 9 | end |
10 | 10 | |
11 | -context "Generating BCrypt salts" do | |
11 | +describe "Generating BCrypt salts" do | |
12 | 12 | |
13 | 13 | specify "should produce strings" do |
14 | 14 | BCrypt::Engine.generate_salt.should be_an_instance_of(String) |
15 | 15 | end |
@@ -26,9 +26,9 @@ | ||
26 | 26 | lambda { BCrypt::Engine.generate_salt(-1) }.should raise_error(BCrypt::Errors::InvalidCost) |
27 | 27 | end |
28 | 28 | end |
29 | 29 | |
30 | -context "Autodetecting of salt cost" do | |
30 | +describe "Autodetecting of salt cost" do | |
31 | 31 | |
32 | 32 | specify "should work" do |
33 | 33 | BCrypt::Engine.autodetect_cost("$2a$08$hRx2IVeHNsTSYYtUWn61Ou").should == 8 |
34 | 34 | BCrypt::Engine.autodetect_cost("$2a$05$XKd1bMnLgUnc87qvbAaCUu").should == 5 |
@@ -36,9 +36,9 @@ | ||
36 | 36 | end |
37 | 37 | |
38 | 38 | end |
39 | 39 | |
40 | -context "Generating BCrypt hashes" do | |
40 | +describe "Generating BCrypt hashes" do | |
41 | 41 | |
42 | 42 | class MyInvalidSecret |
43 | 43 | undef to_s |
44 | 44 | end |
spec/bcrypt/password_spec.rb | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 | require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper")) |
2 | 2 | |
3 | -context "Creating a hashed password" do | |
3 | +describe "Creating a hashed password" do | |
4 | 4 | |
5 | 5 | before :each do |
6 | 6 | @secret = "wheedle" |
7 | 7 | @password = BCrypt::Password.create(@secret, :cost => 4) |
@@ -27,9 +27,9 @@ | ||
27 | 27 | lambda { BCrypt::Password.create( String.new ) }.should_not raise_error |
28 | 28 | end |
29 | 29 | end |
30 | 30 | |
31 | -context "Reading a hashed password" do | |
31 | +describe "Reading a hashed password" do | |
32 | 32 | before :each do |
33 | 33 | @secret = "U*U" |
34 | 34 | @hash = "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW" |
35 | 35 | end |
@@ -46,9 +46,9 @@ | ||
46 | 46 | lambda { BCrypt::Password.new('weedle') }.should raise_error(BCrypt::Errors::InvalidHash) |
47 | 47 | end |
48 | 48 | end |
49 | 49 | |
50 | -context "Comparing a hashed password with a secret" do | |
50 | +describe "Comparing a hashed password with a secret" do | |
51 | 51 | before :each do |
52 | 52 | @secret = "U*U" |
53 | 53 | @hash = "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW" |
54 | 54 | @password = BCrypt::Password.create(@secret) |
@@ -60,5 +60,5 @@ | ||
60 | 60 | |
61 | 61 | specify "should compare unsuccessfully to anything besides original secret" do |
62 | 62 | (@password == "@secret").should be(false) |
63 | 63 | end |
64 | -end | |
64 | +end |
Built with git-ssb-web