Skip to content

Commit

Permalink
added capybara, guard and create part of the user flow integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
nrevko committed Jan 30, 2012
1 parent 876c9eb commit 5dc4404
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

# Ignore Rubymine created folder
.idea
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ gem 'jquery-rails'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :development, :test do
gem 'rspec-rails'
gem 'rspec-rails', :group => [:development, :test]
group :test do
gem "factory_girl_rails"
gem 'capybara'
gem 'launchy'
gem 'database_cleaner'
gem "guard-rspec"
gem "launchy"
gem "database_cleaner"
end
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ GEM
erubis (2.7.0)
execjs (1.2.13)
multi_json (~> 1.0)
factory_girl (2.5.0)
activesupport
factory_girl_rails (1.6.0)
factory_girl (~> 2.5.0)
railties (>= 3.0.0)
ffi (1.0.11)
guard (1.0.0)
ffi (>= 0.5.0)
thor (~> 0.14.6)
guard-rspec (0.6.0)
guard (>= 0.10.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
Expand Down Expand Up @@ -155,6 +165,8 @@ DEPENDENCIES
coffee-rails (~> 3.1.1)
database_cleaner
devise
factory_girl_rails
guard-rspec
jquery-rails
launchy
rails (= 3.1.3)
Expand Down
19 changes: 19 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end

4 changes: 4 additions & 0 deletions spec/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Factory.define :user do |f|
f.sequence(:email) { |n| "example0#{n}@example.com"}
f.password "test123"
end
61 changes: 61 additions & 0 deletions spec/requests/users_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require 'spec_helper'

describe "existing user", :js => true do

before(:each) do
@user = Factory(:user)
@user.confirm!

@event = Factory(:event)

end

it "should signin and edit his/her settings" do
visit new_user_session_path

fill_in "Email", :with => @user.email
fill_in "Password", :with => @user.password
click_button "Sign in"

page.should have_content("Signed in successfully")

page.should have_content("Become Volunteer")

click_link "Become A Volunteer"

page.should have_content("specify your skills")

check("Coordinating")
check("Teaching")
check("TAing")
check("Mentoring")
check("Childcaring")
check("Writing")
page.should have_content("Evangelizing")
page.should have_content("Other")

click_button "Submit"

page.should have_content("Thanks for submitting your skills")

@user.skills.should == ["Coordinating", "Teaching", "TAing", "Mentoring", "Hacking", "Designing", "Childcaring", "Writing"]

page.should have_content("Update your skills")

click_link "Update your skills"

page.should have_content("specify your skills")

uncheck("Hacking")
uncheck("Designing")

click_button "Submit"

page.should have_content("Thanks for submitting your skills")

@user.skills.should == ["Coordinating", "Teaching", "TAing", "Mentoring", "Childcaring", "Writing"]


end

end
11 changes: 10 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|

#Uncomment if need to write tests using devise helpers
#config.include Devise::TestHelpers, :type => :controller
#config.extend ControllerMacros, :type => :controller

# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
Expand All @@ -35,6 +39,11 @@
DatabaseCleaner.clean
end

config.mock_with :rspec
#config.use_transactional_fixtures = true

Rails.application.routes.default_url_options[:host] = 'localhost:3000'

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
Expand Down

0 comments on commit 5dc4404

Please sign in to comment.