acts_as_keyed 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Jeremy Hubert"]
10
10
  s.email = ["jhubert@gmail.com"]
11
- s.homepage = "http://github.com/jhubert/acts-as-keyed"
11
+ s.homepage = "https://github.com/jhubert/acts-as-keyed"
12
12
  s.summary = %q{Automatically key an active record model with a unique key}
13
13
  s.description = %q{A simple plugin that automatically generates a key for a model on create. It takes care of protecting the key, automatically generating it and making sure it is unique.}
14
14
 
@@ -10,7 +10,7 @@ module ActsAsKeyed
10
10
 
11
11
  self.options = options
12
12
 
13
- raise ArgumentError, "#{self.name} is missing key column" if ActiveRecord::Base.connection.table_exists?(self.table_name) && columns_hash['key'].nil?
13
+ raise MissingKeyColumnError if ActiveRecord::Base.connection.table_exists?(self.table_name) && columns_hash['key'].nil?
14
14
 
15
15
  attr_protected :key
16
16
 
@@ -1,7 +1,12 @@
1
1
  module ActsAsKeyed
2
- class NoAvailableKeys < StandardError
2
+ class NoAvailableKeysError < StandardError
3
3
  def to_s
4
4
  'Very few unique keys are still available. Please change your acts_as_keyed chars or size settings.'
5
5
  end
6
6
  end
7
+ class MissingKeyColumnError < StandardError
8
+ def to_s
9
+ 'The table must have a column named "key"'
10
+ end
11
+ end
7
12
  end
@@ -19,7 +19,7 @@ module ActsAsKeyed
19
19
  break if self.class.count(:conditions => { :key => k }) == 0
20
20
  k = nil
21
21
  end
22
- raise NoAvailableKeys if k.nil?
22
+ raise NoAvailableKeysError if k.nil?
23
23
  self.key = k
24
24
  end
25
25
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsKeyed
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -53,26 +53,19 @@ class ActsAsKeyedTest < ActsAsKeyedBaseTest
53
53
  test "should raise an error if no unique keys can be found easily" do
54
54
  owk_setup(:chars => ['a'], :size => 1)
55
55
 
56
- error = false
57
- begin
56
+ assert_raise ActsAsKeyed::NoAvailableKeysError do
58
57
  2.times do
59
58
  o = ObjectWithKey.create
60
59
  end
61
- rescue ActsAsKeyed::NoAvailableKeys
62
- error = true
63
60
  end
64
-
65
- assert error
66
61
  end
67
62
 
68
63
  test "should fail if object doesn't have key column" do
69
64
  output = nil
70
- begin
65
+
66
+ assert_raise ActsAsKeyed::MissingKeyColumnError do
71
67
  ObjectWithoutKey.acts_as_keyed
72
- rescue ArgumentError => e
73
- output = e.message
74
68
  end
75
- assert_equal "ObjectWithoutKey is missing key column", output
76
69
  end
77
70
 
78
71
  private
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_keyed
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Hubert
@@ -56,7 +56,7 @@ files:
56
56
  - lib/acts_as_keyed/version.rb
57
57
  - test/acts_as_keyed_test.rb
58
58
  - test/test_helper.rb
59
- homepage: http://github.com/jhubert/acts-as-keyed
59
+ homepage: https://github.com/jhubert/acts-as-keyed
60
60
  licenses: []
61
61
 
62
62
  post_install_message: