Use RSpec 'expect' instead of 'should'

This commit is contained in:
Dan Rice 2014-05-16 15:42:03 -04:00
parent 4ee8c2e7fd
commit 7a3f90a020
20 changed files with 208 additions and 248 deletions

View file

@ -1,12 +1,12 @@
When(/^I collapse the context container of "([^"]*)"$/) do |context_name| When(/^I collapse the context container of "([^"]*)"$/) do |context_name|
toggle = page.find(:xpath, toggle_context_container_xpath(find_context(context_name))) toggle = page.find(:xpath, toggle_context_container_xpath(find_context(context_name)))
toggle.should be_visible expect(toggle).to be_visible
toggle.click toggle.click
end end
When(/^I collapse the project container of "(.*?)"$/) do |project_name| When(/^I collapse the project container of "(.*?)"$/) do |project_name|
toggle = page.find(:xpath, toggle_project_container_xpath(find_project(project_name))) toggle = page.find(:xpath, toggle_project_container_xpath(find_project(project_name)))
toggle.should be_visible expect(toggle).to be_visible
toggle.click toggle.click
end end
@ -107,7 +107,7 @@ end
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description| Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
within "div#due_after_this_month_container" do within "div#due_after_this_month_container" do
page.should have_css("div#line_todo_#{find_todo(todo_description).id}") expect(page).to have_css("div#line_todo_#{find_todo(todo_description).id}")
end end
end end
@ -148,7 +148,7 @@ Then /^I should (see|not see) empty message for (done today|done this week|done
css = "div#deferred_pending_container-empty-d" if state == "deferred todos" css = "div#deferred_pending_container-empty-d" if state == "deferred todos"
elem = find(css) elem = find(css)
elem.should_not be_nil expect(elem).to_not be_nil
check_elem_visibility(visible, elem) check_elem_visibility(visible, elem)
end end

View file

@ -4,10 +4,10 @@ When /^I delete the context "([^\"]*)"$/ do |context_name|
handle_js_confirm do handle_js_confirm do
click_link "delete_context_#{context.id}" click_link "delete_context_#{context.id}"
end end
get_confirm_text.should == "Are you sure that you want to delete the context '#{context_name}'? Be aware that this will also delete all (repeating) actions in this context!" expect(get_confirm_text).to eq("Are you sure that you want to delete the context '#{context_name}'? Be aware that this will also delete all (repeating) actions in this context!")
# wait until the context is removed # wait until the context is removed
page.should_not have_css("a#delete_context_#{context.id}") expect(page).to_not have_css("a#delete_context_#{context.id}")
end end
When /^I edit the context to rename it to "([^\"]*)"$/ do |new_name| When /^I edit the context to rename it to "([^\"]*)"$/ do |new_name|
@ -61,7 +61,7 @@ When /^I edit the state of context "(.*?)" to closed$/ do |context_name|
end end
Then /^context "([^"]*)" should be above context "([^"]*)"$/ do |context_high, context_low| Then /^context "([^"]*)" should be above context "([^"]*)"$/ do |context_high, context_low|
context_list_find_index(context_high).should < context_list_find_index(context_low) expect(context_list_find_index(context_high)).to be < context_list_find_index(context_low)
end end
Then(/^I should see that a context named "([^"]*)" (is|is not) present$/) do |context_name, present| Then(/^I should see that a context named "([^"]*)" (is|is not) present$/) do |context_name, present|
@ -87,9 +87,9 @@ Then /^the new context form should (be|not be) visible$/ do |visible|
end end
Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state_name, count| Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state_name, count|
find("span##{state_name}-contexts-count").text.should == count expect(find("span##{state_name}-contexts-count").text).to eq(count)
end end
Then /^I should (see|not see) empty message for (active|hidden|closed) contexts$/ do |visible, state| Then /^I should (see|not see) empty message for (active|hidden|closed) contexts$/ do |visible, state|
check_css_visibility(visible, "div##{state}-contexts-empty-nd") check_css_visibility(visible, "div##{state}-contexts-empty-nd")
end end

View file

@ -5,7 +5,7 @@ end
Given /^there exists (an active|a hidden|a closed) context called "([^"]*)" for user "([^"]*)"$/ do |state, context_name, login| Given /^there exists (an active|a hidden|a closed) context called "([^"]*)" for user "([^"]*)"$/ do |state, context_name, login|
user = User.where(:login => login).first user = User.where(:login => login).first
user.should_not be_nil expect(user).to_not be_nil
context_state = {"an active" => "active", "a hidden" => "hidden", "a closed" => "closed"}[state] context_state = {"an active" => "active", "a hidden" => "hidden", "a closed" => "closed"}[state]
@context = user.contexts.where(:name => context_name, :state => context_state).first_or_create @context = user.contexts.where(:name => context_name, :state => context_state).first_or_create
end end
@ -63,11 +63,11 @@ end
Then /^he should see that a context named "([^\"]*)" (is|is not) present$/ do |context_name, visible| Then /^he should see that a context named "([^\"]*)" (is|is not) present$/ do |context_name, visible|
context = @current_user.contexts.where(:name => context_name).first context = @current_user.contexts.where(:name => context_name).first
if visible == "is" if visible == "is"
context.should_not be_nil expect(context).to_not be_nil
css = "div#context_#{context.id} div.context_description a" css = "div#context_#{context.id} div.context_description a"
page.should have_selector(css, :visible => true) expect(page).to have_selector(css, :visible => true)
page.find(:css, css).text.should == context_name expect(page.find(:css, css).text).to eq(context_name)
else else
page.should_not have_selector("div#context_#{context.id} div.context_description a", :visible => true) if context expect(page).to_not have_selector("div#context_#{context.id} div.context_description a", :visible => true) if context
end end
end end

View file

@ -18,7 +18,7 @@ end
When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name| When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name|
todo = Todo.where(:description=>todo_name).first todo = Todo.where(:description=>todo_name).first
todo.should_not be_nil expect(todo).to_not be_nil
expand_img_locator = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img" expand_img_locator = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
page.find(:xpath, expand_img_locator).click page.find(:xpath, expand_img_locator).click
@ -28,9 +28,9 @@ end
When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |todo_description, predecessor_description| When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |todo_description, predecessor_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
predecessor = @current_user.todos.where(:description => predecessor_description).first predecessor = @current_user.todos.where(:description => predecessor_description).first
predecessor.should_not be_nil expect(predecessor).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -43,29 +43,29 @@ When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |
page.execute_script %Q{$("#{form_css}").find('input[id$="predecessor_input"]').autocomplete('search')} if Capybara.javascript_driver == :webkit page.execute_script %Q{$("#{form_css}").find('input[id$="predecessor_input"]').autocomplete('search')} if Capybara.javascript_driver == :webkit
# wait for auto complete # wait for auto complete
page.should have_css("a.ui-state-focus") expect(page).to have_css("a.ui-state-focus")
# click first line # click first line
page.find(:css, "ul li a.ui-state-focus").click page.find(:css, "ul li a.ui-state-focus").click
# wait for the new dependency to be added to the list # wait for the new dependency to be added to the list
page.should have_css("li#pred_#{predecessor.id}") expect(page).to have_css("li#pred_#{predecessor.id}")
submit_edit_todo_form(todo) submit_edit_todo_form(todo)
end end
When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ do |todo_description, predecessor_description| When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ do |todo_description, predecessor_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
predecessor = @current_user.todos.where(:description => predecessor_description).first predecessor = @current_user.todos.where(:description => predecessor_description).first
predecessor.should_not be_nil expect(predecessor).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
delete_dep_button = "//form[@id='form_todo_#{todo.id}']//img[@id='delete_dep_#{predecessor.id}']" delete_dep_button = "//form[@id='form_todo_#{todo.id}']//img[@id='delete_dep_#{predecessor.id}']"
page.find(:xpath, delete_dep_button).click page.find(:xpath, delete_dep_button).click
page.should_not have_xpath(delete_dep_button) expect(page).to_not have_xpath(delete_dep_button)
submit_edit_todo_form(todo) submit_edit_todo_form(todo)
wait_for_ajax wait_for_ajax
@ -74,7 +74,7 @@ end
When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps| When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps|
todo = @dep_todo = @current_user.todos.where(:description => todo_name).first todo = @dep_todo = @current_user.todos.where(:description => todo_name).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
fill_in "predecessor_list_todo_#{todo.id}", :with => deps fill_in "predecessor_list_todo_#{todo.id}", :with => deps
@ -83,7 +83,7 @@ end
Then /^the successors of "(.*)" should include "(.*)"$/ do |parent_name, child_name| Then /^the successors of "(.*)" should include "(.*)"$/ do |parent_name, child_name|
parent = @current_user.todos.where(:description => parent_name).first parent = @current_user.todos.where(:description => parent_name).first
parent.should_not be_nil expect(parent).to_not be_nil
# wait until the successor is added. TODO: make this not loop indefinitly # wait until the successor is added. TODO: make this not loop indefinitly
wait_until do wait_until do
@ -95,7 +95,7 @@ end
Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description| Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
# open successors # open successors
within "div#line_todo_#{todo.id}" do within "div#line_todo_#{todo.id}" do
@ -109,14 +109,14 @@ end
Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |successor_description, todo_description| Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
step "I should not see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\"" step "I should not see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\""
end end
Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description| Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img" dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
page.should_not have_xpath(dependencies_icon) expect(page).to_not have_xpath(dependencies_icon)
end end

View file

@ -7,23 +7,23 @@ Then /^I should see a message that you need a project to get feeds for projects$
end end
Then /^I should see feeds for projects$/ do Then /^I should see feeds for projects$/ do
page.should have_css("select#feed-projects option[value='#{@current_user.projects.first.id}']") expect(page).to have_css("select#feed-projects option[value='#{@current_user.projects.first.id}']")
end end
Then /^I should see feeds for contexts$/ do Then /^I should see feeds for contexts$/ do
page.should have_css("select#feed-contexts option[value='#{@current_user.contexts.first.id}']") expect(page).to have_css("select#feed-contexts option[value='#{@current_user.contexts.first.id}']")
end end
Then /^I should see "([^"]*)" as the selected project$/ do |project_name| Then /^I should see "([^"]*)" as the selected project$/ do |project_name|
page.should have_css 'select#feed-projects option[selected="selected"]' expect(page).to have_css('select#feed-projects option[selected="selected"]')
end end
Then /^I should see "([^"]*)" as the selected context$/ do |context_name| Then /^I should see "([^"]*)" as the selected context$/ do |context_name|
page.should have_css 'select#feed-contexts option[selected="selected"]' expect(page).to have_css('select#feed-contexts option[selected="selected"]')
end end
Then /^I should see feeds for "([^"]*)" in list of "([^"]*)"$/ do |name, list_type| Then /^I should see feeds for "([^"]*)" in list of "([^"]*)"$/ do |name, list_type|
wait_for_ajax wait_for_ajax
xpath= "//div[@id='feeds-for-#{list_type}']//strong" xpath= "//div[@id='feeds-for-#{list_type}']//strong"
name.should == find(:xpath, xpath).text expect(name).to eq(find(:xpath, xpath).text)
end end

View file

@ -16,15 +16,15 @@ end
Then /the badge should show (.*)/ do |number| Then /the badge should show (.*)/ do |number|
badge = find("span#badge_count").text.to_i badge = find("span#badge_count").text.to_i
badge.should == number.to_i expect(badge).to eq(number.to_i)
end end
Then(/^I should see an error flash message saying "([^"]*)"$/) do |message| Then(/^I should see an error flash message saying "([^"]*)"$/) do |message|
xpath = "//div[@id='message_holder']/h4[@id='flash']" xpath = "//div[@id='message_holder']/h4[@id='flash']"
page.should have_xpath(xpath, :visible => true) expect(page).to have_xpath(xpath, :visible => true)
text = page.find(:xpath, xpath).text text = page.find(:xpath, xpath).text
text.should == message expect(text).to eq(message)
end end
Then /^I should see "([^"]*)" $/ do |text| Then /^I should see "([^"]*)" $/ do |text|

View file

@ -8,13 +8,13 @@ Then /^I should see scripts$/ do
end end
Then /^I should see a script "([^\"]*)" for "([^\"]*)"$/ do |script, context_name| Then /^I should see a script "([^\"]*)" for "([^\"]*)"$/ do |script, context_name|
page.should have_css("##{script}", :visible => true) expect(page).to have_css("##{script}", :visible => true)
context = Context.where(:name => context_name).first context = Context.where(:name => context_name).first
page.should have_content("#{context.id} (* #{context_name} *)") expect(page).to have_content("#{context.id} (* #{context_name} *)")
# make sure the text is found within the textarea # make sure the text is found within the textarea
script_source = page.find(:xpath, "//textarea[@id='#{script}']").text script_source = page.find(:xpath, "//textarea[@id='#{script}']").text
script_source.should =~ /#{context.id} \(\* #{context_name} \*\)/ expect(script_source).to match(/#{context.id} \(\* #{context_name} \*\)/)
end end

View file

@ -10,9 +10,9 @@ When /^I delete the first note$/ do
handle_js_confirm do handle_js_confirm do
click_link "delete_note_#{id}" click_link "delete_note_#{id}"
end end
get_confirm_text.should == "Are you sure that you want to delete the note '#{id}'?" expect(get_confirm_text).to eq("Are you sure that you want to delete the note '#{id}'?")
page.should_not have_css("a#delete_note_#{id}") expect(page).to_not have_css("a#delete_note_#{id}")
end end
When /^I click the icon next to the note$/ do When /^I click the icon next to the note$/ do
@ -32,7 +32,7 @@ end
When(/^I toggle the note of "([^"]*)"$/) do |todo_description| When(/^I toggle the note of "([^"]*)"$/) do |todo_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
xpath = "//div[@id='line_todo_#{todo.id}']/div/a/img" xpath = "//div[@id='line_todo_#{todo.id}']/div/a/img"
page.find(:xpath, xpath).click page.find(:xpath, xpath).click
@ -52,7 +52,7 @@ Then /^(.*) notes should be visible$/ do |number|
# count number of project_notes # count number of project_notes
count = 0 count = 0
page.all("div.project_notes").each { |node| count += 1 } page.all("div.project_notes").each { |node| count += 1 }
count.should == number.to_i expect(count).to eq(number.to_i)
end end
Then /^I should see note "([^\"]*)" on the "([^\"]*)" project page$/ do |note, project| Then /^I should see note "([^\"]*)" on the "([^\"]*)" project page$/ do |note, project|
@ -71,7 +71,7 @@ Then /^the first note should disappear$/ do
id = title.split(' ').last id = title.split(' ').last
note = "div#note_#{id}" note = "div#note_#{id}"
page.should_not have_css(note, :visible=>true) expect(page).to_not have_css(note, :visible=>true)
end end
Then /^I should see the note text$/ do Then /^I should see the note text$/ do
@ -79,9 +79,9 @@ Then /^I should see the note text$/ do
end end
Then /^I should not see the note "([^"]*)"$/ do |note_content| Then /^I should not see the note "([^"]*)"$/ do |note_content|
page.should_not have_selector("div", :text => note_content, :visible => true) expect(page).to_not have_selector("div", :text => note_content, :visible => true)
end end
Then /^I should see the note "([^"]*)"$/ do |note_content| Then /^I should see the note "([^"]*)"$/ do |note_content|
page.all("div", :text => note_content).first.should be_visible expect(page.all("div", :text => note_content).first).to be_visible
end end

View file

@ -1,11 +1,11 @@
When /^I delete project "([^"]*)"$/ do |project_name| When /^I delete project "([^"]*)"$/ do |project_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
handle_js_confirm do handle_js_confirm do
click_link "delete_project_#{project.id}" click_link "delete_project_#{project.id}"
end end
get_confirm_text.should == "Are you sure that you want to delete the project '#{project_name}'?" expect(get_confirm_text).to eq("Are you sure that you want to delete the project '#{project_name}'?")
wait_until do wait_until do
!page.has_css?("a#delete_project_#{project.id}") !page.has_css?("a#delete_project_#{project.id}")
@ -40,7 +40,7 @@ When /^I sort the active list alphabetically$/ do
end end
wait_for_ajax wait_for_ajax
end end
get_confirm_text.should == "Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order." expect(get_confirm_text).to eq("Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order.")
end end
When /^I sort the active list by number of tasks$/ do When /^I sort the active list by number of tasks$/ do
@ -50,7 +50,7 @@ When /^I sort the active list by number of tasks$/ do
end end
wait_for_ajax wait_for_ajax
end end
get_confirm_text.should == "Are you sure that you want to sort these projects by the number of tasks? This will replace the existing sort order." expect(get_confirm_text).to eq("Are you sure that you want to sort these projects by the number of tasks? This will replace the existing sort order.")
end end
Then /^I should see that a project named "([^"]*)" is not present$/ do |project_name| Then /^I should see that a project named "([^"]*)" is not present$/ do |project_name|
@ -75,34 +75,34 @@ end
Then(/^I should not see the project "(.*?)"$/) do |project_name| Then(/^I should not see the project "(.*?)"$/) do |project_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
project_xpath = "//div[@id='project_#{project.id}']" project_xpath = "//div[@id='project_#{project.id}']"
page.should_not have_xpath(project_xpath) expect(page).to_not have_xpath(project_xpath)
end end
Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project_high, project_low| Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project_high, project_low|
project_list_find_index(project_high).should < project_list_find_index(project_low) expect(project_list_find_index(project_high)).to be < project_list_find_index(project_low)
end end
Then /^the project "([^"]*)" should not be in state list "([^"]*)"$/ do |project_name, state_name| Then /^the project "([^"]*)" should not be in state list "([^"]*)"$/ do |project_name, state_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
list_id = @source_view=="review" ? "list-#{state}-projects" : "list-#{state_name}-projects-container" list_id = @source_view=="review" ? "list-#{state}-projects" : "list-#{state_name}-projects-container"
xpath = "//div[@id='#{list_id}']//div[@id='project_#{project.id}']" xpath = "//div[@id='#{list_id}']//div[@id='project_#{project.id}']"
page.should_not have_xpath(xpath) expect(page).to_not have_xpath(xpath)
end end
Then /^the project "([^"]*)" should be in state list "([^"]*)"$/ do |project_name, state_name| Then /^the project "([^"]*)" should be in state list "([^"]*)"$/ do |project_name, state_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
list_id = @source_view=="review" ? "list-#{state_name}-projects" : "list-#{state_name}-projects-container" list_id = @source_view=="review" ? "list-#{state_name}-projects" : "list-#{state_name}-projects-container"
xpath = "//div[@id='#{list_id}']//div[@id='project_#{project.id}']" xpath = "//div[@id='#{list_id}']//div[@id='project_#{project.id}']"
page.should have_xpath(xpath) expect(page).to have_xpath(xpath)
end end
Then /^I see the project "([^"]*)" in the "([^"]*)" list$/ do |project_name, state_name| Then /^I see the project "([^"]*)" in the "([^"]*)" list$/ do |project_name, state_name|
@ -110,27 +110,27 @@ Then /^I see the project "([^"]*)" in the "([^"]*)" list$/ do |project_name, sta
end end
Then /^the project list badge for "([^"]*)" projects should show (\d+)$/ do |state_name, count| Then /^the project list badge for "([^"]*)" projects should show (\d+)$/ do |state_name, count|
page.find(:xpath, "//span[@id='#{state_name}-projects-count']").text.should == count expect(page.find(:xpath, "//span[@id='#{state_name}-projects-count']").text).to eq(count)
end end
Then /^the new project form should be visible$/ do Then /^the new project form should be visible$/ do
page.should have_css("div#project_new", :visible => true) expect(page).to have_css("div#project_new", :visible => true)
end end
Then /^the new project form should not be visible$/ do Then /^the new project form should not be visible$/ do
page.should_not have_css("div#project_new", :visible => true) expect(page).to_not have_css("div#project_new", :visible => true)
end end
Then /^the project "([^"]*)" should have (\d+) actions listed$/ do |project_name, count| Then /^the project "([^"]*)" should have (\d+) actions listed$/ do |project_name, count|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']" xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
page.find(:xpath, xpath).text.should == "#{project.name} (#{count} actions)" expect(page.find(:xpath, xpath).text).to eq("#{project.name} (#{count} actions)")
end end
Then /^the project "([^"]*)" should have (\d+) deferred actions listed$/ do |project_name, deferred| Then /^the project "([^"]*)" should have (\d+) deferred actions listed$/ do |project_name, deferred|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']" xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
page.find(:xpath, xpath).text.should == "#{project.name} (#{deferred} deferred actions)" expect(page.find(:xpath, xpath).text).to eq("#{project.name} (#{deferred} deferred actions)")
end end

View file

@ -42,7 +42,7 @@ end
Given /^there exists a project (?:|called )"([^"]*)" for user "([^"]*)"$/ do |project_name, user_name| Given /^there exists a project (?:|called )"([^"]*)" for user "([^"]*)"$/ do |project_name, user_name|
user = User.where(:login => user_name).first user = User.where(:login => user_name).first
user.should_not be_nil expect(user).to_not be_nil
@project = user.projects.create!(:name => project_name) @project = user.projects.create!(:name => project_name)
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this # acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
@project.move_to_bottom @project.move_to_bottom
@ -73,7 +73,7 @@ Given /^I have a (completed|hidden) project called "([^"]*)"$/ do |state, projec
step "I have a project called \"#{project_name}\"" step "I have a project called \"#{project_name}\""
@project.send(state=="completed" ? "complete!" : "hide!") @project.send(state=="completed" ? "complete!" : "hide!")
@project.reload @project.reload
@project.send(state=="completed" ? "completed?" : "hidden?").should be_true expect(@project.send(state=="completed" ? "completed?" : "hidden?")).to be_true
end end
Given /^I have (\d+) completed projects$/ do |number_of_projects| Given /^I have (\d+) completed projects$/ do |number_of_projects|
@ -102,7 +102,7 @@ end
Given /^the default tags for "(.*?)" are "(.*?)"$/ do |project_name, default_tags| Given /^the default tags for "(.*?)" are "(.*?)"$/ do |project_name, default_tags|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
project.default_tags = default_tags project.default_tags = default_tags
project.save! project.save!
@ -110,12 +110,12 @@ end
When /^I open the project edit form$/ do When /^I open the project edit form$/ do
click_link "link_edit_project_#{@project.id}" click_link "link_edit_project_#{@project.id}"
page.should have_css("button#submit_project_#{@project.id}", :visible => true) expect(page).to have_css("button#submit_project_#{@project.id}", :visible => true)
end end
When /^I cancel the project edit form$/ do When /^I cancel the project edit form$/ do
click_link "cancel_project_#{@project.id}" click_link "cancel_project_#{@project.id}"
page.should_not have_css("submit_project_#{@project.id}") expect(page).to_not have_css("submit_project_#{@project.id}")
wait_for_animations_to_end wait_for_animations_to_end
end end
@ -147,13 +147,13 @@ end
When /^I edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name| When /^I edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name|
@project = @current_user.projects.where(:name => project_current_name).first @project = @current_user.projects.where(:name => project_current_name).first
@project.should_not be_nil expect(@project).to_not be_nil
step "I edit the project name to \"#{project_new_name}\"" step "I edit the project name to \"#{project_new_name}\""
end end
When /^I try to edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name| When /^I try to edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name|
@project = @current_user.projects.where(:name => project_current_name).first @project = @current_user.projects.where(:name => project_current_name).first
@project.should_not be_nil expect(@project).to_not be_nil
step "I try to edit the project name to \"#{project_new_name}\"" step "I try to edit the project name to \"#{project_new_name}\""
end end
@ -168,14 +168,14 @@ When /^I click to edit the project name in place$/ do
end end
When /^I edit the project settings$/ do When /^I edit the project settings$/ do
@project.should_not be_nil expect(@project).to_not be_nil
click_link "link_edit_project_#{@project.id}" click_link "link_edit_project_#{@project.id}"
page.should have_xpath("//div[@id='edit_project_#{@project.id}']/form//button[@id='submit_project_#{@project.id}']") expect(page).to have_xpath("//div[@id='edit_project_#{@project.id}']/form//button[@id='submit_project_#{@project.id}']")
end end
When /^I close the project settings$/ do When /^I close the project settings$/ do
@project.should_not be_nil expect(@project).to_not be_nil
click_link "Cancel" click_link "Cancel"
wait_for_ajax wait_for_ajax
wait_for_animations_to_end wait_for_animations_to_end
@ -183,7 +183,7 @@ end
When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, state_name| When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, state_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
edit_project_settings(project) do edit_project_settings(project) do
choose "project_state_#{state_name}" choose "project_state_#{state_name}"
@ -192,7 +192,7 @@ end
When /^I edit project "([^"]*)" and mark the project as reviewed$/ do |project_name| When /^I edit project "([^"]*)" and mark the project as reviewed$/ do |project_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
open_project_edit_form(project) open_project_edit_form(project)
click_link "reviewed_project_#{project.id}" click_link "reviewed_project_#{project.id}"
@ -207,11 +207,11 @@ When /^I add a note "([^"]*)" to the project$/ do |note_body|
submit_button = "div.widgets button#submit_note" submit_button = "div.widgets button#submit_note"
click_link "Add a note" click_link "Add a note"
page.should have_css submit_button expect(page).to have_css submit_button
fill_in "note[body]", :with => note_body fill_in "note[body]", :with => note_body
elem = find(submit_button) elem = find(submit_button)
elem.should_not be_nil expect(elem).to_not be_nil
elem.click elem.click
wait_until do wait_until do
@ -221,9 +221,9 @@ When /^I add a note "([^"]*)" to the project$/ do |note_body|
end end
When /^I click on the first note icon$/ do When /^I click on the first note icon$/ do
@project.should_not be_nil expect(@project).to_not be_nil
@note = @project.notes.first # assume first note is also first on screen @note = @project.notes.first # assume first note is also first on screen
@note.should_not be_nil expect(@note).to_not be_nil
click_link "link_note_#{@note.id}" click_link "link_note_#{@note.id}"
end end
@ -242,44 +242,44 @@ end
Then /^I should be able to change the project name in place$/ do Then /^I should be able to change the project name in place$/ do
# Note that this is not changing the project name # Note that this is not changing the project name
page.should have_css("span#project_name>form>input") expect(page).to have_css("span#project_name>form>input")
page.find("span#project_name > form > button[type=cancel]").click page.find("span#project_name > form > button[type=cancel]").click
page.should_not have_css("span#project_name>form>input") expect(page).to_not have_css("span#project_name>form>input")
end end
Then /^I should not be able to change the project name in place$/ do Then /^I should not be able to change the project name in place$/ do
step "I click to edit the project name in place" step "I click to edit the project name in place"
page.should_not have_xpath("//span[@id='project_name']/form/input") expect(page).to_not have_xpath("//span[@id='project_name']/form/input")
end end
Then /^the form for adding a note should not be visible$/ do Then /^the form for adding a note should not be visible$/ do
page.should_not have_css("edit_form_note") expect(page).to_not have_css("edit_form_note")
end end
Then /^I should go to that note page$/ do Then /^I should go to that note page$/ do
current_path = URI.parse(current_url).path current_path = URI.parse(current_url).path
note_path = note_path(@note) note_path = note_path(@note)
current_path.should == note_path expect(current_path).to eq(note_path)
end end
Then /^I should see one note in the project$/ do Then /^I should see one note in the project$/ do
page.should have_xpath("//div[@class='note_wrapper']") expect(page).to have_xpath("//div[@class='note_wrapper']")
end end
Then /^I should see the bold text "([^\"]*)" in the project description$/ do |text_in_bold| Then /^I should see the bold text "([^\"]*)" in the project description$/ do |text_in_bold|
xpath="//div[@class='project_description']/p/strong" xpath="//div[@class='project_description']/p/strong"
page.should have_xpath(xpath) expect(page).to have_xpath(xpath)
bold_text = page.find(:xpath, xpath).text bold_text = page.find(:xpath, xpath).text
bold_text.should =~ /#{text_in_bold}/ expect(bold_text).to match(/#{text_in_bold}/)
end end
Then /^I should see the italic text "([^\"]*)" in the project description$/ do |text_in_italic| Then /^I should see the italic text "([^\"]*)" in the project description$/ do |text_in_italic|
xpath="//div[@class='project_description']/p/em" xpath="//div[@class='project_description']/p/em"
page.should have_xpath(xpath) expect(page).to have_xpath(xpath)
italic_text = page.find(:xpath, xpath).text italic_text = page.find(:xpath, xpath).text
italic_text.should =~ /#{text_in_italic}/ expect(italic_text).to match(/#{text_in_italic}/)
end end
Then /^the project title should be "(.*)"$/ do |title| Then /^the project title should be "(.*)"$/ do |title|
@ -295,24 +295,24 @@ end
Then /^I should (see|not see) the default project settings$/ do |visible| Then /^I should (see|not see) the default project settings$/ do |visible|
default_settings = "This project is active with no default context and with no default tags" default_settings = "This project is active with no default context and with no default tags"
page.should have_css("div.project_settings") expect(page).to have_css("div.project_settings")
elem = page.find("div.project_settings") elem = page.find("div.project_settings")
if visible == "see" if visible == "see"
elem.should be_visible expect(elem).to be_visible
elem.text.should =~ /#{default_settings}/ expect(elem.text).to match(/#{default_settings}/)
else else
elem.should_not be_visible expect(elem).to_not be_visible
end end
end end
Then /^I should have a project called "([^"]*)"$/ do |project_name| Then /^I should have a project called "([^"]*)"$/ do |project_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
end end
Then /^I should have (\d+) todo in project "([^"]*)"$/ do |todo_count, project_name| Then /^I should have (\d+) todo in project "([^"]*)"$/ do |todo_count, project_name|
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
project.todos.count.should == todo_count.to_i expect(project.todos.count).to eq(todo_count.to_i)
end end

View file

@ -14,7 +14,7 @@ Given /^I have a repeat pattern called "([^"]*)"$/ do |pattern_name|
:created_at => Time.now - 1.day, :created_at => Time.now - 1.day,
:completed_at => nil :completed_at => nil
) )
@recurring_todo.completed?.should be_false expect(@recurring_todo.completed?).to be_false
@todo = @current_user.todos.create!( @todo = @current_user.todos.create!(
:description => pattern_name, :description => pattern_name,
:context_id => context.id, :context_id => context.id,
@ -24,7 +24,7 @@ end
Given /^I have a completed repeat pattern "([^"]*)"$/ do |pattern_name| Given /^I have a completed repeat pattern "([^"]*)"$/ do |pattern_name|
step "I have a repeat pattern called \"#{pattern_name}\"" step "I have a repeat pattern called \"#{pattern_name}\""
@recurring_todo.toggle_completion! @recurring_todo.toggle_completion!
@recurring_todo.completed?.should be_true expect(@recurring_todo.completed?).to be_true
end end
Given /^I have (\d+) completed repeat patterns$/ do |number_of_patterns| Given /^I have (\d+) completed repeat patterns$/ do |number_of_patterns|
@ -39,39 +39,39 @@ end
When /^I edit the name of the pattern "([^\"]*)" to "([^\"]*)"$/ do |pattern_name, new_name| When /^I edit the name of the pattern "([^\"]*)" to "([^\"]*)"$/ do |pattern_name, new_name|
pattern = @current_user.recurring_todos.where(:description => pattern_name).first pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil expect(pattern).to_not be_nil
click_link "link_edit_recurring_todo_#{pattern.id}" click_link "link_edit_recurring_todo_#{pattern.id}"
page.should have_css("input#edit_recurring_todo_description") expect(page).to have_css("input#edit_recurring_todo_description")
fill_in "edit_recurring_todo_description", :with => new_name fill_in "edit_recurring_todo_description", :with => new_name
page.find("button#recurring_todo_edit_update_button").click page.find("button#recurring_todo_edit_update_button").click
page.should_not have_css("div#edit-recurring-todo", :visible => true) expect(page).to_not have_css("div#edit-recurring-todo", :visible => true)
end end
When /^I star the pattern "([^\"]*)"$/ do |pattern_name| When /^I star the pattern "([^\"]*)"$/ do |pattern_name|
pattern = @current_user.recurring_todos.where(:description => pattern_name).first pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil expect(pattern).to_not be_nil
click_link "star_icon_#{pattern.id}" click_link "star_icon_#{pattern.id}"
end end
When /^I delete the pattern "([^"]*)"$/ do |pattern_name| When /^I delete the pattern "([^"]*)"$/ do |pattern_name|
pattern = @current_user.recurring_todos.where(:description => pattern_name).first pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil expect(pattern).to_not be_nil
handle_js_confirm do handle_js_confirm do
click_link "delete_icon_#{pattern.id}" click_link "delete_icon_#{pattern.id}"
end end
get_confirm_text.should == "Are you sure that you want to delete the recurring action '#{pattern_name}'?" expect(get_confirm_text).to eq("Are you sure that you want to delete the recurring action '#{pattern_name}'?")
page.should_not have_css("#delete_icon_#{pattern.id}") expect(page).to_not have_css("#delete_icon_#{pattern.id}")
end end
When /^I mark the pattern "([^"]*)" as (complete|active)$/ do |pattern_name, state| When /^I mark the pattern "([^"]*)" as (complete|active)$/ do |pattern_name, state|
pattern = @current_user.recurring_todos.where(:description => pattern_name).first pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil expect(pattern).to_not be_nil
pattern.completed?.should(state=="complete" ? be_false : be_true) expect(pattern.completed?).to (state=="complete" ? be_false : be_true)
page.find("#check_#{pattern.id}").click page.find("#check_#{pattern.id}").click
wait_for_ajax wait_for_ajax
wait_for_animations_to_end wait_for_animations_to_end
@ -79,7 +79,7 @@ end
When /^I follow the recurring todo link of "([^"]*)"$/ do |action_description| When /^I follow the recurring todo link of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
page.find(:xpath, "//div[@id='todo_#{todo.id}']//a[@class='recurring_icon']/img").click page.find(:xpath, "//div[@id='todo_#{todo.id}']//a[@class='recurring_icon']/img").click
sleep 1 # wait for page to load sleep 1 # wait for page to load
@ -89,21 +89,21 @@ Then /^the state list "([^"]*)" should be empty$/ do |state|
empty_id = "recurring-todos-empty-nd" if state.downcase == "active" empty_id = "recurring-todos-empty-nd" if state.downcase == "active"
empty_id = "completed-empty-nd" if state.downcase == "completed" empty_id = "completed-empty-nd" if state.downcase == "completed"
empty_msg = page.find("div##{empty_id}") empty_msg = page.find("div##{empty_id}")
empty_msg.visible?.should be_true expect(empty_msg.visible?).to be_true
end end
Then /^the pattern "([^\"]*)" should be starred$/ do |pattern_name| Then /^the pattern "([^\"]*)" should be starred$/ do |pattern_name|
pattern = @current_user.recurring_todos.where(:description => pattern_name).first pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil expect(pattern).to_not be_nil
page.should have_xpath("//div[@id='recurring_todo_#{pattern.id}']//img[@class='todo_star starred']") expect(page).to have_xpath("//div[@id='recurring_todo_#{pattern.id}']//img[@class='todo_star starred']")
end end
Then /^I should see the form for "([^\"]*)" recurrence pattern$/ do |recurrence_period| Then /^I should see the form for "([^\"]*)" recurrence pattern$/ do |recurrence_period|
page.should have_css("#recurring_#{recurrence_period.downcase}", :visible => true) expect(page).to have_css("#recurring_#{recurrence_period.downcase}", :visible => true)
end end
Then /^the pattern "([^"]*)" should be in the state list "([^"]*)"$/ do |pattern_name, state_name| Then /^the pattern "([^"]*)" should be in the state list "([^"]*)"$/ do |pattern_name, state_name|
pattern = @current_user.recurring_todos.where(:description => pattern_name).first pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil expect(pattern).to_not be_nil
page.should have_xpath("//div[@id='#{state_name}_recurring_todos_container']//div[@id='recurring_todo_#{pattern.id}']") expect(page).to have_xpath("//div[@id='#{state_name}_recurring_todos_container']//div[@id='recurring_todo_#{pattern.id}']")
end end

View file

@ -1,15 +1,15 @@
Then /^the single action form should be visible$/ do Then /^the single action form should be visible$/ do
page.should have_css("#todo_new_action", :visible => true) expect(page).to have_css("#todo_new_action", :visible => true)
end end
Then /^the single action form should not be visible$/ do Then /^the single action form should not be visible$/ do
page.should_not have_css("#todo_new_action", :visible=>true) expect(page).to_not have_css("#todo_new_action", :visible=>true)
end end
Then /^the multiple action form should be visible$/ do Then /^the multiple action form should be visible$/ do
page.should have_css("#todo_multi_add", :visible => true) expect(page).to have_css("#todo_multi_add", :visible => true)
end end
Then /^the multiple action form should not be visible$/ do Then /^the multiple action form should not be visible$/ do
page.should_not have_css("#todo_multi_add", :visible=>true) expect(page).to_not have_css("#todo_multi_add", :visible=>true)
end end

View file

@ -4,7 +4,7 @@ When /^I click on the chart for actions done in the last 12 months$/ do
end end
Then /^I should see a chart$/ do Then /^I should see a chart$/ do
page.should have_css("div.open-flash-chart") expect(page).to have_css("div.open-flash-chart")
end end
When /^I click on the chart for running time of all incomplete actions$/ do When /^I click on the chart for running time of all incomplete actions$/ do

View file

@ -17,7 +17,7 @@ Given(/^I have a todo "([^"]*)" in the context "([^"]*)" in the project "([^"]*)
step "I have a todo \"#{description}\" in the context \"#{context_name}\"" step "I have a todo \"#{description}\" in the context \"#{context_name}\""
@project = @current_user.projects.where(:name => project_name).first_or_create @project = @current_user.projects.where(:name => project_name).first_or_create
@project.should_not be_nil expect(@project).to_not be_nil
@todo.project = @project @todo.project = @project
@todo.save! @todo.save!
@ -189,7 +189,7 @@ end
Given /^I have a project "([^"]*)" that has the following (todos|deferred todos)$/ do |project_name, kind_of_todo, todos| Given /^I have a project "([^"]*)" that has the following (todos|deferred todos)$/ do |project_name, kind_of_todo, todos|
step "I have a project called \"#{project_name}\"" step "I have a project called \"#{project_name}\""
@project.should_not be_nil expect(@project).to_not be_nil
todos.hashes.each do |todo| todos.hashes.each do |todo|
new_todo = @current_user.todos.create!( new_todo = @current_user.todos.create!(
@ -242,7 +242,7 @@ When /^I submit a new action with description "([^"]*)" with a dependency on "([
click_first_line_of_auto_complete click_first_line_of_auto_complete
new_dependency_line = "//li[@id='pred_#{predecessor.id}']" new_dependency_line = "//li[@id='pred_#{predecessor.id}']"
page.should have_xpath(new_dependency_line, :visible => true) expect(page).to have_xpath(new_dependency_line, :visible => true)
submit_next_action_form submit_next_action_form
end end

View file

@ -2,7 +2,7 @@
When /^I mark "([^"]*)" as complete$/ do |action_description| When /^I mark "([^"]*)" as complete$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
check "mark_complete_#{todo.id}" check "mark_complete_#{todo.id}"
@ -12,7 +12,7 @@ end
When /^I mark "([^"]*)" as uncompleted$/ do |action_description| When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
uncheck "mark_complete_#{todo.id}" uncheck "mark_complete_#{todo.id}"
@ -30,12 +30,12 @@ end
When /^I star the action "([^"]*)"$/ do |action_description| When /^I star the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']" xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']" xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
page.should have_xpath(xpath_unstarred) expect(page).to have_xpath(xpath_unstarred)
star_img = "//img[@id='star_img_#{todo.id}']" star_img = "//img[@id='star_img_#{todo.id}']"
page.find(:xpath, star_img).click page.find(:xpath, star_img).click
@ -43,22 +43,22 @@ When /^I star the action "([^"]*)"$/ do |action_description|
wait_for_ajax wait_for_ajax
wait_for_animations_to_end wait_for_animations_to_end
page.should have_xpath(xpath_starred) expect(page).to have_xpath(xpath_starred)
end end
When /^I unstar the action "([^"]*)"$/ do |action_description| When /^I unstar the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']" xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']" xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
page.should have_xpath(xpath_starred) expect(page).to have_xpath(xpath_starred)
star_img = "//img[@id='star_img_#{todo.id}']" star_img = "//img[@id='star_img_#{todo.id}']"
page.find(:xpath, star_img).click page.find(:xpath, star_img).click
page.should have_xpath(xpath_unstarred) expect(page).to have_xpath(xpath_unstarred)
end end
####### Editing a todo using Edit Form ####### ####### Editing a todo using Edit Form #######
@ -87,7 +87,7 @@ end
When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description| When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
within "form.edit_todo_form" do within "form.edit_todo_form" do
@ -98,7 +98,7 @@ end
When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description| When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
within "form.edit_todo_form" do within "form.edit_todo_form" do
@ -112,7 +112,7 @@ end
When /^I edit the due date of "([^"]*)" to "([^"]*)"$/ do |action_description, date| When /^I edit the due date of "([^"]*)" to "([^"]*)"$/ do |action_description, date|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
fill_in "due_todo_#{todo.id}", :with => date fill_in "due_todo_#{todo.id}", :with => date
@ -131,7 +131,7 @@ end
When /^I clear the due date of "([^"]*)"$/ do |action_description| When /^I clear the due date of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
# use all()[0] to get the first todo. This is for calendar page where you can have # use all()[0] to get the first todo. This is for calendar page where you can have
@ -147,7 +147,7 @@ end
When /^I edit the show from date of "([^"]*)" to next month$/ do |action_description| When /^I edit the show from date of "([^"]*)" to next month$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
fill_in "show_from_todo_#{todo.id}", :with => format_date(todo.created_at + 1.month) fill_in "show_from_todo_#{todo.id}", :with => format_date(todo.created_at + 1.month)
@ -156,7 +156,7 @@ end
When /^I remove the show from date from "([^"]*)"$/ do |action_description| When /^I remove the show from date from "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
page.find(:xpath, "//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img").click page.find(:xpath, "//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img").click
@ -169,7 +169,7 @@ end
When /^I defer "([^"]*)" for 1 day$/ do |action_description| When /^I defer "([^"]*)" for 1 day$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_submenu_for(todo) do open_submenu_for(todo) do
click_link "defer_1_todo_#{todo.id}" click_link "defer_1_todo_#{todo.id}"
@ -181,7 +181,7 @@ end
When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags| When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
within "form#form_todo_#{todo.id}" do within "form#form_todo_#{todo.id}" do
@ -192,13 +192,13 @@ end
When /^I make a project of "([^"]*)"$/ do |action_description| When /^I make a project of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
open_submenu_for(todo) do open_submenu_for(todo) do
click_link "to_project_todo_#{todo.id}" click_link "to_project_todo_#{todo.id}"
end end
page.should have_no_css("div#line_todo_#{todo.id}") expect(page).to have_no_css("div#line_todo_#{todo.id}")
wait_for_ajax wait_for_ajax
wait_for_animations_to_end wait_for_animations_to_end
end end
@ -207,5 +207,5 @@ end
Then /^I should see an error message$/ do Then /^I should see an error message$/ do
error_block = "//form/div[@id='edit_error_status']" error_block = "//form/div[@id='edit_error_status']"
page.should have_xpath(error_block) expect(page).to have_xpath(error_block)
end end

