Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated tests for new layout tweaks

  • Loading branch information...
commit e81121ffc374b4a3e980ace27891ae2a2a56b34e 1 parent 1bb56a7
@jcasimir authored
View
11 spec/integration/email_addresses_views_spec.rb
@@ -8,7 +8,7 @@
describe "when looking at the new email address form" do
- before(:all) do
+ before(:each) do
visit new_email_address_path(:person_id => @person.id)
end
@@ -19,6 +19,10 @@
current_path.should == person_path(@person)
page.should have_selector('li', :text => sample_address)
end
+
+ it "should show the contact's name in the title" do
+ page.should have_selector("h1", :text => "#{@person.last_name}, #{@person.first_name}")
+ end
end
describe "when looking at the edit email address form" do
@@ -27,6 +31,11 @@
visit edit_email_address_path(@person.email_addresses.first)
end
+ it "should show the contact's name in the title" do
+ page.should have_selector("h1", :text => "#{@person.last_name}, #{@person.first_name}")
+ end
+
+
it "should redirect to the person's page and show the edited data" do
new_address = "john@doe.com"
page.fill_in("email_address_address", :with => new_address)
View
45 spec/integration/phone_numbers_views_spec.rb
@@ -0,0 +1,45 @@
+require 'spec_helper'
+require 'capybara/rspec'
+
+describe "the views for phone numberes", :type => :request do
+ before(:all) do
+ @person = Person.create(:first_name => "John", :last_name => "Doe")
+ end
+
+ describe "when looking at the new phone number form" do
+ before(:each) do
+ visit new_phone_number_path(:person_id => @person.id)
+ end
+
+ it "should redirect to the person's page after successful submission" do
+ sample_number = "2023334444"
+ page.fill_in("phone_number_number", :with => sample_number)
+ page.click_button("phone_number_submit")
+ current_path.should == person_path(@person)
+ page.should have_selector('li', :text => sample_number)
+ end
+
+ it "should show the contact's name in the title" do
+ page.should have_selector("h1", :text => "#{@person.last_name}, #{@person.first_name}")
+ end
+ end
+
+ describe "when looking at the edit phone number form" do
+ before(:all) do
+ @person.phone_numbers.create(:number => "4445556767")
+ visit edit_phone_number_path(@person.phone_numbers.first)
+ end
+
+ it "should show the contact's name in the title" do
+ page.should have_selector("h1", :text => "#{@person.last_name}, #{@person.first_name}")
+ end
+
+ it "should redirect to the person's page and show the edited data" do
+ new_number = "7778888787"
+ page.fill_in("phone_number_number", :with => new_number)
+ page.click_button("phone_number_submit")
+ current_path.should == person_path(@person)
+ page.should have_selector('li', :text => new_number)
+ end
+ end
+end
View
4 spec/models/person_spec.rb
@@ -10,6 +10,10 @@
@person.should be_valid
end
+ it "should convert to a string with last name, first name" do
+ @person.to_s.should == "Doe, John"
+ end
+
it "should not be valid without a first name" do
@person.first_name = nil
@person.should_not be_valid
Please sign in to comment.
Something went wrong with that request. Please try again.