Skip to content

Commit

Permalink
Remove support for testing and extensions
Browse files Browse the repository at this point in the history
Some things of this gem will be moved to [solidus_extension_dev_tools](dev_tools)
we should remove and/or deprecate those within solidus_support to avoid
confusion and have a clear update path for extension maintainers.

Extracted:
+ feature/spec helpers
+ coverage support
+ preferences stub (`stub_spree_preferences`)
+ extension decorator (`SolidusSupport::EngineExtensions::Decorators`)

Ref. solidusio/solidus_dev_support#13

[dev_tool]: https://github.com/solidusio-contrib/solidus_extension_dev_tools)
  • Loading branch information
Flavio Auciello committed Dec 6, 2019
1 parent 9df07a6 commit 758d407
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 299 deletions.
88 changes: 0 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,94 +24,6 @@ SolidusSupport::Migration[5.0] # same as `ActiveRecord::Migration[5.0]`

There's no reason to use `SolidusSupport::Migration[5.0]` over `ActiveRecord::Migration[5.0]`, but it is provided.

### Engine Extensions

This extension provides a module that extends `Rails::Engine` functionalities
to support loading correctly the decorators class created into an extension
both for development and production enviroments.

To use it just include the provided module in the Engine as follow:

```ruby
module SolidusExtensionName
class Engine < Rails::Engine
engine_name 'solidus_extension_name'

include SolidusSupport::EngineExtensions::Decorators
# ...
end
end
```

To make it work, be sure to remove the previous implementation from the
Engine, that should be something like:

```ruby
def self.activate
Dir.glob(File.join(root, "app/**/*_decorator*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

config.to_prepare(&method(:activate).to_proc)
```

### Testing Helpers

This gem provides some useful helpers for RSpec to setup an extension's test
environment easily.

Into your extension's spec/spec_helper.rb:

```ruby
require "solidus_support/extension/feature_helper"
```

This helper loads configuration needed to run extensions feature specs
correctly, setting up Capybara and configuring Rails test application
to precompile assets before the first feature spec.

This helper requires the `rails_helper`, also provided by this gem and
requireable as a stand-alone helper.

By doing:

```ruby
require "solidus_support/extension/rails_helper"
```

extension's test suite will have all Rails related tests configuration,
like authorization helpers, Solidus core factories, url helpers, and
other helpers to easily work with Solidus Config.

This `rails_helper` in turn requires the basic `spec_helper`, which is
responsible to load a basic RSpec configuration, which could be needed
in all extensions. It is also requireable as a stand-alone helper with:

```ruby
require "solidus_support/extension/spec_helper"
```

### Coverage Collection

The gem also includes a SimpleCov configuration that will send your test
coverage information directly to Codecov.io. Simply add this at the top
of your `spec/spec_helper.rb`:

```ruby
require "solidus_support/extension/coverage"
```

**Note: Make sure to add this at the VERY TOP of your spec_helper,
otherwise you'll get skewed coverage reports!**

If your extension is in a public repo and being tested on Travis or
CircleCI, there's nothing else you need to do - you'll get coverage
reports for free!

If your setup is more complex, look at the [SimpleCov](https://github.com/colszowka/simplecov)
and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs.

## Development

After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down
1 change: 0 additions & 1 deletion lib/solidus_support.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'solidus_support/version'
require 'solidus_support/migration'
require 'solidus_support/engine_extensions'
require 'solidus_core'

module SolidusSupport
Expand Down
1 change: 0 additions & 1 deletion lib/solidus_support/engine_extensions.rb

This file was deleted.

37 changes: 0 additions & 37 deletions lib/solidus_support/engine_extensions/decorators.rb

This file was deleted.

16 changes: 0 additions & 16 deletions lib/solidus_support/extension/coverage.rb

This file was deleted.

44 changes: 0 additions & 44 deletions lib/solidus_support/extension/feature_helper.rb

This file was deleted.

45 changes: 0 additions & 45 deletions lib/solidus_support/extension/rails_helper.rb

This file was deleted.

19 changes: 0 additions & 19 deletions lib/solidus_support/extension/spec_helper.rb

This file was deleted.

45 changes: 0 additions & 45 deletions lib/solidus_support/testing_support/preferences.rb

This file was deleted.

3 changes: 0 additions & 3 deletions solidus_support.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,4 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-rspec'
spec.add_development_dependency 'solidus_core'

spec.add_dependency 'capybara-screenshot'
spec.add_dependency 'codecov'
end

0 comments on commit 758d407

Please sign in to comment.