Rail Functional Test

In the Rails ( test/functional/products_controller_test.rb) automatic generated function test, I see the following code:

class ProductsControllerTest < ActionController::TestCase
  setup do
    @product = products(:one)
    ...
  end

  ...some tests here... 
end

I have the following questions:

  • Where / how is the calling method defined products()?

  • What does it mean products(:one)? Looking at the code, this probably means “create one product,” but how does it work?

NB I am new to Ruby / Rails, sorry if these are trivial questions.

+5
source share
1 answer

test/fixtures, products.yml. . products(:one) "". , products() .

yml.

+11

All Articles