teabag 0.4.6 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +83 -92
- data/app/assets/javascripts/teabag-jasmine.js +5 -2
- data/app/assets/javascripts/teabag-mocha.js +5 -2
- data/app/assets/javascripts/teabag-qunit.js +5 -2
- data/app/assets/javascripts/teabag/base/reporters/console.coffee +2 -1
- data/app/assets/javascripts/teabag/base/reporters/html/progress_view.coffee +1 -1
- data/app/controllers/teabag/spec_controller.rb +2 -2
- data/app/helpers/teabag/spec_helper.rb +11 -2
- data/app/views/teabag/spec/index.html.erb +1 -1
- data/bin/teabag +6 -0
- data/config/routes.rb +2 -2
- data/lib/generators/teabag/install/POST_INSTALL +0 -2
- data/lib/generators/teabag/install/install_generator.rb +46 -5
- data/lib/generators/teabag/install/templates/env.rb +28 -0
- data/lib/generators/teabag/install/templates/{initializer.rb → jasmine/initializer.rb} +5 -13
- data/lib/generators/teabag/install/templates/jasmine/spec_helper.coffee +25 -0
- data/lib/generators/teabag/install/templates/jasmine/spec_helper.js +25 -0
- data/lib/generators/teabag/install/templates/mocha/initializer.rb +58 -0
- data/lib/generators/teabag/install/templates/mocha/spec_helper.coffee +25 -0
- data/lib/generators/teabag/install/templates/mocha/spec_helper.js +25 -0
- data/lib/generators/teabag/install/templates/qunit/initializer.rb +58 -0
- data/lib/generators/teabag/install/templates/qunit/test_helper.coffee +24 -0
- data/lib/generators/teabag/install/templates/qunit/test_helper.js +24 -0
- data/lib/tasks/teabag.rake +1 -1
- data/lib/teabag/command_line.rb +96 -0
- data/lib/teabag/configuration.rb +25 -35
- data/lib/teabag/console.rb +19 -7
- data/lib/teabag/drivers/phantomjs/runner.coffee +2 -2
- data/lib/teabag/drivers/selenium_driver.rb +2 -2
- data/lib/teabag/environment.rb +46 -0
- data/lib/teabag/exceptions.rb +1 -0
- data/lib/teabag/formatters/base_formatter.rb +5 -0
- data/lib/teabag/formatters/dot_formatter.rb +3 -2
- data/lib/teabag/formatters/junit_formatter.rb +19 -0
- data/lib/teabag/formatters/swayze_or_oprah_formatter.rb +7 -2
- data/lib/teabag/formatters/tap_y_formatter.rb +1 -0
- data/lib/teabag/runner.rb +1 -1
- data/lib/teabag/suite.rb +15 -6
- data/lib/teabag/version.rb +1 -1
- data/spec/dummy/log/development.log +62925 -0
- data/spec/dummy/log/test.log +614 -0
- data/spec/dummy/tmp/cache/assets/C35/A30/sprockets%2F29906bf540f7d2e081088494b2554989 +0 -0
- data/spec/dummy/tmp/cache/assets/C4E/9B0/sprockets%2Fa807397434c9262c3d62da3e91152184 +0 -0
- data/spec/dummy/tmp/cache/assets/C59/250/sprockets%2Fa80d3fe493d2476e58c4323996064512 +0 -0
- data/spec/dummy/tmp/cache/assets/C72/150/sprockets%2F4194031b4b51b6422c14ac697e3455e5 +0 -0
- data/spec/dummy/tmp/cache/assets/C75/D50/sprockets%2F5302968a40e08d2c011aa38666d273f6 +0 -0
- data/spec/dummy/tmp/cache/assets/C78/F80/sprockets%2F9161622ddd251097a4ab816b8220984c +0 -0
- data/spec/dummy/tmp/cache/assets/C7A/EC0/sprockets%2F5c16e4214f5662e1b27932a57c43491b +0 -0
- data/spec/dummy/tmp/cache/assets/C89/700/sprockets%2F259935a7704fef0069303ea63fa89408 +0 -0
- data/spec/dummy/tmp/cache/assets/C8A/460/sprockets%2F77bffd9959420103906722b404ae8d59 +0 -0
- data/spec/dummy/tmp/cache/assets/C91/FA0/sprockets%2F2eb81283f5789ae91a69344552db3856 +0 -0
- data/spec/dummy/tmp/cache/assets/C9D/E90/sprockets%2F3045c9533f179d3e1c805d163ed002a0 +0 -0
- data/spec/dummy/tmp/cache/assets/CA6/DF0/sprockets%2F7da83747ce56e49393b6b8726587f846 +0 -0
- data/spec/dummy/tmp/cache/assets/CA9/C40/sprockets%2F932b7e2cd1e067289ab51190800814df +0 -0
- data/spec/dummy/tmp/cache/assets/CAA/0C0/sprockets%2F057b0ce384f16d9202ae84473436cc35 +0 -0
- data/spec/dummy/tmp/cache/assets/CAD/410/sprockets%2F651414e5c7e86f05c5108dc71626b25c +0 -0
- data/spec/dummy/tmp/cache/assets/CAF/0F0/sprockets%2F6000e67cf3f2377f860c24da7c819701 +0 -0
- data/spec/dummy/tmp/cache/assets/CB7/2B0/sprockets%2Fdf3d317564a780186148134f2ddd59a9 +0 -0
- data/spec/dummy/tmp/cache/assets/CBB/FA0/sprockets%2F74922109263bdc965b2e9567eec6d154 +0 -0
- data/spec/dummy/tmp/cache/assets/CBD/AF0/sprockets%2Fd687ec33822256e9444e8cd04f1b4873 +0 -0
- data/spec/dummy/tmp/cache/assets/CBF/630/sprockets%2F707d2db81468088470d476abff35388d +0 -0
- data/spec/dummy/tmp/cache/assets/CC1/DB0/sprockets%2F95e6273223502af230a0dbaa25410de8 +0 -0
- data/spec/dummy/tmp/cache/assets/CC2/EC0/sprockets%2F76bf80cb571ca530357f78db78167866 +0 -0
- data/spec/dummy/tmp/cache/assets/CCE/C50/sprockets%2Fe12774c2fea852112414bb379a71f31a +0 -0
- data/spec/dummy/tmp/cache/assets/CD1/620/sprockets%2F06a3eb05fcb4175a679d6084a06026a6 +0 -0
- data/spec/dummy/tmp/cache/assets/CD3/460/sprockets%2F7f3f6802b0b309ed142d0b671c9640c4 +0 -0
- data/spec/dummy/tmp/cache/assets/CD9/DD0/sprockets%2Fe5774759168a731da1c1149ecf0e1b03 +0 -0
- data/spec/dummy/tmp/cache/assets/CE0/090/sprockets%2F48d5d35ae87d0723318b8bc257fa2237 +0 -0
- data/spec/dummy/tmp/cache/assets/CE3/1F0/sprockets%2Fe69a515d3a9d14c669be8871012a7d07 +0 -0
- data/spec/dummy/tmp/cache/assets/CE6/270/sprockets%2F2c98152560d18470fec8cf4c6829b4d0 +0 -0
- data/spec/dummy/tmp/cache/assets/CE6/7C0/sprockets%2Fa03a2c86ce6724be8542295e1cf24798 +0 -0
- data/spec/dummy/tmp/cache/assets/CE7/A60/sprockets%2Ff58eee249aa167d23f8220087bb46684 +0 -0
- data/spec/dummy/tmp/cache/assets/CE9/9E0/sprockets%2F135480d497ed7e4884462dc0ef0b80d7 +0 -0
- data/spec/dummy/tmp/cache/assets/CEB/680/sprockets%2F67f0794ef8c0576d5c7da34f4437305a +0 -0
- data/spec/dummy/tmp/cache/assets/CEB/B40/sprockets%2F1150bf8d912aa100a132251eefaf6045 +0 -0
- data/spec/dummy/tmp/cache/assets/CF4/6F0/sprockets%2Fed96f92571224b862b84d7078b86ded3 +0 -0
- data/spec/dummy/tmp/cache/assets/CF8/780/sprockets%2F8845b81ff27cdb57c835836c9f91a265 +0 -0
- data/spec/dummy/tmp/cache/assets/CFA/D20/sprockets%2Fb26796b39b3c5d6ed70be7989637a493 +0 -0
- data/spec/dummy/tmp/cache/assets/CFB/210/sprockets%2F9104695bfbf9a9d4b94382e6e90487a9 +0 -0
- data/spec/dummy/tmp/cache/assets/CFC/380/sprockets%2Fa7443cbd671446a589867dd5f4a4f989 +0 -0
- data/spec/dummy/tmp/cache/assets/D00/110/sprockets%2F6a6353b7723a8b21708e0fbfe04bd422 +0 -0
- data/spec/dummy/tmp/cache/assets/D00/F60/sprockets%2F42e279b52511c47d26c0adb125fd04e8 +0 -0
- data/spec/dummy/tmp/cache/assets/D03/630/sprockets%2F5d8da32dba6a7be70426a1d554773701 +0 -0
- data/spec/dummy/tmp/cache/assets/D04/170/sprockets%2F76ab1dc02e6c7618852708a1e05a2df3 +0 -0
- data/spec/dummy/tmp/cache/assets/D04/480/sprockets%2F8bd8f10500b21d2f9d94e4cd1401c936 +0 -0
- data/spec/dummy/tmp/cache/assets/D05/8D0/sprockets%2F319f8f235f452343f1ebf03cb262d23d +0 -0
- data/spec/dummy/tmp/cache/assets/D09/BF0/sprockets%2F9e6bca5d26f50d9484385d51ba04312c +0 -0
- data/spec/dummy/tmp/cache/assets/D0E/570/sprockets%2F90fe371bf8091e88a712124d9cdae260 +0 -0
- data/spec/dummy/tmp/cache/assets/D15/750/sprockets%2F8effdd3e668a4036260a3e370f3b6657 +0 -0
- data/spec/dummy/tmp/cache/assets/D17/710/sprockets%2Ffa49fb6823d466e79a195e0cd71340c5 +0 -0
- data/spec/dummy/tmp/cache/assets/D1A/D30/sprockets%2F815a5177e9edba0c5c996182ef1b3675 +0 -0
- data/spec/dummy/tmp/cache/assets/D1D/560/sprockets%2F1ca784ee7ba1922465147e7f8963eae5 +0 -0
- data/spec/dummy/tmp/cache/assets/D1E/AA0/sprockets%2F5c8741a556bc955cd36e61c88582b6dc +0 -0
- data/spec/dummy/tmp/cache/assets/D31/9C0/sprockets%2Fbd102a4f5a4985c3519dd6ab0295a1c6 +0 -0
- data/spec/dummy/tmp/cache/assets/D35/7C0/sprockets%2Ff536a2606eaf7d542c0985104cb62baf +0 -0
- data/spec/dummy/tmp/cache/assets/D37/FF0/sprockets%2F96841ca4cfae32c515077f3f5fc303b2 +0 -0
- data/spec/dummy/tmp/cache/assets/D3C/840/sprockets%2Fc6202ec91d567a85bd3d46dc43ea9108 +0 -0
- data/spec/dummy/tmp/cache/assets/D44/E90/sprockets%2F05cfc0bf7c9938963d1d1c63248db80d +0 -0
- data/spec/dummy/tmp/cache/assets/D45/C30/sprockets%2Fcc744877558178a3adb77c441cadce70 +0 -0
- data/spec/dummy/tmp/cache/assets/D47/A90/sprockets%2Fe7ca382b607c595ea6505853f7fb63da +0 -0
- data/spec/dummy/tmp/cache/assets/D49/1F0/sprockets%2F773b56f87127c6605e7d1d3faf2b6af6 +0 -0
- data/spec/dummy/tmp/cache/assets/D49/A10/sprockets%2Fc4656bd995a6f297c26d19b13aadb963 +0 -0
- data/spec/dummy/tmp/cache/assets/D50/D70/sprockets%2Fe2a3e6c95b11e0801a4eebae3a026026 +0 -0
- data/spec/dummy/tmp/cache/assets/D51/400/sprockets%2Ff5e433d8a31e80985b75ce598de236be +0 -0
- data/spec/dummy/tmp/cache/assets/D5C/710/sprockets%2F9427d05cee2caa721241a25a9af1d08f +0 -0
- data/spec/dummy/tmp/cache/assets/D5C/CC0/sprockets%2Faa8bf6de211f2765b0a26f112b971f0c +0 -0
- data/spec/dummy/tmp/cache/assets/D5E/FA0/sprockets%2Fc81c371ae2d61a6aa1708262fba79e0d +0 -0
- data/spec/dummy/tmp/cache/assets/D61/1F0/sprockets%2F0c7a6176d2fc4db00bb9a74d36380fe1 +0 -0
- data/spec/dummy/tmp/cache/assets/D67/BC0/sprockets%2F35d2c2b45981ade5a2db2a9c7f37a615 +0 -0
- data/spec/dummy/tmp/cache/assets/D69/F90/sprockets%2F6a0795b7b38bd7e6142cd1b88211dade +0 -0
- data/spec/dummy/tmp/cache/assets/D6A/950/sprockets%2F429b1806cb7580ebf29f9a12c33cbea6 +0 -0
- data/spec/dummy/tmp/cache/assets/D6B/6E0/sprockets%2F266d99da1afe084cac250a6ba864c565 +0 -0
- data/spec/dummy/tmp/cache/assets/D6D/DA0/sprockets%2Fac936bf40b42227a2bf9d474ae9ec149 +0 -0
- data/spec/dummy/tmp/cache/assets/D6F/5B0/sprockets%2F5dcc801a7a6c340c5baf525839f9b8b6 +0 -0
- data/spec/dummy/tmp/cache/assets/D77/B30/sprockets%2F946cf2f17c7eb41037f9ee08ad67ec40 +0 -0
- data/spec/dummy/tmp/cache/assets/D78/2F0/sprockets%2F3c61f8915b8f717b1de788e6ecad122c +0 -0
- data/spec/dummy/tmp/cache/assets/D7E/C10/sprockets%2F747c98c3cc7494a62dd882752adffb2b +0 -0
- data/spec/dummy/tmp/cache/assets/D8C/520/sprockets%2F221cd58a042baac534d27e4cfedc1188 +0 -0
- data/spec/dummy/tmp/cache/assets/D93/BD0/sprockets%2Ff5e1b60201e08e3ddf8d3de5211f3d5e +0 -0
- data/spec/dummy/tmp/cache/assets/DA0/330/sprockets%2Fcbbb4de706387d50f48a72ee6c9c1b80 +0 -0
- data/spec/dummy/tmp/cache/assets/DA5/0A0/sprockets%2F7a4b5928cec69ab65afff309a04d6b47 +0 -0
- data/spec/dummy/tmp/cache/assets/DA9/BF0/sprockets%2Fc59f8f7bf494fe030610bc86bb7cc5e5 +0 -0
- data/spec/dummy/tmp/cache/assets/DAC/9B0/sprockets%2F5e58701704fefbc8f88ae24c549fab6b +0 -0
- data/spec/dummy/tmp/cache/assets/DAE/6C0/sprockets%2F77c7a8676aeefa73156c55dfcf51cc46 +0 -0
- data/spec/dummy/tmp/cache/assets/DB3/5D0/sprockets%2Fce1d4d75832c9bdeafd869f6f7b61725 +0 -0
- data/spec/dummy/tmp/cache/assets/DB4/1F0/sprockets%2F69ad2749d7bfe831c0e74e7d7fc4dc57 +0 -0
- data/spec/dummy/tmp/cache/assets/DB5/040/sprockets%2F9a9da5df88713663b9fbc945facca891 +0 -0
- data/spec/dummy/tmp/cache/assets/DC3/230/sprockets%2Fdf52e72eb73be91eccc60182191aed0b +0 -0
- data/spec/dummy/tmp/cache/assets/DC7/A10/sprockets%2F84a8af0fcbf401864e1ae5bf092cba94 +0 -0
- data/spec/dummy/tmp/cache/assets/DCD/EB0/sprockets%2F4f77f509126ecbced7ea2a5ab290c8d4 +0 -0
- data/spec/dummy/tmp/cache/assets/DE4/140/sprockets%2F139e4ab85d1aacb22c115fa136afdc8a +0 -0
- data/spec/dummy/tmp/cache/assets/DEB/110/sprockets%2F2dbdab0ce5babca645cdb5780004f875 +0 -0
- data/spec/dummy/tmp/cache/assets/DF6/0E0/sprockets%2F85b10db6e1afe643aba6d396abdd77f0 +0 -0
- data/spec/dummy/tmp/cache/assets/DF7/E10/sprockets%2F25e4253aba9a9adcefb72552fb1ff0c8 +0 -0
- data/spec/dummy/tmp/cache/assets/DFC/C20/sprockets%2Fd9178ad7e3b401c9fceafd64ea2b50d6 +0 -0
- data/spec/dummy/tmp/cache/assets/DFC/C30/sprockets%2Fb50a07cb30b0bd0eec8e98e5de79d65d +0 -0
- data/spec/dummy/tmp/cache/assets/E02/6E0/sprockets%2F63d6a5cdb8cefa64ef76b5c6e0fd3720 +0 -0
- data/spec/dummy/tmp/cache/assets/E08/BB0/sprockets%2Fefac99af1af28543aef6fb607faa4973 +0 -0
- data/spec/dummy/tmp/cache/assets/E08/F20/sprockets%2F4fc5cdcd6974efe7adfe809b30bd6513 +0 -0
- data/spec/dummy/tmp/cache/assets/E16/D30/sprockets%2Fd69469e6e7439baacd8df989c0fdacc2 +0 -0
- data/spec/dummy/tmp/cache/assets/E17/EF0/sprockets%2Fa291ad64a26afd055dfadabbdf03f154 +0 -0
- data/spec/dummy/tmp/cache/assets/E2F/790/sprockets%2F7fac280deaa7ef20a77d5c9b5b9cfc34 +0 -0
- data/spec/dummy/tmp/cache/assets/E41/250/sprockets%2F97cf8fe3d7ffaff076f655aefb36da03 +0 -0
- data/spec/dummy/tmp/cache/assets/E64/1E0/sprockets%2F81ab4c863fbbdec8dd66afc97ebf034d +0 -0
- data/spec/dummy/tmp/cache/assets/E6E/260/sprockets%2Fd9f8ab8b91ef582cc6c99a3ba0dedfe6 +0 -0
- data/spec/dummy/tmp/cache/assets/F79/360/sprockets%2F0ce035fefee5ebdabc8efabfbdbd6ee4 +0 -0
- data/spec/javascripts/spec_helper.coffee +2 -0
- data/spec/javascripts/support/json2.js +486 -0
- data/spec/javascripts/teabag/base/reporters/console_spec.coffee +14 -2
- data/spec/javascripts/teabag/base/teabag_spec.coffee +1 -0
- data/spec/javascripts/teabag/mocha/mocha_mspec.coffee +1 -1
- data/spec/javascripts/teabag/phantomjs/runner_spec.coffee +1 -0
- data/spec/teabag/command_line_spec.rb +50 -0
- data/spec/teabag/console_spec.rb +32 -3
- data/spec/teabag/drivers/selenium_driver_spec.rb +2 -2
- data/spec/teabag/environment_spec.rb +88 -0
- data/spec/teabag/formatters/dot_formatter_spec.rb +2 -2
- data/spec/teabag/runner_spec.rb +4 -0
- data/spec/teabag/suite_spec.rb +8 -2
- data/spec/teabag_env.rb +27 -0
- metadata +40 -8
- data/app/assets/images/teabag/photo-white.jpg +0 -0
- data/lib/generators/teabag/install/templates/spec_helper.js +0 -31
@@ -0,0 +1,24 @@
|
|
1
|
+
// You can require javascript files here. A good place to start is by requiring your application.js.
|
2
|
+
// require application
|
3
|
+
//
|
4
|
+
// Teabag includes some support files, but you can use anything from your own support path too.
|
5
|
+
// require support/sinon
|
6
|
+
// require support/your-support-file
|
7
|
+
//
|
8
|
+
// Deferring execution
|
9
|
+
// If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call Teabag.execute()
|
10
|
+
// after everything has been loaded. Simple example of a timeout:
|
11
|
+
//
|
12
|
+
// Teabag.defer = true
|
13
|
+
// setTimeout(Teabag.execute, 1000)
|
14
|
+
//
|
15
|
+
// Matching files
|
16
|
+
// By default Teabag will look for files that match _test.{js,js.coffee,.coffee}. Add a filename_test.js file in your
|
17
|
+
// test path and it'll be included in the default suite automatically. If you want to customize suites, check out the
|
18
|
+
// configuration in config/initializers/teabag.rb
|
19
|
+
//
|
20
|
+
// Manifest
|
21
|
+
// If you'd rather require your test files manually (to control order for instance) you can disable the suite matcher in
|
22
|
+
// the configuration and use this file as a manifest.
|
23
|
+
//
|
24
|
+
// For more information: http://github.com/modeset/teabag
|
data/lib/tasks/teabag.rake
CHANGED
@@ -0,0 +1,96 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "teabag/version"
|
3
|
+
|
4
|
+
module Teabag
|
5
|
+
class CommandLine
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@options = {}
|
9
|
+
@files = opt_parser.parse!
|
10
|
+
|
11
|
+
begin
|
12
|
+
require_console
|
13
|
+
abort if Teabag::Console.new(@options, @files).execute
|
14
|
+
rescue Teabag::EnvironmentNotFound => e
|
15
|
+
STDOUT.print "Unable to load Teabag environment in {#{Teabag::Environment.standard_environments.join(', ')}}.\n"
|
16
|
+
STDOUT.print "Consider using -r path/to/teabag_env\n"
|
17
|
+
abort
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def opt_parser
|
22
|
+
OptionParser.new do |parser|
|
23
|
+
parser.banner = "Usage: teabag [options] [files]\n\n"
|
24
|
+
|
25
|
+
parser.on("-r", "--require FILE", "Require Teabag environment file.") do |file|
|
26
|
+
@options[:environment] = file
|
27
|
+
end
|
28
|
+
|
29
|
+
#parser.on("-O", "--options PATH", "Specify the path to a custom options file.") do |path|
|
30
|
+
# @options[:custom_options_file] = path
|
31
|
+
#end
|
32
|
+
|
33
|
+
parser.on("-d", "--driver DRIVER", "Specify driver:",
|
34
|
+
" phantomjs (default)",
|
35
|
+
" selenium") do |driver|
|
36
|
+
@options[:driver] = driver
|
37
|
+
end
|
38
|
+
|
39
|
+
parser.on("--server-timeout SECONDS", "Sets the timeout for the server to start.") do |seconds|
|
40
|
+
@options[:server_timeout] = seconds
|
41
|
+
end
|
42
|
+
|
43
|
+
parser.on("--[no-]fail-fast", "Abort after the first failing suite.") do |o|
|
44
|
+
@options[:fail_fast] = o
|
45
|
+
end
|
46
|
+
|
47
|
+
parser.separator("\n **** Filtering ****\n\n")
|
48
|
+
|
49
|
+
parser.on("-s", "--suite SUITE", "Focus to a specific suite.") do |suite|
|
50
|
+
@options[:suite] = suite
|
51
|
+
end
|
52
|
+
|
53
|
+
parser.on("-g", "--filter FILTER", "Filter tests matching a specific filter.") do |filter|
|
54
|
+
@options[:filter] = filter
|
55
|
+
end
|
56
|
+
|
57
|
+
parser.separator("\n **** Output ****\n\n")
|
58
|
+
|
59
|
+
parser.on("-f", "--format FORMATTERS", "Specify formatters (comma separated)",
|
60
|
+
" dot (default)",
|
61
|
+
" tap_y",
|
62
|
+
" swayze_or_oprah") do |formatters|
|
63
|
+
@options[:formatters] = formatters
|
64
|
+
end
|
65
|
+
|
66
|
+
parser.on("-q", "--[no-]suppress-log", "Suppress logs coming from console[log/debug/error].") do |o|
|
67
|
+
@options[:suppress_log] = o
|
68
|
+
end
|
69
|
+
|
70
|
+
parser.on("-c", "--[no-]colour", "Enable/Disable color output.") do |o|
|
71
|
+
@options[:color] = o
|
72
|
+
end
|
73
|
+
|
74
|
+
parser.separator("\n **** Utility ****\n\n")
|
75
|
+
|
76
|
+
parser.on("-v", "--version", "Display the version.") do
|
77
|
+
puts Teabag::VERSION
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
|
81
|
+
parser.on("-h", "--help", "You're looking at it.") do
|
82
|
+
puts parser
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def require_console
|
89
|
+
require "teabag/console"
|
90
|
+
end
|
91
|
+
|
92
|
+
def abort
|
93
|
+
exit(1)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/teabag/configuration.rb
CHANGED
@@ -5,41 +5,22 @@ module Teabag
|
|
5
5
|
|
6
6
|
include Singleton
|
7
7
|
|
8
|
-
cattr_accessor :root,
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
:server_timeout,
|
15
|
-
:fail_fast,
|
16
|
-
:suppress_log,
|
17
|
-
:phantomjs_bin,
|
18
|
-
:suites
|
19
|
-
|
20
|
-
@@mount_at = "/teabag"
|
21
|
-
@@root = nil # will default to Rails.root if left unset
|
22
|
-
@@asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]
|
23
|
-
@@fixture_path = "spec/javascripts/fixtures"
|
24
|
-
@@suites = {}
|
8
|
+
cattr_accessor :mount_at, :root, :asset_paths, :fixture_path, :suites
|
9
|
+
@@mount_at = "/teabag"
|
10
|
+
@@root = nil # will default to Rails.root if left unset
|
11
|
+
@@asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]
|
12
|
+
@@fixture_path = "spec/javascripts/fixtures"
|
13
|
+
@@suites = {"default" => proc{}}
|
25
14
|
|
26
15
|
# console runner specific
|
27
|
-
|
28
|
-
@@
|
29
|
-
@@
|
30
|
-
@@
|
31
|
-
@@
|
32
|
-
@@
|
33
|
-
|
34
|
-
|
35
|
-
@@root = Pathname.new(path.to_s) if path.present?
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.suite(name = :default, &block)
|
39
|
-
@@suites[name.to_s] = block
|
40
|
-
end
|
41
|
-
|
42
|
-
self.suite(:default) {}
|
16
|
+
cattr_accessor :driver, :phantomjs_bin, :server_timeout, :fail_fast, :formatters, :suppress_log, :color
|
17
|
+
@@driver = "phantomjs"
|
18
|
+
@@phantomjs_bin = nil
|
19
|
+
@@server_timeout = 20
|
20
|
+
@@fail_fast = true
|
21
|
+
@@formatters = "dot"
|
22
|
+
@@suppress_log = false
|
23
|
+
@@color = true
|
43
24
|
|
44
25
|
class Suite
|
45
26
|
attr_accessor :matcher, :helper, :stylesheets, :javascripts
|
@@ -53,6 +34,15 @@ module Teabag
|
|
53
34
|
yield self if block_given?
|
54
35
|
end
|
55
36
|
end
|
37
|
+
|
38
|
+
def self.root=(path)
|
39
|
+
@@root = Pathname.new(path.to_s) if path.present?
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.suite(name = :default, &block)
|
43
|
+
@@suites[name.to_s] = block
|
44
|
+
end
|
45
|
+
|
56
46
|
end
|
57
47
|
|
58
48
|
autoload :Formatters, "teabag/formatters/base_formatter"
|
@@ -69,11 +59,11 @@ module Teabag
|
|
69
59
|
private
|
70
60
|
|
71
61
|
def self.override_from_env
|
72
|
-
%w(FAIL_FAST SUPPRESS_LOG).each do |directive|
|
62
|
+
%w(FAIL_FAST SUPPRESS_LOG COLOR).each do |directive|
|
73
63
|
next unless ENV[directive].present?
|
74
64
|
@@configuration.send("#{directive.downcase}=", ENV[directive] == "true")
|
75
65
|
end
|
76
|
-
%w(FORMATTERS
|
66
|
+
%w(DRIVER FORMATTERS SERVER_TIMEOUT PHANTOMJS_BIN).each do |directive|
|
77
67
|
next unless ENV[directive].present?
|
78
68
|
@@configuration.send("#{directive.downcase}=", ENV[directive])
|
79
69
|
end
|
data/lib/teabag/console.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'open-uri'
|
2
|
+
require 'teabag/environment'
|
2
3
|
|
3
4
|
module Teabag
|
4
5
|
class Console
|
5
6
|
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
|
7
|
+
def initialize(options = nil, files = [])
|
8
|
+
@options = options || {}
|
9
|
+
@files = files
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
Teabag::Environment.load(@options)
|
12
|
+
require "teabag/server"
|
13
|
+
Rails.application.config.assets.debug = false if Teabag.configuration.driver == 'phantomjs'
|
14
|
+
|
15
|
+
if @options[:suite].present?
|
16
|
+
@suites = [@options[:suite]]
|
12
17
|
else
|
13
18
|
@suites = Teabag.configuration.suites.keys
|
14
19
|
end
|
@@ -44,8 +49,15 @@ module Teabag
|
|
44
49
|
@driver ||= Teabag::Drivers.const_get("#{Teabag.configuration.driver.to_s.camelize}Driver").new
|
45
50
|
end
|
46
51
|
|
52
|
+
def filter
|
53
|
+
parts = []
|
54
|
+
parts << "grep=#{URI::encode(@options[:filter])}" if @options[:filter].present?
|
55
|
+
@files.each { |file| parts << "file[]=#{URI::encode(file)}" }
|
56
|
+
"?#{parts.join('&')}"
|
57
|
+
end
|
58
|
+
|
47
59
|
def url(suite)
|
48
|
-
["#{@server.url}#{Teabag.configuration.mount_at}", suite].join("/")
|
60
|
+
["#{@server.url}#{Teabag.configuration.mount_at}", suite, filter].join("/")
|
49
61
|
end
|
50
62
|
end
|
51
63
|
end
|
@@ -24,7 +24,7 @@ class @Runner
|
|
24
24
|
|
25
25
|
|
26
26
|
waitForResults: =>
|
27
|
-
@fail("Timed out") if (Date.
|
27
|
+
@fail("Timed out") if (new Date().getTime() - @start) >= @timeout
|
28
28
|
finished = @page.evaluate(-> window.Teabag && window.Teabag.finished)
|
29
29
|
if finished then @finish() else setTimeout(@waitForResults, 200)
|
30
30
|
|
@@ -50,7 +50,7 @@ class @Runner
|
|
50
50
|
|
51
51
|
|
52
52
|
onLoadFinished: (status) =>
|
53
|
-
@start = Date.
|
53
|
+
@start = new Date().getTime()
|
54
54
|
defined = @page.evaluate(-> window.Teabag)
|
55
55
|
unless status == "success" && defined
|
56
56
|
@fail("Failed to load: #{@url}")
|
@@ -9,11 +9,11 @@ module Teabag
|
|
9
9
|
runner = Teabag::Runner.new(suite)
|
10
10
|
|
11
11
|
driver = Selenium::WebDriver.for(:firefox)
|
12
|
-
driver.navigate.to("#{url}
|
12
|
+
driver.navigate.to("#{url}&reporter=Console")
|
13
13
|
|
14
14
|
Selenium::WebDriver::Wait.new(timeout: 180, interval: 0.01, message: "Timed out").until do
|
15
15
|
done = driver.execute_script("return window.Teabag && window.Teabag.finished")
|
16
|
-
driver.execute_script("return Teabag.getMessages()").each do |line|
|
16
|
+
driver.execute_script("return window.Teabag && window.Teabag.getMessages() || []").each do |line|
|
17
17
|
runner.process("#{line}\n")
|
18
18
|
end
|
19
19
|
done
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "teabag/exceptions"
|
2
|
+
|
3
|
+
module Teabag
|
4
|
+
module Environment
|
5
|
+
|
6
|
+
def self.load(options = {})
|
7
|
+
unless rails_loaded?
|
8
|
+
require_environment(options[:environment])
|
9
|
+
raise "Rails environment not found." unless rails_loaded?
|
10
|
+
end
|
11
|
+
|
12
|
+
require "teabag"
|
13
|
+
|
14
|
+
configure_from_options(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.require_environment(override = nil)
|
18
|
+
return require_env(File.expand_path(override, Dir.pwd)) if override
|
19
|
+
|
20
|
+
standard_environments.each do |filename|
|
21
|
+
file = File.expand_path(filename, Dir.pwd)
|
22
|
+
return require_env(file) if File.exists?(file)
|
23
|
+
end
|
24
|
+
|
25
|
+
raise Teabag::EnvironmentNotFound
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.standard_environments
|
29
|
+
["spec/teabag_env.rb", "test/teabag_env.rb", "teabag_env.rb"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.configure_from_options(options)
|
33
|
+
options.each do |key, value|
|
34
|
+
Teabag.configuration.send("#{key.downcase}=", value) if Teabag.configuration.respond_to?("#{key.downcase}=")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.require_env(file)
|
39
|
+
require(file)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.rails_loaded?
|
43
|
+
defined?(Rails)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/teabag/exceptions.rb
CHANGED
@@ -29,6 +29,11 @@ module Teabag
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def result(results)
|
33
|
+
return if failures.size == 0
|
34
|
+
raise Teabag::Failure if Teabag.configuration.fail_fast
|
35
|
+
end
|
36
|
+
|
32
37
|
# Exceptions come from startup errors in the server
|
33
38
|
def exception(exception = {})
|
34
39
|
raise Teabag::RunnerException
|
@@ -34,6 +34,7 @@ module Teabag
|
|
34
34
|
log_information
|
35
35
|
log_stats(results)
|
36
36
|
log_failed_examples
|
37
|
+
super
|
37
38
|
end
|
38
39
|
|
39
40
|
protected
|
@@ -72,10 +73,9 @@ module Teabag
|
|
72
73
|
return if failures.size == 0
|
73
74
|
log "\nFailed examples:\n"
|
74
75
|
failures.each do |failure|
|
75
|
-
log "\
|
76
|
+
log "\nteabag -s #{@suite_name} --filter=\"#{failure.link}\"", RED
|
76
77
|
end
|
77
78
|
log "\n\n"
|
78
|
-
raise Teabag::Failure if Teabag.configuration.fail_fast
|
79
79
|
end
|
80
80
|
|
81
81
|
private
|
@@ -85,6 +85,7 @@ module Teabag
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def colorize(str, color_code)
|
88
|
+
return str unless Teabag.configuration.color
|
88
89
|
"\e[#{color_code}m#{str}\e[0m"
|
89
90
|
end
|
90
91
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'teabag/formatters/base_formatter'
|
2
|
+
|
3
|
+
module Teabag
|
4
|
+
module Formatters
|
5
|
+
class JunitFormatter < BaseFormatter
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@builder = Builder::XmlMarkup.new
|
10
|
+
@builder.instruct! :xml, version: "1.0", :encoding=>"UTF-8"
|
11
|
+
end
|
12
|
+
|
13
|
+
def spec
|
14
|
+
@builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
15
|
+
puts @builder
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,8 +3,13 @@ module Teabag
|
|
3
3
|
class SwayzeOrOprahFormatter < BaseFormatter
|
4
4
|
|
5
5
|
def result(results)
|
6
|
-
|
7
|
-
|
6
|
+
if failures.size == 0
|
7
|
+
quote = QUOTES[Random.rand(QUOTES.size)]
|
8
|
+
STDOUT.print("\n#{quote.inspect} -- Oprah Winfrey or Patrick Swayze?\n")
|
9
|
+
else
|
10
|
+
STDOUT.print("\nNo quote for you.\n")
|
11
|
+
end
|
12
|
+
super
|
8
13
|
end
|
9
14
|
|
10
15
|
QUOTES = [
|
data/lib/teabag/runner.rb
CHANGED
@@ -9,7 +9,7 @@ module Teabag
|
|
9
9
|
|
10
10
|
def initialize(suite_name = :default)
|
11
11
|
@suite_name = suite_name
|
12
|
-
@formatters = Teabag.configuration.formatters.split(/,\s
|
12
|
+
@formatters = Teabag.configuration.formatters.split(/,\s?/).map{ |f| resolve_formatter(f).new(suite_name) }
|
13
13
|
@failure_count = 0
|
14
14
|
end
|
15
15
|
|