matthewtodd-has_digest 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ this_rakefile_uses_shoe = <<END
2
+ ----------------------------------------
3
+ Please install Shoe:
4
+ gem sources --add http://gems.github.com
5
+ gem install matthewtodd-shoe
6
+ ----------------------------------------
7
+ END
8
+
9
+ begin
10
+ gem 'matthewtodd-shoe'
11
+ rescue Gem::LoadError
12
+ abort this_rakefile_uses_shoe
13
+ else
14
+ require 'shoe'
15
+ end
16
+
17
+ Shoe.tie('has_digest', '0.1.3', 'ActiveRecord macro that helps encrypt passwords and generate api tokens before_save.') do |spec|
18
+ spec.add_development_dependency 'thoughtbot-shoulda'
19
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{has_digest}
5
+ s.version = "0.1.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Matthew Todd"]
9
+ s.date = %q{2009-09-02}
10
+ s.email = %q{matthew.todd@gmail.com}
11
+ s.extra_rdoc_files = ["README.rdoc", "shoulda_macros/has_digest.rb"]
12
+ s.files = ["Rakefile", "has_digest.gemspec", "README.rdoc", "lib/has_digest.rb", "shoulda_macros/has_digest.rb", "test/has_digest_test.rb", "test/shoulda_macro_test.rb", "test/test_helper.rb"]
13
+ s.rdoc_options = ["--main", "README.rdoc", "--title", "has_digest-0.1.3", "--inline-source"]
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = %q{1.3.5}
16
+ s.summary = %q{ActiveRecord macro that helps encrypt passwords and generate api tokens before_save.}
17
+
18
+ if s.respond_to? :specification_version then
19
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
20
+ s.specification_version = 3
21
+
22
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
23
+ s.add_development_dependency(%q<matthewtodd-shoe>, [">= 0"])
24
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
25
+ else
26
+ s.add_dependency(%q<matthewtodd-shoe>, [">= 0"])
27
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
28
+ end
29
+ else
30
+ s.add_dependency(%q<matthewtodd-shoe>, [">= 0"])
31
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
32
+ end
33
+ end
@@ -10,20 +10,20 @@ module HasDigest
10
10
  def should_have_digest(name, options = {})
11
11
  options.assert_valid_keys(:depends, :limit)
12
12
 
13
- context "#{model_class.name} with has_digest :#{name}" do
13
+ context "#{described_type.name} with has_digest :#{name}" do
14
14
  should_have_db_column name, :type => :string, :limit => (options[:limit] || 40)
15
15
 
16
16
  should "generate digest for :#{name}" do
17
- assert_not_nil self.class.model_class.has_digest_attributes[name]
17
+ assert_not_nil self.class.described_type.has_digest_attributes[name]
18
18
  end
19
19
 
20
20
  if options[:depends]
21
21
  dependencies = options[:depends]
22
22
  dependencies = [dependencies] unless dependencies.respond_to?(:each)
23
- dependencies.unshift(:salt) if model_class.column_names.include?('salt')
23
+ dependencies.unshift(:salt) if described_type.column_names.include?('salt')
24
24
 
25
25
  should "generate digest for :#{name} from #{dependencies.to_sentence}" do
26
- attributes = self.class.model_class.has_digest_attributes[name] || {}
26
+ attributes = self.class.described_type.has_digest_attributes[name] || {}
27
27
  assert_equal dependencies, attributes[:dependencies]
28
28
  end
29
29
  end
@@ -13,11 +13,11 @@ class HasDigestTest < Test::Unit::TestCase
13
13
 
14
14
  context 'save' do
15
15
  setup { @instance.save }
16
- should_change '@instance.token', :to => /^\w{40}$/
16
+ should_change('@instance.token', :to => /^\w{40}$/) { @instance.token }
17
17
 
18
18
  context 'save again' do
19
19
  setup { @instance.save }
20
- should_not_change '@instance.token'
20
+ should_not_change('@instance.token') { @instance.token }
21
21
  end
22
22
  end
23
23
 
@@ -49,12 +49,12 @@ class HasDigestTest < Test::Unit::TestCase
49
49
 
50
50
  context 'saved again' do
51
51
  setup { @instance.save }
52
- should_not_change '@instance.encrypted_password'
52
+ should_not_change('@instance.encrypted_password') { @instance.encrypted_password }
53
53
  end
54
54
 
55
55
  context 'updated' do
56
56
  setup { @instance.update_attributes(:password => 'NEW PASSWORD') }
57
- should_change '@instance.encrypted_password'
57
+ should_change('@instance.encrypted_password') { @instance.encrypted_password }
58
58
  end
59
59
 
60
60
  context 'loaded completely fresh' do
@@ -62,7 +62,7 @@ class HasDigestTest < Test::Unit::TestCase
62
62
 
63
63
  context 'and saved' do
64
64
  setup { @instance.save }
65
- should_not_change '@instance.encrypted_password'
65
+ should_not_change('@instance.encrypted_password') { @instance.encrypted_password }
66
66
  end
67
67
  end
68
68
  end
@@ -84,7 +84,7 @@ class HasDigestTest < Test::Unit::TestCase
84
84
 
85
85
  context 'update one attribute' do
86
86
  setup { @instance.update_attributes(:remember_me_until => 3.weeks.from_now) }
87
- should_change '@instance.remember_me_token'
87
+ should_change('@instance.remember_me_token') { @instance.remember_me_token }
88
88
  end
89
89
 
90
90
  context 'update one attribute to nil' do
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class ShouldaMacroTest < Test::Unit::TestCase
4
+ def self.described_type
5
+ model_with_attributes(:token) do
6
+ has_digest :token
7
+ end
8
+ end
9
+
10
+ # This is just a smoke test to make sure we can call should_have_digest.
11
+ should_have_digest :token
12
+ end
@@ -1,16 +1,18 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
+ require 'active_record'
3
4
  require 'shoulda'
5
+ require 'shoulda/active_record'
4
6
  require 'mocha'
5
- require 'active_record'
6
7
  require File.join(File.dirname(__FILE__), '..', 'lib', 'has_digest.rb')
8
+ require File.join(File.dirname(__FILE__), '..', 'shoulda_macros', 'has_digest.rb')
7
9
 
8
10
  ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
9
11
 
10
12
  def model_with_attributes(*attributes, &block)
11
13
  ActiveRecord::Base.connection.create_table :models, :force => true do |table|
12
14
  attributes.each do |attribute|
13
- table.string attribute
15
+ table.string attribute, :limit => 40
14
16
  end
15
17
  end
16
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matthewtodd-has_digest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Todd
@@ -9,10 +9,29 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-02 00:00:00 -08:00
12
+ date: 2009-09-02 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: matthewtodd-shoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: thoughtbot-shoulda
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
16
35
  description:
17
36
  email: matthew.todd@gmail.com
18
37
  executables: []
@@ -23,23 +42,24 @@ extra_rdoc_files:
23
42
  - README.rdoc
24
43
  - shoulda_macros/has_digest.rb
25
44
  files:
45
+ - Rakefile
46
+ - has_digest.gemspec
26
47
  - README.rdoc
27
- - MIT-LICENSE
28
- - init.rb
29
48
  - lib/has_digest.rb
30
49
  - shoulda_macros/has_digest.rb
31
50
  - test/has_digest_test.rb
51
+ - test/shoulda_macro_test.rb
32
52
  - test/test_helper.rb
33
- has_rdoc: true
53
+ has_rdoc: false
34
54
  homepage:
55
+ licenses:
35
56
  post_install_message:
36
57
  rdoc_options:
37
58
  - --main
38
59
  - README.rdoc
39
60
  - --title
40
- - has_digest-0.1.2
61
+ - has_digest-0.1.3
41
62
  - --inline-source
42
- - --line-numbers
43
63
  require_paths:
44
64
  - lib
45
65
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -57,9 +77,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
77
  requirements: []
58
78
 
59
79
  rubyforge_project:
60
- rubygems_version: 1.2.0
80
+ rubygems_version: 1.3.5
61
81
  signing_key:
62
- specification_version: 2
82
+ specification_version: 3
63
83
  summary: ActiveRecord macro that helps encrypt passwords and generate api tokens before_save.
64
84
  test_files: []
65
85
 
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 [name of plugin creator]
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'has_digest'