Skip to content

Instantly share code, notes, and snippets.

@yohm
Last active December 17, 2015 05:48
Show Gist options
  • Save yohm/5560193 to your computer and use it in GitHub Desktop.
Save yohm/5560193 to your computer and use it in GitHub Desktop.
capybaraを使ってfeature specを書いてみた。
require 'spec_helper'
describe "simulators pages", js: false do
before(:each) do
@sim = FactoryGirl.create(:simulator,
parameter_sets_count: 1,
runs_count: 3,
analyzers_count: 0
)
end
describe "index page" do
before(:each) do
visit simulators_path
end
it "shows 'Simulators' in page-header" do
within('.page-header') do
page.should have_content("Simulators")
end
# page.save_screenshot('screenshot.png')
end
it "has table of registered simulators" do
page.should have_selector('table')
within('table') do
find_link(@sim.name)[:href].should eq(simulator_path(@sim))
end
end
end
describe "show page" do
before(:each) do
visit simulator_path(@sim)
end
it "displays name of the simulator in page-header" do
within('.page-header') do
page.should have_content(@sim.name)
page.should_not have_content('Simulators')
end
end
it "has breadcrumb list" do
within('.breadcrumb') do
page.should have_content('Simulators')
page.should have_content(@sim.name)
find_link(@sim.name)[:href].should eq(simulator_path(@sim))
end
end
it "has a table of parameter_sets" do
page.should have_selector('table#parameter_sets_table')
within('.table#parameter_sets_table') do
ps = @sim.parameter_sets.first
page.should have_content(ps.id)
find_link(ps.id)[:href].should eq(parameter_set_path(ps))
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment