echo_base 0.1.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +2 -2
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.rdoc +32 -32
- data/Rakefile +51 -40
- data/bin/echo_base +7 -0
- data/echo_base.gemspec +150 -134
- data/lib/echo_base.rb +122 -0
- data/lib/{generators/echo_base/templates → templates}/Capfile +0 -0
- data/lib/{generators/echo_base/templates → templates}/Gemfile +8 -6
- data/lib/{generators/echo_base/templates → templates}/app/controllers/application_controller.rb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/controllers/sessions_controller.rb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/controllers/users_controller.rb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/models/authorization.rb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/models/user.rb +0 -0
- data/lib/{generators/echo_base/templates/application.html.erb → templates/app/views/layouts/application.html.erb.tt} +4 -3
- data/lib/{generators/echo_base/templates → templates}/app/views/shared/_js.html.erb +2 -3
- data/lib/{generators/echo_base/templates → templates}/app/views/users/_form.html.erb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/views/users/_sidebar.html.erb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/views/users/edit.html.erb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/views/users/index.html.erb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/views/users/new.html.erb +0 -0
- data/lib/{generators/echo_base/templates → templates}/app/views/users/show.html.erb +0 -0
- data/lib/{generators/echo_base/templates → templates}/config/deploy.rb +0 -0
- data/lib/{generators/echo_base/templates → templates}/config/initializers/hoptoad.rb +0 -1
- data/lib/{generators/echo_base/templates → templates}/config/initializers/omniauth.rb +0 -0
- data/lib/{generators/echo_base/templates/public/favicon.ico → templates/config/newrelic.yml.example} +0 -0
- data/lib/{generators/echo_base/templates → templates}/config/omniauth.yml +0 -0
- data/lib/templates/config/omniauth.yml.example +62 -0
- data/lib/{generators/echo_base/templates → templates}/db/migrate/20101008210657_create_authorizations.rb +0 -0
- data/lib/{generators/echo_base/templates → templates}/db/migrate/20101009192412_create_users.rb +0 -0
- data/lib/templates/gitignore +17 -0
- data/lib/{generators/echo_base/templates → templates}/public/404.html +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/422.html +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/500.html +0 -0
- data/lib/{generators/echo_base/templates/public/stylesheets/.gitkeep → templates/public/favicon.ico} +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/arrow.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/avatar.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/boxbar-background.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/breadcrumb.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/button-background-active.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/button-background.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/about +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/anchor-hover.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/anchor.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/cross-hover.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/cross.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/download-hover.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/download.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/edit-hover.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/edit.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/export-hover.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/export.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/show-hover.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/24/show.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/add.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/application_edit.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/calendar-hover.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/calendar.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/cross.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/delete.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/download.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/edit.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/key.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/pdf.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/search.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/see-less.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/see-more.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/send-mail.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/show.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/source +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/tick.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/icons/upload.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/logo.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/menubar-background.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/search-button.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/session/account.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/session/config.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/session/home.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/session/logout.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/images/web-app-theme/tipsy.gif +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/javascripts/application.js +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/javascripts/dd_belatedpng.js +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/javascripts/jquery-1.4.2.min.js +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/javascripts/modernizr-1.5.min.js +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/javascripts/rails.js +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/robots.txt +0 -0
- data/lib/templates/public/stylesheets/.gitkeep +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/handheld.css +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/style.css +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/base.css +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/override.css +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/themes/default/images/arrow.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/themes/default/images/boxbar-background.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/themes/default/images/button-background-active.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/themes/default/images/button-background.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/themes/default/images/menubar-background.png +0 -0
- data/lib/{generators/echo_base/templates → templates}/public/stylesheets/web-app-theme/themes/default/style.css +0 -0
- data/spec/echo_base_spec.rb +77 -0
- data/spec/spec_helper.rb +12 -0
- metadata +314 -138
- data/.gitignore +0 -21
- data/VERSION +0 -1
- data/lib/generators/echo_base/USAGE +0 -5
- data/lib/generators/echo_base/echo_base_generator.rb +0 -51
- data/lib/generators/echo_base/templates/.infinity_test +0 -25
- data/lib/generators/echo_base/templates/.rspec +0 -1
- data/lib/generators/echo_base/templates/.rvmrc +0 -1
- data/lib/generators/echo_base/templates/app/helpers/application_helper.rb +0 -2
- data/lib/generators/echo_base/templates/app/helpers/sessions_helper.rb +0 -2
- data/lib/generators/echo_base/templates/app/helpers/users_helper.rb +0 -2
- data/lib/generators/echo_base/templates/autotest/discover.rb +0 -2
- data/lib/generators/echo_base/templates/config/cucumber.yml +0 -8
- data/lib/generators/echo_base/templates/config/newrelic.yml +0 -1
- data/lib/generators/echo_base/templates/features/manage_authentications.feature +0 -45
- data/lib/generators/echo_base/templates/features/manage_users.feature +0 -45
- data/lib/generators/echo_base/templates/features/step_definitions/authentication_steps.rb +0 -14
- data/lib/generators/echo_base/templates/features/step_definitions/users_steps.rb +0 -14
- data/lib/generators/echo_base/templates/features/step_definitions/web_steps.rb +0 -219
- data/lib/generators/echo_base/templates/features/support/env.rb +0 -57
- data/lib/generators/echo_base/templates/features/support/paths.rb +0 -39
- data/lib/generators/echo_base/templates/spec/controllers/sessions_controller_spec.rb +0 -5
- data/lib/generators/echo_base/templates/spec/controllers/users_controller_spec.rb +0 -125
- data/lib/generators/echo_base/templates/spec/helpers/users_helper_spec.rb +0 -15
- data/lib/generators/echo_base/templates/spec/models/authorization_spec.rb +0 -5
- data/lib/generators/echo_base/templates/spec/models/user_spec.rb +0 -5
- data/lib/generators/echo_base/templates/spec/routing/users_routing_spec.rb +0 -35
- data/lib/generators/echo_base/templates/spec/spec_helper.rb +0 -16
- data/lib/generators/echo_base/templates/spec/views/users/edit.html.erb_spec.rb +0 -27
- data/lib/generators/echo_base/templates/spec/views/users/index.html.erb_spec.rb +0 -36
- data/lib/generators/echo_base/templates/spec/views/users/new.html.erb_spec.rb +0 -27
- data/lib/generators/echo_base/templates/spec/views/users/show.html.erb_spec.rb +0 -27
- data/test/helper.rb +0 -10
- data/test/test_echo_base.rb +0 -7
data/.gitignore
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.3
|
@@ -1,51 +0,0 @@
|
|
1
|
-
class EchoBaseGenerator < Rails::Generators::NamedBase
|
2
|
-
source_root File.expand_path('../templates', __FILE__)
|
3
|
-
argument :app_name, :type => :string, :default => "Echo Base"
|
4
|
-
def config
|
5
|
-
directory "config"
|
6
|
-
end
|
7
|
-
|
8
|
-
def routes
|
9
|
-
route("resources :users")
|
10
|
-
route("match '/auth/:provider/callback', :to => 'sessions#create'")
|
11
|
-
route("root :to => 'users#index'")
|
12
|
-
end
|
13
|
-
|
14
|
-
def migrations
|
15
|
-
directory "db"
|
16
|
-
end
|
17
|
-
|
18
|
-
def gems
|
19
|
-
copy_file "Gemfile"
|
20
|
-
end
|
21
|
-
|
22
|
-
def capistrano
|
23
|
-
copy_file "Capfile"
|
24
|
-
end
|
25
|
-
|
26
|
-
def public_folder
|
27
|
-
directory "public"
|
28
|
-
remove_file "public/index.html"
|
29
|
-
remove_file "public/images/rails.png"
|
30
|
-
end
|
31
|
-
|
32
|
-
def rspec
|
33
|
-
directory "spec"
|
34
|
-
directory "autotest"
|
35
|
-
copy_file ".infinity_test"
|
36
|
-
copy_file ".rspec"
|
37
|
-
end
|
38
|
-
|
39
|
-
def cucumber
|
40
|
-
directory "features"
|
41
|
-
end
|
42
|
-
|
43
|
-
def rvmrc
|
44
|
-
copy_file ".rvmrc"
|
45
|
-
end
|
46
|
-
|
47
|
-
def users
|
48
|
-
directory "app"
|
49
|
-
template "application.html.erb", "app/views/layouts/application.html.erb"
|
50
|
-
end
|
51
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
infinity_test do
|
2
|
-
|
3
|
-
notifications :growl do
|
4
|
-
show_images :mode => :rails
|
5
|
-
end
|
6
|
-
|
7
|
-
use :rubies => %w(1.8.7 1.9.2 ree), :gemset => 'echo_base', :test_framework => :rspec
|
8
|
-
|
9
|
-
before(:each_ruby) do |environment|
|
10
|
-
#...
|
11
|
-
end
|
12
|
-
|
13
|
-
after(:each_ruby) do |environment|
|
14
|
-
#...
|
15
|
-
end
|
16
|
-
|
17
|
-
before_run do
|
18
|
-
clear :terminal
|
19
|
-
end
|
20
|
-
|
21
|
-
after_run do
|
22
|
-
#... some code
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
--colour
|
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 1.9.2@echo_base
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
-
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
-
std_opts = "--format pretty --strict --tags ~@wip"
|
5
|
-
%>
|
6
|
-
default: <%= std_opts %> features
|
7
|
-
wip: --tags @wip:3 --wip features
|
8
|
-
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
@@ -1 +0,0 @@
|
|
1
|
-
#
|
@@ -1,45 +0,0 @@
|
|
1
|
-
Feature: Manage authentications
|
2
|
-
In order to [goal]
|
3
|
-
[stakeholder]
|
4
|
-
wants [behaviour]
|
5
|
-
|
6
|
-
Scenario: Register new authentication
|
7
|
-
Given I am on the new authentication page
|
8
|
-
And I press "Create"
|
9
|
-
|
10
|
-
# Rails generates Delete links that use Javascript to pop up a confirmation
|
11
|
-
# dialog and then do a HTTP POST request (emulated DELETE request).
|
12
|
-
#
|
13
|
-
# Capybara must use Culerity/Celerity or Selenium2 (webdriver) when pages rely
|
14
|
-
# on Javascript events. Only Culerity/Celerity supports clicking on confirmation
|
15
|
-
# dialogs.
|
16
|
-
#
|
17
|
-
# Since Culerity/Celerity and Selenium2 has some overhead, Cucumber-Rails will
|
18
|
-
# detect the presence of Javascript behind Delete links and issue a DELETE request
|
19
|
-
# instead of a GET request.
|
20
|
-
#
|
21
|
-
# You can turn this emulation off by tagging your scenario with @no-js-emulation.
|
22
|
-
# Turning on browser testing with @selenium, @culerity, @celerity or @javascript
|
23
|
-
# will also turn off the emulation. (See the Capybara documentation for
|
24
|
-
# details about those tags). If any of the browser tags are present, Cucumber-Rails
|
25
|
-
# will also turn off transactions and clean the database with DatabaseCleaner
|
26
|
-
# after the scenario has finished. This is to prevent data from leaking into
|
27
|
-
# the next scenario.
|
28
|
-
#
|
29
|
-
# Another way to avoid Cucumber-Rails' javascript emulation without using any
|
30
|
-
# of the tags above is to modify your views to use <button> instead. You can
|
31
|
-
# see how in http://github.com/jnicklas/capybara/issues#issue/12
|
32
|
-
#
|
33
|
-
Scenario: Delete authentication
|
34
|
-
Given the following authentications:
|
35
|
-
||
|
36
|
-
||
|
37
|
-
||
|
38
|
-
||
|
39
|
-
||
|
40
|
-
When I delete the 3rd authentication
|
41
|
-
Then I should see the following authentications:
|
42
|
-
||
|
43
|
-
||
|
44
|
-
||
|
45
|
-
||
|
@@ -1,45 +0,0 @@
|
|
1
|
-
Feature: Manage users
|
2
|
-
In order to [goal]
|
3
|
-
[stakeholder]
|
4
|
-
wants [behaviour]
|
5
|
-
|
6
|
-
Scenario: Register new users
|
7
|
-
Given I am on the new user page
|
8
|
-
And I press "Create"
|
9
|
-
|
10
|
-
# Rails generates Delete links that use Javascript to pop up a confirmation
|
11
|
-
# dialog and then do a HTTP POST request (emulated DELETE request).
|
12
|
-
#
|
13
|
-
# Capybara must use Culerity/Celerity or Selenium2 (webdriver) when pages rely
|
14
|
-
# on Javascript events. Only Culerity/Celerity supports clicking on confirmation
|
15
|
-
# dialogs.
|
16
|
-
#
|
17
|
-
# Since Culerity/Celerity and Selenium2 has some overhead, Cucumber-Rails will
|
18
|
-
# detect the presence of Javascript behind Delete links and issue a DELETE request
|
19
|
-
# instead of a GET request.
|
20
|
-
#
|
21
|
-
# You can turn this emulation off by tagging your scenario with @no-js-emulation.
|
22
|
-
# Turning on browser testing with @selenium, @culerity, @celerity or @javascript
|
23
|
-
# will also turn off the emulation. (See the Capybara documentation for
|
24
|
-
# details about those tags). If any of the browser tags are present, Cucumber-Rails
|
25
|
-
# will also turn off transactions and clean the database with DatabaseCleaner
|
26
|
-
# after the scenario has finished. This is to prevent data from leaking into
|
27
|
-
# the next scenario.
|
28
|
-
#
|
29
|
-
# Another way to avoid Cucumber-Rails' javascript emulation without using any
|
30
|
-
# of the tags above is to modify your views to use <button> instead. You can
|
31
|
-
# see how in http://github.com/jnicklas/capybara/issues#issue/12
|
32
|
-
#
|
33
|
-
Scenario: Delete users
|
34
|
-
Given the following users:
|
35
|
-
||
|
36
|
-
||
|
37
|
-
||
|
38
|
-
||
|
39
|
-
||
|
40
|
-
When I delete the 3rd users
|
41
|
-
Then I should see the following users:
|
42
|
-
||
|
43
|
-
||
|
44
|
-
||
|
45
|
-
||
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Given /^the following authentications:$/ do |authentications|
|
2
|
-
Authentication.create!(authentications.hashes)
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I delete the (\d+)(?:st|nd|rd|th) authentication$/ do |pos|
|
6
|
-
visit authentications_path
|
7
|
-
within("table tr:nth-child(#{pos.to_i+1})") do
|
8
|
-
click_link "Destroy"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
Then /^I should see the following authentications:$/ do |expected_authentications_table|
|
13
|
-
expected_authentications_table.diff!(tableish('table tr', 'td,th'))
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Given /^the following users:$/ do |users|
|
2
|
-
Users.create!(users.hashes)
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I delete the (\d+)(?:st|nd|rd|th) users$/ do |pos|
|
6
|
-
visit users_path
|
7
|
-
within("table tr:nth-child(#{pos.to_i+1})") do
|
8
|
-
click_link "Destroy"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
Then /^I should see the following users:$/ do |expected_users_table|
|
13
|
-
expected_users_table.diff!(tableish('table tr', 'td,th'))
|
14
|
-
end
|
@@ -1,219 +0,0 @@
|
|
1
|
-
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
-
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
-
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
-
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
-
# files.
|
6
|
-
|
7
|
-
|
8
|
-
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
|