Class: QUnited::Rails::TestTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- QUnited::Rails::TestTask
- Includes:
- Rake::DSL
- Defined in:
- lib/qunited/rails/test_task.rb
Constant Summary collapse
- TMP_DIR_NAME =
'qunited-compiled-js'
Instance Attribute Summary collapse
-
#driver ⇒ Object
The driver to use to run the QUnit tests.
-
#fail_on_test_failure ⇒ Object
Fail rake task when tests fail.
-
#fixture_files ⇒ Object
Array or glob pattern of fixture files.
-
#helper_files ⇒ Object
Array or glob pattern of test helper files.
-
#name ⇒ Object
Name of task.
-
#server_port ⇒ Object
The port to use if running the server.
-
#source_paths ⇒ Object
writeonly
Array or strings specifying logical paths of Assets.
-
#test_files ⇒ Object
Array or glob pattern of QUnit test files.
-
#verbose ⇒ Object
Use verbose output.
Instance Method Summary collapse
-
#initialize(*args) {|_self| ... } ⇒ TestTask
constructor
A new instance of TestTask.
Constructor Details
#initialize(*args) {|_self| ... } ⇒ TestTask
Returns a new instance of TestTask.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/qunited/rails/test_task.rb', line 51 def initialize(*args) @name = args.shift || :qunited @verbose = true @fail_on_test_failure = true @server_port = nil yield self if block_given? desc('Run QUnit JavaScript tests') unless ::Rake.application.last_comment task(@name => :environment) do internal_task_name = "qunited-rails-#{@name}" QUnited::RakeTask.new(internal_task_name) do |t| create_tmp_dir compiled_source_files = [] source_paths.each do |path| compiled_source_files << compile_and_write_tmp_file(path) end t.source_files = compiled_source_files %w[test_files helper_files fixture_files driver verbose fail_on_test_failure server_port].each do |a| t.send("#{a}=", send(a)) end end Rake::Task[internal_task_name].invoke end end |
Instance Attribute Details
#driver ⇒ Object
The driver to use to run the QUnit tests.
31 32 33 |
# File 'lib/qunited/rails/test_task.rb', line 31 def driver @driver end |
#fail_on_test_failure ⇒ Object
Fail rake task when tests fail.
default:
true
43 44 45 |
# File 'lib/qunited/rails/test_task.rb', line 43 def fail_on_test_failure @fail_on_test_failure end |
#fixture_files ⇒ Object
Array or glob pattern of fixture files. These are included under the #qunit-fixture element on the test page. These will be included in order if specified as an array.
28 29 30 |
# File 'lib/qunited/rails/test_task.rb', line 28 def fixture_files @fixture_files end |
#helper_files ⇒ Object
Array or glob pattern of test helper files. These include extra libraries for mocks or other test tools. These are loaded after source files and before test files. These will be loaded in order if specified as an array.
24 25 26 |
# File 'lib/qunited/rails/test_task.rb', line 24 def helper_files @helper_files end |
#name ⇒ Object
Name of task.
default:
:qunited
12 13 14 |
# File 'lib/qunited/rails/test_task.rb', line 12 def name @name end |
#server_port ⇒ Object
The port to use if running the server.
default:
3040
49 50 51 |
# File 'lib/qunited/rails/test_task.rb', line 49 def server_port @server_port end |
#source_paths=(value) ⇒ Object
Array or strings specifying logical paths of Assets. These will be loaded in order if specified as an array.
16 17 18 |
# File 'lib/qunited/rails/test_task.rb', line 16 def source_paths=(value) @source_paths = value end |
#test_files ⇒ Object
Array or glob pattern of QUnit test files. These will be loaded in order if specified as an array.
19 20 21 |
# File 'lib/qunited/rails/test_task.rb', line 19 def test_files @test_files end |
#verbose ⇒ Object
Use verbose output. If this is true, the task will print the QUnited command to stdout.
default:
true
37 38 39 |
# File 'lib/qunited/rails/test_task.rb', line 37 def verbose @verbose end |