Skip to content

Commit a658413

Browse files
committed
Add Happy Path Smoke Test
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
1 parent 4f3b7c0 commit a658413

18 files changed

+198
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
*.o
1313
*.a
1414
mkmf.log
15+
/log/
16+
spec/dummy/my-app/

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--require spec_helper

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.2.3

.travis.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: ruby
2+
sudo: false
3+
cache: bundler
4+
5+
notifications:
6+
email: false
7+
8+
rvm:
9+
- 2.2.0
10+
- 2.1.0
11+
- 2.0.0
12+
13+
before_install:
14+
- qmake -version
15+
- "echo '--colour' > ~/.rspec"
16+
- "echo 'gem: --no-document' > ~/.gemrc"
17+
- export DISPLAY=:99.0
18+
- sh -e /etc/init.d/xvfb start
19+
before_script: bin/setup
20+
script: xvfb-run -a bin/rspec

Gemfile

+9
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@ source "https://rubygems.org"
22

33
gemspec
44

5+
gem "rails", "4.2.4"
56
gem "pry"
7+
8+
group :development, :test do
9+
gem "rspec-rails", "~> 3.3.0"
10+
end
11+
12+
group :test do
13+
gem "capybara-webkit", "~> 1.7.0"
14+
end

bin/bundle

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env ruby
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3+
load Gem.bin_path('bundler', 'bundle')

bin/rspec

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env ruby
2+
#
3+
# This file was generated by Bundler.
4+
#
5+
# The application 'rspec' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'pathname'
10+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11+
Pathname.new(__FILE__).realpath)
12+
13+
require 'rubygems'
14+
require 'bundler/setup'
15+
16+
load Gem.bin_path('rspec-core', 'rspec')

bin/setup

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Set up Ruby dependencies via Bundler
6+
gem install bundler --conservative
7+
bundle check || bundle install
8+
9+
# Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
10+
mkdir -p .git/safe
11+
12+
if ! command -v bower > /dev/null; then
13+
npm install -g bower
14+
fi
15+
16+
if ! [ -d spec/dummy/my-app ]; then
17+
git clone https://github.com/kellyselden/ember-cli-output.git spec/dummy/my-app
18+
fi
19+
20+
root="$(pwd)"
21+
22+
cd ${root}/spec/dummy/my-app &&
23+
npm install --save-dev ember-cli-rails-addon &&
24+
bower install
25+
26+
cd ${root}/spec/dummy && bundle exec rake ember:install

spec/dummy/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!.keep
2+
*.DS_Store
3+
*.swo
4+
*.swp
5+
/.bundle
6+
/.env
7+
/.foreman
8+
/coverage/*
9+
/db/*.sqlite3
10+
/log/*
11+
/public/system
12+
/public/assets
13+
/tags
14+
/tmp/*

spec/dummy/Rakefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require File.expand_path("../application", __FILE__)
2+
3+
Rails.application.load_tasks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class ApplicationController < ActionController::Base
2+
# Prevent CSRF attacks by raising an exception.
3+
# For APIs, you may want to use :null_session instead.
4+
protect_from_forgery with: :exception
5+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%= include_ember_script_tags "my-app" %>
2+
<%= include_ember_stylesheet_tags "my-app" %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Dummy</title>
5+
<%= csrf_meta_tags %>
6+
</head>
7+
<body>
8+
9+
<%= yield %>
10+
11+
</body>
12+
</html>

spec/dummy/application.rb

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require "rails"
2+
3+
require "action_controller/railtie"
4+
require "action_view/railtie"
5+
require "sprockets/railtie"
6+
7+
Bundler.require(*Rails.groups)
8+
9+
module Dummy
10+
class Application < Rails::Application
11+
config.root = File.expand_path("..", __FILE__).freeze
12+
config.eager_load = false
13+
14+
# Show full error reports and disable caching.
15+
config.consider_all_requests_local = true
16+
config.action_controller.perform_caching = false
17+
18+
# Raise exceptions instead of rendering exception templates.
19+
config.action_dispatch.show_exceptions = false
20+
21+
# Randomize the order test cases are executed.
22+
config.active_support.test_order = :random
23+
24+
# Print deprecation notices to the stderr.
25+
config.active_support.deprecation = :stderr
26+
27+
config.assets.enabled = true
28+
config.assets.debug = true
29+
config.assets.digest = true
30+
config.assets.raise_runtime_errors = true
31+
config.assets.version = "1.0"
32+
33+
config.secret_token = "SECRET_TOKEN_IS_MIN_30_CHARS_LONG"
34+
config.secret_key_base = "SECRET_KEY_BASE"
35+
36+
def require_environment!
37+
initialize!
38+
end
39+
end
40+
end
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
EmberCLI.configure do |c|
2+
c.app "my-app"
3+
end

spec/dummy/config/routes.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Rails.application.routes.draw do
2+
root to: "application#index"
3+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
feature "User views ember app", :js do
2+
scenario "from root" do
3+
visit root_path
4+
5+
expect(page).to have_text "Welcome to Ember"
6+
end
7+
end

spec/spec_helper.rb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ENV["RAILS_ENV"] = "test"
2+
3+
require "dummy/application"
4+
5+
require "rspec/rails"
6+
7+
Dummy::Application.initialize!
8+
9+
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file }
10+
11+
RSpec.configure do |config|
12+
config.expect_with :rspec do |expectations|
13+
expectations.syntax = :expect
14+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
15+
end
16+
17+
config.mock_with :rspec do |mocks|
18+
mocks.syntax = :expect
19+
mocks.verify_partial_doubles = true
20+
end
21+
22+
config.infer_spec_type_from_file_location!
23+
config.order = :random
24+
end
25+
26+
Capybara::Webkit.configure do |config|
27+
config.block_unknown_urls = true
28+
end
29+
30+
Capybara.javascript_driver = :webkit

0 commit comments

Comments
 (0)