simple_slug 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d858815acb25626bd487c3a08d1550cdf39c3895
4
- data.tar.gz: 18a66060a237cb85e5f901566305e6b5e6698dff
3
+ metadata.gz: a288220a77771ee9ef0b7578d6831e83dfa9e8fe
4
+ data.tar.gz: 9ecf9b7e5d4cabc46e09aff7dc2738533eb04029
5
5
  SHA512:
6
- metadata.gz: 8b2edc684abb85fa503c0b214488428a4ebd5684cd62a79424e703f486e52b805fe41aa0d44dfa9e7fdde2a215f56d95295d0bee822710b21410b5bb7f9761e1
7
- data.tar.gz: 2258496ff4fb76de5a69cd08f5d9dd14036875817eb473f0ac9d84abb35efd146877a42ca5fa62270dfa5da521559ba827c51b2ff06eecb1fa16edc4f5607f10
6
+ metadata.gz: 8980a48ed1d7db74e82f1baf19ba7d2b2fed3380123b9cd44028771adbbb14346b8e7b7031c8bd5d25d03da136afe5458b4f5dab380352f4a01d7189aed31b6f
7
+ data.tar.gz: 680168768188b1fd55f03010a2b660269347f72b1d38b5cda9dd5ec1a1fdfd0ffdcb0d5e049b71c6dee06076fd045976a80e5ba40522517dce319995c2791115
@@ -1,3 +1,3 @@
1
1
  module SimpleSlug
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
data/simple_slug.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'activerecord', '>= 4.0.0', '< 5.0'
22
- spec.add_dependency 'i18n', '~> 0.6.0'
22
+ spec.add_dependency 'i18n', '~> 0.6'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.5'
25
25
  spec.add_development_dependency 'rake'
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  describe SimpleSlug do
4
4
  context 'defaults' do
5
5
  it 'slug column' do
6
- SimpleSlug.slug_column.should == 'slug'
6
+ expect(SimpleSlug.slug_column).to eq 'slug'
7
7
  end
8
8
 
9
9
  it 'excludes' do
10
- SimpleSlug.excludes.should include('new', 'edit')
10
+ expect(SimpleSlug.excludes).to include('new', 'edit')
11
11
  end
12
12
 
13
13
  it 'exclude regexps' do
14
- SimpleSlug.exclude_regexp.should == /\A\d+\z/
14
+ expect( SimpleSlug.exclude_regexp).to eq /\A\d+\z/
15
15
  end
16
16
  end
17
17
  end
@@ -7,21 +7,21 @@ end
7
7
  describe 'slug history' do
8
8
  describe 'history records handling' do
9
9
  before do
10
- SlugHistoryRspecModel.any_instance.stub(:simple_slug_exists?).and_return(false)
10
+ expect_any_instance_of(SlugHistoryRspecModel).to receive(:simple_slug_exists?).and_return(false)
11
11
  end
12
12
 
13
13
  it 'create' do
14
14
  relation = double
15
- ::SimpleSlug::HistorySlug.should_receive(:where).once.ordered.with(sluggable_type: 'SlugHistoryRspecModel', sluggable_id: 1, slug: 'hello').and_return(relation)
16
- relation.should_receive(:first_or_create)
15
+ expect(::SimpleSlug::HistorySlug).to receive(:where).once.ordered.with(sluggable_type: 'SlugHistoryRspecModel', sluggable_id: 1, slug: 'hello').and_return(relation)
16
+ expect(relation).to receive(:first_or_create)
17
17
  SlugHistoryRspecModel.create(id: 1, name: 'Hello')
18
18
  end
19
19
 
20
20
  it 'cleanup' do
21
21
  relation = double
22
- relation.stub(:first_or_create)
23
- ::SimpleSlug::HistorySlug.stub(:where).and_return(relation)
24
- relation.should_receive(:delete_all)
22
+ expect(relation).to receive(:first_or_create)
23
+ allow(::SimpleSlug::HistorySlug).to receive(:where).and_return(relation)
24
+ expect(relation).to receive(:delete_all)
25
25
  SlugHistoryRspecModel.create(name: 'Hello', id: 1).destroy
26
26
  end
27
27
  end
@@ -29,24 +29,24 @@ describe 'slug history' do
29
29
  describe 'conflicts' do
30
30
  it 'history slug exists' do
31
31
  record = SlugGenerationRspecModel.new(name: 'Hi')
32
- record.stub(:simple_slug_base_exists?).and_return(false)
33
- record.should_receive(:simple_slug_history_exists?).once.ordered.and_return(true)
34
- record.should_receive(:simple_slug_history_exists?).once.ordered.and_return(false)
32
+ allow(record).to receive(:simple_slug_base_exists?).and_return(false)
33
+ expect(record).to receive(:simple_slug_history_exists?).once.ordered.and_return(true)
34
+ expect(record).to receive(:simple_slug_history_exists?).once.ordered.and_return(false)
35
35
  record.save
36
- record.slug.should start_with('hi--')
36
+ expect(record.slug).to start_with('hi--')
37
37
  end
38
38
  end
39
39
 
40
40
  describe '#friendly_find' do
41
41
  before do
42
- SlugHistoryRspecModel.stub(:find_by)
42
+ allow(SlugHistoryRspecModel).to receive(:find_by)
43
43
  end
44
44
 
45
45
  it 'find from history' do
46
46
  record = double('history')
