Skip to content

Commit

Permalink
Add Happy Path Smoke Test
Browse files Browse the repository at this point in the history
Embed a Rails application in `spec/dummy`.

Configure `capybara-webkit` for CI according to old [suspenders]
configuration.

Embed an EmberCLI application in `spec/dummy/my-app`. Exclude from
version control. When running `bin/setup`, a generated EmberCLI will be
cloned from [kellyselden/ember-cli-output].

[suspenders]: thoughtbot/suspenders@ac3924d
[kellyselden/ember-cli-output]: https://github.com/kellyselden/ember-cli-output
  • Loading branch information
seanpdoyle committed Oct 27, 2015
1 parent 4f3b7c0 commit a658413
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
*.o
*.a
mkmf.log
/log/
spec/dummy/my-app/
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.3
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
16 changes: 16 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -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')
26 changes: 26 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions spec/dummy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
!.keep
*.DS_Store
*.swo
*.swp
/.bundle
/.env
/.foreman
/coverage/*
/db/*.sqlite3
/log/*
/public/system
/public/assets
/tags
/tmp/*
3 changes: 3 additions & 0 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require File.expand_path("../application", __FILE__)

Rails.application.load_tasks
5 changes: 5 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions spec/dummy/app/views/application/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= include_ember_script_tags "my-app" %>
<%= include_ember_stylesheet_tags "my-app" %>
12 changes: 12 additions & 0 deletions spec/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>
40 changes: 40 additions & 0 deletions spec/dummy/application.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions spec/dummy/config/initializers/ember.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EmberCLI.configure do |c|
c.app "my-app"
end
3 changes: 3 additions & 0 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rails.application.routes.draw do
root to: "application#index"
end
7 changes: 7 additions & 0 deletions spec/features/user_views_ember_app_spec.rb
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a658413

Please sign in to comment.