-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add rubocop and drop support for Rubies < 2.0 #124
Changes from all commits
f9f05b3
0af010d
80e354e
04d591c
d4f178a
494e672
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Style/StringLiterals: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
# Allow some style changes in specs | ||
Metrics/ModuleLength: | ||
Exclude: | ||
- spec/**/* | ||
Metrics/BlockLength: | ||
Exclude: | ||
- spec/**/* | ||
Style/BlockDelimiters: | ||
Exclude: | ||
- spec/**/* | ||
Style/RescueModifier: | ||
Exclude: | ||
- spec/**/* | ||
Metrics/MethodLength: | ||
Exclude: | ||
- spec/interactor/hooks_spec.rb | ||
Style/IndentArray: | ||
Exclude: | ||
- spec/integration_spec.rb | ||
- spec/interactor/hooks_spec.rb | ||
|
||
# Allow nice tree-like comments in specs | ||
Style/AsciiComments: | ||
Exclude: | ||
- spec/integration_spec.rb | ||
|
||
# Here inconsistent indentation helps to understand | ||
# tree nature of callbacks. | ||
Style/AlignArray: | ||
Exclude: | ||
- spec/integration_spec.rb | ||
|
||
# This could be removed if throws are used instead of | ||
# raising Failure in #fail! | ||
Lint/HandleExceptions: | ||
Exclude: | ||
- lib/interactor.rb | ||
|
||
Style/EmptyMethod: | ||
Enabled: false | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
require "rubocop/rake_task" | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
RuboCop::RakeTask.new(:rubocop) | ||
|
||
task default: :spec | ||
task default: [:spec, :rubocop] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
# encoding: utf-8 | ||
require "English" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "interactor" | ||
spec.version = "4.0.0" | ||
|
||
spec.author = "Collective Idea" | ||
spec.email = "[email protected]" | ||
spec.description = "Interactor provides a common interface for performing complex user interactions." | ||
spec.description = "Interactor provides a common interface for performing " \ | ||
"complex user interactions." | ||
spec.summary = "Simple interactor implementation" | ||
spec.homepage = "https://github.com/collectiveidea/interactor" | ||
spec.license = "MIT" | ||
|
||
spec.files = `git ls-files`.split($/) | ||
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) | ||
spec.test_files = spec.files.grep(/^spec/) | ||
|
||
spec.required_ruby_version = ">= 2.0" | ||
|
||
spec.add_development_dependency "bundler", "~> 1.9" | ||
spec.add_development_dependency "rake", "~> 10.4" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,23 @@ | |
def build_interactor(&block) | ||
interactor = Class.new.send(:include, Interactor) | ||
interactor.class_eval(&block) if block | ||
interactor.class_eval do | ||
def unexpected_error! | ||
raise "foo" | ||
end | ||
end | ||
interactor | ||
end | ||
|
||
def build_organizer(options = {}, &block) | ||
organizer = Class.new.send(:include, Interactor::Organizer) | ||
organizer.organize(options[:organize]) if options[:organize] | ||
organizer.class_eval(&block) if block | ||
organizer.class_eval do | ||
def unexpected_error! | ||
raise "foo" | ||
end | ||
end | ||
organizer | ||
end | ||
|
||
|
@@ -25,7 +35,8 @@ def build_organizer(options = {}, &block) | |
# └─ interactor5 | ||
|
||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are this and the similar changes below just a line length concern? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm all for the 80 character limit but I typically relax that rule a bit for specs. But maybe I shouldn't! |
||
around do |interactor| | ||
context.steps << :around_before | ||
interactor.call | ||
|
@@ -315,7 +326,8 @@ def rollback | |
|
||
context "when an around hook fails early" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
context.fail! | ||
context.steps << :around_before | ||
|
@@ -345,9 +357,10 @@ def rollback | |
|
||
context "when an around hook errors early" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :around_before | ||
interactor.call | ||
context.steps << :around_after | ||
|
@@ -381,7 +394,8 @@ def rollback | |
|
||
context "when a before hook fails" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
context.steps << :around_before | ||
interactor.call | ||
|
@@ -412,15 +426,16 @@ def rollback | |
|
||
context "when a before hook errors" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
context.steps << :around_before | ||
interactor.call | ||
context.steps << :around_after | ||
end | ||
|
||
before do | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :before | ||
end | ||
|
||
|
@@ -449,7 +464,8 @@ def rollback | |
|
||
context "when an after hook fails" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
context.steps << :around_before | ||
interactor.call | ||
|
@@ -500,7 +516,8 @@ def rollback | |
|
||
context "when an after hook errors" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
context.steps << :around_before | ||
interactor.call | ||
|
@@ -512,7 +529,7 @@ def rollback | |
end | ||
|
||
after do | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :after | ||
end | ||
end | ||
|
@@ -557,7 +574,8 @@ def rollback | |
|
||
context "when an around hook fails late" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
context.steps << :around_before | ||
interactor.call | ||
|
@@ -609,11 +627,12 @@ def rollback | |
|
||
context "when an around hook errors late" do | ||
let(:organizer) { | ||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | ||
interactors = [organizer2, interactor3, organizer4, interactor5] | ||
build_organizer(organize: interactors) do | ||
around do |interactor| | ||
context.steps << :around_before | ||
interactor.call | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :around_after | ||
end | ||
|
||
|
@@ -716,7 +735,7 @@ def rollback | |
let(:interactor3) { | ||
build_interactor do | ||
around do |interactor| | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :around_before3 | ||
interactor.call | ||
context.steps << :around_after3 | ||
|
@@ -823,7 +842,7 @@ def rollback | |
end | ||
|
||
before do | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :before3 | ||
end | ||
|
||
|
@@ -933,7 +952,7 @@ def rollback | |
end | ||
|
||
def call | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :call3 | ||
end | ||
|
||
|
@@ -1032,7 +1051,7 @@ def rollback | |
end | ||
|
||
after do | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :after3 | ||
end | ||
|
||
|
@@ -1128,7 +1147,7 @@ def rollback | |
around do |interactor| | ||
context.steps << :around_before3 | ||
interactor.call | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :around_after3 | ||
end | ||
|
||
|
@@ -1233,7 +1252,7 @@ def rollback | |
let(:interactor4b) { | ||
build_interactor do | ||
around do |interactor| | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :around_before4b | ||
interactor.call | ||
context.steps << :around_after4b | ||
|
@@ -1350,7 +1369,7 @@ def rollback | |
end | ||
|
||
before do | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :before4b | ||
end | ||
|
||
|
@@ -1470,7 +1489,7 @@ def rollback | |
end | ||
|
||
def call | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :call4b | ||
end | ||
|
||
|
@@ -1579,7 +1598,7 @@ def rollback | |
end | ||
|
||
after do | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :after4b | ||
end | ||
|
||
|
@@ -1685,7 +1704,7 @@ def rollback | |
around do |interactor| | ||
context.steps << :around_before4b | ||
interactor.call | ||
raise "foo" | ||
unexpected_error! | ||
context.steps << :around_after4b | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I didn't know about this!