glman 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe Glman::ConfigManager do
4
+
5
+ # subject { described_class.new }
6
+ let(:config_file) { double('config_file') }
7
+ let(:config) { nil }
8
+
9
+ before(:each) do
10
+ subject.stub(:config_file).and_return(config_file)
11
+ File.stub(:exist?).and_return(true)
12
+ YAML.stub(:load_file).and_return(config)
13
+ end
14
+
15
+ describe '#get' do
16
+ describe 'returns empty hash' do
17
+ it 'when config file missing' do
18
+ File.stub(:exist?).and_return(false)
19
+ subject.get.should eq({})
20
+ end
21
+
22
+ it 'when raise error on configuration loading' do
23
+ YAML.stub(:load_file).and_return('bad_data')
24
+
25
+ subject.get.should eq({})
26
+ end
27
+ end
28
+
29
+ describe 'returns configuration as hash' do
30
+ let(:config) {{ 'test' => 'works' }}
31
+ it 'when present' do
32
+ subject.get.should eq config
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '#set' do
38
+ it 'raise ConfigSetError when argument is not a hash kind' do
39
+ -> { subject.set('bad_arg') }.should raise_error Glman::ConfigManager::SetConfigError
40
+ end
41
+
42
+ describe 'save' do
43
+ let(:config) {{gitlab: {private_token: 'token', url:'test'}}}
44
+ let(:new_setting) {{new_key: 'test_val'}}
45
+ let(:updated_config) {config.merge(new_setting)}
46
+
47
+ it 'updated configuration' do
48
+ subject.should_receive(:get).and_return(config)
49
+ subject.should_receive(:save_configuration).with(updated_config)
50
+ subject.set(new_setting)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Glman::InitRequired do
4
+
5
+ class TestInitRequiredClass
6
+ include Glman::InitRequired
7
+
8
+ attr_required :a
9
+ end
10
+
11
+ it 'Test class should have propery a' do
12
+ subject = TestInitRequiredClass.new(a: 'test')
13
+ subject.a.should eq 'test'
14
+ end
15
+
16
+ it 'should raise InitializationError when required attr missing on initialization' do
17
+ -> { TestInitRequiredClass.new }.should raise_error
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/glman')
9
+ require 'rspec'
10
+ require 'ostruct'
11
+
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Niemczyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - ! '>='
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: irc-notify
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description: Git Lab Manager
126
154
  email:
127
155
  - pniemczyk@o2.pl
@@ -139,11 +167,30 @@ files:
139
167
  - glman.gemspec
140
168
  - lib/glman.rb
141
169
  - lib/glman/commands/base.rb
142
- - lib/glman/configuration.rb
170
+ - lib/glman/commands/config.rb
171
+ - lib/glman/commands/configs/aliases_config.rb
172
+ - lib/glman/commands/configs/gitlab_config.rb
173
+ - lib/glman/commands/configs/notify_irc_config.rb
174
+ - lib/glman/commands/configs/users_config.rb
175
+ - lib/glman/commands/help_messages.rb
176
+ - lib/glman/commands/mr.rb
177
+ - lib/glman/commands/notify.rb
178
+ - lib/glman/config_manager.rb
179
+ - lib/glman/data_presenter.rb
180
+ - lib/glman/init_required.rb
181
+ - lib/glman/kernel.rb
143
182
  - lib/glman/repos/git_repo.rb
144
183
  - lib/glman/repos/projects_repo.rb
145
184
  - lib/glman/repos/users_repo.rb
146
185
  - lib/glman/version.rb
186
+ - spec/glman/commands/config/aliases_config_spec.rb
187
+ - spec/glman/commands/config/gitlab_config_spec.rb
188
+ - spec/glman/commands/config/notify_irc_config_spec.rb
189
+ - spec/glman/commands/config/users_config_spec.rb
190
+ - spec/glman/commands/config_spec.rb
191
+ - spec/glman/config_manager_spec.rb
192
+ - spec/glman/init_required_spec.rb
193
+ - spec/spec_helper.rb
147
194
  homepage: https://github.com/pniemczyk/glman
148
195
  licenses:
149
196
  - MIT
@@ -168,4 +215,12 @@ rubygems_version: 2.1.10
168
215
  signing_key:
169
216
  specification_version: 4
170
217
  summary: Git Lab Manager
171
- test_files: []
218
+ test_files:
219
+ - spec/glman/commands/config/aliases_config_spec.rb
220
+ - spec/glman/commands/config/gitlab_config_spec.rb
221
+ - spec/glman/commands/config/notify_irc_config_spec.rb
222
+ - spec/glman/commands/config/users_config_spec.rb
223
+ - spec/glman/commands/config_spec.rb
224
+ - spec/glman/config_manager_spec.rb
225
+ - spec/glman/init_required_spec.rb
226
+ - spec/spec_helper.rb
@@ -1,58 +0,0 @@
1
- require 'yaml'
2
- require 'hashie'
3
-
4
- module Glman
5
- class Configuration
6
-
7
- def load
8
- File.exist?(config_file) ? Hashie::Mash.new(YAML.load_file(config_file)) : nil
9
- end
10
-
11
- def build_config(config={})
12
- validare_config(config)
13
- File.write(config_file, config.to_yaml)
14
- end
15
-
16
- def show_aliases
17
- load[:aliases]
18
- end
19
-
20
- def add_user_alias(opts={})
21
- config = load
22
- aliases = config[:aliases] || {}
23
- aliases[opts.fetch(:alias)] = opts.fetch(:email)
24
- config[:aliases] = aliases
25
- File.write(config_file, config.to_yaml)
26
- end
27
-
28
- def clear_user_aliases
29
- config = load
30
- config[:aliases] = {}
31
- File.write(config_file, config.to_yaml)
32
- end
33
-
34
- def set_user_list(users)
35
- config = load
36
- config[:users] = users
37
- File.write(config_file, config.to_yaml)
38
- end
39
-
40
- private
41
-
42
- def validare_config(hash)
43
- raise ArgumentError, 'config is not hash' unless hash.kind_of?(Hash)
44
- raise ArgumentError, 'private_token missing in configuration' unless hash.has_key?(:private_token)
45
- raise ArgumentError, 'gitlab_url missing in configuration' unless hash.has_key?(:gitlab_url)
46
- end
47
-
48
- def config_load
49
- Hashie::Mash.new(YAML.load_file(config_file)).tap do |config|
50
- validare_config(config)
51
- end
52
- end
53
-
54
- def config_file
55
- File.expand_path('.glmanrc',Dir.home)
56
- end
57
- end
58
- end