Permalink
Browse files

pretty up rspec

  • Loading branch information...
nawakkap committed Mar 11, 2012
1 parent 757f160 commit d347ebf117f1e5e51b40773c2c3f2e15bf97d53e
@@ -5,8 +5,8 @@
</small>
<nav>
<ul>
- <li><%= link_to "About", '#' %></li>
- <li><%= link_to "Contact", '#' %></li>
+ <li><%= link_to "About", about_path %></li>
+ <li><%= link_to "Contact", contact_path %></li>
<li><a href="http://news.railstutorial.org/">News</a></li>
</ul>
</nav>
@@ -1,11 +1,11 @@
<header class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
- <%= link_to "sample app", '#', id: "logo"%>
+ <%= link_to "sample app", root_path, id: "logo"%>
<nav>
<ul class="nav pull-right">
- <li><%=link_to "Home", '#'%></li>
- <li><%=link_to "Help", '#'%></li>
+ <li><%=link_to "Home", root_path%></li>
+ <li><%=link_to "Help", help_path%></li>
<li><%=link_to "Sign in", '#'%></li>
</ul>
</nav>
@@ -1,4 +1,3 @@
-<% provide(:title, 'Home')%>
<div class="center hero-unit">
<h1>Welcome to the Sample App</h1>
@@ -2,64 +2,34 @@
describe "Static pages" do
- describe "Home page" do
-
- it "should have the h1 'Sample App'" do
- visit root_path
- page.should have_selector('h1', text: 'Sample App')
- end
+ subject { page }
- it "should have the base title" do
- visit root_path
- page.should have_selector('title',
- text: "Ruby on Rails Tutorial Sample App")
- end
+ describe "Home page" do
+ before { visit root_path }
- it "should not have a custom page title" do
- visit root_path
- page.should_not have_selector('title', text: '| Home')
- end
+ it { should have_selector('h1', text: 'Sample App') }
+ it { should have_selector('title', text: full_title('')) }
+ it { should_not have_selector 'title', text: '| Home' }
end
describe "Help page" do
+ before { visit help_path }
- it "should have the h1 'Help'" do
- visit help_path
- page.should have_selector('h1', text: 'Help')
- end
-
- it "should have the title 'Help'" do
- visit help_path
- page.should have_selector('title',
- text: "Ruby on Rails Tutorial Sample App | Help")
- end
+ it { should have_selector('h1', text: 'Help') }
+ it { should have_selector('title', text: full_title('Help')) }
end
describe "About page" do
+ before { visit about_path }
- it "should have the h1 'About'" do
- visit about_path
- page.should have_selector('h1', text: 'About Us')
- end
-
- it "should have the title 'About Us'" do
- visit about_path
- page.should have_selector('title',
- text: "Ruby on Rails Tutorial Sample App | About Us")
- end
+ it { should have_selector('h1', text: 'About') }
+ it { should have_selector('title', text: full_title('About Us')) }
end
describe "Contact page" do
+ before { visit contact_path }
- it "should have the h1 'Contact'" do
- visit contact_path
- page.should have_selector('h1', text: 'Contact')
- end
-
- it "should have the title 'Contact'" do
- visit contact_path
- page.should have_selector('title',
- text: "Ruby on Rails Tutorial Sample App | Contact")
- end
+ it { should have_selector('h1', text: 'Contact') }
+ it { should have_selector('title', text: full_title('Contact')) }
end
end
@@ -0,0 +1,8 @@
+def full_title(page_title)
+ base_title = "Ruby on Rails Tutorial Sample App"
+ if page_title.empty?
+ base_title
+ else
+ "#{base_title} | #{page_title}"
+ end
+end

0 comments on commit d347ebf

Please sign in to comment.