View file

@ -12,7 +12,7 @@ When /^I delete the action "([^"]*)"$/ do |action_description|
click_link "delete_todo_#{todo.id}" click_link "delete_todo_#{todo.id}"
end end
end end
get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?" expect(get_confirm_text).to eq("Are you sure that you want to delete the action '#{todo.description}'?")
wait_for_ajax wait_for_ajax
end end
@ -25,130 +25,130 @@ end
When /^I open the notes of "([^"]*)"$/ do |action_description| When /^I open the notes of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
page.find(:xpath, "//div[@id='line_todo_#{todo.id}']/div/a/img").click page.find(:xpath, "//div[@id='line_todo_#{todo.id}']/div/a/img").click
page.should have_xpath("//div[@id='notes_todo_#{todo.id}']", :visible=>true) expect(page).to have_xpath("//div[@id='notes_todo_#{todo.id}']", :visible=>true)
end end
####### THEN ####### ####### THEN #######
Then /^I should see a starred "([^"]*)"$/ do |action_description| Then /^I should see a starred "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']" xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
page.should have_xpath(xpath_starred) expect(page).to have_xpath(xpath_starred)
end end
Then /^I should see an unstarred "([^"]*)"$/ do |action_description| Then /^I should see an unstarred "([^"]*)"$/ do |action_description|
todo = @current_user.todos.where(:description => action_description).first todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil expect(todo).to_not be_nil
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']" xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
page.should have_xpath(xpath_starred) expect(page).to have_xpath(xpath_starred)
end end
Then /^I should see ([0-9]+) todos$/ do |count| Then /^I should see ([0-9]+) todos$/ do |count|
total = page.all("div.item-container").inject(0) { |s, e| s+=1 } total = page.all("div.item-container").inject(0) { |s, e| s+=1 }
total.should == count.to_i expect(total).to eq(count.to_i)
end end
Then /^I should see the todo "([^\"]*)"$/ do |todo_description| Then /^I should see the todo "([^\"]*)"$/ do |todo_description|
page.should have_xpath("//span[.=\"#{todo_description}\"]", :visible => true) expect(page).to have_xpath("//span[.=\"#{todo_description}\"]", :visible => true)
end end
Then /^I should not see the todo "([^\"]*)"$/ do |todo_description| Then /^I should not see the todo "([^\"]*)"$/ do |todo_description|
page.should_not have_xpath("//span[.=\"#{todo_description}\"]", :visible => true) expect(page).to_not have_xpath("//span[.=\"#{todo_description}\"]", :visible => true)
end end
Then /^I should see a completed todo "([^"]*)"$/ do |todo_description| Then /^I should see a completed todo "([^"]*)"$/ do |todo_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
# only completed todos have a grey span with the completed_at date # only completed todos have a grey span with the completed_at date
xpath = "//div[@id='line_todo_#{todo.id}']/div/span[@class='grey']" xpath = "//div[@id='line_todo_#{todo.id}']/div/span[@class='grey']"
page.should have_xpath(xpath, :visible=>true) expect(page).to have_xpath(xpath, :visible=>true)
end end
Then /^I should see an active todo "([^"]*)"$/ do |todo_description| Then /^I should see an active todo "([^"]*)"$/ do |todo_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
xpath = "//div[@id='line_todo_#{todo.id}']/img[@class='grip']" xpath = "//div[@id='line_todo_#{todo.id}']/img[@class='grip']"
page.should have_xpath(xpath, :visible=>true) expect(page).to have_xpath(xpath, :visible=>true)
end end
Then /^the number of actions should be (\d+)$/ do |count| Then /^the number of actions should be (\d+)$/ do |count|
@current_user.todos.count.should == count.to_i expect(@current_user.todos.count).to eq(count.to_i)
end end
Then /^a confirmation for adding a new context "([^"]*)" should be asked$/ do |context_name| Then /^a confirmation for adding a new context "([^"]*)" should be asked$/ do |context_name|
get_confirm_text.should == "New context '#{context_name}' will be also created. Are you sure?" expect(get_confirm_text).to eq("New context '#{context_name}' will be also created. Are you sure?")
end end
Then /^the selected project should be "([^"]*)"$/ do |content| Then /^the selected project should be "([^"]*)"$/ do |content|
# Works for mobile. TODO: make it work for both mobile and non-mobile # Works for mobile. TODO: make it work for both mobile and non-mobile
if content.blank? if content.blank?
page.has_css?("select#todo_project_id option[selected='selected']").should be_false expect(page.has_css?("select#todo_project_id option[selected='selected']")).to be_false
else else
page.find("select#todo_project_id option[selected='selected']").text.should =~ /#{content}/ expect(page.find("select#todo_project_id option[selected='selected']").text).to match(/#{content}/)
end end
end end
Then /^the selected context should be "([^"]*)"$/ do |content| Then /^the selected context should be "([^"]*)"$/ do |content|
# Works for mobile. TODO: make it work for both mobile and non-mobile # Works for mobile. TODO: make it work for both mobile and non-mobile
if content.blank? if content.blank?
page.has_css?("select#todo_context_id option[selected='selected']").should be_false expect(page.has_css?("select#todo_context_id option[selected='selected']")).to be_false
else else
page.find("select#todo_context_id option[selected='selected']").text.should =~ /#{content}/ expect(page.find("select#todo_context_id option[selected='selected']").text).to match(/#{content}/)
end end
end end
Then /^I should see the page selector$/ do Then /^I should see the page selector$/ do
page.should have_xpath(".//a[@class='next_page']") expect(page).to have_xpath(".//a[@class='next_page']")
end end
Then /^the page should be "([^"]*)"$/ do |page_number| Then /^the page should be "([^"]*)"$/ do |page_number|
page.find(:xpath, ".//div[@class='paginate_header']//em[@class='current']").text.should == page_number expect(page.find(:xpath, ".//div[@class='paginate_header']//em[@class='current']").text).to eq(page_number)
end end
Then /^the project field of the new todo form should contain "([^"]*)"$/ do |project_name| Then /^the project field of the new todo form should contain "([^"]*)"$/ do |project_name|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_project_name']" xpath= "//form[@id='todo-form-new-action']/input[@id='todo_project_name']"
project_name.should == page.find(:xpath, xpath).value expect(project_name).to eq(page.find(:xpath, xpath).value)
end end
Then /^the default context of the new todo form should be "([^"]*)"$/ do |context_name| Then /^the default context of the new todo form should be "([^"]*)"$/ do |context_name|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_context_name']" xpath= "//form[@id='todo-form-new-action']/input[@id='todo_context_name']"
context_name.should == page.find(:xpath, xpath).value expect(context_name).to eq(page.find(:xpath, xpath).value)
end end
Then /^the tag field in the new todo form should be empty$/ do Then /^the tag field in the new todo form should be empty$/ do
xpath= "//form[@id='todo-form-new-action']/input[@id='tag_list']" xpath= "//form[@id='todo-form-new-action']/input[@id='tag_list']"
page.find(:xpath, xpath).value.blank?.should be_true expect(page.find(:xpath, xpath).value).to be_blank
end end
Then /^the tag field in the new todo form should be "([^"]*)"$/ do |tag_list| Then /^the tag field in the new todo form should be "([^"]*)"$/ do |tag_list|
xpath= "//form[@id='todo-form-new-action']/input[@id='tag_list']" xpath= "//form[@id='todo-form-new-action']/input[@id='tag_list']"
tag_list.should == page.find(:xpath, xpath).value expect(tag_list).to eq(page.find(:xpath, xpath).value)
end end
Then /^the tags of "([^"]*)" should be "([^"]*)"$/ do |todo_description, tag_list| Then /^the tags of "([^"]*)" should be "([^"]*)"$/ do |todo_description, tag_list|
find_todo(todo_description).tag_list.should == tag_list expect(find_todo(todo_description).tag_list).to eq(tag_list)
end end
Then /^I should see "([^"]*)" in the completed section of the mobile site$/ do |desc| Then /^I should see "([^"]*)" in the completed section of the mobile site$/ do |desc|
todo = @current_user.todos.where(:description => desc).first todo = @current_user.todos.where(:description => desc).first
todo.should_not be_nil expect(todo).to_not be_nil
xpath = "//div[@id='completed_container']//a[@href='/todos/#{todo.id}.m']" xpath = "//div[@id='completed_container']//a[@href='/todos/#{todo.id}.m']"
page.should have_xpath(xpath) expect(page).to have_xpath(xpath)
end end
Then /^I should (see|not see) the notes of "([^"]*)"$/ do |visible, todo_description| Then /^I should (see|not see) the notes of "([^"]*)"$/ do |visible, todo_description|
todo = @current_user.todos.where(:description => todo_description).first todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil expect(todo).to_not be_nil
page.find("div#notes_todo_#{todo.id}").send(visible=="see" ? "should" : "should_not", be_visible) page.find("div#notes_todo_#{todo.id}").send(visible=="see" ? "should" : "should_not", be_visible)
end end

View file

@ -19,13 +19,13 @@ Given /^the following user records with hash algorithm$/ do |table|
when 'bcrypt' when 'bcrypt'
user.change_password( password, password ) user.change_password( password, password )
user.reload user.reload
BCrypt::Password.new(user.crypted_password).should == password expect(BCrypt::Password.new(user.crypted_password)).to eq(password)
when 'sha1' when 'sha1'
user.password = user.password_confirmation = nil user.password = user.password_confirmation = nil
user.send(:write_attribute, :crypted_password, user.sha1(password)) user.send(:write_attribute, :crypted_password, user.sha1(password))
user.save user.save
user.reload user.reload
user.crypted_password.should == user.sha1(password) expect(user.crypted_password).to eq(user.sha1(password))
else else
raise "Unknown hashing algorithm: #{algorithm}" raise "Unknown hashing algorithm: #{algorithm}"
end end
@ -49,14 +49,14 @@ When /^I delete the user "([^\"]*)"$/ do |username|
# click "//tr[@id='user-3']//img" # click "//tr[@id='user-3']//img"
# assert_confirmation "Warning: this will delete user 'john', all their actions, contexts, project and notes. Are you sure that you want to continue?" # assert_confirmation "Warning: this will delete user 'john', all their actions, contexts, project and notes. Are you sure that you want to continue?"
user = User.where(:login => username).first user = User.where(:login => username).first
user.should_not be_nil expect(user).to_not be_nil
handle_js_confirm do handle_js_confirm do
page.find(:xpath, "//tr[@id='user-#{user.id}']//img").click page.find(:xpath, "//tr[@id='user-#{user.id}']//img").click
end end
get_confirm_text.should == "Warning: this will delete user '#{user.login}', all their actions, contexts, project and notes. Are you sure that you want to continue?" expect(get_confirm_text).to eq("Warning: this will delete user '#{user.login}', all their actions, contexts, project and notes. Are you sure that you want to continue?")
page.should_not have_css("tr#user-#{user.id}") expect(page).to_not have_css("tr#user-#{user.id}")
end end
Then /^I should see that a user named "([^\"]*)" is not present$/ do |username| Then /^I should see that a user named "([^\"]*)" is not present$/ do |username|

View file

@ -101,48 +101,32 @@ Then /^(?:|I )should see JSON:$/ do |expected_json|
require 'json' require 'json'
expected = JSON.pretty_generate(JSON.parse(expected_json)) expected = JSON.pretty_generate(JSON.parse(expected_json))
actual = JSON.pretty_generate(JSON.parse(response.body)) actual = JSON.pretty_generate(JSON.parse(response.body))
expected.should == actual expect(expected).to eq(actual)
end end
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector| Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
with_scope(selector) do with_scope(selector) do
if page.respond_to? :should expect(page).to have_content(text)
page.should have_content(text)
else
assert page.has_content?(text)
end
end end
end end
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector| Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
regexp = Regexp.new(regexp) regexp = Regexp.new(regexp)
with_scope(selector) do with_scope(selector) do
if page.respond_to? :should expect(page).to have_xpath('//*', :text => regexp)
page.should have_xpath('//*', :text => regexp)
else
assert page.has_xpath?('//*', :text => regexp)
end
end end
end end
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector| Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
with_scope(selector) do with_scope(selector) do
if page.respond_to? :should expect(page).to have_no_content(text)
page.should have_no_content(text)
else
assert page.has_no_content?(text)
end
end end
end end
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector| Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
regexp = Regexp.new(regexp) regexp = Regexp.new(regexp)
with_scope(selector) do with_scope(selector) do
if page.respond_to? :should expect(page).to have_no_xpath('//*', :text => regexp)
page.should have_no_xpath('//*', :text => regexp)
else
assert page.has_no_xpath?('//*', :text => regexp)
end
end end
end end
@ -150,11 +134,7 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |
with_scope(selector) do with_scope(selector) do
field = find_field(field) field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should expect(field_value).to match(/#{value}/)
field_value.should =~ /#{value}/
else
assert_match(/#{value}/, field_value)
end
end end
end end
@ -162,43 +142,27 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/
with_scope(selector) do with_scope(selector) do
field = find_field(field) field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should_not expect(field_value).to_not match(/#{value}/)
field_value.should_not =~ /#{value}/
else
assert_no_match(/#{value}/, field_value)
end
end end
end end
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector| Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
with_scope(selector) do with_scope(selector) do
field_checked = find_field(label)['checked'] field_checked = find_field(label)['checked']
if field_checked.respond_to? :should expect(field_checked).to be_true
field_checked.should be_true
else
assert field_checked
end
end end
end end
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector| Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
with_scope(selector) do with_scope(selector) do
field_checked = find_field(label)['checked'] field_checked = find_field(label)['checked']
if field_checked.respond_to? :should expect(field_checked).to be_false
field_checked.should be_false
else
assert !field_checked
end
end end
end end
Then /^(?:|I )should be on (.+)$/ do |page_name| Then /^(?:|I )should be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path current_path = URI.parse(current_url).path
if current_path.respond_to? :should expect(current_path).to eq(path_to(page_name))
current_path.should == path_to(page_name)
else
assert_equal path_to(page_name), current_path
end
end end
Then /^(?:|I )should have the following query string:$/ do |expected_pairs| Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
@ -207,11 +171,7 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
expected_params = {} expected_params = {}
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')} expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
if actual_params.respond_to? :should expect(actual_params).to eq(expected_params)
actual_params.should == expected_params
else
assert_equal expected_params, actual_params
end
end end
Then /^show me the page$/ do Then /^show me the page$/ do

View file

@ -4,7 +4,7 @@ module TracksFormHelper
edit_link = "div#line_todo_#{todo.id} a#icon_edit_todo_#{todo.id}" edit_link = "div#line_todo_#{todo.id} a#icon_edit_todo_#{todo.id}"
# make sure we can open the edit form # make sure we can open the edit form
page.should have_css(edit_link) expect(page).to have_css(edit_link)
# on calendar page there can be more than 1 occurance of a todo, so we select the first here # on calendar page there can be more than 1 occurance of a todo, so we select the first here
all(:css, edit_link)[0].click all(:css, edit_link)[0].click
@ -17,7 +17,7 @@ module TracksFormHelper
page.find("a#link_edit_context_#{context.id}").click page.find("a#link_edit_context_#{context.id}").click
# wait for the form to appear (which included a submit button) # wait for the form to appear (which included a submit button)
page.should have_css("button#submit_context_#{context.id}", :visible=>true) expect(page).to have_css("button#submit_context_#{context.id}", :visible=>true)
end end
def submit_form(form_xpath, button_name) def submit_form(form_xpath, button_name)
@ -53,23 +53,23 @@ module TracksFormHelper
end end
def wait_for_todo_form_to_go_away(todo) def wait_for_todo_form_to_go_away(todo)
page.should_not have_content("button#submit_todo_#{todo.id}") expect(page).to_not have_content("button#submit_todo_#{todo.id}")
end end
def wait_for_context_form_to_appear(context) def wait_for_context_form_to_appear(context)
page.should have_css("button#submit_context_#{context.id}", :visible=>true) expect(page).to have_css("button#submit_context_#{context.id}", :visible=>true)
end end
def wait_for_context_form_to_go_away(context) def wait_for_context_form_to_go_away(context)
# wait for the form to go away # wait for the form to go away
page.should_not have_css("button#submit_context_#{context.id}", :visible => true) expect(page).to_not have_css("button#submit_context_#{context.id}", :visible => true)
# wait for the changed context to appear # wait for the changed context to appear
page.should have_css("a#link_edit_context_#{context.id}", :visible=> true) expect(page).to have_css("a#link_edit_context_#{context.id}", :visible=> true)
end end
def open_project_edit_form(project) def open_project_edit_form(project)
click_link "link_edit_project_#{project.id}" click_link "link_edit_project_#{project.id}"
page.should have_css("button#submit_project_#{project.id}") expect(page).to have_css("button#submit_project_#{project.id}")
end end
def submit_project_edit_form(project) def submit_project_edit_form(project)
@ -92,7 +92,7 @@ module TracksFormHelper
wait_for_ajax wait_for_ajax
wait_for_animations_to_end wait_for_animations_to_end
page.should_not have_css("button#submit_project_#{project.id}", :visible => true) expect(page).to_not have_css("button#submit_project_#{project.id}", :visible => true)
end end
def edit_project_settings(project) def edit_project_settings(project)

View file

@ -29,14 +29,14 @@ module TracksStepHelper
def wait_for_ajax def wait_for_ajax
start_time = Time.now start_time = Time.now
page.evaluate_script('jQuery.isReady&&jQuery.active==0').class.should_not eql(String) expect(page.evaluate_script('jQuery.isReady&&jQuery.active==0').class).to_not eql(String)
until(page.evaluate_script('jQuery.isReady&&jQuery.active==0') || (start_time + 5.seconds) < Time.now) until(page.evaluate_script('jQuery.isReady&&jQuery.active==0') || (start_time + 5.seconds) < Time.now)
sleep 0.05 sleep 0.05
end end
end end
def wait_for_auto_complete def wait_for_auto_complete
page.should have_css("a.ui-state-focus", :visible => true) expect(page).to have_css("a.ui-state-focus", :visible => true)
end end
def click_first_line_of_auto_complete def click_first_line_of_auto_complete
@ -57,19 +57,19 @@ module TracksStepHelper
def find_todo(description) def find_todo(description)
todo = @current_user.todos.where(:description => description).first todo = @current_user.todos.where(:description => description).first
todo.should_not be_nil expect(todo).to_not be_nil
return todo return todo
end end
def find_context(context_name) def find_context(context_name)
context = @current_user.contexts.where(:name => context_name).first context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil expect(context).to_not be_nil
return context return context
end end
def find_project(project_name) def find_project(project_name)
project = @current_user.projects.where(:name => project_name).first project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil expect(project).to_not be_nil
return project return project
end end
@ -102,12 +102,12 @@ module TracksStepHelper
# click menu # click menu
view_menu_link = "#{view_menu} a#menu_view_link" view_menu_link = "#{view_menu} a#menu_view_link"
page.should have_css(view_menu_link, :visible => true) expect(page).to have_css(view_menu_link, :visible => true)
page.find(view_menu_link).click page.find(view_menu_link).click
# wait for menu to be visible # wait for menu to be visible
view_menu_item = "#{view_menu} li#menu_view_toggle_contexts" view_menu_item = "#{view_menu} li#menu_view_toggle_contexts"
page.should have_css(view_menu_item) expect(page).to have_css(view_menu_item)
within view_menu do within view_menu do
yield yield
@ -118,7 +118,7 @@ module TracksStepHelper
wait_for_animations_to_end wait_for_animations_to_end
submenu_arrow = "div#line_todo_#{todo.id} img.todo-submenu" submenu_arrow = "div#line_todo_#{todo.id} img.todo-submenu"
page.should have_css(submenu_arrow, :visible=>true) expect(page).to have_css(submenu_arrow, :visible=>true)
arrow = page.find(submenu_arrow, :match => :first) arrow = page.find(submenu_arrow, :match => :first)
arrow.click arrow.click
@ -148,4 +148,4 @@ module TracksStepHelper
page.execute_script(js) page.execute_script(js)
end end
end end