Skip to content

Instantly share code, notes, and snippets.

@markfeedly
Created October 10, 2013 14:38
Show Gist options
  • Save markfeedly/6919434 to your computer and use it in GitHub Desktop.
Save markfeedly/6919434 to your computer and use it in GitHub Desktop.
I have no idea why I'm getting failures
......F.FF.
Failures:
1) User pages User profile page url, title and basic content it should behave like Basic Page should have a specific title
Failure/Error: should have_title("#{base_title}#{title}")
expected #has_title?("Ruby on Rails Tutorial Sample App | John Lennon") to return true, got false
Shared Example Group: "Basic Page" called from ./spec/requests/user_pages_spec.rb:68
# ./spec/support/shared/basic_page_helper.rb:16:in `block (2 levels) in <top (required)>'
2) User pages User profile page microposts
Failure/Error: it { page.should have_content(m2.content) }
expected #has_content?("Bar") to return true, got false
# ./spec/requests/user_pages_spec.rb:78:in `block (4 levels) in <top (required)>'
3) User pages User profile page microposts
Failure/Error: it { page.should have_content(m1.content) }
expected #has_content?("Foo") to return true, got false
# ./spec/requests/user_pages_spec.rb:77:in `block (4 levels) in <top (required)>'
Finished in 1.43 seconds
11 examples, 3 failures
Failed examples:
rspec ./spec/support/shared/basic_page_helper.rb:14 # User pages User profile page url, title and basic content it should behave like Basic Page should have a specific title
rspec ./spec/requests/user_pages_spec.rb:78 # User pages User profile page microposts
rspec ./spec/requests/user_pages_spec.rb:77 # User pages User profile page microposts
require 'spec_helper'
describe "User pages" do
describe 'Sign up' do
#let(:url){signup_path}
#let(:title){"| Sign up"}
#let(:content){"Sign up"}
#it_should_behave_like "Basic Page"
it 'should have a registration page' do
visit new_user_registration_path
page.should have_content('Sign up')
end
end
describe 'Sign in' do
it 'should have a sign in page' do
visit new_user_registration_path
page.should have_content('Password confirmation')
end
end
describe "Profile edit page" do
def sign_up_with email, password
visit '/users/sign_up' #sign_up_path
fill_in 'user_email', with: email
fill_in 'user_password', with: password
fill_in 'user_password_confirmation', with: password
click_button 'Sign up'
end
def user_signed_in
expect(page).to have_content('Sign out')
end
before do
sign_up_with 'l2@a.com', '11111111'
visit edit_user_registration_path
end
subject { page }
describe "Should exist and include specific content" do
it { user_signed_in }
it { current_path.should == '/users/edit' } # fragile but I like the failure message with expected and got
it { should have_content("Edit your profile") }
# it { should have_link('change', href: 'http://gravatar.com/emails') }
end
describe "Can't update without the user's current password" do #redundant test of well known gem
before { click_button "Update" } # so stylistically why not just click_button 'Update' ?
it { should have_content('error') }
end
end
describe "User profile page" do
let(:user) { FactoryGirl.create(:user) }
describe "url, title and basic content" do
let(:url) { user_path(user) }
let(:title) { "| #{user.name}" } # pass /fail is order dependent
let(:content) { "microposts" }
it_should_behave_like "Basic Page"
end
describe "microposts" do
let!(:m1) { FactoryGirl.create(:micropost, user_id: 1, content: "Foo") } # fails
let!(:m2) { FactoryGirl.create(:micropost, user: user, content: "Bar") } # fails
before { visit user_path(user) }
it { page.should have_content(m1.content) }
it { page.should have_content(m2.content) }
it { page.should have_content(user.microposts.count) }
end
end
end
<% provide(:title, current_user.name ) %>
<h1><%= current_user.name %></h1>
<h2><%= "#{current_user.microposts.count}" %> microposts</h2>
<ol class="microposts">
<%- current_user.microposts.each do |m| %>
<li><%= "#{m.content}" %> </li>
<% end -%>
</ol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment