add cucumber test for main process

This commit is contained in:
szpyxlwoni
2012-11-15 10:17:16 +08:00
parent e7e5566447
commit eabc239dc2
9 changed files with 210 additions and 4 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
source 'http://ruby.taobao.org'
gem 'rails', '3.2.8'
gem 'slim'
@@ -28,4 +28,8 @@ group :development, :test do
gem 'rspec-rails'
gem 'simplecov'
gem 'machinist'
gem 'cucumber-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'selenium-webdriver'
end
+37 -1
View File
@@ -1,5 +1,5 @@
GEM
remote: https://rubygems.org/
remote: http://ruby.taobao.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
@@ -41,6 +41,15 @@ GEM
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
builder (3.0.0)
capybara (2.0.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
childprocess (0.3.6)
ffi (~> 1.0, >= 1.0.6)
chronic (0.7.0)
cocaine (0.3.0)
code_analyzer (0.3.0)
@@ -53,6 +62,16 @@ GEM
execjs
coffee-script-source (1.3.3)
colored (1.2)
cucumber (1.2.1)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.0)
json (>= 1.4.6)
cucumber-rails (1.3.0)
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
database_cleaner (0.9.1)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
@@ -62,9 +81,12 @@ GEM
i18n (~> 0.4)
faraday (0.8.4)
multipart-post (~> 1.1)
ffi (1.1.5)
flay (2.0.0)
ruby_parser (~> 3.0.0)
sexp_processor (~> 4.0)
gherkin (2.11.5)
json (>= 1.4.6)
github (0.1.1)
google-api-client (0.5.0)
addressable (>= 2.3.2)
@@ -93,6 +115,8 @@ GEM
launchy (2.1.2)
addressable (~> 2.3)
libv8 (3.3.10.4)
libwebsocket (0.1.5)
addressable
machinist (2.0)
mail (2.4.4)
i18n (>= 0.4.0)
@@ -160,11 +184,17 @@ GEM
rspec (~> 2.11.0)
ruby_parser (3.0.1)
sexp_processor (~> 4.1)
rubyzip (0.9.9)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.26.0)
childprocess (>= 0.2.5)
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
sexp_processor (4.1.2)
signet (0.4.3)
addressable (>= 2.2.3)
@@ -204,14 +234,19 @@ GEM
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
uuidtools (2.1.3)
xpath (1.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
aws-sdk
capybara
chronic
coffee-rails (~> 3.2.1)
cucumber-rails
database_cleaner
execjs
faker
flay
@@ -226,6 +261,7 @@ DEPENDENCIES
rails_best_practices (~> 1.11.1)
rspec-rails
sass-rails (~> 3.2.3)
selenium-webdriver
simplecov
slim
tddium
+8
View File
@@ -0,0 +1,8 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
+4 -2
View File
@@ -18,10 +18,12 @@ development:
pool: 5
timeout: 5000
test:
test: &test
adapter: postgresql
database: ocelots_test
user: ocelots
host: localhost
pool: 5
timeout: 5000
timeout: 5000
cucumber:
<<: *test
+9
View File
@@ -0,0 +1,9 @@
Feature: Main process of Ocelots
AS A normal user
I WANT TO use main functionality of Ocelots
SO THAT I can know my team members better
Scenario: Go to home page
Given I am not signed in
When I go to home page
Then I should see sign in buttons
+11
View File
@@ -0,0 +1,11 @@
Given /^I am not signed in$/ do
end
When /^I go to home page$/ do
visit '/'
end
Then /^I should see sign in buttons$/ do
# TODO: assertion here
end
+61
View File
@@ -0,0 +1,61 @@
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'cucumber/rails'
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# # { :except => [:widgets] } may not do what you expect here
# # as tCucumber::Rails::Database.javascript_strategy overrides
# # this setting.
# DatabaseCleaner.strategy = :truncation
# end
#
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#
# Possible values are :truncation and :transaction
# The :transaction strategy is faster, but might give you threading problems.
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
Cucumber::Rails::Database.javascript_strategy = :truncation
Capybara.app_host = 'http://localhost:3000'
Capybara.default_driver = :selenium
+65
View File
@@ -0,0 +1,65 @@
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
begin
require 'cucumber/rake/task'
namespace :cucumber do
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
t.fork = true # You may get faster startup if you set this to false
t.profile = 'default'
end
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'wip'
end
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'rerun'
end
desc 'Run all features'
task :all => [:ok, :wip]
task :statsetup do
require 'rails/code_statistics'
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
end
end
desc 'Alias for cucumber:ok'
task :cucumber => 'cucumber:ok'
task :default => :cucumber
task :features => :cucumber do
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
end
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
task 'db:test:prepare' do
end
task :stats => 'cucumber:statsetup'
rescue LoadError
desc 'cucumber rake task not available (cucumber not installed)'
task :cucumber do
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
end
end
end
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end