SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help! w/ these simple tests!

    Help! w/ these simple tests!

    Ok - yes - I'm a desperate newbie and I am not sure why these test don't
    pass.

    Here's the rundown:

    Code:
    #### the method ###############
    def show_space
      @space = Space.find(:all, :conditions => ["id=?", params[:id]])
    end
    
    #### the test #################
    def test_show_space
        get :show_space, :id => 1
        assert_response :success
        assert_template 'show_space'
        assert_not_nil assigns(:space)
        assert_equal assigns(:space), spaces(:first_space)
    end
    
    #### and the YAML file: spaces.yml ###############
    first_space:
    id: 1
    title: My first space
    subdomain: first-space
    domain: functionalalcoholism.org
    home_page_id: 57
    user_id: 1
    owner_id: 1
    created_at: 2005-05-21 00:00:00
    updated_at: 2005-05-21 00:00:00
    wikiwords_enabled: 1
    country_code: US
    timezone_identifier: US/Eastern
    ####################################################
    
    #### the method ####################################
    def show
        @accounts = Account.find (:all, :include => {'owned_spaces' =>
    :memberships}, :conditions =>   ["accounts.id=?", params[:id]])
    end
    
    #### the test ######################################
    def test_show
      get :show,:id => 1
      assert_response :success
      assert_template 'show'
      assert_equal assigns(:account), accounts(:blake_account)
    end
    
    #### and the YAML file: accounts.yml ###############
    blake_account:
    id: 1
    user_id: 1
    first_name: Blake
    street: none
    expire_on: <%= Date.today + 32 %>
    recurring: false
    country_code: US

  2. #2
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well you don't specify what the problem is but looking at the first test, you are asserting that assignsspace) will be a single Space object with the following:

    assert_equal assignsspace), spacesfirst_space)

    However in your controller code you are using .findall) which means @space will be an Array no matter how many Space objects it contains.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •