From 6efe391364383936d8c1df9645a3ea0d372dded3 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 28 Sep 2017 16:19:12 -0400 Subject: [PATCH 1/5] Initial setup for Project --- .rubocop.yml | 4 ++ .rubocop_todo.yml | 7 +++ Gemfile | 11 +++++ Gemfile.lock | 69 ++++++++++++++++++++++++++++ features/step_definitions/.gitignore | 0 features/support/env.rb | 0 6 files changed, 91 insertions(+) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 features/step_definitions/.gitignore create mode 100644 features/support/env.rb 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..921ad78 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,7 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2017-09-28 16:03:29 -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..083179d --- /dev/null +++ b/Gemfile @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } + +gem 'cucumber' +gem 'faraday' +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..a97a406 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,69 @@ +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) + 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) + 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 + 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..e69de29 From 7f2aa39dcac60e60cee48cbbe56e3f2c65506840 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 28 Sep 2017 19:31:04 -0400 Subject: [PATCH 2/5] Adding Json Spec --- .rubocop_todo.yml | 2 +- Gemfile | 1 + Gemfile.lock | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 921ad78..9a9ca6b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-09-28 16:03:29 -0400 using RuboCop version 0.50.0. +# 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 diff --git a/Gemfile b/Gemfile index 083179d..6c7b0d8 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } gem 'cucumber' gem 'faraday' +gem 'json_spec' gem 'report_builder' gem 'rspec' gem 'rubocop', '~> 0.50.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index a97a406..7b32cd7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,6 +19,9 @@ GEM 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) @@ -61,6 +64,7 @@ PLATFORMS DEPENDENCIES cucumber faraday + json_spec report_builder rspec rubocop (~> 0.50.0) From e13bbb39f2b38fcc7693a4fa5d75c02700278092 Mon Sep 17 00:00:00 2001 From: Abel Date: Mon, 2 Oct 2017 10:43:30 -0400 Subject: [PATCH 3/5] Adding conversion to JSON --- features/support/utils/response_manager.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 features/support/utils/response_manager.rb 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 From 4653a74d96e0571ad02758ec3f587cd3c4ed77b5 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 2 Oct 2017 16:40:46 +0000 Subject: [PATCH 4/5] ENV.YML and After Configuration --- features/support/env.rb | 43 ++++++++++++++++++++++++++++++++ features/support/env.yml | 12 +++++++++ features/support/env_yml.example | 12 +++++++++ 3 files changed, 67 insertions(+) create mode 100644 features/support/env.yml create mode 100644 features/support/env_yml.example diff --git a/features/support/env.rb b/features/support/env.rb index e69de29..96e6e6f 100644 --- a/features/support/env.rb +++ 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 From c3b2924878c86999321378428f1449dd5355337c Mon Sep 17 00:00:00 2001 From: yuryver Date: Mon, 2 Oct 2017 14:54:11 -0400 Subject: [PATCH 5/5] base for conect to database --- Gemfile | 2 ++ Gemfile.lock | 3 +++ features/support/utils/database_manager.rb | 11 +++++++++++ 3 files changed, 16 insertions(+) create mode 100644 features/support/utils/database_manager.rb diff --git a/Gemfile b/Gemfile index 6c7b0d8..50ef81d 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,9 @@ 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 index 7b32cd7..3443c6b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM 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 @@ -64,7 +65,9 @@ PLATFORMS DEPENDENCIES cucumber faraday + json json_spec + pg report_builder rspec rubocop (~> 0.50.0) 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