Skip to content

Commit

Permalink
Test MultilineOperationIndentation configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Lazarev committed May 8, 2015
1 parent 7db78d9 commit 7c20c7a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/models/style_guide/ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,46 @@ def initialize(name: , age: )
end
end
end

context "when continued lines are not aligned with operand" do
it "returns violations" do
code = <<-CODE.strip_heredoc
def foo
user = User.where(email: "[email protected]").
assign_attributes(name: "User")
user.save!
end
CODE

violations = violations_in(code)

expect(violations).to eq [
"Align the operands of an expression in an assignment " +
"spanning multiple lines."
]
end
end

context "when continued lines are aligned with operand" do
context "with thoughtbot repo" do
it "returns violations" do
code = <<-CODE.strip_heredoc
def foo
user = User.where(email: "[email protected]").
assign_attributes(name: "User")
user.save!
end
CODE

violations = violations_in(code, repository_owner_name: "thoughtbot")

expect(violations).to eq [
"Use 2 (not 7) spaces for indenting an expression " +
"in an assignment spanning multiple lines."
]
end
end
end
end

context "with custom configuration" do
Expand Down

0 comments on commit 7c20c7a

Please sign in to comment.