/
feature_import_steps.rb
73 lines (62 loc) · 2.49 KB
/
feature_import_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
Given /^the project has a feature to export with duplicate scenarios$/ do
Given %{we have a valid feature file}
end
Given /^the project has a project path$/ do
@project.update_attribute(:location,"#{RAILS_ROOT}/spec/fixtures")
end
Given /^there are no projects to import$/ do
Feature.stub!(:find_by_path).and_return mock_model(Feature).as_null_object
end
Then /^I should see a import link$/ do
response.should have_selector :a, attribute = {:href => "/projects/#{@project.id}/import"}
end
Then /^I should not see a import link$/ do
response.should_not have_selector :a, attribute = {:href => "/projects/#{@project.id}/import"}
end
# Refactor to help speed things up
Then /^I should see a list of features that will be imported$/ do
response.should have_selector :ul do |list|
@project.import_features do |feature|
list.should have_selector :li do |content|
content.should contain "#{feature[:feature].title}"
end
end
end
end
Then /^each of the features tabs should not include any underscores$/ do
response.should have_selector :ul do |list|
@project.import_features do |feature|
list.should have_selector :li do |content|
content.should have_selector :a, :content => "#{feature[:file].sub(/\.feature/,"").gsub(/_/," ")}"
end
end
end
end
Then /^each of the features title should not include any underscores$/ do
response.should have_selector :form do |content|
@project.import_features do |feature|
content.should have_selector :h3, :content => "Feature: #{feature[:file].sub(/\.feature/,"").gsub("_"," ")}"
end
end
end
Then /^the first story should contain its examples$/ do
@project.import_features do |feature|
if feature[:file] == 'most_used.feature'
response.should contain feature[:feature].stories.first.example
end
end
response.should contain 'Examples'
end
Then /^the submit button will be disabled for "([^\"]*)"$/ do |container|
response.should have_selector :p, attribute = {:id => "error"} do |error|
error.should contain "Feature has duplicate scenario"
end
end
Then /^display the feature file for "([^\"]*)" already exists$/ do |feature_file|
response.should have_selector :p, attribute = {:id => "error"} do |error|
error.should contain "Feature already exists in #{RAILS_ROOT}/spec/fixtures/features/duplicates/sample_one.feature"
end
end
Then /^I should not see a import all link$/ do
response.should_not have_selector :a, attribute = {:href => "/projects/#{@project.id}/import_all"}
end