paper_trail 3.0.6 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rspec +1 -2
  4. data/.travis.yml +14 -5
  5. data/CHANGELOG.md +215 -8
  6. data/CONTRIBUTING.md +84 -0
  7. data/README.md +922 -502
  8. data/Rakefile +2 -2
  9. data/doc/bug_report_template.rb +65 -0
  10. data/gemfiles/ar3.gemfile +61 -0
  11. data/lib/generators/paper_trail/install_generator.rb +22 -3
  12. data/lib/generators/paper_trail/templates/add_object_changes_to_versions.rb +6 -1
  13. data/lib/generators/paper_trail/templates/add_transaction_id_column_to_versions.rb +11 -0
  14. data/lib/generators/paper_trail/templates/create_version_associations.rb +17 -0
  15. data/lib/generators/paper_trail/templates/create_versions.rb +22 -1
  16. data/lib/paper_trail.rb +52 -22
  17. data/lib/paper_trail/attributes_serialization.rb +89 -0
  18. data/lib/paper_trail/cleaner.rb +32 -15
  19. data/lib/paper_trail/config.rb +35 -2
  20. data/lib/paper_trail/frameworks/active_record.rb +4 -5
  21. data/lib/paper_trail/frameworks/active_record/models/paper_trail/version_association.rb +7 -0
  22. data/lib/paper_trail/frameworks/rails.rb +1 -0
  23. data/lib/paper_trail/frameworks/rails/controller.rb +27 -11
  24. data/lib/paper_trail/frameworks/rspec.rb +5 -0
  25. data/lib/paper_trail/frameworks/sinatra.rb +3 -1
  26. data/lib/paper_trail/has_paper_trail.rb +304 -148
  27. data/lib/paper_trail/record_history.rb +59 -0
  28. data/lib/paper_trail/reifier.rb +270 -0
  29. data/lib/paper_trail/serializers/json.rb +13 -2
  30. data/lib/paper_trail/serializers/yaml.rb +16 -2
  31. data/lib/paper_trail/version_association_concern.rb +15 -0
  32. data/lib/paper_trail/version_concern.rb +160 -122
  33. data/lib/paper_trail/version_number.rb +3 -3
  34. data/paper_trail.gemspec +22 -9
  35. data/spec/generators/install_generator_spec.rb +4 -4
  36. data/spec/models/animal_spec.rb +36 -0
  37. data/spec/models/boolit_spec.rb +48 -0
  38. data/spec/models/callback_modifier_spec.rb +96 -0
  39. data/spec/models/fluxor_spec.rb +19 -0
  40. data/spec/models/gadget_spec.rb +14 -12
  41. data/spec/models/joined_version_spec.rb +9 -9
  42. data/spec/models/json_version_spec.rb +103 -0
  43. data/spec/models/kitchen/banana_spec.rb +14 -0
  44. data/spec/models/not_on_update_spec.rb +19 -0
  45. data/spec/models/post_with_status_spec.rb +3 -3
  46. data/spec/models/skipper_spec.rb +46 -0
  47. data/spec/models/thing_spec.rb +11 -0
  48. data/spec/models/version_spec.rb +195 -44
  49. data/spec/models/widget_spec.rb +136 -76
  50. data/spec/modules/paper_trail_spec.rb +27 -0
  51. data/spec/modules/version_concern_spec.rb +8 -8
  52. data/spec/modules/version_number_spec.rb +16 -16
  53. data/spec/paper_trail/config_spec.rb +52 -0
  54. data/spec/paper_trail_spec.rb +17 -17
  55. data/spec/rails_helper.rb +34 -0
  56. data/spec/requests/articles_spec.rb +10 -14
  57. data/spec/spec_helper.rb +81 -34
  58. data/spec/support/alt_db_init.rb +1 -1
  59. data/test/dummy/app/controllers/application_controller.rb +1 -1
  60. data/test/dummy/app/controllers/articles_controller.rb +4 -1
  61. data/test/dummy/app/models/animal.rb +2 -0
  62. data/test/dummy/app/models/book.rb +4 -0
  63. data/test/dummy/app/models/boolit.rb +4 -0
  64. data/test/dummy/app/models/callback_modifier.rb +45 -0
  65. data/test/dummy/app/models/chapter.rb +9 -0
  66. data/test/dummy/app/models/citation.rb +5 -0
  67. data/test/dummy/app/models/customer.rb +4 -0
  68. data/test/dummy/app/models/editor.rb +4 -0
  69. data/test/dummy/app/models/editorship.rb +5 -0
  70. data/test/dummy/app/models/fruit.rb +5 -0
  71. data/test/dummy/app/models/kitchen/banana.rb +5 -0
  72. data/test/dummy/app/models/line_item.rb +4 -0
  73. data/test/dummy/app/models/not_on_update.rb +4 -0
  74. data/test/dummy/app/models/order.rb +5 -0
  75. data/test/dummy/app/models/paragraph.rb +5 -0
  76. data/test/dummy/app/models/person.rb +13 -3
  77. data/test/dummy/app/models/post.rb +0 -1
  78. data/test/dummy/app/models/quotation.rb +5 -0
  79. data/test/dummy/app/models/section.rb +6 -0
  80. data/test/dummy/app/models/skipper.rb +6 -0
  81. data/test/dummy/app/models/song.rb +20 -0
  82. data/test/dummy/app/models/thing.rb +3 -0
  83. data/test/dummy/app/models/whatchamajigger.rb +4 -0
  84. data/test/dummy/app/models/widget.rb +5 -0
  85. data/test/dummy/app/versions/json_version.rb +3 -0
  86. data/test/dummy/app/versions/kitchen/banana_version.rb +5 -0
  87. data/test/dummy/config/application.rb +6 -0
  88. data/test/dummy/config/database.postgres.yml +1 -1
  89. data/test/dummy/config/environments/test.rb +5 -1
  90. data/test/dummy/config/initializers/paper_trail.rb +6 -1
  91. data/test/dummy/db/migrate/20110208155312_set_up_test_tables.rb +143 -3
  92. data/test/dummy/db/schema.rb +169 -25
  93. data/test/functional/controller_test.rb +4 -2
  94. data/test/functional/modular_sinatra_test.rb +1 -1
  95. data/test/functional/sinatra_test.rb +1 -1
  96. data/test/paper_trail_test.rb +7 -0
  97. data/test/test_helper.rb +38 -2
  98. data/test/time_travel_helper.rb +15 -0
  99. data/test/unit/associations_test.rb +726 -0
  100. data/test/unit/inheritance_column_test.rb +6 -6
  101. data/test/unit/model_test.rb +109 -125
  102. data/test/unit/protected_attrs_test.rb +4 -3
  103. data/test/unit/serializer_test.rb +6 -6
  104. data/test/unit/serializers/json_test.rb +17 -4
  105. data/test/unit/serializers/yaml_test.rb +5 -1
  106. data/test/unit/version_test.rb +87 -69
  107. metadata +172 -75
  108. data/gemfiles/3.0.gemfile +0 -42
  109. data/test/dummy/public/404.html +0 -26
  110. data/test/dummy/public/422.html +0 -26
  111. data/test/dummy/public/500.html +0 -26
  112. data/test/dummy/public/favicon.ico +0 -0
  113. data/test/dummy/public/javascripts/application.js +0 -2
  114. data/test/dummy/public/javascripts/controls.js +0 -965
  115. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  116. data/test/dummy/public/javascripts/effects.js +0 -1123
  117. data/test/dummy/public/javascripts/prototype.js +0 -6001
  118. data/test/dummy/public/javascripts/rails.js +0 -175
  119. data/test/dummy/public/stylesheets/.gitkeep +0 -0
