Permalink
Browse files

refactored testing

  • Loading branch information...
1 parent d99f08a commit fdcdc73c177479ec505c1702e44a1905cd44d97a Andy committed May 23, 2012
Showing with 37 additions and 11 deletions.
  1. +1 −1 app/views/static_pages/home.html.erb
  2. +2 −2 app/views/users/new.html.erb
  3. +34 −8 spec/requests/static_pages_spec.rb
@@ -5,7 +5,7 @@
Here you can do stuff.
</h2>
- <%= link_to "Sign up now!", signup_path, class: "btn btn-large btn-primary" %>
+ <%= link_to "Sign up", signup_path, class: "btn btn-large btn-primary" %>
</div>
<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
@@ -1,3 +1,3 @@
-<% provide(:title, 'Sign up') %>
-<h1>Sign up</h1>
+<% provide(:title, 'Sign Up') %>
+<h1>Sign Up</h1>
<p>Find me in app/views/users/new.html.erb</p>
@@ -3,28 +3,54 @@
describe "Static pages" do
let(:page_title_base) { "SndStream" }
subject { page }
+
+ shared_examples_for "all static pages" do
+ it { should have_selector 'h1', text: heading }
+ it { should have_selector 'title', text: full_title(page_title) }
+ end
+
describe "Home page" do
before { visit root_path }
- it { should have_selector 'h1', text: 'SndStream' }
- it { should have_selector 'title', text: full_title('') }
+ let(:heading) { 'SndStream' }
+ let(:page_title) { '' }
+
+ it_should_behave_like "all static pages"
it { should_not have_selector 'title', text: " | Home" }
end
describe "Help page" do
before { visit help_path }
- it { should have_selector 'h1', text: 'Help' }
- it { should have_selector 'title', text: full_title('Help') }
+ let(:heading) { 'Help' }
+ let(:page_title) { 'Help' }
+ it_should_behave_like "all static pages"
end
describe "About page" do
before { visit about_path }
- it { should have_selector 'h1', text: 'About' }
- it { should have_selector 'title', text: full_title('About') }
+ let(:heading) { 'About' }
+ let(:page_title) { 'About' }
+ it_should_behave_like "all static pages"
end
describe "Contact page" do
before { visit contact_path }
- it { should have_selector 'h1', text: 'Contact' }
- it { should have_selector 'title', text: full_title('Contact') }
+ let(:heading) { 'Contact' }
+ let(:page_title) { 'Contact' }
+ it_should_behave_like "all static pages"
+ end
+
+ it "should have the right links on the layout " do
+ visit root_path
+ click_link "About"
+ page.should have_selector 'title', text: full_title('About')
+ click_link "Help"
+ page.should have_selector 'title', text: full_title('Help')
+ click_link "Contact"
+ page.should have_selector 'title', text: full_title('Contact')
+ click_link "Home"
+ click_link "Sign up"
+ page.should have_selector 'title', text: full_title('Sign Up')
+ click_link "SndStream"
+ page.should have_selector 'title', text: full_title('')
end
end

0 comments on commit fdcdc73

Please sign in to comment.