rails-exporter 0.0.9 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +34 -9
  3. data/Rakefile +12 -11
  4. data/config/locales/exporters.en.yml +3 -0
  5. data/lib/rails_exporter/base.rb +1 -1
  6. data/lib/rails_exporter/engine.rb +5 -0
  7. data/lib/rails_exporter/exporter.rb +42 -8
  8. data/lib/rails_exporter/helper.rb +4 -4
  9. data/lib/rails_exporter/version.rb +1 -1
  10. data/spec/rails_exporter/base_spec.rb +11 -0
  11. data/spec/rails_exporter/engine_spec.rb +5 -0
  12. data/spec/rails_exporter/exporter_spec.rb +9 -0
  13. data/spec/rails_exporter/helper_spec.rb +5 -0
  14. data/spec/rails_exporter_spec.rb +7 -0
  15. data/spec/rails_helper.rb +66 -0
  16. data/spec/spec_helper.rb +100 -0
  17. data/spec/test_app/Rakefile +6 -0
  18. data/spec/test_app/app/assets/config/manifest.js +4 -0
  19. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  20. data/spec/test_app/app/assets/javascripts/cable.js +13 -0
  21. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  22. data/spec/test_app/app/channels/application_cable/channel.rb +4 -0
  23. data/spec/test_app/app/channels/application_cable/connection.rb +4 -0
  24. data/spec/test_app/app/controllers/application_controller.rb +3 -0
  25. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  26. data/spec/test_app/app/jobs/application_job.rb +2 -0
  27. data/spec/test_app/app/mailers/application_mailer.rb +4 -0
  28. data/spec/test_app/app/models/application_record.rb +3 -0
  29. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  30. data/spec/test_app/app/views/layouts/mailer.html.erb +13 -0
  31. data/spec/test_app/app/views/layouts/mailer.text.erb +1 -0
  32. data/spec/test_app/bin/bundle +3 -0
  33. data/spec/test_app/bin/rails +4 -0
  34. data/spec/test_app/bin/rake +4 -0
  35. data/spec/test_app/bin/setup +38 -0
  36. data/spec/test_app/bin/update +29 -0
  37. data/spec/test_app/bin/yarn +11 -0
  38. data/spec/test_app/config.ru +5 -0
  39. data/spec/test_app/config/application.rb +26 -0
  40. data/spec/test_app/config/boot.rb +5 -0
  41. data/spec/test_app/config/cable.yml +10 -0
  42. data/spec/test_app/config/database.yml +25 -0
  43. data/spec/test_app/config/environment.rb +5 -0
  44. data/spec/test_app/config/environments/development.rb +54 -0
  45. data/spec/test_app/config/environments/production.rb +91 -0
  46. data/spec/test_app/config/environments/test.rb +42 -0
  47. data/spec/test_app/config/initializers/application_controller_renderer.rb +8 -0
  48. data/spec/test_app/config/initializers/assets.rb +14 -0
  49. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  50. data/spec/test_app/config/initializers/cookies_serializer.rb +5 -0
  51. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/spec/test_app/config/initializers/inflections.rb +16 -0
  53. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  54. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  55. data/spec/test_app/config/locales/en.yml +33 -0
  56. data/spec/test_app/config/puma.rb +56 -0
  57. data/spec/test_app/config/routes.rb +3 -0
  58. data/spec/test_app/config/secrets.yml +32 -0
  59. data/spec/test_app/config/spring.rb +6 -0
  60. data/spec/test_app/db/schema.rb +15 -0
  61. data/spec/test_app/package.json +5 -0
  62. data/spec/test_app/public/404.html +67 -0
  63. data/spec/test_app/public/422.html +67 -0
  64. data/spec/test_app/public/500.html +66 -0
  65. data/spec/test_app/public/apple-touch-icon-precomposed.png +0 -0
  66. data/spec/test_app/public/apple-touch-icon.png +0 -0
  67. data/spec/test_app/public/favicon.ico +0 -0
  68. metadata +184 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 81bb6b6cc49c8bdb659aa048e5fbdbfcb226f0d0
