-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19185aa
commit 83136c5
Showing
7 changed files
with
80 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This step uses our Role Based Access Control (RBAC) | ||
# which can have multiple roles, each identified by | ||
# an "external id" (id) that is typically one word | ||
# like "administrator", "manager", "assistant", etc. | ||
# | ||
# Example: | ||
# Given my role is an Administrator | ||
# => @user.rbac_roles=[Factory(:rbac_role, :xid => 'administrator") | ||
|
||
Given /my role is (?:|an? )(\w+)/i do |rbac_role_xid| | ||
@user.rbac_roles=[Factory(:rbac_role, :xid => rbac_role_xid.downcase)] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# A Cucumber step to generate any number of objects, for any model, typically using factory girl | ||
# http://cassiomarques.wordpress.com/2009/04/16/a-cucumber-step-to-generate-any-number-of-objects-for-any-model/ | ||
Given /^there are (\d+) (.+)$/ do |n, model_str| | ||
model_str = model_str.gsub(/\s/, '_').singularize | ||
model_sym = model_str.to_sym | ||
klass = eval(model_str.camelize) | ||
klass.transaction do | ||
klass.destroy_all | ||
n.to_i.times do |i| | ||
Factory(model_sym) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Given /I am a user/ do | ||
@user= Factory(:user) | ||
end | ||
|
||
def current_user | ||
@user | ||
end |
30 changes: 0 additions & 30 deletions
30
step_definitions/user_steps.rb → step_definitions/misc_steps.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Then /^(?:|I )should see button "([^"]*)"(?: within "([^"]*)")?$/ do |button_name, selector| | ||
with_scope(selector) do | ||
find_button(button_name)!=nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/env ruby | ||
# | ||
# Cucumber step to say "Then I should see my ..." | ||
# | ||
# The "my" is the user returned by the #current_user method. | ||
# | ||
# The "..." can be any user method name written in plain English. | ||
# The method name is converted to a method symbol in three steps: | ||
# - delete periods | ||
# - change non-alphanumerics to underscores | ||
# - downcase | ||
# | ||
# The leading "I" and trailing "." are optional as usual. | ||
# | ||
# Examples: | ||
# Then I should see my name | ||
# => Then I should see current_user.name | ||
# | ||
# should see my U.S. postal address. | ||
# => Then I should see current_user.us_postal_address | ||
|
||
Then /^(?:|I )should see my (.+)\.?$/ do |target| | ||
case target | ||
user = @user || current_user | ||
method_sym = target.gsub(/\./,'').gsub(/\W+/,'_').downcase.to_sym | ||
if user.methods.include?(method_sym) | ||
target_text = current_user.send(method_sym) | ||
Then "I should see \"#{target_text}\"" | ||
default | ||
raise "The current user does not have a target \"#{target}\" method \"#{method_sym}\"" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Cucumber support for Factory Girl by ThoughtBot | ||
require "factory_girl" | ||
|
||
# Require Factory Girl's included step definitions; | ||
# these enable creating many factories easily. | ||
require "factory_girl/step_definitions" | ||
|
||
# Require our factories, which we put in the /factories directory | ||
Dir.glob(File.join(Rails.root, 'factories', '*.rb')).each {|f| require f } | ||
|