cross_spec_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab4c26ff9701070ec54444e14a3ddeec799a7250
4
+ data.tar.gz: 56899dc926863a48ca2be4fe77f6123744375d9d
5
+ SHA512:
6
+ metadata.gz: b32ff2abfd9f033e43ae1e5dc43f490f11b0a7f50e1fe8a7ab3227e0c61bf355caecf832fcf98b2cf5a68f839de1d5c388535bd08dc531b6845e341f6287c6ab
7
+ data.tar.gz: '028cd801cbcf0798369e85c3912cd9611c7f53aa2b72ddd46940aa149ed1aca2dbaea98550a130c5387956904589a6b950061ff252291af3c859b47f4f243dfa'
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Ben Fischer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # CrossSpecRails
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ Mount the engine in your routes file like
6
+ ```
7
+ mount CrossSpecRails::Engine, at: "/cross_spec"
8
+ ```
9
+
10
+ ### Requesting factory data over http
11
+
12
+ ```
13
+ curl -X POST http://localhost:5020/cross_spec/factories/user
14
+ ```
15
+ Note the URL namespace from the routes.rb of `cross_spec` followed by the `/factories` path followed by the name of your factory.
16
+
17
+ You can also specify attributes for the factory using a query string like
18
+ ```
19
+ curl -X POST http://localhost:5020/cross_spec/factories/user?email=julie@example.com&name=Julie
20
+ ```
21
+
22
+ Traits are supported as well
23
+ ```
24
+ curl -X POST http://localhost:5020/cross_spec/factories/user?traits[]=admin&traits[]=with_articles
25
+ ```
26
+
27
+ The data doesn't have to be in the query string it can be part of the request body as well (it uses what is available in the params hash).
28
+
29
+
30
+ ## Installation
31
+ Add this line to your application's Gemfile:
32
+
33
+ ```ruby
34
+ gem 'cross_spec_rails'
35
+ ```
36
+
37
+ And then execute:
38
+ ```bash
39
+ $ bundle
40
+ ```
41
+
42
+ Or install it yourself as:
43
+ ```bash
44
+ $ gem install cross_spec_rails
45
+ ```
46
+
47
+ ## Contributing
48
+ Contribution directions go here.
49
+
50
+ ## License
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'CrossSpecRails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/cross_spec_rails .js
2
+ //= link_directory ../stylesheets/cross_spec_rails .css
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require activestorage
15
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ module CrossSpecRails
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ begin
2
+ require_dependency 'factory_girl'
3
+ FactoryGirl.find_definitions
4
+ rescue LoadError
5
+ rescue FactoryGirl::DuplicateDefinitionError
6
+ end
7
+
8
+ begin
9
+ require_dependency 'factory_bot'
10
+ FactoryBot.find_definitions
11
+ rescue LoadError
12
+ rescue FactoryBot::DuplicateDefinitionError
13
+ end
14
+
15
+ module CrossSpecRails
16
+ class FactoriesController < ApplicationController
17
+ skip_before_action :verify_authenticity_token
18
+
19
+ def create
20
+ factory = params[:factory]
21
+ traits = Array(params[:traits])
22
+ attributes = params.except(:action, :controller, :factory, :traits).permit!.to_h
23
+ render json: factory_klass.create(factory, *traits, attributes)
24
+ end
25
+
26
+ private
27
+
28
+ def factory_klass
29
+ return FactoryBot if defined? FactoryBot
30
+ return FactoryGirl if defined? FactoryGirl
31
+ raise "Unable to find a factory builder class"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module CrossSpecRails
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module CrossSpecRails
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module CrossSpecRails
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module CrossSpecRails
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Cross spec rails</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "cross_spec_rails/application", media: "all" %>
9
+ <%= javascript_include_tag "cross_spec_rails/application" %>
10
+ </head>
11
+ <body>
12
+
13
+ <%= yield %>
14
+
15
+ </body>
16
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ CrossSpecRails::Engine.routes.draw do
2
+ post 'factories/:factory', to: 'factories#create'
3
+ end
@@ -0,0 +1,5 @@
1
+ module CrossSpecRails
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace CrossSpecRails
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module CrossSpecRails
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ require "cross_spec_rails/engine"
2
+
3
+ module CrossSpecRails
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :cross_spec_rails do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cross_spec_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Fischer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cross_spec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: distributed_tracing
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Adds http endpoint for requesting factories and other goodies
56
+ email:
57
+ - bfischer@doximity.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/assets/config/cross_spec_rails_manifest.js
66
+ - app/assets/javascripts/cross_spec_rails/application.js
67
+ - app/assets/stylesheets/cross_spec_rails/application.css
68
+ - app/controllers/cross_spec_rails/application_controller.rb
69
+ - app/controllers/cross_spec_rails/factories_controller.rb
70
+ - app/helpers/cross_spec_rails/application_helper.rb
71
+ - app/jobs/cross_spec_rails/application_job.rb
72
+ - app/mailers/cross_spec_rails/application_mailer.rb
73
+ - app/models/cross_spec_rails/application_record.rb
74
+ - app/views/layouts/cross_spec_rails/application.html.erb
75
+ - config/routes.rb
76
+ - lib/cross_spec_rails.rb
77
+ - lib/cross_spec_rails/engine.rb
78
+ - lib/cross_spec_rails/version.rb
79
+ - lib/tasks/cross_spec_rails_tasks.rake
80
+ homepage: https://github.com/doximity/cross_spec_rails
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.6.14
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Intergrations for cross spec ruby and rails
104
+ test_files: []