Sha256: f652a4f6d28c7098f13e51e956c5b39a58d663d4673b067acbe9e15c38291abb

Contents?: true

Size: 1.13 KB

Versions: 52

Compression:

Stored size: 1.13 KB

Contents

require 'rails_helper'

module Optimacms
  RSpec.describe PageServices::PageRouteService, :type => :model do
    before :each do

    end

    describe 'parse_url' do

      it 'parse empty' do
        u = ''
        r = PageServices::PageRouteService.parse_url u
        expect(r).to eq '^$'
      end

    end

    it 'parse simple' do
      r = PageServices::PageRouteService.parse_url 'about.html'
      expect(r).to eq '^about[.]html$'
    end

    it 'parse variables' do
      r = PageServices::PageRouteService.parse_url 'service-:name.html'
      expect(r).to eq '^service-([^/]+)[.]html$'
    end
  end

  describe 'url variables' do
    before :each do
      @service = PageServices::PageRouteService
    end

    it 'one variable' do
      # prepare
      u = 'service-hosting.html'
      page_url = 'service-:name.html'
      page_parsed_url = '^service-([^/]+)[.]html$'

      page_row = instance_double("Optimacms::Page", :url => page_url, :parsed_url=>page_parsed_url)

      # do
      res = @service.get_url_vars(u, page_row)

      # check
      expect(res).to have_key(:name)
      expect(res[:name]).to eq 'hosting'


    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
optimacms-0.1.61 spec/models/page_route_service_spec.rb
optimacms-0.4.3 spec/models/page_route_service_spec.rb
optimacms-0.4.2 spec/models/page_route_service_spec.rb
optimacms-0.3.9 spec/models/page_route_service_spec.rb
optimacms-0.3.8 spec/models/page_route_service_spec.rb
optimacms-0.3.7 spec/models/page_route_service_spec.rb
optimacms-0.3.6 spec/models/page_route_service_spec.rb
optimacms-0.3.5 spec/models/page_route_service_spec.rb
optimacms-0.3.2 spec/models/page_route_service_spec.rb
optimacms-0.3.1 spec/models/page_route_service_spec.rb
optimacms-0.2.23 spec/models/page_route_service_spec.rb
optimacms-0.2.22 spec/models/page_route_service_spec.rb
optimacms-0.2.21 spec/models/page_route_service_spec.rb
optimacms-0.2.20 spec/models/page_route_service_spec.rb
optimacms-0.2.19 spec/models/page_route_service_spec.rb
optimacms-0.2.18 spec/models/page_route_service_spec.rb
optimacms-0.2.17 spec/models/page_route_service_spec.rb
optimacms-0.2.16 spec/models/page_route_service_spec.rb
optimacms-0.2.15 spec/models/page_route_service_spec.rb
optimacms-0.2.14 spec/models/page_route_service_spec.rb