refinerycms-testing 1.0.11 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -1
- data/lib/generators/refinery/testing/templates/Guardfile +30 -0
- data/lib/generators/refinery/testing/templates/spec/spec_helper.rb +52 -0
- data/lib/generators/refinery/testing/testing_generator.rb +14 -0
- data/lib/refinery/tasks/testing.rake +51 -0
- data/lib/refinery/testing.rb +33 -0
- data/lib/refinery/testing/controller_macros.rb +8 -0
- data/lib/refinery/testing/controller_macros/authentication.rb +43 -0
- data/lib/refinery/testing/controller_macros/methods.rb +33 -0
- data/lib/refinery/testing/railtie.rb +31 -0
- data/lib/refinery/testing/request_macros.rb +7 -0
- data/lib/refinery/testing/request_macros/authentication.rb +63 -0
- data/lib/refinery/testing/url_helper.rb +9 -0
- data/lib/refinerycms-testing.rb +1 -50
- data/refinerycms-testing.gemspec +19 -51
- metadata +191 -169
- data/config/cucumber.yml +0 -11
- data/features/step_definitions/web_steps.rb +0 -227
- data/features/support/env.rb +0 -63
- data/features/support/factories.rb +0 -1
- data/features/support/negative_expectations_helper.rb +0 -57
- data/features/support/paths.rb +0 -92
- data/lib/gemspec.rb +0 -50
- data/lib/generators/refinerycms_testing_generator.rb +0 -28
- data/lib/generators/templates/features/support/paths.rb +0 -19
- data/lib/tasks/cucumber.rake +0 -53
- data/lib/tasks/rcov.rake +0 -47
- data/spec/rcov.opts +0 -2
- data/spec/spec_helper.rb +0 -83
- data/spec/support/refinery/controller_macros.rb +0 -27
data/lib/gemspec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# Encoding: UTF-8
|
2
|
-
require 'pathname'
|
3
|
-
gempath = Pathname.new(File.expand_path('../../', __FILE__))
|
4
|
-
require gempath.join('..', 'base', 'lib', 'base', 'refinery')
|
5
|
-
|
6
|
-
gemspec = <<EOF
|
7
|
-
# Encoding: UTF-8
|
8
|
-
# DO NOT EDIT THIS FILE DIRECTLY! Instead, use lib/gemspec.rb to generate it.
|
9
|
-
|
10
|
-
Gem::Specification.new do |s|
|
11
|
-
s.name = %q{#{gemname = 'refinerycms-testing'}}
|
12
|
-
s.version = %q{#{::Refinery.version}}
|
13
|
-
s.summary = %q{Testing plugin for Refinery CMS}
|
14
|
-
s.description = %q{This plugin adds the ability to run cucumber and rspec against the RefineryCMS gem while inside a RefineryCMS project}
|
15
|
-
s.date = %q{#{Time.now.strftime('%Y-%m-%d')}}
|
16
|
-
s.email = %q{info@refinerycms.com}
|
17
|
-
s.homepage = %q{http://refinerycms.com}
|
18
|
-
s.rubyforge_project = %q{refinerycms}
|
19
|
-
s.authors = ['Philip Arndt']
|
20
|
-
s.license = %q{MIT}
|
21
|
-
s.require_paths = %w(lib)
|
22
|
-
s.executables = %w(#{Pathname.glob(gempath.join('bin/*')).map{|d| d.relative_path_from(gempath)}.sort.join(" ")})
|
23
|
-
|
24
|
-
s.add_dependency 'refinerycms-core', '= #{::Refinery::Version}'
|
25
|
-
|
26
|
-
# RSpec
|
27
|
-
s.add_dependency 'rspec-rails', '~> 2.6'
|
28
|
-
s.add_dependency 'fuubar'
|
29
|
-
s.add_dependency 'rspec-instafail'
|
30
|
-
|
31
|
-
# Cucumber
|
32
|
-
s.add_dependency 'database_cleaner'
|
33
|
-
s.add_dependency 'cucumber-rails', '~> 1.0.0'
|
34
|
-
s.add_dependency 'launchy'
|
35
|
-
s.add_dependency 'rack-test', '>= 0.5.6'
|
36
|
-
s.add_dependency 'json_pure'
|
37
|
-
|
38
|
-
# Factory Girl
|
39
|
-
s.add_dependency 'factory_girl'
|
40
|
-
|
41
|
-
s.files = [
|
42
|
-
'#{%w( **/{*,.rspec,.gitignore,.yardopts} ).map { |file| Pathname.glob(gempath.join(file)) }.flatten.reject{|f|
|
43
|
-
!f.exist? or f.to_s =~ /(\.(gem|rbc)|tmp(\/.*)?|spec\/lib\/tmp(\/.*)?)$/ or (f.directory? and f.children.empty?)
|
44
|
-
}.map{|d| d.relative_path_from(gempath)}.uniq.sort.join("',\n '")}'
|
45
|
-
]
|
46
|
-
end
|
47
|
-
EOF
|
48
|
-
|
49
|
-
(gemfile = gempath.join("#{gemname}.gemspec")).open('w') {|f| f.puts(gemspec)}
|
50
|
-
puts `cd #{gempath} && gem build #{gemfile}` if ARGV.any?{|a| a == "BUILD=true"}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'refinery/generators'
|
2
|
-
|
3
|
-
class RefinerycmsTesting < ::Refinery::Generators::EngineInstaller
|
4
|
-
|
5
|
-
source_root File.expand_path('../../../', __FILE__)
|
6
|
-
engine_name "testing"
|
7
|
-
|
8
|
-
def generate
|
9
|
-
copy_file 'config/cucumber.yml',
|
10
|
-
Rails.root.join('config', 'cucumber.yml')
|
11
|
-
|
12
|
-
copy_file 'spec/spec_helper.rb',
|
13
|
-
Rails.root.join('spec', 'spec_helper.rb')
|
14
|
-
|
15
|
-
copy_file 'spec/rcov.opts',
|
16
|
-
Rails.root.join('spec', 'rcov.opts')
|
17
|
-
|
18
|
-
copy_file 'spec/support/refinery/controller_macros.rb',
|
19
|
-
Rails.root.join('spec', 'support', 'refinery', 'controller_macros.rb')
|
20
|
-
|
21
|
-
copy_file '.rspec',
|
22
|
-
Rails.root.join('.rspec')
|
23
|
-
|
24
|
-
copy_file 'lib/generators/templates/features/support/paths.rb',
|
25
|
-
Rails.root.join('features', 'support', 'paths.rb')
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module NavigationHelpers
|
2
|
-
module Refinery
|
3
|
-
module RailsApplicationRoot
|
4
|
-
|
5
|
-
def path_to(page_name)
|
6
|
-
# Replace the nil below with the commented code to use this.
|
7
|
-
nil
|
8
|
-
|
9
|
-
#case page_name
|
10
|
-
#when /the root path/
|
11
|
-
# root_path
|
12
|
-
#else
|
13
|
-
# nil
|
14
|
-
#end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/tasks/cucumber.rake
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
-
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
-
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
-
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
-
# files.
|
6
|
-
|
7
|
-
|
8
|
-
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
-
|
10
|
-
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
-
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'cucumber/rake/task'
|
15
|
-
|
16
|
-
namespace :cucumber do
|
17
|
-
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
-
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
-
t.fork = true # You may get faster startup if you set this to false
|
20
|
-
t.profile = 'default'
|
21
|
-
end
|
22
|
-
|
23
|
-
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
-
t.binary = vendored_cucumber_bin
|
25
|
-
t.fork = true # You may get faster startup if you set this to false
|
26
|
-
t.profile = 'wip'
|
27
|
-
end
|
28
|
-
|
29
|
-
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
-
t.binary = vendored_cucumber_bin
|
31
|
-
t.fork = true # You may get faster startup if you set this to false
|
32
|
-
t.profile = 'rerun'
|
33
|
-
end
|
34
|
-
|
35
|
-
desc 'Run all features'
|
36
|
-
task :all => [:ok, :wip]
|
37
|
-
end
|
38
|
-
desc 'Alias for cucumber:ok'
|
39
|
-
task :cucumber => 'cucumber:ok'
|
40
|
-
|
41
|
-
task :default => :cucumber
|
42
|
-
|
43
|
-
task :features => :cucumber do
|
44
|
-
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
45
|
-
end
|
46
|
-
rescue LoadError
|
47
|
-
desc 'cucumber rake task not available (cucumber not installed)'
|
48
|
-
task :cucumber do
|
49
|
-
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
data/lib/tasks/rcov.rake
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# Forked to get it working with Rails 3 and RSpec 2
|
2
|
-
#
|
3
|
-
# From http://github.com/jaymcgavren
|
4
|
-
#
|
5
|
-
# Save this as rcov.rake in lib/tasks and use rcov:all =>
|
6
|
-
# to get accurate spec/feature coverage data
|
7
|
-
#
|
8
|
-
# Use rcov:rspec or rcov:cucumber
|
9
|
-
# to get non-aggregated coverage reports for rspec or cucumber separately
|
10
|
-
|
11
|
-
require 'cucumber/rake/task'
|
12
|
-
require "rspec/core/rake_task"
|
13
|
-
|
14
|
-
namespace :rcov do
|
15
|
-
Cucumber::Rake::Task.new(:cucumber_run) do |t|
|
16
|
-
t.rcov = true
|
17
|
-
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
|
18
|
-
t.rcov_opts << %[-o "coverage"]
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec::Core::RakeTask.new(:rspec_run) do |t|
|
22
|
-
t.pattern = '**/*_spec.rb'
|
23
|
-
t.rcov = true
|
24
|
-
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/}
|
25
|
-
t.rcov_opts << '--aggregate coverage.data'
|
26
|
-
t.rcov_opts << %[-o "coverage"]
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "Run both specs and features to generate aggregated coverage"
|
30
|
-
task :all do |t|
|
31
|
-
rm "coverage.data" if File.exist?("coverage.data")
|
32
|
-
Rake::Task["rcov:cucumber_run"].invoke
|
33
|
-
Rake::Task["rcov:rspec_run"].invoke
|
34
|
-
end
|
35
|
-
|
36
|
-
desc "Run only rspecs"
|
37
|
-
task :rspec do |t|
|
38
|
-
rm "coverage.data" if File.exist?("coverage.data")
|
39
|
-
Rake::Task["rcov:rspec_run"].invoke
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "Run only cucumber"
|
43
|
-
task :cucumber do |t|
|
44
|
-
rm "coverage.data" if File.exist?("coverage.data")
|
45
|
-
Rake::Task["rcov:cucumber_run"].invoke
|
46
|
-
end
|
47
|
-
end if RUBY_VERSION < '1.9'
|
data/spec/rcov.opts
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require 'factory_girl'
|
3
|
-
require File.expand_path('../support/refinery/controller_macros', __FILE__)
|
4
|
-
|
5
|
-
def setup_environment
|
6
|
-
# This file is copied to ~/spec when you run 'rails generate rspec'
|
7
|
-
# from the project root directory.
|
8
|
-
ENV["RAILS_ENV"] ||= 'test'
|
9
|
-
require File.expand_path("../../config/environment", __FILE__)
|
10
|
-
require 'rspec/rails'
|
11
|
-
|
12
|
-
# Requires supporting files with custom matchers and macros, etc,
|
13
|
-
# in ./support/ and its subdirectories.
|
14
|
-
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f}
|
15
|
-
|
16
|
-
RSpec.configure do |config|
|
17
|
-
# == Mock Framework
|
18
|
-
#
|
19
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
20
|
-
#
|
21
|
-
# config.mock_with :mocha
|
22
|
-
# config.mock_with :flexmock
|
23
|
-
# config.mock_with :rr
|
24
|
-
config.mock_with :rspec
|
25
|
-
|
26
|
-
config.fixture_path = ::Rails.root.join('spec', 'fixtures').to_s
|
27
|
-
|
28
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
29
|
-
# examples within a transaction, comment the following line or assign false
|
30
|
-
# instead of true.
|
31
|
-
config.use_transactional_fixtures = true
|
32
|
-
config.use_instantiated_fixtures = false
|
33
|
-
|
34
|
-
config.include ::Devise::TestHelpers, :type => :controller
|
35
|
-
config.extend ::Refinery::ControllerMacros, :type => :controller
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def each_run
|
40
|
-
end
|
41
|
-
|
42
|
-
require 'rubygems'
|
43
|
-
# If spork is available in the Gemfile it'll be used but we don't force it.
|
44
|
-
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
|
45
|
-
|
46
|
-
Spork.prefork do
|
47
|
-
# Loading more in this block will cause your tests to run faster. However,
|
48
|
-
# if you change any configuration or code from libraries loaded here, you'll
|
49
|
-
# need to restart spork for it take effect.
|
50
|
-
setup_environment
|
51
|
-
end
|
52
|
-
|
53
|
-
Spork.each_run do
|
54
|
-
# This code will be run each time you run your specs.
|
55
|
-
each_run
|
56
|
-
end
|
57
|
-
|
58
|
-
# --- Instructions ---
|
59
|
-
# - Sort through your spec_helper file. Place as much environment loading
|
60
|
-
# code that you don't normally modify during development in the
|
61
|
-
# Spork.prefork block.
|
62
|
-
# - Place the rest under Spork.each_run block
|
63
|
-
# - Any code that is left outside of the blocks will be ran during preforking
|
64
|
-
# and during each_run!
|
65
|
-
# - These instructions should self-destruct in 10 seconds. If they don't,
|
66
|
-
# feel free to delete them.
|
67
|
-
#
|
68
|
-
else
|
69
|
-
setup_environment
|
70
|
-
each_run
|
71
|
-
end
|
72
|
-
|
73
|
-
def capture_stdout(stdin_str = '')
|
74
|
-
begin
|
75
|
-
require 'stringio'
|
76
|
-
$o_stdin, $o_stdout, $o_stderr = $stdin, $stdout, $stderr
|
77
|
-
$stdin, $stdout, $stderr = StringIO.new(stdin_str), StringIO.new, StringIO.new
|
78
|
-
yield
|
79
|
-
{:stdout => $stdout.string, :stderr => $stderr.string}
|
80
|
-
ensure
|
81
|
-
$stdin, $stdout, $stderr = $o_stdin, $o_stdout, $o_stderr
|
82
|
-
end
|
83
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Refinery
|
2
|
-
module ControllerMacros
|
3
|
-
def login_user
|
4
|
-
before (:each) do
|
5
|
-
@user = Factory(:user)
|
6
|
-
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
7
|
-
sign_in @user
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def login_refinery_user
|
12
|
-
before (:each) do
|
13
|
-
@refinery_user = Factory(:refinery_user)
|
14
|
-
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
15
|
-
sign_in @refinery_user
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def login_refinery_translator
|
20
|
-
before (:each) do
|
21
|
-
@refinery_translator = Factory(:refinery_translator)
|
22
|
-
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
23
|
-
sign_in @refinery_translator
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|