Skip to content

Instantly share code, notes, and snippets.

View zealoushacker's full-sized avatar

Alex Notov zealoushacker

View GitHub Profile
Then table "business_services" should have the values:
| row | col | value |
| 1 | 1 | Unlimited Class Card |
| 1 | 2 | ul |
| 1 | 3 | $100.00 |
@zealoushacker
zealoushacker / table_values_matcher.rb
Created July 13, 2011 17:14
Table values matcher
Then /^table "([^"]*)" should have the values:$/ do |table_id, table|
table.hashes.each do |row|
Then %{row #{row[:row]} column #{row[:col]} of table "#{table_id}" should be "#{row[:value]}"}
end
end
@zealoushacker
zealoushacker / row_col_val_matcher.rb
Created July 13, 2011 17:13
Row+column/value matcher
Then /^row (\d+) column (\d+) of table "([^"]*)" should be "([^"]*)"$/ do |row,column,table_id,value|
locator = "css=table##{table_id} tbody tr:nth-of-type(#{row}) td:nth-of-type(#{column})"
selenium.get_text(locator).should == value
end
Then /^student (\d+|\d+..\d+) should have (\d+) less credits$/ do |student_num, num_credits|
if student_num =~ /\d+..\d+/
student_num.to_range.each do |s_id|
tr_locator = "table#customer_users tbody tr:nth-of-type(#{s_id})"
selenium.get_text("css=#{tr_locator} td:nth-of-type(4)").should == (@cu.credits_active - num_credits.to_i).to_s
selenium.get_text("css=#{tr_locator} td:nth-of-type(5)").should == (@cu.attended + 1).to_s
end
else
@zealoushacker
zealoushacker / take_attendance.feature
Created July 13, 2011 17:08
Taking attendance scenario
@multiple_students @selenium
Scenario: Taking attendance for multiple students with default settings
When I select 3 students
And I press "Take Attendance"
Then students 1..3 should have 1 less credits
And I should see "3 classes recorded"
@zealoushacker
zealoushacker / gist:1016312
Created June 9, 2011 08:20 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end