add transaction controller spec
This commit is contained in:
parent
3d8b1e9c60
commit
5d97041e29
2 changed files with 18 additions and 0 deletions
|
@ -1,5 +1,21 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe TransactionsController, type: :controller do
|
RSpec.describe TransactionsController, type: :controller do
|
||||||
|
describe "creating transaction" do
|
||||||
|
before :each do
|
||||||
|
@debtor = create(:user)
|
||||||
|
@creditor = create(:user)
|
||||||
|
sign_in @debtor
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should create a valid transaction" do
|
||||||
|
expect do
|
||||||
|
put :create, { transaction: {
|
||||||
|
creditor: @creditor.name,
|
||||||
|
amount: 20,
|
||||||
|
message: "hoi"
|
||||||
|
}}
|
||||||
|
end.to change {Transaction.count}.by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,8 +17,10 @@
|
||||||
#
|
#
|
||||||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||||
require 'factory_girl'
|
require 'factory_girl'
|
||||||
|
require 'devise'
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include FactoryGirl::Syntax::Methods
|
config.include FactoryGirl::Syntax::Methods
|
||||||
|
config.include Devise::TestHelpers, type: :controller
|
||||||
# rspec-expectations config goes here. You can use an alternate
|
# rspec-expectations config goes here. You can use an alternate
|
||||||
# assertion/expectation library such as wrong or the stdlib/minitest
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||||
# assertions if you prefer.
|
# assertions if you prefer.
|
||||||
|
|
Loading…
Reference in a new issue