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
|
||||
|
||||
gem 'rake', '0.8.7'
|
||||
gem 'rake', '0.9.2'
|
||||
|
||||
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
|
||||
|
||||
group :development do
|
||||
# Using unicorn_rails instead of webrick (default server)
|
||||
gem 'unicorn'
|
||||
gem 'unicorn' # Using unicorn_rails instead of webrick (default server)
|
||||
|
||||
gem 'rspec-rails', '2.3.1' # in order to have rspec tasks and generators
|
||||
end
|
||||
|
||||
group :test, :development do
|
||||
@ -52,6 +53,8 @@ group :test, :development do
|
||||
gem 'ruby-debug19', :platforms => :mri_19
|
||||
|
||||
gem 'bushido_stub', :git => 'git://github.com/did/bushido_stub.git'
|
||||
|
||||
gem 'cucumber-rails', '1.0.2'
|
||||
end
|
||||
|
||||
group :production do
|
||||
@ -65,12 +68,10 @@ group :test do
|
||||
gem 'rspec-rails', '2.3.1'
|
||||
gem 'factory_girl_rails'
|
||||
gem 'pickle'
|
||||
gem 'xpath', '0.1.3'
|
||||
gem 'xpath', '~> 0.1.4'
|
||||
gem 'capybara'
|
||||
|
||||
gem 'database_cleaner'
|
||||
gem 'cucumber', '0.8.5'
|
||||
gem 'cucumber-rails'
|
||||
|
||||
gem 'spork'
|
||||
gem 'launchy'
|
||||
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
|
||||
|
50
Gemfile.lock
50
Gemfile.lock
@ -63,30 +63,28 @@ GEM
|
||||
json (>= 1.4.6)
|
||||
rest-client (>= 1.6.1)
|
||||
cancan (1.6.5)
|
||||
capybara (0.4.1.2)
|
||||
celerity (>= 0.7.9)
|
||||
culerity (>= 0.2.4)
|
||||
capybara (1.0.0)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (>= 0.0.27)
|
||||
xpath (~> 0.1.3)
|
||||
celerity (0.8.9)
|
||||
selenium-webdriver (~> 0.2.0)
|
||||
xpath (~> 0.1.4)
|
||||
childprocess (0.1.9)
|
||||
ffi (~> 1.0.6)
|
||||
columnize (0.3.3)
|
||||
configuration (1.3.1)
|
||||
crack (0.1.8)
|
||||
cucumber (0.8.5)
|
||||
builder (~> 2.1.2)
|
||||
diff-lcs (~> 1.1.2)
|
||||
gherkin (~> 2.1.4)
|
||||
json_pure (~> 1.4.3)
|
||||
term-ansicolor (~> 1.0.4)
|
||||
cucumber-rails (0.3.2)
|
||||
cucumber (>= 0.8.0)
|
||||
culerity (0.2.15)
|
||||
cucumber (1.0.0)
|
||||
builder (>= 2.1.2)
|
||||
diff-lcs (>= 1.1.2)
|
||||
gherkin (~> 2.4.1)
|
||||
json (>= 1.4.6)
|
||||
term-ansicolor (>= 1.0.5)
|
||||
cucumber-rails (1.0.2)
|
||||
capybara (>= 1.0.0)
|
||||
cucumber (~> 1.0.0)
|
||||
nokogiri (>= 1.4.6)
|
||||
custom_fields (1.0.0.beta.19)
|
||||
activesupport (>= 3.0.7)
|
||||
mongoid (= 2.0.2)
|
||||
@ -127,8 +125,8 @@ GEM
|
||||
actionpack (>= 2.3.7)
|
||||
activesupport (>= 2.3.7)
|
||||
i18n (~> 0.4)
|
||||
gherkin (2.1.5)
|
||||
trollop (~> 1.16.2)
|
||||
gherkin (2.4.1)
|
||||
json (>= 1.4.6)
|
||||
growl-glue (1.0.7)
|
||||
haml (3.1.2)
|
||||
has_scope (0.5.0)
|
||||
@ -146,7 +144,7 @@ GEM
|
||||
jammit (0.6.3)
|
||||
yui-compressor (>= 0.9.3)
|
||||
json (1.5.3)
|
||||
json_pure (1.4.6)
|
||||
json_pure (1.5.3)
|
||||
kgio (2.5.0)
|
||||
launchy (0.3.7)
|
||||
configuration (>= 0.0.5)
|
||||
@ -208,8 +206,8 @@ GEM
|
||||
rdoc (~> 3.4)
|
||||
thor (~> 0.14.4)
|
||||
raindrops (0.7.0)
|
||||
rake (0.8.7)
|
||||
rdoc (3.6.1)
|
||||
rake (0.9.2)
|
||||
rdoc (3.7)
|
||||
responders (0.6.4)
|
||||
rest-client (1.6.3)
|
||||
mime-types (>= 1.16)
|
||||
@ -257,8 +255,7 @@ GEM
|
||||
thor (0.14.6)
|
||||
treetop (1.4.9)
|
||||
polyglot (>= 0.3.1)
|
||||
trollop (1.16.2)
|
||||
tzinfo (0.3.28)
|
||||
tzinfo (0.3.29)
|
||||
unicorn (4.0.0)
|
||||
kgio (~> 2.4)
|
||||
rack
|
||||
@ -266,7 +263,7 @@ GEM
|
||||
warden (1.0.4)
|
||||
rack (>= 1.0)
|
||||
will_paginate (2.3.15)
|
||||
xpath (0.1.3)
|
||||
xpath (0.1.4)
|
||||
nokogiri (~> 1.3)
|
||||
yui-compressor (0.9.6)
|
||||
POpen4 (>= 0.1.4)
|
||||
@ -285,8 +282,7 @@ DEPENDENCIES
|
||||
bushido_stub!
|
||||
cancan
|
||||
capybara
|
||||
cucumber (= 0.8.5)
|
||||
cucumber-rails
|
||||
cucumber-rails (= 1.0.2)
|
||||
custom_fields (= 1.0.0.beta.19)
|
||||
database_cleaner
|
||||
delayed_job (= 2.1.4)
|
||||
@ -313,7 +309,7 @@ DEPENDENCIES
|
||||
pickle
|
||||
rack-cache
|
||||
rails (= 3.0.9)
|
||||
rake (= 0.8.7)
|
||||
rake (= 0.9.2)
|
||||
rmagick (= 2.12.2)
|
||||
rspec-rails (= 2.3.1)
|
||||
ruby-debug
|
||||
@ -324,4 +320,4 @@ DEPENDENCIES
|
||||
unicorn
|
||||
warden
|
||||
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 'rubygems'
|
||||
|
||||
require 'rake'
|
||||
require 'rake/testtask'
|
||||
require 'rake/rdoctask'
|
||||
require 'rake/gempackagetask'
|
||||
require 'rdoc/task'
|
||||
require 'rubygems/package_task'
|
||||
|
||||
Locomotive::Application.load_tasks
|
||||
|
||||
gemspec = eval(File.read('locomotive_cms.gemspec'))
|
||||
Rake::GemPackageTask.new(gemspec) do |pkg|
|
||||
Gem::PackageTask.new(gemspec) do |pkg|
|
||||
pkg.gem_spec = gemspec
|
||||
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
|
||||
sh "gem push pkg/locomotive_cms-#{gemspec.version}.gem"
|
||||
sh "gem push pkg/custom_fields-#{gemspec.version}.gem"
|
||||
end
|
||||
|
||||
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
|
||||
|
13
doc/TODO
13
doc/TODO
@ -3,6 +3,7 @@ BOARD:
|
||||
x bushido version
|
||||
x default template
|
||||
~ 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 remove asset_collections
|
||||
x site templates
|
||||
@ -49,9 +50,9 @@ x enable rack-cache only for a specific url
|
||||
=> MERGE
|
||||
|
||||
- bugs
|
||||
- heroku: unable to upload a new file
|
||||
- import
|
||||
- delete an item
|
||||
- heroku: unable to upload a new file => okay
|
||||
- import => okay
|
||||
- delete an item => okay
|
||||
- liquid tag: Date.today (now), add a test to compare 2 dates
|
||||
- better ui: increase text field length + refactor error message
|
||||
|
||||
@ -86,7 +87,7 @@ BUGS:
|
||||
|
||||
NICE TO HAVE:
|
||||
- export site
|
||||
- asset collections: custom resizing if image
|
||||
|
||||
- super_finder
|
||||
- traffic statistics
|
||||
- asset picker (content instance)
|
||||
@ -94,7 +95,6 @@ NICE TO HAVE:
|
||||
- automatic update !
|
||||
- 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)
|
||||
- resizing images on the fly
|
||||
- code completion ? http://blog.quplo.com/2010/06/common-sense-code-completion/
|
||||
|
||||
DONE:
|
||||
@ -267,4 +267,5 @@ x generated sitemaps are invalid (url + date)
|
||||
x integrate new locomotivecms home
|
||||
x seo section for the page form: seo title, seo keywords, seo description
|
||||
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
|
@ -4,7 +4,13 @@ Feature: Manage Contents
|
||||
I want to add/edit/delete custom contents of my site
|
||||
|
||||
Background:
|
||||
Given I have the site: "test site" set up
|
||||
And I am an authenticated user
|
||||
Given I have the site: "test site" set up
|
||||
And I have a custom project model
|
||||
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|
|
||||
page = @site.pages.where(:slug => page_slug).first
|
||||
raise "Could not find page: #{page_slug}" unless page
|
||||
|
||||
page.raw_template.should == content
|
||||
end
|
||||
|
||||
# checks if the rendered body matches a string
|
||||
Then /^the rendered output should look like:$/ do |body_contents|
|
||||
page.body.should == body_contents
|
||||
page.source.should == body_contents
|
||||
end
|
||||
|
||||
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.
|
||||
# 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.
|
||||
|
||||
|
||||
require 'uri'
|
||||
require 'cgi'
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
||||
|
||||
module WithinHelpers
|
||||
def with_scope(locator)
|
||||
locator ? within(locator) { yield } : yield
|
||||
locator ? within(*selector_for(locator)) { yield } : yield
|
||||
end
|
||||
end
|
||||
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|
|
||||
visit path_to(page_name)
|
||||
end
|
||||
@ -24,28 +35,20 @@ When /^(?:|I )go to (.+)$/ do |page_name|
|
||||
visit path_to(page_name)
|
||||
end
|
||||
|
||||
When /^(?:|I )press "([^\"]*)"(?: within "([^\"]*)")?$/ do |button, selector|
|
||||
with_scope(selector) do
|
||||
click_button(button)
|
||||
end
|
||||
When /^(?:|I )press "([^"]*)"$/ do |button|
|
||||
click_button(button)
|
||||
end
|
||||
|
||||
When /^(?:|I )follow "([^\"]*)"(?: within "([^\"]*)")?$/ do |link, selector|
|
||||
with_scope(selector) do
|
||||
click_link(link)
|
||||
end
|
||||
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
||||
click_link(link)
|
||||
end
|
||||
|
||||
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, value, selector|
|
||||
with_scope(selector) do
|
||||
fill_in(field, :with => value)
|
||||
end
|
||||
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
||||
fill_in(field, :with => value)
|
||||
end
|
||||
|
||||
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
|
||||
with_scope(selector) do
|
||||
fill_in(field, :with => value)
|
||||
end
|
||||
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
||||
fill_in(field, :with => value)
|
||||
end
|
||||
|
||||
# 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
|
||||
# based on naming conventions.
|
||||
#
|
||||
When /^(?:|I )fill in the following(?: within "([^\"]*)")?:$/ do |selector, fields|
|
||||
with_scope(selector) do
|
||||
fields.rows_hash.each do |name, value|
|
||||
When %{I fill in "#{name}" with "#{value}"}
|
||||
end
|
||||
When /^(?:|I )fill in the following:$/ do |fields|
|
||||
fields.rows_hash.each do |name, value|
|
||||
When %{I fill in "#{name}" with "#{value}"}
|
||||
end
|
||||
end
|
||||
|
||||
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
|
||||
with_scope(selector) do
|
||||
select(value, :from => field)
|
||||
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
||||
select(value, :from => field)
|
||||
end
|
||||
|
||||
When /^(?:|I )check "([^"]*)"$/ do |field|
|
||||
check(field)
|
||||
end
|
||||
|
||||
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
||||
uncheck(field)
|
||||
end
|
||||
|
||||
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
||||
choose(field)
|
||||
end
|
||||
|
||||
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
||||
attach_file(field, File.expand_path(path))
|
||||
end
|
||||
|
||||
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
||||
if page.respond_to? :should
|
||||
page.should have_content(text)
|
||||
else
|
||||
assert page.has_content?(text)
|
||||
end
|
||||
end
|
||||
|
||||
When /^(?:|I )check "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
||||
with_scope(selector) do
|
||||
check(field)
|
||||
end
|
||||
end
|
||||
|
||||
When /^(?:|I )uncheck "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
||||
with_scope(selector) do
|
||||
uncheck(field)
|
||||
end
|
||||
end
|
||||
|
||||
When /^(?:|I )choose "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
||||
with_scope(selector) do
|
||||
choose(field)
|
||||
end
|
||||
end
|
||||
|
||||
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"(?: within "([^\"]*)")?$/ do |path, field, selector|
|
||||
with_scope(selector) do
|
||||
attach_file(field, path)
|
||||
end
|
||||
end
|
||||
|
||||
Then /^(?:|I )should see JSON:$/ do |expected_json|
|
||||
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
|
||||
page.should have_content(text)
|
||||
else
|
||||
assert page.has_content?(text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
|
||||
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
||||
regexp = Regexp.new(regexp)
|
||||
with_scope(selector) do
|
||||
if page.respond_to? :should
|
||||
page.should have_xpath('//*', :text => regexp)
|
||||
else
|
||||
assert page.has_xpath?('//*', :text => regexp)
|
||||
end
|
||||
|
||||
if page.respond_to? :should
|
||||
page.should have_xpath('//*', :text => regexp)
|
||||
else
|
||||
assert page.has_xpath?('//*', :text => regexp)
|
||||
end
|
||||
end
|
||||
|
||||
Then /^(?:|I )should not see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
|
||||
with_scope(selector) do
|
||||
if page.respond_to? :should
|
||||
page.should have_no_content(text)
|
||||
else
|
||||
assert page.has_no_content?(text)
|
||||
end
|
||||
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
||||
if page.respond_to? :should
|
||||
page.should have_no_content(text)
|
||||
else
|
||||
assert page.has_no_content?(text)
|
||||
end
|
||||
end
|
||||
|
||||
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
|
||||
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
||||
regexp = Regexp.new(regexp)
|
||||
with_scope(selector) do
|
||||
if page.respond_to? :should
|
||||
page.should have_no_xpath('//*', :text => regexp)
|
||||
else
|
||||
assert page.has_no_xpath?('//*', :text => regexp)
|
||||
end
|
||||
|
||||
if page.respond_to? :should
|
||||
page.should have_no_xpath('//*', :text => regexp)
|
||||
else
|
||||
assert page.has_no_xpath?('//*', :text => regexp)
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ do |field, selector, value|
|
||||
with_scope(selector) do
|
||||
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
||||
with_scope(parent) do
|
||||
field = find_field(field)
|
||||
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||
if field_value.respond_to? :should
|
||||
@ -158,8 +136,8 @@ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ d
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"$/ do |field, selector, value|
|
||||
with_scope(selector) do
|
||||
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
||||
with_scope(parent) do
|
||||
field = find_field(field)
|
||||
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||
if field_value.respond_to? :should_not
|
||||
@ -170,24 +148,24 @@ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should be checked$/ do |label, selector|
|
||||
with_scope(selector) do
|
||||
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
||||
with_scope(parent) do
|
||||
field_checked = find_field(label)['checked']
|
||||
if field_checked.respond_to? :should
|
||||
field_checked.should == 'checked'
|
||||
field_checked.should be_true
|
||||
else
|
||||
assert_equal 'checked', field_checked
|
||||
assert field_checked
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector|
|
||||
with_scope(selector) do
|
||||
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
||||
with_scope(parent) do
|
||||
field_checked = find_field(label)['checked']
|
||||
if field_checked.respond_to? :should_not
|
||||
field_checked.should_not == 'checked'
|
||||
if field_checked.respond_to? :should
|
||||
field_checked.should be_false
|
||||
else
|
||||
assert_not_equal 'checked', field_checked
|
||||
assert !field_checked
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,46 +4,159 @@
|
||||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||
# 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 'cucumber/rails'
|
||||
|
||||
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 'capybara'
|
||||
require 'capybara/rails'
|
||||
require 'capybara/cucumber'
|
||||
require 'capybara/session'
|
||||
|
||||
require 'ruby-debug'
|
||||
# Capybara.default_selector = :css
|
||||
|
||||
# envjs doesnt work at the moment
|
||||
# require 'capybara/envjs'
|
||||
Capybara.configure do |config|
|
||||
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
|
||||
# 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 = :rack_test # :selenium
|
||||
|
||||
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.
|
||||
# Stop endless errors like
|
||||
# ~/.rvm/gems/ruby-1.9.2-p0@global/gems/rack-1.2.1/lib/rack/utils.rb:16:
|
||||
# warning: regexp match /.../n against to UTF-8 string
|
||||
# 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
|
||||
# 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
|
||||
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
||||
# exceptions and display an error page (just like when the app is running in production).
|
||||
# Typical scenarios where you want to do this is when you test your error pages.
|
||||
# There are two ways to allow Rails to rescue exceptions:
|
||||
#
|
||||
# 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/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)
|
||||
case page_name
|
||||
|
||||
when /the home\s?page/
|
||||
when /the home\s?page$/
|
||||
'/'
|
||||
when /login/
|
||||
new_admin_session_path
|
||||
@ -39,10 +39,10 @@ module NavigationHelpers
|
||||
|
||||
else
|
||||
begin
|
||||
page_name =~ /the (.*) page/
|
||||
page_name =~ /^the (.*) page$/
|
||||
path_components = $1.split(/\s+/)
|
||||
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" +
|
||||
"Now, go and add a mapping in #{__FILE__}"
|
||||
end
|
||||
@ -51,3 +51,58 @@ module NavigationHelpers
|
||||
end
|
||||
|
||||
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'
|
||||
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
|
||||
desc 'Alias for cucumber:ok'
|
||||
task :cucumber => 'cucumber:ok'
|
||||
@ -43,6 +49,8 @@ begin
|
||||
task :features => :cucumber do
|
||||
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
||||
end
|
||||
|
||||
task :stats => 'cucumber:statsetup'
|
||||
rescue LoadError
|
||||
desc 'cucumber rake task not available (cucumber not installed)'
|
||||
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