Skip to content

Commit

Permalink
feat(undefined): introduce undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Feb 19, 2023
1 parent 9fa0b62 commit 2f93bdc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/convenient_service/support.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require_relative "support/not_passed"
require_relative "support/undefined"

require_relative "support/concern"

require_relative "support/abstract_method"
Expand Down
9 changes: 9 additions & 0 deletions lib/convenient_service/support/undefined.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module ConvenientService
module Support
UNDEFINED = ::Object.new.tap do |object|
object.define_singleton_method(:inspect) { "undefined" }
end
end
end
25 changes: 25 additions & 0 deletions spec/lib/convenient_service/support/undefined_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require "spec_helper"

require "convenient_service"

# rubocop:disable RSpec/NestedGroups, RSpec/DescribeClass
RSpec.describe "convenient_service/support/undefined" do
example_group "constants" do
describe "::UNDEFINED" do
it "returns `Object` instance" do
expect(ConvenientService::Support::UNDEFINED).to be_instance_of(Object)
end

example_group "instance_methods" do
describe "#inspect" do
it "returns inspect representation" do
expect(ConvenientService::Support::UNDEFINED.inspect).to eq("undefined")
end
end
end
end
end
end
# rubocop:enable RSpec/NestedGroups, RSpec/DescribeClass

0 comments on commit 2f93bdc

Please sign in to comment.