-
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
Matt Gillooly
committed
Jan 2, 2014
1 parent
16e55fc
commit 4ad290f
Showing
3 changed files
with
49 additions
and
52 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
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,41 @@ | ||
require 'capybara/poltergeist' | ||
require 'ics_validator/api_response' | ||
|
||
module IcsValidator | ||
|
||
# Capybara session for interacting with icalvalid.cloudapp.net | ||
# | ||
class WebSession | ||
|
||
def initialize | ||
@session = Capybara::Session.new(:poltergeist) | ||
|
||
@session.driver.headers = { | ||
'User-Agent' => "Mozilla/5.0 (Macintosh; Intel Mac OS X)" | ||
} | ||
|
||
@session.visit('http://icalvalid.cloudapp.net/') | ||
end | ||
|
||
def validate_snippet(snippet) | ||
@session.fill_in('Content_tbSnippet', with: snippet) | ||
@session.click_button "Content_btnValidateSnippet" | ||
end | ||
|
||
def validate_file(path) | ||
@session.attach_file('Content_fileUpload', path) | ||
@session.click_button "Content_btnUpload" | ||
end | ||
|
||
def get_api_response | ||
response = nil | ||
|
||
Capybara.send(:timeout, 20, @session.driver) do | ||
response = ApiResponse.build(@session.html) | ||
end | ||
|
||
response | ||
end | ||
|
||
end | ||
end |