upgrade rake (0.9.2), cucumber-rails (1.0.2), capybara
This commit is contained in:
parent
c1f89f1cca
commit
c8f0ad0bbe
15
Gemfile
15
Gemfile
@ -2,7 +2,7 @@ source :rubygems
|
|||||||
|
|
||||||
# add in all the runtime dependencies
|
# add in all the runtime dependencies
|
||||||
|
|
||||||
gem 'rake', '0.8.7'
|
gem 'rake', '0.9.2'
|
||||||
|
|
||||||
gem 'rails', '3.0.9'
|
gem 'rails', '3.0.9'
|
||||||
|
|
||||||
@ -42,8 +42,9 @@ gem 'SystemTimer', :platforms => :ruby_18
|
|||||||
# The rest of the dependencies are for use when in the locomotive dev environment
|
# The rest of the dependencies are for use when in the locomotive dev environment
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# Using unicorn_rails instead of webrick (default server)
|
gem 'unicorn' # Using unicorn_rails instead of webrick (default server)
|
||||||
gem 'unicorn'
|
|
||||||
|
gem 'rspec-rails', '2.3.1' # in order to have rspec tasks and generators
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test, :development do
|
group :test, :development do
|
||||||
@ -52,6 +53,8 @@ group :test, :development do
|
|||||||
gem 'ruby-debug19', :platforms => :mri_19
|
gem 'ruby-debug19', :platforms => :mri_19
|
||||||
|
|
||||||
gem 'bushido_stub', :git => 'git://github.com/did/bushido_stub.git'
|
gem 'bushido_stub', :git => 'git://github.com/did/bushido_stub.git'
|
||||||
|
|
||||||
|
gem 'cucumber-rails', '1.0.2'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
@ -65,12 +68,10 @@ group :test do
|
|||||||
gem 'rspec-rails', '2.3.1'
|
gem 'rspec-rails', '2.3.1'
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_girl_rails'
|
||||||
gem 'pickle'
|
gem 'pickle'
|
||||||
gem 'xpath', '0.1.3'
|
gem 'xpath', '~> 0.1.4'
|
||||||
gem 'capybara'
|
gem 'capybara'
|
||||||
|
|
||||||
gem 'database_cleaner'
|
gem 'database_cleaner'
|
||||||
gem 'cucumber', '0.8.5'
|
|
||||||
gem 'cucumber-rails'
|
|
||||||
gem 'spork'
|
gem 'spork'
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
|
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
|
||||||
|
50
Gemfile.lock
50
Gemfile.lock
@ -63,30 +63,28 @@ GEM
|
|||||||
json (>= 1.4.6)
|
json (>= 1.4.6)
|
||||||
rest-client (>= 1.6.1)
|
rest-client (>= 1.6.1)
|
||||||
cancan (1.6.5)
|
cancan (1.6.5)
|
||||||
capybara (0.4.1.2)
|
capybara (1.0.0)
|
||||||
celerity (>= 0.7.9)
|
|
||||||
culerity (>= 0.2.4)
|
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
selenium-webdriver (>= 0.0.27)
|
selenium-webdriver (~> 0.2.0)
|
||||||
xpath (~> 0.1.3)
|
xpath (~> 0.1.4)
|
||||||
celerity (0.8.9)
|
|
||||||
childprocess (0.1.9)
|
childprocess (0.1.9)
|
||||||
ffi (~> 1.0.6)
|
ffi (~> 1.0.6)
|
||||||
columnize (0.3.3)
|
columnize (0.3.3)
|
||||||
configuration (1.3.1)
|
configuration (1.3.1)
|
||||||
crack (0.1.8)
|
crack (0.1.8)
|
||||||
cucumber (0.8.5)
|
cucumber (1.0.0)
|
||||||
builder (~> 2.1.2)
|
builder (>= 2.1.2)
|
||||||
diff-lcs (~> 1.1.2)
|
diff-lcs (>= 1.1.2)
|
||||||
gherkin (~> 2.1.4)
|
gherkin (~> 2.4.1)
|
||||||
json_pure (~> 1.4.3)
|
json (>= 1.4.6)
|
||||||
term-ansicolor (~> 1.0.4)
|
term-ansicolor (>= 1.0.5)
|
||||||
cucumber-rails (0.3.2)
|
cucumber-rails (1.0.2)
|
||||||
cucumber (>= 0.8.0)
|
capybara (>= 1.0.0)
|
||||||
culerity (0.2.15)
|
cucumber (~> 1.0.0)
|
||||||
|
nokogiri (>= 1.4.6)
|
||||||
custom_fields (1.0.0.beta.19)
|
custom_fields (1.0.0.beta.19)
|
||||||
activesupport (>= 3.0.7)
|
activesupport (>= 3.0.7)
|
||||||
mongoid (= 2.0.2)
|
mongoid (= 2.0.2)
|
||||||
@ -127,8 +125,8 @@ GEM
|
|||||||
actionpack (>= 2.3.7)
|
actionpack (>= 2.3.7)
|
||||||
activesupport (>= 2.3.7)
|
activesupport (>= 2.3.7)
|
||||||
i18n (~> 0.4)
|
i18n (~> 0.4)
|
||||||
gherkin (2.1.5)
|
gherkin (2.4.1)
|
||||||
trollop (~> 1.16.2)
|
json (>= 1.4.6)
|
||||||
growl-glue (1.0.7)
|
growl-glue (1.0.7)
|
||||||
haml (3.1.2)
|
haml (3.1.2)
|
||||||
has_scope (0.5.0)
|
has_scope (0.5.0)
|
||||||
@ -146,7 +144,7 @@ GEM
|
|||||||
jammit (0.6.3)
|
jammit (0.6.3)
|
||||||
yui-compressor (>= 0.9.3)
|
yui-compressor (>= 0.9.3)
|
||||||
json (1.5.3)
|
json (1.5.3)
|
||||||
json_pure (1.4.6)
|
json_pure (1.5.3)
|
||||||
kgio (2.5.0)
|
kgio (2.5.0)
|
||||||
launchy (0.3.7)
|
launchy (0.3.7)
|
||||||
configuration (>= 0.0.5)
|
configuration (>= 0.0.5)
|
||||||
@ -208,8 +206,8 @@ GEM
|
|||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
thor (~> 0.14.4)
|
thor (~> 0.14.4)
|
||||||
raindrops (0.7.0)
|
raindrops (0.7.0)
|
||||||
rake (0.8.7)
|
rake (0.9.2)
|
||||||
rdoc (3.6.1)
|
rdoc (3.7)
|
||||||
responders (0.6.4)
|
responders (0.6.4)
|
||||||
rest-client (1.6.3)
|
rest-client (1.6.3)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
@ -257,8 +255,7 @@ GEM
|
|||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
treetop (1.4.9)
|
treetop (1.4.9)
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
trollop (1.16.2)
|
tzinfo (0.3.29)
|
||||||
tzinfo (0.3.28)
|
|
||||||
unicorn (4.0.0)
|
unicorn (4.0.0)
|
||||||
kgio (~> 2.4)
|
kgio (~> 2.4)
|
||||||
rack
|
rack
|
||||||
@ -266,7 +263,7 @@ GEM
|
|||||||
warden (1.0.4)
|
warden (1.0.4)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
will_paginate (2.3.15)
|
will_paginate (2.3.15)
|
||||||
xpath (0.1.3)
|
xpath (0.1.4)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
yui-compressor (0.9.6)
|
yui-compressor (0.9.6)
|
||||||
POpen4 (>= 0.1.4)
|
POpen4 (>= 0.1.4)
|
||||||
@ -285,8 +282,7 @@ DEPENDENCIES
|
|||||||
bushido_stub!
|
bushido_stub!
|
||||||
cancan
|
cancan
|
||||||
capybara
|
capybara
|
||||||
cucumber (= 0.8.5)
|
cucumber-rails (= 1.0.2)
|
||||||
cucumber-rails
|
|
||||||
custom_fields (= 1.0.0.beta.19)
|
custom_fields (= 1.0.0.beta.19)
|
||||||
database_cleaner
|
database_cleaner
|
||||||
delayed_job (= 2.1.4)
|
delayed_job (= 2.1.4)
|
||||||
@ -313,7 +309,7 @@ DEPENDENCIES
|
|||||||
pickle
|
pickle
|
||||||
rack-cache
|
rack-cache
|
||||||
rails (= 3.0.9)
|
rails (= 3.0.9)
|
||||||
rake (= 0.8.7)
|
rake (= 0.9.2)
|
||||||
rmagick (= 2.12.2)
|
rmagick (= 2.12.2)
|
||||||
rspec-rails (= 2.3.1)
|
rspec-rails (= 2.3.1)
|
||||||
ruby-debug
|
ruby-debug
|
||||||
@ -324,4 +320,4 @@ DEPENDENCIES
|
|||||||
unicorn
|
unicorn
|
||||||
warden
|
warden
|
||||||
will_paginate
|
will_paginate
|
||||||
xpath (= 0.1.3)
|
xpath (~> 0.1.4)
|
||||||
|
13
Rakefile
13
Rakefile
@ -1,20 +1,21 @@
|
|||||||
require File.expand_path('../config/application', __FILE__)
|
require File.expand_path('../config/application', __FILE__)
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/testtask'
|
require 'rdoc/task'
|
||||||
require 'rake/rdoctask'
|
require 'rubygems/package_task'
|
||||||
require 'rake/gempackagetask'
|
|
||||||
|
|
||||||
Locomotive::Application.load_tasks
|
Locomotive::Application.load_tasks
|
||||||
|
|
||||||
gemspec = eval(File.read('locomotive_cms.gemspec'))
|
gemspec = eval(File.read('locomotive_cms.gemspec'))
|
||||||
Rake::GemPackageTask.new(gemspec) do |pkg|
|
Gem::PackageTask.new(gemspec) do |pkg|
|
||||||
pkg.gem_spec = gemspec
|
pkg.gem_spec = gemspec
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "build the gem and release it to rubygems.org"
|
desc 'build the gem and release it to rubygems.org'
|
||||||
task :release => :gem do
|
task :release => :gem do
|
||||||
sh "gem push pkg/locomotive_cms-#{gemspec.version}.gem"
|
sh "gem push pkg/custom_fields-#{gemspec.version}.gem"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :default => [:spec, :cucumber]
|
task :default => [:spec, :cucumber]
|
@ -1,2 +1,8 @@
|
|||||||
default: features --require features --format pretty --color --tags ~@wip
|
<%
|
||||||
wip: features --require features --tags @wip
|
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
||||||
|
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
||||||
|
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
||||||
|
%>
|
||||||
|
default: <%= std_opts %> features
|
||||||
|
wip: --tags @wip:3 --wip features
|
||||||
|
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
||||||
|
11
doc/TODO
11
doc/TODO
@ -3,6 +3,7 @@ BOARD:
|
|||||||
x bushido version
|
x bushido version
|
||||||
x default template
|
x default template
|
||||||
~ editable_elements: inheritable: false (Mattias) => seems to be fixed by Dirk's last pull request (#44) => content tag
|
~ editable_elements: inheritable: false (Mattias) => seems to be fixed by Dirk's last pull request (#44) => content tag
|
||||||
|
x resizing images on the fly
|
||||||
x locomedia tinyMCE plugin (Bernd)
|
x locomedia tinyMCE plugin (Bernd)
|
||||||
x remove asset_collections
|
x remove asset_collections
|
||||||
x site templates
|
x site templates
|
||||||
@ -49,9 +50,9 @@ x enable rack-cache only for a specific url
|
|||||||
=> MERGE
|
=> MERGE
|
||||||
|
|
||||||
- bugs
|
- bugs
|
||||||
- heroku: unable to upload a new file
|
- heroku: unable to upload a new file => okay
|
||||||
- import
|
- import => okay
|
||||||
- delete an item
|
- delete an item => okay
|
||||||
- liquid tag: Date.today (now), add a test to compare 2 dates
|
- liquid tag: Date.today (now), add a test to compare 2 dates
|
||||||
- better ui: increase text field length + refactor error message
|
- better ui: increase text field length + refactor error message
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ BUGS:
|
|||||||
|
|
||||||
NICE TO HAVE:
|
NICE TO HAVE:
|
||||||
- export site
|
- export site
|
||||||
- asset collections: custom resizing if image
|
|
||||||
- super_finder
|
- super_finder
|
||||||
- traffic statistics
|
- traffic statistics
|
||||||
- asset picker (content instance)
|
- asset picker (content instance)
|
||||||
@ -94,7 +95,6 @@ NICE TO HAVE:
|
|||||||
- automatic update !
|
- automatic update !
|
||||||
- page not found (front) => if logged in, link to create the page
|
- page not found (front) => if logged in, link to create the page
|
||||||
- switch to list (theme assets / assets ?). delete all in once (with checkbox) or see details (updated_at, size, ...etc)
|
- switch to list (theme assets / assets ?). delete all in once (with checkbox) or see details (updated_at, size, ...etc)
|
||||||
- resizing images on the fly
|
|
||||||
- code completion ? http://blog.quplo.com/2010/06/common-sense-code-completion/
|
- code completion ? http://blog.quplo.com/2010/06/common-sense-code-completion/
|
||||||
|
|
||||||
DONE:
|
DONE:
|
||||||
@ -268,3 +268,4 @@ x integrate new locomotivecms home
|
|||||||
x seo section for the page form: seo title, seo keywords, seo description
|
x seo section for the page form: seo title, seo keywords, seo description
|
||||||
x bugs: #50, #51
|
x bugs: #50, #51
|
||||||
x 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa)
|
x 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa)
|
||||||
|
! asset collections: custom resizing if image
|
@ -5,6 +5,12 @@ Feature: Manage Contents
|
|||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given I have the site: "test site" set up
|
Given I have the site: "test site" set up
|
||||||
|
And I have a custom project model
|
||||||
And I am an authenticated user
|
And I am an authenticated user
|
||||||
|
|
||||||
|
Scenario: Adding a new entry
|
||||||
|
When I go to the "Projects" model edition page
|
||||||
|
And I follow "new item"
|
||||||
|
Then I should see "Projects — new item"
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,13 +33,12 @@ end
|
|||||||
Then /^I should have "(.*)" in the (.*) page$/ do |content, page_slug|
|
Then /^I should have "(.*)" in the (.*) page$/ do |content, page_slug|
|
||||||
page = @site.pages.where(:slug => page_slug).first
|
page = @site.pages.where(:slug => page_slug).first
|
||||||
raise "Could not find page: #{page_slug}" unless page
|
raise "Could not find page: #{page_slug}" unless page
|
||||||
|
|
||||||
page.raw_template.should == content
|
page.raw_template.should == content
|
||||||
end
|
end
|
||||||
|
|
||||||
# checks if the rendered body matches a string
|
# checks if the rendered body matches a string
|
||||||
Then /^the rendered output should look like:$/ do |body_contents|
|
Then /^the rendered output should look like:$/ do |body_contents|
|
||||||
page.body.should == body_contents
|
page.source.should == body_contents
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see delete page buttons$/ do
|
Then /^I should see delete page buttons$/ do
|
||||||
|
@ -1,21 +1,32 @@
|
|||||||
|
# TL;DR: YOU SHOULD DELETE THIS FILE
|
||||||
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
||||||
# It is recommended to regenerate this file in the future when you upgrade to a
|
# It is recommended to regenerate this file in the future when you upgrade to a
|
||||||
# newer version of cucumber-rails. Consider adding your own code to a new file
|
# newer version of cucumber-rails. Consider adding your own code to a new file
|
||||||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||||
# files.
|
# files.
|
||||||
|
|
||||||
|
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
||||||
|
|
||||||
module WithinHelpers
|
module WithinHelpers
|
||||||
def with_scope(locator)
|
def with_scope(locator)
|
||||||
locator ? within(locator) { yield } : yield
|
locator ? within(*selector_for(locator)) { yield } : yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
World(WithinHelpers)
|
World(WithinHelpers)
|
||||||
|
|
||||||
|
# Single-line step scoper
|
||||||
|
When /^(.*) within (.*[^:])$/ do |step, parent|
|
||||||
|
with_scope(parent) { When step }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Multi-line step scoper
|
||||||
|
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
|
||||||
|
with_scope(parent) { When "#{step}:", table_or_string }
|
||||||
|
end
|
||||||
|
|
||||||
Given /^(?:|I )am on (.+)$/ do |page_name|
|
Given /^(?:|I )am on (.+)$/ do |page_name|
|
||||||
visit path_to(page_name)
|
visit path_to(page_name)
|
||||||
end
|
end
|
||||||
@ -24,28 +35,20 @@ When /^(?:|I )go to (.+)$/ do |page_name|
|
|||||||
visit path_to(page_name)
|
visit path_to(page_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )press "([^\"]*)"(?: within "([^\"]*)")?$/ do |button, selector|
|
When /^(?:|I )press "([^"]*)"$/ do |button|
|
||||||
with_scope(selector) do
|
|
||||||
click_button(button)
|
click_button(button)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )follow "([^\"]*)"(?: within "([^\"]*)")?$/ do |link, selector|
|
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
||||||
with_scope(selector) do
|
|
||||||
click_link(link)
|
click_link(link)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, value, selector|
|
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
||||||
with_scope(selector) do
|
|
||||||
fill_in(field, :with => value)
|
fill_in(field, :with => value)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
|
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
||||||
with_scope(selector) do
|
|
||||||
fill_in(field, :with => value)
|
fill_in(field, :with => value)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use this to fill in an entire form with data from a table. Example:
|
# Use this to fill in an entire form with data from a table. Example:
|
||||||
@ -59,95 +62,70 @@ end
|
|||||||
# TODO: Add support for checkbox, select og option
|
# TODO: Add support for checkbox, select og option
|
||||||
# based on naming conventions.
|
# based on naming conventions.
|
||||||
#
|
#
|
||||||
When /^(?:|I )fill in the following(?: within "([^\"]*)")?:$/ do |selector, fields|
|
When /^(?:|I )fill in the following:$/ do |fields|
|
||||||
with_scope(selector) do
|
|
||||||
fields.rows_hash.each do |name, value|
|
fields.rows_hash.each do |name, value|
|
||||||
When %{I fill in "#{name}" with "#{value}"}
|
When %{I fill in "#{name}" with "#{value}"}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
|
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
||||||
with_scope(selector) do
|
|
||||||
select(value, :from => field)
|
select(value, :from => field)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )check "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
When /^(?:|I )check "([^"]*)"$/ do |field|
|
||||||
with_scope(selector) do
|
|
||||||
check(field)
|
check(field)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )uncheck "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
||||||
with_scope(selector) do
|
|
||||||
uncheck(field)
|
uncheck(field)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )choose "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
||||||
with_scope(selector) do
|
|
||||||
choose(field)
|
choose(field)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"(?: within "([^\"]*)")?$/ do |path, field, selector|
|
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
||||||
with_scope(selector) do
|
attach_file(field, File.expand_path(path))
|
||||||
attach_file(field, path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^(?:|I )should see JSON:$/ do |expected_json|
|
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
||||||
require 'json'
|
|
||||||
expected = JSON.pretty_generate(JSON.parse(expected_json))
|
|
||||||
actual = JSON.pretty_generate(JSON.parse(response.body))
|
|
||||||
expected.should == actual
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
|
|
||||||
with_scope(selector) do
|
|
||||||
if page.respond_to? :should
|
if page.respond_to? :should
|
||||||
page.should have_content(text)
|
page.should have_content(text)
|
||||||
else
|
else
|
||||||
assert page.has_content?(text)
|
assert page.has_content?(text)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
|
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
||||||
regexp = Regexp.new(regexp)
|
regexp = Regexp.new(regexp)
|
||||||
with_scope(selector) do
|
|
||||||
if page.respond_to? :should
|
if page.respond_to? :should
|
||||||
page.should have_xpath('//*', :text => regexp)
|
page.should have_xpath('//*', :text => regexp)
|
||||||
else
|
else
|
||||||
assert page.has_xpath?('//*', :text => regexp)
|
assert page.has_xpath?('//*', :text => regexp)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^(?:|I )should not see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
|
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
||||||
with_scope(selector) do
|
|
||||||
if page.respond_to? :should
|
if page.respond_to? :should
|
||||||
page.should have_no_content(text)
|
page.should have_no_content(text)
|
||||||
else
|
else
|
||||||
assert page.has_no_content?(text)
|
assert page.has_no_content?(text)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
|
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
||||||
regexp = Regexp.new(regexp)
|
regexp = Regexp.new(regexp)
|
||||||
with_scope(selector) do
|
|
||||||
if page.respond_to? :should
|
if page.respond_to? :should
|
||||||
page.should have_no_xpath('//*', :text => regexp)
|
page.should have_no_xpath('//*', :text => regexp)
|
||||||
else
|
else
|
||||||
assert page.has_no_xpath?('//*', :text => regexp)
|
assert page.has_no_xpath?('//*', :text => regexp)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ do |field, selector, value|
|
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
||||||
with_scope(selector) do
|
with_scope(parent) do
|
||||||
field = find_field(field)
|
field = find_field(field)
|
||||||
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||||
if field_value.respond_to? :should
|
if field_value.respond_to? :should
|
||||||
@ -158,8 +136,8 @@ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ d
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"$/ do |field, selector, value|
|
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
||||||
with_scope(selector) do
|
with_scope(parent) do
|
||||||
field = find_field(field)
|
field = find_field(field)
|
||||||
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||||
if field_value.respond_to? :should_not
|
if field_value.respond_to? :should_not
|
||||||
@ -170,24 +148,24 @@ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should be checked$/ do |label, selector|
|
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
||||||
with_scope(selector) do
|
with_scope(parent) do
|
||||||
field_checked = find_field(label)['checked']
|
field_checked = find_field(label)['checked']
|
||||||
if field_checked.respond_to? :should
|
if field_checked.respond_to? :should
|
||||||
field_checked.should == 'checked'
|
field_checked.should be_true
|
||||||
else
|
else
|
||||||
assert_equal 'checked', field_checked
|
assert field_checked
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector|
|
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
||||||
with_scope(selector) do
|
with_scope(parent) do
|
||||||
field_checked = find_field(label)['checked']
|
field_checked = find_field(label)['checked']
|
||||||
if field_checked.respond_to? :should_not
|
if field_checked.respond_to? :should
|
||||||
field_checked.should_not == 'checked'
|
field_checked.should be_false
|
||||||
else
|
else
|
||||||
assert_not_equal 'checked', field_checked
|
assert !field_checked
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,46 +4,159 @@
|
|||||||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||||
# files.
|
# files.
|
||||||
|
|
||||||
ENV["RAILS_ENV"] ||= "test"
|
# ENV['RAILS_ENV'] ||= 'test'
|
||||||
|
#
|
||||||
|
# require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
||||||
|
#
|
||||||
|
# require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
||||||
|
# require 'cucumber/rails'
|
||||||
|
# require 'cucumber/rails/rspec'
|
||||||
|
# require 'cucumber/rails/world'
|
||||||
|
# require 'cucumber/web/tableish'
|
||||||
|
#
|
||||||
|
# require 'capybara/rails'
|
||||||
|
# require 'capybara/cucumber'
|
||||||
|
# require 'capybara/session'
|
||||||
|
#
|
||||||
|
# # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
||||||
|
# # order to ease the transition to Capybara we set the default here. If you'd
|
||||||
|
# # prefer to use XPath just remove this line and adjust any selectors in your
|
||||||
|
# # steps to use the XPath syntax.
|
||||||
|
# Capybara.default_selector = :css
|
||||||
|
#
|
||||||
|
# Capybara.javascript_driver = :selenium
|
||||||
|
#
|
||||||
|
# Capybara.default_host = 'test.example.com'
|
||||||
|
|
||||||
|
ENV['RAILS_ENV'] ||= 'test'
|
||||||
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
||||||
|
|
||||||
|
# require 'cucumber/rails'
|
||||||
|
|
||||||
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
||||||
require 'cucumber/rails/rspec'
|
require 'cucumber/rails/rspec'
|
||||||
require 'cucumber/rails/world'
|
require 'cucumber/rails/world'
|
||||||
require 'cucumber/web/tableish'
|
require 'cucumber/web/tableish'
|
||||||
|
|
||||||
|
# require 'capybara'
|
||||||
require 'capybara/rails'
|
require 'capybara/rails'
|
||||||
require 'capybara/cucumber'
|
require 'capybara/cucumber'
|
||||||
require 'capybara/session'
|
require 'capybara/session'
|
||||||
|
|
||||||
require 'ruby-debug'
|
# Capybara.default_selector = :css
|
||||||
|
|
||||||
# envjs doesnt work at the moment
|
Capybara.configure do |config|
|
||||||
# require 'capybara/envjs'
|
config.run_server = false
|
||||||
|
config.default_selector = :css
|
||||||
|
config.app_host = 'http://test.example.com'
|
||||||
|
end
|
||||||
|
|
||||||
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
Capybara.javascript_driver = :rack_test # :selenium
|
||||||
# order to ease the transition to Capybara we set the default here. If you'd
|
|
||||||
# prefer to use XPath just remove this line and adjust any selectors in your
|
|
||||||
# steps to use the XPath syntax.
|
|
||||||
Capybara.default_selector = :css
|
|
||||||
|
|
||||||
Capybara.javascript_driver = :selenium
|
|
||||||
|
|
||||||
# If you set this to false, any error raised from within your app will bubble
|
# Stop endless errors like
|
||||||
# up to your step definition and out to cucumber unless you catch it somewhere
|
# ~/.rvm/gems/ruby-1.9.2-p0@global/gems/rack-1.2.1/lib/rack/utils.rb:16:
|
||||||
# on the way. You can make Rails rescue errors and render error pages on a
|
# warning: regexp match /.../n against to UTF-8 string
|
||||||
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
# more information here: https://github.com/jnicklas/capybara/issues/243
|
||||||
|
# $VERBOSE = nil
|
||||||
|
|
||||||
|
# Capybara.default_host = 'test.example.com'
|
||||||
|
|
||||||
|
# Capybara.app_host = 'test.example.com'
|
||||||
|
|
||||||
|
# By default, any exception happening in your Rails application will bubble up
|
||||||
|
# to Cucumber so that your scenario will fail. This is a different from how
|
||||||
|
# your application behaves in the production environment, where an error page will
|
||||||
|
# be rendered instead.
|
||||||
#
|
#
|
||||||
# If you set this to true, Rails will rescue all errors and render error
|
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
||||||
# pages, more or less in the same way your application would behave in the
|
# exceptions and display an error page (just like when the app is running in production).
|
||||||
# default production environment. It's not recommended to do this for all
|
# Typical scenarios where you want to do this is when you test your error pages.
|
||||||
# of your scenarios, as this makes it hard to discover errors in your application.
|
# There are two ways to allow Rails to rescue exceptions:
|
||||||
ActionController::Base.allow_rescue = false
|
#
|
||||||
|
# 1) Tag your scenario (or feature) with @allow-rescue
|
||||||
|
#
|
||||||
|
# 2) Set the value below to true. Beware that doing this globally is not
|
||||||
|
# recommended as it will mask a lot of errors for you!
|
||||||
|
#
|
||||||
|
# ActionController::Base.allow_rescue = false
|
||||||
|
|
||||||
|
# # Remove/comment out the lines below if your app doesn't have a database.
|
||||||
|
# # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
||||||
|
# begin
|
||||||
|
# DatabaseCleaner.strategy = :transaction
|
||||||
|
# rescue NameError
|
||||||
|
# raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
||||||
|
# end
|
||||||
|
|
||||||
Capybara.default_host = 'test.example.com'
|
|
||||||
# Capybara.app_host = 'http://test.example.com'
|
|
||||||
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/carrierwave')
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/carrierwave')
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/locomotive')
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/locomotive')
|
||||||
|
|
||||||
Locomotive.configure_for_test(true)
|
Locomotive.configure_for_test(true)
|
||||||
|
|
||||||
|
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
||||||
|
# See the DatabaseCleaner documentation for details. Example:
|
||||||
|
#
|
||||||
|
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
||||||
|
# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
||||||
|
# DatabaseCleaner.strategy = :transaction
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
||||||
|
# # It is recommended to regenerate this file in the future when you upgrade to a
|
||||||
|
# # newer version of cucumber-rails. Consider adding your own code to a new file
|
||||||
|
# # instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||||
|
# # files.
|
||||||
|
#
|
||||||
|
# ENV["RAILS_ENV"] ||= "test"
|
||||||
|
# require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
||||||
|
#
|
||||||
|
# # require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
||||||
|
# # require 'cucumber/rails/rspec'
|
||||||
|
# # require 'cucumber/rails/world'
|
||||||
|
# # require 'cucumber/web/tableish'
|
||||||
|
#
|
||||||
|
# require 'cucumber/rails'
|
||||||
|
#
|
||||||
|
# require 'capybara/rails'
|
||||||
|
# require 'capybara/cucumber'
|
||||||
|
# require 'capybara/session'
|
||||||
|
#
|
||||||
|
# # require 'ruby-debug'
|
||||||
|
#
|
||||||
|
# # envjs doesnt work at the moment
|
||||||
|
# # require 'capybara/envjs'
|
||||||
|
#
|
||||||
|
# # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
||||||
|
# # order to ease the transition to Capybara we set the default here. If you'd
|
||||||
|
# # prefer to use XPath just remove this line and adjust any selectors in your
|
||||||
|
# # steps to use the XPath syntax.
|
||||||
|
# Capybara.default_selector = :css
|
||||||
|
#
|
||||||
|
# Capybara.javascript_driver = :selenium
|
||||||
|
#
|
||||||
|
# # If you set this to false, any error raised from within your app will bubble
|
||||||
|
# # up to your step definition and out to cucumber unless you catch it somewhere
|
||||||
|
# # on the way. You can make Rails rescue errors and render error pages on a
|
||||||
|
# # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
||||||
|
# #
|
||||||
|
# # If you set this to true, Rails will rescue all errors and render error
|
||||||
|
# # pages, more or less in the same way your application would behave in the
|
||||||
|
# # default production environment. It's not recommended to do this for all
|
||||||
|
# # of your scenarios, as this makes it hard to discover errors in your application.
|
||||||
|
# ActionController::Base.allow_rescue = false
|
||||||
|
#
|
||||||
|
# Capybara.default_host = 'test.example.com'
|
||||||
|
# # Capybara.app_host = 'http://test.example.com'
|
||||||
|
#
|
||||||
|
# require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/carrierwave')
|
||||||
|
# require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/locomotive')
|
||||||
|
#
|
||||||
|
# Locomotive.configure_for_test(true)
|
@ -8,7 +8,7 @@ module NavigationHelpers
|
|||||||
def path_to(page_name)
|
def path_to(page_name)
|
||||||
case page_name
|
case page_name
|
||||||
|
|
||||||
when /the home\s?page/
|
when /the home\s?page$/
|
||||||
'/'
|
'/'
|
||||||
when /login/
|
when /login/
|
||||||
new_admin_session_path
|
new_admin_session_path
|
||||||
@ -39,10 +39,10 @@ module NavigationHelpers
|
|||||||
|
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
page_name =~ /the (.*) page/
|
page_name =~ /^the (.*) page$/
|
||||||
path_components = $1.split(/\s+/)
|
path_components = $1.split(/\s+/)
|
||||||
self.send(path_components.push('path').join('_').to_sym)
|
self.send(path_components.push('path').join('_').to_sym)
|
||||||
rescue Object => e
|
rescue NoMethodError, ArgumentError
|
||||||
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
||||||
"Now, go and add a mapping in #{__FILE__}"
|
"Now, go and add a mapping in #{__FILE__}"
|
||||||
end
|
end
|
||||||
@ -51,3 +51,58 @@ module NavigationHelpers
|
|||||||
end
|
end
|
||||||
|
|
||||||
World(NavigationHelpers)
|
World(NavigationHelpers)
|
||||||
|
|
||||||
|
|
||||||
|
# module NavigationHelpers
|
||||||
|
# # Maps a name to a path. Used by the
|
||||||
|
# #
|
||||||
|
# # When /^I go to (.+)$/ do |page_name|
|
||||||
|
# #
|
||||||
|
# # step definition in web_steps.rb
|
||||||
|
# #
|
||||||
|
# def path_to(page_name)
|
||||||
|
# case page_name
|
||||||
|
#
|
||||||
|
# when /the home\s?page/
|
||||||
|
# '/'
|
||||||
|
# when /login/
|
||||||
|
# new_admin_session_path
|
||||||
|
# when /logout/
|
||||||
|
# destroy_admin_session_path
|
||||||
|
# when /pages( list)?/
|
||||||
|
# admin_pages_path
|
||||||
|
# when /new page/
|
||||||
|
# new_admin_page_path
|
||||||
|
# when /"(.*)" edition page/
|
||||||
|
# page = Site.first.pages.where(:slug => $1).first
|
||||||
|
# edit_admin_page_path(page)
|
||||||
|
# when /theme assets/
|
||||||
|
# admin_theme_assets_path
|
||||||
|
# when /site settings/
|
||||||
|
# edit_admin_current_site_path
|
||||||
|
# when /import page/
|
||||||
|
# new_admin_import_path
|
||||||
|
# when /the "(.*)" model edition page/
|
||||||
|
# content_type = Site.first.content_types.where(:name => $1).first
|
||||||
|
# edit_admin_content_type_path(content_type)
|
||||||
|
#
|
||||||
|
# # Add more mappings here.
|
||||||
|
# # Here is an example that pulls values out of the Regexp:
|
||||||
|
# #
|
||||||
|
# # when /^(.*)'s profile page$/i
|
||||||
|
# # user_profile_path(User.find_by_login($1))
|
||||||
|
#
|
||||||
|
# else
|
||||||
|
# begin
|
||||||
|
# page_name =~ /the (.*) page/
|
||||||
|
# path_components = $1.split(/\s+/)
|
||||||
|
# self.send(path_components.push('path').join('_').to_sym)
|
||||||
|
# rescue Object => e
|
||||||
|
# raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
||||||
|
# "Now, go and add a mapping in #{__FILE__}"
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# World(NavigationHelpers)
|
||||||
|
39
features/support/selectors.rb
Normal file
39
features/support/selectors.rb
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
module HtmlSelectorsHelpers
|
||||||
|
# Maps a name to a selector. Used primarily by the
|
||||||
|
#
|
||||||
|
# When /^(.+) within (.+)$/ do |step, scope|
|
||||||
|
#
|
||||||
|
# step definitions in web_steps.rb
|
||||||
|
#
|
||||||
|
def selector_for(locator)
|
||||||
|
case locator
|
||||||
|
|
||||||
|
when "the page"
|
||||||
|
"html > body"
|
||||||
|
|
||||||
|
# Add more mappings here.
|
||||||
|
# Here is an example that pulls values out of the Regexp:
|
||||||
|
#
|
||||||
|
# when /^the (notice|error|info) flash$/
|
||||||
|
# ".flash.#{$1}"
|
||||||
|
|
||||||
|
# You can also return an array to use a different selector
|
||||||
|
# type, like:
|
||||||
|
#
|
||||||
|
# when /the header/
|
||||||
|
# [:xpath, "//header"]
|
||||||
|
|
||||||
|
# This allows you to provide a quoted selector as the scope
|
||||||
|
# for "within" steps as was previously the default for the
|
||||||
|
# web steps:
|
||||||
|
when /^"(.+)"$/
|
||||||
|
$1
|
||||||
|
|
||||||
|
else
|
||||||
|
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
|
||||||
|
"Now, go and add a mapping in #{__FILE__}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
World(HtmlSelectorsHelpers)
|
@ -34,6 +34,12 @@ begin
|
|||||||
|
|
||||||
desc 'Run all features'
|
desc 'Run all features'
|
||||||
task :all => [:ok, :wip]
|
task :all => [:ok, :wip]
|
||||||
|
|
||||||
|
task :statsetup do
|
||||||
|
require 'rails/code_statistics'
|
||||||
|
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
||||||
|
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
desc 'Alias for cucumber:ok'
|
desc 'Alias for cucumber:ok'
|
||||||
task :cucumber => 'cucumber:ok'
|
task :cucumber => 'cucumber:ok'
|
||||||
@ -43,6 +49,8 @@ begin
|
|||||||
task :features => :cucumber do
|
task :features => :cucumber do
|
||||||
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :stats => 'cucumber:statsetup'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
desc 'cucumber rake task not available (cucumber not installed)'
|
desc 'cucumber rake task not available (cucumber not installed)'
|
||||||
task :cucumber do
|
task :cucumber do
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
begin
|
|
||||||
require 'rspec/core'
|
|
||||||
require 'rspec/core/rake_task'
|
|
||||||
rescue MissingSourceFile
|
|
||||||
module Rspec
|
|
||||||
module Core
|
|
||||||
class RakeTask
|
|
||||||
|
|
||||||
include ::Rake::DSL
|
|
||||||
|
|
||||||
def initialize(name)
|
|
||||||
task name do
|
|
||||||
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
|
||||||
|
|
||||||
# ... otherwise, do this:
|
|
||||||
raise <<-MSG
|
|
||||||
|
|
||||||
#{"*" * 80}
|
|
||||||
* You are trying to run an rspec rake task defined in
|
|
||||||
* #{__FILE__},
|
|
||||||
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
|
||||||
#{"*" * 80}
|
|
||||||
MSG
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Rake.application.instance_variable_get('@tasks').delete('default')
|
|
||||||
|
|
||||||
spec_prereq = :noop # we are using mongoid and not ActiveRecord, no need to prepare the test database
|
|
||||||
task :noop do
|
|
||||||
end
|
|
||||||
|
|
||||||
task :default => :spec
|
|
||||||
task :stats => "spec:statsetup"
|
|
||||||
|
|
||||||
desc "Run all specs in spec directory (excluding plugin specs)"
|
|
||||||
Rspec::Core::RakeTask.new(:spec => spec_prereq)
|
|
||||||
|
|
||||||
namespace :spec do
|
|
||||||
[:requests, :models, :controllers, :views, :helpers, :mailers, :lib].each do |sub|
|
|
||||||
desc "Run the code examples in spec/#{sub}"
|
|
||||||
Rspec::Core::RakeTask.new(sub => spec_prereq) do |t|
|
|
||||||
t.pattern = "./spec/#{sub}/**/*_spec.rb"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
task :statsetup do
|
|
||||||
require 'rails/code_statistics'
|
|
||||||
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
|
||||||
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
|
||||||
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
|
||||||
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
|
||||||
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
|
||||||
::STATS_DIRECTORIES << %w(Mailer\ specs spec/mailers) if File.exist?('spec/mailers')
|
|
||||||
::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
|
|
||||||
::STATS_DIRECTORIES << %w(Request\ specs spec/requests) if File.exist?('spec/requests')
|
|
||||||
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
|
||||||
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
|
||||||
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
|
||||||
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
|
||||||
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
|
||||||
::CodeStatistics::TEST_TYPES << "Mailer specs" if File.exist?('spec/mailer')
|
|
||||||
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
|
||||||
::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user