punto_pagos_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +36 -0
- data/app/assets/javascripts/punto_pagos_rails/application.js +13 -0
- data/app/assets/stylesheets/punto_pagos_rails/application.css +49 -0
- data/app/controllers/punto_pagos_rails/application_controller.rb +4 -0
- data/app/controllers/punto_pagos_rails/transactions_controller.rb +50 -0
- data/app/helpers/punto_pagos_rails/application_helper.rb +4 -0
- data/app/models/punto_pagos_rails/transaction.rb +35 -0
- data/app/views/layouts/punto_pagos_rails/application.html.erb +14 -0
- data/config/locales/en.yml +12 -0
- data/config/locales/es.yml +12 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20140928003539_create_punto_pagos_rails_transactions.rb +13 -0
- data/lib/generators/punto_pagos_rails/install/USAGE +8 -0
- data/lib/generators/punto_pagos_rails/install/install_generator.rb +47 -0
- data/lib/generators/punto_pagos_rails/install/templates/error.html.erb +6 -0
- data/lib/generators/punto_pagos_rails/install/templates/punto_pagos_rails.rb +3 -0
- data/lib/generators/punto_pagos_rails/install/templates/puntopagos.yml +13 -0
- data/lib/generators/punto_pagos_rails/install/templates/success.html.erb +6 -0
- data/lib/punto_pagos_rails.rb +18 -0
- data/lib/punto_pagos_rails/engine.rb +10 -0
- data/lib/punto_pagos_rails/resource_extension.rb +20 -0
- data/lib/punto_pagos_rails/transaction_service.rb +87 -0
- data/lib/punto_pagos_rails/version.rb +3 -0
- data/lib/tasks/punto_pagos_rails_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/home_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/ticket.rb +4 -0
- data/spec/dummy/app/views/home/index.html.erb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/punto_pagos_rails/transactions/error.html.erb +6 -0
- data/spec/dummy/app/views/punto_pagos_rails/transactions/success.html.erb +6 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/punto_pagos_rails.rb +3 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puntopagos.yml +12 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20141026172010_create_tickets.rb +9 -0
- data/spec/dummy/db/migrate/20141026172011_create_punto_pagos_rails_transactions.punto_pagos_rails.rb +14 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +5364 -0
- data/spec/dummy/log/test.log +3753 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/factories/tickets.rb +5 -0
- data/spec/dummy/spec/lib/punto_pagos_rails/transaction_service_spec.rb +140 -0
- data/spec/dummy/spec/models/punto_pagos_rails/transaction_spec.rb +7 -0
- data/spec/dummy/spec/models/ticket_spec.rb +7 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/913223216b0b1897b0ec8d3b22ba52c7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9e9c010aa4c17a17d0ba371813cd1804 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b6844dbdd15de17485877b0ac65e829e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c9ab7add939c37b818c61fa4f1ada3ab +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cc9bafdd79b6777f18f5680c8d5e5aee +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f0bf33738d12f42f7b9f302975b8a9d7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/rails_helper.rb +22 -0
- data/spec/spec_helper.rb +78 -0
- metadata +354 -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,140 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
include PuntoPagosRails
|
4
|
+
|
5
|
+
RSpec.describe TransactionService do
|
6
|
+
|
7
|
+
let(:ticket) { Ticket.create amount: 22 }
|
8
|
+
let(:service) { TransactionService.new(ticket.id) }
|
9
|
+
let(:request) { double }
|
10
|
+
let(:response) { double }
|
11
|
+
let(:token) { 'XXXXX' }
|
12
|
+
let(:payment_process_url) { double }
|
13
|
+
let(:notification) { double }
|
14
|
+
let(:transaction) { Transaction.create }
|
15
|
+
|
16
|
+
before do
|
17
|
+
allow(PuntoPagos::Request).to receive(:new).and_return(request)
|
18
|
+
allow(request).to receive(:create).and_return(response)
|
19
|
+
allow(response).to receive(:success?).and_return(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#create" do
|
23
|
+
it "creates transaction" do
|
24
|
+
expect { service.create }.to change { ticket.reload.transactions.size }.by(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
context "success" do
|
28
|
+
before do
|
29
|
+
allow(response).to receive(:success?).and_return(true)
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with succesful initialization" do
|
33
|
+
before do
|
34
|
+
allow(response).to receive(:get_token).and_return(token)
|
35
|
+
allow(response).to receive(:payment_process_url).and_return(payment_process_url)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns true" do
|
39
|
+
expect(service.create).to eq(true)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has the correct token" do
|
43
|
+
service.create
|
44
|
+
expect(ticket.transactions.last.token).to eq(token)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns payment process url" do
|
48
|
+
service.create
|
49
|
+
expect(service.process_url).to eq(payment_process_url)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with unsuccesful initialization" do
|
54
|
+
|
55
|
+
it "returns false with invalid token" do
|
56
|
+
allow(response).to receive(:get_token).and_return(nil)
|
57
|
+
expect(service.create).to eq(false)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "fails with repeated token" do
|
61
|
+
Transaction.create(token: 'REPEATED_TOKEN')
|
62
|
+
allow(response).to receive(:get_token).and_return('REPEATED_TOKEN')
|
63
|
+
expect(service.create).to eq(false)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
context "error" do
|
71
|
+
|
72
|
+
it "returns false" do
|
73
|
+
expect(service.create).to eq(false)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "sets resource error" do
|
77
|
+
allow(Ticket).to receive(:find).with(ticket.id).and_return(ticket)
|
78
|
+
service.create
|
79
|
+
expect(ticket.errors[:base]).to include(
|
80
|
+
I18n.t("activerecord.errors.models.ticket.attributes.base.invalid_puntopagos_response"))
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#notificate" do
|
87
|
+
|
88
|
+
before do
|
89
|
+
allow(PuntoPagos::Notification).to receive(:new).and_return(notification)
|
90
|
+
allow(notification).to receive(:valid?).with({}, {}).and_return(true)
|
91
|
+
allow(PuntoPagosRails::Transaction).to receive(:find_by_token).and_return(transaction)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "creates a notification" do
|
95
|
+
TransactionService.notificate({}, {})
|
96
|
+
expect(PuntoPagos::Notification).to have_received(:new)
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when the notification is valid" do
|
100
|
+
|
101
|
+
it "the notification is completed" do
|
102
|
+
TransactionService.notificate({}, {})
|
103
|
+
expect(transaction.reload.state).to eq('completed')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when the notification is invalid" do
|
108
|
+
before do
|
109
|
+
allow(notification).to receive(:valid?).with({}, {}).and_return(false)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "the notification is rejected" do
|
113
|
+
TransactionService.notificate({}, {})
|
114
|
+
expect(transaction.reload.state).to eq('rejected')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "when the notification is completed" do
|
119
|
+
before do
|
120
|
+
transaction.update_column :state, 'completed'
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should not be rejectable" do
|
124
|
+
TransactionService.notificate({}, {})
|
125
|
+
expect(transaction.reload.state).to_not eq('rejected')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "when the notification is rejected" do
|
130
|
+
before do
|
131
|
+
transaction.update_column :state, 'rejected'
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should not be completable" do
|
135
|
+
TransactionService.notificate({}, {})
|
136
|
+
expect(transaction.reload.state).to_not eq('completed')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= 'test'
|
2
|
+
|
3
|
+
require 'rspec/rails'
|
4
|
+
require 'spec_helper'
|
5
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
6
|
+
require 'factory_girl_rails'
|
7
|
+
require 'shoulda-matchers'
|
8
|
+
|
9
|
+
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
10
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
11
|
+
|
12
|
+
ActiveRecord::Migration.maintain_test_schema!
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.use_transactional_fixtures = true
|
16
|
+
config.infer_spec_type_from_file_location!
|
17
|
+
config.order = :random
|
18
|
+
config.render_views
|
19
|
+
config.include FactoryGirl::Syntax::Methods
|
20
|
+
|
21
|
+
FactoryGirl::SyntaxRunner.send(:include, RSpec::Mocks::ExampleMethods)
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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
|