diff options
| author | Zog | 2017-12-15 17:01:49 +0100 |
|---|---|---|
| committer | Zog | 2017-12-19 17:02:37 +0100 |
| commit | c3ce5e25c3596329bd1ff9542d73354e1a2bb368 (patch) | |
| tree | e26784690d9ae563e265681ddb52e453b0f96bc1 /spec/support | |
| parent | 74da4b28490d0b8822e74ddf8a7e897d1fc24588 (diff) | |
| download | chouette-core-c3ce5e25c3596329bd1ff9542d73354e1a2bb368.tar.bz2 | |
Ref #5291@2h; Specs setup
- Refactor specs helper to be more generic
- Write missing specs for the Workbenches#show view
We now have failing tests highlighting the bug
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/integration_spec_helper.rb | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/spec/support/integration_spec_helper.rb b/spec/support/integration_spec_helper.rb index 5bcf0bd3a..6edec2a05 100644 --- a/spec/support/integration_spec_helper.rb +++ b/spec/support/integration_spec_helper.rb @@ -1,26 +1,32 @@ module IntegrationSpecHelper - def with_permission permission, &block - context "with permission #{permission}" do - let(:permissions){ [permission] } - context('', &block) if block_given? - end + def paginate_collection klass, decorator, page=1 + ModelDecorator.decorate( klass.page(page), with: decorator ) + end - def paginate_collection klass, decorator, page=1 - ModelDecorator.decorate( klass.page(page), with: decorator ) - end + def build_paginated_collection factory, decorator, opts={} + count = opts.delete(:count) || 2 + page = opts.delete(:page) || 1 + klass = nil + count.times { klass ||= create(factory, opts).class } + paginate_collection klass, decorator, page + end - def build_paginated_collection factory, decorator, opts={} - count = opts.delete(:count) || 2 - page = opts.delete(:page) || 1 - klass = nil - count.times { klass ||= create(factory, opts).class } - paginate_collection klass, decorator, page + module Methods + def with_permission permission, &block + context "with permission #{permission}" do + let(:permissions){ [permission] } + context('', &block) if block_given? + end end end + + def self.included into + into.extend Methods + end end RSpec.configure do |config| - config.extend IntegrationSpecHelper, type: :view + config.include IntegrationSpecHelper, type: :view end RSpec::Matchers.define :have_link_for_each_item do |collection, name, href| |
