Skip to content

Commit

Permalink
refactor(examples): structure contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Jan 13, 2024
1 parent 078d219 commit 7d03868
Show file tree
Hide file tree
Showing 98 changed files with 3,010 additions and 2,997 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result(path: path) }

example_group "modules" do
subject { described_class }

Expand All @@ -21,7 +19,9 @@

example_group "class methods" do
describe ".result" do
context "when assertion that file exists is NOT successful" do
subject(:result) { described_class.result(path: path) }

context "when `AssertFileExists` is NOT successful" do
context "when `path` is NOT present" do
let(:path) { "" }

Expand All @@ -39,7 +39,7 @@
end
end

context "when assertion that file exists is successful" do
context "when `AssertFileExists` is successful" do
##
# NOTE: Tempfile uses its own `let` in order to prevent its premature garbage collection.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result(path: path) }

example_group "modules" do
subject { described_class }

Expand All @@ -21,7 +19,9 @@

example_group "class methods" do
describe ".result" do
context "when assertion that file is NOT empty is NOT successful" do
subject(:result) { described_class.result(path: path) }

context "when `AssertFileNotEmpty` is NOT successful" do
context "when `path` is NOT present" do
let(:path) { "" }

Expand All @@ -43,7 +43,7 @@
end
end

context "when assertion that file is NOT empty is successful" do
context "when `AssertFileNotEmpty` is successful" do
##
# NOTE: Tempfile uses its own `let` in order to prevent its premature garbage collection.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result }

example_group "modules" do
subject { described_class }

Expand All @@ -22,9 +20,11 @@

example_group "class methods" do
describe ".result" do
subject(:result) { described_class.result }

let(:node_available_command) { "which node > /dev/null 2>&1" }

context "when assertion that node is available is NOT successful" do
context "when `AssertNodeAvailable` is NOT successful" do
context "when node is NOT available" do
before do
stub_service(ConvenientService::Examples::Dry::Gemfile::Services::RunShellCommand)
Expand All @@ -38,7 +38,7 @@
end
end

context "when assertion that node is available is successful" do
context "when `AssertNodeAvailable` is successful" do
before do
stub_service(ConvenientService::Examples::Dry::Gemfile::Services::RunShellCommand)
.with_arguments(command: node_available_command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result(name: name) }
let(:name) { "strip-comments" }

example_group "modules" do
subject { described_class }

Expand All @@ -23,9 +20,12 @@

example_group "class methods" do
describe ".result" do
subject(:result) { described_class.result(name: name) }

let(:name) { "strip-comments" }
let(:npm_package_available_command) { "npm list #{name} --depth=0 > /dev/null 2>&1" }

context "when assertion that npm package is available is NOT successful" do
context "when `AssertNpmPackageAvailable` is NOT successful" do
if ConvenientService::Dependencies.support_has_j_send_result_params_validations_using_active_model_validations?
context "when `name` is NOT valid" do
context "when `name` is NOT present" do
Expand Down Expand Up @@ -64,7 +64,7 @@
end
end

context "when assertion that npm package is available is successful" do
context "when `AssertNpmPackageAvailable` is successful" do
before do
stub_service(ConvenientService::Examples::Dry::Gemfile::Services::RunShellCommand)
.with_arguments(command: npm_package_available_command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result(content: content) }
let(:content) { double }

example_group "modules" do
subject { described_class }

Expand All @@ -22,7 +19,11 @@

example_group "class methods" do
describe ".result" do
context "when assertion that ruby syntax is valid is NOT successful" do
subject(:result) { described_class.result(content: content) }

let(:content) { double }

context "when `AssertValidRubySyntax` is NOT successful" do
context "when `content` does NOT contain valid Ruby syntax" do
let(:content) { "2 */ 2" }

Expand All @@ -32,7 +33,7 @@
end
end

context "when assertion that ruby syntax is valid is successful" do
context "when `AssertValidRubySyntax` is successful" do
let(:content) { "2 + 2" }

it "returns `success`" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
include ConvenientService::RSpec::Matchers::IncludeModule
include ConvenientService::RSpec::Matchers::DelegateTo

let(:result) { described_class.result(parsed_content: parsed_content) }
let(:parsed_content) { {} }

example_group "modules" do
subject { described_class }

Expand All @@ -23,7 +20,11 @@

example_group "class methods" do
describe ".result" do
context "when formatting of gems of body is successful" do
subject(:result) { described_class.result(parsed_content: parsed_content) }

let(:parsed_content) { {} }

context "when `FormatBody` is successful" do
let(:parsed_content) do
{
gems: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result(parsed_content: parsed_content) }
let(:parsed_content) { {} }

example_group "modules" do
subject { described_class }

Expand All @@ -22,7 +19,11 @@

example_group "class methods" do
describe ".result" do
context "when formatting of gems with envs is NOT successful" do
subject(:result) { described_class.result(parsed_content: parsed_content) }

let(:parsed_content) { {} }

context "when `FormatGemsWithEnvs` is NOT successful" do
context "when `parsed_content` is NOT hash" do
let(:parsed_content) { [] }

Expand Down Expand Up @@ -88,7 +89,7 @@
end
end

context "when formatting of gems with envs is successful" do
context "when `FormatGemsWithEnvs` is successful" do
let(:parsed_content) do
{
gems: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result(parsed_content: parsed_content) }
let(:parsed_content) { {} }

example_group "modules" do
subject { described_class }

Expand All @@ -22,7 +19,11 @@

example_group "class methods" do
describe ".result" do
context "when formatting of gems without envs is NOT successful" do
subject(:result) { described_class.result(parsed_content: parsed_content) }

let(:parsed_content) { {} }

context "when `FormatGemsWithoutEnvs` is NOT successful" do
context "when `parsed_content` is NOT hash" do
let(:parsed_content) { [] }

Expand Down Expand Up @@ -88,7 +89,7 @@
end
end

context "when formatting of gems without envs is successful" do
context "when `FormatGemsWithoutEnvs` is successful" do
let(:parsed_content) do
{
gems: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
include ConvenientService::RSpec::Matchers::Results
include ConvenientService::RSpec::Matchers::IncludeModule

let(:result) { described_class.result(parsed_content: parsed_content, skip_frozen_string_literal: skip_frozen_string_literal) }
let(:parsed_content) { {} }
let(:skip_frozen_string_literal) { false }

example_group "modules" do
subject { described_class }

Expand All @@ -23,7 +19,12 @@

example_group "class methods" do
describe ".result" do
context "when formatting of header is NOT successful" do
subject(:result) { described_class.result(parsed_content: parsed_content, skip_frozen_string_literal: skip_frozen_string_literal) }

let(:parsed_content) { {} }
let(:skip_frozen_string_literal) { false }

context "when `FormatHeader` is NOT successful" do
context "when `parsed_content` is NOT hash" do
let(:parsed_content) { [] }

Expand Down Expand Up @@ -103,7 +104,7 @@
end
end

context "when formatting of header is successful" do
context "when `FormatHeader` is successful" do
let(:skip_frozen_string_literal) { false }

let(:parsed_content) do
Expand Down
Loading

0 comments on commit 7d03868

Please sign in to comment.