Created
February 28, 2011 20:41
-
-
Save guilleiguaran/847989 to your computer and use it in GitHub Desktop.
RSpec+Capybara acceptance test example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# acceptance/acceptance_helper.rb | |
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | |
# Put your acceptance spec helpers inside /spec/acceptance/support | |
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# acceptance/support/database_cleaner.rb | |
require 'database_cleaner' | |
DatabaseCleaner.strategy = :truncation | |
RSpec.configure do |config| | |
config.use_transactional_fixtures = false | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# acceptance/support/helpers.rb | |
module HelperMethods | |
# Put helper methods you need to be available in all tests here. | |
def create_user | |
#User.create_with_omniauth(OmniAuth.config.mock_auth[:facebook]) | |
user = Factory(:user) | |
return user | |
end | |
end | |
RSpec.configuration.include HelperMethods, :type => :acceptance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# acceptance/support/paths.rb | |
module NavigationHelpers | |
# Put helper methods related to the paths in your application here. | |
def homepage | |
"/" | |
end | |
def login_page | |
"/auth/facebook" | |
end | |
def logout_page | |
"/logout" | |
end | |
end | |
RSpec.configuration.include NavigationHelpers, :type => :acceptance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# acceptance/users_login_spec.rb | |
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') | |
feature "Users Login", %q{ | |
In order to start using the page | |
As a potential user | |
I want to login using my Facebook account | |
} do | |
background do | |
end | |
scenario "I login in the page" do | |
visit login_page | |
page.should have_content('John') | |
page.should have_content('Logout') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment