seed_helper 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -2
- data/Gemfile +1 -1
- data/lib/seed_helper/version.rb +1 -1
- data/lib/seed_helper.rb +2 -2
- data/spec/lib/seed_formatter_spec.rb +20 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 788dec4ed90cf36ebdb4b169ca52fa2fd12383b6
|
4
|
+
data.tar.gz: a25308ff88ff387b78a1c2a7128838bb53273f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaa1dee063234427594e94c3b137d36d5a93d44762452261c7521189f9e72bc9877f833b3dacdb0f8765555040d7e6a05ff1ab0d99ed84ac4873c965887fb438
|
7
|
+
data.tar.gz: 13a595191054b2bc962dba8589186418a937743893924986619e423520fc109998c5ba18f3c348b1f99055755f5235c54fe05cfaeccb247bbe77a978871887e1
|
data/.rspec
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
--color
|
2
|
-
--debug
|
1
|
+
--color
|
data/Gemfile
CHANGED
data/lib/seed_helper/version.rb
CHANGED
data/lib/seed_helper.rb
CHANGED
@@ -7,7 +7,7 @@ class SeedHelper
|
|
7
7
|
extend SeedHelper::OutputFormatter
|
8
8
|
extend SeedHelper::RakeHelper
|
9
9
|
|
10
|
-
def create_resource(resource_class, attributes)
|
10
|
+
def self.create_resource(resource_class, attributes)
|
11
11
|
if resource = find_resource(resource_class, attributes)
|
12
12
|
resource_already_exists(resource)
|
13
13
|
else
|
@@ -25,7 +25,7 @@ class SeedHelper
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def find_resource(resource_class, attributes)
|
28
|
+
def self.find_resource(resource_class, attributes)
|
29
29
|
# Remove symbols from attributes. They cause SQL to get mad.
|
30
30
|
cloned_attributes = Hash[ attributes.map { |k, v| [k, v.is_a?(Symbol) ? v.to_s : v] } ]
|
31
31
|
cloned_attributes.delete_if do |key, value|
|
@@ -1,50 +1,44 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class TestClass
|
4
|
-
include SeedHelper
|
5
|
-
end
|
6
|
-
|
7
3
|
describe SeedHelper do
|
8
4
|
|
9
|
-
let(:tc) { TestClass.new }
|
10
|
-
|
11
5
|
describe '#output' do
|
12
|
-
subject {
|
6
|
+
subject { SeedHelper.output message, options }
|
13
7
|
let(:message) { "message" }
|
14
8
|
let(:options) { {} }
|
15
9
|
|
16
10
|
context 'options[:prefix] is provided' do
|
17
11
|
let(:options) { {:prefix => "a prefix "} }
|
18
12
|
it "prefixes the message with options[:prefix]" do
|
19
|
-
$stdout.
|
13
|
+
expect($stdout).to receive(:puts).with(/a prefix message/)
|
20
14
|
subject
|
21
15
|
end
|
22
16
|
end
|
23
17
|
context 'options[:suffix] is provided' do
|
24
18
|
let(:options) { {:suffix => " a suffix"} }
|
25
19
|
it "suffixes the message with options[:suffix]" do
|
26
|
-
$stdout.
|
20
|
+
expect($stdout).to receive(:puts).with(/message a suffix/)
|
27
21
|
subject
|
28
22
|
end
|
29
23
|
end
|
30
24
|
context 'options[:color] is provided' do
|
31
25
|
let(:options) { {:color => :blue} }
|
32
26
|
it "prints the message with the provided color" do
|
33
|
-
$stdout.
|
27
|
+
expect($stdout).to receive(:puts).with("\e[34mmessage\e[0m")
|
34
28
|
subject
|
35
29
|
end
|
36
30
|
end
|
37
31
|
context 'options[:color] is not provided' do
|
38
32
|
let(:options) { {:color => nil} }
|
39
33
|
it "prints the message in white by default" do
|
40
|
-
$stdout.
|
34
|
+
expect($stdout).to receive(:puts).with("\e[37mmessage\e[0m")
|
41
35
|
subject
|
42
36
|
end
|
43
37
|
end
|
44
38
|
end
|
45
39
|
|
46
40
|
describe '#message' do
|
47
|
-
subject {
|
41
|
+
subject { SeedHelper.message message, options }
|
48
42
|
let(:message) { "message" }
|
49
43
|
let(:options) { {:prefix => prefix, :color => color} }
|
50
44
|
let(:prefix) { nil }
|
@@ -52,33 +46,33 @@ describe SeedHelper do
|
|
52
46
|
context 'options[:prefix] is provided' do
|
53
47
|
let(:prefix) { "a prefix " }
|
54
48
|
it 'passes options[:prefix] to output' do
|
55
|
-
|
49
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:prefix => prefix))
|
56
50
|
subject
|
57
51
|
end
|
58
52
|
end
|
59
53
|
context 'options[:prefix] is not provided' do
|
60
54
|
it 'passes a default prefix through to output' do
|
61
|
-
|
55
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:prefix => "*** "))
|
62
56
|
subject
|
63
57
|
end
|
64
58
|
end
|
65
59
|
context 'options[:color] is provided' do
|
66
60
|
let(:color) { :blue }
|
67
61
|
it 'passes options[:color] to output' do
|
68
|
-
|
62
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:color => color))
|
69
63
|
subject
|
70
64
|
end
|
71
65
|
end
|
72
66
|
context 'options[:color] is not provided' do
|
73
67
|
it 'passes a default color through to output' do
|
74
|
-
|
68
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:color => :white))
|
75
69
|
subject
|
76
70
|
end
|
77
71
|
end
|
78
72
|
end
|
79
73
|
|
80
74
|
describe '#success' do
|
81
|
-
subject {
|
75
|
+
subject { SeedHelper.success message, options }
|
82
76
|
let(:message) { "message" }
|
83
77
|
let(:options) { {:prefix => prefix, :color => color} }
|
84
78
|
let(:prefix) { nil }
|
@@ -86,33 +80,33 @@ describe SeedHelper do
|
|
86
80
|
context 'options[:prefix] is provided' do
|
87
81
|
let(:prefix) { "a prefix " }
|
88
82
|
it 'passes options[:prefix] to output' do
|
89
|
-
|
83
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:prefix => prefix))
|
90
84
|
subject
|
91
85
|
end
|
92
86
|
end
|
93
87
|
context 'options[:prefix] is not provided' do
|
94
88
|
it 'passes a default prefix through to output' do
|
95
|
-
|
89
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:prefix => " + "))
|
96
90
|
subject
|
97
91
|
end
|
98
92
|
end
|
99
93
|
context 'options[:color] is provided' do
|
100
94
|
let(:color) { :blue }
|
101
95
|
it 'passes options[:color] to output' do
|
102
|
-
|
96
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:color => color))
|
103
97
|
subject
|
104
98
|
end
|
105
99
|
end
|
106
100
|
context 'options[:color] is not provided' do
|
107
101
|
it 'passes a default color through to output' do
|
108
|
-
|
102
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:color => :green))
|
109
103
|
subject
|
110
104
|
end
|
111
105
|
end
|
112
106
|
end
|
113
107
|
|
114
108
|
describe '#error' do
|
115
|
-
subject {
|
109
|
+
subject { SeedHelper.error message, options }
|
116
110
|
let(:message) { "message" }
|
117
111
|
let(:options) { {:prefix => prefix, :color => color} }
|
118
112
|
let(:prefix) { nil }
|
@@ -120,26 +114,26 @@ describe SeedHelper do
|
|
120
114
|
context 'options[:prefix] is provided' do
|
121
115
|
let(:prefix) { "a prefix " }
|
122
116
|
it 'passes options[:prefix] to output' do
|
123
|
-
|
117
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:prefix => prefix))
|
124
118
|
subject
|
125
119
|
end
|
126
120
|
end
|
127
121
|
context 'options[:prefix] is not provided' do
|
128
122
|
it 'passes a default prefix through to output' do
|
129
|
-
|
123
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:prefix => " - "))
|
130
124
|
subject
|
131
125
|
end
|
132
126
|
end
|
133
127
|
context 'options[:color] is provided' do
|
134
128
|
let(:color) { :blue }
|
135
129
|
it 'passes options[:color] to output' do
|
136
|
-
|
130
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:color => color))
|
137
131
|
subject
|
138
132
|
end
|
139
133
|
end
|
140
134
|
context 'options[:color] is not provided' do
|
141
135
|
it 'passes a default color through to output' do
|
142
|
-
|
136
|
+
expect(SeedHelper).to receive(:output).with(anything, hash_including(:color => :red))
|
143
137
|
subject
|
144
138
|
end
|
145
139
|
end
|