1. Install
sudo gem install rspec
sudo gem install rspec-rails
2. Create rails project (ep. blog)
rails blog
cd blog
3. Generate rspec dirs
ruby script/generate rspec
4. Generate rspec MVC files (ep. post)
model:
ruby script/generate rspec_mode Post title:string content:text
controller:
ruby script/generate rspec_controller Post title:string content:text
scaffold:
ruby script/generate rspec_scaffold Post title:string content:text
5. DB
rake db:migrate
rake db:migrate RAILS_ENV=test
6. Use auto test
autospec
7. Test a file
ruby -S bundle exec rspec ./spec/helpers/users_helper_spec.rb
8. Test models
rake spec:models
9. Test controllers
rake spec:controllers
10. Test all
rake spec
11. more pls to see "rake -T spec"
Wrapped assertions
assert_equal 'aaa', 'aaa':
'aaa'.should equal('aaa'), 'aaa'.should == 'aaa'
assert_not_equal 'aaa', 'bbb': 'bbb'.should_not equal('aaa'), 'bbb'.should_not == 'aaa'
assert_same: should be()
assert_not_same: should_not be()
assert_nil: should be_nil
assert_not_nil: should_not be_nil
assert_in_delta: should be_close
assert_match: should match(), should =~
assert_no_match: should_not match(), should.not =~
assert_instance_of: should be_an_instance_of()
assert_kind_of: should be_a_kind_of
assert_respond_to: should respond_to
assert_raise: should raise
assert_nothing_raised: should_not raise
assert_throws: should throw
assert_nothing_thrown: should_not throw
assert_block: should satisfy
Tree
- project
- |
- +—app
- |
- +—…
- |
- +—spec
- |
- +— spec_helper.rb
- |
- +— controllers
- |
- +— helpers
- |
- +— models
- |
- +— views
分享到:
相关推荐
rspec-mocks 是一个 rspec 的 test-double 框架,支持 method stubs, fakes 和生成 test-doubls 和类似真的对象的预期消息。 标签:rspec
自述文件 该自述文件通常会记录启动和运行应用程序所需的所有步骤。 您可能要讲的内容: Ruby版本 系统依赖 配置 数据库创建 数据库初始化 如何运行测试套件 服务(作业队列,缓存服务器,搜索引擎等) ...
Instant RSpec Test-Driven Development How-to – Free Pdf Book
RSpec supports Test Driven Development in Ruby through the BDD lens, keeping your focus on design and documentation while also supporting thorough testing and quick fault isolation. Cucumber, RSpec's...
安装gem install rspec # for rspec-core, rspec-expectations, rspec-mocksgem install rspec-mocks # for rspec-mocks only想要与main分支对抗吗? 您还需要包括相关的RSpec存储库。 将以下内容添加到您的Gemfile ...
Rails test described by RSpec
Fobless 键盘安全建筑物的自动访问要求带有电话号码的Redis安装使用电话号码设置输入 twilio 电话号码的请求网址运行bundle install 部署应用设置环境变量测试运行测试套件rspec test.rb配置必需的环境变量 ...
调整Plist到Junit ... $ rspec test/tuneup_plist_to_junit_utils_spec.rb 用法 要使用,只需使用 $ tuneup_plist_to_junit_parser Usage: TuneUpPlistToJunit.rb [options] Specific options: -i, --input FIL
i18n任务 i18n任务可帮助您查找和管理缺失和未使用的... 复制rspec test作为套件的一部分来测试缺失和未使用的翻译(可选): $ cp $( i18n-tasks gem-path ) /templates/rspec/i18n_spec.rb spec/ 或用于最小测试
db-query-matchers, 用于数据库查询的RSpec匹配器 db-query-matchers 用于数据库查询的RSpec匹配器。安装在你的应用程序中添加这一行,最好在你的test 组中:gem 'db-query-matchers'然后执行:bundle
添加rspec-rails ,以两个:development和:test组的应用程式中Gemfile : # Run against the latest stable releasegroup :development , :test do gem 'rspec-rails' , '~> 4.0.2'end# Or, run
将此添加到您的Gemfile中: gem 'rspec_api_helpers'然后执行: $ bundle或将其自己安装为: $ gem install rspec_api_helpers将其包含在您的spec_helper中 RSpec . configure do | config | # ... config . ...
旧的自述文件Testbot是一个测试分发工具,可与Rails,RSpec,RSpec2,Test :: Unit和Cucumber一起使用。 基本思想是让testbot将测试的负载分散到多台计算机上,以使测试运行更快。 在11台机器(25个内核)上使用...
手机编程20210311设置要求- Ruby: 2.7.2安装$ bundle install用法运行测试$ bundle exec rspec test.rb
flavor-gem generate rspec # adds rspec test flavor flavor-gem generate minitest # adds rails test macro flavor flavor-gem generate thor # adds thor flavor to make executable in bin to use it flavor-...
Your Ruby on Rails ...This new edition has been updated to Rails 5.2 and RSpec 3.7 and contains full coverage of new Rails features, including system tests and the Webpack-based JavaScript setup.
为Visual Studio Code(vscode)运行RSpec扩展 该扩展提供了基本命令,用于在内置vscode终端中运行规范文件。 特征 仅使用cmd + 1运行当前行(RSpec:RSpec上的运行行) 使用cmd + alt + l搜索并运行基于Spec的当前...
RSpec JUnit格式器 CI可以读取的 2和3结果。 , , , ,也许还有更多。用法安装gem: gem install rspec_junit_formatter 用它: ... group :test do gem "rspec" gem "rspec_junit_formatter"end 将与上述命令相同
欢迎@ packrat386作为rspec-sidekiq新维护者! Sidekiq的RSpec 通过匹配器和帮助器的集合对Sidekiq作业进行... 因此,仅在要求这种行为的环境(例如test组)中包括gem "rspec-sidekiq" 。 配置 如果要修改默认行为
group :test do gem 'mongoid-rspec' end 兼容性 该宝石与Mongoid 3、4、5、6和7兼容。 组态 滑轨 添加到您的rails_helper.rb文件 require 'mongoid-rspec' RSpec . configure do | config | config . include ...