diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..5b7814e --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,4 @@ +inherit_from: .rubocop_todo.yml + +Layout/EndOfLine: + EnforcedStyle: lf diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..9a9ca6b --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,7 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2017-09-28 18:58:27 -0400 using RuboCop version 0.50.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..50ef81d --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } + +gem 'cucumber' +gem 'faraday' +gem 'json' +gem 'json_spec' +gem 'pg' +gem 'report_builder' +gem 'rspec' +gem 'rubocop', '~> 0.50.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..3443c6b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,76 @@ +GEM + remote: https://rubygems.org/ + specs: + ast (2.3.0) + builder (3.2.3) + cucumber (2.4.0) + builder (>= 2.1.2) + cucumber-core (~> 1.5.0) + cucumber-wire (~> 0.0.1) + diff-lcs (>= 1.1.3) + gherkin (~> 4.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (1.5.0) + gherkin (~> 4.0) + cucumber-wire (0.0.1) + diff-lcs (1.3) + faraday (0.13.1) + multipart-post (>= 1.2, < 3) + gherkin (4.1.3) + json (2.0.2) + json_spec (1.1.5) + multi_json (~> 1.0) + rspec (>= 2.0, < 4.0) + multi_json (1.12.2) + multi_test (0.1.2) + multipart-post (2.0.0) + parallel (1.12.0) + parser (2.4.0.0) + ast (~> 2.2) + pg (0.21.0-x64-mingw32) + powerpack (0.1.1) + rainbow (2.2.2) + rake + rake (12.1.0) + report_builder (0.1.6) + builder (~> 3.2, >= 3.2.2) + json (>= 1.8.1) + rspec (3.6.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) + rubocop (0.50.0) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.9.0) + unicode-display_width (1.3.0) + +PLATFORMS + x64-mingw32 + +DEPENDENCIES + cucumber + faraday + json + json_spec + pg + report_builder + rspec + rubocop (~> 0.50.0) + +BUNDLED WITH + 1.15.4 diff --git a/features/step_definitions/.gitignore b/features/step_definitions/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..96e6e6f --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,43 @@ +require 'pathname' +require 'yaml' + +def find_config_file(filename) + root = Pathname.pwd + until root.root? + root.find do |path| + return path.to_s if path.file? && path.basename.to_s == filename + end + root = root.parent + end + raise 'Configuration file ' +end + +def load_app_config_file(filename) + config_file = find_config_file(filename) + config = YAML.load_file(config_file) + $app_context = config['app']['rootPath'] + config +end + +def load_bd_config_file(filename) + config_file = find_config_file(filename) + config_bd = YAML.load_file(config_file) + $bd_context = config_bd['database']['connection'] + config_bd +end + +AfterConfiguration do + # read config file + configuration = load_app_config_file('env.yml') + configuration_bd = load_bd_config_file('env.yml') + # Load application configuration parameters + $app_host = configuration['app']['host'] + $app_port = configuration['app']['port'] + $app_root = configuration['app']['rootPath'] + $bd_connection = configuration_bd['database']['connection'] + $bd_host = configuration_bd['database']['host'] + $bd_port = configuration_bd['database']['port'] + $bd_database = configuration_bd['database']['database'] + $bd_username = configuration_bd['database']['username'] + $bd_password = configuration_bd['database']['password'] +end diff --git a/features/support/env.yml b/features/support/env.yml new file mode 100644 index 0000000..7c5eb22 --- /dev/null +++ b/features/support/env.yml @@ -0,0 +1,12 @@ +app: + host: + port: + rootPath: + +database: + connection: + host: + port: + database: + username: + password: \ No newline at end of file diff --git a/features/support/env_yml.example b/features/support/env_yml.example new file mode 100644 index 0000000..5bb807b --- /dev/null +++ b/features/support/env_yml.example @@ -0,0 +1,12 @@ +app: + host: http://12.43.3.94 + port: 8080 + rootPath: /api/v2 + +database: + connection: postgres + host: 127.0.0.1 + port: 3306 + database: home + username: username + password: secret \ No newline at end of file diff --git a/features/support/utils/database_manager.rb b/features/support/utils/database_manager.rb new file mode 100644 index 0000000..84d8be2 --- /dev/null +++ b/features/support/utils/database_manager.rb @@ -0,0 +1,11 @@ +require 'pg' +# Conect to Database +module DatabaseManager + def self.conn + PG.connect host: $bd_host, + port: $bd_port, + dbname: $bd_database, + user: $bd_username, + password: $bd_password + end +end diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb new file mode 100644 index 0000000..d41b4d4 --- /dev/null +++ b/features/support/utils/response_manager.rb @@ -0,0 +1,12 @@ +require 'json' + +# Manage the conversion of hashes and string to json +module ResponseManager + def hash_to_json(hash) + hash.to_json + end + + def string_to_json(string) + JSON.parse string + end +end