Search code examples
rubycucumberwatirpage-object-gem

How to embed text into cucumber report with ruby?


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");
    }
}

Solution

  • 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