nenv 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/nenv/version.rb +1 -1
- data/nenv.gemspec +6 -3
- metadata +4 -23
- data/.rspec +0 -2
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -33
- data/.travis.yml +0 -13
- data/Gemfile +0 -12
- data/Guardfile +0 -32
- data/Rakefile +0 -17
- data/spec/lib/nenv/builder_spec.rb +0 -27
- data/spec/lib/nenv/environment/dumper_spec.rb +0 -34
- data/spec/lib/nenv/environment/loader_spec.rb +0 -59
- data/spec/lib/nenv/environment_spec.rb +0 -220
- data/spec/lib/nenv_spec.rb +0 -66
- data/spec/spec_helper.rb +0 -49
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d06558bd1f60f7df4ca005879f7edf5766d39f43
         | 
| 4 | 
            +
              data.tar.gz: b799514f85b409d39b5cc00ed89a75ac40128a2e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 34f8b3b1ba84e8cefded199b13f7aa36bba820455191dcedbb2a6811e2f06f49c39ccaccc8b6e25b20cb10c26bf594db4ccb76a7530cb53d70d27b2fe51e389e
         | 
| 7 | 
            +
              data.tar.gz: 541451121f650f2d099632b0c8d900d5f8d630a78c19aa9245127606f71fb20986f77883532a3d14882b1195d4651fd666e93cb6170b056f5a08eddb700488ba
         | 
    
        data/README.md
    CHANGED
    
    | @@ -54,7 +54,7 @@ You no longer have to care whether the value is "0" or "false" or "no" or "FALSE | |
| 54 54 | 
             
            ```ruby
         | 
| 55 55 | 
             
            # Without Nenv
         | 
| 56 56 | 
             
            t.verbose = (ENV['CI'] == 'true')
         | 
| 57 | 
            -
            ok = ENV['RUBYGEMS_GEMDEPS'] == "1" || ENV.key?('BUNDLE_GEMFILE' | 
| 57 | 
            +
            ok = ENV['RUBYGEMS_GEMDEPS'] == "1" || ENV.key?('BUNDLE_GEMFILE')
         | 
| 58 58 | 
             
            ENV['DEBUG'] = "true"
         | 
| 59 59 |  | 
| 60 60 | 
             
            ```
         | 
    
        data/lib/nenv/version.rb
    CHANGED
    
    
    
        data/nenv.gemspec
    CHANGED
    
    | @@ -9,13 +9,16 @@ Gem::Specification.new do |spec| | |
| 9 9 | 
             
              spec.authors       = ['Cezary Baginski']
         | 
| 10 10 | 
             
              spec.email         = ['cezary@chronomantic.net']
         | 
| 11 11 | 
             
              spec.summary       = "Convenience wrapper for Ruby's ENV"
         | 
| 12 | 
            -
              spec.description   = 'Using ENV is like using raw SQL statements in your code.  | 
| 12 | 
            +
              spec.description   = 'Using ENV is like using raw SQL statements in your code. We all know how that ends...'
         | 
| 13 13 | 
             
              spec.homepage      = 'https://github.com/e2/nenv'
         | 
| 14 14 | 
             
              spec.license       = 'MIT'
         | 
| 15 15 |  | 
| 16 | 
            -
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject do |f|
         | 
