Skip to content

Commit

Permalink
Cleaning up unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
khamusa committed Jan 9, 2025
1 parent b3e64d4 commit 5dd981c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
1 change: 0 additions & 1 deletion lib/tabasco.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
module Tabasco
class Error < StandardError; end
end

27 changes: 1 addition & 26 deletions lib/tabasco/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

module Tabasco
PreconditionNotMetError = Class.new(StandardError)
class CapybaraAPI
include Capybara::DSL
end

class Section
include Capybara::RSpecMatchers
Expand Down Expand Up @@ -44,8 +41,6 @@ def self.ensure_loaded_block
def self.section(name, klass = nil, test_id: nil, &block)
test_id = (test_id || name).to_s.tr("_", "-")

parent_name = self.name
section_name = name.to_s.capitalize
parent_attributes = attributes

klass ||= Class.new(Section) do
Expand All @@ -57,34 +52,14 @@ def self.section(name, klass = nil, test_id: nil, &block)

def self.attribute(*)
raise ArgumentError, "Attributes cannot be defined in anonymous sections. " \
"They inherit all arguments from parent pages/sections automatically."
"They inherit all arguments from parent pages/sections automatically."
end

# Simple and naive implementation for Anonymous classes
# Will raise a Capybara error if the container cannot be found
# Can be overridden in the inline block anyway
ensure_loaded { container }

class_eval <<~METHOD, __FILE__, __LINE__ + 1
class << self
def name
"#{parent_name}|#{section_name}"
end
def inspect
"Section(\#{name})"
end
alias_method :to_s, :inspect
end
def inspect
"#<\#{self.class.inspect}:\#{object_id}>"
end
alias_method :to_s, :inspect
METHOD

class_eval(&block) if block
end

Expand Down

0 comments on commit 5dd981c

Please sign in to comment.