Skip to content

Commit

Permalink
Update specs to match new error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
xjunior committed Nov 6, 2023
1 parent 40c3925 commit b3d9ec1
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it "when command is defined directly inside app/commands/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/commands/`. Namespace them like `app/commands/my_component/foo.rb`
^^^^^^^^^ Cobra/CommandFilePlacement: Do not add top-level files into `app/commands/`. Namespace them like `app/commands/my_component/foo.rb`
end
RUBY

Expand All @@ -37,7 +37,7 @@ class Foo
it "when command is defined inside a different subdirectory of app/commands/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/commands/`. Namespace them like `app/commands/my_component/other_namespace/foo.rb`
^^^^^^^^^ Cobra/CommandFilePlacement: Do not add top-level files into `app/commands/`. Namespace them like `app/commands/my_component/other_namespace/foo.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
it "when controller is defined directly inside app/controllers/" do
source = <<~RUBY
class FooController
^^^^^^^^^^^^^^^^^^^ Do not add top-level files into `app/controllers/`. Namespace them like `app/controllers/my_component/foo_controller.rb`
^^^^^^^^^^^^^^^^^^^ Cobra/ControllerFilePlacement: Do not add top-level files into `app/controllers/`. Namespace them like `app/controllers/my_component/foo_controller.rb`
end
RUBY

Expand All @@ -43,7 +43,7 @@ class FooController
it "when controller is defined inside a different subdirectory of app/controllers/" do
source = <<~RUBY
class FooController
^^^^^^^^^^^^^^^^^^^ Do not add top-level files into `app/controllers/`. Namespace them like `app/controllers/my_component/other_namespace/foo_controller.rb`
^^^^^^^^^^^^^^^^^^^ Cobra/ControllerFilePlacement: Do not add top-level files into `app/controllers/`. Namespace them like `app/controllers/my_component/other_namespace/foo_controller.rb`
end
RUBY

Expand All @@ -55,7 +55,7 @@ class FooController
it "when file is directly inside a concerns directory inside app/controllers/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/controllers/concerns/`. Namespace them like `app/controllers/concerns/my_component/foo.rb`
^^^^^^^^^ Cobra/ControllerFilePlacement: Do not add top-level files into `app/controllers/concerns/`. Namespace them like `app/controllers/concerns/my_component/foo.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
path ".." do
gem "nitro_component", require: true
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Component Gemfile dependencies must specify 'require: nil'.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cobra/GemRequirement: Component Gemfile dependencies must specify 'require: nil'.
end
RUBY
end
Expand All @@ -72,7 +72,7 @@
path ".." do
gem "nitro_component"
^^^^^^^^^^^^^^^^^^^^^ Component Gemfile dependencies must specify 'require: nil'.
^^^^^^^^^^^^^^^^^^^^^ Cobra/GemRequirement: Component Gemfile dependencies must specify 'require: nil'.
end
RUBY
end
Expand All @@ -85,7 +85,7 @@
# Dependencies on other components go here
gem "nitro_component", require: nil
gem "other_component"
^^^^^^^^^^^^^^^^^^^^^ Component Gemfile dependencies must specify 'require: nil'.
^^^^^^^^^^^^^^^^^^^^^ Cobra/GemRequirement: Component Gemfile dependencies must specify 'require: nil'.
gem "another_component", require: nil
end
RUBY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it "when helper is defined directly inside app/helpers/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/helpers/`. Namespace them like `app/helpers/my_component/foo.rb`
^^^^^^^^^ Cobra/HelperFilePlacement: Do not add top-level files into `app/helpers/`. Namespace them like `app/helpers/my_component/foo.rb`
end
RUBY

