Używam Cucumber do rozwoju BDD w moim projekcie Ruby on Rails i mam pewne wątpliwości, w jaki sposób path.rb obsługuje ścieżki używane w aplikacjach railsowych.Ogórek i webrat - jak obsługiwać dynamiczne adresy URL w paths.rb?
Biorąc mam:
class Parent < ActiveRecord::Base
has_many :children
end
class Child < ActiveRecord::Base
belongs_to :parent
end
i mam następujący Ogórek cechę:
Scenario: A test feature
Given I am on the parent page
When I follow "Link to Children"
Then I should be on the children list page
ze ścieżką zdefiniowany jako:
def path_to(page_name)
case page_name
when /the children list page/
'/parents/:id/children'
end
Problem natknąć jest następujący błąd podczas uruchamiania funkcji:
Spec::Expectations::ExpectationNotMetError: expected: "/parents/:id/children",
got: "/parents/1726/children" (using ==)
Nie obchodzi mnie, co to jest: id. Co powinienem zamiast tego zrobić? Czy jest to możliwe z domyślnymi krokami sieci? Czy myślę o problemie w niewłaściwy sposób?