spree_iugu_bank_slip 3.0.4
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.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +9 -0
- data/Guardfile +90 -0
- data/LICENSE +26 -0
- data/README.md +48 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/backend/spree_iugu_bank_slip.js +2 -0
- data/app/assets/javascripts/spree/frontend/spree_iugu_bank_slip.js +2 -0
- data/app/assets/stylesheets/spree/backend/spree_iugu_bank_slip.css +3 -0
- data/app/assets/stylesheets/spree/frontend/spree_iugu_bank_slip.css +4 -0
- data/app/controllers/spree/admin/bank_slip_settings_controller.rb +27 -0
- data/app/controllers/spree/bank_slips_controller.rb +32 -0
- data/app/models/spree/bank_slip.rb +109 -0
- data/app/models/spree/payment_method/bank_slip.rb +175 -0
- data/app/overrides/spree/admin/shared/sub_menu/_configuration/add_bank_slip_settings_tab.html.erb.deface +2 -0
- data/app/overrides/spree/payments/_payment/add_bank_slip_info_to_details.html.erb.deface +8 -0
- data/app/views/spree/admin/bank_slip_settings/edit.html.erb +45 -0
- data/app/views/spree/admin/payments/source_forms/_bankslip.html.erb +3 -0
- data/app/views/spree/admin/payments/source_views/_bankslip.html.erb +39 -0
- data/app/views/spree/checkout/payment/_bankslip.html.erb +3 -0
- data/bin/rails +7 -0
- data/config/locales/en.yml +29 -0
- data/config/locales/pt-br.yml +29 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20160105163131_create_spree_bank_slips.rb +17 -0
- data/lib/generators/spree_iugu_bank_slip/install/install_generator.rb +31 -0
- data/lib/spree/bank_slip_configuration.rb +11 -0
- data/lib/spree_iugu_bank_slip.rb +4 -0
- data/lib/spree_iugu_bank_slip/engine.rb +33 -0
- data/lib/spree_iugu_bank_slip/factories.rb +32 -0
- data/spec/controllers/spree/bank_slips_controller_spec.rb +39 -0
- data/spec/features/admin/bank_slip_settings_spec.rb +63 -0
- data/spec/fixtures/iugu_responses/create.json +131 -0
- data/spec/fixtures/iugu_responses/create_error.json +136 -0
- data/spec/fixtures/iugu_responses/fetch.json +131 -0
- data/spec/models/spree/bank_slip_spec.rb +56 -0
- data/spec/models/spree/payment_method/bank_slip_spec.rb +90 -0
- data/spec/spec_helper.rb +99 -0
- data/spec/support/capybara_login.rb +13 -0
- data/spree_iugu_bank_slip.gemspec +42 -0
- metadata +402 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
{
|
2
|
+
"id": "1",
|
3
|
+
"due_date": "2016-01-09",
|
4
|
+
"currency": "BRL",
|
5
|
+
"discount_cents": null,
|
6
|
+
"email": "spree@example.com",
|
7
|
+
"items_total_cents": 1000,
|
8
|
+
"notification_url": null,
|
9
|
+
"return_url": null,
|
10
|
+
"status": "pending",
|
11
|
+
"tax_cents": null,
|
12
|
+
"updated_at": "2016-01-06T13:24:21-02:00",
|
13
|
+
"total_cents": 1000,
|
14
|
+
"total_paid_cents": 0,
|
15
|
+
"paid_at": null,
|
16
|
+
"taxes_paid_cents": null,
|
17
|
+
"paid_cents": null,
|
18
|
+
"cc_emails": null,
|
19
|
+
"financial_return_date": null,
|
20
|
+
"payable_with": "all",
|
21
|
+
"overpaid_cents": null,
|
22
|
+
"ignore_due_email": true,
|
23
|
+
"ignore_canceled_email": true,
|
24
|
+
"advance_fee_cents": null,
|
25
|
+
"secure_id": "1",
|
26
|
+
"secure_url": "http://localhost:3000",
|
27
|
+
"customer_id": null,
|
28
|
+
"customer_ref": null,
|
29
|
+
"customer_name": null,
|
30
|
+
"user_id": null,
|
31
|
+
"total": "R$ 10,00",
|
32
|
+
"taxes_paid": "R$ 0,00",
|
33
|
+
"total_paid": "R$ 0,00",
|
34
|
+
"total_overpaid": "R$ 0,00",
|
35
|
+
"fines_on_occurrence_day": null,
|
36
|
+
"total_on_occurrence_day": null,
|
37
|
+
"fines_on_occurrence_day_cents": null,
|
38
|
+
"total_on_occurrence_day_cents": null,
|
39
|
+
"advance_fee": null,
|
40
|
+
"paid": "R$ 0,00",
|
41
|
+
"interest": null,
|
42
|
+
"discount": null,
|
43
|
+
"created_at": "06/01, 13:24 h",
|
44
|
+
"refundable": null,
|
45
|
+
"installments": null,
|
46
|
+
"transaction_number": 1111,
|
47
|
+
"payment_method": null,
|
48
|
+
"created_at_iso": "2016-01-06T13:24:20-02:00",
|
49
|
+
"updated_at_iso": "2016-01-06T13:24:21-02:00",
|
50
|
+
"financial_return_dates": null,
|
51
|
+
"bank_slip": {
|
52
|
+
"digitable_line": "00000000000000000000000000000000000000000000000",
|
53
|
+
"barcode_data": "00000000000000000000000000000000000000000000",
|
54
|
+
"barcode": "http://localhost:3000"
|
55
|
+
},
|
56
|
+
"items": [
|
57
|
+
{
|
58
|
+
"id": "34F9D7F67E5244EF99796936CF208E35",
|
59
|
+
"description": "Item Um",
|
60
|
+
"price_cents": 1000,
|
61
|
+
"quantity": 1,
|
62
|
+
"created_at": "2016-01-06T13:24:20-02:00",
|
63
|
+
"updated_at": "2016-01-06T13:24:20-02:00",
|
64
|
+
"price": "R$ 10,00"
|
65
|
+
}
|
66
|
+
],
|
67
|
+
"variables": [
|
68
|
+
{
|
69
|
+
"id": "06B21226727C4121AC4BDB524DC0DA45",
|
70
|
+
"variable": "payer.address.country",
|
71
|
+
"value": "Brasil"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"id": "1D6D9BAA1D4E44F8A428B409371BF12F",
|
75
|
+
"variable": "payer.address.zip_code",
|
76
|
+
"value":"12122-00"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"id": "2D26D1E24B1240D1A42EF4826AF758E7",
|
80
|
+
"variable": "payer.phone",
|
81
|
+
"value": "12121212"
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"id": "34B880D1A6EA4A8F81583B8093AFC548",
|
85
|
+
"variable": "payer.phone_prefix",
|
86
|
+
"value": "11"
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"id": "5242B104C9F942A6A2891EB17B6AD3B1",
|
90
|
+
"variable": "payer.name",
|
91
|
+
"value": "Nome do Cliente"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"id": "605E45FCC8444E22A28BF38A2409582B",
|
95
|
+
"variable": "payer.address.number",
|
96
|
+
"value": "700"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"id": "726310D0E206478E8F5609813C35387B",
|
100
|
+
"variable": "payment_data.transaction_number",
|
101
|
+
"value": "1111"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"id": "9DEA3D530F12427896818A60BABF753A",
|
105
|
+
"variable": "payer.address.street",
|
106
|
+
"value": "Rua Tal"
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"id": "A4BD3C27296C440A8EC7F983F75132D8",
|
110
|
+
"variable": "payer.cpf_cnpj",
|
111
|
+
"value": "12312312312"
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"id": "E66AF99801BA4071ABBD80FDA6A1B534",
|
115
|
+
"variable": "payer.address.city",
|
116
|
+
"value": "São Paulo"
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"id": "E9197DB3A6A74B9BBA4BCDF2E9553774",
|
120
|
+
"variable": "payer.email",
|
121
|
+
"value": "spree@example.com"
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"id": "F2711AED42874D61ACC2D893EAAA43E0",
|
125
|
+
"variable": "payer.address.state",
|
126
|
+
"value": "SP"
|
127
|
+
}
|
128
|
+
],
|
129
|
+
"custom_variables": [],
|
130
|
+
"logs": [],
|
131
|
+
"errors": {
|
132
|
+
"due_date": [
|
133
|
+
"não pode ser anterior ao dia de hoje"
|
134
|
+
]
|
135
|
+
}
|
136
|
+
}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
{
|
2
|
+
"id": "1",
|
3
|
+
"due_date": "2016-01-09",
|
4
|
+
"currency": "BRL",
|
5
|
+
"discount_cents": null,
|
6
|
+
"email": "spree@example.com",
|
7
|
+
"items_total_cents": 1000,
|
8
|
+
"notification_url": null,
|
9
|
+
"return_url": null,
|
10
|
+
"status": "pending",
|
11
|
+
"tax_cents": null,
|
12
|
+
"updated_at": "2016-01-06T13:24:21-02:00",
|
13
|
+
"total_cents": 1000,
|
14
|
+
"total_paid_cents": 0,
|
15
|
+
"paid_at": null,
|
16
|
+
"taxes_paid_cents": null,
|
17
|
+
"paid_cents": null,
|
18
|
+
"cc_emails": null,
|
19
|
+
"financial_return_date": null,
|
20
|
+
"payable_with": "all",
|
21
|
+
"overpaid_cents": null,
|
22
|
+
"ignore_due_email": true,
|
23
|
+
"ignore_canceled_email": true,
|
24
|
+
"advance_fee_cents": null,
|
25
|
+
"secure_id": "1",
|
26
|
+
"secure_url": "http://localhost:3000",
|
27
|
+
"customer_id": null,
|
28
|
+
"customer_ref": null,
|
29
|
+
"customer_name": null,
|
30
|
+
"user_id": null,
|
31
|
+
"total": "R$ 10,00",
|
32
|
+
"taxes_paid": "R$ 0,00",
|
33
|
+
"total_paid": "R$ 0,00",
|
34
|
+
"total_overpaid": "R$ 0,00",
|
35
|
+
"fines_on_occurrence_day": null,
|
36
|
+
"total_on_occurrence_day": null,
|
37
|
+
"fines_on_occurrence_day_cents": null,
|
38
|
+
"total_on_occurrence_day_cents": null,
|
39
|
+
"advance_fee": null,
|
40
|
+
"paid": "R$ 0,00",
|
41
|
+
"interest": null,
|
42
|
+
"discount": null,
|
43
|
+
"created_at": "06/01, 13:24 h",
|
44
|
+
"refundable": null,
|
45
|
+
"installments": null,
|
46
|
+
"transaction_number": 1111,
|
47
|
+
"payment_method": null,
|
48
|
+
"created_at_iso": "2016-01-06T13:24:20-02:00",
|
49
|
+
"updated_at_iso": "2016-01-06T13:24:21-02:00",
|
50
|
+
"financial_return_dates": null,
|
51
|
+
"bank_slip": {
|
52
|
+
"digitable_line": "00000000000000000000000000000000000000000000000",
|
53
|
+
"barcode_data": "00000000000000000000000000000000000000000000",
|
54
|
+
"barcode": "http://localhost:3000"
|
55
|
+
},
|
56
|
+
"items": [
|
57
|
+
{
|
58
|
+
"id": "34F9D7F67E5244EF99796936CF208E35",
|
59
|
+
"description": "Item Um",
|
60
|
+
"price_cents": 1000,
|
61
|
+
"quantity": 1,
|
62
|
+
"created_at": "2016-01-06T13:24:20-02:00",
|
63
|
+
"updated_at": "2016-01-06T13:24:20-02:00",
|
64
|
+
"price": "R$ 10,00"
|
65
|
+
}
|
66
|
+
],
|
67
|
+
"variables": [
|
68
|
+
{
|
69
|
+
"id": "06B21226727C4121AC4BDB524DC0DA45",
|
70
|
+
"variable": "payer.address.country",
|
71
|
+
"value": "Brasil"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"id": "1D6D9BAA1D4E44F8A428B409371BF12F",
|
75
|
+
"variable": "payer.address.zip_code",
|
76
|
+
"value":"12122-00"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"id": "2D26D1E24B1240D1A42EF4826AF758E7",
|
80
|
+
"variable": "payer.phone",
|
81
|
+
"value": "12121212"
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"id": "34B880D1A6EA4A8F81583B8093AFC548",
|
85
|
+
"variable": "payer.phone_prefix",
|
86
|
+
"value": "11"
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"id": "5242B104C9F942A6A2891EB17B6AD3B1",
|
90
|
+
"variable": "payer.name",
|
91
|
+
"value": "Nome do Cliente"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"id": "605E45FCC8444E22A28BF38A2409582B",
|
95
|
+
"variable": "payer.address.number",
|
96
|
+
"value": "700"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"id": "726310D0E206478E8F5609813C35387B",
|
100
|
+
"variable": "payment_data.transaction_number",
|
101
|
+
"value": "1111"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"id": "9DEA3D530F12427896818A60BABF753A",
|
105
|
+
"variable": "payer.address.street",
|
106
|
+
"value": "Rua Tal"
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"id": "A4BD3C27296C440A8EC7F983F75132D8",
|
110
|
+
"variable": "payer.cpf_cnpj",
|
111
|
+
"value": "12312312312"
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"id": "E66AF99801BA4071ABBD80FDA6A1B534",
|
115
|
+
"variable": "payer.address.city",
|
116
|
+
"value": "São Paulo"
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"id": "E9197DB3A6A74B9BBA4BCDF2E9553774",
|
120
|
+
"variable": "payer.email",
|
121
|
+
"value": "spree@example.com"
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"id": "F2711AED42874D61ACC2D893EAAA43E0",
|
125
|
+
"variable": "payer.address.state",
|
126
|
+
"value": "SP"
|
127
|
+
}
|
128
|
+
],
|
129
|
+
"custom_variables": [],
|
130
|
+
"logs": []
|
131
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::BankSlip, type: :model do
|
4
|
+
|
5
|
+
let(:payment) { FactoryGirl.build(:payment) }
|
6
|
+
let(:slip) { FactoryGirl.build(:bank_slip, status: 'pending', payment: payment) }
|
7
|
+
|
8
|
+
it 'should return true when slip is pending' do
|
9
|
+
expect(slip.pending?).to be true
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'actions options' do
|
13
|
+
it 'should return when can capture the slip' do
|
14
|
+
payment.state = 'checkout'
|
15
|
+
expect(slip.can_capture?(payment)).to be true
|
16
|
+
|
17
|
+
payment.state = 'pending'
|
18
|
+
expect(slip.can_capture?(payment)).to be true
|
19
|
+
|
20
|
+
payment.state = 'void'
|
21
|
+
expect(slip.can_capture?(payment)).to be false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return when can void the slip' do
|
25
|
+
payment.state = 'checkout'
|
26
|
+
expect(slip.can_void?(payment)).to be true
|
27
|
+
|
28
|
+
payment.state = 'pending'
|
29
|
+
expect(slip.can_void?(payment)).to be true
|
30
|
+
|
31
|
+
payment.state = 'processing'
|
32
|
+
expect(slip.can_void?(payment)).to be true
|
33
|
+
|
34
|
+
payment.state = 'void'
|
35
|
+
expect(slip.can_void?(payment)).to be false
|
36
|
+
|
37
|
+
payment.state = 'failure'
|
38
|
+
expect(slip.can_void?(payment)).to be false
|
39
|
+
|
40
|
+
payment.state = 'invalid'
|
41
|
+
expect(slip.can_void?(payment)).to be false
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should return the actions to payments according to state' do
|
45
|
+
payment.state = 'checkout'
|
46
|
+
expect(slip.actions).to eq %w(capture void)
|
47
|
+
|
48
|
+
payment.state = 'processing'
|
49
|
+
expect(slip.actions).to eq %w(void)
|
50
|
+
|
51
|
+
payment.state = 'void'
|
52
|
+
expect(slip.actions).to eq []
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::PaymentMethod::BankSlip, type: :model do
|
4
|
+
|
5
|
+
let(:object) { create(:slip_payment_method) }
|
6
|
+
let!(:slip) { create(:bank_slip) }
|
7
|
+
|
8
|
+
before { Iugu.api_key = '' }
|
9
|
+
|
10
|
+
it 'payment_source_class should be BankSlip' do
|
11
|
+
expect(object.payment_source_class).to eq Spree::BankSlip
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'payment method should not be auto captured' do
|
15
|
+
expect(object.auto_capture).to be_falsey
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'authorize' do
|
19
|
+
|
20
|
+
it 'should authorize when Iugu create the invoice' do
|
21
|
+
stub_iugu
|
22
|
+
response = object.authorize '1599', slip, slip.payment.gateway_options
|
23
|
+
|
24
|
+
expect(response.success?).to be_truthy
|
25
|
+
expect(slip.amount).to eq 15.99
|
26
|
+
expect(slip.invoice_id).to eq '1'
|
27
|
+
expect(slip.payment_due).to eq Date.parse('2016-01-09')
|
28
|
+
expect(slip.url).to eq 'http://localhost:3000'
|
29
|
+
expect(slip.pdf).to eq 'http://localhost:3000.pdf'
|
30
|
+
expect(slip.pending?).to be true
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should unauthorize when Iugu return error' do
|
34
|
+
stub_iugu 'create_error'
|
35
|
+
Spree::BankSlipConfig[:days_to_due_date] = -10
|
36
|
+
response = object.authorize '1599', slip, slip.payment.gateway_options
|
37
|
+
|
38
|
+
expect(response.success?).to be_falsey
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'capture' do
|
44
|
+
object.capture '1599', '1', slip.payment.gateway_options
|
45
|
+
|
46
|
+
expect(slip.reload.paid?).to be_truthy
|
47
|
+
expect(slip.paid_in).to eq Date.today
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'void' do
|
51
|
+
it 'should void successfully' do
|
52
|
+
object.void '1', slip.payment.gateway_options
|
53
|
+
expect(slip.reload.canceled?).to be_truthy
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should return error when bank slip not found' do
|
57
|
+
response = object.void 10, slip.payment.gateway_options
|
58
|
+
expect(response.success?).to be_falsey
|
59
|
+
expect(slip.reload.canceled?).to be_falsey
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'cancel' do
|
64
|
+
it 'should cancel successfully' do
|
65
|
+
object.cancel 1
|
66
|
+
expect(slip.reload.canceled?).to be_truthy
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should return error when bank slip not found' do
|
70
|
+
response = object.cancel 10
|
71
|
+
expect(response.success?).to be_falsey
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def stub_iugu(filename = 'create')
|
76
|
+
create_response = JSON.parse File.read("spec/fixtures/iugu_responses/#{filename}.json")
|
77
|
+
|
78
|
+
# Stub da criacao da fatura
|
79
|
+
stub_request(:post, 'https://api.iugu.com/v1/invoices').
|
80
|
+
with(headers: {'Accept'=>'application/json',
|
81
|
+
'Accept-Charset'=>'utf-8',
|
82
|
+
'Accept-Encoding'=>'gzip, deflate',
|
83
|
+
'Accept-Language'=>'pt-br;q=0.9,pt-BR',
|
84
|
+
'Content-Type'=>'application/json; charset=utf-8',
|
85
|
+
'User-Agent'=>'Iugu RubyLibrary'},
|
86
|
+
body: hash_including({'method' => 'bank_slip'})).
|
87
|
+
to_return(body: create_response.to_json, status: 200)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# Run Coverage report
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter 'spec/dummy'
|
5
|
+
add_group 'Controllers', 'app/controllers'
|
6
|
+
add_group 'Helpers', 'app/helpers'
|
7
|
+
add_group 'Mailers', 'app/mailers'
|
8
|
+
add_group 'Models', 'app/models'
|
9
|
+
add_group 'Views', 'app/views'
|
10
|
+
add_group 'Libraries', 'lib'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Configure Rails Environment
|
14
|
+
ENV['RAILS_ENV'] = 'test'
|
15
|
+
|
16
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
17
|
+
|
18
|
+
require 'rspec/rails'
|
19
|
+
require 'database_cleaner'
|
20
|
+
require 'ffaker'
|
21
|
+
|
22
|
+
require 'capybara/poltergeist'
|
23
|
+
Capybara.javascript_driver = :poltergeist
|
24
|
+
|
25
|
+
require 'webmock/rspec'
|
26
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
27
|
+
|
28
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
29
|
+
# in spec/support/ and its subdirectories.
|
30
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
31
|
+
|
32
|
+
# Requires factories and other useful helpers defined in spree_core.
|
33
|
+
require 'spree/testing_support/authorization_helpers'
|
34
|
+
require 'spree/testing_support/capybara_ext'
|
35
|
+
require 'spree/testing_support/controller_requests'
|
36
|
+
require 'spree/testing_support/factories'
|
37
|
+
require 'spree/testing_support/url_helpers'
|
38
|
+
|
39
|
+
# Requires factories defined in lib/spree_iugu_bank_slip/factories.rb
|
40
|
+
require 'spree_iugu_bank_slip/factories'
|
41
|
+
|
42
|
+
RSpec.configure do |config|
|
43
|
+
config.include FactoryGirl::Syntax::Methods
|
44
|
+
|
45
|
+
# Infer an example group's spec type from the file location.
|
46
|
+
config.infer_spec_type_from_file_location!
|
47
|
+
|
48
|
+
# == URL Helpers
|
49
|
+
#
|
50
|
+
# Allows access to Spree's routes in specs:
|
51
|
+
#
|
52
|
+
# visit spree.admin_path
|
53
|
+
# current_path.should eql(spree.products_path)
|
54
|
+
config.include Spree::TestingSupport::UrlHelpers
|
55
|
+
|
56
|
+
# == Requests support
|
57
|
+
#
|
58
|
+
# Adds convenient methods to request Spree's controllers
|
59
|
+
# spree_get :index
|
60
|
+
config.include Spree::TestingSupport::ControllerRequests, type: :controller
|
61
|
+
|
62
|
+
# == Mock Framework
|
63
|
+
#
|
64
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
65
|
+
#
|
66
|
+
# config.mock_with :mocha
|
67
|
+
# config.mock_with :flexmock
|
68
|
+
# config.mock_with :rr
|
69
|
+
config.mock_with :rspec
|
70
|
+
config.color = true
|
71
|
+
|
72
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
73
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
74
|
+
|
75
|
+
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
76
|
+
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
77
|
+
# to setup a test will be unavailable to the browser, which runs under a separate server instance.
|
78
|
+
config.use_transactional_fixtures = false
|
79
|
+
|
80
|
+
# Ensure Suite is set to use transactions for speed.
|
81
|
+
config.before :suite do
|
82
|
+
DatabaseCleaner.strategy = :transaction
|
83
|
+
DatabaseCleaner.clean_with :truncation
|
84
|
+
end
|
85
|
+
|
86
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
87
|
+
config.before :each do
|
88
|
+
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
89
|
+
DatabaseCleaner.start
|
90
|
+
end
|
91
|
+
|
92
|
+
# After each spec clean the database.
|
93
|
+
config.after :each do
|
94
|
+
DatabaseCleaner.clean
|
95
|
+
end
|
96
|
+
|
97
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
98
|
+
config.order = "random"
|
99
|
+
end
|