Uses capybara to run jasmine specs with jasminerice and rails asset pipeline
- capybara >= 2.0
- jasminerice >= 0.0.10
- jasmine >= 1.1
- nokogiri >= 1.6
- colorize >= 0.8
- coffee-script >= 2.0
Rails 4.0 or greater ( currently this was tested only with Rails), but i can accept pull requests for other rack-based applications MRI >= 2.0
Rubinius, Jruby, MRI 1.8, MRI 1.9 are not officially supported.
Add it to your Gemfile
gem "jasminerice-runner"
For Jasmine <2.0 add this to your spec.js:
#= require jasminerice_runner_base
#= require jasminerice_legacy_reporter
For Jasmine > 2.0 add this to your spec.js:
#= require jasminerice_runner_base
#= require jasminerice_reporter
Then, run the rake task
rake jasminerice:run
To switch drivers, in a config/initializer
Jasminerice::Runner.configure do |config|
# you can use any other driver (phantomjs, or other drivers)
config.capybara_driver = :webkit
# For Jasmine < 2.0, this gem also provides a Junit XML formatter ( for Jasmine > 2.0 this will have no effect )
# If you want to enable the JUNIT XML Formatter you need to specify `:junit_xml`
# By Default this is set to nil, however if the environment variable CI is present and has as value 'true',
# and you are using Jasmine < 2.0, this will be automatically set to :junit_xml
# unless of course this is not overidden in a initializer
config.formatters = nil
# For Jasmine < 2.0, this gem also provides a Junit XML formatter ( for Jasmine > 2.0 this will have no effect )
config.junit_xml_path = File.join(Dir.pwd, 'spec', 'reports')
end
Default driver is :selenium*
Starting with version 2.0 , Jasmine supports custom formatters by using this configuration:
Jasmine.configure do |config|
config.formatters << Jasmine::Formatters::JunitXml
end
Put this configuration in a file located in config/initializers.
But in order for this to work , you will have to add the gem jasmine_junitxml_formatter to your Gemfile
If your app has multiple jasmine environments, you can specify the runner to only run jasmine tests for that environment. Adding an environment will run the file "#{ENVIRONMENT}_spec.js". The default spec file (spec.js) will be run if no environment is specified.
For example, if you wanted to run all specs in admin_spec.js the rake task would be:
rake jasminerice:run["admin"]