frigate 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +7 -0
  5. data/Gemfile +10 -0
  6. data/Guardfile +67 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +31 -0
  9. data/Rakefile +13 -0
  10. data/frigate.gemspec +31 -0
  11. data/lib/frigate/form/association.rb +94 -0
  12. data/lib/frigate/form/base.rb +141 -0
  13. data/lib/frigate/form/property.rb +40 -0
  14. data/lib/frigate/form/synchronizer/base.rb +22 -0
  15. data/lib/frigate/form/synchronizer/basic.rb +75 -0
  16. data/lib/frigate/form/synchronizer/contract.rb +46 -0
  17. data/lib/frigate/form/synchronizer/form.rb +40 -0
  18. data/lib/frigate/form/synchronizer/fundamental.rb +17 -0
  19. data/lib/frigate/form/synchronizer.rb +14 -0
  20. data/lib/frigate/form.rb +16 -0
  21. data/lib/frigate/function.rb +41 -0
  22. data/lib/frigate/operation/action/base.rb +65 -0
  23. data/lib/frigate/operation/action/create.rb +21 -0
  24. data/lib/frigate/operation/action/update.rb +24 -0
  25. data/lib/frigate/operation/action.rb +12 -0
  26. data/lib/frigate/operation/base.rb +79 -0
  27. data/lib/frigate/operation/controller.rb +42 -0
  28. data/lib/frigate/operation/invalid_params_error.rb +7 -0
  29. data/lib/frigate/operation/renderable.rb +52 -0
  30. data/lib/frigate/operation/worker.rb +50 -0
  31. data/lib/frigate/operation.rb +16 -0
  32. data/lib/frigate/version.rb +3 -0
  33. data/lib/frigate.rb +61 -0
  34. data/spec/fixtures/user_form.rb +34 -0
  35. data/spec/frigate/form/base_spec.rb +120 -0
  36. data/spec/frigate/operation/base_spec.rb +52 -0
  37. data/spec/rails_test_app/Rakefile +6 -0
  38. data/spec/rails_test_app/app/controllers/application_controller.rb +5 -0
  39. data/spec/rails_test_app/app/helpers/application_helper.rb +2 -0
  40. data/spec/rails_test_app/app/models/user/profile/passport.rb +5 -0
  41. data/spec/rails_test_app/app/models/user/profile.rb +6 -0
  42. data/spec/rails_test_app/app/models/user.rb +5 -0
  43. data/spec/rails_test_app/bin/bundle +3 -0
  44. data/spec/rails_test_app/bin/rails +4 -0
  45. data/spec/rails_test_app/bin/rake +4 -0
  46. data/spec/rails_test_app/config/application.rb +30 -0
  47. data/spec/rails_test_app/config/boot.rb +4 -0
  48. data/spec/rails_test_app/config/database.yml +25 -0
  49. data/spec/rails_test_app/config/environment.rb +5 -0
  50. data/spec/rails_test_app/config/environments/development.rb +28 -0
  51. data/spec/rails_test_app/config/environments/production.rb +67 -0
  52. data/spec/rails_test_app/config/environments/test.rb +39 -0
  53. data/spec/rails_test_app/config/initializers/backtrace_silencers.rb +7 -0
  54. data/spec/rails_test_app/config/initializers/cookies_serializer.rb +3 -0
  55. data/spec/rails_test_app/config/initializers/filter_parameter_logging.rb +4 -0
  56. data/spec/rails_test_app/config/initializers/inflections.rb +16 -0
  57. data/spec/rails_test_app/config/initializers/mime_types.rb +4 -0
  58. data/spec/rails_test_app/config/initializers/session_store.rb +3 -0
  59. data/spec/rails_test_app/config/initializers/wrap_parameters.rb +14 -0
  60. data/spec/rails_test_app/config/locales/en.yml +23 -0
  61. data/spec/rails_test_app/config/routes.rb +56 -0
  62. data/spec/rails_test_app/config/secrets.yml +22 -0
  63. data/spec/rails_test_app/config.ru +4 -0
  64. data/spec/rails_test_app/db/migrate/20141212054646_create_users.rb +10 -0
  65. data/spec/rails_test_app/db/migrate/20141212054746_create_user_profiles.rb +10 -0
  66. data/spec/rails_test_app/db/migrate/20141212054847_create_user_profile_passports.rb +15 -0
  67. data/spec/rails_test_app/db/seeds.rb +7 -0
  68. data/spec/spec_helper.rb +84 -0
  69. metadata +217 -0
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Frigate::Operation::Base do
4
+
5
+ context 'action:update' do
6
+ class UserUpdate < Frigate::Operation::Base
7
+ model User
8
+ action :update
9
+ property :email, validates: { presence: true }
10
+ end
11
+
12
+ let(:params) { { email: 'johndoe@gmail.com' } }
13
+ let(:invalid_params) { {} }
14
+
15
+ context '.run' do
16
+ before(:example) do
17
+ @user = User.create(email: 'smth@email.coms')
18
+ end
19
+ it 'updates user' do
20
+ UserUpdate.run(params.merge({ id: @user.id }))
21
+ user = User.first
22
+ expect(user.email).to eq(params[:email])
23
+ end
24
+ context 'raises' do
25
+ it 'params invalid error' do
26
+ expect {
27
+ UserUpdate.run(invalid_params.merge({ id: @user.id }))
28
+ }.to raise_error(Frigate::Operation::InvalidParamsError)
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ context 'action:create' do
35
+ class UserCreate < Frigate::Operation::Base
36
+ model User
37
+ action :create
38
+ property :email, validates: { presence: true }
39
+ end
40
+
41
+ let(:params) { { email: 'johndoe@gmail.com' } }
42
+
43
+ context '.run' do
44
+ it 'creates user' do
45
+ UserCreate.run(params)
46
+ user = User.first
47
+ expect(user.email).to eq(params[:email])
48
+ end
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,5 @@
1
+ class User::Profile::Passport < ActiveRecord::Base
2
+ belongs_to :user_profile, class_name: 'User::Profile'
3
+
4
+ alias_method :profile, :user_profile
5
+ end
@@ -0,0 +1,6 @@
1
+ class User::Profile < ActiveRecord::Base
2
+ belongs_to :user
3
+ has_one :user_profile_passport, class_name: 'User::Profile::Passport'
4
+
5
+ alias_method :passport, :user_profile_passport
6
+ end
@@ -0,0 +1,5 @@
1
+ class User < ActiveRecord::Base
2
+ has_one :user_profile, class_name: 'User::Profile'
3
+
4
+ alias_method :profile, :user_profile
5
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,30 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_model/railtie"
5
+ require "active_record/railtie"
6
+ require "action_controller/railtie"
7
+ require "action_mailer/railtie"
8
+ # require "action_view/railtie"
9
+ # require "sprockets/railtie"
10
+ require "rails/test_unit/railtie"
11
+
12
+ # Require the gems listed in Gemfile, including any gems
13
+ # you've limited to :test, :development, or :production.
14
+ Bundler.require(*Rails.groups)
15
+
16
+ module RailsTestApp
17
+ class Application < Rails::Application
18
+ # Settings in config/environments/* take precedence over those specified here.
19
+ # Application configuration should go into files in config/initializers
20
+ # -- all .rb files in that directory are automatically loaded.
21
+
22
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
23
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
24
+ # config.time_zone = 'Central Time (US & Canada)'
25
+
26
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
27
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
28
+ # config.i18n.default_locale = :de
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,28 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
+
25
+
26
+ # Raises error for missing translations
27
+ # config.action_view.raise_on_missing_translations = true
28
+ end
@@ -0,0 +1,67 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+
26
+ # Specifies the header that your server uses for sending files.
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # Set to :debug to see everything in the log.
34
+ config.log_level = :info
35
+
36
+ # Prepend all log lines with the following tags.
37
+ # config.log_tags = [ :subdomain, :uuid ]
38
+
39
+ # Use a different logger for distributed setups.
40
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
+
42
+ # Use a different cache store in production.
43
+ # config.cache_store = :mem_cache_store
44
+
45
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
46
+ # config.action_controller.asset_host = "http://assets.example.com"
47
+
48
+ # Ignore bad email addresses and do not raise email delivery errors.
49
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
50
+ # config.action_mailer.raise_delivery_errors = false
51
+
52
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
53
+ # the I18n.default_locale when a translation cannot be found).
54
+ config.i18n.fallbacks = true
55
+
56
+ # Send deprecation notices to registered listeners.
57
+ config.active_support.deprecation = :notify
58
+
59
+ # Disable automatic flushing of the log to improve performance.
60
+ # config.autoflush_log = false
61
+
62
+ # Use default logging formatter so that PID and timestamp are not suppressed.
63
+ config.log_formatter = ::Logger::Formatter.new
64
+
65
+ # Do not dump schema after migrations.
66
+ config.active_record.dump_schema_after_migration = false
67
+ end
@@ -0,0 +1,39 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = 'public, max-age=3600'
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+
37
+ # Raises error for missing translations
38
+ # config.action_view.raise_on_missing_translations = true
39
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_rails_test_app_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,56 @@
1
+ Rails.application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 867c9691bfccba8858a6f6c919f8432699289a3afda4c6dbaee48f534c785cb691f478c61bed56f7e3c57fbf3d3e8d9f3954649fca3adcce4440143132561890
15
+
16
+ test:
17
+ secret_key_base: 983046a3af7b59b998eeb196195b9707d3b17bd163a64fe6142ac272f9c8e84d84c4efde8d057cf15452ea9a51249ff9a1ba6366381b3ab99a4963543d41ba33
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,10 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :email
5
+ t.string :encrypted_password
6
+ end
7
+
8
+ add_index :users, :email, unique: true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateUserProfiles < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_profiles do |t|
4
+ t.integer :user_id
5
+ t.string :first_name
6
+ t.string :last_name
7
+ t.string :skype
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ class CreateUserProfilePassports < ActiveRecord::Migration
2
+ def up
3
+ create_table :user_profile_passports do |t|
4
+ t.integer :profile_id
5
+ t.string :number
6
+ t.string :country
7
+ t.string :city
8
+ t.datetime :given_at
9
+ end
10
+ end
11
+
12
+ def down
13
+ drop_table :user_profile_passports
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -0,0 +1,84 @@
1
+ require 'frigate'
2
+ Bundler.require(:default)
3
+
4
+ Dir[File.join(Dir.pwd, 'spec/fixtures/**/*.rb')].each { |f| require f }
5
+
6
+ require File.expand_path('../rails_test_app/config/environment', __FILE__)
7
+
8
+ silence_stream(STDOUT) do
9
+ ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
10
+ ActiveRecord::Migrator.migrate File.expand_path('../rails_test_app/db/migrate/', __FILE__)
11
+ end
12
+
13
+ RSpec.configure do |config|
14
+ # The settings below are suggested to provide a good initial experience
15
+ # with RSpec, but feel free to customize to your heart's content.
16
+
17
+ # These two settings work together to allow you to limit a spec run
18
+ # to individual examples or groups you care about by tagging them with
19
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
20
+ # get run.
21
+ config.filter_run :focus
22
+ config.run_all_when_everything_filtered = true
23
+
24
+ # Many RSpec users commonly either run the entire suite or an individual
25
+ # file, and it's useful to allow more verbose output when running an
26
+ # individual spec file.
27
+ if config.files_to_run.one?
28
+ config.full_backtrace = true
29
+
30
+ # Use the documentation formatter for detailed output,
31
+ # unless a formatter has already been configured
32
+ # (e.g. via a command-line flag).
33
+ config.default_formatter = 'doc'
34
+ else
35
+ config.full_backtrace = false
36
+ end
37
+
38
+ # Run specs in random order to surface order dependencies. If you find an
39
+ # order dependency and want to debug it, you can fix the order by providing
40
+ # the seed, which is printed after each run.
41
+ # --seed 1234
42
+ config.order = :random
43
+
44
+ # Seed global randomization in this process using the `--seed` CLI option.
45
+ # Setting this allows you to use `--seed` to deterministically reproduce
46
+ # test failures related to randomization by passing the same `--seed` value
47
+ # as the one that triggered the failure.
48
+ Kernel.srand config.seed
49
+
50
+ # rspec-expectations config goes here. You can use an alternate
51
+ # assertion/expectation library such as wrong or the stdlib/minitest
52
+ # assertions if you prefer.
53
+ config.expect_with :rspec do |expectations|
54
+ # Enable only the newer, non-monkey-patching expect syntax.
55
+ # For more details, see:
56
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57
+ expectations.syntax = :expect
58
+ end
59
+
60
+ # rspec-mocks config goes here. You can use an alternate test double
61
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
62
+ config.mock_with :rspec do |mocks|
63
+ # Enable only the newer, non-monkey-patching expect syntax.
64
+ # For more details, see:
65
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ mocks.syntax = :expect
67
+
68
+ # Prevents you from mocking or stubbing a method that does not exist on
69
+ # a real object. This is generally recommended.
70
+ mocks.verify_partial_doubles = true
71
+ mocks.verify_doubled_constant_names = true
72
+ end
73
+
74
+ config.before(:suite) do
75
+ DatabaseCleaner.strategy = :transaction
76
+ DatabaseCleaner.clean_with(:truncation)
77
+ end
78
+
79
+ config.around(:each) do |example|
80
+ DatabaseCleaner.cleaning do
81
+ example.run
82
+ end
83
+ end
84
+ end