added tests and so on

This commit is contained in:
2015-10-02 22:03:51 +02:00
parent c3ac940aea
commit c7a2fbe62c
9 changed files with 105 additions and 120 deletions
+1
View File
@@ -6,6 +6,7 @@
# Ignore bundler config.
/.bundle
/.rspec
# Ignore all logfiles and tempfiles.
/log/*
+14
View File
@@ -0,0 +1,14 @@
AllCops:
Include:
- Rakefile
- config.ru
Exclude:
- bin/**
- spec/dummy/config/initializers/secret_token.rb
Documentation:
Enabled: false
LineLength:
Enabled: true
Max: 160
AbcSize:
Enabled: false
+1 -1
View File
@@ -37,7 +37,7 @@ gem 'slim-rails'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'mongoid-rspec', '3.0.0'
gem 'rspec-rails', '~> 3.0'
end
+9
View File
@@ -78,6 +78,10 @@ GEM
mongo (~> 2.1)
origin (~> 2.1)
tzinfo (>= 0.3.37)
mongoid-rspec (3.0.0)
mongoid (~> 5.0)
rake
rspec (~> 3.3)
multi_json (1.11.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
@@ -111,6 +115,10 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
@@ -180,6 +188,7 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails
mongoid (~> 5.0.0)
mongoid-rspec (= 3.0.0)
rails (= 4.2.4)
rspec-rails (~> 3.0)
sass-rails (~> 5.0)
+1 -1
View File
@@ -27,7 +27,7 @@ module Ch420
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :de
# config.i18n.default_locale = :de
config.generators do |g|
g.orm :mongoid
-118
View File
@@ -1,128 +1,10 @@
development:
# Configure available database clients. (required)
clients:
# Defines the default client. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: ch420_development
# Provides the hosts the default client can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change the default write concern. (default = { w: 1 })
# write:
# w: 1
# Change the default read preference. Valid options for mode are: :secondary,
# :secondary_preferred, :primary, :primary_preferred, :nearest
# (default: primary)
# read:
# mode: :secondary_preferred
# The name of the user for authentication.
# user: 'user'
# The password of the user for authentication.
# password: 'password'
# The user's database roles.
# roles:
# - 'dbOwner'
# Change the default authentication mechanism. Valid options are: :scram,
# :mongodb_cr, :mongodb_x509, and :plain. (default on 3.0 is :scram, default
# on 2.4 and 2.6 is :plain)
# auth_mech: :scram
# The database or source to authenticate the user against. (default: admin)
# auth_source: admin
# Force a the driver cluster to behave in a certain manner instead of auto-
# discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct
# when connecting to hidden members of a replica set.
# connect: :direct
# Changes the default time in seconds the server monitors refresh their status
# via ismaster commands. (default: 10)
# heartbeat_frequency: 10
# The time in seconds for selecting servers for a near read preference. (default: 5)
# local_threshold: 5
# The timeout in seconds for selecting a server for an operation. (default: 30)
# server_selection_timeout: 30
# The maximum number of connections in the connection pool. (default: 5)
# max_pool_size: 5
# The minimum number of connections in the connection pool. (default: 1)
# min_pool_size: 1
# The time to wait, in seconds, in the connection pool for a connection
# to be checked in before timing out. (default: 5)
# wait_queue_timeout: 5
# The time to wait to establish a connection before timing out, in seconds.
# (default: 5)
# connect_timeout: 5
# The timeout to wait to execute operations on a socket before raising an error.
# (default: 5)
# socket_timeout: 5
# The name of the replica set to connect to. Servers provided as seeds that do
# not belong to this replica set will be ignored.
# replica_set: name
# Whether to connect to the servers via ssl. (default: false)
# ssl: true
# The certificate file used to identify the connection against MongoDB.
# ssl_cert: /path/to/my.cert
# The private keyfile used to identify the connection against MongoDB.
# Note that even if the key is stored in the same file as the certificate,
# both need to be explicitly specified.
# ssl_key: /path/to/my.key
# A passphrase for the private key.
# ssl_key_pass_phrase: password
# Whether or not to do peer certification validation. (default: false)
# ssl_verify: true
# The file containing a set of concatenated certification authority certifications
# used to validate certs passed from the other end of the connection.
# ssl_ca_cert: /path/to/ca.cert
# Configure Mongoid specific options. (optional)
options:
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serialization. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Use Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
clients:
default:
+7
View File
@@ -0,0 +1,7 @@
require 'rails_helper'
describe Supporter do
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_uniqueness_of(:email) }
it { is_expected.to validate_presence_of(:support) }
end
+25
View File
@@ -0,0 +1,25 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
RSpec.configure(&:infer_spec_type_from_file_location!)
+47
View File
@@ -0,0 +1,47 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'mongoid-rspec'
Mongo::Logger.logger.level = Logger::WARN # Set log level to DEBUG to see everything
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
RSpec.configure do |config|
config.include Mongoid::Matchers, type: :model
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end
config.order = :random
config.after(:each) do
Mongoid.purge!
end
end