add transaction controller spec

This commit is contained in:
Ilion Beyst 2015-09-09 14:37:40 +02:00
parent 3d8b1e9c60
commit 5d97041e29
2 changed files with 18 additions and 0 deletions

View File

@ -1,5 +1,21 @@
require 'rails_helper'
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

View File

@ -17,8 +17,10 @@
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'factory_girl'
require 'devise'
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.include Devise::TestHelpers, type: :controller
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.