4
- data.tar.gz: bdd1d68b1922c5656ee4b5a49a7164654be1728c
2
+ SHA256:
3
+ metadata.gz: ddc19215c259d345b4cb6d45de77f894f8c731563ac66d00700afe8005592e47
4
+ data.tar.gz: 3dfa2dc4afea2746d777cb4ac9d73ca62547f31f6ffbf3a3c4231440b83329b9
5
5
  SHA512:
6
- metadata.gz: 96b68fad1cdee09a587e91da4c92b9209b087adb3cae473b8b68027fa3cad3d0db61588ba7184122356fd0549f494e34ebbd43a64d31067d5db573225718946b
7
- data.tar.gz: 570d1740faea715a4074654c6418641a7c92930c11ac6a00d386c9f99883677cb1d222306dc399f270eec6b24b03b534675d7f175c0bef5d60aa0a66c6ff55c5
6
+ metadata.gz: fe2062f3eff5c10224ad5a34e768af44b0941881fca429dd689f00c7bbfc3f801816f0ca483a57623b7195dab990a274b80ae1ca0e75df1ccb68840284ea3e47
7
+ data.tar.gz: ad1580cf514598006306bbf65789563c9544f58ff79ba8b734f06ba475e33cbe308b121fdb5227b4b63dad1dd6edfe2300eb82415ff81c62d4a32c30a0dba35f
data/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # Rails Exporter
2
2
 
3
- Rails Exporter (XML, XLS, CSV)
3
+ Rails Exporter (CSV, XML, XLS, XSLX)
4
4
 
5
5
  ## How to install
6
6
 
7
- Add it to your **Gemfile**:
7
+ Add it to your `Gemfile`:
8
8
  ```ruby
9
9
  gem 'rails-exporter'
10
10
  ```
11
11
 
12
12
  Run the following command to install it:
13
- ```sh
13
+ ```shell
14
14
  $ bundle install
15
15
  $ rails generate rails_exporter:install
16
16
  ```
@@ -19,7 +19,7 @@ $ rails generate rails_exporter:install
19
19
 
20
20
  You can generate exporters `app/exporters/example_exporter.rb`
21
21
 
22
- ```sh
22
+ ```bash
23
23
  $ rails generate rails_exporter:exporter example
24
24
  ```
25
25
 
@@ -33,6 +33,7 @@ class ExampleExporter < RailsExporter::Base
33
33
  column :email
34
34
  column :price => :currency
35
35
  column :is_admin => :boolean
36
+ column :any_time => :time
36
37
  column :birthday => :date
37
38
  column :created_at => :datetime
38
39
  column(:account) {|record| record.account.name}
@@ -52,17 +53,37 @@ end
52
53
  ### How to use
53
54
 
54
55
  You can call `export_to` from **Array** or **ActiveRecord::Relation** objects:
55
- ```erb
56
+ ```ruby
56
57
  records = MyModel.all
57
- records.export_to(:csv) # or MyModelExporter.export_to_csv(records)
58
+ records.export_to(:csv) # or MyModelExporter.export_to_csv(records)
58
59
 
59
60
  records = [MyModel.first, MyModel.last]
60
61
  records.export_to(:xml) # or MyModelExporter.export_to_xml(records)
62
+
63
+ ## With context :simple
64
+ # records.export_to(:csv, :simple)
65
+ # or MyModelExporter.export_to_csv(records, :simple)
66
+
67
+ ## CSV Custom Params
68
+ # records.export_to(:csv, params: {col_sep: ','}))
61
69
  ```
62
70
 
71
+ ### Avaliable Types
72
+
73
+ You can call `RailsExporter::Base.file_types` to list all supported file types:
74
+ ```ruby
75
+ RailsExporter::Base.file_types.each do |type|
76
+ puts type
77
+ end
78
+ ```
79
+
80
+ ### I18n Configuration
81
+
82
+ Modify you `config/locales/exporters.en.yml`
83
+
63
84
  ### Controller Example
64
85
 
65
- ```erb
86
+ ```ruby
66
87
  class UsersController < ApplicationController
67
88
  def index
68
89
  @users = User.all
@@ -71,12 +92,16 @@ class UsersController < ApplicationController
71
92
  format.csv { send_data @users.export_to(:csv) }
72
93
  format.xml { send_data @users.export_to(:xml) }
73
94
  format.xls { send_data @users.export_to(:xls) }
95
+ format.xlsx { send_data @users.export_to(:xlsx) }
74
96
  end
75
97
  end
76
98
  end
77
99
  ```
