mezuro_steps.rb
1.36 KB
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
When /^I create a Mezuro (project|configuration) with the following data$/ do |type, fields|
click_link ("Mezuro " + type)
fields.rows_hash.each do |name, value|
When %{I fill in "#{name}" with "#{value}"}
end
if Article.find_by_name(fields.rows_hash[:Title])
return false
end
click_button "Save" # Does not work without selenium?
Article.find_by_name(fields.rows_hash[:Title])
end
Then /^I directly delete content with name "([^\"]*)" for testing purposes$/ do |content_name|
Article.find_by_name(content_name).destroy
end
Then /^I should be at the url "([^\"]*)"$/ do |url|
if response.class.to_s == 'Webrat::SeleniumResponse'
URI.parse(response.selenium.get_location).path.should == url
else
URI.parse(current_url).path.should == url
end
end
Then /^I don't fill anything$/ do
end
Then /^I should see "([^\"]*)" inside an alert$/ do |message|
selenium.get_alert.should eql(message)
selenium.chooseOkOnNextConfirmation();
end
Given /^the following Mezuro project$/ do |table|
table.hashes.map{|item| item.dup}.each do |item|
owner_identifier = item.delete("owner")
parent = item.delete("parent")
owner = Profile[owner_identifier]
item.merge!(:profile => owner)
result = MezuroPlugin::ProjectContent.new(item)
if !parent.blank?
result.parent = Article.find_by_name(parent)
end
result.save!
end
end