diff --git a/.gitignore b/.gitignore index ae3fdc29..957f69ad 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ *.o *.a mkmf.log +/log/ +spec/dummy/my-app/ diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..83e16f80 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..58594069 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.2.3 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..bae50f23 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: ruby +sudo: false +cache: bundler + +notifications: + email: false + +rvm: +- 2.2.0 +- 2.1.0 +- 2.0.0 + +before_install: + - qmake -version + - "echo '--colour' > ~/.rspec" + - "echo 'gem: --no-document' > ~/.gemrc" + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start +before_script: bin/setup +script: xvfb-run -a bin/rspec diff --git a/Gemfile b/Gemfile index 7c38f02f..8ba739c2 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,13 @@ source "https://rubygems.org" gemspec +gem "rails", "4.2.4" gem "pry" + +group :development, :test do + gem "rspec-rails", "~> 3.3.0" +end + +group :test do + gem "capybara-webkit", "~> 1.7.0" +end diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 00000000..66e9889e --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 00000000..0c86b5c6 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('rspec-core', 'rspec') diff --git a/bin/setup b/bin/setup new file mode 100755 index 00000000..930fcc21 --- /dev/null +++ b/bin/setup @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +# Set up Ruby dependencies via Bundler +gem install bundler --conservative +bundle check || bundle install + +# Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv +mkdir -p .git/safe + +if ! command -v bower > /dev/null; then + npm install -g bower +fi + +if ! [ -d spec/dummy/my-app ]; then + git clone https://github.com/kellyselden/ember-cli-output.git spec/dummy/my-app +fi + +root="$(pwd)" + +cd ${root}/spec/dummy/my-app && + npm install --save-dev ember-cli-rails-addon && + bower install + +cd ${root}/spec/dummy && bundle exec rake ember:install diff --git a/spec/dummy/.gitignore b/spec/dummy/.gitignore new file mode 100644 index 00000000..1a572b5c --- /dev/null +++ b/spec/dummy/.gitignore @@ -0,0 +1,14 @@ +!.keep +*.DS_Store +*.swo +*.swp +/.bundle +/.env +/.foreman +/coverage/* +/db/*.sqlite3 +/log/* +/public/system +/public/assets +/tags +/tmp/* diff --git a/spec/dummy/Rakefile b/spec/dummy/Rakefile new file mode 100644 index 00000000..b48da4e5 --- /dev/null +++ b/spec/dummy/Rakefile @@ -0,0 +1,3 @@ +require File.expand_path("../application", __FILE__) + +Rails.application.load_tasks diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb new file mode 100644 index 00000000..d83690e1 --- /dev/null +++ b/spec/dummy/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/spec/dummy/app/views/application/index.html.erb b/spec/dummy/app/views/application/index.html.erb new file mode 100644 index 00000000..8d07285c --- /dev/null +++ b/spec/dummy/app/views/application/index.html.erb @@ -0,0 +1,2 @@ +<%= include_ember_script_tags "my-app" %> +<%= include_ember_stylesheet_tags "my-app" %> diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb new file mode 100644 index 00000000..bdb7dd94 --- /dev/null +++ b/spec/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,12 @@ + + + + Dummy + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/spec/dummy/application.rb b/spec/dummy/application.rb new file mode 100644 index 00000000..31d350ec --- /dev/null +++ b/spec/dummy/application.rb @@ -0,0 +1,40 @@ +require "rails" + +require "action_controller/railtie" +require "action_view/railtie" +require "sprockets/railtie" + +Bundler.require(*Rails.groups) + +module Dummy + class Application < Rails::Application + config.root = File.expand_path("..", __FILE__).freeze + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Randomize the order test cases are executed. + config.active_support.test_order = :random + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + config.assets.enabled = true + config.assets.debug = true + config.assets.digest = true + config.assets.raise_runtime_errors = true + config.assets.version = "1.0" + + config.secret_token = "SECRET_TOKEN_IS_MIN_30_CHARS_LONG" + config.secret_key_base = "SECRET_KEY_BASE" + + def require_environment! + initialize! + end + end +end diff --git a/spec/dummy/config/initializers/ember.rb b/spec/dummy/config/initializers/ember.rb new file mode 100644 index 00000000..9f072cad --- /dev/null +++ b/spec/dummy/config/initializers/ember.rb @@ -0,0 +1,3 @@ +EmberCLI.configure do |c| + c.app "my-app" +end diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb new file mode 100644 index 00000000..4cce18b5 --- /dev/null +++ b/spec/dummy/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + root to: "application#index" +end diff --git a/spec/features/user_views_ember_app_spec.rb b/spec/features/user_views_ember_app_spec.rb new file mode 100644 index 00000000..ba41148c --- /dev/null +++ b/spec/features/user_views_ember_app_spec.rb @@ -0,0 +1,7 @@ +feature "User views ember app", :js do + scenario "from root" do + visit root_path + + expect(page).to have_text "Welcome to Ember" + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..4dc5beac --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,30 @@ +ENV["RAILS_ENV"] = "test" + +require "dummy/application" + +require "rspec/rails" + +Dummy::Application.initialize! + +Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file } + +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + expectations.syntax = :expect + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.syntax = :expect + mocks.verify_partial_doubles = true + end + + config.infer_spec_type_from_file_location! + config.order = :random +end + +Capybara::Webkit.configure do |config| + config.block_unknown_urls = true +end + +Capybara.javascript_driver = :webkit