rails new test_app --skip-test-unit 不生成默认的test,稍后用rspec
cd test_app

修改Gemfile(大部分为自动生成)

source 'https://ruby.taobao.org' -- 使用淘宝镜像,因为连接不了rubygem

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1' --rails版本
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem "slim-rails" --能够让erb转slim
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment
# gem 'capistrano-rails', group: :development group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
gem 'rspec-rails', '3.5.1' -- 此处添加最新rspec
  # Use sqlite3 as the database for Active Record
 gem 'sqlite3'
end

group :test do -- 添加capybara及其依赖gem,能够编写类英语交互语句
gem 'selenium-webdriver', '~> 2.53', '>= 2.53.4'
gem 'capybara', '2.8.0'
end group :production do
gem 'pg', '~> 0.18.4'
end group :development do --heroku部署用
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

bundle install

bundle install --without production
bundle update
bundle install

生成rspec测试模块

rails generate rspec:install

push至git上

git init
git add .
git commit -m "Initial commit"
git remote add origin url
git push -u origin master

设置rails,让其服务于静态资源文件

config/environments/production.rb

TestApp::Application.configure do
.
.
.
config.serve_static_assets = true
.
.
.
end

spec测试文件:

require 'rails_helper'

RSpec.describe "StaticPages", :type => :feature do
describe "Home page" do
it "should have the content 'Help'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
end describe "Help page" do
it "should have the content 'Help'" do
visit '/static_pages/help'
expect(page).to have_content('Help')
end
end
end

测试语句

bundle exec rspec spec/requests/static_pages_spec.rb

启动rails

rails s

最新文章

  1. CocoaPods 1.1.0上传遇到swift问题
  2. 49. 3种方法实现复杂链表的复制[clone of complex linked list]
  3. 企业IT管理员IE11升级指南【1】—— Internet Explorer 11增强保护模式 (EPM) 介绍
  4. VS2012 单元测试之泛型类(Generics Unit Test)
  5. 访问图片可以使用闭包map
  6. Android Studio导入Fresco
  7. 了解OpenStack
  8. curl批量伪造数据
  9. GC日志分析
  10. 结合prototype和xmlhttprequest封装ajax请求
  11. VS2010在网络共享目录使用IntelliSense、ipch、sdf和SQL Compact Server相关问题
  12. B/S(Web)实时通讯解决方案
  13. Go语言--数组、切片、
  14. PPT母版制作
  15. [LeetCode]题1:two sum
  16. python成长之路六-函数的初识
  17. VC6下OpenGL 开发环境的构建外加一个简单的二维网络棋盘绘制示例
  18. 扯皮的cplex-感觉时间不对
  19. Java--普通代码块静态代码块执行顺序
  20. 基于 Lucene 的桌面文件搜索

热门文章

  1. 用javascript实现用户登录验证
  2. LeetCode Meeting Rooms
  3. iOS:iOS开发非常全的三方库、插件等等
  4. openni2 和opencv读取数据
  5. sdut2169:Sequence(dp)
  6. MySQL管理之道:性能调优、高可用与监控内置脚本
  7. window.open被浏览器拦截的解决方案
  8. C语言中malloc()和calloc()c函数用法
  9. Java 线程池的介绍以及工作原理
  10. Mysql 5.7.7