spec/cucumber/formatter/pretty_spec.rb in cucumber-1.3.20 vs spec/cucumber/formatter/pretty_spec.rb in cucumber-2.0.0.beta.1
- old
+ new
@@ -11,46 +11,56 @@
context "With no options" do
before(:each) do
Cucumber::Term::ANSIColor.coloring = false
@out = StringIO.new
- @formatter = Pretty.new(step_mother, @out, {})
+ @formatter = Pretty.new(runtime, @out, {})
end
describe "given a single feature" do
before(:each) do
run_defined_feature
end
- describe "basic feature" do
+ describe "with a scenario" do
define_feature <<-FEATURE
- Feature: Bananas
- In order to find my inner monkey
- As a human
- I must eat bananas
+ Feature: Banana party
+
+ Scenario: Monkey eats banana
+ Given there are bananas
FEATURE
- it "prints out the feature description" do
- @out.string.should include "Feature: Bananas"
- @out.string.should include "I must eat bananas"
+ it "outputs the scenario name" do
+ expect(@out.string).to include "Scenario: Monkey eats banana"
end
+ it "outputs the step" do
+ expect(@out.string).to include "Given there are bananas"
+ end
end
- describe "with a scenario" do
+ describe "with a background" do
define_feature <<-FEATURE
- Feature: Banana party
+Feature: Banana party
- Scenario: Monkey eats banana
- Given there are bananas
+ Background:
+ Given a tree
+
+ Scenario: Monkey eats banana
+ Given there are bananas
FEATURE
+ it "outputs the gherkin" do
+ expect(@out.string).to include(self.class.feature_content)
+ end
+
it "outputs the scenario name" do
- @out.string.should include "Scenario: Monkey eats banana"
+ expect(@out.string).to include "Scenario: Monkey eats banana"
end
+
it "outputs the step" do
- @out.string.should include "Given there are bananas"
+ expect(@out.string).to include "Given there are bananas"
end
end
describe "with a scenario outline" do
define_feature <<-FEATURE
@@ -79,22 +89,79 @@
| Things |
| broccoli |
| carrots |
OUTPUT
lines.split("\n").each do |line|
- @out.string.should include line.strip
+ expect(@out.string).to include line.strip
end
end
+
it "has 4 undefined scenarios" do
- @out.string.should include "4 scenarios (4 undefined)"
+ expect(@out.string).to include "4 scenarios (4 undefined)"
end
+
it "has 4 undefined steps" do
- @out.string.should include "4 steps (4 undefined)"
+ expect(@out.string).to include "4 steps (4 undefined)"
end
+ context 'when the examples table header is wider than the rows' do
+ define_feature <<-FEATURE
+ Feature: Monkey Business
+
+ Scenario Outline: Types of monkey
+ Given there are <Types of monkey>
+
+ Examples:
+ | Types of monkey |
+ | Hominidae |
+ FEATURE
+
+ it "outputs the scenario outline" do
+ lines = <<-OUTPUT
+ Examples:
+ | Types of monkey |
+ | Hominidae |
+ OUTPUT
+ lines.split("\n").each do |line|
+ expect(@out.string).to include line.strip
+ end
+ end
+ end
end
+ # To ensure https://rspec.lighthouseapp.com/projects/16211/tickets/475 remains fixed.
+ describe "with a scenario outline with a pystring" do
+ define_feature <<-FEATURE
+ Feature:
+ Scenario Outline: Monkey eats a balanced diet
+ Given a multiline string:
+ """
+ Monkeys eat <things>
+ """
+
+ Examples:
+ | things |
+ | apples |
+ FEATURE
+
+ it "outputs the scenario outline" do
+ lines = <<-OUTPUT
+ Given a multiline string:
+ """
+ Monkeys eat <things>
+ """
+
+ Examples:
+ | things |
+ | apples |
+ OUTPUT
+ lines.split("\n").each do |line|
+ expect(@out.string).to include line.strip
+ end
+ end
+ end
+
describe "with a step with a py string" do
define_feature <<-FEATURE
Feature: Traveling circus
Scenario: Monkey goes to town
@@ -103,11 +170,11 @@
foo
"""
FEATURE
it "displays the pystring nested" do
- @out.string.should include <<OUTPUT
+ expect(@out.string).to include <<OUTPUT
"""
foo
"""
OUTPUT
end
@@ -123,11 +190,11 @@
| foo |
| bar |
FEATURE
it "displays the multiline string" do
- @out.string.should include <<OUTPUT
+ expect(@out.string).to include <<OUTPUT
Given there are monkeys:
| name |
| foo |
| bar |
OUTPUT
@@ -147,18 +214,19 @@
| e | f |
| g | h |
FEATURE
it "displays the table for the background" do
- @out.string.should include <<OUTPUT
+ expect(@out.string).to include <<OUTPUT
Given table:
| a | b |
| c | d |
OUTPUT
end
+
it "displays the table for the scenario" do
- @out.string.should include <<OUTPUT
+ expect(@out.string).to include <<OUTPUT
Given another table:
| e | f |
| g | h |
OUTPUT
end
@@ -179,19 +247,20 @@
bar
"""
FEATURE
it "displays the background py string" do
- @out.string.should include <<OUTPUT
+ expect(@out.string).to include <<OUTPUT
Given stuff:
"""
foo
"""
OUTPUT
end
+
it "displays the scenario py string" do
- @out.string.should include <<OUTPUT
+ expect(@out.string).to include <<OUTPUT
Given more stuff:
"""
bar
"""
OUTPUT
@@ -202,46 +271,32 @@
context "With --no-multiline passed as an option" do
before(:each) do
Cucumber::Term::ANSIColor.coloring = false
@out = StringIO.new
- @formatter = Pretty.new(step_mother, @out, {:no_multiline => true})
+ @formatter = Pretty.new(runtime, @out, {:no_multiline => 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"
+ expect(@out.string).to include "Scenario: Monkey eats banana"
end
+
it "outputs the step" do
- @out.string.should include "Given there are bananas"
+ expect(@out.string).to include "Given there are bananas"
end
end
describe "with a scenario outline" do
define_feature <<-FEATURE
@@ -270,20 +325,21 @@
| Things |
| broccoli |
| carrots |
OUTPUT
lines.split("\n").each do |line|
- @out.string.should include line.strip
+ expect(@out.string).to include line.strip
end
end
+
it "has 4 undefined scenarios" do
- @out.string.should include "4 scenarios (4 undefined)"
+ expect(@out.string).to include "4 scenarios (4 undefined)"
end
+
it "has 4 undefined steps" do
- @out.string.should include "4 steps (4 undefined)"
+ expect(@out.string).to include "4 steps (4 undefined)"
end
-
end
describe "with a step with a py string" do
define_feature <<-FEATURE
Feature: Traveling circus
@@ -294,11 +350,11 @@
foo
"""
FEATURE
it "does not display the pystring" do
- @out.string.should_not include <<OUTPUT
+ expect(@out.string).not_to include <<OUTPUT
"""
foo
"""
OUTPUT
end
@@ -314,11 +370,11 @@
| foo |
| bar |
FEATURE
it "does not display the multiline string" do
- @out.string.should_not include <<OUTPUT
+ expect(@out.string).not_to include <<OUTPUT
| name |
| foo |
| bar |
OUTPUT
end
@@ -337,17 +393,17 @@
| e | f |
| g | h |
FEATURE
it "does not display the table for the background" do
- @out.string.should_not include <<OUTPUT
+ expect(@out.string).not_to include <<OUTPUT
| a | b |
| c | d |
OUTPUT
end
it "does not display the table for the scenario" do
- @out.string.should_not include <<OUTPUT
+ expect(@out.string).not_to include <<OUTPUT
| e | f |
| g | h |
OUTPUT
end
end
@@ -367,25 +423,155 @@
bar
"""
FEATURE
it "does not display the background py string" do
- @out.string.should_not include <<OUTPUT
+ expect(@out.string).not_to include <<OUTPUT
"""
foo
"""
OUTPUT
end
it "does not display the scenario py string" do
- @out.string.should_not include <<OUTPUT
+ expect(@out.string).not_to include <<OUTPUT
"""
bar
"""
OUTPUT
end
end
end
end
+ context "In --expand mode" do
+ let(:runtime) { Runtime.new({:expand => true})}
+ let(:mappings) { Mappings.new(runtime) }
+ before(:each) do
+ Cucumber::Term::ANSIColor.coloring = false
+ @out = StringIO.new
+ @formatter = Pretty.new(runtime, @out, {})
+ end
+
+ describe "given a single feature" do
+ before(:each) do
+ run_defined_feature
+ end
+
+ describe "with a scenario outline" do
+ define_feature <<-FEATURE
+ Feature: Fud Pyramid
+
+ Scenario Outline: Monkey eats a balanced diet
+ Given there are <Things>
+
+ Examples: Fruit
+ | Things |
+ | apples |
+ | bananas |
+ Examples: Vegetables
+ | Things |
+ | broccoli |
+ | carrots |
+ FEATURE
+
+ it "outputs the instantiated scenarios" do
+ lines = <<-OUTPUT
+ Examples: Fruit
+ Scenario: | apples |
+ Given there are apples
+ Scenario: | bananas |
+ Given there are bananas
+ Examples: Vegetables
+ Scenario: | broccoli |
+ Given there are broccoli
+ Scenario: | carrots |
+ Given there are carrots
+ OUTPUT
+ lines.split("\n").each do |line|
+ expect(@out.string).to include line.strip
+ end
+ end
+ end
+ end
+ end
+
+ context "In --expand mode with --source as an option" do
+ let(:runtime) { Runtime.new({:expand => true})}
+ let(:mappings) { Mappings.new(runtime) }
+ before(:each) do
+ Cucumber::Term::ANSIColor.coloring = false
+ @out = StringIO.new
+ @formatter = Pretty.new(runtime, @out, {:source => true})
+ end
+
+ describe "given a single feature" do
+ before(:each) do
+ run_defined_feature
+ end
+
+ describe "with a scenario outline" do
+ define_feature <<-FEATURE
+ Feature: Fud Pyramid
+
+ Scenario Outline: Monkey eats a balanced diet
+ Given there are <Things>
+
+ Examples: Fruit
+ | Things |
+ | apples |
+ | bananas |
+ Examples: Vegetables
+ | Things |
+ | broccoli |
+ | carrots |
+ FEATURE
+
+ it "includes the source in the output" do
+ lines = <<-OUTPUT
+ Scenario Outline: Monkey eats a balanced diet # spec.feature:3
+ Given there are <Things> # spec.feature:4
+ Examples: Fruit
+ Scenario: | apples | # spec.feature:8
+ Given there are apples # spec.feature:4
+ Scenario: | bananas | # spec.feature:9
+ Given there are bananas # spec.feature:4
+ Examples: Vegetables
+ Scenario: | broccoli | # spec.feature:12
+ Given there are broccoli # spec.feature:4
+ Scenario: | carrots | # spec.feature:13
+ Given there are carrots # spec.feature:4
+ OUTPUT
+ lines.split("\n").each do |line|
+ expect(@out.string).to include line.strip
+ end
+ end
+
+ context "With very wide cells" do
+ define_feature <<-FEATURE
+ Feature: Monkey Business
+
+ Scenario Outline: Types of monkey
+ Given there are <Types of monkey>
+
+ Examples:
+ | Types of monkey | Extra |
+ | Hominidae | Very long cell content |
+ FEATURE
+
+ it "the scenario line controls the source indentation" do
+ lines = <<-OUTPUT
+ Examples:
+ Scenario: | Hominidae | Very long cell content | # spec.feature:8
+ Given there are Hominidae # spec.feature:4
+
+ OUTPUT
+ lines.split("\n").each do |line|
+ expect(@out.string).to include line.strip
+ end
+ end
+ end
+ end
+ end
+ end
end
end
end