workarea-testing 3.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +52 -0
  3. data/README.md +19 -0
  4. data/app/assets/javascripts/workarea/admin/spec_helper.js +1 -0
  5. data/app/assets/javascripts/workarea/core/feature_test_helper.js +15 -0
  6. data/app/assets/javascripts/workarea/core/spec_helper.js +45 -0
  7. data/app/assets/javascripts/workarea/storefront/spec_helper.js +2 -0
  8. data/app/assets/stylesheets/workarea/admin/_feature_test_helper.scss +16 -0
  9. data/app/assets/stylesheets/workarea/core/_feature_test_helper.scss +8 -0
  10. data/lib/workarea/admin/integration_test.rb +15 -0
  11. data/lib/workarea/core/discount_condition_tests.rb +100 -0
  12. data/lib/workarea/core/featured_products_test.rb +30 -0
  13. data/lib/workarea/core/navigable_test.rb +68 -0
  14. data/lib/workarea/generator_test.rb +5 -0
  15. data/lib/workarea/integration_test.rb +45 -0
  16. data/lib/workarea/performance_test.rb +135 -0
  17. data/lib/workarea/storefront/breakpoint_helpers.rb +27 -0
  18. data/lib/workarea/storefront/catalog_customization_test_class.rb +28 -0
  19. data/lib/workarea/storefront/integration_test.rb +82 -0
  20. data/lib/workarea/storefront/pagination_view_model_test.rb +56 -0
  21. data/lib/workarea/storefront/product_browsing_view_model_test.rb +38 -0
  22. data/lib/workarea/storefront/system_test.rb +142 -0
  23. data/lib/workarea/system_test.rb +161 -0
  24. data/lib/workarea/test_case.rb +197 -0
  25. data/lib/workarea/test_help.rb +67 -0
  26. data/lib/workarea/testing/cassette_persister.rb +40 -0
  27. data/lib/workarea/testing/custom_capybara_matchers.rb +18 -0
  28. data/lib/workarea/testing/decoration_reporter.rb +37 -0
  29. data/lib/workarea/testing/deferred_garbage_collection.rb +21 -0
  30. data/lib/workarea/testing/elasticsearch_response.json +1 -0
  31. data/lib/workarea/testing/engine.rb +6 -0
  32. data/lib/workarea/testing/example_document.pdf +0 -0
  33. data/lib/workarea/testing/factories/bulk_action.rb +17 -0
  34. data/lib/workarea/testing/factories/catalog.rb +66 -0
  35. data/lib/workarea/testing/factories/comment.rb +12 -0
  36. data/lib/workarea/testing/factories/content.rb +38 -0
  37. data/lib/workarea/testing/factories/data_file.rb +21 -0
  38. data/lib/workarea/testing/factories/fulfillment.rb +21 -0
  39. data/lib/workarea/testing/factories/insights.rb +32 -0
  40. data/lib/workarea/testing/factories/metrics.rb +25 -0
  41. data/lib/workarea/testing/factories/navigation.rb +30 -0
  42. data/lib/workarea/testing/factories/order.rb +77 -0
  43. data/lib/workarea/testing/factories/payment.rb +37 -0
  44. data/lib/workarea/testing/factories/performance/catalog.rb +92 -0
  45. data/lib/workarea/testing/factories/pricing.rb +59 -0
  46. data/lib/workarea/testing/factories/recommendation.rb +17 -0
  47. data/lib/workarea/testing/factories/search.rb +72 -0
  48. data/lib/workarea/testing/factories/user.rb +24 -0
  49. data/lib/workarea/testing/factories.rb +146 -0
  50. data/lib/workarea/testing/factory_configuration.rb +90 -0
  51. data/lib/workarea/testing/indexes.rb +22 -0
  52. data/lib/workarea/testing/locale_routing_fixes.rb +33 -0
  53. data/lib/workarea/testing/product_image.jpg +0 -0
  54. data/lib/workarea/testing/teaspoon.rb +186 -0
  55. data/lib/workarea/testing/user_avatar.jpg +0 -0
  56. data/lib/workarea/testing/warning_suppressor.rb +59 -0
  57. data/lib/workarea/view_test.rb +40 -0
  58. data/workarea-testing.gemspec +29 -0
  59. metadata +240 -0
