Skip to content

Commit bdb70ba

Browse files
committed
Install testing libraries
* RSpec * Combustion for dummy app generation * Capybara/Poltergeist for end to end testing
1 parent f35b036 commit bdb70ba

File tree

15 files changed

+155
-1
lines changed

15 files changed

+155
-1
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
.bundle
12
.ruby-version
23
.ruby-gemset
34
Gemfile.lock
45
/pkg/*
6+
/spec/internal/tmp
7+
/spec/internal/db/*.sqlite
8+
/spec/examples.txt

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require spec_helper

activeadmin-select2.gemspec

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ Gem::Specification.new do |spec|
1919

2020
spec.add_development_dependency "bundler", "~> 1.5"
2121
spec.add_development_dependency "rake"
22+
spec.add_development_dependency 'rspec-rails', '~> 3.6'
23+
spec.add_development_dependency 'combustion', '~> 0.7.0'
24+
spec.add_development_dependency 'database_cleaner', '~> 1.6'
25+
spec.add_development_dependency 'sqlite3', '~> 1.3'
26+
spec.add_development_dependency 'capybara', '~> 2.15'
27+
spec.add_development_dependency 'poltergeist', '~> 1.15'
28+
spec.add_development_dependency 'rails'
2229

2330
spec.add_runtime_dependency 'activeadmin'
2431
spec.add_runtime_dependency 'jquery-rails'
2532
spec.add_runtime_dependency 'select2-rails'
26-
2733
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//= require active_admin/base
2+
//= require active_admin/select2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "active_admin/mixins";
2+
@import "active_admin/base";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class ApplicationController < ActionController::Base
2+
cattr_accessor :current_user
3+
4+
helper_method :current_user
5+
end

spec/internal/config/database.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test:
2+
adapter: sqlite3
3+
database: db/combustion_test.sqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Rails.application.config.assets.precompile += %w(active_admin.js active_admin.css active_admin/print.css)

spec/internal/config/routes.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Rails.application.routes.draw do
2+
ActiveAdmin.routes(self)
3+
end

spec/internal/db/schema.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ActiveRecord::Schema.define do
2+
create_table(:active_admin_comments, force: true) do |t|
3+
t.string :namespace
4+
t.text :body
5+
t.string :resource_id, null: false
6+
t.string :resource_type, null: false
7+
t.references :author, polymorphic: true
8+
t.timestamps null: false
9+
end
10+
end

spec/internal/log/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.log

spec/internal/public/favicon.ico

Whitespace-only changes.

spec/rails_helper.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ENV['RAILS_ENV'] ||= 'test'
2+
3+
require 'combustion'
4+
Combustion.initialize!(:active_record, :action_controller, :action_view, :sprockets)
5+
6+
require 'rspec/rails'
7+
8+
RSpec.configure do |config|
9+
config.infer_spec_type_from_file_location!
10+
11+
config.filter_rails_from_backtrace!
12+
end

spec/spec_helper.rb

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# This file was generated by the `rspec --init` command. Conventionally, all
2+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3+
# The generated `.rspec` file contains `--require spec_helper` which will cause
4+
# this file to always be loaded, without a need to explicitly require it in any
5+
# files.
6+
#
7+
# Given that it is always loaded, you are encouraged to keep this file as
8+
# light-weight as possible. Requiring heavyweight dependencies from this file
9+
# will add to the boot time of your test suite on EVERY test run, even for an
10+
# individual file that may not need all of that loaded. Instead, consider making
11+
# a separate helper file that requires the additional dependencies and performs
12+
# the additional setup, and require it from the spec files that actually need
13+
# it.
14+
#
15+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16+
RSpec.configure do |config|
17+
# rspec-expectations config goes here. You can use an alternate
18+
# assertion/expectation library such as wrong or the stdlib/minitest
19+
# assertions if you prefer.
20+
config.expect_with :rspec do |expectations|
21+
# This option will default to `true` in RSpec 4. It makes the `description`
22+
# and `failure_message` of custom matchers include text for helper methods
23+
# defined using `chain`, e.g.:
24+
# be_bigger_than(2).and_smaller_than(4).description
25+
# # => "be bigger than 2 and smaller than 4"
26+
# ...rather than:
27+
# # => "be bigger than 2"
28+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29+
end
30+
31+
# rspec-mocks config goes here. You can use an alternate test double
32+
# library (such as bogus or mocha) by changing the `mock_with` option here.
33+
config.mock_with :rspec do |mocks|
34+
# Prevents you from mocking or stubbing a method that does not exist on
35+
# a real object. This is generally recommended, and will default to
36+
# `true` in RSpec 4.
37+
mocks.verify_partial_doubles = true
38+
end
39+
40+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41+
# have no way to turn it off -- the option exists only for backwards
42+
# compatibility in RSpec 3). It causes shared context metadata to be
43+
# inherited by the metadata hash of host groups and examples, rather than
44+
# triggering implicit auto-inclusion in groups with matching metadata.
45+
config.shared_context_metadata_behavior = :apply_to_host_groups
46+
47+
# This allows you to limit a spec run to individual examples or groups
48+
# you care about by tagging them with `:focus` metadata. When nothing
49+
# is tagged with `:focus`, all examples get run. RSpec also provides
50+
# aliases for `it`, `describe`, and `context` that include `:focus`
51+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
52+
config.filter_run_when_matching :focus
53+
54+
# Allows RSpec to persist some state between runs in order to support
55+
# the `--only-failures` and `--next-failure` CLI options. We recommend
56+
# you configure your source control system to ignore this file.
57+
config.example_status_persistence_file_path = 'spec/examples.txt'
58+
59+
# Limits the available syntax to the non-monkey patched syntax that is
60+
# recommended. For more details, see:
61+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
62+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
63+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
64+
config.disable_monkey_patching!
65+
66+
# This setting enables warnings. It's recommended, but in some cases may
67+
# be too noisy due to issues in dependencies.
68+
config.warnings = false
69+
70+
# Many RSpec users commonly either run the entire suite or an individual
71+
# file, and it's useful to allow more verbose output when running an
72+
# individual spec file.
73+
if config.files_to_run.one?
74+
# Use the documentation formatter for detailed output,
75+
# unless a formatter has already been configured
76+
# (e.g. via a command-line flag).
77+
config.default_formatter = 'doc'
78+
end
79+
80+
# Print the 10 slowest examples and example groups at the
81+
# end of the spec run, to help surface which specs are running
82+
# particularly slow.
83+
config.profile_examples = 10
84+
85+
# Run specs in random order to surface order dependencies. If you find an
86+
# order dependency and want to debug it, you can fix the order by providing
87+
# the seed, which is printed after each run.
88+
# --seed 1234
89+
config.order = :random
90+
91+
# Seed global randomization in this process using the `--seed` CLI option.
92+
# Setting this allows you to use `--seed` to deterministically reproduce
93+
# test failures related to randomization by passing the same `--seed` value
94+
# as the one that triggered the failure.
95+
Kernel.srand config.seed
96+
end

spec/support/capybara.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'capybara/rspec'
2+
require 'capybara/poltergeist'
3+
4+
Capybara.javascript_driver = :poltergeist
5+
6+
RSpec.configure do |config|
7+
config.include Capybara::RSpecMatchers, type: :request
8+
end

0 commit comments

Comments
 (0)