-
Notifications
You must be signed in to change notification settings - Fork 1
/
feature_file_steps.rb
130 lines (99 loc) · 3.98 KB
/
feature_file_steps.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Given /^we create a FeatureFile from a none cucumber feature file$/ do
@file = FeatureFile.new("#{RAILS_ROOT}/spec/fixtures/projects.yml")
end
Given /^we create a FeatureFile from a cucumber feature file$/ do
@file = FeatureFile.new("#{RAILS_ROOT}/spec/fixtures/test.feature")
end
Given /^we have a feature file$/ do
File.exists?("#{RAILS_ROOT}/spec/fixtures/test.feature").should be_true
end
Given /^we create a FeatureFile from a cucumber feature file with a scenario outline$/ do
@file = FeatureFile.new "#{RAILS_ROOT}/features/plain/enhancements.feature"
end
Given /^the feature file is not present in the system$/ do
Feature.find_by_title(@feature.title).should be_nil
end
When /^a feature is valid$/ do
@file.should_not be_invalid
end
When /^it has more than one scenario$/ do
@file.scenarios.count.should >= 1
end
When /^it has a scenario outline$/ do
@file.read.should contain "Scenario Outline:"
end
Then /^the object should be valid$/ do
@file.should_not be_invalid
end
Then /^the feature property should not be nil$/ do
@file.feature.should_not be_nil
end
Then /^the object should be invalid$/ do
@file.should be_invalid
end
Then /^the 'In order' property should not be nil$/ do
@file.in_order.should_not be_nil
end
Then /^the 'As a' property should not be nil$/ do
@file.as_a.should_not be_nil
end
Then /^the 'I want' property should not be nil$/ do
@file.i_want.should_not be_nil
end
Then /^the object should have 1 or more scenarios$/ do
@file.scenarios.should_not be_nil
end
Then /^each scenario should have the expected steps$/ do
@file.scenarios.first.steps.should_not be_empty
end
Then /^export will return a Feature object$/ do
@file.export.should be_a Feature
end
Then /^the feature should have stories$/ do
@file.export.stories.should_not be_empty
end
Then /^these stores should have steps$/ do
@file.export.stories.each { |story| story.steps.should_not be_nil }
end
Then /^exported features 'title' will not contain '(.*)' prefix$/ do |content|
@file.export.title.should_not contain content
end
Then /^exported features 'in_order' will not contain '(.*)' prefix$/ do |content|
@file.export.in_order.should_not contain content
end
Then /^exported features 'i_want' will not contain '(.*)' prefix$/ do |content|
@file.export.i_want.should_not contain content
end
Then /^exported features 'as_a' will not contain '(.*)' prefix$/ do |content|
@file.export.as_a.should_not contain content
end
Then /^each scenario should not be prefixed with 'Scenario:'$/ do
@file.export.stories.each { |story| story.scenario.should_not contain /^Scenario:/}
end
When /^each scenario should not be prefixed with 'Scenario Outline:'$/ do
@file.export.stories.each { |story| story.scenario.should_not contain /^Scenario Outline:/}
end
Then /^a scenario outline should be found$/ do
@file.export.stories.first.examples.first.should_not be_nil
end
Then /^each scenario outline should have the expected steps$/ do
@file.export.stories.first.steps.should_not be_empty
end
Then /^the scenario outline should precede its examples$/ do
@file.export.stories.first.examples.should_not be_empty
end
Then /^the example should have a list of actions$/ do
@file.export.stories.first.examples.first.actions.should_not be_empty
end
Then /^the scenario outlines example should be found$/ do
@file.export.stories.first.examples.first.should_not be_nil
end
Then /^the actions should only contain "([^\"]*)"$/ do |words|
words.split(',').each_with_index { |word,index| @file.export.stories.first.examples.first.actions[index].title.should == word }
end
Then /^the "([^\"]*)" should have "([^\"]*)" associated to it "([^\"]*)" of times$/ do |action, current_item, amount|
@file.export.stories.first.examples.first.actions.each {|current_action| count = 0; current_action.items.each {|item| (item.title == current_item)? count += 1 :nil; } ; count.to_s.should eql amount if current_action.title == action }
end
Then /^we want to be able to import the feature$/ do
response.should have_selector :a
end