@@ -0,0 +1,146 @@
1
+ module Workarea
2
+ module Factories
3
+ #
4
+ # Factory method module registration
5
+ #
6
+ #
7
+
8
+ mattr_accessor :plugins, :included_in
9
+ self.plugins ||= []
10
+ self.included_in ||= []
11
+
12
+ def self.add(mod)
13
+ self.plugins << mod
14
+ included_in.each { |c| plugins.each { |p| c.include p } }
15
+ end
16
+
17
+ def self.included(mod)
18
+ included_in << mod
19
+ plugins.each { |p| mod.send(:include, p) }
20
+ end
21
+
22
+ def self.require_factories
23
+ core_factories = Workarea::Testing::Engine
24
+ .root
25
+ .join('lib', 'workarea', 'testing', 'factories', '**', '*.rb')
26
+
27
+ Dir[core_factories].each do |factory_file|
28
+ require factory_file
29
+ end
30
+
31
+ Workarea::Plugin.installed.each do |plugin|
32
+ Dir[plugin.root.join('test', 'factories', '**', '*.rb')].each do |factory_file|
33
+ require factory_file
34
+ end
35
+ end
36
+ end
37
+
38
+ def factory_defaults_config
39
+ Workarea.config.testing_factory_defaults
40
+ end
41
+
42
+ def factory_defaults(factory)
43
+ default = factory_defaults_config.send(factory)
44
+ default.respond_to?(:call) ? self.instance_eval(&default) : default
45
+ end
46
+
47
+ #
48
+ # Misc factory methods
49
+ #
50
+ #
51
+
52
+ mattr_accessor :email_signup_count, :user_count, :shipping_service_count, :tax_categories_count
53
+ self.email_signup_count = 0
54
+ self.user_count = 0
55
+ self.shipping_service_count = 0
56
+ self.tax_categories_count = 0
57
+
58
+ def create_release(overrides = {})
59
+ attributes = factory_defaults(:release).merge(overrides)
60
+ Release.create!(attributes)
61
+ end
62
+
63
+ def create_email_signup(overrides = {})
64
+ attributes = factory_defaults(:email_signup).merge(overrides)
65
+ Email::Signup.create!(attributes).tap do
66
+ Factories.email_signup_count += 1
67
+ end
68
+ end
69
+
70
+ def create_shipping(overrides = {})
71
+ attributes = factory_defaults(:shipping).merge(overrides)
72
+ Shipping.create!(attributes)
73
+ end
74
+
75
+ def create_shipping_service(overrides = {})
76
+ attributes = factory_defaults(:shipping_service).merge(overrides)
77
+
78
+ Shipping::Service.new(attributes.except(:rates)).tap do |service|
79
+ if attributes[:rates].present?
80
+ attributes[:rates].each do |attrs|
81
+ service.rates.build(attrs)
82
+ end
83
+ end
84
+
85
+ service.save!
86
+ Factories.shipping_service_count += 1
87
+ end
88
+ end
89
+
90
+ def create_tax_category(overrides = {})
91
+ attributes = factory_defaults(:tax_category).merge(overrides)
92
+
93
+ Tax::Category.new(attributes.except(:rates)).tap do |category|
94
+ if attributes[:rates].present?
95
+ attributes[:rates].each do |attrs|
96
+ category.rates.build(attrs)
97
+ end
98
+ end
99
+
100
+ category.save!
101
+ category.rates.each(&:save!)
102
+
103
+ Factories.tax_categories_count += 1
104
+ end
105
+ end
106
+
107
+ def create_inventory(overrides = {})
108
+ attributes = factory_defaults(:inventory).merge(overrides)
109
+ Inventory::Sku.new(attributes).tap do |sku|
110
+ sku.id = attributes[:id] if attributes[:id].present?
111
+ sku.save!
112
+ end
113
+ end
114
+
115
+ def create_help_article(overrides = {})
116
+ attributes = factory_defaults(:help_article).merge(overrides)
117
+ Help::Article.create!(attributes)
118
+ end
119
+
120
+ def create_shipping_sku(overrides = {})
121
+ attributes = factory_defaults(:shipping_sku).merge(overrides)
122
+ Shipping::Sku.create!(attributes)
123
+ end
124
+
125
+ def create_audit_log_entry(overrides = {})
126
+ attributes = factory_defaults(:audit_log_entry).merge(overrides)
127
+ Mongoid::AuditLog::Entry.create!(attributes)
128
+ end
129
+
130
+ def create_admin_visit(overrides = {})
131
+ attributes = factory_defaults(:admin_visit).merge(overrides)
132
+ Workarea::User::AdminVisit.create!(attributes)
133
+ end
134
+
135
+ def create_admin_bookmark(overrides = {})
136
+ attributes = factory_defaults(:admin_bookmark).merge(overrides)
137
+ Workarea::User::AdminBookmark.create!(attributes)
138
+ end
139
+
140
+ def create_tempfile(content, name: 'foo', extension: 'txt', encoding: nil)
141
+ file = Tempfile.new([name, ".#{extension}"], encoding: encoding)
142
+ file.write(content)
143
+ file.tap(&:close)
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,90 @@
1
+ config = Workarea::Configuration.config
2
+ config.testing_factory_defaults = ActiveSupport::Configurable::Configuration.new
3
+
4
+ defaults = config.testing_factory_defaults
5
+
6
+ # factories.rb
7
+ defaults.admin_visit = { name: 'Dashboard', path: '/' }
8
+ defaults.admin_bookmark = { name: 'Dashboard', path: '/' }
9
+ defaults.audit_log_entry = Proc.new { { modifier: create_user, audited: create_page } }
10
+ defaults.email_signup = Proc.new { { email: "email-signup-#{email_signup_count}@workarea.com" } }
11
+ defaults.help_article = { name: 'Product Editing', category: 'Howto' }
12
+ defaults.inventory = { id: 'SKU', policy: 'standard', available: 5 }
13
+ defaults.release = { name: 'Content Release' }
14
+ defaults.shipping = { order_id: '1234' }
15
+ defaults.shipping_sku = { id: 'SKU1', weight: 2.3 }
16
+ defaults.shipping_service = Proc.new { { name: "Test #{shipping_service_count}", rates: [{ price: 1.to_m }] } }
17
+ defaults.tax_category = Proc.new { { name: 'Clothing', code: tax_categories_count, rates: [{ percentage: 0.06, country: 'US', region: 'PA' }] } }
18
+
19
+ # factories/bulk_action.rb
20
+ defaults.bulk_action_product_edit = Proc.new { { query_id: Workarea::Search::AdminProducts.new.to_global_id } }
21
+ defaults.sequential_product_edit = { ids: %w(1 2 3) }
22
+
23
+ # factories/catalog.rb
24
+ defaults.category = { name: 'Test Category' }
25
+ defaults.product = { name: 'Test Product', details: { 'Material' => 'Cotton', 'Style' => '12345' }, filters: { 'Material' => 'Cotton', 'Style' => '12345' }, variants: [{ sku: 'SKU', regular: 5.00 }] }
26
+ defaults.create_product_placeholder_image = Proc.new { { image: product_image_file } }
27
+
28
+ # factories/comment.rb
29
+ defaults.comment = { author_id: '1234', body: 'foo bar' }
30
+
31
+ # factories/content.rb
32
+ defaults.asset = Proc.new { { name: 'Test Asset', tag_list: 'test', file: product_image_file } }
33
+ defaults.content = { name: 'Test content' }
34
+ defaults.page = { name: 'Test Page' }
35
+
36
+ # factories/data_file.rb
37
+ defaults.import = { model_type: Workarea::Catalog::Product }
38
+ defaults.export = Proc.new { { model_type: Workarea::Catalog::Product, query_id: Workarea::Search::AdminProducts.new.to_global_id } }
39
+
40
+ # factories/insights.rb
41
+ defaults.insights_product_by_week = Proc.new { { product_id: "foo-#{product_by_week_count}", reporting_on: Time.current } }
42
+ defaults.insights_search_by_week = Proc.new { { query_id: "foo#{search_by_week_count}", reporting_on: Time.current } }
43
+ defaults.hot_products = Proc.new { { results: Array.new(3) { create_product_by_week.as_document } } }
44
+ defaults.cold_products = Proc.new { { results: Array.new(3) { create_product_by_week.as_document } } }
45
+ defaults.top_products = Proc.new { { results: Array.new(3) { create_product_by_week.as_document } } }
46
+ defaults.trending_products = Proc.new { { results: Array.new(3) { create_product_by_week.as_document } } }
47
+ defaults.top_discounts = Proc.new { { results: Array.new(3) { { discount_id: rand(1000) } } } }
48
+
49
+ # factories/navigation.rb
50
+ defaults.taxon = { name: 'Test Taxon' }
51
+ defaults.redirect = { path: '/faq', destination: '/pages/faq' }
52
+ defaults.menu = Proc.new { { taxon: create_taxon } }
53
+
54
+ # factories/order.rb
55
+ defaults.order = { email: 'bcrouse@workarea.com' }
56
+ defaults.placed_order = Proc.new { { id: '1234', email: 'bcrouse-new@workarea.com', placed_at: Time.current } }
57
+ defaults.shipping_address = { first_name: 'Ben', last_name: 'Crouse', street: '22 S. 3rd St.', street_2: 'Second Floor', city: 'Philadelphia', region: 'PA', postal_code: '19106', country: 'US' }
58
+ defaults.billing_address = { first_name: 'Ben', last_name: 'Crouse', street: '22 S. 3rd St.', street_2: 'Second Floor', city: 'Philadelphia', region: 'PA', postal_code: '19106', country: 'US' }
59
+ defaults.checkout_payment = { payment: 'new_card', credit_card: { number: '1', month: '1', year: Time.current.year + 1, cvv: '999' } }
60
+
61
+ # factories/payment.rb
62
+ defaults.payment = {}
63
+ defaults.payment_profile = { email: 'user@workarea.com', reference: '1243' }
64
+ defaults.saved_credit_card = Proc.new { { profile: Workarea::Payment::Profile.lookup(Workarea::PaymentReference.new(create_user)), first_name: 'Ben', last_name: 'Crouse', number: '1', month: 1, year: Time.current.year + 1, cvv: '999' } }
65
+ defaults.transaction = { action: 'authorize', amount: 5.to_m }
66
+
67
+ # factories/pricing.rb
68
+ defaults.buy_some_get_some_discount = { name: 'Test Discount', purchase_quantity: 1, apply_quantity: 1, percent_off: 100 }
69
+ defaults.category_discount = { name: 'Test Discount', amount_type: 'percent', amount: 50, category_ids: %w(1 2 3) }
70
+ defaults.code_list = { name: 'Test Code List', count: 2 }
71
+ defaults.free_gift_discount = { name: 'Test Discount', sku: 'SKU2' }
72
+ defaults.order_total_discount = { name: 'Order Total Discount', amount_type: 'percent', amount: 10 }
73
+ defaults.pricing_sku = { id: '2134' }
74
+ defaults.product_attribute_discount = { name: 'Test Discount', attribute_name: 'foo', attribute_value: 'bar', amount: 10 }
75
+ defaults.product_discount = { name: 'Test Discount', amount_type: 'percent', amount: 50, product_ids: ['PRODUCT1'] }
76
+ defaults.quantity_fixed_price_discount = { name: 'Quantity Price Discount', quantity: 3, price: 10, product_ids: ['PRODUCT'] }
77
+ defaults.shipping_discount = { name: 'Shipping Discount', amount: 0, shipping_service: 'Ground' }
78
+
79
+ # factories/recommendation.rb
80
+ defaults.recommendations = {}
81
+ defaults.user_activity = {}
82
+
83
+ # factories/search.rb
84
+ defaults.search_settings = { terms_facets: %w(Color Size), range_facets: { price: [{ to: 9.99 }, { from: 10, to: 19.99 }, { from: 20, to: 29.99 }, { from: 30, to: 39.99 }, { from: 40 }] } }
85
+ defaults.search_customization = { id: 'foo', query: 'Foo' }
86
+ defaults.admin_search = Proc.new { { results: [create_product, create_product, create_product], stats: {}, facets: { 'color' => { 'Red' => 2, 'Blue' => 1 } }, total: 3, page: 1, per_page: Workarea.config.per_page } }
87
+ defaults.product_browse_search_options = Proc.new { { products: [create_product, create_product, create_product], stats: {}, facets: { 'color' => { 'Red' => 2, 'Blue' => 1 } }, total: 3, page: 1, per_page: Workarea.config.per_page } }
88
+
89
+ # factories/user.rb
90
+ defaults.user = Proc.new { { email: "user#{user_count}@workarea.com", password: 'W3bl1nc!', first_name: 'Ben', last_name: 'Crouse' } }
@@ -0,0 +1,22 @@
1
+ module Workarea
2
+ module Testing
3
+ module Indexes
4
+ def self.enable_enforcing!
5
+ set(1)
6
+ end
7
+
8
+ def self.disable_enforcing!
9
+ set(0)
10
+ end
11
+
12
+ def self.set(value)
13
+ servers = Mongoid::Clients.default.cluster.servers
14
+ addresses = servers.map(&:address).map(&:to_s)
15
+
16
+ client = Mongo::Client.new(addresses, database: 'admin')
17
+ client.command(setParameter: 1, notablescan: value)
18
+ client.close
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ # These fixes allow us to default locale to nil so routes in tests can be
2
+ # generated as expected. This is unbelievably shitty and makes me really sad.
3
+ # Details on this can be found here: https://github.com/rspec/rspec-rails/issues/255
4
+ # This combination of monkey patchs are the only thing I could find to cover
5
+ # all cases.
6
+
7
+ class ActionView::TestCase::TestController
8
+ def default_url_options(options={})
9
+ if options.key?(:locale) || options.key?('locale')
10
+ options
11
+ else
12
+ { locale: nil }.merge(options)
13
+ end
14
+ end
15
+ end
16
+
17
+ class ActionDispatch::Routing::RouteSet
18
+ module WorkareaLocaleFixes
19
+ def default_url_options
20
+ result = super
21
+
22
+ if !result.key?(:locale) && !result.key?('locale')
23
+ result[:locale] = nil
24
+ end
25
+
26
+ result
27
+ end
28
+ end
29
+ end
30
+
31
+ ActionDispatch::Routing::RouteSet.prepend(
32
+ ActionDispatch::Routing::RouteSet::WorkareaLocaleFixes
33
+ )
@@ -0,0 +1,186 @@
1
+ require 'workarea/testing/engine'
2
+
3
+ module Workarea
4
+ module Teaspoon
5
+ def self.apply(config)
6
+ # Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to
7
+ # `http://localhost:3000/jasmine` to run your tests.
8
+ config.mount_at = "/teaspoon"
9
+
10
+ # Specifies the root where Teaspoon will look for files. If you're testing an engine using a dummy application it can
11
+ # be useful to set this to your engines root (e.g. `Teaspoon::Engine.root`).
12
+ # Note: Defaults to `Rails.root` if nil.
13
+ config.root = nil
14
+
15
+ # Paths that will be appended to the Rails assets paths
16
+ # Note: Relative to `config.root`.
17
+ config.asset_paths = ["test/javascripts", "test/javascripts/stylesheets"]
18
+ config.asset_paths << "#{Workarea::Testing::Engine.root}/app/assets/javascripts"
19
+ config.asset_paths << "#{Workarea::Testing::Engine.root}/app/assets/stylesheets"
20
+
21
+ # Fixtures are rendered through a controller, which allows using HAML, RABL/JBuilder, etc. Files in these paths will
22
+ # be rendered as fixtures.
23
+ config.fixture_paths = ["test/javascripts/fixtures"]
24
+
25
+ # SUITES
26
+ #
27
+ # You can modify the default suite configuration and create new suites here. Suites are isolated from one another.
28
+ #
29
+ # When defining a suite you can provide a name and a block. If the name is left blank, :default is assumed. You can
30
+ # omit various directives and the ones defined in the default suite will be used.
31
+ #
32
+ # To run a specific suite
33
+ # - in the browser: http://localhost/teaspoon/[suite_name]
34
+ # - with the rake task: rake teaspoon suite=[suite_name]
35
+ # - with the cli: teaspoon --suite=[suite_name]
36
+ config.suite do |suite|
37
+ # Specify the framework you would like to use. This allows you to select versions, and will do some basic setup for
38
+ # you -- which you can override with the directives below. This should be specified first, as it can override other
39
+ # directives.
40
+ # Note: If no version is specified, the latest is assumed.
41
+ #
42
+ # Versions: 1.10.0, 1.17.1, 1.18.2, 1.19.0, 2.0.1, 2.1.0, 2.2.4
43
+ suite.use_framework :mocha, "2.2.4"
44
+
45
+ # Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These
46
+ # files need to be within an asset path. You can add asset paths using the `config.asset_paths`.
47
+ suite.matcher = "{test/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
48
+
49
+ # Load additional JS files, but requiring them in your spec helper is the preferred way to do this.
50
+ # suite.javascripts = []
51
+
52
+ # You can include your own stylesheets if you want to change how Teaspoon looks.
53
+ # Note: Spec related CSS can and should be loaded using fixtures.
54
+ # suite.stylesheets = ["teaspoon"]
55
+
56
+ # This suites spec helper, which can require additional support files. This file is loaded before any of your test
57
+ # files are loaded.
58
+ suite.helper = "spec_helper"
59
+
60
+ # Partial to be rendered in the head tag of the runner. You can use the provided ones or define your own by creating
61
+ # a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance.
62
+ #
63
+ # Available: boot, boot_require_js
64
+ suite.boot_partial = "boot"
65
+
66
+ # Partial to be rendered in the body tag of the runner. You can define your own to create a custom body structure.
67
+ suite.body_partial = "body"
68
+
69
+ # Hooks allow you to use `Teaspoon.hook("fixtures")` before, after, or during your spec run. This will make a
70
+ # synchronous Ajax request to the server that will call all of the blocks you've defined for that hook name.
71
+ # suite.hook :fixtures, &proc{}
72
+
73
+ # Determine whether specs loaded into the test harness should be embedded as individual script tags or concatenated
74
+ # into a single file. Similar to Rails' asset `debug: true` and `config.assets.debug = true` options. By default,
75
+ # Teaspoon expands all assets to provide more valuable stack traces that reference individual source files.
76
+ # suite.expand_assets = true
77
+ end
78
+
79
+ # Example suite. Since we're just filtering to files already within the root test/javascripts, these files will also
80
+ # be run in the default suite -- but can be focused into a more specific suite.
81
+ # config.suite :targeted do |suite|
82
+ # suite.matcher = "spec/javascripts/targeted/*_spec.{js,js.coffee,coffee}"
83
+ # end
84
+
85
+ # CONSOLE RUNNER SPECIFIC
86
+ #
87
+ # These configuration directives are applicable only when running via the rake task or command line interface. These
88
+ # directives can be overridden using the command line interface arguments or with ENV variables when using the rake
89
+ # task.
90
+ #
91
+ # Command Line Interface:
92
+ # teaspoon --driver=phantomjs --server-port=31337 --fail-fast=true --format=junit --suite=my_suite /spec/file_spec.js
93
+ #
94
+ # Rake:
95
+ # teaspoon DRIVER=phantomjs SERVER_PORT=31337 FAIL_FAST=true FORMATTERS=junit suite=my_suite
96
+
97
+ # Specify which headless driver to use. Supports PhantomJS and Selenium Webdriver.
98
+ #
99
+ # Available: :phantomjs, :selenium, :capybara_webkit
100
+ # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
101
+ # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
102
+ # Capybara Webkit: https://github.com/modeset/teaspoon/wiki/Using-Capybara-Webkit
103
+ # config.driver = :phantomjs
104
+
105
+ # Specify additional options for the driver.
106
+ #
107
+ # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
108
+ # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
109
+ # Capybara Webkit: https://github.com/modeset/teaspoon/wiki/Using-Capybara-Webkit
110
+ # config.driver_options = nil
111
+
112
+ # Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be
113
+ # considered a failure. This is to avoid issues that can arise where tests stall.
114
+ # config.driver_timeout = 180
115
+
116
+ # Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used.
117
+ # config.server = nil
118
+
119
+ # Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.
120
+ # config.server_port = nil
121
+
122
+ # Timeout for starting the server in seconds. If your server is slow to start you may have to bump this, or you may
123
+ # want to lower this if you know it shouldn't take long to start.
124
+ # config.server_timeout = 20
125
+
126
+ # Force Teaspoon to fail immediately after a failing suite. Can be useful to make Teaspoon fail early if you have
127
+ # several suites, but in environments like CI this may not be desirable.
128
+ # config.fail_fast = true
129
+
130
+ # Specify the formatters to use when outputting the results.
131
+ # Note: Output files can be specified by using `"junit>/path/to/output.xml"`.
132
+ #
133
+ # Available: :dot, :clean, :documentation, :json, :junit, :pride, :rspec_html, :snowday, :swayze_or_oprah, :tap, :tap_y, :teamcity
134
+ # config.formatters = [:dot]
135
+
136
+ # Specify if you want color output from the formatters.
137
+ # config.color = true
138
+
139
+ # Teaspoon pipes all console[log/debug/error] to $stdout. This is useful to catch places where you've forgotten to
140
+ # remove them, but in verbose applications this may not be desirable.
141
+ # config.suppress_log = false
142
+
143
+ # COVERAGE REPORTS / THRESHOLD ASSERTIONS
144
+ #
145
+ # Coverage reports requires Istanbul (https://github.com/gotwarlost/istanbul) to add instrumentation to your code and
146
+ # display coverage statistics.
147
+ #
148
+ # Coverage configurations are similar to suites. You can define several, and use different ones under different
149
+ # conditions.
150
+ #
151
+ # To run with a specific coverage configuration
152
+ # - with the rake task: rake teaspoon USE_COVERAGE=[coverage_name]
153
+ # - with the cli: teaspoon --coverage=[coverage_name]
154
+
155
+ # Specify that you always want a coverage configuration to be used. Otherwise, specify that you want coverage
156
+ # on the CLI.
157
+ # Set this to "true" or the name of your coverage config.
158
+ # config.use_coverage = nil
159
+
160
+ # You can have multiple coverage configs by passing a name to config.coverage.
161
+ # e.g. config.coverage :ci do |coverage|
162
+ # The default coverage config name is :default.
163
+ config.coverage do |coverage|
164
+ # Which coverage reports Istanbul should generate. Correlates directly to what Istanbul supports.
165
+ #
166
+ # Available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity
167
+ # coverage.reports = ["text-summary", "html"]
168
+
169
+ # The path that the coverage should be written to - when there's an artifact to write to disk.
170
+ # Note: Relative to `config.root`.
171
+ # coverage.output_path = "coverage"
172
+
173
+ # Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The
174
+ # default excludes assets from vendor, gems and support libraries.
175
+ # coverage.ignore = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
176
+
177
+ # Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any
178
+ # aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil.
179
+ # coverage.statements = nil
180
+ # coverage.functions = nil
181
+ # coverage.branches = nil
182
+ # coverage.lines = nil
183
+ end
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,59 @@
1
+ module Capybara::Poltergeist
2
+ class Client
3
+ private
4
+
5
+ # This is an extension of the 'abomination' written by
6
+ # the authors of poltergeist. They say its for JRuby, but
7
+ # the suppressor does not work without redirecting stderr
8
+ # in addition to stdout.
9
+ #
10
+ def redirect_stdout
11
+ prev = STDOUT.dup
12
+ prev.autoclose = false
13
+ $stdout = @write_io
14
+ STDOUT.reopen(@write_io)
15
+
16
+ prev = STDERR.dup
17
+ prev.autoclose = false
18
+ $stderr = @write_io
19
+ STDERR.reopen(@write_io)
20
+ yield
21
+ ensure
22
+ STDOUT.reopen(prev)
23
+ $stdout = STDOUT
24
+ STDERR.reopen(prev)
25
+ $stderr = STDERR
26
+ end
27
+ end
28
+ end
29
+
30
+ module Workarea
31
+
32
+ # Basic Logger class that filters out warnings that match a list of
33
+ # specified messages from phantomjs
34
+ #
35
+ class WarningSuppressor
36
+ IGNORES = [
37
+ /QFont::setPixelSize: Pixel size <= 0/,
38
+ /CoreText performance note:/,
39
+ /Heya! This page is using wysihtml/
40
+ ]
41
+
42
+ class << self
43
+ def write(message)
44
+ if suppress?(message)
45
+ 0
46
+ else
47
+ puts(message)
48
+ 1
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def suppress?(message)
55
+ IGNORES.any? { |re| message =~ re }
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,40 @@
1
+ # This fix allows us to default locale to nil so routes in helper tests can be
2
+ # generated as expected. This is unbelievably shitty and makes me really sad.
3
+ # Details on this can be found here: https://github.com/rspec/rspec-rails/issues/255
4
+ #
5
+
6
+ class ActionView::TestCase::TestController
7
+ def default_url_options(options = {})
8
+ if options.key?(:locale) || options.key?('locale')
9
+ options
10
+ else
11
+ { locale: nil }.merge(options)
12
+ end
13
+ end
14
+ end
15
+
16
+ module Workarea
17
+ class ViewTest < ActionView::TestCase
18
+ extend TestCase::Decoration
19
+ include TestCase::RunnerLocation
20
+ include Factories
21
+ include TestCase::Workers
22
+ include TestCase::Locales
23
+
24
+ setup do
25
+ Mongoid.truncate!
26
+ Workarea.redis.flushdb
27
+ WebMock.disable_net_connect!(allow_localhost: true)
28
+ Workarea.config.send_email = false
29
+ ActionMailer::Base.deliveries.clear
30
+
31
+ Sidekiq::Testing.inline!
32
+ Sidekiq::Callbacks.inline
33
+ Sidekiq::Callbacks.disable
34
+ end
35
+
36
+ teardown do
37
+ travel_back
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path('../../core/lib/workarea/version', __FILE__)
2
+
3
+ # Describe your gem and declare its dependencies:
4
+ Gem::Specification.new do |s|
5
+ s.name = "workarea-testing"
6
+ s.version = Workarea::VERSION::STRING
7
+ s.authors = ["Ben Crouse"]
8
+ s.email = ["bcrouse@workarea.com"]
9
+ s.homepage = "http://www.workarea.com"
10
+ s.license = 'Business Software License'
11
+ s.summary = "Testing tools for the Workarea Commerce Platform"
12
+ s.description = "Provides tooling for writing tests for the Workarea Commerce Platform."
13
+
14
+ s.require_paths = %w(lib)
15
+ s.files = `git ls-files`.split("\n")
16
+
17
+ s.required_ruby_version = '>= 2.3.0'
18
+
19
+ s.add_dependency 'workarea-core', Workarea::VERSION::STRING
20
+ s.add_dependency 'capybara', '~> 3.18'
21
+ s.add_dependency 'webmock', '~> 3.5.0'
22
+ s.add_dependency 'vcr', '~> 2.9.0'
23
+ s.add_dependency 'launchy', '~> 2.4.3'
24
+ s.add_dependency 'teaspoon', '~> 1.1.5'
25
+ s.add_dependency 'teaspoon-mocha', '~> 2.3.3'
26
+ s.add_dependency 'mocha', '~> 1.3.0'
27
+ s.add_dependency 'selenium-webdriver', '~> 3.142'
28
+ s.add_dependency 'webdrivers', '~> 3.0'
29
+ end