Skip to content

Commit

Permalink
rubocop -A
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglass committed Nov 12, 2024
1 parent 5cb20a5 commit 8627bb7
Show file tree
Hide file tree
Showing 53 changed files with 365 additions and 254 deletions.
2 changes: 2 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

appraise 'rails-5.2' do
gem 'rails', '~> 5.2.0'
end
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in rails_edge_test.gemspec
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'rails_edge_test'
Expand Down
1 change: 1 addition & 0 deletions exe/generate_edges
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'open3'
require 'rails_edge_test'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_edge_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_edge_test/version'
require 'rails_edge_test/dsl'
require 'rails_edge_test/dsl/controller'
Expand Down
14 changes: 5 additions & 9 deletions lib/rails_edge_test/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsEdgeTest
class Configuration
attr_accessor :elm_path, :edge_root_path, :printer
Expand Down Expand Up @@ -35,23 +37,17 @@ def after_each(&block)
end

def wrap_suite_execution(&block)
@before_suite_blocks.each do |before_suit_block|
before_suit_block.call
end
@before_suite_blocks.each(&:call)

block.call
end

def wrap_edge_execution(&edge)
@before_each_blocks.each do |before_each_block|
before_each_block.call
end
@before_each_blocks.each(&:call)

edge.call

@after_each_blocks.each do |after_each_block|
after_each_block.call
end
@after_each_blocks.each(&:call)
end
end
end
2 changes: 2 additions & 0 deletions lib/rails_edge_test/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsEdgeTest
module Dsl
def controller(controller_class, &)
Expand Down
78 changes: 41 additions & 37 deletions lib/rails_edge_test/dsl/action.rb
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
module RailsEdgeTest::Dsl
Action = Struct.new(:name, :controller) do
def initialize(*args)
super
@edges = {}
@let_handler = LetHandler.new
end
# frozen_string_literal: true

def edge(description, &block)
edge = Edge.new(description, self)
@edges[edge] = block
end
module RailsEdgeTest
module Dsl
Action = Struct.new(:name, :controller) do
def initialize(*args)
super
@edges = {}
@let_handler = LetHandler.new
end

def let(title, &block)
@let_handler.add_definition(title, &block)
end
def edge(description, &block)
edge = Edge.new(description, self)
@edges[edge] = block
end

def generate(title, &block)
@let_handler.add_definition("generate_#{title}", &block)
end
def let(title, &block)
@let_handler.add_definition(title, &block)
end

def __edges
@edges
end
def generate(title, &block)
@let_handler.add_definition("generate_#{title}", &block)
end

def __let_handler
@let_handler
end
def __edges
@edges
end

def controller_class
controller.controller_class
end
def __let_handler
@let_handler
end

# support calling methods defined in controller
def method_missing(method_name, ...)
if controller.respond_to?(method_name)
controller.public_send(method_name, ...)
else
super
def controller_class
controller.controller_class
end

# support calling methods defined in controller
def method_missing(method_name, ...)
if controller.respond_to?(method_name)
controller.public_send(method_name, ...)
else
super
end
end
end

# always define respond_to_missing? when defining method_missing:
# https://thoughtbot.com/blog/always-define-respond-to-missing-when-overriding
def respond_to_missing?(method_name, include_private = false)
controller.respond_to?(method_name) || super
# always define respond_to_missing? when defining method_missing:
# https://thoughtbot.com/blog/always-define-respond-to-missing-when-overriding
def respond_to_missing?(method_name, include_private = false)
controller.respond_to?(method_name) || super
end
end
end
end
44 changes: 24 additions & 20 deletions lib/rails_edge_test/dsl/controller.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
module RailsEdgeTest::Dsl
Controller = Struct.new(:controller_class) do
def initialize(*args)
super
@actions = []
@let_handler = LetHandler.new
end
# frozen_string_literal: true

def action(name, &block)
new_action = Action.new(name, self)
new_action.instance_exec(&block)
@actions << new_action
end
module RailsEdgeTest
module Dsl
Controller = Struct.new(:controller_class) do
def initialize(*args)
super
@actions = []
@let_handler = LetHandler.new
end

def let(title, &block)
@let_handler.add_definition(title, &block)
end
def action(name, &block)
new_action = Action.new(name, self)
new_action.instance_exec(&block)
@actions << new_action
end

def __actions
@actions
end
def let(title, &block)
@let_handler.add_definition(title, &block)
end

def __actions
@actions
end

def __let_handler
@let_handler
def __let_handler
@let_handler
end
end
end
end
Loading

0 comments on commit 8627bb7

Please sign in to comment.