Skip to content

Commit

Permalink
Actually assert in validation helper functions and minor clean up of …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
Nitrodist committed Jan 14, 2013
1 parent ec443e1 commit 71d61c8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/strongbox_multiply_test.rb
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
require 'test/test_helper'

class StrongboxMultiPlyTest < Test::Unit::TestCase
class StrongboxMultiplyTest < Test::Unit::TestCase
context 'A Class with two secured fields' do
setup do
@password = 'boost facile'
Expand Down
6 changes: 3 additions & 3 deletions test/strongbox_test.rb
Expand Up @@ -46,7 +46,7 @@ class StrongboxTest < Test::Unit::TestCase
end
end

should 'impliment to_json' do
should 'implement to_json' do
assert_nothing_raised do
@dummy.secret.to_json
end
Expand Down Expand Up @@ -156,11 +156,11 @@ class StrongboxTest < Test::Unit::TestCase
end

context 'when a private key is not provided' do
setup do
setup do
@password = 'boost facile'
rebuild_class(:public_key => File.join(FIXTURES_DIR,'keypair.pem'))
@dummy = Dummy.new(:secret => 'Shhhh')
end
end

should 'raise on decrypt with a password' do
assert_raises(Strongbox::StrongboxError) do
Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Expand Up @@ -55,12 +55,12 @@ def rebuild_class options = {}

def assert_has_errors_on(model,attribute)
# Rails 2.X && Rails 3.X
!model.errors[attribute].empty?
assert !model.errors[attribute].empty?
end

def assert_does_not_have_errors_on(model,attribute)
# Rails 2.X Rails 3.X
model.errors[attribute].nil? || model.errors[attribute].empty?
assert model.errors[attribute].nil? || model.errors[attribute].empty?
end

def generate_key_pair(password = nil,size = 2048)
Expand Down
2 changes: 0 additions & 2 deletions test/validations_test.rb
Expand Up @@ -26,7 +26,6 @@ class ValidationsTest < Test::Unit::TestCase

context 'using validates_length_of' do
setup do
rebuild_class(:key_pair => File.join(FIXTURES_DIR,'keypair.pem'))
Dummy.send(:validates_length_of,
:secret,
:in => 5..10,
Expand Down Expand Up @@ -64,7 +63,6 @@ class ValidationsTest < Test::Unit::TestCase
if defined?(ActiveModel::Validations) # Rails 3
context 'using validates for length' do
setup do
rebuild_class(:key_pair => File.join(FIXTURES_DIR,'keypair.pem'))
Dummy.send(:validates,
:secret,
:length => {:minimum => 4, :maximum => 16})
Expand Down

0 comments on commit 71d61c8

Please sign in to comment.