Expand All @@ -37,7 +37,7 @@ class Foo
it "when helper is defined inside a different subdirectory of app/helpers/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/helpers/`. Namespace them like `app/helpers/my_component/other_namespace/foo.rb`
^^^^^^^^^ Cobra/HelperFilePlacement: Do not add top-level files into `app/helpers/`. Namespace them like `app/helpers/my_component/other_namespace/foo.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FooController < MyComponent::ApplicationController
it "registers an offense when inheriting from ApplicationController" do
expect_offense(<<-RUBY)
class FooController < ApplicationController
^^^^^^^^^^^^^^^^^^^^^ Do not directly inherit from a global ApplicationController. Instead, inherit from your component's modularized ApplicationController, such as MyComponent::ApplicationController.
^^^^^^^^^^^^^^^^^^^^^ Cobra/Inheritance: Do not directly inherit from a global ApplicationController. Instead, inherit from your component's modularized ApplicationController, such as MyComponent::ApplicationController.
end
RUBY
end
Expand All @@ -30,7 +30,7 @@ class Foo < MyComponent::ApplicationRecord
it "registers an offense when inheriting from ApplicationRecord" do
expect_offense(<<-RUBY)
class Foo < ApplicationRecord
^^^^^^^^^^^^^^^^^ Do not directly inherit from a global ApplicationRecord. Instead, inherit from your component's modularized ApplicationRecord, such as MyComponent::ApplicationRecord.
^^^^^^^^^^^^^^^^^ Cobra/Inheritance: Do not directly inherit from a global ApplicationRecord. Instead, inherit from your component's modularized ApplicationRecord, such as MyComponent::ApplicationRecord.
end
RUBY
end
Expand All @@ -45,7 +45,7 @@ class FooController < MyComponent::ApiController
it "registers an offense when inheriting from ApiController" do
expect_offense(<<-RUBY)
class FooController < ApiController
^^^^^^^^^^^^^ Do not directly inherit from a global ApiController. Instead, inherit from your component's modularized ApiController, such as MyComponent::ApiController.
^^^^^^^^^^^^^ Cobra/Inheritance: Do not directly inherit from a global ApiController. Instead, inherit from your component's modularized ApiController, such as MyComponent::ApiController.
end
RUBY
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it "when job is defined directly inside app/jobs/" do
source = <<~RUBY
class FooJob
^^^^^^^^^^^^ Do not add top-level files into `app/jobs/`. Namespace them like `app/jobs/my_component/foo_job.rb`
^^^^^^^^^^^^ Cobra/JobFilePlacement: Do not add top-level files into `app/jobs/`. Namespace them like `app/jobs/my_component/foo_job.rb`
end
RUBY

Expand All @@ -37,7 +37,7 @@ class FooJob
it "when job is defined directly inside mismatched subdirectory of app/jobs/" do
source = <<~RUBY
class FooJob
^^^^^^^^^^^^ Do not add top-level files into `app/jobs/`. Namespace them like `app/jobs/my_component/other_namespace/foo_job.rb`
^^^^^^^^^^^^ Cobra/JobFilePlacement: Do not add top-level files into `app/jobs/`. Namespace them like `app/jobs/my_component/other_namespace/foo_job.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
it "when lib file is defined directly inside lib/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `lib/`. Namespace them like `lib/awesome_component/foo.rb`
^^^^^^^^^ Cobra/LibFilePlacement: Do not add top-level files into `lib/`. Namespace them like `lib/awesome_component/foo.rb`
end
RUBY

Expand All @@ -61,7 +61,7 @@ class Foo
it "when lib file is defined inside a different subdirectory of lib/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `lib/`. Namespace them like `lib/my_component/other_namespace/my_file.rb`
^^^^^^^^^ Cobra/LibFilePlacement: Do not add top-level files into `lib/`. Namespace them like `lib/my_component/other_namespace/my_file.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it "when mailer is defined directly inside app/mailers/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/mailers/`. Namespace them like `app/mailers/my_component/foo.rb`
^^^^^^^^^ Cobra/MailerFilePlacement: Do not add top-level files into `app/mailers/`. Namespace them like `app/mailers/my_component/foo.rb`
end
RUBY