@@ -0,0 +1,27 @@
1
+ require 'rails_helper'
2
+
3
+ describe PaperTrail, :type => :module, :versioning => true do
4
+ describe '#config' do
5
+ it { is_expected.to respond_to(:config) }
6
+
7
+ it "should allow for config values to be set" do
8
+ expect(subject.config.enabled).to eq(true)
9
+ subject.config.enabled = false
10
+ expect(subject.config.enabled).to eq(false)
11
+ end
12
+
13
+ it "should accept blocks and yield the config instance" do
14
+ expect(subject.config.enabled).to eq(true)
15
+ subject.config { |c| c.enabled = false }
16
+ expect(subject.config.enabled).to eq(false)
17
+ end
18
+ end
19
+
20
+ describe '#configure' do
21
+ it { is_expected.to respond_to(:configure) }
22
+
23
+ it "should be an alias for the `config` method" do
24
+ expect(subject.method(:configure)).to eq(subject.method(:config))
25
+ end
26
+ end
27
+ end
@@ -1,21 +1,21 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe PaperTrail::VersionConcern do
4
4
 
5
5
  before(:all) { require 'support/alt_db_init' }
6
6
 
7
7
  it 'allows included class to have different connections' do
8
- Foo::Version.connection.should_not == Bar::Version.connection
8
+ expect(Foo::Version.connection).not_to eq(Bar::Version.connection)
9
9
  end
