small medium large xlarge

20 Nov 2012, 20:39
Jeffery H. Brown (2 posts)

after adding the assert_selects into store_controller_test.rb and the ruby: entry into product.yml I receive the following error after issuing rake test:functionals -

1) Failure: test_should_get_index(StoreControllerTest) [/home/jeff/myapps/depot/test/functional/store_controller_test.rb:9]: <”Programming Ruby 1.9”> expected but was <”MyString1”>.

Thinking it was a typo I copy/pasted the code and product.yml from the downloaded source code.

MyString1 is the title I assosicated with key one:

Any ideas?

25 Nov 2012, 18:05
Álvaro González (2 posts)

When you browser your browser localhost:3000/products what products do you see?

13 Dec 2012, 01:18
Jeffery H. Brown (2 posts)

Sorry it has been a few weeks.

Here are the products in order:

CoffeeScript Programming……. Rail Test Prescriptions

14 Dec 2012, 04:51
Adrian Lee Elder (9 posts)

I remember having the same error, but I can’t remember how I fixed it exactly. It may have had something to do with the fixtures.yml file.

11 Feb 2013, 15:13
Aleks (5 posts)

Having the same problem. Can anyone direct me to a solution?

23 Feb 2013, 16:47
Adrian Lee Elder (9 posts)

Hi Aleks,

I’m pretty sure it has something to do with the test data (fixtures). Make sure that you fill out the data in the product fixture file.

You should see three fixtures in your products.yml (test/fixtures/products.yml) file:

  title: MyString
  description: MyText
  image_url: MyString
  price: 9.99

  title: MyString
  description: MyText
  image_url: MyString
  price: 9.99

  title: Programming Ruby 1.9
    Ruby is the fastest growing and most exciting dynamic language out there. 
    If you need to get working programs delivered fast, you should add Ruby to your toolbox.
  price: 49.50
  image_url: ruby.png

Make sure you use the space bar to line up the attributes and not the tab key. Very important!

Also ensure that your functional test matches up with your fixture data in your StoreControllerTest file:

  test "should get index" do
    get :index
    assert_response :success
    assert_select '#columns #side a', minimum: 4
    assert_select '#main .entry', 3
    assert_select 'h3', 'Programming Ruby 1.9'
    assert_select '.price', /\$[,\d]+\.\d\d/

Remember this code is checking to make sure that when the store’s index is called, there is an entry for Programming Ruby 1.9 in the store’s product listing.

Good luck!