permoid 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ class TestPermalinkClass
4
+ include Mongoid::Document
5
+ include Permoid::Base
6
+
7
+ field :title
8
+ end
9
+
10
+ describe Permoid::Base do
11
+ before :each do
12
+ TestPermalinkClass.delete_all
13
+ end
14
+
15
+ describe 'permalink' do
16
+ it 'should have the method' do
17
+ TestPermalinkClass.new.respond_to?(:set_permalink).should eql(true)
18
+ end
19
+
20
+ it 'should be a Mongoid::Document object' do
21
+ TestNoMongoidClass = Struct.new(:title)
22
+ lambda do
23
+ TestNoMongoidClass.send(:include, Permoid::Base)
24
+ end.should raise_error
25
+ end
26
+
27
+ it 'should set the permalink' do
28
+ test = TestPermalinkClass.create(:title => 'test permalink')
29
+ test.permalink.should eql('test-permalink')
30
+ end
31
+
32
+ it 'should set a fixed permalink' do
33
+ test = TestPermalinkClass.new(:title => 'test permalink')
34
+ test.set_permalink 'blah'
35
+ test.permalink.should eql('blah')
36
+ end
37
+
38
+ it 'should not have twice the same permalink' do
39
+ test = TestPermalinkClass.create(:title => 'test permalink')
40
+ test.permalink.should eql('test-permalink')
41
+
42
+ second = TestPermalinkClass.create(:title => 'test permalink')
43
+ second.permalink.should eql('test-permalink-1')
44
+ end
45
+
46
+ it 'should increment if there are more than twice the same permalink' do
47
+ test = TestPermalinkClass.create(:title => 'test permalink')
48
+ test.permalink.should eql('test-permalink')
49
+
50
+ second = TestPermalinkClass.create(:title => 'test permalink')
51
+ second.permalink.should eql('test-permalink-1')
52
+
53
+ third = TestPermalinkClass.create(:title => 'test permalink')
54
+ third.permalink.should eql('test-permalink-2')
55
+ end
56
+
57
+ it 'should not increment if the permalink is the current object' do
58
+ test = TestPermalinkClass.create(:title => 'test permalink')
59
+ test.permalink.should eql('test-permalink')
60
+
61
+ test.save!
62
+ test.permalink.should eql('test-permalink')
63
+ end
64
+
65
+ it 'should return the permalink' do
66
+ test = TestPermalinkClass.create(:title => 'test permalink')
67
+ test.to_param.should eql(test.permalink)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Permoid::String do
4
+
5
+ describe 'permalink' do
6
+ it 'should have the method' do
7
+ String.new.respond_to?(:to_permalink).should eql(true)
8
+ end
9
+
10
+ it 'should export a permalink' do
11
+ "test".to_permalink.should eql('test')
12
+ end
13
+
14
+ it 'should lowercase' do
15
+ "Test".to_permalink.should eql('test')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ require 'mongoid'
2
+ require 'permoid'
3
+
4
+ require 'rspec'
5
+ require 'mocha'
6
+
7
+ Mongoid.configure do |config|
8
+ config.master = Mongo::Connection.new('127.0.0.1', 27017).db('permoid_test')
9
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: permoid
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Damien MATHIEU
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-20 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Add permalinks to your mongoid models
22
+ email: 42@dmathieu.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - spec/spec_helper.rb
31
+ - spec/permoid/permoid_spec.rb
32
+ - spec/permoid/string_spec.rb
33
+ has_rdoc: true
34
+ homepage: http://github.com/dmathieu/permoid
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --charset=UTF-8
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: -707619406829477027
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.7
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Permalinkd for Mongoid
66
+ test_files:
67
+ - spec/spec_helper.rb
68
+ - spec/permoid/permoid_spec.rb
69
+ - spec/permoid/string_spec.rb