Expand All @@ -37,7 +37,7 @@ class Foo
it "when mailer is defined inside a different subdirectory of app/mailers/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/mailers/`. Namespace them like `app/mailers/my_component/other_namespace/foo.rb`
^^^^^^^^^ Cobra/MailerFilePlacement: Do not add top-level files into `app/mailers/`. Namespace them like `app/mailers/my_component/other_namespace/foo.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
it "when model is defined directly inside app/models/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/models/`. Namespace them like `app/models/my_component/foo.rb`
^^^^^^^^^ Cobra/ModelFilePlacement: Do not add top-level files into `app/models/`. Namespace them like `app/models/my_component/foo.rb`
end
RUBY

Expand All @@ -43,7 +43,7 @@ class Foo
it "when model is defined directly inside mismatched subdirectory of app/models/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/models/`. Namespace them like `app/models/my_component/other_namespace/foo.rb`
^^^^^^^^^ Cobra/ModelFilePlacement: Do not add top-level files into `app/models/`. Namespace them like `app/models/my_component/other_namespace/foo.rb`
end
RUBY

Expand All @@ -55,7 +55,7 @@ class Foo
it "when file is directly inside a concerns directory inside of app/models/" do
source = <<~RUBY
class Foo
^^^^^^^^^ Do not add top-level files into `app/models/concerns/`. Namespace them like `app/models/concerns/my_component/foo.rb`
^^^^^^^^^ Cobra/ModelFilePlacement: Do not add top-level files into `app/models/concerns/`. Namespace them like `app/models/concerns/my_component/foo.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it "when presenter is defined directly inside app/presenters/" do
source = <<~RUBY
class FooPresenter
^^^^^^^^^^^^^^^^^^ Do not add top-level files into `app/presenters/`. Namespace them like `app/presenters/my_component/foo_presenter.rb`
^^^^^^^^^^^^^^^^^^ Cobra/PresenterFilePlacement: Do not add top-level files into `app/presenters/`. Namespace them like `app/presenters/my_component/foo_presenter.rb`
end
RUBY

Expand All @@ -37,7 +37,7 @@ class FooPresenter
it "when presenter is defined directly inside mismatched subdirectory of app/presenters/" do
source = <<~RUBY
class FooPresenter
^^^^^^^^^^^^^^^^^^ Do not add top-level files into `app/presenters/`. Namespace them like `app/presenters/my_component/other_namespace/foo_presenter.rb`
^^^^^^^^^^^^^^^^^^ Cobra/PresenterFilePlacement: Do not add top-level files into `app/presenters/`. Namespace them like `app/presenters/my_component/other_namespace/foo_presenter.rb`
end
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
it "when view_component is defined directly inside app/components/" do
source = <<~RUBY
class FooComponent < ::ViewComponent::Base
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cobra/ViewComponentFilePlacement: Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
end
RUBY

Expand All @@ -43,7 +43,7 @@ class FooComponent < ::ViewComponent::Base
it "when view_component is defined directly inside mismatched subdirectory of app/components/" do
source = <<~RUBY
class FooComponent < ::ViewComponent::Base
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cobra/ViewComponentFilePlacement: Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
end
RUBY

Expand All @@ -55,7 +55,7 @@ class FooComponent < ::ViewComponent::Base
it "when view_component is defined directly inside mismatched subdirectory of app/components/" do
source = <<~RUBY
class FooComponent < ::ViewComponent::Base
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cobra/ViewComponentFilePlacement: Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
end
RUBY

Expand All @@ -67,7 +67,7 @@ class FooComponent < ::ViewComponent::Base
it "when view_component is defined within directory of component name, but not in an additional subdirectory" do
source = <<~RUBY
module MyComponent
^^^^^^^^^^^^^^^^^^ Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
^^^^^^^^^^^^^^^^^^ Cobra/ViewComponentFilePlacement: Nest ViewComponent definitions in the parent component and resource namespace. For example: `app/components/my_component/<resource>/foo_component.rb`
class FooComponent < MyComponent::ApplicationComponent
end
end
Expand Down

0 comments on commit b3d9ec1

Please sign in to comment.