Skip to content

Commit

Permalink
Add reckon_requirement automatic step
Browse files Browse the repository at this point in the history
  • Loading branch information
smiller committed Oct 9, 2023
1 parent 80f104f commit 1604c8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -163,3 +163,16 @@ def relies_on_message(requirement)
""
end
end

def reckon_requirement(example)
example_matches = /.+\((.+):(\d+)\).+/.match(example.inspect)
line_number = example_matches[2].to_i - 1
stdout, _, _ = Open3.capture3("grep", "-nr", "# @REQUIREMENT: ", example_matches[1])
lines = stdout.split("\n")
lines.each do |line|
line_matches = /#{example_matches[1]}:(\d+).+# @REQUIREMENT: (.+)/.match(line)
if line_matches[1].to_i == line_number
return line_matches[2]
end
end
end
4 changes: 2 additions & 2 deletions spec/with_requirement_spec.rb
Expand Up @@ -8,12 +8,12 @@
describe "keys in response" do
# @REQUIREMENT: my_hounds includes :breeding_stock
it "includes :breeding_stock" do
expect(subject).to include_key(:breeding_stock, "my_hounds includes :breeding_stock")
expect(subject).to include_key(:breeding_stock, reckon_requirement(self))
end

# @REQUIREMENT: my_hounds includes :traits
it "includes :traits" do
expect(subject).to include_key(:traits, "my_hounds includes :traits")
expect(subject).to include_key(:traits, reckon_requirement(self))
end
end
end
Expand Down

0 comments on commit 1604c8d

Please sign in to comment.