在主页我有:
汽车:
<select id="cars">
<option value="volvo">Volvo </option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi </option>
</select>
Run Code Online (Sandbox Code Playgroud)
static_pages_spec.rb中的测试代码:
it "should have the right select" do
visit home_path
it { should have_select('cars', :options => ['volvo', 'saab','mercedes','audi'])}
end
Run Code Online (Sandbox Code Playgroud)
回应是
rspec ./spec/requests/static_pages_spec.rb:21 # Static pages Home page should have the right select
Run Code Online (Sandbox Code Playgroud)