dotenvious 0.0.1 → 0.0.3

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: 7f3d8233b6bd8144495af0638e41cf3b14fa65db
4
- data.tar.gz: 18506bfd293ac3125816db78052fed52dd85660a
3
+ metadata.gz: 9fbd0527566372e2936735e868632eae06450968
4
+ data.tar.gz: ffab6509a4ce0ef809f5b095ac9f6c0d67c99d43
5
5
  SHA512:
6
- metadata.gz: 26a1170e357207a78f1ecfb5a8881e0ca1a462b0db643ba7e1dff023eec89b38d3cad3b60f26297d76439aa44c578e0843a260cf5cbf2719b63a38f80e3fe479
7
- data.tar.gz: cc93d31e8d2ac1cec5e6b47e9bb033d0b993b5f99647b284488dfa4ccb3320be2366fd524a16f042cb623603d75246c778b05eac8a8d2fd6e5d8659366ca72b5
6
+ metadata.gz: 0533e7fbf6f16111122bb2fba3b718af04ad1de1b65590a6bc549ceadd44a668bf6d8aa2d230ca928b418138c8b24a809bdc0b18eb0d1cdff33449d9f16d6893
7
+ data.tar.gz: 176333978d98cc06104debc2d40c5627628a8c9c3dc97dfcfbecd397c7bb9198656854a77c65d5f7c4e4de2b196dc6b406b03ce7cb22919744e6ed5fb7a8c99d
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  .example-env
4
4
  .envious
5
5
  dotenvious-*.gem
6
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.3.1
5
+
6
+ script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
1
  source 'https://www.rubygems.org'
2
2
 
3
- gemspec
3
+ ruby '2.3.1'
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem 'rake'
9
+ end
data/README.md CHANGED
@@ -1,41 +1,61 @@
1
1
  # Dotenvious
2
2
 
3
- A gem to manage .env dependencies.
3
+ A gem to manage `.env` dependencies.
4
4
 
5
5
  Your `.env` file gets jealous when `.example-env` has keys that it does not. Dotenvious helps `.env` get back on the right track.
6
6
 
7
- This gem exists to solve the following workflow:
7
+ See that your most recent pull breaks Rails on startup due to missing environment variables? Run `bundle exec dotenvious` and it will present to you the new variables that were added - and give you the option to immediately add them to your `.env` file.
8
8
 
9
- Imagine you're working at a small to mid-size team in a startup whose architecture is constantly evolving. In a fast-moving startup, environment variable may change rapidly.
9
+ Dotenvious eliminates the pain of manually parsing through a newly changed `.example-env` file to see which new breaking variables have been added.
10
10
 
11
- If you're working on one team within a larger application, environment variables may be added to your codebase that you might know were added, some of which may break the application's code after pulling from your updated repository.
11
+ ## Getting Started
12
12
 
13
- Dotenvious solves this problem. See that your most recent pull breaks Rails on startup? Run dotenvious and it will present to you the new variables that were added - and give you the option to immediately add them to your `.env` file.
13
+ Add the gem to your Gemfile by the following:
14
14
 
15
- Dotenvious eliminates the pain of manually parsing through a newly changed `.example-env` file to see which new breaking variables have been added.
15
+ ```
16
+ 
group :development do
17
+ gem 'dotenvious'
18
+ end
16
19
 
17
- ## Getting Started
20
+ ```
18
21
 
22
+ then run:
19
23
 
24
+ ```
25
+ bundle install
26
+ bundle exec dotenvious
27
+ ```
20
28
 
21
- ## What You Need
29
+ The CLI will then take you through your `.env` and `.example-env` files, prompting you to add missing variables or overwrite differing variables.
22
30
 
23
- This gem compares the variables set in your `.env` file with what exists in `.example-env`. The gem includes a CLI which walks you through the variables missing in `.env` but present in `.example-env`.
24
31
 
