Module: ExecutableStories::RSpecStoryDSL

Defined in:
lib/executable_stories/rspec.rb

Instance Method Summary collapse

Instance Method Details

#story(scenario, tags: nil, ticket: nil, meta: nil, trace_url_template: nil, **example_metadata, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/executable_stories/rspec.rb', line 11

def story(scenario, tags: nil, ticket: nil, meta: nil, trace_url_template: nil, **, &block)
  it(scenario, **, executable_stories: {
       scenario: scenario,
       tags: tags,
       ticket: ticket,
       meta: meta,
       trace_url_template: trace_url_template
     }) do
    story = ExecutableStories.init(
      scenario,
      tags: tags,
      ticket: ticket,
      meta: meta,
      trace_url_template: trace_url_template
    )

    story.meta ||= {}
    story.meta["rspec"] = {
      "fullDescription" => RSpec.current_example.full_description,
      "description" => RSpec.current_example.description,
      "filePath" => RSpec.current_example.[:file_path],
      "lineNumber" => RSpec.current_example.[:line_number],
      "scopedId" => RSpec.current_example.[:scoped_id]
    }

    RSpec.current_example.[:executable_stories_story] = story
    instance_exec(story, &block) if block
  end
end