Pārlūkot izejas kodu

setup som ebasic tests

Chris Mague 7 gadi atpakaļ
vecāks
revīzija
f904c7b0ef
4 mainītis faili ar 34 papildinājumiem un 1 dzēšanām
  1. 1 0
      Gemfile
  2. 8 1
      Rakefile
  3. 4 0
      lib/neoinfra/config.rb
  4. 21 0
      spec/config_spec.rb

+ 1 - 0
Gemfile

@@ -4,6 +4,7 @@ source 'http://rubygems.org'
 
 gem 'fog'
 gem 'neo4j', '7.2.0'
+gem 'rspec'
 gem 'rubytree'
 
 group :development do

+ 8 - 1
Rakefile

@@ -3,9 +3,16 @@
 task default: :full_test
 
 require 'rubocop/rake_task'
+require 'rake'
+require 'rspec/core/rake_task'
 
 RuboCop::RakeTask.new(:rubocop) do |t|
   t.options = ['--display-cop-names']
 end
 
-task full_test: [:rubocop]
+RSpec::Core::RakeTask.new(:spec) do |t|
+  t.pattern = Dir.glob('spec/*_spec.rb')
+  t.rspec_opts = '--format documentation'
+end
+
+task full_test: %i[rubocop spec]

+ 4 - 0
lib/neoinfra/config.rb

@@ -15,6 +15,10 @@ module NeoInfra
       )
     end
 
+    def neo4j
+      @config['neo4j']
+    end
+
     def accounts
       @config['accounts']
     end

+ 21 - 0
spec/config_spec.rb

@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib')
+$LOAD_PATH.unshift(lib_dir) unless
+  $LOAD_PATH.include?(lib_dir) || $LOAD_PATH.include?(lib_dir)
+
+require 'neoinfra/config'
+
+describe NeoInfra do
+  before(:each) do
+    @test_config = NeoInfra::Config.new('config.yaml.example')
+  end
+
+  it 'loads test accounts' do
+    expect(@test_config.accounts.length).to eql(1)
+  end
+
+  it 'neo4j default host is set' do
+    expect(@test_config.neo4j[:host]).to eql('localhost')
+  end
+end