Sha256: 2a55fa47deef09e48dd6eaf6fb6c3ad51990c8e75d197672a035807412760f50

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

require "spec_helper"
require "ribose/resource_helper"

RSpec.describe "TestResourceHelper" do
  describe "helpers" do
    context "without any customization" do
      it "builds and returns the default values" do
        resource = Ribose::TestResourceHelper.new

        expect(resource.resource).to eq("resource")
        expect(resource.resources).to eq("resources")

        expect(resource.resources_path).to eq("resources")
        expect(resource.resource_path).to eq("resources/123456789")
      end

      context "with customization" do
        it "returns the custom values when available" do
          custom_resource = Ribose::CustomResourceHelper.new

          expect(custom_resource.resources).to eq("resources")
          expect(custom_resource.resources_path).to eq("resource/nested")
          expect(custom_resource.resource_path).to eq("custom/nested/123456789")
        end
      end
    end
  end

  module Ribose
    class TestResourceHelper
      include Ribose::ResourceHelper

      def resource
        "resource"
      end

      def resource_id
        123_456_789
      end
    end

    class CustomResourceHelper
      include Ribose::ResourceHelper

      def resource
        "resource"
      end

      def resources_path
        "resource/nested"
      end

      def resource_path
        "custom/nested/123456789"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ribose-0.5.0 spec/ribose/resource_helper_spec.rb
ribose-0.4.1 spec/ribose/resource_helper_spec.rb
ribose-0.4.0 spec/ribose/resource_helper_spec.rb
ribose-0.3.2 spec/ribose/resource_helper_spec.rb
ribose-0.3.1 spec/ribose/resource_helper_spec.rb
ribose-0.3.0 spec/ribose/resource_helper_spec.rb
ribose-0.2.0 spec/ribose/resource_helper_spec.rb