Sha256: c7201b2b3803a5d4f9733d5ecdf86de38bff9da1da3fcc045a1a1e7205a41db8

Contents?: true

Size: 1.21 KB

Versions: 22

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require "hanami/slice_name"

require "dry/inflector"

RSpec.describe Hanami::SliceName do
  subject(:slice_name) { described_class.new(slice, inflector: -> { inflector }) }
  let(:slice) { double(name: "Main::Slice") }
  let(:inflector) { Dry::Inflector.new }

  let(:slice_module) { Module.new }

  before do
    stub_const "Main", slice_module
  end

  describe "#name" do
    it "returns the downcased, underscored string name of the module containing the slice" do
      expect(slice_name.name).to eq "main"
    end
  end

  describe "#to_s" do
    it "returns the downcased, underscored string name of the module containing the slice" do
      expect(slice_name.to_s).to eq "main"
    end
  end

  describe "#to_sym" do
    it "returns the downcased, underscored, symbolized name of the module containing the slice" do
      expect(slice_name.to_sym).to eq :main
    end
  end

  describe "#namespace_name" do
    it "returns the string name of the module containing the slice" do
      expect(slice_name.namespace_name).to eq "Main"
    end
  end

  describe "#namespace_const" do
    it "returns the module containing the slice" do
      expect(slice_name.namespace).to be slice_module
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/unit/hanami/slice_name_spec.rb
hanami-2.2.0 spec/unit/hanami/slice_name_spec.rb
hanami-2.2.0.rc1 spec/unit/hanami/slice_name_spec.rb
hanami-2.2.0.beta2 spec/unit/hanami/slice_name_spec.rb
hanami-2.2.0.beta1 spec/unit/hanami/slice_name_spec.rb
hanami-2.1.0 spec/unit/hanami/slice_name_spec.rb
hanami-2.1.0.rc3 spec/unit/hanami/slice_name_spec.rb
hanami-2.1.0.rc2 spec/unit/hanami/slice_name_spec.rb
hanami-2.1.0.rc1 spec/unit/hanami/slice_name_spec.rb
hanami-2.1.0.beta2.1 spec/unit/hanami/slice_name_spec.rb
hanami-2.1.0.beta2 spec/unit/hanami/slice_name_spec.rb
hanami-2.1.0.beta1 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.3 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.2 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.1 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.0 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.0.rc1 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.0.beta4 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.0.beta3 spec/unit/hanami/slice_name_spec.rb
hanami-2.0.0.beta2 spec/unit/hanami/slice_name_spec.rb