Skip to content

Commit 5083ea2

Browse files
committed
getting the dummy rails app in spec
1 parent fad65be commit 5083ea2

31 files changed

+323
-4
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
pkg
44
doc
55
Gemfile.lock
6-
dummy
76
searchkit-builds/node_modules
87
searchkit-builds/build

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#!/usr/bin/env rake
12
require 'bundler/gem_tasks'
3+
require 'rspec/core'
24
require 'rspec/core/rake_task'
35

46
def copy_searchkit_asset(webpack_file, destination_file)

searchkit-rails.gemspec

+14-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,25 @@ Gem::Specification.new do |s|
2121
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
2222
s.require_paths = ['lib']
2323

24+
s.add_runtime_dependency 'sass', '>= 3.3.4'
25+
2426
s.add_dependency 'rails', '>= 4.2'
2527
s.add_dependency 'react-rails', '>= 1.7'
2628

29+
# Standard dependencies
2730
s.add_development_dependency('bundler')
2831
s.add_development_dependency('rake')
29-
s.add_development_dependency('rspec', '~> 3.4')
32+
s.add_development_dependency('rspec-rails')
33+
s.add_development_dependency('capybara')
34+
s.add_development_dependency('factory_girl_rails')
3035
s.add_development_dependency('pry-byebug', '~>3.3.0')
36+
37+
# Dummy Rails app dependencies
38+
s.add_development_dependency 'actionpack', '>= 4.1.5'
39+
s.add_development_dependency 'activesupport', '>= 4.1.5'
40+
s.add_development_dependency 'json', '>= 1.8.1'
41+
s.add_development_dependency 'sprockets-rails', '>= 2.1.3'
42+
s.add_development_dependency 'slim-rails'
43+
s.add_development_dependency 'uglifier'
3144
end
3245

spec/dummy/README.rdoc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
== README
2+
3+
This is a minimal Rails app for testing

spec/dummy/Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -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+
Dummy::Application.load_tasks

spec/dummy/app/assets/images/.keep

Whitespace-only changes.

spec/dummy/app/assets/javascripts/application.js

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import 'bootstrap-sprockets'
2+
@import 'bootstrap'
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Dummy Rails App</title>
5+
<%= stylesheet_link_tag 'application', media: "all", 'data-turbolinks-track' => true %>
6+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7+
<%= csrf_meta_tags %>
8+
</head>
9+
10+
<body>
11+
<%= yield %>
12+
</body>
13+
14+
</html>

spec/dummy/config.ru

+4
Original file line numberDiff line numberDiff line change
@@ -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

spec/dummy/config/application.rb

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require File.expand_path('../boot', __FILE__)
2+
3+
require 'rails'
4+
5+
%w(
6+
action_controller
7+
action_view
8+
sprockets
9+
).each do |framework|
10+
require "#{framework}/railtie"
11+
end
12+
13+
require 'slim-rails'
14+
require 'uglifier'
15+
16+
module Dummy
17+
class Application < Rails::Application
18+
config.assets.enabled = true if config.assets.respond_to?(:enabled)
19+
config.assets.precompile += %w( application.css application.js )
20+
config.to_prepare do
21+
if ENV['VERBOSE']
22+
STDERR.puts "Loaded Rails #{Rails::VERSION::STRING}, Sprockets #{Sprockets::VERSION}",
23+
"Asset paths: #{Rails.application.config.assets.paths}"
24+
end
25+
end
26+
end
27+
end
28+

spec/dummy/config/boot.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Set up gems listed in the Gemfile.
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3+
4+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5+
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)

