@@ -58,7 +58,7 @@ group :test do |
||
| 58 | 58 |
gem "rspec" |
| 59 | 59 |
gem "rspec-rails" |
| 60 | 60 |
gem "webrat" |
| 61 |
- gem 'cucumber-rails' |
|
| 61 |
+ gem 'cucumber-rails', :require => false |
|
| 62 | 62 |
gem 'database_cleaner' |
| 63 | 63 |
end |
| 64 | 64 |
|
@@ -7,7 +7,7 @@ class BlogPostsController < ApplicationController |
||
| 7 | 7 |
# GET /blog_posts |
| 8 | 8 |
# GET /blog_posts.json |
| 9 | 9 |
def index |
| 10 |
- @blog_posts = BlogPost.order('created_at DESC').all
|
|
| 10 |
+ @blog_posts = BlogPost.order('created_at DESC')
|
|
| 11 | 11 |
end |
| 12 | 12 |
|
| 13 | 13 |
# GET /blog_posts/1 |
@@ -0,0 +1,8 @@ |
||
| 1 |
+<% |
|
| 2 |
+rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
|
| 3 |
+rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
|
| 4 |
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
|
| 5 |
+%> |
|
| 6 |
+default: <%= std_opts %> features |
|
| 7 |
+wip: --tags @wip:3 --wip features |
|
| 8 |
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip |
@@ -43,7 +43,7 @@ development: |
||
| 43 | 43 |
# Warning: The database defined as "test" will be erased and |
| 44 | 44 |
# re-generated from your development database when you run "rake". |
| 45 | 45 |
# Do not set this db to the same as development or production. |
| 46 |
-test: |
|
| 46 |
+test: &test |
|
| 47 | 47 |
adapter: postgresql |
| 48 | 48 |
encoding: unicode |
| 49 | 49 |
database: rails_website_template_test |
@@ -57,4 +57,7 @@ production: |
||
| 57 | 57 |
database: rails_website_template_production |
| 58 | 58 |
pool: 5 |
| 59 | 59 |
username: rails_website_template |
| 60 |
- password: |
|
| 60 |
+ password: |
|
| 61 |
+ |
|
| 62 |
+cucumber: |
|
| 63 |
+ <<: *test |
@@ -33,4 +33,5 @@ RailsWebsiteTemplate::Application.configure do |
||
| 33 | 33 |
|
| 34 | 34 |
# Print deprecation notices to the stderr. |
| 35 | 35 |
config.active_support.deprecation = :stderr |
| 36 |
+ |
|
| 36 | 37 |
end |
@@ -0,0 +1,9 @@ |
||
| 1 |
+Feature: Manage Articles |
|
| 2 |
+ In order to make a blog |
|
| 3 |
+ As an author |
|
| 4 |
+ I want to create and manage articles |
|
| 5 |
+ |
|
| 6 |
+Scenario: Blog Posts List |
|
| 7 |
+ Given I have blog posts titled Pizza, Breadsticks |
|
| 8 |
+ When I go to the blog page |
|
| 9 |
+ Then I should see "Pizza" And I should see "Breadsticks" |
@@ -0,0 +1,16 @@ |
||
| 1 |
+Info.create( :website_name => 'Website', :tagline => 'A Ruby on Rails app template', :default_language => 'en' ) |
|
| 2 |
+ |
|
| 3 |
+Given /^I have blog posts titled (.+)$/ do |titles| |
|
| 4 |
+ titles.split(', ').each do |title|
|
|
| 5 |
+ BlogPost.create!(:title => title) |
|
| 6 |
+ end |
|
| 7 |
+end |
|
| 8 |
+ |
|
| 9 |
+When(/^I go to the blog page$/) do |
|
| 10 |
+ visit blog_path |
|
| 11 |
+end |
|
| 12 |
+ |
|
| 13 |
+Then(/^I should see "(.*?)" And I should see "(.*?)"$/) do |arg1, arg2| |
|
| 14 |
+ page.should have_content(arg1) |
|
| 15 |
+ page.should have_content(arg2) |
|
| 16 |
+end |
@@ -0,0 +1,58 @@ |
||
| 1 |
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. |
|
| 2 |
+# It is recommended to regenerate this file in the future when you upgrade to a |
|
| 3 |
+# newer version of cucumber-rails. Consider adding your own code to a new file |
|
| 4 |
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb |
|
| 5 |
+# files. |
|
| 6 |
+ |
|
| 7 |
+require 'cucumber/rails' |
|
| 8 |
+ |
|
| 9 |
+# Capybara defaults to CSS3 selectors rather than XPath. |
|
| 10 |
+# If you'd prefer to use XPath, just uncomment this line and adjust any |
|
| 11 |
+# selectors in your step definitions to use the XPath syntax. |
|
| 12 |
+# Capybara.default_selector = :xpath |
|
| 13 |
+ |
|
| 14 |
+# By default, any exception happening in your Rails application will bubble up |
|
| 15 |
+# to Cucumber so that your scenario will fail. This is a different from how |
|
| 16 |
+# your application behaves in the production environment, where an error page will |
|
| 17 |
+# be rendered instead. |
|
| 18 |
+# |
|
| 19 |
+# Sometimes we want to override this default behaviour and allow Rails to rescue |
|
| 20 |
+# exceptions and display an error page (just like when the app is running in production). |
|
| 21 |
+# Typical scenarios where you want to do this is when you test your error pages. |
|
| 22 |
+# There are two ways to allow Rails to rescue exceptions: |
|
| 23 |
+# |
|
| 24 |
+# 1) Tag your scenario (or feature) with @allow-rescue |
|
| 25 |
+# |
|
| 26 |
+# 2) Set the value below to true. Beware that doing this globally is not |
|
| 27 |
+# recommended as it will mask a lot of errors for you! |
|
| 28 |
+# |
|
| 29 |
+ActionController::Base.allow_rescue = false |
|
| 30 |
+ |
|
| 31 |
+# Remove/comment out the lines below if your app doesn't have a database. |
|
| 32 |
+# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. |
|
| 33 |
+begin |
|
| 34 |
+ DatabaseCleaner.strategy = :transaction |
|
| 35 |
+rescue NameError |
|
| 36 |
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." |
|
| 37 |
+end |
|
| 38 |
+ |
|
| 39 |
+# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. |
|
| 40 |
+# See the DatabaseCleaner documentation for details. Example: |
|
| 41 |
+# |
|
| 42 |
+# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
|
| 43 |
+# # { :except => [:widgets] } may not do what you expect here
|
|
| 44 |
+# # as Cucumber::Rails::Database.javascript_strategy overrides |
|
| 45 |
+# # this setting. |
|
| 46 |
+# DatabaseCleaner.strategy = :truncation |
|
| 47 |
+# end |
|
| 48 |
+# |
|
| 49 |
+# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
|
| 50 |
+# DatabaseCleaner.strategy = :transaction |
|
| 51 |
+# end |
|
| 52 |
+# |
|
| 53 |
+ |
|
| 54 |
+# Possible values are :truncation and :transaction |
|
| 55 |
+# The :transaction strategy is faster, but might give you threading problems. |
|
| 56 |
+# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature |
|
| 57 |
+Cucumber::Rails::Database.javascript_strategy = :truncation |
|
| 58 |
+ |
@@ -0,0 +1,65 @@ |
||
| 1 |
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. |
|
| 2 |
+# It is recommended to regenerate this file in the future when you upgrade to a |
|
| 3 |
+# newer version of cucumber-rails. Consider adding your own code to a new file |
|
| 4 |
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb |
|
| 5 |
+# files. |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
|
| 9 |
+ |
|
| 10 |
+vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
|
| 11 |
+$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? |
|
| 12 |
+ |
|
| 13 |
+begin |
|
| 14 |
+ require 'cucumber/rake/task' |
|
| 15 |
+ |
|
| 16 |
+ namespace :cucumber do |
|
| 17 |
+ Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t|
|
|
| 18 |
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. |
|
| 19 |
+ t.fork = true # You may get faster startup if you set this to false |
|
| 20 |
+ t.profile = 'default' |
|
| 21 |
+ end |
|
| 22 |
+ |
|
| 23 |
+ Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t|
|
|
| 24 |
+ t.binary = vendored_cucumber_bin |
|
| 25 |
+ t.fork = true # You may get faster startup if you set this to false |
|
| 26 |
+ t.profile = 'wip' |
|
| 27 |
+ end |
|
| 28 |
+ |
|
| 29 |
+ Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
|
| 30 |
+ t.binary = vendored_cucumber_bin |
|
| 31 |
+ t.fork = true # You may get faster startup if you set this to false |
|
| 32 |
+ t.profile = 'rerun' |
|
| 33 |
+ end |
|
| 34 |
+ |
|
| 35 |
+ desc 'Run all features' |
|
| 36 |
+ task :all => [:ok, :wip] |
|
| 37 |
+ |
|
| 38 |
+ task :statsetup do |
|
| 39 |
+ require 'rails/code_statistics' |
|
| 40 |
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
|
| 41 |
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
|
| 42 |
+ end |
|
| 43 |
+ end |
|
| 44 |
+ desc 'Alias for cucumber:ok' |
|
| 45 |
+ task :cucumber => 'cucumber:ok' |
|
| 46 |
+ |
|
| 47 |
+ task :default => :cucumber |
|
| 48 |
+ |
|
| 49 |
+ task :features => :cucumber do |
|
| 50 |
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" |
|
| 51 |
+ end |
|
| 52 |
+ |
|
| 53 |
+ # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. |
|
| 54 |
+ task 'test:prepare' do |
|
| 55 |
+ end |
|
| 56 |
+ |
|
| 57 |
+ task :stats => 'cucumber:statsetup' |
|
| 58 |
+rescue LoadError |
|
| 59 |
+ desc 'cucumber rake task not available (cucumber not installed)' |
|
| 60 |
+ task :cucumber do |
|
| 61 |
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' |
|
| 62 |
+ end |
|
| 63 |
+end |
|
| 64 |
+ |
|
| 65 |
+end |
@@ -0,0 +1,10 @@ |
||
| 1 |
+#!/usr/bin/env ruby |
|
| 2 |
+ |
|
| 3 |
+vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
|
| 4 |
+if vendored_cucumber_bin |
|
| 5 |
+ load File.expand_path(vendored_cucumber_bin) |
|
| 6 |
+else |
|
| 7 |
+ require 'rubygems' unless ENV['NO_RUBYGEMS'] |
|
| 8 |
+ require 'cucumber' |
|
| 9 |
+ load Cucumber::BINARY |
|
| 10 |
+end |