Skip to content

Commit

Permalink
add some integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
siroj100 committed Sep 22, 2010
1 parent f942878 commit 7e629c4
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Address < ActiveRecord::Base
belongs_to :person
validates_presence_of :person

def to_s
street
end

# --- Permissions --- #

def create_permitted?
Expand Down
9 changes: 9 additions & 0 deletions test/factories/address.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'factory_girl'

Factory.define :address do |a|
a.street 'Jl. K.H. Ahmad Dahlan VI no 21F'
a.zip '16425'
a.city 'Depok'
a.country 'ID'
a.association :person
end
6 changes: 6 additions & 0 deletions test/factories/person.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'factory_girl'

Factory.define :person do |p|
p.name 'Sirajuddin Maizir'
p.sex 'male'
end
28 changes: 28 additions & 0 deletions test/integration/address_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require File.dirname(__FILE__) + '/../test_helper'

class AddressTest < ActionController::IntegrationTest
context 'An address of a person' do
setup do
@address = Factory(:address)
end

should 'be visible on person page' do
visit '/people'
click_link @address.person.name
assert_contain @address.street
end

should 'be able to see the details (street, zip, city, country code)' do
visit '/people'
click_link @address.person.name
click_link @address.street
assert_equal 200, status
assert_contain @address.street
assert_contain @address.zip
assert_contain @address.city
assert_contain @address.country
end

end
end

17 changes: 17 additions & 0 deletions test/integration/person_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require File.dirname(__FILE__) + '/../test_helper'

class PersonTest < ActionController::IntegrationTest
context 'A person' do
setup do
@person = Factory(:person)
end

should 'be visible on the web and clickable' do
visit '/people'
assert_contain @person.name
click_link @person.name
assert_equal 200, status
end
end
end

0 comments on commit 7e629c4

Please sign in to comment.