10
10
 
11
11
  it 'allows custom version class to share connection with superclass' do
12
- Foo::Version.connection.should == Foo::Document.connection
13
- Bar::Version.connection.should == Bar::Document.connection
12
+ expect(Foo::Version.connection).to eq(Foo::Document.connection)
13
+ expect(Bar::Version.connection).to eq(Bar::Document.connection)
14
14
  end
15
15
 
16
16
  it 'can be used with class_name option' do
17
- Foo::Document.version_class_name.should == 'Foo::Version'
18
- Bar::Document.version_class_name.should == 'Bar::Version'
17
+ expect(Foo::Document.version_class_name).to eq('Foo::Version')
18
+ expect(Bar::Document.version_class_name).to eq('Bar::Version')
19
19
  end
20
20
 
21
21
  describe 'persistence', :versioning => true do
@@ -25,8 +25,8 @@ describe PaperTrail::VersionConcern do
25
25
  end
26
26
 
27
27
  it 'should store versions in the correct corresponding db location' do
28
- @foo_doc.versions.first.should be_instance_of(Foo::Version)
29
- @bar_doc.versions.first.should be_instance_of(Bar::Version)
28
+ expect(@foo_doc.versions.first).to be_instance_of(Foo::Version)
29
+ expect(@bar_doc.versions.first).to be_instance_of(Bar::Version)
30
30
  end
31
31
  end
32
32
  end
@@ -1,35 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'PaperTrail::VERSION' do
3
+ describe PaperTrail::VERSION do
4
4
 
5
5
  describe "Constants" do
6
6
  subject { PaperTrail::VERSION }
7
7
 
8
8
  describe :MAJOR do
9
- it { should be_const_defined(:MAJOR) }
10
- it { subject::MAJOR.should be_a(Integer) }
9
+ it { is_expected.to be_const_defined(:MAJOR) }
10
+ it { expect(subject::MAJOR).to be_a(Integer) }
11
11
  end
12
12
  describe :MINOR do
13
- it { should be_const_defined(:MINOR) }
14
- it { subject::MINOR.should be_a(Integer) }
13
+ it { is_expected.to be_const_defined(:MINOR) }
14
+ it { expect(subject::MINOR).to be_a(Integer) }
15
15
  end
16
16
  describe :TINY do
17
- it { should be_const_defined(:TINY) }
18
- it { subject::TINY.should be_a(Integer) }
17
+ it { is_expected.to be_const_defined(:TINY) }
18
+ it { expect(subject::TINY).to be_a(Integer) }
19
19
  end
20
20
  describe :PRE do
21
- it { should be_const_defined(:PRE) }
21
+ it { is_expected.to be_const_defined(:PRE) }
22
22
  if PaperTrail::VERSION::PRE
23
- it { subject::PRE.should be_instance_of(String) }
23
+ it { expect(subject::PRE).to be_instance_of(String) }
24
24
  end
25
25
  end
26
26
  describe :STRING do
27
- it { should be_const_defined(:STRING) }
28
- it { subject::STRING.should be_instance_of(String) }
27
+ it { is_expected.to be_const_defined(:STRING) }
28
+ it { expect(subject::STRING).to be_instance_of(String) }
29
29
 
30
30
  it "should join the numbers into a period separated string" do
31
- subject::STRING.should ==
32
- [subject::MAJOR, subject::MINOR, subject::TINY, subject::PRE].compact.join('.')
31
+ expect(subject::STRING).to eq(
32
+ [subject::MAJOR, subject::MINOR, subject::TINY, subject::PRE].compact.join('.'))
33
33
  end
34
34
  end
35
35
  end
@@ -37,8 +37,8 @@ describe 'PaperTrail::VERSION' do
37
37
  end
38
38
 
39
39
  describe PaperTrail do
40
- describe :version do
41
- it { should respond_to(:version) }
42
- its(:version) { should == PaperTrail::VERSION::STRING }
40
+ describe '#version' do
41
+ it { is_expected.to respond_to(:version) }
42
+ it { expect(subject.version).to eq(PaperTrail::VERSION::STRING) }
43
43
  end
44
44
  end
