bauxite 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,8 +24,121 @@ require 'optparse'
24
24
  require_relative 'core/Context.rb'
25
25
 
26
26
  module Bauxite
27
+ # +bauxite+ command-line program.
28
+ #
29
+ # This program executes Bauxite tests and outputs the execution progress
30
+ # and tests results to the terminal.
31
+ #
32
+ # == Synopsis
33
+ #
34
+ # bauxite [OPTIONS] file1 file2 ...
35
+ # # => Executes file1, then file2, and so on.
36
+ #
37
+ # bauxite [OPTIONS] -d
38
+ # # => Start Bauxite directly in the debug console.
39
+ #
40
+ # bauxite [OPTIONS]
41
+ # # => Start Bauxite and read test actions from the standard input.
42
+ #
43
+ # == Options
44
+ # For a detailed list of options for your Bauxite version execute:
45
+ # bauxite -h
46
+ #
47
+ #
48
+ # [-v, \--verbose]
49
+ # Show verbose error messages (i.e. print exception names and
50
+ # backtraces).
51
+ #
52
+ # [-t, \--timeout SECONDS]
53
+ # Number of seconds to wait before issuing a timeout error. This
54
+ # timeout applies only to Selectors.
55
+ #
56
+ # [-d, \--debug]
57
+ # If an error occurs, break into the debug console. This mode is very
58
+ # useful to try different selector combinations and debug
59
+ # NoSuchElementError errors.
60
+ #
61
+ # [-p, \--provider DRIVER]
62
+ # Selenium WebDriver provider. Defaults to +firefox+.
63
+ #
64
+ # Other options include:
65
+ # - +remote+
66
+ # - +ie+
67
+ # - +chrome+
68
+ # - +android+
69
+ # - +iphone+
70
+ # - +opera+
71
+ # - +phantomjs+
72
+ # - +safari+
73
+ #
74
+ # Driver availability dependes on the system running Bauxite.
75
+ # [-P, \--provider-option OPTION]
76
+ # A <tt>name=value</tt> pair of options that are directly forwarded to
77
+ # the Selenium WebDriver provider. This option argument can appear
78
+ # multiple times in the command line to specify multiple options.
79
+ #
80
+ # [-l, \--logger LOGGER]
81
+ # Logger instance to use. Defaults to +xterm+ if the +TERM+ environment
82
+ # variable is set to +xterm+, otherwise it defaults to +terminal+.
83
+ #
84
+ # To see a complete list of the available loggers execute:
85
+ # bauxite -h
86
+ #
87
+ # [-L, \--logger-option OPTION]
88
+ # A <tt>name=value</tt> pair of options that are directly forwarded to
89
+ # the logger. This option argument can appear multiple times in the
90
+ # command line to specify multiple options.
91
+ #
92
+ # [-r, \--reset]
93
+ # Issue a Action#reset action between every test specified in
94
+ # the command line. This option enforces test isolation by resetting
95
+ # the test context before each test (this removes cookies, sessions,
96
+ # etc. from the previous test).
97
+ #
98
+ # [-w, \--wait]
99
+ # Wait for user input when the test completes instead of closing the
100
+ # browser window.
101
+ #
102
+ # [-u, \--url URL]
103
+ # This option is an alias of:
104
+ # -p remote -P url=URL
105
+ # If +URL+ is not present <tt>http://localhost:4444/wd/hub</tt> will be
106
+ # assumed.
107
+ #
108
+ # [-e, \--extension DIR]
109
+ # Loads every Ruby file (*.rb) inside +DIR+ (and subdirectories). This
110
+ # option can be used to load custom Bauxite extensions (e.g. Actions,
111
+ # Selectors, Loggers, etc.) for a specific test run.
112
+ #
113
+ # For example:
114
+ # # === custom/my_selector.rb ======= #
115
+ # class Bauxite::Selector
116
+ # def by_attr(value)
117
+ # attr "by_attr:#{value}"
118
+ # end
119
+ # end
120
+ # # === end custom/my_selector.rb === #
121
+ #
122
+ # # === custom/my_test.bxt ========== #
123
+ # # ...
124
+ # assert "by_attr=attr_value" hello
125
+ # # ...
126
+ # # === end custom/my_test.bxt ====== #
127
+ #
128
+ # bauxite -e custom custom/my_test.bxt
129
+ #
130
+ # [\--version]
131
+ # Shows the Bauxite version.
132
+ #
133
+ # == Exit Status
134
+ # The +bauxite+ program exits with +zero+ if every action in the test
135
+ # succeeded and +non-zero+ otherwise.
136
+ #
137
+ # If the test run includes multiple Action#test actions, the exit status
138
+ # equals the number of failed test cases (again, +zero+ indicates success).
139
+ #
27
140
  class Application
