-
-
Notifications
You must be signed in to change notification settings - Fork 696
/
feature_parser_spec.rb
86 lines (67 loc) · 2.36 KB
/
feature_parser_spec.rb
1
2
3
4
5
6
7
8
9
10
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
require File.dirname(__FILE__) + '/../../spec_helper'
module Cucumber
module TreetopParser
describe FeatureParser do
it "should parse features with weird spaces" do
p = FeatureParser.new
f = p.parse_feature(File.dirname(__FILE__) + '/spaces.feature')
v = Object.new.instance_eval do
def visit_header(h)
h.should == "Some title"
end
def visit_scenario(s)
def self.visit_scenario(s)
s.name.should == "second"
s.accept(self)
end
s.name.should == "first"
s.accept(self)
end
def visit_regular_scenario(s)
end
def visit_step(s)
def self.visit_step(s)
s.name.should == "b"
end
s.name.should == "a"
end
self
end
f.accept(v)
end
it "should parse GivenScenario" do
p = FeatureParser.new
f = p.parse_feature(File.dirname(__FILE__) + '/given_scenario.feature')
f.header.should == "Some title"
f.should have(2).scenarios
first = f.scenarios[0]
first.should have(2).steps
second = f.scenarios[1]
second.should have(3).steps
end
it "should allow spaces between FIT values" do
p = FeatureParser.new
Cucumber::Tree::RowScenario.should_receive(:new).with(anything, anything, ['I can have spaces'], anything)
f = p.parse_feature(File.dirname(__FILE__) + '/fit_scenario.feature')
end
it "should allow comments in feature files" do
p = FeatureParser.new
f = p.parse_feature(File.dirname(__FILE__) + '/with_comments.feature')
f.scenarios[0].should have(2).steps
end
it "should allow empty scenarios" do
p = FeatureParser.new
f = p.parse_feature(File.dirname(__FILE__) + '/empty_scenario.feature')
f.scenarios[0].should have(1).steps
f.scenarios[1].should have(0).steps
f.scenarios[2].should have(1).steps
end
it "should allow multiple tables" do
p = FeatureParser.new
f = p.parse_feature(File.dirname(__FILE__) + '/multiple_tables.feature')
f.should have(6).scenarios
f.scenarios[0].should have(5).steps
end
end
end
end