brynary / webrat
- Source
- Commits
- Network (270)
- Issues (31)
- Wiki (10)
- Graphs
-
Tree:
2c51d90
Kieran Pilkington (author)
Sat Dec 27 14:39:34 -0800 2008
| 31cc6b75 » | brynary | 2008-11-16 | 1 | module Webrat | |
| 2 | |||||
| 3 | # Configures Webrat. If this is not done, Webrat will be created | ||||
| 4 | # with all of the default settings. | ||||
| 5 | def self.configure(configuration = Webrat::Configuration.new) | ||||
| 6 | yield configuration if block_given? | ||||
| 7 | @@configuration = configuration | ||||
| 8 | end | ||||
| 9 | |||||
| f5ed57e0 » | brynary | 2008-11-30 | 10 | def self.configuration # :nodoc: | |
| 31cc6b75 » | brynary | 2008-11-16 | 11 | @@configuration ||= Webrat::Configuration.new | |
| 12 | end | ||||
| f5ed57e0 » | brynary | 2008-11-30 | 13 | ||
| 14 | # Webrat can be configured using the Webrat.configure method. For example: | ||||
| 15 | # | ||||
| 16 | # Webrat.configure do |config| | ||||
| 17 | # config.parse_with_nokogiri = false | ||||
| 18 | # end | ||||
| 31cc6b75 » | brynary | 2008-11-16 | 19 | class Configuration | |
| 22c78345 » | gaffo | 2008-12-25 | 20 | ||
| e822535b » | brynary | 2008-11-24 | 21 | # Should XHTML be parsed with Nokogiri? Defaults to true, except on JRuby. When false, Hpricot and REXML are used | |
| f6ce5bbf » | brynary | 2008-11-23 | 22 | attr_writer :parse_with_nokogiri | |
| adf68c2f » | brynary | 2008-11-22 | 23 | ||
| e822535b » | brynary | 2008-11-24 | 24 | # Webrat's mode, set automatically when requiring webrat/rails, webrat/merb, etc. | |
| f5ed57e0 » | brynary | 2008-11-30 | 25 | attr_accessor :mode # :nodoc: | |
| adf68c2f » | brynary | 2008-11-22 | 26 | ||
| e822535b » | brynary | 2008-11-24 | 27 | # Save and open pages with error status codes (500-599) in a browser? Defualts to true. | |
| f6ce5bbf » | brynary | 2008-11-23 | 28 | attr_writer :open_error_files | |
| 31cc6b75 » | brynary | 2008-11-16 | 29 | ||
| 2c51d908 » | Kieran Pilkington | 2008-12-27 | 30 | # Which environment should the selenium tests be run in? Defaults to selenium. | |
| 31 | attr_accessor :selenium_environment | ||||
| 32 | |||||
| 33 | # Which port should the selenium tests be run on? Defaults to 3001. | ||||
| 34 | attr_accessor :selenium_port | ||||
| 35 | |||||
| e822535b » | brynary | 2008-11-24 | 36 | def initialize # :nodoc: | |
| 31cc6b75 » | brynary | 2008-11-16 | 37 | self.open_error_files = true | |
| 1017fdfb » | brynary | 2008-11-23 | 38 | self.parse_with_nokogiri = !Webrat.on_java? | |
| 2c51d908 » | Kieran Pilkington | 2008-12-27 | 39 | self.selenium_environment = :selenium | |
| 40 | self.selenium_port = 3001 | ||||
| 31cc6b75 » | brynary | 2008-11-16 | 41 | end | |
| 42 | |||||
| 3b8fc555 » | brynary | 2008-11-24 | 43 | def parse_with_nokogiri? #:nodoc: | |
| f6ce5bbf » | brynary | 2008-11-23 | 44 | @parse_with_nokogiri ? true : false | |
| 45 | end | ||||
| 46 | |||||
| 3b8fc555 » | brynary | 2008-11-24 | 47 | def open_error_files? #:nodoc: | |
| f6ce5bbf » | brynary | 2008-11-23 | 48 | @open_error_files ? true : false | |
| 49 | end | ||||
| 50 | |||||
| 22c78345 » | gaffo | 2008-12-25 | 51 | # Allows setting of webrat's mode, valid modes are: | |
| 52 | # :rails, :selenium, :rack, :sinatra, :mechanize, :merb | ||||
| 53 | def mode=(mode) | ||||
| 54 | @mode = mode | ||||
| 55 | require("webrat/#{mode}") | ||||
| 56 | end | ||||
| 57 | |||||
| 31cc6b75 » | brynary | 2008-11-16 | 58 | end | |
| 59 | |||||
| 19353b50 » | gaffo | 2008-11-14 | 60 | end | |