78
100
 
101
+ ### MimeTypes
102
+
79
103
  Declare XLS as a new mimetype in `config/initializers/mime_types`:
80
- ```erb
81
- Mime::Type.register "application/xls", :xls
104
+ ```ruby
105
+ Mime::Type.register "application/vnd.ms-excel", :xls
106
+ Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
82
107
  ```
data/Rakefile CHANGED
@@ -4,20 +4,21 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
- # require 'rdoc/task'
8
- #
9
- # RDoc::Task.new(:rdoc) do |rdoc|
10
- # rdoc.rdoc_dir = 'rdoc'
11
- # rdoc.title = 'RailsExporter'
12
- # rdoc.options << '--line-numbers'
13
- # rdoc.rdoc_files.include('README.rdoc')
14
- # rdoc.rdoc_files.include('lib/**/*.rb')
15
- # end
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RailsExporter'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
19
  load 'rails/tasks/statistics.rake'
20
- Bundler::GemHelper.install_tasks
20
+ # Bundler::GemHelper.install_tasks
21
+ require 'bundler/gem_tasks'
21
22
 
22
23
  # require 'rake/testtask'
23
24
  # Rake::TestTask.new(:test) do |t|
@@ -1,6 +1,9 @@
1
1
  en:
2
2
  exporters:
3
3
  spreadsheet_name: 'Spreadsheet'
4
+ time_format: "%I:%M %P"
5
+ date_format: "%m/%d/%Y"
6
+ datetime_format: "%m/%d/%Y, %I:%M %P"
4
7
  example:
5
8
  name: 'Name'
6
9
  another_example:
@@ -8,7 +8,7 @@ module RailsExporter
8
8
 
9
9
  class << self
10
10
  def file_types
11
- [:csv, :xls, :xml]
11
+ [:csv, :xls, :xlsx, :xml]
12
12
  end
13
13
 
14
14
  # def method_missing(m, *args, &block)
@@ -1,4 +1,9 @@
1
1
  module RailsExporter
2
2
  class Engine < ::Rails::Engine
3
+ engine_name "rails_exporter"
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ end
3
8
  end
4
9
  end
@@ -1,5 +1,9 @@
1
1
  require 'builder'
2
2
  require 'spreadsheet'
3
+ require 'rubyXL'
4
+ require 'rubyXL/convenience_methods/font'
5
+ require 'rubyXL/convenience_methods/workbook'
6
+ require 'rubyXL/convenience_methods/worksheet'
3
7
 
4
8
  module RailsExporter
5
9
  module Exporter
@@ -9,8 +13,9 @@ module RailsExporter
9
13
  end
10
14
 
11
15
  module ClassMethods
12
- def export_to_csv(records, context=:default)
13
- CSV.generate({:col_sep => ';', :force_quotes => true}) do |csv|
16
+ def export_to_csv(records, context=:default, params: nil)
17
+ custom_params = {col_sep: ';', force_quotes: true}.merge(params || {})
18
+ CSV.generate(custom_params) do |csv|
14
19
  # HEADER
15
20
  csv << get_columns(context).map do |attr|
16
21
  attr_name(attr)
@@ -22,9 +27,10 @@ module RailsExporter
22
27
  end
23
28
  end
24
29
 
25
- def export_to_xml(records, context=:default)
30
+ def export_to_xml(records, context=:default, params: nil)
31
+ #TODO: custom params
26
32
  #File XML
27
- xml = Builder::XmlMarkup.new(:indent => 2)
33
+ xml = Builder::XmlMarkup.new(indent: 2)
28
34
  #Format
29
35
  xml.instruct! :xml, :encoding => "UTF-8"
30
36
  xml.records do
@@ -42,7 +48,8 @@ module RailsExporter
42
48
  end
43
49
  end
44
50
 
45
- def export_to_xls(records, context=:default)
51
+ def export_to_xls(records, context=:default, params: nil)
52
+ #TODO: custom params
46
53
  #FILE
47
54
  file_contents = StringIO.new
48
55
  #CHARSET
@@ -68,6 +75,28 @@ module RailsExporter
68
75
  file_contents.string.force_encoding('binary')
69
76
  end
70
77
 
78
+ def export_to_xlsx(records, context=:default, params: nil)
79
+ #TODO: custom params
80
+ #NEW document/spreadsheet
81
+ workbook = RubyXL::Workbook.new
82
+ worksheet = workbook[0]
83
+ # worksheet = workbook.add_worksheet(I18n.t(:spreadsheet_name, default: ['Spreadsheet'], scope: [:exporters]))
84
+ worksheet.sheet_name = I18n.t(:spreadsheet_name, default: ['Spreadsheet'], scope: [:exporters])
85
+ #HEADER FORMAT
86
+ worksheet.change_row_bold(0, true)
87
+ #HEADER (ROW=0)
88
+ get_columns(context).each_with_index do |attr, i|
89
+ worksheet.add_cell(0, i, attr_name(attr))
90
+ end
91
+ #ROWS
92
+ records.each_with_index do |record, row_index|
93
+ values = get_values(record, context)
94
+ values.each_with_index {|value, col_index| worksheet.add_cell(row_index+1, col_index, value)}
95
+ end
96
+ #RETURN STRING
97
+ workbook.stream.string.force_encoding('binary')
98
+ end
99
+
71
100
  private
72
101
  def get_columns(context)
73
102
  self.send(:columns, context) || []
@@ -94,12 +123,17 @@ module RailsExporter
94
123
  ActionController::Base.helpers.number_to_currency(value)
95
124
  elsif type==:boolean
96
125
  (value==true or value=='true' or value=='1') ? 'S' : 'N'
126
+ elsif type==:time
127
+ locale_format = I18n.t(:time_format, default: ['%H:%M:%S'], scope: [:exporters])
128
+ (I18n.l(value, format: locale_format) rescue value).to_s
97
129
  elsif type==:date
98
- (I18n.l(value, format: '%d/%m/%Y') rescue value).to_s
130
+ locale_format = I18n.t(:date_format, default: ['%d/%m/%Y'], scope: [:exporters])
131
+ (I18n.l(value, format: locale_format) rescue value).to_s
99
132
  elsif type==:datetime
100
- (I18n.l(value, format: '%d/%m/%Y %H:%i:%s') rescue value).to_s
133
+ locale_format = I18n.t(:datetime_format, default: ['%d/%m/%Y %H:%M:%S'], scope: [:exporters])
134
+ (I18n.l(value, format: locale_format) rescue value).to_s
101
135
  else
102
- (I18n.l(value) rescue value)
136
+ (I18n.l(value) rescue value).to_s
103
137
  end
104
138
  end
105
139
 
@@ -3,20 +3,20 @@ require 'rails_exporter/base'
3
3
  module RailsExporter
4
4
  module Helper
5
5
 
6
- define_method "export_to" do |ext, context=:default|
7
- exec_method(ext, context)
6
+ define_method "export_to" do |ext, context=:default, params: nil|
7
+ exec_method(ext, context, params: params)
8
8
  end
9
9
 
10
10
  private
11
11
  def get_obj_class
12
12
  (self.first.class rescue nil)
13
13
  end
14
- def exec_method(ext, context)
14
+ def exec_method(ext, context, params: nil)
15
15
  klass = get_obj_class
16
16
  exporter_klass = "#{klass.name}_exporter".classify.constantize
17
17
  # RailsExporter::Base.file_types
18
18
  if exporter_klass and exporter_klass.respond_to?("export_to_#{ext}")
19
- exporter_klass.send("export_to_#{ext}", self, context)
19
+ exporter_klass.send("export_to_#{ext}", self, context, params: params)
20
20
  end
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module RailsExporter
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe RailsExporter::Base do
4
+
5
+ describe '.file_types' do
6
+ it 'return the supported file types' do
7
+ expect(RailsExporter::Base.file_types).to eq([:csv, :xls, :xlsx, :xml])
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,5 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe RailsExporter::Engine do
4
+
5
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe RailsExporter::Exporter do
4
+
5
+ describe '.export_to_csv' do
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,5 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe RailsExporter::Helper do
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ describe RailsExporter do
4
+ it 'have version number' do
5
+ expect(RailsExporter::VERSION).not_to be_nil
6
+ end
7
+ end
@@ -0,0 +1,66 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_group 'Files', ['rails_exporter', 'lib/rails_exporter']
5
+ add_filter ['spec','rails-exporter']
6
+ end
7
+
8
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
9
+ require 'spec_helper'
10
+ ENV['RAILS_ENV'] ||= 'test'
11
+ require File.expand_path('../../spec/test_app/config/environment', __FILE__)
12
+ # Prevent database truncation if the environment is production
13
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
14
+ require 'rspec/rails'
15
+ # Add additional requires below this line. Rails is not loaded until this point!
16
+
17
+ # Requires supporting ruby files with custom matchers and macros, etc, in
18
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
19
+ # run as spec files by default. This means that files in spec/support that end
20
+ # in _spec.rb will both be required and run as specs, causing the specs to be
21
+ # run twice. It is recommended that you do not name files matching this glob to
22
+ # end with _spec.rb. You can configure this pattern with the --pattern
23
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
24
+ #
25
+ # The following line is provided for convenience purposes. It has the downside
26
+ # of increasing the boot-up time by auto-requiring all files in the support
27
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
28
+ # require only the support files necessary.
29
+ #
30
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
31
+
32
+ # Checks for pending migration and applies them before tests are run.
33
+ # If you are not using ActiveRecord, you can remove this line.
34
+ ActiveRecord::Migration.maintain_test_schema!
35
+ ActiveJob::Base.queue_adapter = :test
36
+
37
+ RSpec.configure do |config|
38
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
39
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
40
+
41
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
42
+ # examples within a transaction, remove the following line or assign false
43
+ # instead of true.
44
+ config.use_transactional_fixtures = true
45
+
46
+ # RSpec Rails can automatically mix in different behaviours to your tests
47
+ # based on their file location, for example enabling you to call `get` and
48
+ # `post` in specs under `spec/controllers`.
49
+ #
50
+ # You can disable this behaviour by removing the line below, and instead
51
+ # explicitly tag your specs with their type, e.g.:
52
+ #
53
+ # RSpec.describe UsersController, :type => :controller do
54
+ # # ...
55
+ # end
56
+ #
57
+ # The different available types are documented in the features, such as in
58
+ # https://relishapp.com/rspec/rspec-rails/docs
59
+ config.infer_spec_type_from_file_location!
60
+
61
+ # Filter lines from Rails gems in backtraces.
62
+ config.filter_rails_from_backtrace!
63
+ # arbitrary gems may also be filtered via:
64
+ # config.filter_gems_from_backtrace("gem name")
65
+
66
+ end
@@ -0,0 +1,100 @@
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
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67
+ config.disable_monkey_patching!
68
+
69
+ # This setting enables warnings. It's recommended, but in some cases may
70
+ # be too noisy due to issues in dependencies.
71
+ config.warnings = true
72
+
73
+ # Many RSpec users commonly either run the entire suite or an individual
74
+ # file, and it's useful to allow more verbose output when running an
75
+ # individual spec file.
76
+ if config.files_to_run.one?
77
+ # Use the documentation formatter for detailed output,
78
+ # unless a formatter has already been configured
79
+ # (e.g. via a command-line flag).
80
+ config.default_formatter = "doc"
81
+ end
82
+
83
+ # Print the 10 slowest examples and example groups at the
84
+ # end of the spec run, to help surface which specs are running
85
+ # particularly slow.
86
+ config.profile_examples = 10
87
+
88
+ # Run specs in random order to surface order dependencies. If you find an
89
+ # order dependency and want to debug it, you can fix the order by providing
90
+ # the seed, which is printed after each run.
91
+ # --seed 1234
92
+ config.order = :random
93
+
94
+ # Seed global randomization in this process using the `--seed` CLI option.
95
+ # Setting this allows you to use `--seed` to deterministically reproduce
96
+ # test failures related to randomization by passing the same `--seed` value
97
+ # as the one that triggered the failure.
98
+ Kernel.srand config.seed
99
+ =end
100
+ end