spec/dummy/config/environment.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Load the Rails application.
2+
require File.expand_path('../application', __FILE__)
3+
4+
# Initialize the Rails application.
5+
Dummy::Application.initialize!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Dummy::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+
# Print deprecation notices to the Rails logger.
17+
config.active_support.deprecation = :log
18+
19+
# Debug mode disables concatenation and preprocessing of assets.
20+
# This option may cause significant delays in view rendering with a large
21+
# number of complex assets.
22+
config.assets.debug = true
23+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Dummy::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 thread 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+
if config.respond_to?(:serve_static_files)
24+
# rails >= 4.2
25+
config.serve_static_files = true
26+
elsif config.respond_to?(:serve_static_assets)
27+
# rails < 4.2
28+
config.serve_static_assets = true
29+
end
30+
31+
# Compress JavaScripts and CSS.
32+
config.assets.js_compressor = :uglifier
33+
# config.assets.css_compressor = :sass
34+
35+
# Do not fallback to assets pipeline if a precompiled asset is missed.
36+
config.assets.compile = false
37+
38+
# Generate digests for assets URLs.
39+
config.assets.digest = true
40+
41+
# Version of your assets, change this if you want to expire all your assets.
42+
config.assets.version = '1.0'
43+
44+
# Specifies the header that your server uses for sending files.
45+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
46+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
47+
48+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
49+
# config.force_ssl = true
50+
51+
# Set to :debug to see everything in the log.
52+
config.log_level = :info
53+
54+
# Prepend all log lines with the following tags.
55+
# config.log_tags = [ :subdomain, :uuid ]
56+
57+
# Use a different logger for distributed setups.
58+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
59+
60+
# Use a different cache store in production.
61+
# config.cache_store = :mem_cache_store
62+
63+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
64+
# config.action_controller.asset_host = "http://assets.example.com"
65+
66+
# Precompile additional assets.
67+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
68+
# config.assets.precompile += %w( search.js )
69+
70+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
71+
# the I18n.default_locale when a translation can not be found).
72+
config.i18n.fallbacks = true
73+
74+
# Send deprecation notices to registered listeners.
75+
config.active_support.deprecation = :notify
76+
77+
# Disable automatic flushing of the log to improve performance.
78+
# config.autoflush_log = false
79+
80+
# Use default logging formatter so that PID and timestamp are not suppressed.
81+
config.log_formatter = ::Logger::Formatter.new
82+
end
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Dummy::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+
if config.respond_to?(:serve_static_files)
17+
# rails >= 4.2
18+
config.serve_static_files = true
19+
elsif config.respond_to?(:serve_static_assets)
20+
# rails < 4.2
21+
config.serve_static_assets = true
22+
end
23+
config.static_cache_control = "public, max-age=3600"
24+
25+
# Show full error reports and disable caching.
26+
config.consider_all_requests_local = true
27+
config.action_controller.perform_caching = false
28+
29+
# Raise exceptions instead of rendering exception templates.
30+
config.action_dispatch.show_exceptions = false
31+
32+
# Disable request forgery protection in test environment.
33+
config.action_controller.allow_forgery_protection = false
34+
35+
config.active_support.test_order = :random
36+
37+
config.active_support.deprecation = :stderr
38+
end
Original file line numberDiff line numberDiff line change
@@ -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!
Original file line numberDiff line numberDiff line change
@@ -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]
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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
5+
# Mime::Type.register_alias "text/html", :iphone
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 your secret_key_base is kept private
11+
# if you're sharing your code publicly.
12+
token = '4380f36fda304251bf48f12ad4474b6d11447f1f959bd5b77a5d56c92b97f4c403ee0ae13d31a85ed88058ff8795bf31ec17e70e5c229b3707a77a2ee7e81cc'
13+
14+
if Dummy::Application.config.respond_to?(:secret_key_base=)
15+
Dummy::Application.config.secret_key_base = token
16+
else
17+
Dummy::Application.config.secret_token = token
18+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
Original file line numberDiff line numberDiff line change
@@ -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

spec/dummy/config/locales/en.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
en:
2+
dummy:
3+
hello: Hello

spec/dummy/config/locales/es.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
es:
2+
dummy:
3+
hello: Hola

spec/dummy/config/routes.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Dummy::Application.routes.draw do
2+
root to: 'pages#root'
3+
end

spec/dummy/log/.keep

Whitespace-only changes.

spec/dummy/log/test.log

Whitespace-only changes.

spec/spec_helper.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
require 'rubygems'
2-
require 'rspec'
1+
ENV['RAILS_ENV'] ||= 'test'
2+
3+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
4+
require 'rspec/rails'
5+
require 'factory_girl_rails'
36
require 'pathname'
47
require 'pry-byebug'
58

9+
Rails.backtrace_cleaner.remove_silencers!
10+
11+
# Load support files
12+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
13+
614
ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
715
$LOAD_PATH << File.join(ROOT, 'lib')
816
$LOAD_PATH << File.join(ROOT, 'lib', 'searchkit')
917
require File.join(ROOT, 'lib', 'searchkit-rails.rb')
1018

1119
RSpec.configure do |config|
20+
config.mock_with :rspec
21+
config.use_transactional_fixtures = true
22+
config.infer_base_class_for_anonymous_controllers = false
23+
config.order = "random"
1224
end

0 commit comments

Comments
 (0)