25
- Currently, this gem relies on [Dotenv](https://github.com/bkeepers/dotenv) to load dependencies from ENV.
32
+ ## Customization
26
33
 
27
- ## Future Work
34
+ Currently, one can whitelist which variables they want to exclude from examination.
28
35
 
29
- - [ ] Figure out how to incorporate in rakefile
36
+ First, add a `.envious` file to the root of your project. In the file, you can specify which variables to ignore fully (`optional_variables`) or those that you need but are expected to have different values from those provided in `.example-env` (`custom_variables`).
30
37
 
31
- - [x] Compare keys already present in both files but with different values
38
+ ```
39
+ Dotenvious::Configuration.new do |config|
32
40
 
33
- - [ ] Ability to choose which development `.env-*` file to load from
41
+ config.custom_variables = %w(VARIABLES WITH DIFFERENT VALUES)
42
+
43
+ config.optional_variables = %w(VARIABLES YOU DONT NEED)
44
+
45
+ end
34
46
 
35
- - [ ] Persist user's individual choices in a `.dotenvious` file in directory
47
+ ```
48
+
49
+ These both need to be arrays.
50
+
51
+ `dotenvious` will ignore the variables specified.
52
+ ## Future Work
53
+
54
+
55
+ - [ ] Ability to choose which development `.env-*` file to load from
36
56
 
37
- - [ ] Option to always run on boot after recent pull from master
57
+ - [ ] Persist user's individual choices in a `.envious` file in directory after run
38
58
 
39
59
  - [ ] Auto create `.envious` with user specified options if not exists
40
60
 
41
- - [ ] More things are always on the horizon!
61
+ - [ ] Remove duplicate variables if declared twice in `.env` file
data/bin/dotenvious CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "dotenvious"
4
- Dotenvious::CLI.new.run
4
+ Dotenvious::CLI::Main.new.run
data/dotenvious.gemspec CHANGED
@@ -1,15 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dotenvious'
3
- s.version = '0.0.1'
4
- s.date = '2016-09-10'
3
+ s.version = '0.0.3'
4
+ s.date = '2016-10-21'
5
5
  s.summary = "Dotenvious"
6
- s.description = "A dotenv wrapper to manage variables"
6
+ s.description = "A Gem to manage environment variables"
7
7
  s.authors = ["Jake Faris"]
8
8
  s.email = 'jakefaris@outlook.com'
9
9
  s.files = `git ls-files`.split($/)
10
10
  s.executables = ['dotenvious']
11
- s.homepage =
12
- 'http://rubygems.org/gems/dotenvious'
11
+ s.homepage = 'https://github.com/farisj/dotenvious'
13
12
  s.license = 'MIT'
14
13
 
15
14
  s.add_development_dependency 'bundler', '~> 1.3'
@@ -0,0 +1,36 @@
1
+ require_relative '../loaders/environments'
2
+ require_relative '../missing_variable_finder'
3
+ require_relative '../prompter'
4
+ require_relative '../loaders/configuration'
5
+
6
+ module Dotenvious
7
+ module CLI
8
+ class EnvFileConsolidator
9
+ def run
10
+ Loaders::Configuration.new.load
11
+ Loaders::Environments.new.load_envs
12
+ unless all_vars_present? && all_vars_match?
13
+ alert_user
14
+ decision = STDIN.gets.strip
15
+ Prompter.run if decision.downcase == 'y'
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :filename
22
+
23
+ def alert_user
24
+ puts "You have missing ENV variables. Examime them? [y/n]"
25
+ end
26
+
27
+ def all_vars_present?
28
+ !MissingVariableFinder.required_vars_missing?
29
+ end
30
+
31
+ def all_vars_match?
32
+ !MismatchedVariableFinder.mismatched_vars?
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../loaders/env'
2
+
3
+ module Dotenvious
4
+ module CLI
5
+ class EnvFileSorter
6
+ def run
7
+ Loaders::Env.new.load
8
+ puts "Sorting..."
9
+ File.open('.env', 'w') do |file|
10
+ file.write(sorted_env_text)
11
+ end
12
+ puts 'Your .env file is now neat and orderly. Enjoy!'
13
+ end
14
+
15
+ private
16
+
17
+ def sorted_env_text
18
+ ENV.sort.map do |(key, value)|
19
+ "#{key}=#{value}"
20
+ end.join("\n")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'env_file_consolidator'
2
+ require_relative 'env_file_sorter'
3
+
4
+ module Dotenvious
5
+ module CLI
6
+ class Main
7
+ def run
8
+ if ARGV[0].to_s.empty?
9
+ EnvFileConsolidator.new.run
10
+ elsif ARGV[0].to_s == '--sort'
11
+ EnvFileSorter.new.run
12
+ else
13
+ ask_user_to_remove_flags
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :filename
20
+
21
+ def ask_user_to_remove_flags
22
+ puts "dotenvious does not have flags at this time. Run 'dotenvious' without flags to get the main functionality."
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,6 +3,10 @@ module Dotenvious
3
3
  class Env < Environment
4
4
  private
5
5
 
6
+ def filename
7
+ DEFAULT_ENV_FILE
8
+ end
9
+
6
10
  def environment
7
11
  Dotenvious::ENV
8
12
  end
@@ -1,10 +1,6 @@
1
1
  module Dotenvious
2
2
  module Loaders
3
3
  class Environment
4
- def initialize(filename)
5
- @filename = filename
6
- end
7
-
8
4
  def load
9
5
  #took from Dotenv source code whoops
10
6
  file.each do |line|
@@ -18,11 +14,13 @@ module Dotenvious
18
14
  raise "environment must be defined in child class"
19
15
  end
20
16
 
21
- def file
22
- File.read(@filename).split("\n")
17
+ def filename
18
+ raise "fileame must be defined in child class"
23
19
  end
24
20
 
25
- attr_reader :filename
21
+ def file
22
+ File.read(filename).split("\n")
23
+ end
26
24
  end
27
25
  end
28
26
  end
@@ -4,19 +4,10 @@ require_relative 'env'
4
4
  module Dotenvious
5
5
  module Loaders
6
6
  class Environments
7
-
8
- def initialize(filename)
9
- @filename = filename
10
- end
11
-
12
7
  def load_envs
13
- Env.new('.env').load
14
- Example.new(filename).load
8
+ Env.new.load
9
+ Example.new.load
15
10
  end
16
-
17
- private
18
-
19
- attr_reader :filename
20
11
  end
21
12
  end
22
13
  end
@@ -5,6 +5,10 @@ module Dotenvious
5
5
  class Example < Environment
6
6
  private
7
7
 
8
+ def filename
9
+ DEFAULT_EXAMPLE_ENV_FILE
10
+ end
11
+
8
12
  def environment
9
13
  Dotenvious::ENV_EXAMPLE
10
14
  end
data/lib/dotenvious.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  module Dotenvious
2
+ DEFAULT_ENV_FILE = '.env'
3
+ DEFAULT_EXAMPLE_ENV_FILE = '.example-env'
2
4
  ENV = {}
3
5
  ENV_EXAMPLE = {}
4
6
  CONFIG = {}
5
7
  end
6
8
 
7
- require_relative 'dotenvious/cli'
9
+ require_relative 'dotenvious/cli/main'
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dotenvious::CLI::EnvFileConsolidator do
4
+ describe '.new' do
5
+ xit 'determines the correct file to use as example' do
6
+ # future release work
7
+ end
8
+ end
9
+
10
+ describe '#run' do
11
+ context 'with no flags' do
12
+ before do
13
+ allow(File).to receive(:read).and_return("")
14
+ end
15
+
16
+ it 'loads the environment & example environment variables' do
17
+ expect_any_instance_of(Dotenvious::Loaders::Environments).to receive(:load_envs)
18
+
19
+ described_class.new.run
20
+ end
21
+
22
+ context 'when there are ENV vars missing' do
23
+ context 'and the user wants to append them' do
24
+ it 'begins the Prompter' do
25
+ io_object = double
26
+ expect(STDIN).to receive(:gets).and_return('y')
27
+ expect_any_instance_of(described_class).to receive(:all_vars_present?).and_return false
28
+ expect(Dotenvious::Prompter).to receive(:run)#.and_return false
29
+ described_class.new.run
30
+ end
31
+ end
32
+
33
+ context 'but the user does not care' do
34
+ it 'quits' do
35
+ expect(STDIN).to receive(:gets).and_return('n')
36
+ expect_any_instance_of(described_class).to receive(:all_vars_present?).and_return false
37
+ expect(Dotenvious::Prompter).not_to receive(:run)#.and_return false
38
+
39
+ described_class.new.run
40
+ end
41
+ end
42
+ end
43
+
44
+ #Keep
45
+ context 'when there are no ENV vars missing or mismatched' do
46
+ it 'does nothing' do
47
+ expect_any_instance_of(described_class).to receive(:all_vars_present?).and_return true
48
+ expect_any_instance_of(described_class).to receive(:all_vars_match?).and_return true
49
+
50
+ expect { described_class.new.run }.to_not raise_error
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dotenvious::CLI::EnvFileSorter do
4
+ describe '#run' do
5
+ it "sorts the key-value pairs back into .env" do
6
+ expect_any_instance_of(Dotenvious::Loaders::Env).to receive(:load).and_return true
7
+
8
+ stub_const('Dotenvious::ENV', {'TEST' => 'same', 'ABC' => '123'} )
9
+
10
+ fake_file = double
11
+ expect(fake_file).to receive(:write).with("ABC=123\nTEST=same")
12
+ expect(File).to receive(:open).with('.env', 'w').and_yield fake_file
13
+
14
+ described_class.new.run
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dotenvious::CLI::Main do
4
+ describe '#run' do
5
+ context 'with no flags' do
6
+ before do
7
+ allow(File).to receive(:read).and_return("")
8
+ end
9
+
10
+ it 'begins the EnvFileConsolidator' do
11
+ expect_any_instance_of(Dotenvious::CLI::EnvFileConsolidator).to receive(:run)
12
+
13
+ described_class.new.run
14
+ end
15
+ end
16
+
17
+ context 'when option flags are given' do
18
+ before do
19
+ stub_const('ARGV', ['--test'])
20
+ end
21
+
22
+ it 'tells the user to try again without flags' do
23
+ expect_any_instance_of(described_class).to receive(:ask_user_to_remove_flags)
24
+
25
+ described_class.new.run
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,23 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Dotenvious::Loaders::Env do
4
- describe '.new' do
5
- it 'takes one argument' do
6
- expect{ described_class.new('test') }.to_not raise_error
7
- end
8
- end
9
-
10
4
  describe '#load' do
11
- it 'loads files from its .new argument' do
12
- expect(File).to receive(:read).with('test').and_return ""
5
+ it 'loads files from .env' do
6
+ expect(File).to receive(:read).with('.env').and_return ""
13
7
 
14
- described_class.new('test').load
8
+ described_class.new.load
15
9
  end
16
10
 
17
11
  it 'passes those arguments to Dotenvious::ENV_EXAMPLE' do
18
12
  expect(File).to receive(:read).and_return "TEST=123\nEXAMPLE=234"
19
13
 
20
- described_class.new('test').load
14
+ described_class.new.load
21
15
 
22
16
  expect(Dotenvious::ENV['TEST']).to eq '123'
23
17
  expect(Dotenvious::ENV['EXAMPLE']).to eq '234'
@@ -1,18 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Dotenvious::Loaders::Environments do
4
- describe '#initialize' do
5
- it 'takes 1 argument' do
6
- expect { described_class.new('test') }.to_not raise_error
7
- end
8
- end
9
-
10
4
  describe '#load_envs' do
11
5
  it 'loads from Dotenv as well as Loaders::Example' do
12
6
  expect_any_instance_of(Dotenvious::Loaders::Example).to receive(:load)
13
7
  expect_any_instance_of(Dotenvious::Loaders::Env).to receive(:load)
14
8
 
15
- described_class.new('test').load_envs
9
+ described_class.new.load_envs
16
10
  end
17
11
  end
18
12
  end
@@ -1,23 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Dotenvious::Loaders::Example do
4
- describe '.new' do
5
- it 'takes one argument' do
6
- expect{ described_class.new('test') }.to_not raise_error
7
- end
8
- end
9
-
10
4
  describe '#load' do
11
- it 'loads files from its .new argument' do
12
- expect(File).to receive(:read).with('test').and_return ""
5
+ before do
6
+ stub_const('Dotenvious::DEFAULT_EXAMPLE_ENV_FILE', '.example-env')
7
+ end
8
+ it 'loads files from Dotenvious::DEFAULT_EXAMPLE_ENV_FILE' do
9
+ expect(File).to receive(:read).with('.example-env').and_return ""
13
10
 
14
- described_class.new('test').load
11
+ described_class.new.load
15
12
  end
16
13
 
17
14
  it 'passes those arguments to Dotenvious::ENV_EXAMPLE' do
18
15
  expect(File).to receive(:read).and_return "TEST=123\nEXAMPLE=234"
19
16
 
20
- described_class.new('test').load
17
+ described_class.new.load
21
18
 
22
19
  expect(Dotenvious::ENV_EXAMPLE['TEST']).to eq '123'
23
20
  expect(Dotenvious::ENV_EXAMPLE['EXAMPLE']).to eq '234'
data/spec/spec_helper.rb CHANGED
@@ -18,3 +18,5 @@ RSpec.configure do |config|
18
18
  $stdout = original_stdout
19
19
  end
20
20
  end
21
+
22
+ ARGV = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenvious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Faris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.10'
55
- description: A dotenv wrapper to manage variables
55
+ description: A Gem to manage environment variables
56
56
  email: jakefaris@outlook.com
57
57
  executables:
58
58
  - dotenvious
@@ -60,13 +60,15 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".travis.yml"
63
64
  - Gemfile
64
- - Gemfile.lock
65
65
  - README.md
66
66
  - bin/dotenvious
67
67
  - dotenvious.gemspec
68
68
  - lib/dotenvious.rb
69
- - lib/dotenvious/cli.rb
69
+ - lib/dotenvious/cli/env_file_consolidator.rb
70
+ - lib/dotenvious/cli/env_file_sorter.rb
71
+ - lib/dotenvious/cli/main.rb
70
72
  - lib/dotenvious/configuration.rb
71
73
  - lib/dotenvious/env_appender.rb
72
74
  - lib/dotenvious/loaders/configuration.rb
@@ -78,7 +80,9 @@ files:
78
80
  - lib/dotenvious/missing_variable_finder.rb
79
81
  - lib/dotenvious/prompter.rb
80
82
  - lib/dotenvious/value_replacer.rb
81
- - spec/dotenvious/cli_spec.rb
83
+ - spec/dotenvious/cli/env_file_consolidator_spec.rb
84
+ - spec/dotenvious/cli/env_file_sorter_spec.rb
85
+ - spec/dotenvious/cli/main_spec.rb
82
86
  - spec/dotenvious/configuration_spec.rb
83
87
  - spec/dotenvious/env_appender_spec.rb
84
88
  - spec/dotenvious/loaders/configuration_spec.rb
@@ -90,7 +94,7 @@ files:
90
94
  - spec/dotenvious/prompter_spec.rb
91
95
  - spec/dotenvious/value_replacer_spec.rb
92
96
  - spec/spec_helper.rb
93
- homepage: http://rubygems.org/gems/dotenvious
97
+ homepage: https://github.com/farisj/dotenvious
94
98
  licenses:
95
99
  - MIT
96
100
  metadata: {}
@@ -115,4 +119,3 @@ signing_key:
115
119
  specification_version: 4
116
120
  summary: Dotenvious
117
121
  test_files: []
118
- has_rdoc:
data/Gemfile.lock DELETED
@@ -1,41 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- dotenvious (0.0.0)
5
-
6
- GEM
7
- remote: https://www.rubygems.org/
8
- specs:
9
- coderay (1.1.1)
10
- diff-lcs (1.2.5)
11
- method_source (0.8.2)
12
- pry (0.10.3)
13
- coderay (~> 1.1.0)
14
- method_source (~> 0.8.1)
15
- slop (~> 3.4)
16
- rspec (3.3.0)
17
- rspec-core (~> 3.3.0)
18
- rspec-expectations (~> 3.3.0)
19
- rspec-mocks (~> 3.3.0)
20
- rspec-core (3.3.2)
21
- rspec-support (~> 3.3.0)
22
- rspec-expectations (3.3.1)
23
- diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.3.0)
25
- rspec-mocks (3.3.2)
26
- diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.3.0)
28
- rspec-support (3.3.0)
29
- slop (3.6.0)
30
-
31
- PLATFORMS
32
- ruby
33
-
34
- DEPENDENCIES
35
- bundler (~> 1.3)
36
- dotenvious!
37
- pry
38
- rspec (>= 3.0)
39
-
40
- BUNDLED WITH
41
- 1.12.5
@@ -1,44 +0,0 @@
1
- require_relative 'loaders/environments'
2
- require_relative 'missing_variable_finder'
3
- require_relative 'prompter'
4
- require_relative 'loaders/configuration'
5
- require 'pry'
6
- module Dotenvious
7
- class CLI
8
- def initialize
9
- #figure out which file - for now can just look .env.example or .example-env
10
- @filename = '.example-env' # or .env-example
11
- end
12
-
13
- def run
14
- Loaders::Configuration.new.load
15
- Loaders::Environments.new(filename).load_envs
16
- unless all_vars_present? && all_vars_match?
17
- alert_user
18
- decision = STDIN.gets.strip
19
- Prompter.run if decision.downcase == 'y'
20
- end
21
- end
22
-
23
- private
24
-
25
- attr_reader :filename
26
-
27
- def alert_user
28
- puts "You have missing ENV variables. Examime them? [y/n]"
29
- end
30
-
31
- def all_vars_present?
32
- !MissingVariableFinder.required_vars_missing?
33
- end
34
-
35
- def all_vars_match?
36
- !MismatchedVariableFinder.mismatched_vars?
37
- end
38
-
39
- def abort
40
- abort_message = 'Hold up! Your .env file is green with envy towards .example-env. You should update it.'
41
- super abort_message
42
- end
43
- end
44
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dotenvious::CLI do
4
- describe '.new' do
5
- xit 'determines the correct file to use as example' do
6
- # future release work
7
- end
8
- end
9
-
10
- describe '#run' do
11
- it 'loads the environment & example environment variables' do
12
- expect_any_instance_of(Dotenvious::Loaders::Environments).to receive(:load_envs)
13
-
14
- described_class.new.run
15
- end
16
-
17
- context 'when there are ENV vars missing' do
18
- context 'and the user wants to append them' do
19
- it 'begins the Prompter' do
20
- io_object = double
21
- expect(STDIN).to receive(:gets).and_return('y')
22
- expect_any_instance_of(described_class).to receive(:all_vars_present?).and_return false
23
- expect(Dotenvious::Prompter).to receive(:run)#.and_return false
24
- described_class.new.run
25
- end
26
- end
27
- context 'but the user does not care' do
28
- it 'quits' do
29
- expect(STDIN).to receive(:gets).and_return('n')
30
- expect_any_instance_of(described_class).to receive(:all_vars_present?).and_return false
31
- expect(Dotenvious::Prompter).not_to receive(:run)#.and_return false
32
-
33
- described_class.new.run
34
- end
35
- end
36
- end
37
-
38
- context 'when there are no ENV vars missing or mismatched' do
39
- it 'does nothing' do
40
- expect_any_instance_of(described_class).to receive(:all_vars_present?).and_return true
41
- expect_any_instance_of(described_class).to receive(:all_vars_match?).and_return true
42
-
43
- expect { described_class.new.run }.to_not raise_error
44
- end
45
- end
46
- end
47
- end