refinerycms-testing 0.9.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --drb
@@ -0,0 +1,11 @@
1
+ <%
2
+ ENV["RAILS_ENV"] ||= "test"
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
5
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
6
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip "
7
+ refinery_features = (::Refinery::Plugins.registered.pathnames << Rails.root).map{|p| p.join('features')}.reject{|d| !d.directory?}
8
+ %>
9
+ default: <%= std_opts %> <%= refinery_features.join(' ') %>
10
+ wip: --tags @wip:3 --wip features
11
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,219 @@
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
+ require 'uri'
9
+ require 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^\"]*)"(?: within "([^\"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^\"]*)"(?: within "([^\"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^\"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"(?: within "([^\"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end
@@ -0,0 +1,83 @@
1
+ require 'refinerycms-base'
2
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
3
+ # It is recommended to regenerate this file in the future when you upgrade to a
4
+ # newer version of cucumber-rails. Consider adding your own code to a new file
5
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
6
+ # files.
7
+
8
+ ## This is custom functionality written by Refinery CMS.
9
+ def setup_environment
10
+ ENV["RAILS_ENV"] ||= "test"
11
+
12
+ if RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
13
+ puts "Win32 users may experience cucumber/formatter/unicode errors. Requirement ommited, see: /features/support/env.rb to re-add."
14
+ else
15
+ require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
16
+ end
17
+ require 'cucumber/rails/world'
18
+ require 'cucumber/rails/active_record'
19
+ require 'cucumber/web/tableish'
20
+
21
+
22
+ require 'capybara/rails'
23
+ require 'capybara/cucumber'
24
+ require 'capybara/session'
25
+
26
+ include ::Devise::Controllers::UrlHelpers
27
+
28
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
29
+ # order to ease the transition to Capybara we set the default here. If you'd
30
+ # prefer to use XPath just remove this line and adjust any selectors in your
31
+ # steps to use the XPath syntax.
32
+ Capybara.default_selector = :css
33
+ end
34
+
35
+ def each_run
36
+ # If you set this to false, any error raised from within your app will bubble
37
+ # up to your step definition and out to cucumber unless you catch it somewhere
38
+ # on the way. You can make Rails rescue errors and render error pages on a
39
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
40
+ #
41
+ # If you set this to true, Rails will rescue all errors and render error
42
+ # pages, more or less in the same way your application would behave in the
43
+ # default production environment. It's not recommended to do this for all
44
+ # of your scenarios, as this makes it hard to discover errors in your application.
45
+ ActionController::Base.allow_rescue = false
46
+
47
+ # If you set this to true, each scenario will run in a database transaction.
48
+ # You can still turn off transactions on a per-scenario basis, simply tagging
49
+ # a feature or scenario with the @no-txn tag. If you are using Capybara,
50
+ # tagging with @culerity or @javascript will also turn transactions off.
51
+ #
52
+ # If you set this to false, transactions will be off for all scenarios,
53
+ # regardless of whether you use @no-txn or not.
54
+ #
55
+ # Beware that turning transactions off will leave data in your database
56
+ # after each scenario, which can lead to hard-to-debug failures in
57
+ # subsequent scenarios. If you do this, we recommend you create a Before
58
+ # block that will explicitly put your database in a known state.
59
+ Cucumber::Rails::World.use_transactional_fixtures = true
60
+ # How to clean your database when transactions are turned off. See
61
+ # http://github.com/bmabey/database_cleaner for more info.
62
+ require 'database_cleaner'
63
+ DatabaseCleaner.strategy = :truncation
64
+
65
+ require 'fileutils'
66
+ require 'rails/generators'
67
+ #require 'rails/generators/scripts/generate'
68
+ end
69
+
70
+ require 'rubygems'
71
+ # If spork is available in the Gemfile it'll be used but we don't force it.
72
+ unless RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)! or (begin; require 'spork'; rescue LoadError; nil end).nil?
73
+ Spork.prefork do
74
+ setup_environment
75
+ end
76
+
77
+ Spork.each_run do
78
+ each_run
79
+ end
80
+ else
81
+ setup_environment
82
+ each_run
83
+ end
@@ -0,0 +1 @@
1
+ require 'factory_girl'
@@ -0,0 +1,57 @@
1
+ # https://rspec.lighthouseapp.com/projects/16211/tickets/305
2
+ require 'singleton'
3
+
4
+ module NegativeExpectationsHelper
5
+
6
+ class State
7
+ include Singleton
8
+
9
+ def is_negative?
10
+ @negative === true
11
+ end
12
+
13
+ def is_negative!
14
+ @negative = true
15
+ end
16
+
17
+ def restore!
18
+ @negative = false
19
+ end
20
+ end
21
+
22
+ module ObjectExpectations
23
+ def self.included(base)
24
+ base.class_eval do
25
+ alias_method :original_should, :should
26
+ alias_method :original_should_not, :should_not
27
+
28
+ def should(*args, &block)
29
+ should_if_true(!State.instance.is_negative?, *args, &block)
30
+ end
31
+
32
+ def should_not(*args, &block)
33
+ should_if_true(State.instance.is_negative?, *args, &block)
34
+ end
35
+ end
36
+ end
37
+
38
+ private # ----------------------------------------------------------------
39
+
40
+ def should_if_true(cond, *args, &block)
41
+ cond ? self.send(:original_should, *args, &block) : self.send(:original_should_not, *args, &block)
42
+ end
43
+ end
44
+
45
+ def expect_opposite_if(cond)
46
+ raise "expected block" unless block_given?
47
+ State.instance.is_negative! if cond
48
+ yield
49
+ State.instance.restore! if cond
50
+ end
51
+ end
52
+
53
+ class Object
54
+ include NegativeExpectationsHelper::ObjectExpectations
55
+ end
56
+
57
+ World(NegativeExpectationsHelper)
@@ -0,0 +1,91 @@
1
+ ::Refinery::Plugins.registered.collect{|p|
2
+ p.pathname.join('features', 'support', 'paths.rb')
3
+ }.reject{|p| !p.exist?}.each do |paths|
4
+ require paths
5
+ end
6
+
7
+ module NavigationHelpers
8
+ # Loads in path_to functions from the engines that Refinery is using.
9
+ # They should look like this:
10
+ # module NavigationHelpers
11
+ # module Refinery
12
+ # module EngineName
13
+ # def path_to(page_name)
14
+ # case page_name
15
+ # when /regexp/
16
+ # some_path
17
+ # else
18
+ # nil
19
+ # end
20
+ # end
21
+ # end
22
+ # end
23
+ # end
24
+ NavigationHelpers::Refinery.constants.each do |name|
25
+ begin
26
+ if (mod = "NavigationHelpers::Refinery::#{name}".constantize)
27
+ mod.module_eval %{alias :#{name.downcase}_path_to :path_to}
28
+ include mod
29
+ end
30
+ rescue
31
+ $stdout.puts $!.message
32
+ end
33
+ end if defined?(NavigationHelpers::Refinery)
34
+ # Maps a name to a path. Used by the
35
+ #
36
+ # When /^I go to (.+)$/ do |page_name|
37
+ #
38
+ # step definition in web_steps.rb
39
+ #
40
+ def path_to(page_name)
41
+ case page_name
42
+
43
+ when /the admin root/
44
+ admin_root_path
45
+
46
+ # Add more mappings here.
47
+ # Here is an example that pulls values out of the Regexp:
48
+ #
49
+ # when /^(.*)'s profile page$/i
50
+ # user_profile_path(User.find_by_username($1))
51
+
52
+ else
53
+ # Loads in path_to functions from the engines that Refinery is using.
54
+ # They should look like this:
55
+ # module NavigationHelpers
56
+ # module Refinery
57
+ # module EngineName
58
+ # def path_to(page_name)
59
+ # case page_name
60
+ # when /regexp/
61
+ # some_path
62
+ # else
63
+ # nil
64
+ # end
65
+ # end
66
+ # end
67
+ # end
68
+ # end
69
+ NavigationHelpers::Refinery.constants.each do |name|
70
+ begin
71
+ if (path = self.send(:"#{name.downcase}_path_to", page_name)).present?
72
+ return path
73
+ end
74
+ rescue
75
+ $stdout.puts $!.message
76
+ end
77
+ end if defined?(NavigationHelpers::Refinery)
78
+
79
+ begin
80
+ page_name =~ /the (.*) page/
81
+ path_components = $1.split(/\s+/)
82
+ self.send(path_components.push('path').join('_').to_sym)
83
+ rescue Object => e
84
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
85
+ "Now, go and add a mapping in #{__FILE__}"
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ World(NavigationHelpers)
data/lib/gemspec.rb ADDED
@@ -0,0 +1,53 @@
1
+ require 'pathname'
2
+ gempath = Pathname.new(File.expand_path('../../', __FILE__))
3
+ require gempath.join('..', 'base', 'lib', 'base', 'refinery')
4
+
5
+ gemspec = <<EOF
6
+ # DO NOT EDIT THIS FILE DIRECTLY! Instead, use lib/gemspec.rb to generate it.
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = %q{#{gemname = 'refinerycms-testing'}}
10
+ s.version = %q{#{::Refinery.version}}
11
+ s.summary = %q{Testing plugin for Refinery CMS}
12
+ s.description = %q{This plugin adds the ability to run cucumber and rspec against the RefineryCMS gem while inside a RefineryCMS project}
13
+ s.date = %q{#{Time.now.strftime('%Y-%m-%d')}}
14
+ s.email = %q{info@refinerycms.com}
15
+ s.homepage = %q{http://refinerycms.com}
16
+ s.rubyforge_project = %q{refinerycms}
17
+ s.authors = ['Philip Arndt']
18
+ s.license = %q{MIT}
19
+ s.require_paths = %w(lib)
20
+ s.executables = %w(#{Pathname.glob(gempath.join('bin/*')).map{|d| d.relative_path_from(gempath)}.sort.join(" ")})
21
+
22
+ s.add_dependency 'refinerycms-core', '~> #{::Refinery::Version}'
23
+ # RSpec
24
+ s.add_dependency 'rspec-rails', '~> 2.5'
25
+
26
+ # Cucumber
27
+ s.add_dependency 'capybara', '>= 0.4.1.1'
28
+ s.add_dependency 'database_cleaner'
29
+ s.add_dependency 'cucumber-rails'
30
+ s.add_dependency 'cucumber'
31
+ s.add_dependency 'launchy'
32
+ s.add_dependency 'gherkin'
33
+ s.add_dependency 'rack-test', '~> 0.5.6'
34
+ s.add_dependency 'json_pure'
35
+
36
+ # Factory Girl
37
+ s.add_dependency 'factory_girl'
38
+
39
+ # Autotest
40
+ s.add_dependency 'autotest'
41
+ s.add_dependency 'autotest-rails'
42
+ s.add_dependency 'autotest-notification'
43
+
44
+ s.files = [
45
+ '#{%w( **/{*,.rspec,.gitignore,.yardopts} ).map { |file| Pathname.glob(gempath.join(file)) }.flatten.reject{|f|
46
+ !f.exist? or f.to_s =~ /\.gem$/ or (f.directory? and f.children.empty?)
47
+ }.map{|d| d.relative_path_from(gempath)}.uniq.sort.join("',\n '")}'
48
+ ]
49
+ end
50
+ EOF
51
+
52
+ (gemfile = gempath.join("#{gemname}.gemspec")).open('w') {|f| f.puts(gemspec)}
53
+ puts `cd #{gempath} && gem build #{gemfile}` if ARGV.any?{|a| a == "BUILD=true"}
@@ -0,0 +1,15 @@
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', Rails.root.join('config', 'cucumber.yml')
10
+ copy_file 'spec/spec_helper.rb', Rails.root.join('spec', 'spec_helper.rb')
11
+ copy_file 'spec/rcov.opts', Rails.root.join('spec', 'rcov.opts')
12
+ copy_file '.rspec', Rails.root.join('.rspec')
13
+ end
14
+
15
+ end
@@ -0,0 +1,44 @@
1
+ require 'refinerycms-core'
2
+ require 'rspec-rails'
3
+
4
+ module Refinery
5
+ module Testing
6
+
7
+ class << self
8
+ attr_accessor :root
9
+ def root
10
+ @root ||= Pathname.new(File.expand_path('../../', __FILE__))
11
+ end
12
+ end
13
+
14
+ class Engine < ::Rails::Engine
15
+ config.before_configuration do
16
+ ::Refinery::Application.module_eval do
17
+ def load_tasks
18
+ super
19
+
20
+ # To get specs from all Refinery engines, not just those in Rails.root/spec/
21
+ ::RSpec::Core::RakeTask.module_eval do
22
+ def pattern
23
+ [@pattern] | ::Refinery::Plugins.registered.pathnames.map{|p|
24
+ p.join('spec', '**', '*_spec.rb').to_s
25
+ }
26
+ end
27
+ end if defined?(::RSpec::Core::RakeTask)
28
+ end
29
+ end
30
+ end
31
+
32
+ config.after_initialize do
33
+ ::Refinery::Plugin.register do |plugin|
34
+ plugin.name = "refinerycms_testing_plugin"
35
+ plugin.version = ::Refinery.version
36
+ plugin.hide_from_menu = true
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+
44
+ ::Refinery.engines << 'testing'
@@ -0,0 +1,53 @@
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
@@ -0,0 +1,63 @@
1
+ # DO NOT EDIT THIS FILE DIRECTLY! Instead, use lib/gemspec.rb to generate it.
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{refinerycms-testing}
5
+ s.version = %q{0.9.9.1}
6
+ s.summary = %q{Testing plugin for Refinery CMS}
7
+ s.description = %q{This plugin adds the ability to run cucumber and rspec against the RefineryCMS gem while inside a RefineryCMS project}
8
+ s.date = %q{2011-02-15}
9
+ s.email = %q{info@refinerycms.com}
10
+ s.homepage = %q{http://refinerycms.com}
11
+ s.rubyforge_project = %q{refinerycms}
12
+ s.authors = ['Philip Arndt']
13
+ s.license = %q{MIT}
14
+ s.require_paths = %w(lib)
15
+ s.executables = %w()
16
+
17
+ s.add_dependency 'refinerycms-core', '~> 0.9.9.1'
18
+ # RSpec
19
+ s.add_dependency 'rspec-rails', '~> 2.5'
20
+
21
+ # Cucumber
22
+ s.add_dependency 'capybara', '>= 0.4.1.1'
23
+ s.add_dependency 'database_cleaner'
24
+ s.add_dependency 'cucumber-rails'
25
+ s.add_dependency 'cucumber'
26
+ s.add_dependency 'launchy'
27
+ s.add_dependency 'gherkin'
28
+ s.add_dependency 'rack-test', '~> 0.5.6'
29
+ s.add_dependency 'json_pure'
30
+
31
+ # Factory Girl
32
+ s.add_dependency 'factory_girl'
33
+
34
+ # Autotest
35
+ s.add_dependency 'autotest'
36
+ s.add_dependency 'autotest-rails'
37
+ s.add_dependency 'autotest-notification'
38
+
39
+ s.files = [
40
+ '.rspec',
41
+ 'config',
42
+ 'config/cucumber.yml',
43
+ 'features',
44
+ 'features/step_definitions',
45
+ 'features/step_definitions/web_steps.rb',
46
+ 'features/support',
47
+ 'features/support/env.rb',
48
+ 'features/support/factories.rb',
49
+ 'features/support/negative_expectations_helper.rb',
50
+ 'features/support/paths.rb',
51
+ 'lib',
52
+ 'lib/gemspec.rb',
53
+ 'lib/generators',
54
+ 'lib/generators/refinerycms_testing_generator.rb',
55
+ 'lib/refinerycms-testing.rb',
56
+ 'lib/tasks',
57
+ 'lib/tasks/cucumber.rake',
58
+ 'refinerycms-testing.gemspec',
59
+ 'spec',
60
+ 'spec/rcov.opts',
61
+ 'spec/spec_helper.rb'
62
+ ]
63
+ end
data/spec/rcov.opts ADDED
@@ -0,0 +1,2 @@
1
+ --exclude "spec/*,gems/*"
2
+ --rails
@@ -0,0 +1,77 @@
1
+ require 'rbconfig'
2
+ def setup_environment
3
+ # This file is copied to ~/spec when you run 'rails generate rspec'
4
+ # from the project root directory.
5
+ ENV["RAILS_ENV"] ||= 'test'
6
+ require File.expand_path("../../config/environment", __FILE__)
7
+ require 'rspec/rails'
8
+
9
+ # Requires supporting files with custom matchers and macros, etc,
10
+ # in ./support/ and its subdirectories.
11
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f}
12
+
13
+ RSpec.configure do |config|
14
+ # == Mock Framework
15
+ #
16
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
17
+ #
18
+ # config.mock_with :mocha
19
+ # config.mock_with :flexmock
20
+ # config.mock_with :rr
21
+ config.mock_with :rspec
22
+
23
+ config.fixture_path = ::Rails.root.join('spec', 'fixtures').to_s
24
+
25
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
26
+ # examples within a transaction, comment the following line or assign false
27
+ # instead of true.
28
+ config.use_transactional_fixtures = true
29
+ config.use_instantiated_fixtures = false
30
+ end
31
+ end
32
+
33
+ def each_run
34
+ end
35
+
36
+ require 'rubygems'
37
+ # If spork is available in the Gemfile it'll be used but we don't force it.
38
+ unless RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)! or (begin; require 'spork'; rescue LoadError; nil end).nil?
39
+ require 'spork'
40
+
41
+ Spork.prefork do
42
+ # Loading more in this block will cause your tests to run faster. However,
43
+ # if you change any configuration or code from libraries loaded here, you'll
44
+ # need to restart spork for it take effect.
45
+ setup_environment
46
+ end
47
+
48
+ Spork.each_run do
49
+ # This code will be run each time you run your specs.
50
+ each_run
51
+ end
52
+
53
+ # --- Instructions ---
54
+ # - Sort through your spec_helper file. Place as much environment loading
55
+ # code that you don't normally modify during development in the
56
+ # Spork.prefork block.
57
+ # - Place the rest under Spork.each_run block
58
+ # - Any code that is left outside of the blocks will be ran during preforking
59
+ # and during each_run!
60
+ # - These instructions should self-destruct in 10 seconds. If they don't,
61
+ # feel free to delete them.
62
+ #
63
+ else
64
+ setup_environment
65
+ each_run
66
+ end
67
+
68
+ def capture_stdout(&block)
69
+ original_stdout = $stdout
70
+ $stdout = fake = StringIO.new
71
+ begin
72
+ yield
73
+ ensure
74
+ $stdout = original_stdout
75
+ end
76
+ fake.string
77
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-testing
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.9.9.1
6
+ platform: ruby
7
+ authors:
8
+ - Philip Arndt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-02-15 00:00:00 +13:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: refinerycms-core
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 0.9.9.1
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "2.5"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: capybara
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.4.1.1
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: database_cleaner
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: cucumber-rails
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: cucumber
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ type: :runtime
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: launchy
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ type: :runtime
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: gherkin
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ type: :runtime
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: rack-test
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 0.5.6
113
+ type: :runtime
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: json_pure
117
+ prerelease: false
118
+ requirement: &id010 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ type: :runtime
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: factory_girl
128
+ prerelease: false
129
+ requirement: &id011 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: "0"
135
+ type: :runtime
136
+ version_requirements: *id011
137
+ - !ruby/object:Gem::Dependency
138
+ name: autotest
139
+ prerelease: false
140
+ requirement: &id012 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: "0"
146
+ type: :runtime
147
+ version_requirements: *id012
148
+ - !ruby/object:Gem::Dependency
149
+ name: autotest-rails
150
+ prerelease: false
151
+ requirement: &id013 !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: "0"
157
+ type: :runtime
158
+ version_requirements: *id013
159
+ - !ruby/object:Gem::Dependency
160
+ name: autotest-notification
161
+ prerelease: false
162
+ requirement: &id014 !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: "0"
168
+ type: :runtime
169
+ version_requirements: *id014
170
+ description: This plugin adds the ability to run cucumber and rspec against the RefineryCMS gem while inside a RefineryCMS project
171
+ email: info@refinerycms.com
172
+ executables: []
173
+
174
+ extensions: []
175
+
176
+ extra_rdoc_files: []
177
+
178
+ files:
179
+ - .rspec
180
+ - config/cucumber.yml
181
+ - features/step_definitions/web_steps.rb
182
+ - features/support/env.rb
183
+ - features/support/factories.rb
184
+ - features/support/negative_expectations_helper.rb
185
+ - features/support/paths.rb
186
+ - lib/gemspec.rb
187
+ - lib/generators/refinerycms_testing_generator.rb
188
+ - lib/refinerycms-testing.rb
189
+ - lib/tasks/cucumber.rake
190
+ - refinerycms-testing.gemspec
191
+ - spec/rcov.opts
192
+ - spec/spec_helper.rb
193
+ has_rdoc: true
194
+ homepage: http://refinerycms.com
195
+ licenses:
196
+ - MIT
197
+ post_install_message:
198
+ rdoc_options: []
199
+
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ none: false
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: "0"
208
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: "0"
214
+ requirements: []
215
+
216
+ rubyforge_project: refinerycms
217
+ rubygems_version: 1.5.2
218
+ signing_key:
219
+ specification_version: 3
220
+ summary: Testing plugin for Refinery CMS
221
+ test_files: []
222
+