defra_ruby_features 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/defra_ruby_features/version.rb +1 -1
  4. metadata +21 -268
  5. data/spec/dummy/Rakefile +0 -8
  6. data/spec/dummy/app/assets/config/manifest.js +0 -3
  7. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  8. data/spec/dummy/app/channels/application_cable/channel.rb +0 -6
  9. data/spec/dummy/app/channels/application_cable/connection.rb +0 -6
  10. data/spec/dummy/app/controllers/application_controller.rb +0 -4
  11. data/spec/dummy/app/controllers/test_controller.rb +0 -7
  12. data/spec/dummy/app/helpers/application_helper.rb +0 -4
  13. data/spec/dummy/app/javascript/packs/application.js +0 -14
  14. data/spec/dummy/app/jobs/application_job.rb +0 -9
  15. data/spec/dummy/app/models/ability.rb +0 -9
  16. data/spec/dummy/app/models/application_record.rb +0 -5
  17. data/spec/dummy/app/models/feature_toggle.rb +0 -4
  18. data/spec/dummy/app/models/user.rb +0 -8
  19. data/spec/dummy/app/views/layouts/application.html.erb +0 -12
  20. data/spec/dummy/bin/rails +0 -4
  21. data/spec/dummy/bin/rake +0 -4
  22. data/spec/dummy/bin/setup +0 -25
  23. data/spec/dummy/config/application.rb +0 -29
  24. data/spec/dummy/config/boot.rb +0 -7
  25. data/spec/dummy/config/database.yml +0 -21
  26. data/spec/dummy/config/environment.rb +0 -7
  27. data/spec/dummy/config/environments/development.rb +0 -50
  28. data/spec/dummy/config/environments/test.rb +0 -41
  29. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -10
  30. data/spec/dummy/config/initializers/assets.rb +0 -14
  31. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -9
  32. data/spec/dummy/config/initializers/content_security_policy.rb +0 -30
  33. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -7
  34. data/spec/dummy/config/initializers/defra_ruby_features.rb +0 -7
  35. data/spec/dummy/config/initializers/devise.rb +0 -311
  36. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -6
  37. data/spec/dummy/config/initializers/inflections.rb +0 -18
  38. data/spec/dummy/config/initializers/mime_types.rb +0 -6
  39. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -11
  40. data/spec/dummy/config/locales/devise.en.yml +0 -65
  41. data/spec/dummy/config/locales/en.yml +0 -33
  42. data/spec/dummy/config/routes.rb +0 -7
  43. data/spec/dummy/config.ru +0 -7
  44. data/spec/dummy/db/migrate/20200623125321_create_feature_toggles.rb +0 -12
  45. data/spec/dummy/db/migrate/20200624115316_devise_create_users.rb +0 -44
  46. data/spec/dummy/db/schema.rb +0 -34
  47. data/spec/dummy/db/test.sqlite3 +0 -0
  48. data/spec/dummy/log/test.log +0 -183
  49. data/spec/dummy/public/404.html +0 -67
  50. data/spec/dummy/public/422.html +0 -67
  51. data/spec/dummy/public/500.html +0 -66
  52. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  53. data/spec/dummy/public/apple-touch-icon.png +0 -0
  54. data/spec/dummy/public/favicon.ico +0 -0
  55. data/spec/dummy/tmp/development_secret.txt +0 -1
  56. data/spec/examples.txt +0 -13
  57. data/spec/factories/feature_toggle.rb +0 -8
  58. data/spec/factories/user.rb +0 -11
  59. data/spec/lib/defra_ruby_mocks/configuration_spec.rb +0 -13
  60. data/spec/rails_helper.rb +0 -54
  61. data/spec/requests/defra_ruby_features/feature_toggles_spec.rb +0 -145
  62. data/spec/spec_helper.rb +0 -83
  63. data/spec/support/database_cleaner.rb +0 -19
  64. data/spec/support/devise.rb +0 -5
  65. data/spec/support/factory_bot.rb +0 -8
  66. data/spec/support/migrations.rb +0 -10
  67. data/spec/support/pry.rb +0 -7
  68. data/spec/support/rails_controller_testing.rb +0 -5
  69. data/spec/support/simplecov.rb +0 -17