28
- def self.start
141
+ def self.start #:nodoc:
29
142
  options = {
30
143
  :logger => (ENV['TERM'] == 'xterm') ? 'xterm' : 'terminal',
31
144
  :verbose => false,
@@ -71,7 +71,8 @@ module Bauxite
71
71
  @options = options
72
72
  @driver_name = (options[:driver] || :firefox).to_sym
73
73
  @variables = {
74
- '__TIMEOUT__' => (options[:timeout] || 10).to_i
74
+ '__TIMEOUT__' => (options[:timeout] || 10).to_i,
75
+ '__DEBUG__' => false
75
76
  }
76
77
  @aliases = {}
77
78
  @tests = []
@@ -315,13 +316,15 @@ module Bauxite
315
316
  p e
316
317
  puts e.backtrace
317
318
  end
318
- if break_into_debug and @options[:debug]
319
- debug
320
- elsif exit_on_error
321
- if @variables['__RAISE_ERROR__']
322
- raise
323
- else
324
- exit false
319
+ unless @variables['__DEBUG__']
320
+ if break_into_debug and @options[:debug]
321
+ debug
322
+ elsif exit_on_error
323
+ if @variables['__RAISE_ERROR__']
324
+ raise
325
+ else
326
+ exit false
327
+ end
325
328
  end
326
329
  end
327
330
  end
@@ -68,12 +68,27 @@ protected
68
68
  true
69
69
  end
70
70
 
71
+ #--
72
+ # Adapted from:
73
+ # https://github.com/jimweirich/rake/blob/master/lib/rake/application.rb
74
+ # See Rake::Application#terminal_width
75
+ #++
71
76
  def _screen_width
72
- begin
73
- require 'terminfo'
74
- TermInfo.screen_size[1]
75
- rescue Exception
77
+ if RbConfig::CONFIG['host_os'] =~
78
+ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
79
+ (_dynamic_width_stty.nonzero? || _dynamic_width_tput)
80
+ else
76
81
  super
77
82
  end
83
+ rescue Exception => e
84
+ super
78
85
  end
86
+
87
+ private
88
+ def _dynamic_width_stty
89
+ %x{stty size 2>/dev/null}.split[1].to_i
90
+ end
91
+ def _dynamic_width_tput
92
+ %x{tput cols 2>/dev/null}.to_i
93
+ end
79
94
  end
data/lib/bauxite.rb CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  #--
24
24
  module Bauxite
25
- VERSION = "0.2.0"
25
+ VERSION = "0.3.0"
26
26
  end
27
27
  #++
28
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bauxite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricio Zavolinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -52,6 +52,7 @@ files:
52
52
  - doc/Bauxite.html
53
53
  - doc/Bauxite/Action.html
54
54
  - doc/Bauxite/ActionModule.html
55
+ - doc/Bauxite/Application.html
55
56
  - doc/Bauxite/Context.html
56
57
  - doc/Bauxite/Errors.html
57
58
  - doc/Bauxite/Errors/AssertionError.html