Sha256: 865177e3b6a3d7ea3cc80384659b4ff6d18f6673c02f4b07556672eb35b6ab26

Contents?: true

Size: 1.39 KB

Versions: 22

Compression:

Stored size: 1.39 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
    assert_response :success
  end

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

    get :show, :id => pierre["accountId"]
    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"]
    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"]
  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"]
  assert_response :success
  assert assigns(:account).balance == 0
end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kaui-0.2.5 test/functional/kaui/accounts_controller_test.rb
kaui-0.2.4 test/functional/kaui/accounts_controller_test.rb
kaui-0.2.3 test/functional/kaui/accounts_controller_test.rb
kaui-0.2.2 test/functional/kaui/accounts_controller_test.rb
kaui-0.2.1 test/functional/kaui/accounts_controller_test.rb
kaui-0.2.0 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.18 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.17 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.16 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.15 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.14 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.12 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.11 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.10 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.9 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.8 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.7 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.6 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.5 test/functional/kaui/accounts_controller_test.rb
kaui-0.1.4 test/functional/kaui/accounts_controller_test.rb