How to embed text into cucumber report with ruby?

651 Views Asked by At

How to embed the text into the cucumber report using ruby. We can do it using java by using the below code but similarly how can I do it in cucumber-ruby?

I have tried using embed method but it is not working.

Below is the code in java to write text in to report.

Source: https://gist.github.com/aslakhellesoy/4072962

import cucumber.api.Scenario;

public class MyStepdefs {
    private Scenario scenario;

    @Before
    public void before(Scenario scenario) {
        this.scenario = scenario;
    }

    @Given("^I have (\\d+) cukes in my belly$")
    public void cukes_in_my_belly(int cukes) {
        scenario.write("This goes into the report(s)\n");
    }
}
1

There are 1 best solutions below

0
spectator On BEST ANSWER

I got the solution it is simply by printing the value as below:

Given("I have {int} cukes in my belly") do |cukes|
 puts 'This goes into the report: #{cukes}'
end