| 17 | 
            +
                /^(?:\.rspec|\.rubocop.*\.yml|\.travis\.yml|Rakefile|Guardfile|Gemfile|spec\/.*)$/.match(f)
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 17 20 | 
             
              spec.executables   = spec.files.grep(/^bin\//) { |f| File.basename(f) }
         | 
| 18 | 
            -
              spec.test_files    =  | 
| 21 | 
            +
              spec.test_files    = []
         | 
| 19 22 | 
             
              spec.require_paths = ['lib']
         | 
| 20 23 |  | 
| 21 24 | 
             
              spec.add_development_dependency 'bundler', '~> 1.7'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: nenv
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Cezary Baginski
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-12- | 
| 11 | 
            +
            date: 2014-12-14 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: '10.0'
         | 
| 55 | 
            -
            description: Using ENV is like using raw SQL statements in your code.  | 
| 55 | 
            +
            description: Using ENV is like using raw SQL statements in your code. We all know
         | 
| 56 56 | 
             
              how that ends...
         | 
| 57 57 | 
             
            email:
         | 
| 58 58 | 
             
            - cezary@chronomantic.net
         | 
| @@ -61,15 +61,8 @@ extensions: [] | |
| 61 61 | 
             
            extra_rdoc_files: []
         | 
| 62 62 | 
             
            files:
         | 
| 63 63 | 
             
            - ".gitignore"
         | 
| 64 | 
            -
            - ".rspec"
         | 
| 65 | 
            -
            - ".rubocop.yml"
         | 
| 66 | 
            -
            - ".rubocop_todo.yml"
         | 
| 67 | 
            -
            - ".travis.yml"
         | 
| 68 | 
            -
            - Gemfile
         | 
| 69 | 
            -
            - Guardfile
         | 
| 70 64 | 
             
            - LICENSE.txt
         | 
| 71 65 | 
             
            - README.md
         | 
| 72 | 
            -
            - Rakefile
         | 
| 73 66 | 
             
            - lib/nenv.rb
         | 
| 74 67 | 
             
            - lib/nenv/autoenvironment.rb
         | 
| 75 68 | 
             
            - lib/nenv/builder.rb
         | 
| @@ -78,12 +71,6 @@ files: | |
| 78 71 | 
             
            - lib/nenv/environment/loader.rb
         | 
| 79 72 | 
             
            - lib/nenv/version.rb
         | 
| 80 73 | 
             
            - nenv.gemspec
         | 
| 81 | 
            -
            - spec/lib/nenv/builder_spec.rb
         | 
| 82 | 
            -
            - spec/lib/nenv/environment/dumper_spec.rb
         | 
| 83 | 
            -
            - spec/lib/nenv/environment/loader_spec.rb
         | 
| 84 | 
            -
            - spec/lib/nenv/environment_spec.rb
         | 
| 85 | 
            -
            - spec/lib/nenv_spec.rb
         | 
| 86 | 
            -
            - spec/spec_helper.rb
         | 
| 87 74 | 
             
            homepage: https://github.com/e2/nenv
         | 
| 88 75 | 
             
            licenses:
         | 
| 89 76 | 
             
            - MIT
         | 
| @@ -108,10 +95,4 @@ rubygems_version: 2.2.2 | |
| 108 95 | 
             
            signing_key: 
         | 
| 109 96 | 
             
            specification_version: 4
         | 
| 110 97 | 
             
            summary: Convenience wrapper for Ruby's ENV
         | 
| 111 | 
            -
            test_files:
         | 
| 112 | 
            -
            - spec/lib/nenv/builder_spec.rb
         | 
| 113 | 
            -
            - spec/lib/nenv/environment/dumper_spec.rb
         | 
| 114 | 
            -
            - spec/lib/nenv/environment/loader_spec.rb
         | 
| 115 | 
            -
            - spec/lib/nenv/environment_spec.rb
         | 
| 116 | 
            -
            - spec/lib/nenv_spec.rb
         | 
| 117 | 
            -
            - spec/spec_helper.rb
         | 
| 98 | 
            +
            test_files: []
         | 
    
        data/.rspec
    DELETED
    
    
    
        data/.rubocop.yml
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            inherit_from: .rubocop_todo.yml
         | 
    
        data/.rubocop_todo.yml
    DELETED
    
    | @@ -1,33 +0,0 @@ | |
| 1 | 
            -
            # This configuration was generated by `rubocop --auto-gen-config`
         | 
| 2 | 
            -
            # on 2014-12-13 13:35:53 +0100 using RuboCop version 0.28.0.
         | 
| 3 | 
            -
            # The point is for the user to remove these configuration records
         | 
| 4 | 
            -
            # one by one as the offenses are removed from the code base.
         | 
| 5 | 
            -
            # Note that changes in the inspected code, or installation of new
         | 
| 6 | 
            -
            # versions of RuboCop, may require this file to be generated again.
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            # Offense count: 1
         | 
| 9 | 
            -
            Lint/HandleExceptions:
         | 
| 10 | 
            -
              Enabled: false
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            # Offense count: 1
         | 
| 13 | 
            -
            Metrics/AbcSize:
         | 
| 14 | 
            -
              Max: 16
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            # Offense count: 1
         | 
| 17 | 
            -
            # Configuration parameters: AllowURI, URISchemes.
         | 
| 18 | 
            -
            Metrics/LineLength:
         | 
| 19 | 
            -
              Max: 112
         | 
| 20 | 
            -
             | 
| 21 | 
            -
            # Offense count: 1
         | 
| 22 | 
            -
            # Configuration parameters: CountComments.
         | 
| 23 | 
            -
            Metrics/MethodLength:
         | 
| 24 | 
            -
              Max: 11
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            # Offense count: 8
         | 
| 27 | 
            -
            Style/Documentation:
         | 
| 28 | 
            -
              Enabled: false
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            # Offense count: 1
         | 
| 31 | 
            -
            # Configuration parameters: EnforcedStyle, SupportedStyles.
         | 
| 32 | 
            -
            Style/MethodName:
         | 
| 33 | 
            -
              Enabled: false
         | 
    
        data/.travis.yml
    DELETED
    
    
    
        data/Gemfile
    DELETED
    
    | @@ -1,12 +0,0 @@ | |
| 1 | 
            -
            source 'https://rubygems.org'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            # Specify your gem's dependencies in nenv.gemspec
         | 
| 4 | 
            -
            gemspec development_group: :test
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            gem 'coveralls', require: false
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            group :development do
         | 
| 9 | 
            -
              gem 'guard-rspec', '~> 4.5', require: false
         | 
| 10 | 
            -
              gem 'guard-rubocop', require: false
         | 
| 11 | 
            -
              gem 'pry'
         | 
| 12 | 
            -
            end
         | 
    
        data/Guardfile
    DELETED
    
    | @@ -1,32 +0,0 @@ | |
| 1 | 
            -
            # A sample Guardfile
         | 
| 2 | 
            -
            # More info at https://github.com/guard/guard#readme
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            ## Uncomment and set this to only include directories you want to watch
         | 
| 5 | 
            -
            directories(%w(lib spec))
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            ## Uncomment to clear the screen before every task
         | 
| 8 | 
            -
            # clearing :on
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            group :spec, halt_on_fail: true do
         | 
| 11 | 
            -
              guard :rspec, cmd: 'bundle exec rspec' do
         | 
| 12 | 
            -
                require 'guard/rspec/dsl'
         | 
| 13 | 
            -
                dsl = Guard::RSpec::Dsl.new(self)
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                # Feel free to open issues for suggestions and improvements
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                # RSpec files
         | 
| 18 | 
            -
                rspec = dsl.rspec
         | 
| 19 | 
            -
                watch(rspec.spec_helper) { rspec.spec_dir }
         | 
| 20 | 
            -
                watch(rspec.spec_support) { rspec.spec_dir }
         | 
| 21 | 
            -
                watch(rspec.spec_files)
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                # Ruby files
         | 
| 24 | 
            -
                ruby = dsl.ruby
         | 
| 25 | 
            -
                dsl.watch_spec_files_for(ruby.lib_files)
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              guard :rubocop do
         | 
| 29 | 
            -
                watch(/.+\.rb$/)
         | 
| 30 | 
            -
                watch(/(?:.+\/)?\.rubocop(?:_todo)?\.yml$/) { |m| File.dirname(m[0]) }
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
            end
         | 
    
        data/Rakefile
    DELETED
    
    | @@ -1,17 +0,0 @@ | |
| 1 | 
            -
            require 'bundler/gem_tasks'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'nenv'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            default_tasks = []
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            require 'rspec/core/rake_task'
         | 
| 8 | 
            -
            default_tasks  << RSpec::Core::RakeTask.new(:spec) do |t|
         | 
| 9 | 
            -
              t.verbose = Nenv.ci?
         | 
| 10 | 
            -
            end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            unless Nenv.ci?
         | 
| 13 | 
            -
              require 'rubocop/rake_task'
         | 
| 14 | 
            -
              default_tasks << RuboCop::RakeTask.new(:rubocop)
         | 
| 15 | 
            -
            end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            task default: default_tasks.map(&:name)
         | 
| @@ -1,27 +0,0 @@ | |
| 1 | 
            -
            require 'nenv/builder'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            RSpec.describe Nenv::Builder do
         | 
| 4 | 
            -
              describe '#build' do
         | 
| 5 | 
            -
                before do
         | 
| 6 | 
            -
                  allow(ENV).to receive(:[]).with('FOO')
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                it 'returns a class with the given methods' do
         | 
| 10 | 
            -
                  FooEnv = Nenv::Builder.build do
         | 
| 11 | 
            -
                    create_method(:foo?)
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
                  FooEnv.new.foo?
         | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                context 'with duplicate methods' do
         | 
| 17 | 
            -
                  it 'fails' do
         | 
| 18 | 
            -
                    expect do
         | 
| 19 | 
            -
                      FooEnv = Nenv::Builder.build do
         | 
| 20 | 
            -
                        create_method(:foo?)
         | 
| 21 | 
            -
                        create_method(:foo?)
         | 
| 22 | 
            -
                      end
         | 
| 23 | 
            -
                    end.to raise_error(Nenv::Environment::AlreadyExistsError)
         | 
| 24 | 
            -
                  end
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
            end
         | 
| @@ -1,34 +0,0 @@ | |
| 1 | 
            -
            require 'yaml'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'nenv/environment/dumper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            RSpec.describe Nenv::Environment::Dumper do
         | 
| 6 | 
            -
              subject { described_class.new.dump(value) }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              context "with \"abc\"" do
         | 
| 9 | 
            -
                let(:value) { 'abc' }
         | 
| 10 | 
            -
                it { is_expected.to eq('abc') }
         | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              context 'with 123' do
         | 
| 14 | 
            -
                let(:value) { 123 }
         | 
| 15 | 
            -
                it { is_expected.to eq('123') }
         | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              context 'with nil' do
         | 
| 19 | 
            -
                let(:value) { nil }
         | 
| 20 | 
            -
                it { is_expected.to eq(nil) }
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              context 'with a block' do
         | 
| 24 | 
            -
                subject do
         | 
| 25 | 
            -
                  described_class.new.dump(value) { |data| YAML.dump(data) }
         | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                context 'with a yaml string' do
         | 
| 29 | 
            -
                  let(:value) { { foo: 3 } }
         | 
| 30 | 
            -
                  let(:yaml) { "---\n:foo: 3\n" }
         | 
| 31 | 
            -
                  it { is_expected.to eq(yaml) }
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
            end
         | 
| @@ -1,59 +0,0 @@ | |
| 1 | 
            -
            require 'yaml'
         | 
| 2 | 
            -
            require 'nenv/environment/loader'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            RSpec.describe Nenv::Environment::Loader do
         | 
| 5 | 
            -
              context 'with no block' do
         | 
| 6 | 
            -
                subject { described_class.new(meth).load(value) }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                context 'with a normal method' do
         | 
| 9 | 
            -
                  let(:meth) { :foo }
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                  context "with \"abc\"" do
         | 
| 12 | 
            -
                    let(:value) { 'abc' }
         | 
| 13 | 
            -
                    it { is_expected.to eq('abc') }
         | 
| 14 | 
            -
                  end
         | 
| 15 | 
            -
                end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                context 'with a bool method' do
         | 
| 18 | 
            -
                  let(:meth) { :foo? }
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                  %w(1 true y yes TRUE YES foobar).each do |data|
         | 
| 21 | 
            -
                    context "with #{data.inspect}" do
         | 
| 22 | 
            -
                      let(:value) { data }
         | 
| 23 | 
            -
                      it { is_expected.to eq(true) }
         | 
| 24 | 
            -
                    end
         | 
| 25 | 
            -
                  end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                  %w(0 false n no FALSE NO).each do |data|
         | 
| 28 | 
            -
                    context "with #{data.inspect}" do
         | 
| 29 | 
            -
                      let(:value) { data }
         | 
| 30 | 
            -
                      it { is_expected.to eq(false) }
         | 
| 31 | 
            -
                    end
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                  context 'with nil' do
         | 
| 35 | 
            -
                    let(:value) { nil }
         | 
| 36 | 
            -
                    it { is_expected.to eq(nil) }
         | 
| 37 | 
            -
                  end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                  context 'when empty string' do
         | 
| 40 | 
            -
                    let(:value) { '' }
         | 
| 41 | 
            -
                    it do
         | 
| 42 | 
            -
                      expect { subject }.to raise_error(
         | 
| 43 | 
            -
                        ArgumentError, /Can't convert empty string into Bool/
         | 
| 44 | 
            -
                      )
         | 
| 45 | 
            -
                    end
         | 
| 46 | 
            -
                  end
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
              context 'with a block' do
         | 
| 51 | 
            -
                subject do
         | 
| 52 | 
            -
                  described_class.new(:foo).load(value) { |data| YAML.load(data) }
         | 
| 53 | 
            -
                end
         | 
| 54 | 
            -
                context 'with a yaml string' do
         | 
| 55 | 
            -
                  let(:value) { "--- foo\n...\n" }
         | 
| 56 | 
            -
                  it { is_expected.to eq('foo') }
         | 
| 57 | 
            -
                end
         | 
| 58 | 
            -
              end
         | 
| 59 | 
            -
            end
         | 
| @@ -1,220 +0,0 @@ | |
| 1 | 
            -
            require 'yaml'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'nenv/environment'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            RSpec.describe Nenv::Environment do
         | 
| 6 | 
            -
              let(:env) { instance_double(Hash) } # a hash is close enough
         | 
| 7 | 
            -
              before(:each) { stub_const('ENV', env) }
         | 
| 8 | 
            -
             | 
| 9 | 
            -
              context 'without integration' do
         | 
| 10 | 
            -
                let(:dumper) { instance_double(described_class::Dumper) }
         | 
| 11 | 
            -
                let(:loader) { instance_double(described_class::Loader) }
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                before do
         | 
| 14 | 
            -
                  allow(described_class::Dumper).to receive(:new).and_return(dumper)
         | 
| 15 | 
            -
                  allow(described_class::Loader).to receive(:new).and_return(loader)
         | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                context 'with no namespace' do
         | 
| 19 | 
            -
                  let(:instance) { described_class.new }
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  context 'with an existing method' do
         | 
| 22 | 
            -
                    before do
         | 
| 23 | 
            -
                      subject.create_method(:foo?)
         | 
| 24 | 
            -
                    end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                    it 'uses the name as full key' do
         | 
| 27 | 
            -
                      expect(ENV).to receive(:[]).with('FOO').and_return('true')
         | 
| 28 | 
            -
                      expect(loader).to receive(:load).with('true').and_return(true)
         | 
| 29 | 
            -
                      expect(subject.foo?).to eq(true)
         | 
| 30 | 
            -
                    end
         | 
| 31 | 
            -
                  end
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                context 'with any namespace' do
         | 
| 35 | 
            -
                  let(:namespace) { 'bar' }
         | 
| 36 | 
            -
                  let(:instance) { described_class.new(namespace) }
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  describe 'creating a method' do
         | 
| 39 | 
            -
                    subject { instance }
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                    before do
         | 
| 42 | 
            -
                      subject.create_method(:foo)
         | 
| 43 | 
            -
                    end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                    it { is_expected.to respond_to(:foo) }
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                    context 'when the method already exists' do
         | 
| 48 | 
            -
                      let(:error) { described_class::AlreadyExistsError }
         | 
| 49 | 
            -
                      let(:message) { 'Method :foo already exists' }
         | 
| 50 | 
            -
                      specify do
         | 
| 51 | 
            -
                        expect do
         | 
| 52 | 
            -
                          subject.create_method(:foo)
         | 
| 53 | 
            -
                        end.to raise_error(error, message)
         | 
| 54 | 
            -
                      end
         | 
| 55 | 
            -
                    end
         | 
| 56 | 
            -
                  end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                  describe 'calling' do
         | 
| 59 | 
            -
                    subject { instance }
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                    context 'when method does not exist' do
         | 
| 62 | 
            -
                      let(:error) { NoMethodError }
         | 
| 63 | 
            -
                      let(:message) { /undefined method `foo' for/ }
         | 
| 64 | 
            -
                      it { expect { subject.foo }.to raise_error(error, message) }
         | 
| 65 | 
            -
                    end
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                    context 'with a reader method' do
         | 
| 68 | 
            -
                      context 'with no block' do
         | 
| 69 | 
            -
                        before { instance.create_method(meth) }
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                        context 'with a normal method' do
         | 
| 72 | 
            -
                          let(:meth) { :foo }
         | 
| 73 | 
            -
                          before do
         | 
| 74 | 
            -
                            allow(loader).to receive(:load).with('123').and_return(123)
         | 
| 75 | 
            -
                          end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                          it 'returns unmarshalled stored value' do
         | 
| 78 | 
            -
                            expect(ENV).to receive(:[]).with('BAR_FOO').and_return('123')
         | 
| 79 | 
            -
                            expect(subject.foo).to eq 123
         | 
| 80 | 
            -
                          end
         | 
| 81 | 
            -
                        end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
                        context 'with a bool method' do
         | 
| 84 | 
            -
                          let(:meth) { :foo? }
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                          it 'references the proper ENV variable' do
         | 
| 87 | 
            -
                            allow(loader).to receive(:load).with('false').and_return(false)
         | 
| 88 | 
            -
                            expect(ENV).to receive(:[]).with('BAR_FOO').and_return('false')
         | 
| 89 | 
            -
                            expect(subject.foo?).to eq false
         | 
| 90 | 
            -
                          end
         | 
| 91 | 
            -
                        end
         | 
| 92 | 
            -
                      end
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                      context 'with a block' do
         | 
| 95 | 
            -
                        before do
         | 
| 96 | 
            -
                          instance.create_method(:foo) { |data| YAML.load(data) }
         | 
| 97 | 
            -
                        end
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                        let(:value) { "---\n:foo: 5\n" }
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                        it 'unmarshals using the block' do
         | 
| 102 | 
            -
                          allow(ENV).to receive(:[]).with('BAR_FOO')
         | 
| 103 | 
            -
                            .and_return(value)
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                          allow(loader).to receive(:load).with(value) do |arg, &block|
         | 
| 106 | 
            -
                            expect(block).to be
         | 
| 107 | 
            -
                            block.call(arg)
         | 
| 108 | 
            -
                          end
         | 
| 109 | 
            -
             | 
| 110 | 
            -
                          expect(subject.foo).to eq(foo: 5)
         | 
| 111 | 
            -
                        end
         | 
| 112 | 
            -
                      end
         | 
| 113 | 
            -
                    end
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                    context 'with a writer method' do
         | 
| 116 | 
            -
                      before { instance.create_method(:foo=) }
         | 
| 117 | 
            -
             | 
| 118 | 
            -
                      it 'set the environment variable' do
         | 
| 119 | 
            -
                        expect(ENV).to receive(:[]=).with('BAR_FOO', '123')
         | 
| 120 | 
            -
                        allow(dumper).to receive(:dump).with(123).and_return('123')
         | 
| 121 | 
            -
                        subject.foo = 123
         | 
| 122 | 
            -
                      end
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                      it 'marshals and stores the value' do
         | 
| 125 | 
            -
                        expect(ENV).to receive(:[]=).with('BAR_FOO', '123')
         | 
| 126 | 
            -
                        allow(dumper).to receive(:dump).with(123).and_return('123')
         | 
| 127 | 
            -
                        subject.foo = 123
         | 
| 128 | 
            -
                      end
         | 
| 129 | 
            -
                    end
         | 
| 130 | 
            -
             | 
| 131 | 
            -
                    context 'with a method containing underscores' do
         | 
| 132 | 
            -
                      before { instance.create_method(:foo_baz) }
         | 
| 133 | 
            -
                      it 'reads the correct variable' do
         | 
| 134 | 
            -
                        expect(ENV).to receive(:[]).with('BAR_FOO_BAZ').and_return('123')
         | 
| 135 | 
            -
                        allow(loader).to receive(:load).with('123').and_return(123)
         | 
| 136 | 
            -
                        subject.foo_baz
         | 
| 137 | 
            -
                      end
         | 
| 138 | 
            -
                    end
         | 
| 139 | 
            -
             | 
| 140 | 
            -
                    context 'with a block' do
         | 
| 141 | 
            -
                      before do
         | 
| 142 | 
            -
                        instance.create_method(:foo=) { |data| YAML.dump(data) }
         | 
| 143 | 
            -
                      end
         | 
| 144 | 
            -
             | 
| 145 | 
            -
                      let(:result) { "---\n:foo: 5\n" }
         | 
| 146 | 
            -
             | 
| 147 | 
            -
                      it 'marshals using the block' do
         | 
| 148 | 
            -
                        allow(ENV).to receive(:[]=).with('BAR_FOO', result)
         | 
| 149 | 
            -
             | 
| 150 | 
            -
                        allow(dumper).to receive(:dump).with(foo: 5) do |arg, &block|
         | 
| 151 | 
            -
                          expect(block).to be
         | 
| 152 | 
            -
                          block.call(arg)
         | 
| 153 | 
            -
                        end
         | 
| 154 | 
            -
             | 
| 155 | 
            -
                        subject.foo = { foo: 5 }
         | 
| 156 | 
            -
                      end
         | 
| 157 | 
            -
                    end
         | 
| 158 | 
            -
             | 
| 159 | 
            -
                    context 'with an unsanitized name' do
         | 
| 160 | 
            -
                      pending
         | 
| 161 | 
            -
                    end
         | 
| 162 | 
            -
                  end
         | 
| 163 | 
            -
                end
         | 
| 164 | 
            -
              end
         | 
| 165 | 
            -
             | 
| 166 | 
            -
              describe 'with integration' do
         | 
| 167 | 
            -
                context 'with any namespace' do
         | 
| 168 | 
            -
                  let(:namespace) { 'baz' }
         | 
| 169 | 
            -
                  let(:instance) { described_class.new(namespace) }
         | 
| 170 | 
            -
                  subject { instance }
         | 
| 171 | 
            -
             | 
| 172 | 
            -
                  context 'with a reader method' do
         | 
| 173 | 
            -
                    context 'with no block' do
         | 
| 174 | 
            -
                      before { instance.create_method(:foo) }
         | 
| 175 | 
            -
             | 
| 176 | 
            -
                      it 'returns the stored value' do
         | 
| 177 | 
            -
                        allow(ENV).to receive(:[]).with('BAZ_FOO').and_return('123')
         | 
| 178 | 
            -
                        expect(subject.foo).to eq '123'
         | 
| 179 | 
            -
                      end
         | 
| 180 | 
            -
                    end
         | 
| 181 | 
            -
             | 
| 182 | 
            -
                    context 'with a block' do
         | 
| 183 | 
            -
                      before do
         | 
| 184 | 
            -
                        instance.create_method(:foo) { |data| YAML.load(data) }
         | 
| 185 | 
            -
                      end
         | 
| 186 | 
            -
             | 
| 187 | 
            -
                      it 'unmarshals the value' do
         | 
| 188 | 
            -
                        expect(ENV).to receive(:[]).with('BAZ_FOO')
         | 
| 189 | 
            -
                          .and_return("---\n:foo: 5\n")
         | 
| 190 | 
            -
             | 
| 191 | 
            -
                        expect(subject.foo).to eq(foo: 5)
         | 
| 192 | 
            -
                      end
         | 
| 193 | 
            -
                    end
         | 
| 194 | 
            -
                  end
         | 
| 195 | 
            -
             | 
| 196 | 
            -
                  context 'with a writer method' do
         | 
| 197 | 
            -
                    context 'with no block' do
         | 
| 198 | 
            -
                      before { instance.create_method(:foo=) }
         | 
| 199 | 
            -
             | 
| 200 | 
            -
                      it 'marshals and stores the value' do
         | 
| 201 | 
            -
                        expect(ENV).to receive(:[]=).with('BAZ_FOO', '123')
         | 
| 202 | 
            -
                        subject.foo = 123
         | 
| 203 | 
            -
                      end
         | 
| 204 | 
            -
                    end
         | 
| 205 | 
            -
             | 
| 206 | 
            -
                    context 'with a block' do
         | 
| 207 | 
            -
                      before do
         | 
| 208 | 
            -
                        instance.create_method(:foo=) { |data| YAML.dump(data) }
         | 
| 209 | 
            -
                      end
         | 
| 210 | 
            -
             | 
| 211 | 
            -
                      it 'nmarshals the value' do
         | 
| 212 | 
            -
                        expect(ENV).to receive(:[]=).with('BAZ_FOO', "---\n:foo: 5\n")
         | 
| 213 | 
            -
             | 
| 214 | 
            -
                        subject.foo = { foo: 5 }
         | 
| 215 | 
            -
                      end
         | 
| 216 | 
            -
                    end
         | 
| 217 | 
            -
                  end
         | 
| 218 | 
            -
                end
         | 
| 219 | 
            -
              end
         | 
| 220 | 
            -
            end
         | 
    
        data/spec/lib/nenv_spec.rb
    DELETED
    
    | @@ -1,66 +0,0 @@ | |
| 1 | 
            -
            require 'nenv'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            RSpec.describe Nenv do
         | 
| 4 | 
            -
              let(:env) { instance_double(Hash) } # Hash is close enough
         | 
| 5 | 
            -
              before { stub_const('ENV', env) }
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              describe 'Nenv() helper method' do
         | 
| 8 | 
            -
                it 'reads from env' do
         | 
| 9 | 
            -
                  expect(ENV).to receive(:[]).with('GIT_BROWSER').and_return('chrome')
         | 
| 10 | 
            -
                  Nenv('git').browser
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                it 'return the value from env' do
         | 
| 14 | 
            -
                  allow(ENV).to receive(:[]).with('GIT_BROWSER').and_return('firefox')
         | 
| 15 | 
            -
                  expect(Nenv('git').browser).to eq('firefox')
         | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              describe 'Nenv module' do
         | 
| 20 | 
            -
                it 'reads from env' do
         | 
| 21 | 
            -
                  expect(ENV).to receive(:[]).with('CI').and_return('true')
         | 
| 22 | 
            -
                  Nenv.ci?
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                it 'return the value from env' do
         | 
| 26 | 
            -
                  allow(ENV).to receive(:[]).with('CI').and_return('false')
         | 
| 27 | 
            -
                  expect(Nenv.ci?).to be(false)
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                context 'with no method' do
         | 
| 31 | 
            -
                  it 'automatically creates the method' do
         | 
| 32 | 
            -
                    expect(ENV).to receive(:[]).with('FOO').and_return('true')
         | 
| 33 | 
            -
                    Nenv.foo?
         | 
| 34 | 
            -
                  end
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                context 'with existing method' do
         | 
| 38 | 
            -
                  before do
         | 
| 39 | 
            -
                    Nenv.instance.create_method(:foo?)
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  it 'reads from env' do
         | 
| 43 | 
            -
                    expect(ENV).to receive(:[]).with('FOO').and_return('true')
         | 
| 44 | 
            -
                    Nenv.foo?
         | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                  it 'return the value from env' do
         | 
| 48 | 
            -
                    expect(ENV).to receive(:[]).with('FOO').and_return('true')
         | 
| 49 | 
            -
                    expect(Nenv.foo?).to be(true)
         | 
| 50 | 
            -
                  end
         | 
| 51 | 
            -
                end
         | 
| 52 | 
            -
              end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
              # Test added here to properly test if builder is required
         | 
| 55 | 
            -
              describe 'Nenv builder' do
         | 
| 56 | 
            -
                before do
         | 
| 57 | 
            -
                  allow(ENV).to receive(:[]).with('FOO').and_return('false')
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
                it 'is required and works' do
         | 
| 60 | 
            -
                  FooEnv = Nenv::Builder.build do
         | 
| 61 | 
            -
                    create_method(:foo?)
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
                  FooEnv.new.foo?
         | 
| 64 | 
            -
                end
         | 
| 65 | 
            -
              end
         | 
| 66 | 
            -
            end
         | 
    
        data/spec/spec_helper.rb
    DELETED
    
    | @@ -1,49 +0,0 @@ | |
| 1 | 
            -
            require 'coveralls'
         | 
| 2 | 
            -
            Coveralls.wear!
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            RSpec.configure do |config|
         | 
| 5 | 
            -
              config.expect_with :rspec do |expectations|
         | 
| 6 | 
            -
                expectations.include_chain_clauses_in_custom_matcher_descriptions = true
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
              config.mock_with :rspec do |mocks|
         | 
| 10 | 
            -
                mocks.verify_partial_doubles = true
         | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              config.filter_run focus: ENV['CI'] != 'true'
         | 
| 14 | 
            -
              config.run_all_when_everything_filtered = true
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              config.disable_monkey_patching!
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              # config.warnings = true
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              config.default_formatter = 'doc' if config.files_to_run.one?
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              # config.profile_examples = 10
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              config.order = :random
         | 
| 25 | 
            -
             | 
| 26 | 
            -
              Kernel.srand config.seed
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              config.before do
         | 
| 29 | 
            -
                allow(ENV).to receive(:[]) do |key|
         | 
| 30 | 
            -
                  fail "stub me: ENV[#{key.inspect}]"
         | 
| 31 | 
            -
                end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                allow(ENV).to receive(:[]=) do |key, value|
         | 
| 34 | 
            -
                  fail "stub me: ENV[#{key.inspect}] = #{value.inspect}"
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                allow(ENV).to receive(:[]).with('PRYRC').and_call_original
         | 
| 38 | 
            -
                allow(ENV).to receive(:[]).with('DISABLE_PRY').and_call_original
         | 
| 39 | 
            -
                allow(ENV).to receive(:[]).with('ANSICON').and_call_original
         | 
| 40 | 
            -
                allow(ENV).to receive(:[]).with('TERM').and_call_original
         | 
| 41 | 
            -
              end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
              config.after do
         | 
| 44 | 
            -
                begin
         | 
| 45 | 
            -
                  Nenv.method(:reset).call
         | 
| 46 | 
            -
                rescue NameError
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
            end
         |