I am trying to setup my Rails-Angular project to provide JS tests. I have tried almost everything what I have found in Google:
- Karma (formerly Testacular)
- Jasmine + Jasmine-headless-WebKit
- Jasminerice
- some other tuts
but I failed with all of them. I'm looking for way to run unit and e2e tests in most painless way (it can be in Guard or Karma, I don't care, but it must run it automatically in background).
Have anyone of you some nice article with nice example how to achieve this? In my research I have found this, but IMHO it is example how to NOT do this.
My actual Gemfile
:
source 'https://rubygems.org'
# Use Ruby 1.9.3 instead default Heroku's 1.9.2
# for development I suggest https://gist.github.com/1688857
ruby '1.9.3'
gem 'rails', '3.2.12'
# Use PostgreSQL, which is quite awesome, fast and easy
gem 'pg'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'bootstrap-sass', '~> 2.3.1'
# I heard that you like Compass
gem 'compass'
# Angular.js
gem 'angularjs-rails'
gem 'angularjs-rails-resource'
gem 'angular-ui-rails'
# Assets should be minified before production
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# Serve static pages like a boss
gem 'high_voltage'
# Some user management will be nice
gem 'devise' # User management
# gem 'cancan' # And they privileges
# To use Jbuilder templates for JSON
gem 'jbuilder'
# Be fast and deadly as Puma
#gem 'puma'
# We need also some administration panel, don't we?
gem 'rails_admin'
# Some helpers
gem 'andand'
group :development do
# IRb is ugly. Use Pry for the God's sake
gem 'pry-rails'
# Deploy with Capistrano
# gem 'capistrano'
# or Vlad the Deployer
# gem 'vlad'
# Why bother yourself with rerunning tests? Use Guard
gem 'guard'
gem 'guard-rspec'
gem 'guard-spork'
gem 'guard-livereload'
gem 'guard-jasmine'
gem 'rb-fsevent', require: false
gem 'rb-inotify', require: false
# Who like ugly error pages? We don't.
gem 'better_errors'
gem 'binding_of_caller'
# Prettier documentation
gem 'yard'
end
group :development, :test do
# Use RSpec for testing
gem 'rspec-rails', '~> 2.12.0'
# Test JS using Jasmine
gem 'jasmine'
gem 'jasmine-headless-webkit'
# Some DB table generator
gem 'factory_girl_rails', '~> 4.1.0'
# And fake data generator
gem 'ffaker'
end
group :test do
# Some Gherkins will be also good (to vodka of course)
gem 'turnip', '~> 1.1.0'
# Aww, an of course some web browser will be also apprised
gem 'capybara', '~> 2.0.1'
# Clean DB after tests
gem 'database_cleaner'
# Some nice matchers
gem 'shoulda-matchers'
# Extend your mocks
gem 'bourne', '~> 1.2.1'
# Coverage reports will be nice
gem 'simplecov', require: false
end
PS: It would be nice if I can create coverage reports in simple way.
Grunt
for our Angular project and these created coverage reports and xUnit outputs for CI (such as Jenkins); so does it matter that you have to run these tests from aGemfile
or can you throw somenodejs
into the mix? – Ahmed Nuaman 9 hours agoGemfile
to integrate that with Guard, but I'm not forced to that. Maybe even better will it be if I separate frontend tests from backend tests. So Grunt/Karma option is also nice. But I also want to have all tests inspec/
directory (if it is possible). – Łukasz Niemier 8 hours ago