rspec views测试

1 元素自定义的属性:assert_no_tag 'div', :attributes => {:class => 'admin-panel'}

2 if the response contains two ordered lists, each with four list elements then:

  assert_select "ol" do |elements|
    elements.each do |element|
      assert_select element, "li", 4
    end
  end
will pass, as will:

  assert_select "ol" do
    assert_select "li", 8
  end
3 Given a file named "spec/views/widgets/new.html.erb_spec.rb" with:
require "spec_helper"

describe "widgets/new" do
  it "infers the controller path" do
    controller.request.path_parameters[:action].should eq("new")
  end
end
When I run `rspec spec/views`
Then the examples should all pass

你可能感兴趣的:(assert,rspec)