2010-05-05 19:09:51 +02:00
|
|
|
Given /^I have no contexts$/ do
|
|
|
|
|
# should probably not be needed as you use this given at the start of a scenario
|
|
|
|
|
Context.delete_all
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-23 17:52:50 +02:00
|
|
|
Given /^there exists an active context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
|
2010-07-30 21:06:12 +02:00
|
|
|
user = User.find_by_login(login)
|
|
|
|
|
user.should_not be_nil
|
2010-10-23 17:52:50 +02:00
|
|
|
@context = user.contexts.create!(:name => context_name, :hide => false)
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-24 23:19:11 +02:00
|
|
|
Given /^there exists a context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
|
2010-11-27 17:12:09 +01:00
|
|
|
Given "there exists an active context called \"#{context_name}\" for user \"#{login}\""
|
2010-10-24 23:19:11 +02:00
|
|
|
end
|
|
|
|
|
|
2010-10-23 17:52:50 +02:00
|
|
|
Given /^there exists a hidden context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
|
|
|
|
|
user = User.find_by_login(login)
|
|
|
|
|
user.should_not be_nil
|
|
|
|
|
@context = user.contexts.create!(:name => context_name, :hide => true)
|
2010-07-30 21:06:12 +02:00
|
|
|
end
|
|
|
|
|
|
2010-02-09 10:27:59 +01:00
|
|
|
Given /^I have a context called "([^\"]*)"$/ do |context_name|
|
2010-10-23 17:52:50 +02:00
|
|
|
Given "there exists an active context called \"#{context_name}\" for user \"#{@current_user.login}\""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Given /^I have an active context called "([^\"]*)"$/ do |context_name|
|
|
|
|
|
Given "there exists an active context called \"#{context_name}\" for user \"#{@current_user.login}\""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Given /^I have a hidden context called "([^\"]*)"$/ do |context_name|
|
|
|
|
|
Given "there exists a hidden context called \"#{context_name}\" for user \"#{@current_user.login}\""
|
2010-02-09 10:27:59 +01:00
|
|
|
end
|
|
|
|
|
|
2010-05-05 19:09:51 +02:00
|
|
|
Given /^I have the following contexts:$/ do |table|
|
|
|
|
|
table.hashes.each do |context|
|
|
|
|
|
Given 'I have a context called "'+context[:context]+'"'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2010-05-03 21:26:48 +02:00
|
|
|
Given /^I have a context "([^\"]*)" with (.*) actions$/ do |context_name, number_of_actions|
|
|
|
|
|
context = @current_user.contexts.create!(:name => context_name)
|
|
|
|
|
1.upto number_of_actions.to_i do |i|
|
|
|
|
|
@current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2010-07-29 18:06:30 +02:00
|
|
|
Given /^I have the following contexts$/ do |table|
|
|
|
|
|
Context.delete_all
|
|
|
|
|
table.hashes.each do |hash|
|
|
|
|
|
context = Factory(:context, hash)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-22 20:46:06 +02:00
|
|
|
# TODO: refactor this to paths.rb
|
2010-07-14 15:13:20 +02:00
|
|
|
When /^I visit the context page for "([^\"]*)"$/ do |context_name|
|
2010-02-09 10:27:59 +01:00
|
|
|
context = @current_user.contexts.find_by_name(context_name)
|
|
|
|
|
context.should_not be_nil
|
|
|
|
|
visit "/contexts/#{context.id}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I edit the context name in place to be "([^\"]*)"$/ do |new_context_name|
|
|
|
|
|
selenium.click "context_name"
|
2010-10-22 20:46:06 +02:00
|
|
|
fill_in "value", :with => new_context_name
|
2010-02-09 10:27:59 +01:00
|
|
|
click_button "OK"
|
|
|
|
|
end
|
|
|
|
|
|
2010-05-03 21:26:48 +02:00
|
|
|
Then /^I should see the context name is "([^\"]*)"$/ do |context_name|
|
|
|
|
|
Then "I should see \"#{context_name}\""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^he should see that a context named "([^\"]*)" is present$/ do |context_name|
|
|
|
|
|
Then "I should see \"#{context_name}\""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^he should see that a context named "([^\"]*)" is not present$/ do |context_name|
|
|
|
|
|
Then "I should not see \"#{context_name} (\""
|
2010-07-29 18:06:30 +02:00
|
|
|
end
|
2010-11-27 17:12:09 +01:00
|
|
|
|
|
|
|
|
Then /^I should see feeds for "([^"]*)" in list of "([^"]*)"$/ do |name, list_type|
|
|
|
|
|
xpath= "//div[@id='feeds-for-#{list_type}']//strong"
|
|
|
|
|
name.should == response.selenium.get_text("xpath=#{xpath}")
|
|
|
|
|
end
|