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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 956fe14a4426e1c4ed95d9a2b171d8d32f943210
4
- data.tar.gz: 703ae546351c32a11f67e162f6ddb95bcac1d690
3
+ metadata.gz: 788dec4ed90cf36ebdb4b169ca52fa2fd12383b6
4
+ data.tar.gz: a25308ff88ff387b78a1c2a7128838bb53273f3d
5
5
  SHA512:
6
- metadata.gz: f7472a69bf9a88752082a2237c0ce11cb3681561de291adb5cce638787340ad92d0a34aea1ffee079f71f03a504b125d54dca46060f43e94aa2f92e426b898d3
7
- data.tar.gz: 7c0ea3b2a01d2668cf65eee9f96bfb73d5c8254eda34d42a3b9e29ff4e5346ea440f781650e9915a2aac2ff9d36a4f4ff30044b9fc52f34fef7ad4722cf6c163
6
+ metadata.gz: eaa1dee063234427594e94c3b137d36d5a93d44762452261c7521189f9e72bc9877f833b3dacdb0f8765555040d7e6a05ff1ab0d99ed84ac4873c965887fb438
7
+ data.tar.gz: 13a595191054b2bc962dba8589186418a937743893924986619e423520fc109998c5ba18f3c348b1f99055755f5235c54fe05cfaeccb247bbe77a978871887e1
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --color
2
- --debug
1
+ --color
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in seed_helper.gemspec
4
4
  gemspec
5
5
  gem 'rspec'
6
- gem 'ruby-debug'
6
+ gem 'byebug'
@@ -1,3 +1,3 @@
1
1
  class SeedHelper
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
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 { tc.output message, options }
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.should_receive(:puts).with(/a prefix message/)
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.should_receive(:puts).with(/message a suffix/)
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.should_receive(:puts).with("\e[34mmessage\e[0m")
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.should_receive(:puts).with("\e[37mmessage\e[0m")
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 { tc.message message, options }
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
- tc.should_receive(:output).with(anything, hash_including(:prefix => prefix))
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
- tc.should_receive(:output).with(anything, hash_including(:prefix => "*** "))
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
- tc.should_receive(:output).with(anything, hash_including(:color => color))
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
- tc.should_receive(:output).with(anything, hash_including(:color => :white))
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 { tc.success message, options }
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
- tc.should_receive(:output).with(anything, hash_including(:prefix => prefix))
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
- tc.should_receive(:output).with(anything, hash_including(:prefix => " + "))
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
- tc.should_receive(:output).with(anything, hash_including(:color => color))
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
- tc.should_receive(:output).with(anything, hash_including(:color => :green))
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 { tc.error message, options }
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
- tc.should_receive(:output).with(anything, hash_including(:prefix => prefix))
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
- tc.should_receive(:output).with(anything, hash_including(:prefix => " - "))
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
- tc.should_receive(:output).with(anything, hash_including(:color => color))
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
- tc.should_receive(:output).with(anything, hash_including(:color => :red))
136
+ expect(SeedHelper).to receive(:output).with(anything, hash_including(:color => :red))
143
137
  subject
144
138
  end
145
139
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seed_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Maguire