├── BBQ_VERSION ├── bbq-rspec ├── .rspec ├── lib │ └── bbq │ │ ├── rspec │ │ ├── version.rb │ │ ├── matchers.rb │ │ └── matchers │ │ │ └── see.rb │ │ └── rspec.rb ├── Gemfile ├── Rakefile ├── spec │ ├── acceptance │ │ └── attributes_spec.rb │ ├── spec_helper.rb │ ├── test_user_matchers_spec.rb │ └── rspec_matchers_spec.rb ├── Contributing.md ├── .gitignore ├── Makefile ├── bbq-rspec.gemspec └── README.md ├── bbq ├── lib │ ├── bbq │ │ ├── version.rb │ │ ├── roles.rb │ │ ├── session.rb │ │ ├── test_user.rb │ │ ├── test_client.rb │ │ ├── test.rb │ │ └── test_unit.rb │ └── bbq.rb ├── Gemfile ├── Makefile ├── .gitignore ├── Rakefile ├── bbq.gemspec ├── CHANGELOG └── README.md ├── bbq-rails ├── lib │ ├── bbq │ │ ├── rails.rb │ │ └── rails │ │ │ ├── version.rb │ │ │ ├── routes.rb │ │ │ └── railtie.rb │ ├── generators │ │ ├── rspec │ │ │ ├── templates │ │ │ │ ├── README │ │ │ │ ├── test_user.rb │ │ │ │ └── bbq_spec.rb │ │ │ ├── bbq_test_generator.rb │ │ │ └── bbq_install_generator.rb │ │ ├── test_unit │ │ │ ├── templates │ │ │ │ ├── test_user.rb │ │ │ │ ├── bbq_test_case.rb │ │ │ │ └── README │ │ │ ├── bbq_test_generator.rb │ │ │ └── bbq_install_generator.rb │ │ └── bbq │ │ │ ├── test_generator.rb │ │ │ └── install_generator.rb │ └── tasks │ │ └── bbq.rake ├── Gemfile ├── .gitignore ├── Rakefile ├── Makefile ├── test │ ├── rails_integration_test.rb │ ├── test_user_routes_test.rb │ ├── test_helper.rb │ ├── bbq_test_generator_test.rb │ └── bbq_install_generator_test.rb ├── bbq-rails.gemspec └── README.md ├── bbq-devise ├── test │ ├── dummy │ │ ├── config │ │ │ ├── database.yml │ │ │ ├── environment.rb │ │ │ ├── locales │ │ │ │ └── en.yml │ │ │ ├── initializers │ │ │ │ ├── mime_types.rb │ │ │ │ ├── inflections.rb │ │ │ │ ├── backtrace_silencers.rb │ │ │ │ ├── session_store.rb │ │ │ │ ├── secret_token.rb │ │ │ │ └── devise.rb │ │ │ ├── routes.rb │ │ │ ├── boot.rb │ │ │ ├── application.rb │ │ │ └── environments │ │ │ │ ├── development.rb │ │ │ │ ├── test.rb │ │ │ │ └── production.rb │ │ ├── app │ │ │ ├── controllers │ │ │ │ ├── application_controller.rb │ │ │ │ └── home_controller.rb │ │ │ └── models │ │ │ │ └── user.rb │ │ ├── config.ru │ │ ├── Rakefile │ │ └── db │ │ │ └── schema.rb │ ├── test_helper.rb │ └── bbq_devise_test.rb ├── lib │ └── bbq │ │ ├── devise │ │ └── version.rb │ │ └── devise.rb ├── Gemfile ├── .gitignore ├── Rakefile ├── Makefile ├── README.md └── bbq-devise.gemspec ├── bbq-core ├── lib │ ├── bbq │ │ ├── core │ │ │ ├── version.rb │ │ │ ├── roles.rb │ │ │ ├── test_user │ │ │ │ ├── eyes.rb │ │ │ │ ├── capybara_dsl.rb │ │ │ │ └── within.rb │ │ │ ├── util.rb │ │ │ ├── test_user.rb │ │ │ ├── session.rb │ │ │ └── test_client.rb │ │ └── core.rb │ └── tasks │ │ └── bbq.rake ├── Gemfile ├── test │ ├── test_helper.rb │ ├── util_test.rb │ ├── test_client_test.rb │ ├── session_pool_test.rb │ └── test_user_test.rb ├── Rakefile ├── Makefile ├── .gitignore ├── bbq-core.gemspec ├── CHANGELOG └── README.md ├── support └── make │ ├── test.mk │ ├── help.mk │ ├── install.mk │ └── gem.mk ├── MIT-LICENSE └── Makefile /BBQ_VERSION: -------------------------------------------------------------------------------- 1 | 0.4.0 2 | -------------------------------------------------------------------------------- /bbq-rspec/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | -------------------------------------------------------------------------------- /bbq/lib/bbq/version.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | VERSION = "0.4.0" 3 | end 4 | -------------------------------------------------------------------------------- /bbq-rails/lib/bbq/rails.rb: -------------------------------------------------------------------------------- 1 | require "bbq/rails/version" 2 | require "bbq/rails/railtie" 3 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/database.yml: -------------------------------------------------------------------------------- 1 | test: 2 | adapter: sqlite3 3 | database: ":memory:" 4 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/version.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module Core 3 | VERSION = "0.4.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /bbq-rails/lib/bbq/rails/version.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module Rails 3 | VERSION = "0.4.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /bbq-rspec/lib/bbq/rspec/version.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module RSpec 3 | VERSION = "0.4.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /bbq/lib/bbq/roles.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/roles' 2 | 3 | module Bbq 4 | Roles = ::Bbq::Core::Roles 5 | end 6 | -------------------------------------------------------------------------------- /bbq-core/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | 5 | gem "jruby-openssl", :platforms => :jruby 6 | -------------------------------------------------------------------------------- /bbq-devise/lib/bbq/devise/version.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module Devise 3 | VERSION = "0.4.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /bbq/lib/bbq/session.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/session' 2 | 3 | module Bbq 4 | Session = ::Bbq::Core::Session 5 | end 6 | -------------------------------------------------------------------------------- /bbq/lib/bbq/test_user.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/test_user' 2 | 3 | module Bbq 4 | TestUser = ::Bbq::Core::TestUser 5 | end 6 | -------------------------------------------------------------------------------- /bbq/lib/bbq/test_client.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/test_client' 2 | 3 | module Bbq 4 | TestClient = ::Bbq::Core::TestClient 5 | end 6 | -------------------------------------------------------------------------------- /support/make/test.mk: -------------------------------------------------------------------------------- 1 | test: ## Run unit tests 2 | @echo "Running unit tests" 3 | @bundle exec rake test 4 | 5 | .PHONY: test 6 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module Core 3 | class << self 4 | attr_accessor :app 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /bbq-rspec/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | gem 'rspec', '~> 3.0' 6 | gem 'bbq-core', path: '../bbq-core' 7 | -------------------------------------------------------------------------------- /bbq/lib/bbq/test.rb: -------------------------------------------------------------------------------- 1 | warn "[DEPRECATION] require 'bbq/test' is deprecated. Please replace it with 'bbq/test_unit'" 2 | require "bbq/test_unit" 3 | -------------------------------------------------------------------------------- /bbq-devise/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | gem 'bbq-core', path: '../bbq-core' 6 | gem 'bbq-rails', path: '../bbq-rails' 7 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | end 4 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/rspec/templates/README: -------------------------------------------------------------------------------- 1 | 2 | To finish setup, place in your spec/spec_helper.rb the following: 3 | 4 | require 'bbq/rspec' 5 | 6 | -------------------------------------------------------------------------------- /bbq-rails/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | gem 'bbq-core', path: '../bbq-core' 6 | gem 'rails', '~> 5.0' 7 | gem 'capybara', '~> 3.31' 8 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/rspec/templates/test_user.rb: -------------------------------------------------------------------------------- 1 | require "bbq/test_user" 2 | 3 | class TestUser < Bbq::TestUser 4 | # FIXME: explain here how to extend TestUser 5 | end 6 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/test_unit/templates/test_user.rb: -------------------------------------------------------------------------------- 1 | require "bbq/test_user" 2 | 3 | class TestUser < Bbq::TestUser 4 | # FIXME: explain here how to extend TestUser 5 | end 6 | -------------------------------------------------------------------------------- /bbq-rspec/lib/bbq/rspec/matchers.rb: -------------------------------------------------------------------------------- 1 | require "bbq/rspec/matchers/see" 2 | 3 | module Bbq 4 | module RSpec 5 | module Matchers 6 | include See 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Dummy::Application 5 | -------------------------------------------------------------------------------- /bbq-core/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/autorun' 2 | require 'capybara' 3 | 4 | Capybara.register_driver :rack_test_the_other do |app| 5 | Capybara::RackTest::Driver.new(app) 6 | end 7 | 8 | 9 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | 3 | def index 4 | authenticate_user! 5 | render :text => "dummy" 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/bbq/test_generator.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | class TestGenerator < ::Rails::Generators::NamedBase 3 | hook_for :test_framework, :aliases => "-t", :as => "bbq_test" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /bbq-devise/.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Dummy::Application.initialize! 6 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/bbq/install_generator.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | class InstallGenerator < ::Rails::Generators::Base 3 | hook_for :test_framework, :aliases => "-t", :as => "bbq_install" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/test_unit/templates/bbq_test_case.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class <%= name.classify %>Test < Bbq::TestCase 4 | scenario "the truth" do 5 | assert true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /bbq-rspec/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | begin 4 | require "rspec/core/rake_task" 5 | RSpec::Core::RakeTask.new(:spec) 6 | rescue LoadError 7 | end 8 | 9 | task default: :spec 10 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/rspec/templates/bbq_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | feature "<%= name.underscore.capitalize.gsub(/_/, ' ') %>" do 4 | scenario "the truth" do 5 | assert true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /support/make/help.mk: -------------------------------------------------------------------------------- 1 | help: 2 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = "(:|:[^:]*?## )"}; {printf "\033[36m%-30s\033[0m %s\n", $$2, $$3}' | sort 3 | 4 | .PHONY: help 5 | .DEFAULT_GOAL := help 6 | -------------------------------------------------------------------------------- /bbq-rails/.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | /Gemfile*.lock 16 | -------------------------------------------------------------------------------- /bbq-rails/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rake/testtask" 3 | 4 | Rake::TestTask.new(:test) do |t| 5 | t.libs = %w(lib test) 6 | t.pattern = 'test/*_test.rb' 7 | end 8 | 9 | task default: :test 10 | -------------------------------------------------------------------------------- /bbq-devise/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rake/testtask" 3 | 4 | Rake::TestTask.new(:test) do |t| 5 | t.libs = %w(lib test) 6 | t.pattern = 'test/*_test.rb' 7 | end 8 | 9 | task default: :test 10 | -------------------------------------------------------------------------------- /bbq/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | 5 | gem 'bbq-core', path: '../bbq-core' 6 | gem 'bbq-rails', path: '../bbq-rails' 7 | gem 'bbq-rspec', path: '../bbq-rspec' 8 | gem 'bbq-devise', path: '../bbq-devise' 9 | -------------------------------------------------------------------------------- /bbq-core/Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | require 'rake/testtask' 3 | 4 | Rake::TestTask.new do |t| 5 | t.libs << 'test' 6 | t.test_files = FileList['test/*_test.rb'] 7 | t.verbose = true 8 | end 9 | 10 | task default: :test 11 | -------------------------------------------------------------------------------- /bbq/Makefile: -------------------------------------------------------------------------------- 1 | GEM_VERSION = $(shell cat ../BBQ_VERSION) 2 | GEM_NAME = bbq 3 | REQUIRE = $(GEM_NAME) 4 | 5 | include ../support/make/install.mk 6 | include ../support/make/test.mk 7 | include ../support/make/gem.mk 8 | include ../support/make/help.mk 9 | -------------------------------------------------------------------------------- /bbq-core/Makefile: -------------------------------------------------------------------------------- 1 | GEM_VERSION = $(shell cat ../BBQ_VERSION) 2 | GEM_NAME = bbq-core 3 | REQUIRE = $(GEM_NAME) 4 | 5 | include ../support/make/install.mk 6 | include ../support/make/test.mk 7 | include ../support/make/gem.mk 8 | include ../support/make/help.mk 9 | -------------------------------------------------------------------------------- /bbq-rails/Makefile: -------------------------------------------------------------------------------- 1 | GEM_VERSION = $(shell cat ../BBQ_VERSION) 2 | GEM_NAME = bbq-rails 3 | REQUIRE = $(GEM_NAME) 4 | 5 | include ../support/make/install.mk 6 | include ../support/make/test.mk 7 | include ../support/make/gem.mk 8 | include ../support/make/help.mk 9 | -------------------------------------------------------------------------------- /bbq-rspec/spec/acceptance/attributes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'attributes' do 4 | 5 | specify 'acceptance type in spec/acceptance' do 6 | expect(RSpec.current_example.metadata[:type]).to eq(:acceptance) 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /bbq-devise/Makefile: -------------------------------------------------------------------------------- 1 | GEM_VERSION = $(shell cat ../BBQ_VERSION) 2 | GEM_NAME = bbq-devise 3 | REQUIRE = $(GEM_NAME) 4 | 5 | include ../support/make/install.mk 6 | include ../support/make/test.mk 7 | include ../support/make/gem.mk 8 | include ../support/make/help.mk 9 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ActiveRecord::Base 2 | devise :database_authenticatable, :registerable, 3 | :recoverable, :rememberable, :trackable, :validatable 4 | 5 | attr_accessible :email, :password, :password_confirmation, :remember_me 6 | end 7 | -------------------------------------------------------------------------------- /bbq/lib/bbq.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core' 2 | require 'bbq/rails' if defined?(::Rails) 3 | 4 | module Bbq 5 | class << self 6 | 7 | def app 8 | Bbb::Core.app 9 | end 10 | 11 | def app=(value) 12 | Bbq::Core.app = value 13 | end 14 | 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /bbq-rspec/Contributing.md: -------------------------------------------------------------------------------- 1 | # Development setup 2 | 3 | BUNDLE_GEMFILE=Gemfile.rspec2 bundle 4 | BUNDLE_GEMFILE=Gemfile.rspec3 bundle 5 | 6 | # Running specs 7 | 8 | BUNDLE_GEMFILE=Gemfile.rspec2 bundle exec rake 9 | BUNDLE_GEMFILE=Gemfile.rspec3 bundle exec rake 10 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/routes.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.routes.draw do 2 | devise_for :users 3 | root :to => "home#index" 4 | 5 | get "/miracle" => "home#miracle" 6 | get "/ponycorns" => "home#ponycorns" 7 | get "/rainbow" => "home#rainbow" 8 | get "/uh_oh" => "home#uh_oh" 9 | end 10 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | gemfile = File.expand_path('../../../../Gemfile', __FILE__) 3 | 4 | if File.exist?(gemfile) 5 | ENV['BUNDLE_GEMFILE'] = gemfile 6 | require 'bundler' 7 | Bundler.setup 8 | end 9 | 10 | $:.unshift File.expand_path('../../../../lib', __FILE__) -------------------------------------------------------------------------------- /bbq-rspec/.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | *.gem 16 | test/dummy/db/*.sqlite3 17 | test/dummy/log/*.log 18 | test/dummy/tmp/ 19 | Gemfile*.lock 20 | -------------------------------------------------------------------------------- /bbq/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .bundle 3 | Gemfile.lock 4 | pkg/* 5 | bin/* 6 | tmp/* 7 | test/dummy/db/*.sqlite3 8 | test/dummy/log/*.log 9 | test/dummy/tmp/ 10 | test/dummy/test/acceptance/* 11 | test/dummy/spec/acceptance/* 12 | test/dope/test/acceptance/* 13 | test/dope/spec/acceptance/* 14 | nbproject/ 15 | -------------------------------------------------------------------------------- /bbq-core/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .bundle 3 | Gemfile.lock 4 | pkg/* 5 | bin/* 6 | tmp/* 7 | test/dummy/db/*.sqlite3 8 | test/dummy/log/*.log 9 | test/dummy/tmp/ 10 | test/dummy/test/acceptance/* 11 | test/dummy/spec/acceptance/* 12 | test/dope/test/acceptance/* 13 | test/dope/spec/acceptance/* 14 | nbproject/ 15 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | require 'rake' 6 | 7 | Dummy::Application.load_tasks 8 | -------------------------------------------------------------------------------- /support/make/install.mk: -------------------------------------------------------------------------------- 1 | install: ## Install gem dependencies 2 | @echo "Installing gem dependencies" 3 | @bundle check || bundle install 4 | 5 | remove-lock: 6 | @echo "Removing resolved dependency versions" 7 | -rm Gemfile.lock 8 | 9 | reinstall: remove-lock install ## Removing resolved dependency versions 10 | -------------------------------------------------------------------------------- /bbq-rails/test/rails_integration_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'bbq/core/test_user' 3 | 4 | class RailsIntegration < Minitest::Test 5 | 6 | def test_rails_integration 7 | user = Bbq::Core::TestUser.new 8 | user.visit('/') 9 | 10 | assert user.has_content?('dummy') 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /bbq-rspec/Makefile: -------------------------------------------------------------------------------- 1 | GEM_VERSION = $(shell cat ../BBQ_VERSION) 2 | GEM_NAME = bbq-rspec 3 | REQUIRE = $(GEM_NAME) 4 | 5 | include ../support/make/install.mk 6 | include ../support/make/gem.mk 7 | include ../support/make/help.mk 8 | 9 | test: ## Run unit tests 10 | @echo "Running unit tests" 11 | @bundle exec rspec 12 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/test_unit/templates/README: -------------------------------------------------------------------------------- 1 | 2 | To finish setup, place in your test/test_helper.rb the following: 3 | 4 | require 'bbq/test_unit' 5 | 6 | Also make sure that you require there support files: 7 | 8 | # Load support files 9 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } 10 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/roles.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/util' 2 | 3 | module Bbq 4 | module Core 5 | module Roles 6 | def roles(*names) 7 | names.each do |name| 8 | module_obj = Bbq::Core::Util.find_module(name, self) 9 | self.extend(module_obj) 10 | end 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/rspec/bbq_test_generator.rb: -------------------------------------------------------------------------------- 1 | module Rspec 2 | class BbqTestGenerator < Rails::Generators::NamedBase 3 | source_root File.expand_path(File.join(File.dirname(__FILE__), '../rspec/templates')) 4 | 5 | def create_test 6 | template "bbq_spec.rb", "spec/acceptance/#{name.underscore}_spec.rb" 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/test_user/eyes.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module Core 3 | class TestUser 4 | module Eyes 5 | def see?(*args) 6 | args.all? { |arg| has_content?(arg) } 7 | end 8 | 9 | def not_see?(*args) 10 | args.all? { |arg| has_no_content?(arg) } 11 | end 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/test_unit/bbq_test_generator.rb: -------------------------------------------------------------------------------- 1 | module TestUnit 2 | class BbqTestGenerator < Rails::Generators::NamedBase 3 | source_root File.expand_path(File.join(File.dirname(__FILE__), '../test_unit/templates')) 4 | 5 | def create_test 6 | template "bbq_test_case.rb", "test/acceptance/#{name.underscore}_test.rb" 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /support/make/gem.mk: -------------------------------------------------------------------------------- 1 | build: 2 | @echo "Building gem package" 3 | @gem build -V $(GEM_NAME).gemspec 4 | @mkdir -p pkg/ 5 | @mv $(GEM_NAME)-$(GEM_VERSION).gem pkg/ 6 | 7 | push: 8 | @echo "Pushing package to RubyGems" 9 | @gem push pkg/$(GEM_NAME)-$(GEM_VERSION).gem 10 | 11 | clean: 12 | @echo "Removing previously built package" 13 | -rm pkg/$(GEM_NAME)-$(GEM_VERSION).gem 14 | -------------------------------------------------------------------------------- /bbq-rails/lib/bbq/rails/routes.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module Rails 3 | module Routes 4 | def self.included(klass) 5 | klass.send(:include, ::ActionDispatch::Routing::UrlFor) 6 | klass.send(:include, ::Rails.application.routes.url_helpers) 7 | 8 | unless ::Rails.version < "3.1" 9 | klass.send(:include, ::ActionDispatch::Routing::RouteSet::MountedHelpers) 10 | end 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/test_user/capybara_dsl.rb: -------------------------------------------------------------------------------- 1 | require 'capybara/dsl' 2 | 3 | module Bbq 4 | module Core 5 | class TestUser 6 | module CapybaraDsl 7 | ::Capybara::Session::DSL_METHODS.each do |method| 8 | class_eval <<-RUBY, __FILE__, __LINE__+1 9 | def #{method}(*args, &block) 10 | page.#{method}(*args, &block) 11 | end 12 | RUBY 13 | end 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rails generate session_migration") 8 | # Dummy::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /bbq-core/lib/tasks/bbq.rake: -------------------------------------------------------------------------------- 1 | require 'rake/testtask' 2 | 3 | Rake::TestTask.new("test:acceptance") do |t| 4 | t.libs << 'test' 5 | t.pattern = 'test/acceptance/**/*_test.rb' 6 | t.verbose = false 7 | end if File.exists?('test/acceptance') 8 | 9 | begin 10 | require 'rspec/core/rake_task' 11 | RSpec::Core::RakeTask.new('spec:acceptance') do |spec| 12 | spec.pattern = FileList['spec/acceptance/**/*_spec.rb'] 13 | end if File.exists?('spec/acceptance') 14 | rescue LoadError 15 | end 16 | -------------------------------------------------------------------------------- /bbq-rails/lib/tasks/bbq.rake: -------------------------------------------------------------------------------- 1 | require 'rake/testtask' 2 | 3 | Rake::TestTask.new("test:acceptance") do |t| 4 | t.libs << 'test' 5 | t.pattern = 'test/acceptance/**/*_test.rb' 6 | t.verbose = false 7 | end if File.exists?('test/acceptance') 8 | 9 | begin 10 | require 'rspec/core/rake_task' 11 | RSpec::Core::RakeTask.new('spec:acceptance') do |spec| 12 | spec.pattern = FileList['spec/acceptance/**/*_spec.rb'] 13 | end if File.exists?('spec/acceptance') 14 | rescue LoadError 15 | end 16 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require "active_model/railtie" 4 | require "active_record/railtie" 5 | require "action_controller/railtie" 6 | require "action_view/railtie" 7 | require "action_mailer/railtie" 8 | 9 | require "devise" 10 | 11 | module Dummy 12 | class Application < Rails::Application 13 | config.encoding = "utf-8" 14 | config.filter_parameters += [:password] 15 | config.logger = Logger.new('/dev/null') 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bbq-rails/test/test_user_routes_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'bbq/core/test_user' 3 | require 'bbq/rails/routes' 4 | 5 | class TestUserRoutesTest < Minitest::Test 6 | class TestUserWithRoutes < Bbq::Core::TestUser 7 | include ::Bbq::Rails::Routes 8 | 9 | def visit_test_page 10 | visit(root_url) 11 | end 12 | end 13 | 14 | def test_routes_integration 15 | user = TestUserWithRoutes.new 16 | user.visit_test_page 17 | 18 | assert user.has_content?('dummy') 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /bbq-devise/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/autorun' 2 | 3 | ENV["RAILS_ENV"] = "test" 4 | require File.expand_path("../dummy/config/environment.rb", __FILE__) 5 | require "rails/test_help" 6 | 7 | ActiveRecord::Base.configurations = YAML.load(File.read(File.expand_path("../dummy/config/database.yml", __FILE__))) 8 | ActiveRecord::Base.establish_connection("test") 9 | ActiveRecord::Migration.verbose = false 10 | load File.expand_path("../dummy/db/schema.rb", __FILE__) 11 | 12 | require 'bbq/core' 13 | Bbq::Core.app = Dummy::Application 14 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | Dummy::Application.config.secret_token = '04a135bb493e34c7dd6b2d0cd336d28a5ea8a5e30d2cc228573aadaaba4646636729f70f9381a0dc1ecc1be8fdff208d2be3b9b7fc5788f4f0d0466778e4bd10' 8 | -------------------------------------------------------------------------------- /bbq-rails/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/autorun' 2 | require 'bbq/rails' 3 | require 'action_controller/railtie' 4 | 5 | 6 | class DummyApplication < ::Rails::Application 7 | config.eager_load = false 8 | config.secret_token = SecureRandom.hex(30) 9 | end 10 | 11 | class DummyController < ActionController::Base 12 | def index 13 | render text: 'dummy' 14 | end 15 | end 16 | 17 | DummyApplication.initialize! 18 | DummyApplication.routes.draw { root to: 'dummy#index' } 19 | DummyApplication.routes.default_url_options[:host] = 'example.com' 20 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/rspec/bbq_install_generator.rb: -------------------------------------------------------------------------------- 1 | module Rspec 2 | class BbqInstallGenerator < Rails::Generators::Base 3 | source_root File.expand_path(File.join(File.dirname(__FILE__), '../rspec/templates')) 4 | 5 | def create_directory 6 | empty_directory "spec/acceptance" 7 | end 8 | 9 | def generate_test_user 10 | empty_directory "spec/support" 11 | template "test_user.rb", "spec/support/test_user.rb" 12 | end 13 | 14 | def show_readme 15 | readme "README" if behavior == :invoke 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /bbq/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | begin 3 | require 'bundler/setup' 4 | rescue LoadError 5 | puts 'You must `gem install bundler` and `bundle install` to run rake tasks' 6 | end 7 | 8 | Bundler::GemHelper.install_tasks 9 | require 'rake/testtask' 10 | 11 | Rake::TestTask.new(:test) do |t| 12 | t.libs << 'lib' 13 | t.libs << 'test' 14 | t.pattern = 'test/unit/*_test.rb' # Don't load test/dummy/test && test/dope/test etc. because we run them from our tests with proper commands setup. 15 | t.verbose = false 16 | end 17 | 18 | 19 | task :default => :test 20 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/util.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/core_ext/string/inflections' 2 | 3 | module Bbq 4 | module Core 5 | class Util 6 | def self.find_module(name, scope = nil) 7 | namespace = case scope 8 | when String, Symbol 9 | "::#{scope.to_s.camelize}" 10 | when Class 11 | "::#{scope.name}" 12 | when NilClass 13 | nil 14 | else 15 | "::#{scope.class.name}" 16 | end 17 | "#{namespace}::#{name.to_s.camelize}".constantize 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /bbq-rails/lib/generators/test_unit/bbq_install_generator.rb: -------------------------------------------------------------------------------- 1 | module TestUnit 2 | class BbqInstallGenerator < Rails::Generators::Base 3 | source_root File.expand_path(File.join(File.dirname(__FILE__), '../test_unit/templates')) 4 | 5 | def create_directory 6 | empty_directory "test/acceptance" 7 | end 8 | 9 | def generate_test_user 10 | empty_directory "test/support" 11 | template "test_user.rb", "test/support/test_user.rb" 12 | end 13 | 14 | def show_readme 15 | readme "README" if behavior == :invoke 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /bbq-rspec/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/rspec' 2 | require 'rack/builder' 3 | 4 | Bbq::Core.app = Rack::Builder.new do 5 | map '/test_page' do 6 | html_page = <<-EOP 7 | 8 | 9 | 10 | Ponycorns 11 | 12 | 13 | 16 | 19 | 20 | 21 | EOP 22 | 23 | run ->(env) { ['200', {'Content-Type' => 'text/html'}, [html_page]] } 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /bbq-rails/lib/bbq/rails/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'rails/railtie' 2 | require 'rails/generators' 3 | require 'bbq/core' 4 | 5 | module Bbq 6 | module Rails 7 | class Railtie < ::Rails::Railtie 8 | 9 | initializer "bqq.set_app" do 10 | Bbq::Core.app = ::Rails.application 11 | end 12 | 13 | rake_tasks do 14 | load File.expand_path(File.join(File.dirname(__FILE__), '../../tasks/bbq.rake')) 15 | end 16 | 17 | helper_generators = %w(test_unit rspec).flat_map do |test_framework| 18 | ["#{test_framework}:bbq_test", "#{test_framework}:bbq_install"] 19 | end 20 | ::Rails::Generators.hide_namespaces *helper_generators 21 | 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /bbq-devise/README.md: -------------------------------------------------------------------------------- 1 | # Bbq::Devise 2 | 3 | TODO: Write a gem description 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | ```ruby 10 | gem 'bbq-devise' 11 | ``` 12 | 13 | And then execute: 14 | 15 | $ bundle 16 | 17 | Or install it yourself as: 18 | 19 | $ gem install bbq-devise 20 | 21 | ## Usage 22 | 23 | TODO: Write usage instructions here 24 | 25 | ## Contributing 26 | 27 | 1. Fork it ( https://github.com/[my-github-username]/bbq-devise/fork ) 28 | 2. Create your feature branch (`git checkout -b my-new-feature`) 29 | 3. Commit your changes (`git commit -am 'Add some feature'`) 30 | 4. Push to the branch (`git push origin my-new-feature`) 31 | 5. Create a new Pull Request 32 | -------------------------------------------------------------------------------- /bbq-rspec/spec/test_user_matchers_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | class TestUserWithMatchers < Bbq::Core::TestUser 4 | def ensure_no_red_ponycorns 5 | expect(self).to have_no_content('Red') 6 | end 7 | 8 | def ensure_pink_ponycorns 9 | expect(self).to see('Pink').within('#unicorns') 10 | end 11 | end 12 | 13 | describe 'TestUser matchers' do 14 | 15 | specify 'capybara matcher' do 16 | user = TestUserWithMatchers.new 17 | user.visit('/test_page') 18 | 19 | expect { user.ensure_no_red_ponycorns }.not_to raise_error 20 | end 21 | 22 | specify 'bbq matcher' do 23 | user = TestUserWithMatchers.new 24 | user.visit('/test_page') 25 | 26 | expect { user.ensure_pink_ponycorns }.not_to raise_error 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /bbq-core/test/util_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'bbq/core/util' 3 | 4 | class User 5 | module Commenter 6 | end 7 | end 8 | 9 | module Commenter 10 | end 11 | 12 | class UtilTest < Minitest::Test 13 | 14 | def test_find_module_in_object_namespace 15 | assert_commenter(User.new, User::Commenter) 16 | end 17 | 18 | def test_find_module_in_class_namespace 19 | assert_commenter(User, User::Commenter) 20 | end 21 | 22 | def test_find_module_in_string_namespace 23 | assert_commenter("User", User::Commenter) 24 | end 25 | 26 | def test_find_global_module 27 | assert_commenter(nil, ::Commenter) 28 | end 29 | 30 | def assert_commenter(namespace, result) 31 | [:commenter, "commenter"].each do |name| 32 | assert_equal Bbq::Core::Util.find_module(name, namespace), result 33 | end 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /bbq-devise/test/bbq_devise_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'bbq/core/test_user' 3 | require 'bbq/devise' 4 | 5 | class DeviseTestUser < Bbq::Core::TestUser 6 | include Bbq::Devise 7 | end 8 | 9 | class BbqDeviseTest < Minitest::Unit::TestCase 10 | 11 | def test_user_register 12 | user = DeviseTestUser.new 13 | user.register 14 | 15 | assert user.see?("dummy") 16 | User.find_by_email(user.email).destroy 17 | end 18 | 19 | def test_login_user 20 | user = DeviseTestUser.new(:password => 'dupa.8') 21 | user.register 22 | user.logout 23 | user.login 24 | 25 | assert user.see?("dummy") 26 | User.find_by_email(user.email).destroy 27 | end 28 | 29 | def test_user_without_login 30 | user = DeviseTestUser.new 31 | user.visit user.root_path 32 | 33 | assert user.not_see?("dummy") 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /bbq/lib/bbq/test_unit.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/session' 2 | require 'test/unit' 3 | require 'test/unit/assertions' 4 | require 'active_support/test_case' 5 | 6 | module Bbq 7 | class TestCase < ActiveSupport::TestCase 8 | class << self 9 | alias :scenario :test 10 | alias :background :setup 11 | end 12 | 13 | alias :background :setup 14 | 15 | teardown do 16 | Bbq::Core::Session.pool.release 17 | end 18 | end 19 | 20 | class TestUser 21 | include Test::Unit::Assertions 22 | 23 | def see!(*args) 24 | args.each do |arg| 25 | assert has_content?(arg), "Expecting to see \"#{arg}\", text not found." 26 | end 27 | end 28 | 29 | def not_see!(*args) 30 | args.each do |arg| 31 | assert has_no_content?(arg), "Found \"#{arg}\", which was unexpected." 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/db/schema.rb: -------------------------------------------------------------------------------- 1 | ActiveRecord::Schema.define(:version => 20110521153145) do 2 | create_table "users", :force => true do |t| 3 | t.string "email", :default => "", :null => false 4 | t.string "encrypted_password", :limit => 128, :default => "", :null => false 5 | t.string "reset_password_token" 6 | t.datetime "reset_password_sent_at" 7 | t.datetime "remember_created_at" 8 | t.integer "sign_in_count", :default => 0 9 | t.datetime "current_sign_in_at" 10 | t.datetime "last_sign_in_at" 11 | t.string "current_sign_in_ip" 12 | t.string "last_sign_in_ip" 13 | t.datetime "created_at" 14 | t.datetime "updated_at" 15 | end 16 | 17 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true 18 | add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true 19 | end 20 | -------------------------------------------------------------------------------- /bbq-rails/test/bbq_test_generator_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "rails/generators/test_case" 3 | require "generators/bbq/test_generator" 4 | 5 | class BbqTestGeneratorTest < ::Rails::Generators::TestCase 6 | destination File.expand_path(File.join(File.dirname(__FILE__), '../tmp')) 7 | setup :prepare_destination 8 | 9 | tests Bbq::TestGenerator 10 | 11 | def test_creating_test_unit_feature_file 12 | run_generator %w(MySuperThing -t test_unit) 13 | 14 | assert_file "test/acceptance/my_super_thing_test.rb", /class MySuperThingTest < Bbq::TestCase/ 15 | assert_file "test/acceptance/my_super_thing_test.rb", /require "test_helper"/ 16 | end 17 | 18 | def test_creating_rspec_feature_file 19 | run_generator %w(MySuperThing -t rspec) 20 | 21 | assert_file "spec/acceptance/my_super_thing_spec.rb", /feature "My super thing" do/ 22 | assert_file "spec/acceptance/my_super_thing_spec.rb", /require "spec_helper"/ 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/test_user.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/session' 2 | require 'bbq/core/roles' 3 | require 'bbq/core/test_user/capybara_dsl' 4 | require 'bbq/core/test_user/eyes' 5 | require 'bbq/core/test_user/within' 6 | 7 | module Bbq 8 | module Core 9 | class TestUser 10 | include Bbq::Core::TestUser::CapybaraDsl 11 | include Bbq::Core::TestUser::Eyes 12 | include Bbq::Core::TestUser::Within 13 | include Bbq::Core::Roles 14 | 15 | attr_reader :options 16 | 17 | def initialize(options = {}) 18 | @options = default_options.merge(options) 19 | end 20 | 21 | def default_options 22 | { 23 | :pool => Bbq::Core::Session.pool, 24 | :driver => ::Capybara.default_driver 25 | } 26 | end 27 | 28 | def page 29 | @page ||= options[:session] || Bbq::Core::Session.next(:driver => options[:driver], :pool => options[:pool]) 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /bbq-rspec/bbq-rspec.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path("../lib", __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require "bbq/rspec/version" 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "bbq-rspec" 8 | spec.version = Bbq::RSpec::VERSION 9 | spec.authors = ["DRUG - Dolnośląska Grupa Użytkowników Ruby"] 10 | spec.email = ["bbq@drug.org.pl"] 11 | spec.summary = %q{RSpec integration for bbq.} 12 | spec.description = %q{RSpec integration for bbq.} 13 | spec.homepage = "" 14 | spec.license = "MIT" 15 | 16 | spec.files = `git ls-files -z`.split("\x0") 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ["lib"] 20 | 21 | spec.add_dependency "bbq-core", "= 0.4.0" 22 | 23 | spec.add_development_dependency "rake" 24 | spec.add_development_dependency "rspec", ">= 3.0" 25 | end 26 | -------------------------------------------------------------------------------- /bbq-core/test/test_client_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'bbq/core/test_client' 3 | 4 | class TestClientTest < Minitest::Test 5 | 6 | def test_rack_test_to_env_headers_for_empty_hash 7 | test_client = Bbq::Core::TestClient::RackTest.new(:app) 8 | assert_equal({}, test_client.to_env_headers({})) 9 | end 10 | 11 | def test_rack_test_to_env_headers_for_content_type_or_content_length 12 | test_client = Bbq::Core::TestClient::RackTest.new(:app) 13 | result = test_client.to_env_headers({ 14 | "content-type" => "text/plain", 15 | "content-length" => "40" 16 | }) 17 | assert_includes(result.keys, "CONTENT_TYPE") 18 | assert_includes(result.keys, "CONTENT_LENGTH") 19 | end 20 | 21 | def test_rack_test_to_env_headers_for_other_headers 22 | test_client = Bbq::Core::TestClient::RackTest.new(:app) 23 | result = test_client.to_env_headers({ 24 | "silly-header" => "silly-value" 25 | }) 26 | assert_includes(result.keys, "HTTP_SILLY_HEADER") 27 | end 28 | 29 | end 30 | 31 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/test_user/within.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/core_ext/array/extract_options' 2 | 3 | module Bbq 4 | module Core 5 | class TestUser 6 | module Within 7 | METHODS_USING_WITHIN = [ 8 | :see?, :not_see?, 9 | :attach_file, :check, :choose, :click_link_or_button, :click_button, 10 | :click_link, :click_on, :fill_in, :select, :uncheck, :unselect 11 | ] 12 | 13 | METHODS_USING_WITHIN.each do |method_name| 14 | class_eval <<-RUBY 15 | def #{method_name}(*args) 16 | using_within(args) { super } 17 | end 18 | RUBY 19 | end 20 | 21 | def using_within(args) 22 | options = args.extract_options! 23 | locator = options.delete(:within) 24 | args.push(options) unless options.empty? 25 | 26 | if locator 27 | within(locator) { yield } 28 | else 29 | yield 30 | end 31 | end 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /bbq-rails/bbq-rails.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'bbq/rails/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "bbq-rails" 8 | spec.version = Bbq::Rails::VERSION 9 | spec.authors = ["DRUG - Dolnośląska Grupa Użytkowników Ruby"] 10 | spec.email = ["all@drug.org.pl"] 11 | spec.summary = %q{Rails integration for Bbq.} 12 | spec.description = spec.summary 13 | spec.homepage = "" 14 | spec.license = "MIT" 15 | 16 | spec.files = `git ls-files -z`.split("\x0") 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ["lib"] 20 | 21 | spec.add_dependency "bbq-core", "= 0.4.0" 22 | 23 | spec.add_development_dependency "rake" 24 | spec.add_development_dependency "rails", ">= 5.0" 25 | spec.add_development_dependency "minitest", "~> 5.0" 26 | end 27 | -------------------------------------------------------------------------------- /bbq-rspec/spec/rspec_matchers_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'RSpec matchers' do 4 | 5 | specify 'see given string' do 6 | user = Bbq::Core::TestUser.new 7 | user.visit('/test_page') 8 | 9 | expect { expect(user).to see('Pink') }.to_not raise_error 10 | end 11 | 12 | specify 'unable to see given string' do 13 | user = Bbq::Core::TestUser.new 14 | user.visit('/test_page') 15 | 16 | expect { expect(user).to see('nothing to see') }.to raise_error(RSpec::Expectations::ExpectationNotMetError) 17 | end 18 | 19 | specify 'see given string within scope' do 20 | user = Bbq::Core::TestUser.new 21 | user.visit('/test_page') 22 | 23 | expect { expect(user).to see('Pink').within('#unicorns') }.to_not raise_error 24 | end 25 | 26 | specify 'unable to see given string within scope' do 27 | user = Bbq::Core::TestUser.new 28 | user.visit('/test_page') 29 | 30 | expect { expect(user).to see('Violet').within('#unicorns') }.to raise_error(RSpec::Expectations::ExpectationNotMetError) 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /bbq-core/bbq-core.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $:.push File.expand_path("../lib", __FILE__) 3 | require "bbq/core/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "bbq-core" 7 | s.version = Bbq::Core::VERSION 8 | s.platform = Gem::Platform::RUBY 9 | s.authors = ["DRUG - Dolnośląska Grupa Użytkowników Ruby"] 10 | s.email = ["bbq@drug.org.pl"] 11 | s.homepage = "" 12 | s.description = %q{Objected oriented acceptance testing for Rails, using personas.} 13 | s.summary = %q{Objected oriented acceptance testing for Rails, using personas.} 14 | 15 | s.rubyforge_project = "bbq-core" 16 | 17 | s.files = `git ls-files`.split("\n") 18 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 19 | s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 20 | s.require_paths = ["lib"] 21 | 22 | s.add_dependency "capybara", ">= 2.0" 23 | s.add_dependency "activesupport", ">= 2.0" 24 | 25 | s.add_development_dependency "rake" 26 | s.add_development_dependency "minitest", "~> 5.0" 27 | end 28 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the webserver when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_view.debug_rjs = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Don't care if the mailer can't send 18 | config.action_mailer.raise_delivery_errors = false 19 | 20 | # Print deprecation notices to the Rails logger 21 | config.active_support.deprecation = :log 22 | 23 | # Only use best-standards-support built into browsers 24 | config.action_dispatch.best_standards_support = :builtin 25 | end 26 | 27 | -------------------------------------------------------------------------------- /bbq-rails/test/bbq_install_generator_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "rails/generators/test_case" 3 | require "generators/bbq/install_generator" 4 | 5 | class BbqInstallGeneratorTest < Rails::Generators::TestCase 6 | destination File.expand_path(File.join(File.dirname(__FILE__), '../tmp')) 7 | setup :prepare_destination 8 | 9 | tests Bbq::InstallGenerator 10 | 11 | def test_creating_test_unit_test_directories 12 | run_generator %w(-t test_unit) 13 | 14 | assert_directory "test/acceptance" 15 | assert_directory "test/support" 16 | end 17 | 18 | def test_creating_rspec_test_directories 19 | run_generator %w(-t rspec) 20 | 21 | assert_directory "spec/acceptance" 22 | assert_directory "spec/support" 23 | end 24 | 25 | def test_creating_test_unit_test_user_stub 26 | run_generator %w(-t test_unit) 27 | 28 | assert_file "test/support/test_user.rb", /class TestUser < Bbq::TestUser/ 29 | end 30 | 31 | def test_creating_rspec_test_user_stub 32 | run_generator %w(-t rspec) 33 | 34 | assert_file "spec/support/test_user.rb", /class TestUser < Bbq::TestUser/ 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011 DRUG, Dolnośląska Grupa Użytkowników Ruby 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /bbq-devise/bbq-devise.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'bbq/devise/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "bbq-devise" 8 | spec.version = Bbq::Devise::VERSION 9 | spec.authors = ["Paweł Pacana"] 10 | spec.email = ["pawel.pacana@gmail.com"] 11 | spec.summary = %q{Devise integration for bbq.} 12 | spec.homepage = "" 13 | spec.license = "MIT" 14 | 15 | spec.files = `git ls-files -z`.split("\x0") 16 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 17 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 18 | spec.require_paths = ["lib"] 19 | 20 | spec.add_dependency "bbq-core", "= 0.4.0" 21 | spec.add_dependency "bbq-rails", "= 0.4.0" 22 | 23 | spec.add_development_dependency "rake" 24 | spec.add_development_dependency "devise", ">= 4.0" 25 | spec.add_development_dependency "rails", ">= 5.0" 26 | spec.add_development_dependency "sqlite3", ">= 1.4" 27 | spec.add_development_dependency "minitest", "~> 5.0" 28 | end 29 | -------------------------------------------------------------------------------- /bbq/bbq.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $:.push File.expand_path("../lib", __FILE__) 3 | require "bbq/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "bbq" 7 | s.version = Bbq::VERSION 8 | s.platform = Gem::Platform::RUBY 9 | s.authors = ["DRUG - Dolnośląska Grupa Użytkowników Ruby"] 10 | s.email = ["bbq@drug.org.pl"] 11 | s.homepage = "" 12 | s.description = %q{Objected oriented acceptance testing for Rails, using personas.} 13 | s.summary = %q{Objected oriented acceptance testing for Rails, using personas.} 14 | 15 | s.rubyforge_project = "bbq" 16 | 17 | s.files = `git ls-files`.split("\n") 18 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 19 | s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 20 | s.require_paths = ["lib"] 21 | 22 | s.add_dependency "bbq-core" , "= 0.4.0" 23 | s.add_dependency "bbq-rspec", "= 0.4.0" 24 | s.add_dependency "bbq-rails", "= 0.4.0" 25 | s.add_dependency "bbq-devise", "= 0.4.0" 26 | s.add_dependency "activesupport", ">= 2.0" 27 | 28 | s.add_development_dependency "rake" 29 | s.add_development_dependency "minitest", "~> 5.0" 30 | end 31 | -------------------------------------------------------------------------------- /bbq-rspec/lib/bbq/rspec.rb: -------------------------------------------------------------------------------- 1 | require "bbq/core" 2 | require "bbq/core/test_user" 3 | require "bbq/rspec/version" 4 | require "bbq/rspec/matchers" 5 | require "rspec/core" 6 | require "capybara/rspec/matchers" 7 | 8 | module Bbq 9 | module RSpec 10 | module Feature 11 | def self.included(base) 12 | base.metadata[:type] = :acceptance 13 | base.metadata[:caller] = caller 14 | 15 | base.instance_eval do 16 | alias :background :before 17 | alias :scenario :it 18 | alias :feature :describe 19 | end 20 | end 21 | end 22 | 23 | ::RSpec.configure do |config| 24 | if Gem::Version.new(::RSpec::Core::Version::STRING) >= Gem::Version.new('2.99') 25 | config.include Feature, :type => :acceptance, :file_path => %r{spec/acceptance} 26 | else 27 | config.include Feature, :type => :acceptance, :example_group => {:file_path => %r{spec/acceptance}} 28 | end 29 | config.include Matchers 30 | config.after :each, :type => :acceptance do 31 | ::Bbq::Core::Session.pool.release 32 | end 33 | end 34 | end 35 | 36 | module Core 37 | class TestUser 38 | include Capybara::RSpecMatchers 39 | include ::Bbq::RSpec::Matchers 40 | include ::RSpec::Matchers 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /bbq-core/test/session_pool_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'bbq/core/test_user' 3 | 4 | class SessionPoolTest < Minitest::Test 5 | 6 | def setup 7 | Bbq::Core::Session.instance_variable_set(:@pool, nil) 8 | end 9 | 10 | def test_reuses_sessions 11 | pool = Bbq::Core::Session::Pool.new 12 | user1 = Bbq::Core::TestUser.new(:pool => pool).tap { |u| u.page } 13 | pool.release 14 | user2 = Bbq::Core::TestUser.new(:pool => pool).tap { |u| u.page } 15 | 16 | assert_same user1.page, user2.page 17 | end 18 | 19 | def test_has_default_pool 20 | user1 = Bbq::Core::TestUser.new.tap { |u| u.page } 21 | Bbq::Core::Session::pool.release 22 | user2 = Bbq::Core::TestUser.new.tap { |u| u.page } 23 | 24 | assert_same user1.page, user2.page 25 | end 26 | 27 | def test_without_pool 28 | user1 = Bbq::Core::TestUser.new(:pool => false).tap { |u| u.page } 29 | Bbq::Core::Session::pool.release 30 | user2 = Bbq::Core::TestUser.new(:pool => false).tap { |u| u.page } 31 | 32 | refute_same user1.page, user2.page 33 | end 34 | 35 | def test_pool_returns_correct_driver 36 | pool = Bbq::Core::Session::Pool.new 37 | pool.next(:rack_test) 38 | pool.next(:rack_test_the_other) 39 | pool.release 40 | 41 | assert_equal :rack_test, pool.next(:rack_test).mode 42 | end 43 | 44 | end 45 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/session.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core' 2 | 3 | module Bbq 4 | module Core 5 | module Session 6 | extend self 7 | 8 | def next(options = {}) 9 | driver = options.delete(:driver) 10 | pool = options.delete(:pool) 11 | 12 | if pool 13 | pool.next(driver) 14 | else 15 | create(driver) 16 | end 17 | end 18 | 19 | def create(driver) 20 | Capybara::Session.new(driver, Bbq::Core.app) 21 | end 22 | 23 | def pool 24 | @pool ||= Pool.new 25 | end 26 | 27 | class Pool 28 | attr_accessor :idle, :taken 29 | 30 | def initialize 31 | @idle = [] 32 | @taken = [] 33 | end 34 | 35 | def next(driver) 36 | take_idle(driver) || create(driver) 37 | end 38 | 39 | def release 40 | taken.each(&:reset!) 41 | idle.concat(taken) 42 | taken.clear 43 | end 44 | 45 | private 46 | 47 | def take_idle(driver) 48 | idle.find { |s| s.mode == driver }.tap do |session| 49 | if session 50 | idle.delete(session) 51 | taken.push(session) 52 | end 53 | end 54 | end 55 | 56 | def create(driver) 57 | Bbq::Core::Session.create(driver).tap do |session| 58 | taken.push(session) 59 | end 60 | end 61 | end 62 | end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /bbq/CHANGELOG: -------------------------------------------------------------------------------- 1 | 0.2.1 / 2013-08-22 2 | ================== 3 | 4 | * bugfix: Bbq::TestClient propagates NoMethodErrors from the controller of 5 | tested app instead of rising unsupported method errors. 6 | 7 | 0.2.0 / 2013-01-06 8 | ================== 9 | 10 | * Dropped support for Ruby 1.8.7 11 | * Capybara 2.0 support 12 | 13 | 0.1.0 / 2013-01-06 14 | ================== 15 | 16 | * Extracted Rails' URL helpers inclusion to separate module 17 | * Include only Capybara::Session::DSL_METHODS in TestUser, not the whole Capybara::DSL 18 | * Added Capybara sessions pool 19 | * Moved Test::User default options to separate method 20 | * Added Test::Client for testing REST APIs 21 | * Renamed bbq/test.rb to bbq/test_unit.rb. You may want to fix your test_helper. 22 | * Moved require bbq/test_user to generated test_user.rb. You may want to update your existing test_user.rb. 23 | * Fixed Capybara 'within' scope for RSpec flavour 24 | 25 | 0.0.4 / 2011-10-19 26 | ================== 27 | 28 | * Make Bbq work with Capybara 1.0 and 1.1 29 | * Rails is development dependency 30 | 31 | 0.0.3 / 2011-07-14 32 | ================== 33 | 34 | * Added support and tests for Sinatra 35 | * Added Bbq.app and Bbq.app= 36 | 37 | 0.0.2 / 2011-07-01 38 | ================== 39 | 40 | * Extracted Bbq::TestUser::Eyes module 41 | * Added :within option to TestUser methods 42 | * Fix tests for ree and ruby187 43 | 44 | 0.0.1 / 2011-04-20 45 | ================== 46 | 47 | * Bbq introduced to the wild world! 48 | -------------------------------------------------------------------------------- /bbq-core/CHANGELOG: -------------------------------------------------------------------------------- 1 | 0.2.1 / 2013-08-22 2 | ================== 3 | 4 | * bugfix: Bbq::TestClient propagates NoMethodErrors from the controller of 5 | tested app instead of rising unsupported method errors. 6 | 7 | 0.2.0 / 2013-01-06 8 | ================== 9 | 10 | * Dropped support for Ruby 1.8.7 11 | * Capybara 2.0 support 12 | 13 | 0.1.0 / 2013-01-06 14 | ================== 15 | 16 | * Extracted Rails' URL helpers inclusion to separate module 17 | * Include only Capybara::Session::DSL_METHODS in TestUser, not the whole Capybara::DSL 18 | * Added Capybara sessions pool 19 | * Moved Test::User default options to separate method 20 | * Added Test::Client for testing REST APIs 21 | * Renamed bbq/test.rb to bbq/test_unit.rb. You may want to fix your test_helper. 22 | * Moved require bbq/test_user to generated test_user.rb. You may want to update your existing test_user.rb. 23 | * Fixed Capybara 'within' scope for RSpec flavour 24 | 25 | 0.0.4 / 2011-10-19 26 | ================== 27 | 28 | * Make Bbq work with Capybara 1.0 and 1.1 29 | * Rails is development dependency 30 | 31 | 0.0.3 / 2011-07-14 32 | ================== 33 | 34 | * Added support and tests for Sinatra 35 | * Added Bbq.app and Bbq.app= 36 | 37 | 0.0.2 / 2011-07-01 38 | ================== 39 | 40 | * Extracted Bbq::TestUser::Eyes module 41 | * Added :within option to TestUser methods 42 | * Fix tests for ree and ruby187 43 | 44 | 0.0.1 / 2011-04-20 45 | ================== 46 | 47 | * Bbq introduced to the wild world! 48 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Log error messages when you accidentally call methods on nil. 11 | config.whiny_nils = true 12 | 13 | # Show full error reports and disable caching 14 | config.consider_all_requests_local = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Raise exceptions instead of rendering exception templates 18 | config.action_dispatch.show_exceptions = false 19 | 20 | # Disable request forgery protection in test environment 21 | config.action_controller.allow_forgery_protection = false 22 | 23 | # Tell Action Mailer not to deliver emails to the real world. 24 | # The :test delivery method accumulates sent emails in the 25 | # ActionMailer::Base.deliveries array. 26 | config.action_mailer.delivery_method = :test 27 | 28 | # Use SQL instead of Active Record's schema dumper when creating the test database. 29 | # This is necessary if your schema can't be completely dumped by the schema dumper, 30 | # like if you have constraints or database-specific column types 31 | # config.active_record.schema_format = :sql 32 | 33 | # Print deprecation notices to the stderr 34 | config.active_support.deprecation = :stderr 35 | end 36 | -------------------------------------------------------------------------------- /bbq-devise/lib/bbq/devise.rb: -------------------------------------------------------------------------------- 1 | require "bbq/devise/version" 2 | require "securerandom" 3 | 4 | module Bbq 5 | module Devise 6 | attr_accessor :devise_authentication_key, :email, :password, :scope 7 | 8 | def self.included(klass) 9 | require 'bbq/rails/routes' 10 | klass.send(:include, Bbq::Rails::Routes) 11 | end 12 | 13 | def initialize_devise 14 | @devise_initialized ||= begin 15 | self.devise_authentication_key = ::Devise.authentication_keys.first 16 | self.email = options[devise_authentication_key.to_sym] || Bbq::Devise.next_email 17 | self.password = options[:password] || Bbq::Devise.next_password 18 | self.scope = ::Devise.mappings.first.second.singular.to_s 19 | true 20 | end 21 | end 22 | 23 | def register 24 | initialize_devise 25 | visit send("new_#{scope}_registration_path") 26 | fill_in "#{scope}_#{devise_authentication_key}", :with => @email 27 | fill_in "#{scope}_password", :with => @password 28 | fill_in "#{scope}_password_confirmation", :with => @password 29 | find(:xpath, "//input[@name='commit']").click 30 | end 31 | 32 | def login 33 | initialize_devise 34 | visit send("new_#{scope}_session_path") 35 | fill_in "#{scope}_#{devise_authentication_key}", :with => @email 36 | fill_in "#{scope}_password", :with => @password 37 | find(:xpath, "//input[@name='commit']").click 38 | end 39 | 40 | def logout 41 | visit send("destroy_#{scope}_session_path") 42 | end 43 | 44 | def register_and_login 45 | register 46 | end 47 | 48 | def self.next_email 49 | "#{SecureRandom.hex(3)}@example.com" 50 | end 51 | 52 | def self.next_password 53 | SecureRandom.hex(8) 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /bbq-rspec/lib/bbq/rspec/matchers/see.rb: -------------------------------------------------------------------------------- 1 | module Bbq 2 | module RSpec 3 | module Matchers 4 | module See 5 | class Matcher 6 | attr_reader :text, :scope 7 | 8 | def initialize(text) 9 | @text = text 10 | @scope = nil 11 | end 12 | 13 | def description 14 | if scope 15 | "see #{text} within #{scope}" 16 | else 17 | "see #{text}" 18 | end 19 | end 20 | 21 | def matches?(actor) 22 | @actual = page_fragment(actor) 23 | @actual.has_text?(text) 24 | end 25 | 26 | def does_not_match?(actor) 27 | @actual = page_fragment(actor) 28 | @actual.has_no_text?(text) 29 | end 30 | 31 | def failure_message_for_should 32 | "expected to see \"#{text}\" in #{format(@actual.text)}" 33 | end 34 | alias :failure_message :failure_message_for_should 35 | 36 | def failure_message_for_should_not 37 | "expected not to see \"#{text}\" in #{format(@actual.text)}" 38 | end 39 | alias :failure_message_when_negated :failure_message_for_should_not 40 | 41 | def within(scope) 42 | @scope = scope 43 | self 44 | end 45 | 46 | private 47 | def page_fragment(actor) 48 | if scope 49 | actor.page.first(*scope) 50 | else 51 | actor.page 52 | end 53 | end 54 | 55 | def format(text) 56 | case text 57 | when Regexp 58 | text.inspect 59 | else 60 | text.to_s.gsub(/[[:space:]]+/, ' ').strip.inspect 61 | end 62 | end 63 | end 64 | 65 | def see(text) 66 | Matcher.new(text) 67 | end 68 | end 69 | end 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # The production environment is meant for finished, "live" apps. 5 | # Code is not reloaded between requests 6 | config.cache_classes = true 7 | 8 | # Full error reports are disabled and caching is turned on 9 | config.consider_all_requests_local = false 10 | config.action_controller.perform_caching = true 11 | 12 | # Specifies the header that your server uses for sending files 13 | config.action_dispatch.x_sendfile_header = "X-Sendfile" 14 | 15 | # For nginx: 16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' 17 | 18 | # If you have no front-end server that supports something like X-Sendfile, 19 | # just comment this out and Rails will serve the files 20 | 21 | # See everything in the log (default is :info) 22 | # config.log_level = :debug 23 | 24 | # Use a different logger for distributed setups 25 | # config.logger = SyslogLogger.new 26 | 27 | # Use a different cache store in production 28 | # config.cache_store = :mem_cache_store 29 | 30 | # Disable Rails's static asset server 31 | # In production, Apache or nginx will already do this 32 | config.serve_static_assets = false 33 | 34 | # Enable serving of images, stylesheets, and javascripts from an asset server 35 | # config.action_controller.asset_host = "http://assets.example.com" 36 | 37 | # Disable delivery errors, bad email addresses will be ignored 38 | # config.action_mailer.raise_delivery_errors = false 39 | 40 | # Enable threaded mode 41 | # config.threadsafe! 42 | 43 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 44 | # the I18n.default_locale when a translation can not be found) 45 | config.i18n.fallbacks = true 46 | 47 | # Send deprecation notices to registered listeners 48 | config.active_support.deprecation = :notify 49 | end 50 | -------------------------------------------------------------------------------- /bbq-rails/README.md: -------------------------------------------------------------------------------- 1 | # Bbq::Rails 2 | 3 | [![Build Status](https://secure.travis-ci.org/drugpl/bbq-rails.png)](http://travis-ci.org/drugpl/bbq-rails) [![Dependency Status](https://gemnasium.com/drugpl/bbq-rails.png)](https://gemnasium.com/drugpl/bbq-rails) [![Code Climate](https://codeclimate.com/github/drugpl/bbq-rails.png)](https://codeclimate.com/github/drugpl/bbq-rails) [![Gem Version](https://badge.fury.io/rb/bbq-rails.png)](http://badge.fury.io/rb/bbq-rails) 4 | 5 | ## Quick start 6 | 7 | Add following to your Gemfile: 8 | 9 | ```ruby 10 | gem 'bbq-rails', require: 'bbq/rails' 11 | 12 | ``` 13 | 14 | You may also run `rails generate bbq:install` to have a basic configuration generated. 15 | 16 | ## Features 17 | 18 | ### Test integration 19 | 20 | Your Rails application hooks up to `Bbq::Core.app` in tests automatically. Thus `Bbq::Core::TestUser` and `Bbq::Core::TestClient` can run against it. 21 | 22 | ### Generators 23 | 24 | Generators help you kickstart Bbq test environment. 25 | 26 | At the beginning of your journey with Bbq you can use `rails generate bbq:install`. It'll create directory for acceptance test files and give you basic TestUser class for customization. 27 | 28 | There's also `rails generate bbq:test` which creates new test files for you which have Bbq goodies baked in (DSL and test actor session pool handling). 29 | 30 | ### Rake integration 31 | 32 | Provided you've created `spec/acceptance` or `test/acceptance` directory, there we'll be following tasks for running acceptance tests available: `bundle exec rake spec:acceptance` or `bundle exec rake test:acceptance` respectively. 33 | 34 | ### Routes 35 | 36 | When you require 'bbq/rails/routes' you can then `include Bbq::Rails::Routes` in TestActor to have access to Rails url helpers. While convenient it's not recommended in general. Testing routes is part of acceptance test. Use links and buttons in order to get to other pages in your app. 37 | 38 | ```ruby 39 | require 'bbq/rails/routes' 40 | 41 | class TestUser < Bbq::TestUser 42 | include Bbq::Rails::Routes 43 | end 44 | ``` 45 | 46 | ## Development 47 | 48 | We develop and test against multiple Rails versions. When working with legacy software a test toolkit should be the last to require special attention. 49 | 50 | ```sh 51 | for gemfile in `ls Gemfile* | grep -v lock`; do 52 | BUNDLE_GEMFILE=$gemfile bundle install 53 | BUNDLE_GEMFILE=$gemfile bundle exec rake test 54 | done 55 | -------------------------------------------------------------------------------- /bbq-core/lib/bbq/core/test_client.rb: -------------------------------------------------------------------------------- 1 | require 'bbq/core/roles' 2 | 3 | module Bbq 4 | module Core 5 | class TestClient 6 | class UnsupportedMethodError < StandardError; end 7 | 8 | include Bbq::Core::Roles 9 | 10 | def initialize(options = {}) 11 | @options = options 12 | end 13 | 14 | HTTP_METHODS = %w(get post put delete head options patch) 15 | 16 | HTTP_METHODS.each do |method| 17 | class_eval <<-RUBY 18 | def #{method}(path, params = {}, headers = {}) 19 | unless driver.respond_to? :#{method} 20 | raise UnsupportedMethodError, "Your driver does not support #{method.upcase} method" 21 | end 22 | 23 | response = driver.#{method}(path, params, default_headers.merge(headers)) 24 | parsed_response = parse_response(response) 25 | yield parsed_response if block_given? 26 | parsed_response 27 | end 28 | RUBY 29 | end 30 | 31 | protected 32 | def app 33 | @options[:app] || Bbq::Core.app 34 | end 35 | 36 | def default_headers 37 | @options[:headers] || {} 38 | end 39 | 40 | def driver 41 | @driver ||= RackTest.new(app) 42 | end 43 | 44 | def parse_response(response) 45 | case response.headers["Content-Type"] 46 | when /^application\/(.*\+)?json/ 47 | response.extend(JsonBody) 48 | when /^application\/(.*\+)?x-yaml/ 49 | response.extend(YamlBody) 50 | else 51 | response 52 | end 53 | end 54 | 55 | class RackTest 56 | attr_accessor :app 57 | 58 | def initialize(app) 59 | self.app = app 60 | end 61 | 62 | module ConvertHeaders 63 | HTTP_METHODS.each do |method| 64 | class_eval <<-RUBY 65 | def #{method}(path, params = {}, headers = {}) 66 | super(path, params, to_env_headers(headers)) 67 | end 68 | RUBY 69 | end 70 | 71 | def to_env_headers(http_headers) 72 | http_headers.map do |k, v| 73 | k = k.upcase.gsub("-", "_") 74 | k = "HTTP_#{k}" unless ["CONTENT_TYPE", "CONTENT_LENGTH"].include?(k) 75 | { k => v } 76 | end.inject({}, :merge) 77 | end 78 | end 79 | 80 | include Rack::Test::Methods 81 | include ConvertHeaders 82 | end 83 | 84 | module JsonBody 85 | def body 86 | @parsed_body ||= super.empty?? super : JSON.parse(super) 87 | end 88 | end 89 | 90 | module YamlBody 91 | def body 92 | @parsed_body ||= YAML.load(super) 93 | end 94 | end 95 | end 96 | end 97 | end 98 | -------------------------------------------------------------------------------- /bbq-rspec/README.md: -------------------------------------------------------------------------------- 1 | # Bbq-rspec 2 | 3 | [![Build Status](https://secure.travis-ci.org/drugpl/bbq-rspec.png)](http://travis-ci.org/drugpl/bbq-rspec) [![Dependency Status](https://gemnasium.com/drugpl/bbq-rspec.png)](https://gemnasium.com/drugpl/bbq-rspec) [![Code Climate](https://codeclimate.com/github/drugpl/bbq-rspec.png)](https://codeclimate.com/github/drugpl/bbq-rspec) [![Gem Version](https://badge.fury.io/rb/bbq-rspec.png)](http://badge.fury.io/rb/bbq-rspec) 4 | 5 | 6 | RSpec integration for object oriented acceptance testing with [bbq](https://github.com/drugpl/bbq). 7 | 8 | ## Setup 9 | 10 | Add `bbq-rspec` to your `Gemfile`: 11 | 12 | ```ruby 13 | gem "bbq-rspec" 14 | ``` 15 | 16 | Run install generator: 17 | 18 | ``` 19 | bundle exec rails generate bbq:install 20 | ``` 21 | 22 | Require BBQ in spec/spec_helper.rb: 23 | 24 | ```ruby 25 | require "bbq/rspec" 26 | ``` 27 | 28 | ## Feature generator 29 | 30 | ``` 31 | bundle exec rails g bbq:test MyFeatureName 32 | ``` 33 | 34 | ## Running features 35 | 36 | ``` 37 | bundle exec rake spec:acceptance 38 | ``` 39 | 40 | ## Examples 41 | 42 | ```ruby 43 | class TestUser < Bbq::TestUser 44 | def email 45 | @options[:email] || "buyer@example.com" 46 | end 47 | 48 | module Buyer 49 | def ask_question(question) 50 | fill_in "question", :with => question 51 | fill_in "email", :with => email 52 | click_on("Ask") 53 | end 54 | 55 | def go_to_page_and_open_widget(page_url, &block) 56 | go_to_page(page_url) 57 | open_widget &block 58 | end 59 | 60 | def go_to_page(page_url) 61 | visit page_url 62 | wait_until { page.find("iframe") } 63 | end 64 | 65 | def open_widget 66 | within_widget do 67 | page.find("#widget h3").click 68 | yield if block_given? 69 | end 70 | end 71 | 72 | def within_widget(&block) 73 | within_frame(widget_frame, &block) 74 | end 75 | 76 | def widget_frame 77 | page.evaluate_script("document.getElementsByTagName('iframe')[0].id") 78 | end 79 | end 80 | end 81 | ``` 82 | 83 | ```ruby 84 | feature "ask question widget" do 85 | let(:user) { 86 | user = TestUser.new(:driver => :webkit) 87 | user.roles('buyer') 88 | user 89 | } 90 | 91 | scenario "as a guest user, I should be able to ask a question" do 92 | user.go_to_page_and_open_widget("/widget") do 93 | user.ask_question "my question" 94 | expect(user).to see("Thanks!") 95 | end 96 | end 97 | end 98 | ``` 99 | 100 | ## Contributing 101 | 102 | 1. Fork it ( https://github.com/drugpl/bbq-rspec/fork ) 103 | 2. Create your feature branch (`git checkout -b my-new-feature`) 104 | 3. Commit your changes (`git commit -am 'Add some feature'`) 105 | 4. Push to the branch (`git push origin my-new-feature`) 106 | 5. Create a new Pull Request 107 | -------------------------------------------------------------------------------- /bbq-core/test/test_user_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'bbq/core/test_user' 3 | 4 | 5 | def text(output) 6 | end 7 | 8 | def html(output) 9 | ->{ ['200', {'Content-Type' => 'text/html'}, [output]] } 10 | end 11 | 12 | TestApp = Rack::Builder.new do 13 | map '/' do 14 | run ->(env) { ['200', {'Content-Type' => 'text/plain'}, ['BBQ']] } 15 | end 16 | 17 | map '/miracle' do 18 | run ->(env) { ['200', {'Content-Type' => 'text/plain'}, ['MIRACLE']] } 19 | end 20 | 21 | map '/ponycorns' do 22 | run ->(env) { ['200', {'Content-Type' => 'text/html'}, [< 24 |
  • Pink
  • 25 | 26 | 29 |
    30 | 31 |
    32 | More ponycorns 33 | HTML 34 | ]] } 35 | end 36 | end 37 | 38 | 39 | class TestUser < Bbq::Core::TestUser 40 | module Commenter 41 | def comment 42 | end 43 | end 44 | 45 | module VideoUploader 46 | def upload 47 | end 48 | end 49 | 50 | module CommentModerator 51 | def moderate 52 | end 53 | end 54 | end 55 | 56 | class TestUserTest < Minitest::Test 57 | 58 | def setup 59 | Bbq::Core.app = TestApp 60 | end 61 | 62 | def teardown 63 | Bbq::Core.app = nil 64 | end 65 | 66 | def test_capybara_dsl_methods 67 | user = TestUser.new 68 | Capybara::Session::DSL_METHODS.each do |m| 69 | assert user.respond_to?(m) 70 | end 71 | end 72 | 73 | def test_driver_option 74 | user = TestUser.new(:driver => :rack_test_the_other) 75 | assert_equal :rack_test_the_other, user.page.mode 76 | end 77 | 78 | def test_roles 79 | user = TestUser.new 80 | %w(comment upload moderate).each { |m| assert !user.respond_to?(m) } 81 | 82 | user.roles(:commenter, "comment_moderator") 83 | %w(comment moderate).each { |m| assert user.respond_to?(m) } 84 | assert !user.respond_to?(:upload) 85 | 86 | user.roles(:video_uploader) 87 | %w(comment upload moderate).each { |m| assert user.respond_to?(m) } 88 | end 89 | 90 | def test_explicit_user_eyes 91 | @user = TestUser.new 92 | @user.visit "/miracle" 93 | assert @user.not_see?("BBQ") 94 | assert @user.see?("MIRACLE") 95 | end 96 | 97 | def test_user_eyes_within_scope 98 | @user = TestUser.new 99 | @user.visit "/ponycorns" 100 | assert @user.see?("Pink", :within => "#unicorns") 101 | assert ! @user.see?("Violet", :within => "#unicorns") 102 | assert @user.not_see?("Violet", :within => "#unicorns") 103 | assert ! @user.not_see?("Pink", :within => "#unicorns") 104 | 105 | @user.fill_in "color", :with => "red", :within => "#new_pony" 106 | assert_raises Capybara::ElementNotFound do 107 | @user.fill_in "color", :with => "red", :within => "#new_unicorn" 108 | end 109 | @user.click_link "More ponycorns" 110 | end 111 | 112 | end 113 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | UPSTREAM_REV = `git rev-parse upstream/master` 2 | ORIGIN_REV = `git rev-parse origin/master` 3 | CURRENT_REV = `git rev-parse HEAD` 4 | BBQ_VERSION ?= $(shell cat BBQ_VERSION) 5 | NIX_TYPE = $(shell uname -s) 6 | GEMS = bbq \ 7 | bbq-core \ 8 | bbq-rspec \ 9 | bbq-rails \ 10 | bbq-devise 11 | 12 | ifeq ($(NIX_TYPE),Linux) 13 | SED_OPTS = -i 14 | endif 15 | 16 | ifeq ($(NIX_TYPE),Darwin) 17 | SED_OPTS = -i "" 18 | endif 19 | 20 | $(addprefix install-, $(GEMS)): 21 | @make -C $(subst install-,,$@) install 22 | 23 | $(addprefix reinstall-, $(GEMS)): 24 | @make -C $(subst reinstall-,,$@) reinstall 25 | 26 | $(addprefix test-, $(GEMS)): 27 | @make -C $(subst test-,,$@) test 28 | 29 | $(addprefix build-, $(GEMS)): 30 | @make -C $(subst build-,,$@) build 31 | 32 | $(addprefix push-, $(GEMS)): 33 | @make -C $(subst push-,,$@) push 34 | 35 | $(addprefix clean-, $(GEMS)): 36 | @make -C $(subst clean-,,$@) clean 37 | 38 | git-check-clean: 39 | @git diff --quiet --exit-code 40 | 41 | git-check-committed: 42 | @git diff-index --quiet --cached HEAD 43 | 44 | git-tag: 45 | @git tag -m "Version v$(BBQ_VERSION)" v$(BBQ_VERSION) 46 | @git push origin master --tags 47 | 48 | git-rebase-from-upstream: 49 | @git remote remove upstream > /dev/null 2>&1 || true 50 | @git remote add upstream git@github.com:RailsEventStore/rails_event_store.git 51 | @git fetch upstream master 52 | @git rebase upstream/master 53 | @git push origin master 54 | 55 | set-version: git-check-clean git-check-committed 56 | @echo $(BBQ_VERSION) > BBQ_VERSION 57 | @find . -path ./contrib -prune -o -name version.rb -exec sed $(SED_OPTS) "s/\(VERSION = \)\(.*\)/\1\"$(BBQ_VERSION)\"/" {} \; 58 | @find . -path ./contrib -prune -o -name *.gemspec -exec sed $(SED_OPTS) "s/\(\"bbq-core\", \)\(.*\)/\1\"= $(BBQ_VERSION)\"/" {} \; 59 | @find . -path ./contrib -prune -o -name *.gemspec -exec sed $(SED_OPTS) "s/\(\"bbq-rspec\", \)\(.*\)/\1\"= $(BBQ_VERSION)\"/" {} \; 60 | @find . -path ./contrib -prune -o -name *.gemspec -exec sed $(SED_OPTS) "s/\(\"bbq-rails\", \)\(.*\)/\1\"= $(BBQ_VERSION)\"/" {} \; 61 | @find . -path ./contrib -prune -o -name *.gemspec -exec sed $(SED_OPTS) "s/\(\"bbq-devise\", \)\(.*\)/\1\"= $(BBQ_VERSION)\"/" {} \; 62 | @git add -A **/*.gemspec **/version.rb BBQ_VERSION 63 | @git commit -m "Version v$(BBQ_VERSION)" 64 | 65 | install: $(addprefix install-, $(GEMS)) ## Install all dependencies 66 | 67 | reinstall: $(addprefix reinstall-, $(GEMS)) ## Reinstall (with new resolve) dependencies 68 | 69 | test: $(addprefix test-, $(GEMS)) ## Run all unit tests 70 | 71 | build: $(addprefix build-, $(GEMS)) ## Build all gem packages 72 | 73 | push: $(addprefix push-, $(GEMS)) ## Push all gem packages to RubyGems 74 | 75 | clean: $(addprefix clean-, $(GEMS)) ## Remove all previously built packages 76 | 77 | release: git-check-clean git-check-committed install test git-tag clean build push ## Make a new release on RubyGems 78 | @echo Released v$(BBQ_VERSION) 79 | 80 | include support/make/help.mk 81 | -------------------------------------------------------------------------------- /bbq/README.md: -------------------------------------------------------------------------------- 1 | # BBQ 2 | 3 | [![Build Status](https://secure.travis-ci.org/drugpl/bbq.png)](http://travis-ci.org/drugpl/bbq) [![Dependency Status](https://gemnasium.com/drugpl/bbq.png)](https://gemnasium.com/drugpl/bbq) [![Code Climate](https://codeclimate.com/github/drugpl/bbq.png)](https://codeclimate.com/github/drugpl/bbq) [![Gem Version](https://badge.fury.io/rb/bbq.png)](http://badge.fury.io/rb/bbq) 4 | 5 | Object oriented acceptance testing using personas. 6 | 7 | * Ruby (no Gherkin) 8 | * Objects and methods instead of steps 9 | * Test framework independent (RSpec and Test::Unit support) 10 | * Thins based on Capybara. 11 | * DCI (Data Context Interaction) for roles/personas 12 | * Opinionated 13 | 14 | ## Setup 15 | 16 | First, add BBQ to your apps `Gemfile`: 17 | 18 | ```ruby 19 | gem "bbq", "0.2.1" 20 | ``` 21 | 22 | Run install generator: 23 | 24 | ``` 25 | bundle exec rails generate bbq:install 26 | ``` 27 | 28 | Require BBQ in test/test_helper.rb (in case of Test::Unit): 29 | 30 | ```ruby 31 | require "bbq/test_unit" 32 | ``` 33 | 34 | Require BBQ in spec/spec_helper.rb (in case of RSpec): 35 | 36 | ```ruby 37 | require "bbq/rspec" 38 | ``` 39 | 40 | ## Feature generator 41 | 42 | ``` 43 | bundle exec rails g bbq:test MyFeatureName 44 | ``` 45 | 46 | ## Running features 47 | 48 | For Test::Unit flavour: 49 | 50 | ``` 51 | bundle exec rake test:acceptance 52 | ``` 53 | 54 | For RSpec flavour: 55 | 56 | ``` 57 | bundle exec rake spec:acceptance 58 | ``` 59 | 60 | ## Examples 61 | 62 | ### Roles and Devise integration 63 | 64 | ```ruby 65 | class TestUser < Bbq::TestUser 66 | include Bbq::Devise 67 | 68 | def update_ticket(summary, comment) 69 | show_ticket(summary) 70 | fill_in "Comment", :with => comment 71 | click_on "Add update" 72 | end 73 | 74 | def open_application 75 | visit '/' 76 | end 77 | 78 | module TicketReporter 79 | def open_tickets_listing 80 | open_application 81 | click_link 'Tickets' 82 | end 83 | 84 | def open_ticket(summary, description) 85 | open_tickets_listing 86 | click_on "Open a new ticket" 87 | fill_in "Summary", :with => summary 88 | fill_in "Description", :with => description 89 | click_on "Open ticket" 90 | end 91 | 92 | def show_ticket(summary) 93 | open_tickets_listing 94 | click_on summary 95 | end 96 | end 97 | 98 | module TicketManager 99 | def open_administration 100 | visit '/admin' 101 | end 102 | 103 | def open_tickets_listing 104 | open_administration 105 | click_link 'Tickets' 106 | end 107 | 108 | def close_ticket(summary, comment = nil) 109 | open_tickets_listing 110 | click_on summary 111 | fill_in "Comment", :with => comment if comment 112 | click_on "Close ticket" 113 | end 114 | 115 | def show_ticket(summary) 116 | open_tickets_listing 117 | click_on summary 118 | end 119 | end 120 | end 121 | ``` 122 | 123 | ```ruby 124 | class AdminTicketsTest < Bbq::TestCase 125 | background do 126 | admin = Factory(:admin) 127 | @email, @password = admin.email, admin.password 128 | end 129 | 130 | scenario "admin can browse all user tickets" do 131 | summaries = ["Forgot my password", "Page is not displayed correctly"] 132 | descriptions = ["I lost my yellow note with password under the table!", 133 | "My IE renders crap instead of crispy fonts!"] 134 | 135 | alice = TestUser.new 136 | alice.roles(:ticket_reporter) 137 | alice.register_and_login 138 | alice.open_ticket(summaries.first, descriptions.first) 139 | 140 | bob = TestUser.new 141 | bob.roles(:ticket_reporter) 142 | bob.register_and_login 143 | bob.open_ticket(summaries.second, descriptions.second) 144 | 145 | charlie = TestUser.new(:email => @email, :password => @password) 146 | charlie.login # charlie was already "registered" in factory as admin 147 | charlie.roles(:ticket_manager) 148 | charlie.open_tickets_listing 149 | charlie.see!(*summaries) 150 | 151 | charlie.click_on(summaries.second) 152 | charlie.see!(summaries.second, descriptions.second) 153 | charlie.not_see!(summaries.first, descriptions.first) 154 | end 155 | end 156 | ``` 157 | 158 | ### RSpec integration 159 | 160 | ```ruby 161 | class TestUser < Bbq::TestUser 162 | def email 163 | @options[:email] || "buyer@example.com" 164 | end 165 | 166 | module Buyer 167 | def ask_question(question) 168 | fill_in "question", :with => question 169 | fill_in "email", :with => email 170 | click_on("Ask") 171 | end 172 | 173 | def go_to_page_and_open_widget(page_url, &block) 174 | go_to_page(page_url) 175 | open_widget &block 176 | end 177 | 178 | def go_to_page(page_url) 179 | visit page_url 180 | wait_until { page.find("iframe") } 181 | end 182 | 183 | def open_widget 184 | within_widget do 185 | page.find("#widget h3").click 186 | yield if block_given? 187 | end 188 | end 189 | 190 | ef within_widget(&block) 191 | within_frame(widget_frame, &block) 192 | end 193 | 194 | def widget_frame 195 | page.evaluate_script("document.getElementsByTagName('iframe')[0].id") 196 | end 197 | end 198 | end 199 | ``` 200 | 201 | ```ruby 202 | feature "ask question widget" do 203 | let(:user) { 204 | user = TestUser.new(:driver => :webkit) 205 | user.roles('buyer') 206 | user 207 | } 208 | 209 | scenario "as a guest user, I should be able to ask a question" do 210 | user.go_to_page_and_open_widget("/widget") do 211 | user.ask_question "my question" 212 | user.see!("Thanks!") 213 | end 214 | end 215 | end 216 | ``` 217 | 218 | ## Testing REST APIs 219 | 220 | Bbq provides `Bbq::TestClient`, similar to `Bbq::TestUser`, but intended for testing APIs. 221 | It's a thin wrapper around `Rack::Test` which allows you to send requests and run assertions 222 | against responses. 223 | 224 | ```ruby 225 | class ApiTest < Bbq::TestCase 226 | background do 227 | headers = {'HTTP_ACCEPT' => 'application/json'} 228 | @client = TestClient.new(:headers => headers) 229 | end 230 | 231 | scenario "admin can browse all user tickets" do 232 | @client.get "/unicorn" do |response| 233 | assert_equal 200, response.status 234 | assert_equal "pink", response.body["unicorn"]["color"] 235 | end 236 | @client.post "/ponies", { :name => "Miracle" } do |response| 237 | assert_equal 200, response.status 238 | end 239 | end 240 | end 241 | ``` 242 | 243 | ## Rails URL Helpers 244 | 245 | Using url helpers from Rails in integration tests is not recommended. 246 | Testing routes is part of integration test, so you should actually use only 247 | 248 | ```ruby 249 | visit '/' 250 | ``` 251 | 252 | in your integration test. Use links and buttons in order to get to other pages in your app. 253 | 254 | If you really need url helpers in your test user, just include them in your TestUser class: 255 | 256 | ```ruby 257 | require 'bbq/rails/routes' 258 | 259 | class TestUser < Bbq::TestUser 260 | include Bbq::Rails::Routes 261 | end 262 | ``` 263 | or just 264 | 265 | ```ruby 266 | class TestUser < Bbq::TestUser 267 | include ::ActionDispatch::Routing::UrlFor 268 | include ::Rails.application.routes.url_helpers 269 | include ::ActionDispatch::Routing::RouteSet::MountedHelpers unless ::Rails.version < "3.1" 270 | end 271 | ``` 272 | 273 | ## Devise support 274 | 275 | ```ruby 276 | require "bbq/test_user" 277 | require "bbq/devise" 278 | 279 | class TestUser < Bbq::TestUser 280 | include Bbq::Devise 281 | end 282 | ``` 283 | 284 | After that TestUser have *login*, *logout*, *register*, *register_and_login* methods. 285 | 286 | ```ruby 287 | test "user register with devise" do 288 | user = TestUser.new # or TestUser.new(:email => "email@example.com", :password => "secret") 289 | user.register_and_login 290 | user.see!("Stuff after auth") 291 | end 292 | ``` 293 | 294 | ## Caveats 295 | 296 | ### Timeout::Error 297 | 298 | If you simulate multiple users in your tests and spawn multiple browsers with selenium it might 299 | be a good idea to use Thin instead of Webrick to create application server. 300 | We have experienced some problems with Webrick that lead to `Timeout::Error` exception 301 | when user/browser that was inactive for some time (due to other users/browsers 302 | activities) was requested to execute an action. 303 | 304 | Capybara will use Thin instead of Webrick when it's available, so you only need to add Thin to you Gemfile: 305 | 306 | ```ruby 307 | # In test group if you want it to 308 | # be used only in tests and not in your development mode 309 | # ex. when running 'rails s' 310 | 311 | gem 'thin', :require => false 312 | ``` 313 | 314 | ## Additional information 315 | 316 | * [2 problems with Cucumber](http://andrzejonsoftware.blogspot.com/2011/03/2-problems-with-cucumber.html) 317 | * [Object oriented acceptance testing](http://andrzejonsoftware.blogspot.com/2011/04/object-oriented-acceptance-testing.html) 318 | 319 | -------------------------------------------------------------------------------- /bbq-core/README.md: -------------------------------------------------------------------------------- 1 | # BBQ 2 | 3 | [![Build Status](https://secure.travis-ci.org/drugpl/bbq-core.png)](http://travis-ci.org/drugpl/bbq-core) [![Dependency Status](https://gemnasium.com/drugpl/bbq-core.png)](https://gemnasium.com/drugpl/bbq-core) [![Code Climate](https://codeclimate.com/github/drugpl/bbq-core.png)](https://codeclimate.com/github/drugpl/bbq-core) [![Gem Version](https://badge.fury.io/rb/bbq-core.png)](http://badge.fury.io/rb/bbq-core) 4 | 5 | Object oriented acceptance testing using personas. 6 | 7 | * Ruby (no Gherkin) 8 | * Objects and methods instead of steps 9 | * Test framework independent (RSpec and Test::Unit support) 10 | * Thins based on Capybara. 11 | * DCI (Data Context Interaction) for roles/personas 12 | * Opinionated 13 | 14 | ## Setup 15 | 16 | First, add BBQ to your apps `Gemfile`: 17 | 18 | ```ruby 19 | gem "bbq", "0.2.1" 20 | ``` 21 | 22 | Run install generator: 23 | 24 | ``` 25 | bundle exec rails generate bbq:install 26 | ``` 27 | 28 | Require BBQ in test/test_helper.rb (in case of Test::Unit): 29 | 30 | ```ruby 31 | require "bbq/test_unit" 32 | ``` 33 | 34 | Require BBQ in spec/spec_helper.rb (in case of RSpec): 35 | 36 | ```ruby 37 | require "bbq/rspec" 38 | ``` 39 | 40 | ## Feature generator 41 | 42 | ``` 43 | bundle exec rails g bbq:test MyFeatureName 44 | ``` 45 | 46 | ## Running features 47 | 48 | For Test::Unit flavour: 49 | 50 | ``` 51 | bundle exec rake test:acceptance 52 | ``` 53 | 54 | For RSpec flavour: 55 | 56 | ``` 57 | bundle exec rake spec:acceptance 58 | ``` 59 | 60 | ## Examples 61 | 62 | ### Roles and Devise integration 63 | 64 | ```ruby 65 | class TestUser < Bbq::TestUser 66 | include Bbq::Devise 67 | 68 | def update_ticket(summary, comment) 69 | show_ticket(summary) 70 | fill_in "Comment", :with => comment 71 | click_on "Add update" 72 | end 73 | 74 | def open_application 75 | visit '/' 76 | end 77 | 78 | module TicketReporter 79 | def open_tickets_listing 80 | open_application 81 | click_link 'Tickets' 82 | end 83 | 84 | def open_ticket(summary, description) 85 | open_tickets_listing 86 | click_on "Open a new ticket" 87 | fill_in "Summary", :with => summary 88 | fill_in "Description", :with => description 89 | click_on "Open ticket" 90 | end 91 | 92 | def show_ticket(summary) 93 | open_tickets_listing 94 | click_on summary 95 | end 96 | end 97 | 98 | module TicketManager 99 | def open_administration 100 | visit '/admin' 101 | end 102 | 103 | def open_tickets_listing 104 | open_administration 105 | click_link 'Tickets' 106 | end 107 | 108 | def close_ticket(summary, comment = nil) 109 | open_tickets_listing 110 | click_on summary 111 | fill_in "Comment", :with => comment if comment 112 | click_on "Close ticket" 113 | end 114 | 115 | def show_ticket(summary) 116 | open_tickets_listing 117 | click_on summary 118 | end 119 | end 120 | end 121 | ``` 122 | 123 | ```ruby 124 | class AdminTicketsTest < Bbq::TestCase 125 | background do 126 | admin = Factory(:admin) 127 | @email, @password = admin.email, admin.password 128 | end 129 | 130 | scenario "admin can browse all user tickets" do 131 | summaries = ["Forgot my password", "Page is not displayed correctly"] 132 | descriptions = ["I lost my yellow note with password under the table!", 133 | "My IE renders crap instead of crispy fonts!"] 134 | 135 | alice = TestUser.new 136 | alice.roles(:ticket_reporter) 137 | alice.register_and_login 138 | alice.open_ticket(summaries.first, descriptions.first) 139 | 140 | bob = TestUser.new 141 | bob.roles(:ticket_reporter) 142 | bob.register_and_login 143 | bob.open_ticket(summaries.second, descriptions.second) 144 | 145 | charlie = TestUser.new(:email => @email, :password => @password) 146 | charlie.login # charlie was already "registered" in factory as admin 147 | charlie.roles(:ticket_manager) 148 | charlie.open_tickets_listing 149 | charlie.see!(*summaries) 150 | 151 | charlie.click_on(summaries.second) 152 | charlie.see!(summaries.second, descriptions.second) 153 | charlie.not_see!(summaries.first, descriptions.first) 154 | end 155 | end 156 | ``` 157 | 158 | ### RSpec integration 159 | 160 | ```ruby 161 | class TestUser < Bbq::TestUser 162 | def email 163 | @options[:email] || "buyer@example.com" 164 | end 165 | 166 | module Buyer 167 | def ask_question(question) 168 | fill_in "question", :with => question 169 | fill_in "email", :with => email 170 | click_on("Ask") 171 | end 172 | 173 | def go_to_page_and_open_widget(page_url, &block) 174 | go_to_page(page_url) 175 | open_widget &block 176 | end 177 | 178 | def go_to_page(page_url) 179 | visit page_url 180 | wait_until { page.find("iframe") } 181 | end 182 | 183 | def open_widget 184 | within_widget do 185 | page.find("#widget h3").click 186 | yield if block_given? 187 | end 188 | end 189 | 190 | ef within_widget(&block) 191 | within_frame(widget_frame, &block) 192 | end 193 | 194 | def widget_frame 195 | page.evaluate_script("document.getElementsByTagName('iframe')[0].id") 196 | end 197 | end 198 | end 199 | ``` 200 | 201 | ```ruby 202 | feature "ask question widget" do 203 | let(:user) { 204 | user = TestUser.new(:driver => :webkit) 205 | user.roles('buyer') 206 | user 207 | } 208 | 209 | scenario "as a guest user, I should be able to ask a question" do 210 | user.go_to_page_and_open_widget("/widget") do 211 | user.ask_question "my question" 212 | user.see!("Thanks!") 213 | end 214 | end 215 | end 216 | ``` 217 | 218 | ## Testing REST APIs 219 | 220 | Bbq provides `Bbq::TestClient`, similar to `Bbq::TestUser`, but intended for testing APIs. 221 | It's a thin wrapper around `Rack::Test` which allows you to send requests and run assertions 222 | against responses. 223 | 224 | ```ruby 225 | class ApiTest < Bbq::TestCase 226 | background do 227 | headers = {'HTTP_ACCEPT' => 'application/json'} 228 | @client = TestClient.new(:headers => headers) 229 | end 230 | 231 | scenario "admin can browse all user tickets" do 232 | @client.get "/unicorn" do |response| 233 | assert_equal 200, response.status 234 | assert_equal "pink", response.body["unicorn"]["color"] 235 | end 236 | @client.post "/ponies", { :name => "Miracle" } do |response| 237 | assert_equal 200, response.status 238 | end 239 | end 240 | end 241 | ``` 242 | 243 | ## Rails URL Helpers 244 | 245 | Using url helpers from Rails in integration tests is not recommended. 246 | Testing routes is part of integration test, so you should actually use only 247 | 248 | ```ruby 249 | visit '/' 250 | ``` 251 | 252 | in your integration test. Use links and buttons in order to get to other pages in your app. 253 | 254 | If you really need url helpers in your test user, just include them in your TestUser class: 255 | 256 | ```ruby 257 | require 'bbq/rails/routes' 258 | 259 | class TestUser < Bbq::TestUser 260 | include Bbq::Rails::Routes 261 | end 262 | ``` 263 | or just 264 | 265 | ```ruby 266 | class TestUser < Bbq::TestUser 267 | include ::ActionDispatch::Routing::UrlFor 268 | include ::Rails.application.routes.url_helpers 269 | include ::ActionDispatch::Routing::RouteSet::MountedHelpers unless ::Rails.version < "3.1" 270 | end 271 | ``` 272 | 273 | ## Devise support 274 | 275 | ```ruby 276 | require "bbq/test_user" 277 | require "bbq/devise" 278 | 279 | class TestUser < Bbq::TestUser 280 | include Bbq::Devise 281 | end 282 | ``` 283 | 284 | After that TestUser have *login*, *logout*, *register*, *register_and_login* methods. 285 | 286 | ```ruby 287 | test "user register with devise" do 288 | user = TestUser.new # or TestUser.new(:email => "email@example.com", :password => "secret") 289 | user.register_and_login 290 | user.see!("Stuff after auth") 291 | end 292 | ``` 293 | 294 | ## Caveats 295 | 296 | ### Timeout::Error 297 | 298 | If you simulate multiple users in your tests and spawn multiple browsers with selenium it might 299 | be a good idea to use Thin instead of Webrick to create application server. 300 | We have experienced some problems with Webrick that lead to `Timeout::Error` exception 301 | when user/browser that was inactive for some time (due to other users/browsers 302 | activities) was requested to execute an action. 303 | 304 | Capybara will use Thin instead of Webrick when it's available, so you only need to add Thin to you Gemfile: 305 | 306 | ```ruby 307 | # In test group if you want it to 308 | # be used only in tests and not in your development mode 309 | # ex. when running 'rails s' 310 | 311 | gem 'thin', :require => false 312 | ``` 313 | 314 | ## Additional information 315 | 316 | * [2 problems with Cucumber](http://andrzejonsoftware.blogspot.com/2011/03/2-problems-with-cucumber.html) 317 | * [Object oriented acceptance testing](http://andrzejonsoftware.blogspot.com/2011/04/object-oriented-acceptance-testing.html) 318 | 319 | -------------------------------------------------------------------------------- /bbq-devise/test/dummy/config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | require 'devise/version' 2 | 3 | # Use this hook to configure devise mailer, warden hooks and so forth. The first 4 | # four configuration values can also be set straight in your models. 5 | Devise.setup do |config| 6 | config.secret_key = 'a4afae774b0c49455776c2fd27d0e0f632c4553436dffc00d6d5a90fc56ab437a938277fa36ef991c37033d28465598e1ab9be069a7e297dfefd1a658370fb55' if Devise::VERSION.starts_with?("3.") 7 | 8 | # ==> Mailer Configuration 9 | # Configure the e-mail address which will be shown in DeviseMailer. 10 | config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" 11 | 12 | # Configure the class responsible to send e-mails. 13 | # config.mailer = "Devise::Mailer" 14 | 15 | # ==> ORM configuration 16 | # Load and configure the ORM. Supports :active_record (default) and 17 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 18 | # available as additional gems. 19 | require 'devise/orm/active_record' 20 | 21 | # ==> Configuration for any authentication mechanism 22 | # Configure which keys are used when authenticating a user. The default is 23 | # just :email. You can configure it to use [:username, :subdomain], so for 24 | # authenticating a user, both parameters are required. Remember that those 25 | # parameters are used only when authenticating and not when retrieving from 26 | # session. If you need permissions, you should implement that in a before filter. 27 | # You can also supply a hash where the value is a boolean determining whether 28 | # or not authentication should be aborted when the value is not present. 29 | # config.authentication_keys = [ :email ] 30 | 31 | # Configure parameters from the request object used for authentication. Each entry 32 | # given should be a request method and it will automatically be passed to the 33 | # find_for_authentication method and considered in your model lookup. For instance, 34 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 35 | # The same considerations mentioned for authentication_keys also apply to request_keys. 36 | # config.request_keys = [] 37 | 38 | # Configure which authentication keys should be case-insensitive. 39 | # These keys will be downcased upon creating or modifying a user and when used 40 | # to authenticate or find a user. Default is :email. 41 | config.case_insensitive_keys = [ :email ] 42 | 43 | # Tell if authentication through request.params is enabled. True by default. 44 | # config.params_authenticatable = true 45 | 46 | # Tell if authentication through HTTP Basic Auth is enabled. False by default. 47 | # config.http_authenticatable = false 48 | 49 | # If http headers should be returned for AJAX requests. True by default. 50 | # config.http_authenticatable_on_xhr = true 51 | 52 | # The realm used in Http Basic Authentication. "Application" by default. 53 | # config.http_authentication_realm = "Application" 54 | 55 | # ==> Configuration for :database_authenticatable 56 | # For bcrypt, this is the cost for hashing the password and defaults to 10. If 57 | # using other encryptors, it sets how many times you want the password re-encrypted. 58 | config.stretches = 10 59 | 60 | # Setup a pepper to generate the encrypted password. 61 | # config.pepper = "a433ef8999e265537134701d4ade9b3cd09c66837b24f091bd39ba698456a4462a6393cd2e220b5dd6c9a2376f421d8a068a4a6b46542ba40ad282be61370e21" 62 | 63 | # ==> Configuration for :confirmable 64 | # The time you want to give your user to confirm his account. During this time 65 | # he will be able to access your application without confirming. Default is 0.days 66 | # When confirm_within is zero, the user won't be able to sign in without confirming. 67 | # You can use this to let your user access some features of your application 68 | # without confirming the account, but blocking it after a certain period 69 | # (ie 2 days). 70 | # config.confirm_within = 2.days 71 | 72 | # Defines which key will be used when confirming an account 73 | # config.confirmation_keys = [ :email ] 74 | 75 | # ==> Configuration for :rememberable 76 | # The time the user will be remembered without asking for credentials again. 77 | # config.remember_for = 2.weeks 78 | 79 | # If true, a valid remember token can be re-used between multiple browsers. 80 | # config.remember_across_browsers = true 81 | 82 | # If true, extends the user's remember period when remembered via cookie. 83 | # config.extend_remember_period = false 84 | 85 | # If true, uses the password salt as remember token. This should be turned 86 | # to false if you are not using database authenticatable. 87 | # config.use_salt_as_remember_token = true 88 | 89 | # Options to be passed to the created cookie. For instance, you can set 90 | # :secure => true in order to force SSL only cookies. 91 | # config.cookie_options = {} 92 | 93 | # ==> Configuration for :validatable 94 | # Range for password length. Default is 6..128. 95 | # config.password_length = 6..128 96 | 97 | # Regex to use to validate the email address 98 | # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i 99 | 100 | # ==> Configuration for :timeoutable 101 | # The time you want to timeout the user session without activity. After this 102 | # time the user will be asked for credentials again. Default is 30 minutes. 103 | # config.timeout_in = 30.minutes 104 | 105 | # ==> Configuration for :lockable 106 | # Defines which strategy will be used to lock an account. 107 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 108 | # :none = No lock strategy. You should handle locking by yourself. 109 | # config.lock_strategy = :failed_attempts 110 | 111 | # Defines which key will be used when locking and unlocking an account 112 | # config.unlock_keys = [ :email ] 113 | 114 | # Defines which strategy will be used to unlock an account. 115 | # :email = Sends an unlock link to the user email 116 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 117 | # :both = Enables both strategies 118 | # :none = No unlock strategy. You should handle unlocking by yourself. 119 | # config.unlock_strategy = :both 120 | 121 | # Number of authentication tries before locking an account if lock_strategy 122 | # is failed attempts. 123 | # config.maximum_attempts = 20 124 | 125 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 126 | # config.unlock_in = 1.hour 127 | 128 | # ==> Configuration for :recoverable 129 | # 130 | # Defines which key will be used when recovering the password for an account 131 | # config.reset_password_keys = [ :email ] 132 | 133 | # Time interval you can reset your password with a reset password key. 134 | # Don't put a too small interval or your users won't have the time to 135 | # change their passwords. 136 | config.reset_password_within = 2.hours 137 | 138 | # ==> Configuration for :encryptable 139 | # Allow you to use another encryption algorithm besides bcrypt (default). You can use 140 | # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, 141 | # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) 142 | # and :restful_authentication_sha1 (then you should set stretches to 10, and copy 143 | # REST_AUTH_SITE_KEY to pepper) 144 | # config.encryptor = :sha512 145 | 146 | # ==> Configuration for :token_authenticatable 147 | # Defines name of the authentication token params key 148 | # config.token_authentication_key = :auth_token 149 | 150 | # If true, authentication through token does not store user in session and needs 151 | # to be supplied on each request. Useful if you are using the token as API token. 152 | # config.stateless_token = false 153 | 154 | # ==> Scopes configuration 155 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 156 | # "users/sessions/new". It's turned off by default because it's slower if you 157 | # are using only default views. 158 | # config.scoped_views = false 159 | 160 | # Configure the default scope given to Warden. By default it's the first 161 | # devise role declared in your routes (usually :user). 162 | # config.default_scope = :user 163 | 164 | # Configure sign_out behavior. 165 | # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). 166 | # The default is true, which means any logout action will sign out all active scopes. 167 | # config.sign_out_all_scopes = true 168 | 169 | # ==> Navigation configuration 170 | # Lists the formats that should be treated as navigational. Formats like 171 | # :html, should redirect to the sign in page when the user does not have 172 | # access, but formats like :xml or :json, should return 401. 173 | # 174 | # If you have any extra navigational formats, like :iphone or :mobile, you 175 | # should add them to the navigational formats lists. 176 | # 177 | # The :"*/*" and "*/*" formats below is required to match Internet 178 | # Explorer requests. 179 | # config.navigational_formats = [:"*/*", "*/*", :html] 180 | 181 | # The default HTTP method used to sign out a resource. Default is :get. 182 | # config.sign_out_via = :get 183 | 184 | # ==> OmniAuth 185 | # Add a new OmniAuth provider. Check the wiki for more information on setting 186 | # up on your models and hooks. 187 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' 188 | 189 | # ==> Warden configuration 190 | # If you want to use other strategies, that are not supported by Devise, or 191 | # change the failure app, you can configure them inside the config.warden block. 192 | # 193 | # config.warden do |manager| 194 | # manager.failure_app = AnotherApp 195 | # manager.intercept_401 = false 196 | # manager.default_strategies(:scope => :user).unshift :some_external_strategy 197 | # end 198 | end 199 | --------------------------------------------------------------------------------