rspec rspec
程序员文章站
2024-02-22 19:10:16
...
let(:blog){Blog.new} before(:each) do; blog=Blog.new; end
its(:title){should == nil} @blog=Blog.new;@blog.title.should == nil
[1,2,3].should include(1) [1,2,3].include?(1).should == true
{a: 1, b:2}.should have_key(:a) {a: 1, b: 2}[:a].should_not == nil
[1,2,3].should have(3).items
blog.should be_real blog.real?.should == true
expect{@blog.update_attribute(title: 'title')}.to change(@blog.title).from(nil).to("title")
expect{1/0}.to rails_error(ZeroDivisionError)
subject{Blog.new}; it/specify/example{should be_new_record}
subject{Blog.new(title: 1)}; its(:title){should == 1}
@customer = stub("customer"); @customer.stub(:name).and_return('zcy')
@customer.stub_chain(:foo, :bar, :baz).and_return("blah")
its(:title){should == nil} @blog=Blog.new;@blog.title.should == nil
[1,2,3].should include(1) [1,2,3].include?(1).should == true
{a: 1, b:2}.should have_key(:a) {a: 1, b: 2}[:a].should_not == nil
[1,2,3].should have(3).items
blog.should be_real blog.real?.should == true
expect{@blog.update_attribute(title: 'title')}.to change(@blog.title).from(nil).to("title")
expect{1/0}.to rails_error(ZeroDivisionError)
subject{Blog.new}; it/specify/example{should be_new_record}
subject{Blog.new(title: 1)}; its(:title){should == 1}
@customer = stub("customer"); @customer.stub(:name).and_return('zcy')
@customer.stub_chain(:foo, :bar, :baz).and_return("blah")
推荐阅读
-
rspec rspec
-
Ruby on rails 创建基于Rspec项目 博客分类: ROR rspecrailsruby
-
rspec controller测试 博客分类: 【tec】rails测试 renderresponserspec
-
从JUnit到Rspec的尝试 博客分类: rails rspecjunit
-
RSpec-Core 2.6 博客分类: Ruby 测试rspec
-
RSpec-Core 2.6 博客分类: Ruby 测试rspec
-
ruby , rspec中测试 module rubyrspecmodule
-
Ruby配置rspec和RestClient来检测服务器
-
[ Ruby on Rails ] Rspec and Rails Gem
-
在rspec里使用 route path