Skip to content

Commit

Permalink
Initial steak test environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveyken committed Dec 17, 2011
1 parent 570a674 commit fdb6a43
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ group :development, :test do
gem 'rspec-rails', '>= 2.5.0'
gem 'ffaker', '>= 1.5.0'
gem 'factory_girl', '>= 1.3.3'
gem 'steak', '~> 2.0.0'
gem 'headless', '~> 0.2.2'
end

group :test do
Expand Down
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ GEM
activerecord (>= 3.0.7)
awesome_print (1.0.1)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.2.3)
ffi (~> 1.0.6)
cocaine (0.2.1)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
Expand All @@ -60,11 +69,13 @@ GEM
factory_girl (~> 2.3.0)
railties (>= 3.0.0)
ffaker (1.10.1)
ffi (1.0.11)
fuubar (0.0.6)
rspec (~> 2.0)
rspec-instafail (~> 0.1.8)
ruby-progressbar (~> 0.0.10)
haml (3.1.4)
headless (0.2.2)
hike (1.2.1)
i18n (0.6.0)
json (1.6.3)
Expand All @@ -80,6 +91,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
nokogiri (1.5.0)
paperclip (2.4.5)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
Expand Down Expand Up @@ -151,12 +163,18 @@ GEM
ruby-progressbar (0.0.10)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.5)
sass (3.1.11)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
selenium-webdriver (2.15.0)
childprocess (>= 0.2.1)
ffi (~> 1.0.9)
multi_json (~> 1.0.4)
rubyzip
simple_form (1.5.2)
actionpack (~> 3.0)
activemodel (~> 3.0)
Expand All @@ -168,6 +186,9 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
steak (2.0.0)
capybara (>= 1.0.0)
rspec-rails (>= 2.5.0)
test-unit (2.4.3)
therubyracer (0.9.9)
libv8 (~> 3.3.10)
Expand All @@ -185,6 +206,8 @@ GEM
rack
raindrops (~> 0.6)
will_paginate (3.0.2)
xpath (0.1.4)
nokogiri (~> 1.3)

PLATFORMS
ruby
Expand All @@ -202,6 +225,7 @@ DEPENDENCIES
ffaker (>= 1.5.0)
fuubar
haml (>= 3.1.1)
headless (~> 0.2.2)
paperclip (~> 2.4.5)
pg (>= 0.9.0)
prototype-rails (>= 3.1.0)
Expand All @@ -212,6 +236,7 @@ DEPENDENCIES
sass-rails (~> 3.1.1)
simple_form (~> 1.5.2)
simplecov
steak (~> 2.0.0)
test-unit (~> 2.4.3)
therubyracer
uglifier
Expand Down
22 changes: 22 additions & 0 deletions acceptance/acceptance_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require File.expand_path("../../spec/spec_helper.rb", __FILE__)

# Put your acceptance spec helpers inside spec/acceptance/support
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

# Workaround for ActionDispatch::ClosedError
# https://github.com/binarylogic/authlogic/issues/262#issuecomment-1804988
User.acts_as_authentic_config[:maintain_sessions] = false

if ENV['HEADLESS'] == 'true'
require 'headless'
headless = Headless.new
headless.start
HEADLESS_DISPLAY = ":#{headless.display}"
at_exit do
headless.destroy
end
puts "Running in Headless mode. Display #{HEADLESS_DISPLAY}"
end

# Default timeout for extended for AJAX based application
Capybara.default_wait_time = 7
30 changes: 30 additions & 0 deletions acceptance/accounts_feature_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require File.expand_path("../acceptance_helper.rb", __FILE__)

feature 'Accounts feature', %q{
In order to increase customer satisfaction
As a user
I want to manage accounts
} do

before(:each) do
do_login
end

scenario 'should view a list of accounts' do
2.times { |i| Factory(:account, :name => "Account #{i}") }
visit accounts_path
page.should have_content('Account 0')
page.should have_content('Account 1')
page.should have_content('Search accounts')
page.should have_content('Create Account')
end

#scenario 'should create a new account', :js => true do
#visit accounts_path
#click_link "Create Account"
#fill_in 'account_name', :with => "My new account"
#click_button 'Create Account'
#page.should have_content('My new account')
#end

end
14 changes: 14 additions & 0 deletions acceptance/support/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module HelperMethods
# Put helper methods you need to be available in all acceptance specs here.

def do_login(args = {})
user = Factory(:user, args)
visit '/login'
fill_in "authentication_username", :with => user.username
fill_in "authentication_password", :with => user.password
click_button "Login"
end

end

RSpec.configuration.include HelperMethods, :type => :acceptance
9 changes: 9 additions & 0 deletions acceptance/support/paths.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module NavigationHelpers
# Put helper methods related to the paths in your application here.

def homepage
"/"
end
end

RSpec.configuration.include NavigationHelpers, :type => :acceptance
11 changes: 9 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ENV["RAILS_ENV"] = 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'fuubar'

# Load factories
Expand Down Expand Up @@ -61,12 +62,18 @@
end

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, comment the following line or assign false
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

# Fuubar formatter doesn't work too well on Travis
config.formatter = ENV["TRAVIS"] ? :progress : "Fuubar"

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

end

ActionView::TestCase::TestController.class_eval do
Expand Down Expand Up @@ -97,7 +104,7 @@ def render(options={}, local_assigns={}, &block)

ActionView::Base.class_eval do
def controller_name
request.path_parameters["controller"].split('/').last
HashWithIndifferentAccess.new(request.path_parameters)["controller"].split('/').last
end

def called_from_index_page?(controller = controller_name)
Expand Down

0 comments on commit fdb6a43

Please sign in to comment.