@@ -0,0 +1,52 @@
1
+ require "rails_helper"
2
+
3
+ module PaperTrail
4
+ RSpec.describe Config do
5
+ describe ".instance" do
6
+ it "returns the singleton instance" do
7
+ expect { described_class.instance }.to_not raise_error
8
+ end
9
+ end
10
+
11
+ describe ".new" do
12
+ it "raises NoMethodError" do
13
+ expect { described_class.new }.to raise_error(NoMethodError)
14
+ end
15
+ end
16
+
17
+ describe "#enabled" do
18
+ context "when paper_trail_enabled is true" do
19
+ it "returns true" do
20
+ store = double
21
+ allow(store).to receive(:fetch).
22
+ with(:paper_trail_enabled, true).
23
+ and_return(true)
24
+ allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
25
+ expect(described_class.instance.enabled).to eq(true)
26
+ end
27
+ end
28
+
29
+ context "when paper_trail_enabled is false" do
30
+ it "returns false" do
31
+ store = double
32
+ allow(store).to receive(:fetch).
33
+ with(:paper_trail_enabled, true).
34
+ and_return(false)
35
+ allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
36
+ expect(described_class.instance.enabled).to eq(false)
37
+ end
38
+ end
39
+
40
+ context "when paper_trail_enabled is nil" do
41
+ it "returns true" do
42
+ store = double
43
+ allow(store).to receive(:fetch).
44
+ with(:paper_trail_enabled, true).
45
+ and_return(nil)
46
+ allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
47
+ expect(described_class.instance.enabled).to eq(true)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,58 +1,58 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe "PaperTrail RSpec Helper" do
4
4
  context 'default' do
5
5
  it 'should have versioning off by default' do
6
- ::PaperTrail.should_not be_enabled
6
+ expect(PaperTrail).not_to be_enabled
7
7
  end
8
8
  it 'should turn versioning on in a `with_versioning` block' do
9
- ::PaperTrail.should_not be_enabled
9
+ expect(PaperTrail).not_to be_enabled
10
10
  with_versioning do
11
- ::PaperTrail.should be_enabled
11
+ expect(PaperTrail).to be_enabled
12
12
  end
13
- ::PaperTrail.should_not be_enabled
13
+ expect(PaperTrail).not_to be_enabled
14
14
  end
15
15
 
16
16
  context "error within `with_versioning` block" do
17
17
  it "should revert the value of `PaperTrail.enabled?` to it's previous state" do
18
- ::PaperTrail.should_not be_enabled
18
+ expect(PaperTrail).not_to be_enabled
19
19
  expect { with_versioning { raise } }.to raise_error
20
- ::PaperTrail.should_not be_enabled
20
+ expect(PaperTrail).not_to be_enabled
21
21
  end
22
22
  end
23
23
  end
24
24
 
25
25
  context '`versioning: true`', :versioning => true do
26
26
  it 'should have versioning on by default' do
27
- ::PaperTrail.should be_enabled
27
+ expect(PaperTrail).to be_enabled
28
28
  end
29
29
  it 'should keep versioning on after a with_versioning block' do
30
- ::PaperTrail.should be_enabled
30
+ expect(PaperTrail).to be_enabled
31
31
  with_versioning do
32
- ::PaperTrail.should be_enabled
32
+ expect(PaperTrail).to be_enabled
33
33
  end
34
- ::PaperTrail.should be_enabled
34
+ expect(PaperTrail).to be_enabled
35
35
  end
36
36
  end
37
37
 
38
38
  context '`with_versioning` block at class level' do
39
- it { ::PaperTrail.should_not be_enabled }
39
+ it { expect(PaperTrail).not_to be_enabled }
40
40
 
41
41
  with_versioning do
42
42
  it 'should have versioning on by default' do
43
- ::PaperTrail.should be_enabled
43
+ expect(PaperTrail).to be_enabled
44
44
  end
45
45
  end
46
46
  it 'should not leak the `enabled?` state into successive tests' do
47
- ::PaperTrail.should_not be_enabled
47
+ expect(PaperTrail).not_to be_enabled
48
48
  end
49
49
  end
50
50
 
51
51
  describe :whodunnit do
52
- before(:all) { ::PaperTrail.whodunnit = 'foobar' }
52
+ before(:all) { PaperTrail.whodunnit = 'foobar' }
53
53
 
54
54
  it "should get set to `nil` by default" do
55
- ::PaperTrail.whodunnit.should be_nil
55
+ expect(PaperTrail.whodunnit).to be_nil
56
56
  end
57
57
  end
58
58
 
