require 'spec_helper' require 'cucumber/formatter/spec_helper' require 'cucumber/formatter/pretty' require 'cucumber/cli/options' module Cucumber module Formatter describe Pretty do extend SpecHelperDsl include SpecHelper context "With no options" do before(:each) do Cucumber::Term::ANSIColor.coloring = false @out = StringIO.new @formatter = Pretty.new(step_mother, @out, {}) end describe "given a single feature" do before(:each) do run_defined_feature end describe "basic feature" do define_feature <<-FEATURE Feature: Bananas In order to find my inner monkey As a human I must eat bananas FEATURE it "prints out the feature description" do @out.string.should include "Feature: Bananas" @out.string.should include "I must eat bananas" end end describe "with a scenario" do define_feature <<-FEATURE Feature: Banana party Scenario: Monkey eats banana Given there are bananas FEATURE it "outputs the scenario name" do @out.string.should include "Scenario: Monkey eats banana" end it "outputs the step" do @out.string.should include "Given there are bananas" end end describe "with a scenario outline" do define_feature <<-FEATURE Feature: Fud Pyramid Scenario Outline: Monkey eats a balanced diet Given there are Examples: Fruit | Things | | apples | | bananas | Examples: Vegetables | Things | | broccoli | | carrots | FEATURE it "outputs the scenario outline" do lines = <<-OUTPUT Examples: Fruit | Things | | apples | | bananas | Examples: Vegetables | Things | | broccoli | | carrots | OUTPUT lines.split("\n").each do |line| @out.string.should include line.strip end end it "has 4 undefined scenarios" do @out.string.should include "4 scenarios (4 undefined)" end it "has 4 undefined steps" do @out.string.should include "4 steps (4 undefined)" end end describe "with a step with a py string" do define_feature <<-FEATURE Feature: Traveling circus Scenario: Monkey goes to town Given there is a monkey called: """ foo """ FEATURE it "displays the pystring nested" do @out.string.should include < true}) end describe "given a single feature" do before(:each) do run_defined_feature end describe "basic feature" do define_feature <<-FEATURE Feature: Bananas In order to find my inner monkey As a human I must eat bananas FEATURE it "prints out the feature description" do @out.string.should include "Feature: Bananas" @out.string.should include "I must eat bananas" end end describe "with a scenario" do define_feature <<-FEATURE Feature: Banana party Scenario: Monkey eats banana Given there are bananas FEATURE it "outputs the scenario name" do @out.string.should include "Scenario: Monkey eats banana" end it "outputs the step" do @out.string.should include "Given there are bananas" end end describe "with a scenario outline" do define_feature <<-FEATURE Feature: Fud Pyramid Scenario Outline: Monkey eats a balanced diet Given there are Examples: Fruit | Things | | apples | | bananas | Examples: Vegetables | Things | | broccoli | | carrots | FEATURE it "outputs the scenario outline" do lines = <<-OUTPUT Examples: Fruit | Things | | apples | | bananas | Examples: Vegetables | Things | | broccoli | | carrots | OUTPUT lines.split("\n").each do |line| @out.string.should include line.strip end end it "has 4 undefined scenarios" do @out.string.should include "4 scenarios (4 undefined)" end it "has 4 undefined steps" do @out.string.should include "4 steps (4 undefined)" end end describe "with a step with a py string" do define_feature <<-FEATURE Feature: Traveling circus Scenario: Monkey goes to town Given there is a monkey called: """ foo """ FEATURE it "does not display the pystring" do @out.string.should_not include <