Class: AssignmentObject
- Inherits:
-
Object
- Object
- AssignmentObject
- Includes:
- PageHelper, Utilities, Workflows
- Defined in:
- lib/sakai-cle-test-api/data_objects/assignment.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#link ⇒ Object
Returns the value of attribute link.
-
#site ⇒ Object
Returns the value of attribute site.
-
#status ⇒ Object
Returns the value of attribute status.
-
#title ⇒ Object
(also: #name)
Returns the value of attribute title.
Instance Method Summary collapse
- #create ⇒ Object
- #edit(opts = {}) ⇒ Object
- #get_assignment_info ⇒ Object
-
#initialize(browser, opts = {}) ⇒ AssignmentObject
constructor
A new instance of AssignmentObject.
Methods included from Workflows
menu_link, #open_my_site_by_name
Methods included from Utilities
#current_hour, #current_month, #current_year, #get_filename, #in_15_minutes, #last_hour, #last_month, #last_year, #make, #make_date, #next_hour, #next_month, #next_year, #on_page, #random_alphanums, #random_alphanums_plus, #random_email, #random_high_ascii, #random_letters, #random_multiline, #random_nicelink, #random_string, #random_xss_string, #tomorrow, #yesterday
Methods included from PageHelper
#make, #on, #visit, #wait_until
Constructor Details
#initialize(browser, opts = {}) ⇒ AssignmentObject
Returns a new instance of AssignmentObject.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 9 def initialize(browser, opts={}) @browser = browser defaults = { :title=>random_alphanums, :instructions=>random_multiline(250, 10, :string) } = defaults.merge(opts) @title=[:title] @instructions=[:instructions] @site=[:site] raise "You must specify a Site for your Assignment" if @site==nil end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 7 def id @id end |
#instructions ⇒ Object
Returns the value of attribute instructions.
7 8 9 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 7 def instructions @instructions end |
#link ⇒ Object
Returns the value of attribute link.
7 8 9 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 7 def link @link end |
#site ⇒ Object
Returns the value of attribute site.
7 8 9 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 7 def site @site end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 7 def status @status end |
#title ⇒ Object Also known as: name
Returns the value of attribute title.
7 8 9 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 7 def title @title end |
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 26 def create open_my_site_by_name @site unless @browser.title=~/#{@site}/ # Go to assignments page assignments unless @browser.title=~/Assignments$/ on_page AssignmentsList do |page| page.add end on_page AssignmentAdd do |add| add.title.set @title add.instructions=@instructions add.post end on_page AssignmentsList do |list| @id = list.get_assignment_id @title @link = list.assignment_href @title @status = list.status_of @title end end |
#edit(opts = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 47 def edit opts={} open_my_site_by_name @site unless @browser.title=~/#{@site}/ assignments unless @browser.title=~/Assignments$/ on AssignmentsList do |list| if @status=="Draft" list.edit_assignment "Draft - #{@title}" else list.edit_assignment @title end end on AssignmentAdd do |edit| edit.title.set opts[:title] unless opts[:title] == nil unless opts[:instructions] == nil edit.enter_source_text edit.editor, opts[:instructions] end edit.post end @title=opts[:title] unless opts[:title] == nil @instructions=opts[:instructions] unless opts[:instructions] == nil on AssignmentsList do |list| @status=list.status_of @title end end |
#get_assignment_info ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/sakai-cle-test-api/data_objects/assignment.rb', line 71 def get_assignment_info open_my_site_by_name @site unless @browser.title=~/#{@site}/ assignments unless @browser.title=~/Assignments$/ on AssignmentsList do |list| @id = list.get_assignment_id @title @status=list.status_of @title @link=list.assignment_href @title if @status=="Draft" list.open_assignment "Draft - #{@title}" else list.open_assignment @title end end on AssignmentAdd do |edit| # TODO: Need to add more stuff here as needed... @instructions=edit.get_source_text edit.editor end end |