Sha256: 728da7c24d83d77a0b1cb976fcff5a9c97dc2ccb75ef972281285e742739df01
Contents?: true
Size: 1.69 KB
Versions: 3
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true RSpec.describe "Routing helpers", type: :integration do it "uses routing helpers within action" do with_project do generate "action web home#index --url=/" generate "action web books#index --url=/books" # Add `as:` option, so it can be used by the routing helper replace "apps/web/config/routes.rb", "/books", "get '/books', to: 'books#index', as: :books" rewrite "apps/web/controllers/home/index.rb", <<~EOF module Web::Controllers::Home class Index include Web::Action def call(params) redirect_to routes.books_url end end end EOF server do visit "/" expect(current_path).to eq("/books") end end end it "uses routing helpers within view" do with_project do generate "action web books#index --url=/books" generate "action web books#show --url=/books/:id" # Add `as:` option, so it can be used by the routing helper replace "apps/web/config/routes.rb", "/books/:id", "get '/books/:id', to: 'books#show', as: :book" rewrite "apps/web/views/books/index.rb", <<~EOF module Web::Views::Books class Index include Web::View def featured_book_path routes.path(:book, id: 23) end end end EOF rewrite "apps/web/templates/books/index.html.erb", <<~EOF <h1>Books</h1> <h2><a href="<%= featured_book_path %>">Featured Book</a></h2> EOF server do visit "/books" expect(page.body).to include(%(<a href="/books/23">Featured Book</a>)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hanami-2.0.0.beta2 | spec/integration/routing_helpers_spec.rb |
hanami-2.0.0.beta1.1 | spec/integration/routing_helpers_spec.rb |
hanami-2.0.0.beta1 | spec/integration/routing_helpers_spec.rb |