@@ -1,145 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails_helper"
4
-
5
- module DefraRubyFeatures
6
- RSpec.describe "FeatureToggle", type: :request do
7
- let(:user) { create(:user) }
8
-
9
- context "GET /feature-toggles" do
10
- context "when a user is authenticated" do
11
- before(:each) do
12
- sign_in(user)
13
- end
14
-
15
- it "returns a list of available feature toggles" do
16
- key = "a_feature_toggle"
17
- create(:feature_toggle, key: key)
18
-
19
- get "/feature-toggles"
20
-
21
- expect(response.body).to include(key)
22
- expect(response).to have_http_status(200)
23
- expect(response).to render_template(:index)
24
- end
25
- end
26
-
27
- context "when there is no user authenticated" do
28
- it "redirects away" do
29
- get "/feature-toggles"
30
-
31
- expect(response).to have_http_status(302)
32
- end
33
- end
34
- end
35
-
36
- context "POST /feature-toggles" do
37
- context "when a user is authenticated" do
38
- before(:each) do
39
- sign_in(user)
40
- end
41
-
42
- it "creates a new feature toggle with a given value and redirects to the index page" do
43
- count = FeatureToggle.count
44
-
45
- post "/feature-toggles", params: { feature_toggle: { key: "test", active: "1" } }
46
-
47
- feature_toggle = FeatureToggle.last
48
-
49
- expect(feature_toggle.key).to eq("test")
50
- expect(feature_toggle).to be_active
51
- expect(FeatureToggle.count).to eq(count + 1)
52
- expect(response).to have_http_status(302)
53
- expect(response).to redirect_to("/feature-toggles")
54
- end
55
- end
56
-
57
- context "when there is no user authenticated" do
58
- it "redirects away" do
59
- post "/feature-toggles"
60
-
61
- expect(response).to have_http_status(302)
62
- end
63
- end
64
- end
65
-
66
- context "PUT/PATCH /feature-toggles/:id" do
67
- let(:feature_toggle) { create(:feature_toggle, active: false) }
68
-
69
- context "when a user is authenticated" do
70
- before(:each) do
71
- sign_in(user)
72
- end
73
-
74
- it "updates a feature toggle with the given params and redirects to the index page" do
75
- put "/feature-toggles/#{feature_toggle.id}", params: { feature_toggle: { active: "1" } }
76
-
77
- feature_toggle.reload
78
-
79
- expect(feature_toggle).to be_active
80
- expect(response).to have_http_status(302)
81
- expect(response).to redirect_to("/feature-toggles")
82
- end
83
- end
84
-
85
- context "when there is no user authenticated" do
86
- it "redirects away" do
87
- put "/feature-toggles/#{feature_toggle.id}"
88
-
89
- expect(response).to have_http_status(302)
90
- end
91
- end
92
- end
93
-
94
- context "GET /feature-toggles/new" do
95
- context "when a user is authenticated" do
96
- before(:each) do
97
- sign_in(user)
98
- end
99
-
100
- it "renders a template to create a new feature toggle" do
101
- get "/feature-toggles/new"
102
-
103
- expect(response).to render_template(:new)
104
- expect(response).to have_http_status(200)
105
- end
106
- end
107
-
108
- context "when there is no user authenticated" do
109
- it "redirects away" do
110
- get "/feature-toggles/new"
111
-
112
- expect(response).to have_http_status(302)
113
- end
114
- end
115
- end
116
-
117
- context "DELETE /feature-toggles/:id" do
118
- let!(:feature_toggle) { create(:feature_toggle) }
119
-
120
- context "when there is a user authenticated" do
121
- before(:each) do
122
- sign_in(user)
123
- end
124
-
125
- it "deletes a feature toggle and redirects to the index page" do
126
- count = FeatureToggle.count
127
-
128
- delete "/feature-toggles/#{feature_toggle.id}"
129
-
130
- expect(FeatureToggle.count).to eq(count - 1)
131
- expect(response).to have_http_status(302)
132
- expect(response).to redirect_to("/feature-toggles")
133
- end
134
- end
135
-
136
- context "when there is no user authenticated" do
137
- it "redirects away" do
138
- delete "/feature-toggles/#{feature_toggle.id}"
139
-
140
- expect(response).to have_http_status(302)
141
- end
142
- end
143
- end
144
- end
145
- end
data/spec/spec_helper.rb DELETED
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Require and run our simplecov initializer as the very first thing we do.
4
- # This is as per its docs https://github.com/colszowka/simplecov#getting-started
5
- require "./spec/support/simplecov"
6
-
7
- # This file was generated by the `rspec --init` command. Conventionally, all
8
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9
- # The generated `.rspec` file contains `--require spec_helper` which will cause
10
- # this file to always be loaded, without a need to explicitly require it in any
11
- # files.
12
- #
13
- # Given that it is always loaded, you are encouraged to keep this file as
14
- # light-weight as possible. Requiring heavyweight dependencies from this file
15
- # will add to the boot time of your test suite on EVERY test run, even for an
16
- # individual file that may not need all of that loaded. Instead, consider making
17
- # a separate helper file that requires the additional dependencies and performs
18
- # the additional setup, and require it from the spec files that actually need
19
- # it.
20
- #
21
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
- RSpec.configure do |config|
23
- # rspec-expectations config goes here. You can use an alternate
24
- # assertion/expectation library such as wrong or the stdlib/minitest
25
- # assertions if you prefer.
26
- config.expect_with :rspec do |expectations|
27
- # This option will default to `true` in RSpec 4. It makes the `description`
28
- # and `failure_message` of custom matchers include text for helper methods
29
- # defined using `chain`, e.g.:
30
- # be_bigger_than(2).and_smaller_than(4).description
31
- # # => "be bigger than 2 and smaller than 4"
32
- # ...rather than:
33
- # # => "be bigger than 2"
34
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
- end
36
-
37
- # rspec-mocks config goes here. You can use an alternate test double
38
- # library (such as bogus or mocha) by changing the `mock_with` option here.
39
- config.mock_with :rspec do |mocks|
40
- # Prevents you from mocking or stubbing a method that does not exist on
41
- # a real object. This is generally recommended, and will default to
42
- # `true` in RSpec 4.
43
- mocks.verify_partial_doubles = true
44
- end
45
-
46
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
47
- # have no way to turn it off -- the option exists only for backwards
48
- # compatibility in RSpec 3). It causes shared context metadata to be
49
- # inherited by the metadata hash of host groups and examples, rather than
50
- # triggering implicit auto-inclusion in groups with matching metadata.
51
- config.shared_context_metadata_behavior = :apply_to_host_groups
52
-
53
- # This allows you to limit a spec run to individual examples or groups
54
- # you care about by tagging them with `:focus` metadata. When nothing
55
- # is tagged with `:focus`, all examples get run. RSpec also provides
56
- # aliases for `it`, `describe`, and `context` that include `:focus`
57
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
- config.filter_run_when_matching :focus
59
-
60
- # Allows RSpec to persist some state between runs in order to support
61
- # the `--only-failures` and `--next-failure` CLI options. We recommend
62
- # you configure your source control system to ignore this file.
63
- config.example_status_persistence_file_path = "spec/examples.txt"
64
-
65
- # Limits the available syntax to the non-monkey patched syntax that is
66
- # recommended. For more details, see:
67
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
- config.disable_monkey_patching!
71
-
72
- # Run specs in random order to surface order dependencies. If you find an
73
- # order dependency and want to debug it, you can fix the order by providing
74
- # the seed, which is printed after each run.
75
- # --seed 1234
76
- config.order = :random
77
-
78
- # Seed global randomization in this process using the `--seed` CLI option.
79
- # Setting this allows you to use `--seed` to deterministically reproduce
80
- # test failures related to randomization by passing the same `--seed` value
81
- # as the one that triggered the failure.
82
- Kernel.srand config.seed
83
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Require this to support automatically cleaning the database when testing
4
- require "database_cleaner"
5
-
6
- RSpec.configure do |config|
7
- # Clean the database before running tests. Setup as per
8
- # https://github.com/DatabaseCleaner/database_cleaner#rspec-example
9
- config.before(:suite) do
10
- DatabaseCleaner.strategy = :transaction
11
- DatabaseCleaner.clean_with(:truncation)
12
- end
13
-
14
- config.around(:each) do |example|
15
- DatabaseCleaner.cleaning do
16
- example.run
17
- end
18
- end
19
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.include Devise::Test::IntegrationHelpers, type: :request
5
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Require this here to get factories to play nice with engine
4
- require "factory_bot_rails"
5
-
6
- RSpec.configure do |config|
7
- config.include FactoryBot::Syntax::Methods
8
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Checks for pending migrations and applies them before tests are run.
4
- # If you are not using ActiveRecord, you can remove these lines.
5
- begin
6
- ActiveRecord::Migration.maintain_test_schema!
7
- rescue ActiveRecord::PendingMigrationError => e
8
- puts e.to_s.strip
9
- exit 1
10
- end
data/spec/support/pry.rb DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Support debugging in the tests. Add `binding.pry` wherever you want execution
4
- # to stop and the debugger to kick in.
5
- # Details on the debugging commands can be found here
6
- # https://github.com/deivid-rodriguez/pry-byebug#commands
7
- require "pry-byebug"
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails-controller-testing"
4
-
5
- Rails::Controller::Testing.install
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "simplecov"
4
-
5
- # We start it with the rails param to ensure it includes coverage for all code
6
- # started by the rails app, and not just the files touched by our unit tests.
7
- # This gives us the most accurate assessment of our unit test coverage
8
- # https://github.com/colszowka/simplecov#getting-started
9
- SimpleCov.start do
10
- # We filter the spec folder, mainly to ensure that any dummy apps don't get
11
- # included in the coverage report. However our intent is that nothing in the
12
- # spec folder should be included
13
- add_filter "/spec/"
14
- # The version file is simply just that, so we do not feel the need to ensure
15
- # we have a test for it
16
- add_filter "lib/defra_ruby_features/version"
17
- end