47
- record.stub(:sluggable_id).and_return(1)
48
- ::SimpleSlug::HistorySlug.should_receive(:find_by!).with(slug: 'title').and_return(record)
49
- SlugHistoryRspecModel.should_receive(:find).with(1).and_return(record)
47
+ allow(record).to receive(:sluggable_id).and_return(1)
48
+ expect(::SimpleSlug::HistorySlug).to receive(:find_by!).with(slug: 'title').and_return(record)
49
+ expect(SlugHistoryRspecModel).to receive(:find).with(1).and_return(record)
50
50
  SlugHistoryRspecModel.friendly_find('title')
51
51
  end
52
52
  end
@@ -7,71 +7,71 @@ end
7
7
  describe SimpleSlug::ModelAddition do
8
8
  describe 'slug generation' do
9
9
  before do
10
- SlugGenerationRspecModel.any_instance.stub(:simple_slug_exists?).and_return(false)
10
+ allow_any_instance_of(SlugGenerationRspecModel). to receive(:simple_slug_exists?).and_return(false)
11
11
  end
12
12
 
13
13
  it 'after save' do
14
- SlugGenerationRspecModel.create(name: 'Hello').slug.should == 'hello'
14
+ expect(SlugGenerationRspecModel.create(name: 'Hello').slug).to eq 'hello'
15
15
  end
16
16
 
17
17
  it 'skip excludes' do
18
- SlugGenerationRspecModel.new(name: 'new').should_not be_valid
18
+ expect(SlugGenerationRspecModel.new(name: 'new')).not_to be_valid
19
19
  end
20
20
 
21
21
  it 'skip integers' do
22
- SlugGenerationRspecModel.new(name: '123').should_not be_valid
22
+ expect(SlugGenerationRspecModel.new(name: '123')).not_to be_valid
23
23
  end
24
24
 
25
25
  it 'skip slug generation' do
26
- SlugGenerationRspecModel.any_instance.stub(:should_generate_new_slug?).and_return(false)
27
- SlugGenerationRspecModel.create(name: 'Hello').slug.should be_blank
26
+ allow_any_instance_of(SlugGenerationRspecModel).to receive(:should_generate_new_slug?).and_return(false)
27
+ expect(SlugGenerationRspecModel.create(name: 'Hello').slug).to be_blank
28
28
  end
29
29
  end
30
30
 
31
31
  describe 'resolve conflicts' do
32
32
  it 'duplicate slug' do
33
33
  record = SlugGenerationRspecModel.new(name: 'Hi')
34
- record.should_receive(:simple_slug_exists?).once.ordered.with('hi').and_return(true)
35
- record.should_receive(:simple_slug_exists?).once.ordered.with(/hi--\d+/).and_return(false)
34
+ expect(record).to receive(:simple_slug_exists?).once.ordered.with('hi').and_return(true)
35
+ expect(record).to receive(:simple_slug_exists?).once.ordered.with(/hi--\d+/).and_return(false)
36
36
  record.save
37
- record.slug.should start_with('hi--')
37
+ expect(record.slug).to start_with('hi--')
38
38
  end
39
39
 
40
40
  it 'numeric slug' do
41
41
  record = SlugGenerationRspecModel.new(name: '123')
42
- record.should_receive(:simple_slug_exists?).with('_123').and_return(false)
42
+ expect(record).to receive(:simple_slug_exists?).with('_123').and_return(false)
43
43
  record.save
44
- record.slug.should == '_123'
44
+ expect(record.slug).to eq '_123'
45
45
  end
46
46
  end
47
47
 
48
48
  describe '#to_param' do
49
49
  before do
50
- SlugGenerationRspecModel.any_instance.stub(:simple_slug_exists?).and_return(false)
50
+ allow_any_instance_of(SlugGenerationRspecModel).to receive(:simple_slug_exists?).and_return(false)
51
51
  end
52
52
 
53
53
  it 'slug if exists' do
54
- SlugGenerationRspecModel.create(name: 'Hello').to_param.should == 'hello'
54
+ expect(SlugGenerationRspecModel.create(name: 'Hello').to_param).to eq 'hello'
55
55
  end
56
56
 
57
57
  it 'id without slug' do
58
- SlugGenerationRspecModel.create(id: 1).to_param.should == '1'
58
+ expect(SlugGenerationRspecModel.create(id: 1).to_param).to eq '1'
59
59
  end
60
60
  end
61
61
 
62
62
  describe '#friendly_find' do
63
63
  it '#find if integer like' do
64
- SlugGenerationRspecModel.should_receive(:find).with(1)
64
+ expect(SlugGenerationRspecModel).to receive(:find).with(1)
65
65
  SlugGenerationRspecModel.friendly_find(1)
66
66
  end
67
67
 
68
68
  it '#find if numeric string' do
69
- SlugGenerationRspecModel.should_receive(:find).with('1')
69
+ expect(SlugGenerationRspecModel).to receive(:find).with('1')
70
70
  SlugGenerationRspecModel.friendly_find('1')
71
71
  end
72
72
 
73
73
  it 'find by slug' do
74
- SlugGenerationRspecModel.should_receive(:find_by!).with('slug' => 'title').and_return(double)
74
+ expect(SlugGenerationRspecModel).to receive(:find_by!).with('slug' => 'title').and_return(double)
75
75
  SlugGenerationRspecModel.friendly_find('title')
76
76
  end
77
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_slug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Leschenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.6.0
39
+ version: '0.6'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.6.0
46
+ version: '0.6'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.2.2
133
+ rubygems_version: 2.4.3
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Friendly url generator with history.