approvable 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +21 -0
  5. data/app/models/approvable/change_request.rb +57 -0
  6. data/db/migrate/20140807145534_create_approvable_change_requests.rb +14 -0
  7. data/lib/approvable/acts_as_approvable.rb +85 -0
  8. data/lib/approvable/engine.rb +41 -0
  9. data/lib/approvable/version.rb +3 -0
  10. data/lib/approvable.rb +4 -0
  11. data/spec/dummy/README.rdoc +28 -0
  12. data/spec/dummy/Rakefile +6 -0
  13. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  14. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  15. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  16. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  17. data/spec/dummy/app/models/listing.rb +3 -0
  18. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  19. data/spec/dummy/bin/bundle +3 -0
  20. data/spec/dummy/bin/rails +4 -0
  21. data/spec/dummy/bin/rake +4 -0
  22. data/spec/dummy/config/application.rb +29 -0
  23. data/spec/dummy/config/boot.rb +5 -0
  24. data/spec/dummy/config/database.yml +85 -0
  25. data/spec/dummy/config/environment.rb +5 -0
  26. data/spec/dummy/config/environments/development.rb +37 -0
  27. data/spec/dummy/config/environments/production.rb +82 -0
  28. data/spec/dummy/config/environments/test.rb +39 -0
  29. data/spec/dummy/config/initializers/assets.rb +8 -0
  30. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  31. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  32. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  33. data/spec/dummy/config/initializers/inflections.rb +16 -0
  34. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  35. data/spec/dummy/config/initializers/session_store.rb +3 -0
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  37. data/spec/dummy/config/locales/en.yml +23 -0
  38. data/spec/dummy/config/routes.rb +4 -0
  39. data/spec/dummy/config/secrets.yml +22 -0
  40. data/spec/dummy/config.ru +4 -0
  41. data/spec/dummy/db/migrate/20140807144654_create_listings.rb +12 -0
  42. data/spec/dummy/db/schema.rb +28 -0
  43. data/spec/dummy/log/development.log +339 -0
  44. data/spec/dummy/log/test.log +33704 -0
  45. data/spec/dummy/public/404.html +67 -0
  46. data/spec/dummy/public/422.html +67 -0
  47. data/spec/dummy/public/500.html +66 -0
  48. data/spec/dummy/public/favicon.ico +0 -0
  49. data/spec/factories/change_requests.rb +50 -0
  50. data/spec/factories/listing.rb +15 -0
  51. data/spec/models/acts_as_approvable_spec.rb +192 -0
  52. data/spec/models/approvable/change_request_spec.rb +61 -0
  53. data/spec/rails_helper.rb +52 -0
  54. data/spec/spec_helper.rb +78 -0
  55. data/spec/support/factory_girl.rb +5 -0
  56. metadata +228 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,50 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :change_request, :class => 'Approvable::ChangeRequest' do