@@ -60,7 +60,7 @@ describe "PaperTrail RSpec Helper" do
60
60
  before(:all) { ::PaperTrail.controller_info = {:foo => 'bar'} }
61
61
 
62
62
  it "should get set to an empty hash before each test" do
63
- ::PaperTrail.controller_info.should == {}
63
+ expect(PaperTrail.controller_info).to eq({})
64
64
  end
65
65
  end
66
66
  end
@@ -0,0 +1,34 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ ENV["DB"] ||= 'sqlite'
4
+
5
+ unless File.exists?(File.expand_path('../../test/dummy/config/database.yml', __FILE__))
6
+ warn "WARNING: No database.yml detected for the dummy app, please run `rake prepare` first"
7
+ end
8
+
9
+ require 'spec_helper'
10
+ require File.expand_path('../../test/dummy/config/environment', __FILE__)
11
+ require 'rspec/rails'
12
+ require 'paper_trail/frameworks/rspec'
13
+ require 'shoulda/matchers'
14
+ require 'ffaker'
15
+
16
+ # prevent Test::Unit's AutoRunner from executing during RSpec's rake task
17
+ Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
18
+
19
+ # Checks for pending migrations before tests are run.
20
+ # If you are not using ActiveRecord, you can remove this line.
21
+ ActiveRecord::Migration.check_pending! if ActiveRecord::Migration.respond_to?(:check_pending!)
22
+
23
+ RSpec.configure do |config|
24
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
25
+
26
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
27
+ # examples within a transaction, remove the following line or assign false
28
+ # instead of true.
29
+ config.use_transactional_fixtures = true
30
+
31
+ # The different available types are documented in the features, such as in
32
+ # https://relishapp.com/rspec/rspec-rails/docs
33
+ # config.infer_spec_type_from_file_location!
34
+ end
@@ -1,19 +1,18 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe "Articles" do
3
+ describe "Articles management", :type => :request, :order => :defined do
4
4
  let(:valid_params) { { :article => { :title => 'Doh', :content => Faker::Lorem.sentence } } }
5
5
 
6
6
  context "versioning disabled" do
7
- specify { PaperTrail.should_not be_enabled }
7
+ specify { expect(PaperTrail).not_to be_enabled }
8
8
 
9
9
  it "should not create a version" do
10
- PaperTrail.should be_enabled_for_controller
11
- expect { post articles_path(valid_params) }.to_not change(PaperTrail::Version, :count)
12
- PaperTrail.should_not be_enabled_for_controller
10
+ expect(PaperTrail).to be_enabled_for_controller
11
+ expect { post(articles_path, valid_params) }.to_not change(PaperTrail::Version, :count)
13
12
  end
14
13
 
15
14
  it "should not leak the state of the `PaperTrail.enabled_for_controller?` into the next test" do
16
- PaperTrail.should be_enabled_for_controller
15
+ expect(PaperTrail).to be_enabled_for_controller
17
16
  end
18
17
  end
19
18
 
@@ -21,13 +20,10 @@ describe "Articles" do
21
20
  let(:article) { Article.last }
22
21
 
23
22
  context "`current_user` method returns a `String`" do
24
- if RUBY_VERSION.to_f >= 1.9
25
- it "should set that value as the `whodunnit`" do
26
- expect { post articles_path(valid_params) }.to change(PaperTrail::Version, :count).by(1)
27
- article.title.should == 'Doh'
28
- PaperTrail.whodunnit.should == 'foobar'
29
- article.versions.last.whodunnit.should == 'foobar'
30
- end
23
+ it "should set that value as the `whodunnit`" do
24
+ expect { post articles_path, valid_params }.to change(PaperTrail::Version, :count).by(1)
25
+ expect(article.title).to eq('Doh')
26
+ expect(article.versions.last.whodunnit).to eq('foobar')
31
27
  end
32
28
  end
33
29
  end
data/spec/spec_helper.rb CHANGED
@@ -1,48 +1,95 @@
1
- ENV["RAILS_ENV"] ||= 'test'
2
- ENV["DB"] ||= 'sqlite'
3
-
4
- unless File.exists?(File.expand_path('../../test/dummy/config/database.yml', __FILE__))
5
- warn "WARNING: No database.yml detected for the dummy app, please run `rake prepare` first"
1
+ begin
2
+ require 'pry-nav'
3
+ rescue LoadError
4
+ # It's OK, we don't include pry in e.g. gemfiles/3.0.gemfile
6
5
  end
7
6
 
