-
Notifications
You must be signed in to change notification settings - Fork 1
/
feature_file_steps.rb
103 lines (78 loc) · 3.28 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
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 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 object should be invalid$/ do
@file.should be_invalid
end
Then /^the '(.*)' property should not be nil$/ do |property|
@file.send(property.to_sym).should_not be_nil
end
Then /^the object should have (.*) or more scenarios$/ do |amount|
@file.scenarios.count.should >= amount.to_i
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 '(.*)' will not contain '(.*)' prefix$/ do |property, content|
@file.export.send(property.to_sym).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