data_active 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -1
- data/data_active.gemspec +8 -6
- data/features/step_definitions/step_helper.rb +5 -4
- data/features/step_definitions/sync_books_with_xml.rb +11 -7
- data/features/support/book_generator.rb +29 -0
- data/features/support/factories/book.rb +6 -0
- data/features/support/factories/book_price.rb +8 -0
- data/features/support/factories/chapter.rb +7 -0
- data/features/support/factories/page.rb +7 -0
- data/features/support/fixtures/fresh/pages.yml +10 -10
- data/features/sync_database_with_xml.feature +2 -2
- data/features/sync_one_to_many.feature +0 -6
- data/features/sync_one_to_one.feature +1 -1
- data/lib/data_active.rb +8 -282
- data/lib/data_active/attribute.rb +12 -0
- data/lib/data_active/entity.rb +151 -0
- data/lib/data_active/parser.rb +159 -0
- data/lib/data_active/sax_document.rb +29 -0
- data/lib/data_active/version.rb +1 -1
- data/spec/entity_spec.rb +11 -0
- data/spec/fixtures/xml/ms_xml/books_fresh.xml +173 -0
- data/spec/fixtures/xml/rails_xml/books_fresh.xml +173 -0
- data/spec/parser_spec.rb +285 -0
- data/spec/sax_document_spec.rb +3 -0
- data/spec/spec_helper.rb +39 -0
- data/test_apps/book_store_rails_31x/config/application.rb +0 -32
- data/test_apps/book_store_rails_32x/.rspec +1 -0
- data/test_apps/book_store_rails_32x/.rvmrc +1 -1
- data/test_apps/book_store_rails_32x/Gemfile +12 -4
- data/test_apps/book_store_rails_32x/config/application.rb +0 -40
- metadata +63 -5
- data/features/step_definitions/web_steps.rb +0 -211
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'data_active'
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
# ## Mock Framework
|
14
|
+
#
|
15
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
16
|
+
#
|
17
|
+
# config.mock_with :mocha
|
18
|
+
# config.mock_with :flexmock
|
19
|
+
# config.mock_with :rr
|
20
|
+
|
21
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
22
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
23
|
+
|
24
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
25
|
+
# examples within a transaction, remove the following line or assign false
|
26
|
+
# instead of true.
|
27
|
+
config.use_transactional_fixtures = true
|
28
|
+
|
29
|
+
# If true, the base class of anonymous controllers will be inferred
|
30
|
+
# automatically. This will be the default behavior in future versions of
|
31
|
+
# rspec-rails.
|
32
|
+
config.infer_base_class_for_anonymous_controllers = false
|
33
|
+
|
34
|
+
# Run specs in random order to surface order dependencies. If you find an
|
35
|
+
# order dependency and want to debug it, you can fix the order by providing
|
36
|
+
# the seed, which is printed after each run.
|
37
|
+
# --seed 1234
|
38
|
+
config.order = "random"
|
39
|
+
end
|
@@ -3,46 +3,14 @@ require File.expand_path('../boot', __FILE__)
|
|
3
3
|
require 'rails/all'
|
4
4
|
|
5
5
|
if defined?(Bundler)
|
6
|
-
# If you precompile assets before deploying to production, use this line
|
7
6
|
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
8
|
-
# If you want your assets lazily compiled in production, use this line
|
9
|
-
# Bundler.require(:default, :assets, Rails.env)
|
10
7
|
end
|
11
8
|
|
12
9
|
module BookStore
|
13
10
|
class Application < Rails::Application
|
14
|
-
# Settings in config/environments/* take precedence over those specified here.
|
15
|
-
# Application configuration should go into files in config/initializers
|
16
|
-
# -- all .rb files in that directory are automatically loaded.
|
17
|
-
|
18
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
-
|
21
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
-
|
25
|
-
# Activate observers that should always be running.
|
26
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
-
|
28
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
-
|
32
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
-
# config.i18n.default_locale = :de
|
35
|
-
|
36
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
37
11
|
config.encoding = "utf-8"
|
38
|
-
|
39
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
40
12
|
config.filter_parameters += [:password]
|
41
|
-
|
42
|
-
# Enable the asset pipeline
|
43
13
|
config.assets.enabled = true
|
44
|
-
|
45
|
-
# Version of your assets, change this if you want to expire all your assets
|
46
14
|
config.assets.version = '1.0'
|
47
15
|
end
|
48
16
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -1 +1 @@
|
|
1
|
-
rvm ruby-1.9.3-
|
1
|
+
rvm ruby-1.9.3-p392@book_store_rails_32x --create
|
@@ -1,21 +1,29 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rails', '3.2.
|
3
|
+
gem 'rails', '3.2.11'
|
4
4
|
|
5
5
|
# Bundle edge Rails instead:
|
6
6
|
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
7
|
|
8
8
|
gem 'sqlite3'
|
9
|
-
gem 'data_active', '0.0.
|
9
|
+
gem 'data_active', '0.0.6'
|
10
|
+
gem 'nokogiri'
|
10
11
|
|
11
12
|
group :test do
|
12
13
|
gem 'cucumber'
|
13
|
-
gem 'cucumber-rails'
|
14
14
|
gem 'guard-cucumber'
|
15
15
|
gem 'growl_notify'
|
16
16
|
gem 'database_cleaner'
|
17
|
+
gem 'linecache19', '~> 0.5.13', :git => 'https://github.com/ucberkeley/linecache19.git'
|
18
|
+
gem 'ruby-debug-base19x', '0.11.30.pre11'
|
19
|
+
gem 'ruby-debug-ide', '0.4.17.beta16'
|
17
20
|
end
|
18
21
|
|
22
|
+
gem 'rspec-rails', '~> 2.0', :groups => [:test, :development]
|
23
|
+
gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false
|
24
|
+
gem 'factory_girl_rails'
|
25
|
+
|
26
|
+
|
19
27
|
|
20
28
|
# Gems used only for assets and not required
|
21
29
|
# in production environments by default.
|
@@ -44,4 +52,4 @@ gem 'jquery-rails'
|
|
44
52
|
# gem 'capistrano'
|
45
53
|
|
46
54
|
# To use debugger
|
47
|
-
#
|
55
|
+
#gem 'ruby-debug19', :require => 'ruby-debug'
|
@@ -11,49 +11,9 @@ end
|
|
11
11
|
|
12
12
|
module BookStore
|
13
13
|
class Application < Rails::Application
|
14
|
-
# Settings in config/environments/* take precedence over those specified here.
|
15
|
-
# Application configuration should go into files in config/initializers
|
16
|
-
# -- all .rb files in that directory are automatically loaded.
|
17
|
-
|
18
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
-
|
21
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
-
|
25
|
-
# Activate observers that should always be running.
|
26
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
-
|
28
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
-
|
32
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
-
# config.i18n.default_locale = :de
|
35
|
-
|
36
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
37
14
|
config.encoding = "utf-8"
|
38
|
-
|
39
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
40
15
|
config.filter_parameters += [:password]
|
41
|
-
|
42
|
-
# Use SQL instead of Active Record's schema dumper when creating the database.
|
43
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
44
|
-
# like if you have constraints or database-specific column types
|
45
|
-
# config.active_record.schema_format = :sql
|
46
|
-
|
47
|
-
# Enforce whitelist mode for mass assignment.
|
48
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
49
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
50
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
51
|
-
# config.active_record.whitelist_attributes = true
|
52
|
-
|
53
|
-
# Enable the asset pipeline
|
54
16
|
config.assets.enabled = true
|
55
|
-
|
56
|
-
# Version of your assets, change this if you want to expire all your assets
|
57
17
|
config.assets.version = '1.0'
|
58
18
|
end
|
59
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_active
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -59,6 +59,38 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
62
94
|
description: Data Active is an extension of ActiveRecord that provides features to
|
63
95
|
synchronise an ActiveRecord Model with a supplied XML document
|
64
96
|
email:
|
@@ -78,8 +110,12 @@ files:
|
|
78
110
|
- features/step_definitions/step_helper.rb
|
79
111
|
- features/step_definitions/sync_books_with_xml.rb
|
80
112
|
- features/step_definitions/update_database_with_xml.rb
|
81
|
-
- features/
|
113
|
+
- features/support/book_generator.rb
|
82
114
|
- features/support/env.rb
|
115
|
+
- features/support/factories/book.rb
|
116
|
+
- features/support/factories/book_price.rb
|
117
|
+
- features/support/factories/chapter.rb
|
118
|
+
- features/support/factories/page.rb
|
83
119
|
- features/support/fixtures/fresh/book_prices.yml
|
84
120
|
- features/support/fixtures/fresh/books.yml
|
85
121
|
- features/support/fixtures/fresh/chapters.yml
|
@@ -135,7 +171,17 @@ files:
|
|
135
171
|
- features/sync_one_to_one.feature
|
136
172
|
- features/update_database_with_xml.feature
|
137
173
|
- lib/data_active.rb
|
174
|
+
- lib/data_active/attribute.rb
|
175
|
+
- lib/data_active/entity.rb
|
176
|
+
- lib/data_active/parser.rb
|
177
|
+
- lib/data_active/sax_document.rb
|
138
178
|
- lib/data_active/version.rb
|
179
|
+
- spec/entity_spec.rb
|
180
|
+
- spec/fixtures/xml/ms_xml/books_fresh.xml
|
181
|
+
- spec/fixtures/xml/rails_xml/books_fresh.xml
|
182
|
+
- spec/parser_spec.rb
|
183
|
+
- spec/sax_document_spec.rb
|
184
|
+
- spec/spec_helper.rb
|
139
185
|
- test_apps/book_store_rails_31x/.gitignore
|
140
186
|
- test_apps/book_store_rails_31x/.rvmrc
|
141
187
|
- test_apps/book_store_rails_31x/Gemfile
|
@@ -197,6 +243,7 @@ files:
|
|
197
243
|
- test_apps/book_store_rails_31x/vendor/assets/stylesheets/.gitkeep
|
198
244
|
- test_apps/book_store_rails_31x/vendor/plugins/.gitkeep
|
199
245
|
- test_apps/book_store_rails_32x/.gitignore
|
246
|
+
- test_apps/book_store_rails_32x/.rspec
|
200
247
|
- test_apps/book_store_rails_32x/.rvmrc
|
201
248
|
- test_apps/book_store_rails_32x/Gemfile
|
202
249
|
- test_apps/book_store_rails_32x/README.rdoc
|
@@ -280,15 +327,19 @@ rubyforge_project: data_active
|
|
280
327
|
rubygems_version: 1.8.22
|
281
328
|
signing_key:
|
282
329
|
specification_version: 3
|
283
|
-
summary: data_active 0.0.
|
330
|
+
summary: data_active 0.0.7
|
284
331
|
test_files:
|
285
332
|
- features/remove_records_missing_in_xml.feature
|
286
333
|
- features/step_definitions/remove_records_missing_in_xml.rb
|
287
334
|
- features/step_definitions/step_helper.rb
|
288
335
|
- features/step_definitions/sync_books_with_xml.rb
|
289
336
|
- features/step_definitions/update_database_with_xml.rb
|
290
|
-
- features/
|
337
|
+
- features/support/book_generator.rb
|
291
338
|
- features/support/env.rb
|
339
|
+
- features/support/factories/book.rb
|
340
|
+
- features/support/factories/book_price.rb
|
341
|
+
- features/support/factories/chapter.rb
|
342
|
+
- features/support/factories/page.rb
|
292
343
|
- features/support/fixtures/fresh/book_prices.yml
|
293
344
|
- features/support/fixtures/fresh/books.yml
|
294
345
|
- features/support/fixtures/fresh/chapters.yml
|
@@ -343,6 +394,12 @@ test_files:
|
|
343
394
|
- features/sync_one_to_many.feature
|
344
395
|
- features/sync_one_to_one.feature
|
345
396
|
- features/update_database_with_xml.feature
|
397
|
+
- spec/entity_spec.rb
|
398
|
+
- spec/fixtures/xml/ms_xml/books_fresh.xml
|
399
|
+
- spec/fixtures/xml/rails_xml/books_fresh.xml
|
400
|
+
- spec/parser_spec.rb
|
401
|
+
- spec/sax_document_spec.rb
|
402
|
+
- spec/spec_helper.rb
|
346
403
|
- test_apps/book_store_rails_31x/.gitignore
|
347
404
|
- test_apps/book_store_rails_31x/.rvmrc
|
348
405
|
- test_apps/book_store_rails_31x/Gemfile
|
@@ -404,6 +461,7 @@ test_files:
|
|
404
461
|
- test_apps/book_store_rails_31x/vendor/assets/stylesheets/.gitkeep
|
405
462
|
- test_apps/book_store_rails_31x/vendor/plugins/.gitkeep
|
406
463
|
- test_apps/book_store_rails_32x/.gitignore
|
464
|
+
- test_apps/book_store_rails_32x/.rspec
|
407
465
|
- test_apps/book_store_rails_32x/.rvmrc
|
408
466
|
- test_apps/book_store_rails_32x/Gemfile
|
409
467
|
- test_apps/book_store_rails_32x/README.rdoc
|
@@ -1,211 +0,0 @@
|
|
1
|
-
# TL;DR: YOU SHOULD DELETE THIS FILE
|
2
|
-
#
|
3
|
-
# This file was generated by Cucumber-Rails and is only here to get you a head start
|
4
|
-
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
|
5
|
-
# visit pages, interact with widgets and make assertions about page content.
|
6
|
-
#
|
7
|
-
# If you use these step definitions as basis for your features you will quickly end up
|
8
|
-
# with features that are:
|
9
|
-
#
|
10
|
-
# * Hard to maintain
|
11
|
-
# * Verbose to read
|
12
|
-
#
|
13
|
-
# A much better approach is to write your own higher level step definitions, following
|
14
|
-
# the advice in the following blog posts:
|
15
|
-
#
|
16
|
-
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
17
|
-
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
18
|
-
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
require 'uri'
|
23
|
-
require 'cgi'
|
24
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
25
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
26
|
-
|
27
|
-
module WithinHelpers
|
28
|
-
def with_scope(locator)
|
29
|
-
locator ? within(*selector_for(locator)) { yield } : yield
|
30
|
-
end
|
31
|
-
end
|
32
|
-
World(WithinHelpers)
|
33
|
-
|
34
|
-
# Single-line step scoper
|
35
|
-
When /^(.*) within (.*[^:])$/ do |step, parent|
|
36
|
-
with_scope(parent) { When step }
|
37
|
-
end
|
38
|
-
|
39
|
-
# Multi-line step scoper
|
40
|
-
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
|
41
|
-
with_scope(parent) { When "#{step}:", table_or_string }
|
42
|
-
end
|
43
|
-
|
44
|
-
Given /^(?:|I )am on (.+)$/ do |page_name|
|
45
|
-
visit path_to(page_name)
|
46
|
-
end
|
47
|
-
|
48
|
-
When /^(?:|I )go to (.+)$/ do |page_name|
|
49
|
-
visit path_to(page_name)
|
50
|
-
end
|
51
|
-
|
52
|
-
When /^(?:|I )press "([^"]*)"$/ do |button|
|
53
|
-
click_button(button)
|
54
|
-
end
|
55
|
-
|
56
|
-
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
57
|
-
click_link(link)
|
58
|
-
end
|
59
|
-
|
60
|
-
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
61
|
-
fill_in(field, :with => value)
|
62
|
-
end
|
63
|
-
|
64
|
-
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
65
|
-
fill_in(field, :with => value)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Use this to fill in an entire form with data from a table. Example:
|
69
|
-
#
|
70
|
-
# When I fill in the following:
|
71
|
-
# | Account Number | 5002 |
|
72
|
-
# | Expiry date | 2009-11-01 |
|
73
|
-
# | Note | Nice guy |
|
74
|
-
# | Wants Email? | |
|
75
|
-
#
|
76
|
-
# TODO: Add support for checkbox, select og option
|
77
|
-
# based on naming conventions.
|
78
|
-
#
|
79
|
-
When /^(?:|I )fill in the following:$/ do |fields|
|
80
|
-
fields.rows_hash.each do |name, value|
|
81
|
-
When %{I fill in "#{name}" with "#{value}"}
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
86
|
-
select(value, :from => field)
|
87
|
-
end
|
88
|
-
|
89
|
-
When /^(?:|I )check "([^"]*)"$/ do |field|
|
90
|
-
check(field)
|
91
|
-
end
|
92
|
-
|
93
|
-
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
94
|
-
uncheck(field)
|
95
|
-
end
|
96
|
-
|
97
|
-
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
98
|
-
choose(field)
|
99
|
-
end
|
100
|
-
|
101
|
-
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
102
|
-
attach_file(field, File.expand_path(path))
|
103
|
-
end
|
104
|
-
|
105
|
-
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
106
|
-
if page.respond_to? :should
|
107
|
-
page.should have_content(text)
|
108
|
-
else
|
109
|
-
assert page.has_content?(text)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
114
|
-
regexp = Regexp.new(regexp)
|
115
|
-
|
116
|
-
if page.respond_to? :should
|
117
|
-
page.should have_xpath('//*', :text => regexp)
|
118
|
-
else
|
119
|
-
assert page.has_xpath?('//*', :text => regexp)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
124
|
-
if page.respond_to? :should
|
125
|
-
page.should have_no_content(text)
|
126
|
-
else
|
127
|
-
assert page.has_no_content?(text)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
132
|
-
regexp = Regexp.new(regexp)
|
133
|
-
|
134
|
-
if page.respond_to? :should
|
135
|
-
page.should have_no_xpath('//*', :text => regexp)
|
136
|
-
else
|
137
|
-
assert page.has_no_xpath?('//*', :text => regexp)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
142
|
-
with_scope(parent) do
|
143
|
-
field = find_field(field)
|
144
|
-
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
145
|
-
if field_value.respond_to? :should
|
146
|
-
field_value.should =~ /#{value}/
|
147
|
-
else
|
148
|
-
assert_match(/#{value}/, field_value)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
154
|
-
with_scope(parent) do
|
155
|
-
field = find_field(field)
|
156
|
-
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
157
|
-
if field_value.respond_to? :should_not
|
158
|
-
field_value.should_not =~ /#{value}/
|
159
|
-
else
|
160
|
-
assert_no_match(/#{value}/, field_value)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
166
|
-
with_scope(parent) do
|
167
|
-
field_checked = find_field(label)['checked']
|
168
|
-
if field_checked.respond_to? :should
|
169
|
-
field_checked.should be_true
|
170
|
-
else
|
171
|
-
assert field_checked
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
177
|
-
with_scope(parent) do
|
178
|
-
field_checked = find_field(label)['checked']
|
179
|
-
if field_checked.respond_to? :should
|
180
|
-
field_checked.should be_false
|
181
|
-
else
|
182
|
-
assert !field_checked
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
188
|
-
current_path = URI.parse(current_url).path
|
189
|
-
if current_path.respond_to? :should
|
190
|
-
current_path.should == path_to(page_name)
|
191
|
-
else
|
192
|
-
assert_equal path_to(page_name), current_path
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
197
|
-
query = URI.parse(current_url).query
|
198
|
-
actual_params = query ? CGI.parse(query) : {}
|
199
|
-
expected_params = {}
|
200
|
-
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
201
|
-
|
202
|
-
if actual_params.respond_to? :should
|
203
|
-
actual_params.should == expected_params
|
204
|
-
else
|
205
|
-
assert_equal expected_params, actual_params
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
Then /^show me the page$/ do
|
210
|
-
save_and_open_page
|
211
|
-
end
|