从Test :: Unit切换到RSpec / FactoryGirl

时间:2014-04-18 18:40:52

标签: ruby-on-rails ruby unit-testing rspec

我有一个示例设置演示Test :: Unit的测试。我想使用RSpec和FactoryGirl来完成与此示例相同的操作。我似乎无法完成这项任务,所以任何帮助都会受到赞赏!

终端

$ rails new lab
$ cd lab
$ rails g model foo bar:integer
$ open test/unit/foo_test.rb

红宝石

#insert into test/unit/foo_test.rb
test "example test" do
  assert_not_nil foos(:one).bar, "FooBar is Nil"
  assert_instance_of Fixnum, foos(:one).bar, "FooBar isn't a Fixnum"
  assert_equal 1, foos(:one).bar, "Foobar != 1"
end

终端

$ rake db:migrate
$ rake test

输出

Run options: 

# Running tests:

.

Finished tests in 0.109820s, 9.1058 tests/s, 27.3174 assertions/s.

1 tests, 3 assertions, 0 failures, 0 errors, 0 skips

0 个答案:

没有答案