Skip to content

Commit

Permalink
Fix matchers for workspaces and common steps
Browse files Browse the repository at this point in the history
  • Loading branch information
relaxdiego committed Mar 25, 2012
1 parent acfa2c3 commit 606e336
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions features/step_definitions/_common_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#==========================
# THENs
#==========================
Then /^(?:he|she) will be redirected to (.+)$/ do |page_alias|
Then /^(?:he|she) will be redirected to (?:the|his) (.+) page$/ do |page_alias|
current_path.should == if page_alias == 'home' || page_alias =~ /(?:his|her|the) home page/
root_path
elsif page_alias == 'login' || page_alias =~ /the (?:login|log in|log-in) page/
elsif page_alias =~ /(?:login|log in|log-in)/
new_user_session_path
else
eval ("#{page_alias}_path")
Expand Down
37 changes: 37 additions & 0 deletions features/step_definitions/workspaces_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@
@user.add_to_owned_workspaces(@workspace)
end

Given /^The following workspaces exist in the system:$/ do |table|
workspaces = table.hashes

workspaces.each do |attrs|
Factory.create(:workspace, :name => attrs['Name'])
end
end

Given /^(?:[Hh]e|[Ss]he) is a member of the following workspaces$/ do |table|
workspaces = table.hashes

workspaces.each do |attrs|
workspace = Workspace.find_by_name(attrs['Name'])
workspace.add_member(@user)
end
end

#==========================
# WHENs
#==========================
Expand All @@ -34,6 +51,10 @@
end
end

When /^(?:[Hh]e|[Ss]he) visits the workspaces page$/ do
visit workspaces_path
end

#==========================
# THENs
#==========================
Expand All @@ -52,3 +73,19 @@
@workspace[key].should == @old_workspace_attr_values[key]
end
end

Then /^(?:[Hh]e|[Ss]he) should see the following workspaces$/ do |table|
workspaces = table.hashes
@visible_workspace_names = workspaces.map{ |w| w['Name'] }
@visible_workspace_names.each do |name|
page.should have_content(name)
end
end

Then /^(?:[Hh]e|[Ss]he) should not see the other workspaces$/ do
excluded_workspaces = Workspace.find(:all)
excluded_workspaces.each do |workspace|
next if @visible_workspace_names.include?(workspace[:name])
page.should have_no_content(workspace[:name])
end
end

0 comments on commit 606e336

Please sign in to comment.