5
+ association :approvable, factory: [:listing, :approved]
6
+ requested_changes {{title: "new_#{approvable.title}"}}
7
+
8
+
9
+ trait :approved do
10
+ after(:create) {|c| c.submit; c.approve}
11
+ end
12
+
13
+ trait :pending do
14
+ end
15
+
16
+ trait :submitted do
17
+ after(:create) {|c| c.submit}
18
+ end
19
+
20
+ trait :rejected do
21
+ after(:create) {|c| c.submit; c.reject}
22
+ end
23
+
24
+
25
+ # trait :pending do
26
+ # submitted_at nil
27
+ # approved_at nil
28
+ # rejected_at nil
29
+ # end
30
+ #
31
+ # trait :submitted do
32
+ # submitted_at {Time.now}
33
+ # approved_at nil
34
+ # rejected_at nil
35
+ # end
36
+ #
37
+ # trait :approved do
38
+ # submitted_at {Time.now}
39
+ # approved_at {Time.now}
40
+ # rejected_at nil
41
+ # end
42
+ #
43
+ # trait :rejected do
44
+ # submitted_at {Time.now}
45
+ # approved_at nil
46
+ # rejected_at {Time.now}
47
+ # end
48
+
49
+ end
50
+ end
@@ -0,0 +1,15 @@
1
+ FactoryGirl.define do
2
+ factory :listing do
3
+ sequence(:title) {|n| "Title #{n}"}
4
+ sequence(:description) {|n| "A long description #{n}"}
5
+
6
+ trait :approved do
7
+ after(:create) do |listing|
8
+ listing.submit_changes
9
+ listing.approve_changes
10
+ listing.reload
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,192 @@
1
+ require 'rails_helper'
2
+
3
+ module Approvable
4
+ describe ActsAsApprovable do
5
+ before do
6
+ @listing = create(:listing, :approved)
7
+ end
8
+
9
+ it 'responds to acts_as_approvable to class' do
10
+ expect(Listing).to respond_to :acts_as_approvable
11
+ end
12
+
13
+ it 'responds to with_changes method' do
14
+ expect(@listing).to respond_to :with_changes
15
+ end
16
+
17
+ it 'has_many change_requests' do
18
+ expect(@listing).to respond_to :change_requests
19
+ end
20
+
21
+ it 'has_one current_change_request' do
22
+ expect(@listing).to respond_to :current_change_request
23
+ end
24
+
25
+ it 'returns last unapproved change request' do
26
+ create(:change_request, :approved, approvable: @listing )
27
+ create(:change_request, :approved, approvable: @listing )
28
+ change_request = create(:change_request, :submitted, approvable: @listing )
29
+ @listing.reload
30
+
31
+ expect(@listing.current_change_request).to eq change_request
32
+ end
33
+
34
+ it 'returns nil if no unapproved change request' do
35
+ create(:change_request, :approved, approvable: @listing )
36
+ create(:change_request, :approved, approvable: @listing )
37
+
38
+ expect(@listing.current_change_request).to be nil
39
+ end
40
+
41
+ it 'delegates change_status to current_change_request' do
42
+ create(:change_request, :approved, approvable: @listing )
43
+ create(:change_request, :submitted, approvable: @listing )
44
+ @listing.reload
45
+
46
+ expect(@listing.change_status).to eq 'submitted'
47
+ end
48
+
49
+ it 'returns nil if no current_change_request' do
50
+ create(:change_request, :approved, approvable: @listing )
51
+ create(:change_request, :approved, approvable: @listing )
52
+
53
+ expect(@listing.change_status).to be nil
54
+ end
55
+
56
+ it 'wont create a new change request if there is a current one' do
57
+ create(:change_request, :approved, approvable: @listing )
58
+ create(:change_request, :approved, approvable: @listing )
59
+ create(:change_request, :submitted, approvable: @listing )
60
+
61
+ expect{
62
+ create(:change_request, :submitted, approvable: @listing )
63
+ }.to raise_error ActiveRecord::RecordInvalid
64
+ end
65
+
66
+ it 'creates a new change request for an new listing' do
67
+ expect{
68
+ @listing.update(title: 'a brand new title')
69
+ }.to change {@listing.change_requests.count}.by(1)
70
+ end
71
+
72
+ it 'returns listing with requested changes' do
73
+ @listing.update(title: 'a brand new title')
74
+
75
+ expect(@listing.title).not_to eq 'a brand new title'
76
+ expect(@listing.with_changes.title).to eq 'a brand new title'
77
+ end
78
+
79
+ it 'creates a new change request for an approved listing and doesnt change exiting' do
80
+ change_request = create(:change_request, :approved, approvable: @listing )
81
+ expect{
82
+ @listing.update(title: 'a brand new title')
83
+ }.to change {@listing.change_requests.count}.by(1)
84
+
85
+ change_request.reload
86
+ expect(change_request.changed_attributes).not_to match title: 'a brand new title'
87
+ end
88
+
89
+ it 'updates a pending change request for a pending listing' do
90
+ change_request = create(:change_request, :pending, approvable: @listing )
91
+ @listing.reload
92
+
93
+ expect{
94
+ @listing.update(title: 'a brand new title')
95
+ }.not_to change {@listing.change_requests.count}
96
+
97
+ change_request.reload
98
+ expect(change_request.requested_changes).to match "title" => 'a brand new title'
99
+ expect(change_request.state).to eq 'pending'
100
+ end
101
+
102
+ it 'keeps previous changes and adds new changes' do
103
+ change_request = create(:change_request, :pending, requested_changes: {"title" => 'a brand new title'}, approvable: @listing )
104
+ @listing.reload
105
+
106
+ expect{
107
+ @listing.update(description: 'a hot bod')
108
+ }.not_to change {@listing.change_requests.count}
109
+
110
+ change_request.reload
111
+ expect(change_request.requested_changes).to match "title" => 'a brand new title', "description" => 'a hot bod'
112
+ expect(change_request.state).to eq 'pending'
113
+ end
114
+
115
+ it 'cant update an existing listing if a change is already submitted' do
116
+ change_request = create(:change_request, :submitted, approvable: @listing )
117
+ @listing.reload
118
+
119
+ expect{
120
+ @listing.update!(title: 'a brand new title')
121
+ puts change_request.errors.full_messages.inspect
122
+ puts @listing.errors.full_messages.inspect
123
+
124
+ }.to raise_error ActiveRecord::RecordInvalid
125
+
126
+ change_request.reload
127
+ expect(change_request.requested_changes).not_to match "title" => 'a brand new title'
128
+ expect(change_request.state).to eq 'submitted'
129
+ end
130
+
131
+ it 'updates an existing change request for a rejected listing and changes the status to pending' do
132
+ change_request = create(:change_request, :rejected, approvable: @listing )
133
+ @listing.reload
134
+
135
+ expect{
136
+ @listing.update!(title: 'a brand new title')
137
+ }.not_to change {@listing.change_requests.count}
138
+
139
+ change_request.reload
140
+
141
+ expect(change_request.requested_changes).to match "title" => 'a brand new title'
142
+ expect(change_request.state).to eq 'pending'
143
+ end
144
+
145
+ it 'submits changes' do
146
+ @listing.update(title: 'a brand new title')
147
+ @listing.submit_changes
148
+
149
+ expect(@listing.change_status).to eq 'submitted'
150
+ @listing.reload
151
+
152
+ expect(@listing.title).not_to eq 'a brand new title'
153
+ end
154
+
155
+ it 'unsubmits changes' do
156
+ @listing.update(title: 'a brand new title')
157
+ @listing.submit_changes
158
+ @listing.unsubmit_changes
159
+
160
+ expect(@listing.change_status).to eq 'pending'
161
+ @listing.reload
162
+
163
+ expect(@listing.title).not_to eq 'a brand new title'
164
+ end
165
+
166
+ it 'approves changes' do
167
+ @listing.update(title: 'a brand new title')
168
+ @listing.submit_changes
169
+
170
+ @listing.approve_changes
171
+ @listing.reload
172
+
173
+ expect(@listing.title).to eq 'a brand new title'
174
+ expect(@listing.current_change_request).to be nil
175
+ expect(@listing.change_status).to be nil
176
+ end
177
+
178
+
179
+ it 'rejects changes' do
180
+ @listing.update(title: 'a brand new title')
181
+ @listing.submit_changes
182
+ @listing.reject_changes
183
+ @listing.reload
184
+
185
+ expect(@listing.title).not_to eq 'a brand new title'
186
+ expect(@listing.change_status).to eq 'rejected'
187
+ end
188
+
189
+
190
+
191
+ end
192
+ end
@@ -0,0 +1,61 @@
1
+ require 'rails_helper'
2
+
3
+ module Approvable
4
+ describe ChangeRequest, :type => :model do
5
+
6
+ before {@request = create(:change_request)}
7
+
8
+
9
+ it 'creates a change request as pending' do
10
+ expect(@request.state).to eq 'pending'
11
+ end
12
+
13
+ it 'wont create new request unless all others are approved' do
14
+ approvable = @request.approvable
15
+ expect{create(:change_request, approvable: approvable)}.to raise_error ActiveRecord::RecordInvalid
16
+
17
+ @request.submit
18
+ expect{create(:change_request, approvable: approvable)}.to raise_error ActiveRecord::RecordInvalid
19
+
20
+ @request.reject
21
+ expect{create(:change_request, approvable: approvable)}.to raise_error ActiveRecord::RecordInvalid
22
+
23
+ @request.submit
24
+ @request.approve
25
+ expect{create(:change_request, approvable: approvable)}.not_to raise_error
26
+ end
27
+
28
+ it 'cannot update requested_changes once submitted' do
29
+ @request.submit
30
+ expect{
31
+ @request.update!(requested_changes: {title: 'a brand new title'})
32
+ }.to raise_error ActiveRecord::RecordInvalid
33
+ end
34
+
35
+ it 'cannot update requested_changes once approved' do
36
+ @request.submit
37
+ @request.approve
38
+ expect{
39
+ @request.update!(requested_changes: {title: 'a brand new title'})
40
+ }.to raise_error ActiveRecord::RecordInvalid
41
+ end
42
+
43
+ it 'cannot transition out of approved' do
44
+ @request.submit
45
+ @request.approve
46
+
47
+ expect{@request.reject!}.to raise_error StateMachine::InvalidTransition
48
+ expect{@request.submit!}.to raise_error StateMachine::InvalidTransition
49
+ expect{@request.unreject!}.to raise_error StateMachine::InvalidTransition
50
+ end
51
+
52
+ it 'rejected reverts to pending after changed_attributes change' do
53
+ @request.submit
54
+ @request.reject
55
+ @request.update(requested_changes: {title: 'a brand new title'})
56
+
57
+ expect(@request.state).to eq 'pending'
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,52 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
+ require 'spec_helper'
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'factory_girl_rails'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc, in
9
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
10
+ # run as spec files by default. This means that files in spec/support that end
11
+ # in _spec.rb will both be required and run as specs, causing the specs to be
12
+ # run twice. It is recommended that you do not name files matching this glob to
13
+ # end with _spec.rb. You can configure this pattern with the --pattern
14
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
15
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
16
+
17
+ # Checks for pending migrations before tests are run.
18
+ # If you are not using ActiveRecord, you can remove this line.
19
+ ActiveRecord::Migration.maintain_test_schema!
20
+
21
+ Rails.backtrace_cleaner.remove_silencers!
22
+
23
+
24
+ RSpec.configure do |config|
25
+ config.include FactoryGirl::Syntax::Methods
26
+
27
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
28
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
29
+ config.mock_with :rspec
30
+ config.infer_base_class_for_anonymous_controllers = false
31
+ config.order = "random"
32
+
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
37
+
38
+ # RSpec Rails can automatically mix in different behaviours to your tests
39
+ # based on their file location, for example enabling you to call `get` and
40
+ # `post` in specs under `spec/controllers`.
41
+ #
42
+ # You can disable this behaviour by removing the line below, and instead
43
+ # explicitly tag your specs with their type, e.g.:
44
+ #
45
+ # RSpec.describe UsersController, :type => :controller do
46
+ # # ...
47
+ # end
48
+ #
49
+ # The different available types are documented in the features, such as in
50
+ # https://relishapp.com/rspec/rspec-rails/docs
51
+ config.infer_spec_type_from_file_location!
52
+ end
@@ -0,0 +1,78 @@
1
+ # This file was generated by the `rails generate rspec:install` 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 this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ =begin
21
+ # These two settings work together to allow you to limit a spec run
22
+ # to individual examples or groups you care about by tagging them with
23
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
+ # get run.
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+
28
+ # Many RSpec users commonly either run the entire suite or an individual
29
+ # file, and it's useful to allow more verbose output when running an
30
+ # individual spec file.
31
+ if config.files_to_run.one?
32
+ # Use the documentation formatter for detailed output,
33
+ # unless a formatter has already been configured
34
+ # (e.g. via a command-line flag).
35
+ config.default_formatter = 'doc'
36
+ end
37
+
38
+ # Print the 10 slowest examples and example groups at the
39
+ # end of the spec run, to help surface which specs are running
40
+ # particularly slow.
41
+ config.profile_examples = 10
42
+
43
+ # Run specs in random order to surface order dependencies. If you find an
44
+ # order dependency and want to debug it, you can fix the order by providing
45
+ # the seed, which is printed after each run.
46
+ # --seed 1234
47
+ config.order = :random
48
+
49
+ # Seed global randomization in this process using the `--seed` CLI option.
50
+ # Setting this allows you to use `--seed` to deterministically reproduce
51
+ # test failures related to randomization by passing the same `--seed` value
52
+ # as the one that triggered the failure.
53
+ Kernel.srand config.seed
54
+
55
+ # rspec-expectations config goes here. You can use an alternate
56
+ # assertion/expectation library such as wrong or the stdlib/minitest
57
+ # assertions if you prefer.
58
+ config.expect_with :rspec do |expectations|
59
+ # Enable only the newer, non-monkey-patching expect syntax.
60
+ # For more details, see:
61
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
62
+ expectations.syntax = :expect
63
+ end
64
+
65
+ # rspec-mocks config goes here. You can use an alternate test double
66
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
67
+ config.mock_with :rspec do |mocks|
68
+ # Enable only the newer, non-monkey-patching expect syntax.
69
+ # For more details, see:
70
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
+ mocks.syntax = :expect
72
+
73
+ # Prevents you from mocking or stubbing a method that does not exist on
74
+ # a real object. This is generally recommended.
75
+ mocks.verify_partial_doubles = true
76
+ end
77
+ =end
78
+ end
@@ -0,0 +1,5 @@
1
+ require 'factory_girl_rails'
2
+
3
+ RSpec.configure do |config|
4
+ config.include FactoryGirl::Syntax::Methods
5
+ end