katgut 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,4 +64,34 @@ RSpec.describe Katgut::Rule, type: :model do
64
64
  end
65
65
  end
66
66
  end
67
+
68
+ describe '#set_random_source' do
69
+ context 'the model is new and inialized without source url' do
70
+ let(:rule) { Katgut::Rule.new }
71
+
72
+ it 'generates a random source url automatically' do
73
+ expect(rule.source).not_to eq nil
74
+ end
75
+
76
+ it 'generates at least 6 character length or longer url' do
77
+ expect(rule.source.length).to be >= 6
78
+ end
79
+ end
80
+
81
+ context 'the model is new and initialized with a source url' do
82
+ let(:rule) { build(:rule, source: "osusume") }
83
+
84
+ it 'keeps the given source and do nothing' do
85
+ expect(rule.source).to eq "osusume"
86
+ end
87
+ end
88
+
89
+ context 'the model is persisted and initialized from db' do
90
+ before { create(:rule, source: "osusume") }
91
+
92
+ it 'keeps the given source and do nothing' do
93
+ expect(Katgut::Rule.last.source).to eq "osusume"
94
+ end
95
+ end
96
+ end
67
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katgut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - HAMADA Kazuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-21 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails