-
Notifications
You must be signed in to change notification settings - Fork 73
/
3scale_toolbox_spec.rb
43 lines (37 loc) · 1.21 KB
/
3scale_toolbox_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
RSpec.describe ThreeScaleToolbox do
include_context :temp_dir
include_context :plugin
include_context :random_name
let(:name) { random_lowercase_name }
let(:dest_plugin_file) { tmp_dir.join('3scale_toolbox_plugin.rb') }
around(:each) do |example|
plugin = get_plugin_content(name.capitalize, name)
dest_plugin_file.write(plugin)
$LOAD_PATH.unshift(tmp_dir) unless $LOAD_PATH.include?(tmp_dir)
example.run
$LOAD_PATH.delete(tmp_dir)
end
context '#plugin_paths' do
it 'finds plugin' do
expect(described_class.plugin_paths).to include(dest_plugin_file.to_s)
end
end
context '#load_plugins' do
it 'loads plugin' do
expect { described_class.load_plugins }.not_to raise_error
expect(Object.const_get(name.capitalize.to_sym)).to be_truthy
end
end
context '#default_config_file' do
it 'using ENV var' do
filename = 'some_file_name'
env_copy = ENV.to_h
env_copy['THREESCALE_CLI_CONFIG'] = filename
stub_const('ENV', env_copy)
expect(described_class.default_config_file).to eq filename
end
it 'default' do
expect(described_class.default_config_file).to eq File.join Gem.user_home, '.3scalerc.yaml'
end
end
end