8
- require File.expand_path('../../test/dummy/config/environment', __FILE__)
9
- require 'rspec/rails'
10
- require 'rspec/autorun'
11
- require 'shoulda/matchers'
12
- require 'ffaker'
13
-
14
- # Requires supporting ruby files with custom matchers and macros, etc,
15
- # in spec/support/ and its subdirectories.
16
- Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
17
-
7
+ # This file was generated by the `rspec --init` command. Conventionally, all
8
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
10
+ # file to always be loaded, without a need to explicitly require it in any files.
11
+ #
12
+ # Given that it is always loaded, you are encouraged to keep this file as
13
+ # light-weight as possible. Requiring heavyweight dependencies from this file
14
+ # will add to the boot time of your test suite on EVERY test run, even for an
15
+ # individual file that may not need all of that loaded. Instead, consider making
16
+ # a separate helper file that requires the additional dependencies and performs
17
+ # the additional setup, and require it from the spec files that actually need it.
18
+ #
19
+ # The `.rspec` file also contains a few flags that are not defaults but that
20
+ # users commonly want.
21
+ #
18
22
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
23
  RSpec.configure do |config|
20
- config.treat_symbols_as_metadata_keys_with_true_values = true
24
+ # rspec-expectations config goes here. You can use an alternate
25
+ # assertion/expectation library such as wrong or the stdlib/minitest
26
+ # assertions if you prefer.
27
+ config.expect_with :rspec do |expectations|
28
+ # This option will default to `true` in RSpec 4. It makes the `description`
29
+ # and `failure_message` of custom matchers include text for helper methods
30
+ # defined using `chain`, e.g.:
31
+ # be_bigger_than(2).and_smaller_than(4).description
32
+ # # => "be bigger than 2 and smaller than 4"
33
+ # ...rather than:
34
+ # # => "be bigger than 2"
35
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
36
+ end
21
37
 
22
- # ## Mock Framework
23
- #
24
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
25
- #
26
- # config.mock_with :mocha
27
- # config.mock_with :flexmock
28
- # config.mock_with :rr
38
+ # rspec-mocks config goes here. You can use an alternate test double
39
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
40
+ config.mock_with :rspec do |mocks|
41
+ # Prevents you from mocking or stubbing a method that does not exist on
42
+ # a real object. This is generally recommended, and will default to
43
+ # `true` in RSpec 4.
44
+ mocks.verify_partial_doubles = true
45
+ end
29
46
 
30
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
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
+ # These two settings work together to allow you to limit a spec run
51
+ # to individual examples or groups you care about by tagging them with
52
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
53
+ # get run.
54
+ config.filter_run :focus
55
+ config.run_all_when_everything_filtered = true
32
56
 
33
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
34
- # examples within a transaction, remove the following line or assign false
35
- # instead of true.
36
- config.use_transactional_fixtures = true
57
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
58
+ # For more details, see:
59
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
60
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
61
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
62
+ config.disable_monkey_patching!
37
63
 
38
- # If true, the base class of anonymous controllers will be inferred
39
- # automatically. This will be the default behavior in future versions of
40
- # rspec-rails.
41
- config.infer_base_class_for_anonymous_controllers = false
64
+ # This setting enables warnings. It's recommended, but in some cases may
65
+ # be too noisy due to issues in dependencies.
66
+ config.warnings = true
67
+
68
+ # Many RSpec users commonly either run the entire suite or an individual
69
+ # file, and it's useful to allow more verbose output when running an
70
+ # individual spec file.
71
+ if config.files_to_run.one?
72
+ # Use the documentation formatter for detailed output,
73
+ # unless a formatter has already been configured
74
+ # (e.g. via a command-line flag).
75
+ config.default_formatter = 'doc'
76
+ end
77
+
78
+ # Print the 10 slowest examples and example groups at the
79
+ # end of the spec run, to help surface which specs are running
80
+ # particularly slow.
81
+ config.profile_examples = 10
42
82
 
43
83
  # Run specs in random order to surface order dependencies. If you find an
44
84
  # order dependency and want to debug it, you can fix the order by providing
45
85
  # the seed, which is printed after each run.
46
86
  # --seed 1234
47
- # config.order = 'random'
87
+ config.order = :random
88
+
89
+ # Seed global randomization in this process using the `--seed` CLI option.
90
+ # Setting this allows you to use `--seed` to deterministically reproduce
91
+ # test failures related to randomization by passing the same `--seed` value
92
+ # as the one that triggered the failure.
93
+ Kernel.srand config.seed
94
+ =end
48
95
  end