Sha256: 1a9f584e16507e488f2f5148ee3f768be67f0a9afd8f327093adc6a4d50ac814

Contents?: true

Size: 1.5 KB

Versions: 24

Compression:

Stored size: 1.5 KB

Contents

require 'test_helper'


def test_regex(str)
  /Account balance/.match(str)
end

test_regex("<dt>Account balance:</dt>")


class Kaui::AccountsControllerTest < ActionController::TestCase
  fixtures :accounts

  test "should get index" do
    get :index, :use_route => 'kaui'
    assert_response :success
  end

  test "should find account by id" do
    pierre = accounts(:pierre)

    get :show, :id => pierre["accountId"], :use_route => 'kaui'
    assert_response :success
    assert_equal assigns(:account).account_id, pierre["accountId"]
  end


  test "should find correct positive balance" do
    accnt = accounts(:account_with_positive_balance)

    get :show, :id => accnt["accountId"], :use_route => 'kaui'
    assert_response :success
    assert assigns(:account).balance > 0

    #puts @response.body

    assert_select "dd" do |elements|
      elements.each do |element|
        if /span/.match(element.to_s)
          assert_select "span" do |inner|
            assert /"label label-important"/.match(inner[0].to_s)
          end
        end
      end
    end
end

test "should find correct negative balance" do
  accnt = accounts(:account_with_negative_balance)

  get :show, :id => accnt["accountId"], :use_route => 'kaui'
  assert_response :success
  assert assigns(:account).balance < 0
end

test "should find correct zero balance" do
  accnt = accounts(:account_with_zero_balance)
  get :show, :id => accnt["accountId"], :use_route => 'kaui'
  assert_response :success
  assert assigns(:account).balance == 0
end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
kaui-0.6.6 test/functional/kaui/accounts_controller_test.rb
kaui-0.6.5 test/functional/kaui/accounts_controller_test.rb
kaui-0.6.4 test/functional/kaui/accounts_controller_test.rb
kaui-0.6.3 test/functional/kaui/accounts_controller_test.rb
kaui-0.6.2 test/functional/kaui/accounts_controller_test.rb
kaui-0.6.1 test/functional/kaui/accounts_controller_test.rb
kaui-0.6.0 test/functional/kaui/accounts_controller_test.rb
kaui-0.5.3 test/functional/kaui/accounts_controller_test.rb
kaui-0.5.2 test/functional/kaui/accounts_controller_test.rb
kaui-0.5.1 test/functional/kaui/accounts_controller_test.rb
kaui-0.5.0 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.9 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.8 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.7 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.6 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.5 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.4 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.3 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.2 test/functional/kaui/accounts_controller_test.rb
kaui-0.4.1 test/functional/kaui/accounts_controller_test.rb