-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(fetch_namespace): add initial specs
- Loading branch information
Showing
2 changed files
with
56 additions
and
163 deletions.
There are no files selected for viewing
163 changes: 0 additions & 163 deletions
163
...nient_service/support/dependency_container/commands/fetch_imported_scoped_methods_spec.rb
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
spec/lib/convenient_service/support/dependency_container/commands/fetch_namespace_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
require "convenient_service" | ||
|
||
RSpec.describe ConvenientService::Support::DependencyContainer::Commands::FetchNamespace do | ||
example_group "class methods" do | ||
describe ".call" do | ||
subject(:command_result) { described_class.call(importing_module: importing_module, scope: scope, prepend: prepend) } | ||
|
||
let(:scope) { :class } | ||
let(:prepend) { false } | ||
|
||
let(:importing_module) do | ||
Class.new do | ||
include ConvenientService::Support::DependencyContainer::Import | ||
end | ||
end | ||
|
||
let(:container) do | ||
Module.new do | ||
include ConvenientService::Support::DependencyContainer::Export | ||
|
||
export :foo do | ||
"foo" | ||
end | ||
|
||
export :bar, scope: :class do | ||
"bar" | ||
end | ||
end | ||
end | ||
|
||
describe "importing module" do | ||
context "when `importing module` imports method" do | ||
before do | ||
importing_module.import(method, from: container, scope: scope) | ||
end | ||
|
||
let(:method) { :bar } | ||
|
||
it "returns valid constant" do | ||
expect(command_result).to eq(importing_module::ImportedIncludedClassMethods) | ||
end | ||
end | ||
|
||
context "when `importing module` does NOT import any method" do | ||
it "returns valid constant" do | ||
expect(command_result).to eq(importing_module::ImportedIncludedClassMethods) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |