-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
655 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
AllCops: | ||
Exclude: | ||
- 'spec/spec_helper.rb' | ||
- 'spec/rails_helper.rb' | ||
- 'spec/dummy/**/*' | ||
- 'bin/**/*' | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
Metrics/BlockLength: | ||
Exclude: | ||
- 'spec/**/*' | ||
|
||
Style/FrozenStringLiteralComment: | ||
Exclude: | ||
- 'spec/**/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM ruby:2.5 | ||
RUN apt-get update -qq | ||
RUN gem install bundler | ||
WORKDIR /app | ||
COPY Gemfile Gemfile.lock /app/ | ||
RUN bundle install | ||
COPY . /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
e2e_tests_connector (0.1.0) | ||
rails | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actioncable (6.1.3.2) | ||
actionpack (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
nio4r (~> 2.0) | ||
websocket-driver (>= 0.6.1) | ||
actionmailbox (6.1.3.2) | ||
actionpack (= 6.1.3.2) | ||
activejob (= 6.1.3.2) | ||
activerecord (= 6.1.3.2) | ||
activestorage (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
mail (>= 2.7.1) | ||
actionmailer (6.1.3.2) | ||
actionpack (= 6.1.3.2) | ||
actionview (= 6.1.3.2) | ||
activejob (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
mail (~> 2.5, >= 2.5.4) | ||
rails-dom-testing (~> 2.0) | ||
actionpack (6.1.3.2) | ||
actionview (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
rack (~> 2.0, >= 2.0.9) | ||
rack-test (>= 0.6.3) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.0, >= 1.2.0) | ||
actiontext (6.1.3.2) | ||
actionpack (= 6.1.3.2) | ||
activerecord (= 6.1.3.2) | ||
activestorage (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
nokogiri (>= 1.8.5) | ||
actionview (6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
builder (~> 3.1) | ||
erubi (~> 1.4) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.1, >= 1.2.0) | ||
activejob (6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
globalid (>= 0.3.6) | ||
activemodel (6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
activerecord (6.1.3.2) | ||
activemodel (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
activestorage (6.1.3.2) | ||
actionpack (= 6.1.3.2) | ||
activejob (= 6.1.3.2) | ||
activerecord (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
marcel (~> 1.0.0) | ||
mini_mime (~> 1.0.2) | ||
activesupport (6.1.3.2) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
zeitwerk (~> 2.3) | ||
ast (2.4.2) | ||
builder (3.2.4) | ||
byebug (11.1.3) | ||
concurrent-ruby (1.1.9) | ||
crass (1.0.6) | ||
database_cleaner-active_record (2.0.1) | ||
activerecord (>= 5.a) | ||
database_cleaner-core (~> 2.0.0) | ||
database_cleaner-core (2.0.1) | ||
diff-lcs (1.4.4) | ||
erubi (1.10.0) | ||
factory_bot (6.2.0) | ||
activesupport (>= 5.0.0) | ||
factory_bot_rails (6.2.0) | ||
factory_bot (~> 6.2.0) | ||
railties (>= 5.0.0) | ||
globalid (0.4.2) | ||
activesupport (>= 4.2.0) | ||
i18n (1.8.10) | ||
concurrent-ruby (~> 1.0) | ||
loofah (2.9.1) | ||
crass (~> 1.0.2) | ||
nokogiri (>= 1.5.9) | ||
mail (2.7.1) | ||
mini_mime (>= 0.1.1) | ||
marcel (1.0.1) | ||
method_source (1.0.0) | ||
mini_mime (1.0.3) | ||
mini_portile2 (2.5.3) | ||
minitest (5.14.4) | ||
nio4r (2.5.7) | ||
nokogiri (1.11.7) | ||
mini_portile2 (~> 2.5.0) | ||
racc (~> 1.4) | ||
parallel (1.20.1) | ||
parser (3.0.1.1) | ||
ast (~> 2.4.1) | ||
racc (1.5.2) | ||
rack (2.2.3) | ||
rack-test (1.1.0) | ||
rack (>= 1.0, < 3) | ||
rails (6.1.3.2) | ||
actioncable (= 6.1.3.2) | ||
actionmailbox (= 6.1.3.2) | ||
actionmailer (= 6.1.3.2) | ||
actionpack (= 6.1.3.2) | ||
actiontext (= 6.1.3.2) | ||
actionview (= 6.1.3.2) | ||
activejob (= 6.1.3.2) | ||
activemodel (= 6.1.3.2) | ||
activerecord (= 6.1.3.2) | ||
activestorage (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
bundler (>= 1.15.0) | ||
railties (= 6.1.3.2) | ||
sprockets-rails (>= 2.0.0) | ||
rails-dom-testing (2.0.3) | ||
activesupport (>= 4.2.0) | ||
nokogiri (>= 1.6) | ||
rails-html-sanitizer (1.3.0) | ||
loofah (~> 2.3) | ||
railties (6.1.3.2) | ||
actionpack (= 6.1.3.2) | ||
activesupport (= 6.1.3.2) | ||
method_source | ||
rake (>= 0.8.7) | ||
thor (~> 1.0) | ||
rainbow (3.0.0) | ||
rake (13.0.3) | ||
regexp_parser (2.1.1) | ||
rexml (3.2.5) | ||
rspec-core (3.10.1) | ||
rspec-support (~> 3.10.0) | ||
rspec-expectations (3.10.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-mocks (3.10.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-rails (5.0.1) | ||
actionpack (>= 5.2) | ||
activesupport (>= 5.2) | ||
railties (>= 5.2) | ||
rspec-core (~> 3.10) | ||
rspec-expectations (~> 3.10) | ||
rspec-mocks (~> 3.10) | ||
rspec-support (~> 3.10) | ||
rspec-support (3.10.2) | ||
rubocop (1.16.0) | ||
parallel (~> 1.10) | ||
parser (>= 3.0.0.0) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 1.8, < 3.0) | ||
rexml | ||
rubocop-ast (>= 1.7.0, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 1.4.0, < 3.0) | ||
rubocop-ast (1.7.0) | ||
parser (>= 3.0.1.1) | ||
ruby-progressbar (1.11.0) | ||
sprockets (4.0.2) | ||
concurrent-ruby (~> 1.0) | ||
rack (> 1, < 3) | ||
sprockets-rails (3.2.2) | ||
actionpack (>= 4.0) | ||
activesupport (>= 4.0) | ||
sprockets (>= 3.0.0) | ||
sqlite3 (1.4.2) | ||
thor (1.1.0) | ||
tzinfo (2.0.4) | ||
concurrent-ruby (~> 1.0) | ||
unicode-display_width (2.0.0) | ||
websocket-driver (0.7.4) | ||
websocket-extensions (>= 0.1.0) | ||
websocket-extensions (0.1.5) | ||
zeitwerk (2.4.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
byebug | ||
database_cleaner-active_record | ||
e2e_tests_connector! | ||
factory_bot_rails | ||
rspec-rails (~> 5.0.0) | ||
rubocop | ||
sqlite3 | ||
|
||
BUNDLED WITH | ||
2.2.19 |
44 changes: 44 additions & 0 deletions
44
app/controllers/e2e_tests_connector/connector_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
module E2eTestsConnector | ||
class ConnectorController < ApplicationController | ||
def call | ||
case params[:kind] | ||
when 'reset_db' | ||
run_reset_db | ||
when 'factory' | ||
run_factory | ||
when 'init_default_mocks' | ||
init_custom_mocks | ||
else | ||
run_command | ||
end | ||
end | ||
|
||
private | ||
|
||
def single_command? | ||
params[:commands].is_a?(String) | ||
end | ||
|
||
def run_reset_db | ||
E2eTestsConnector::Config.reset_db.call(params) | ||
render json: { res: nil } | ||
end | ||
|
||
def run_factory | ||
res = E2eTestsConnector::Config.run_factory.call(params) | ||
render json: { res: single_command? ? res.first : res } | ||
end | ||
|
||
def run_command | ||
res = Array(params[:commands]).map { |cmd| eval(cmd) } # rubocop:disable Security/Eval | ||
render json: { res: single_command? ? res.first : res } | ||
end | ||
|
||
def init_custom_mocks | ||
E2eTestsConnector::Config.init_custom_mocks.call(params) | ||
render json: { res: nil } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '2' | ||
|
||
services: | ||
test: | ||
build: . | ||
command: sh -c 'bundle exec rspec' | ||
volumes: | ||
- .:/app | ||
- bundler_gems:/usr/local/bundle/ | ||
|
||
volumes: | ||
bundler_gems: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rspec/rails' if defined?(RSpec) | ||
require './spec/rails_helper' if defined?(RSpec) | ||
require 'database_cleaner/active_record' if defined?(DatabaseCleaner) | ||
|
||
module E2eTestsConnector | ||
class Config | ||
# By default void | ||
# @return nil | ||
cattr_accessor :init_custom_mocks do | ||
lambda do |_params| | ||
end | ||
end | ||
|
||
# By default using database cleaner | ||
# @return nil | ||
cattr_accessor :reset_db do | ||
lambda do |_params| | ||
DatabaseCleaner.strategy = :truncation | ||
DatabaseCleaner.clean | ||
end | ||
end | ||
|
||
# By default using factory bot | ||
# @return (Array<ActiveRecord>) | ||
cattr_accessor :run_factory do | ||
lambda do |params| | ||
Array(params[:commands]).map do |cmd| | ||
FactoryBot.class_eval(cmd).as_json(params[:jsonArgs]) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.