self_systeem 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d746ed306756bff4b736970be16df034abd8275
4
- data.tar.gz: 5d3d66b9432afd019d83b3e92612df019f5ed5d1
3
+ metadata.gz: d2c6cfe25cf61af7377e58c63bbf3ce3a9d75287
4
+ data.tar.gz: 69b1f86627aad4b6e6268e80f3db35e20bf2cf63
5
5
  SHA512:
6
- metadata.gz: 7a280997a7d269198b182836ee954404424e5448a3853c559dc2e8c696ec10af55521a8b0d20f2015e05a3a1ecd8da186412e1424e2b06ec4ffd94a2847299c7
7
- data.tar.gz: 71c1f211cfa66229922f99fbd12eab5dd8ec75dbeadb1999f9de83e26dfba68f81abebc37dbe1a1fe5454d8f887294a19caab11975d191cb6621eeb1dc9a458e
6
+ metadata.gz: d3b41fa5008d20861a5f95436f41c2a2a9c9e9ff46e9568837616727f11cfb376917be14910db768a5ce178179b22b5b5f4411d3c75a3a28ee6105aeadddcacb
7
+ data.tar.gz: 4df8624646d3cfce7e6aa6240fad8e8af83eabf28de6985c45c77e5a9e7124eb05e125a5041c65f58bcd7e8d74e379085d7f7d010392ff81a5596a641c30e048
@@ -0,0 +1,19 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path("../../../../config/environment", __FILE__)
3
+ require "minitest/spec"
4
+ require "cell/test_case"
5
+ require "rails/test_help"
6
+ require "minitest/spec"
7
+ Dir[File.join("./test/support/**/authentication.rb")].sort.each { |f| require f }
8
+
9
+ DatabaseCleaner.strategy = :truncation
10
+ DatabaseCleaner.clean_with :truncation
11
+
12
+ class ActionController::TestCase
13
+ self.use_transactional_fixtures = false
14
+ end
15
+
16
+ module SysteemConfig
17
+ Affirmations = YAML.load_file("./test/system/support/systeem_booster.yml")[:affirmations]
18
+ Session = ActionController::TestSession.new
19
+ end
@@ -0,0 +1,24 @@
1
+ require "./test/system/support/systeem_config.rb"
2
+
3
+ describe "start_db_cleaner" do
4
+ before { DatabaseCleaner.start }
5
+ end
6
+
7
+ SysteemConfig::Affirmations.each do |a|
8
+ describe a[:controller_class_name].constantize do
9
+ before do
10
+ @request.env["devise.mapping"] = Devise.mappings[:user]
11
+ send(a[:request_method].downcase.to_sym, a[:action], a[:request_parameters], SysteemConfig::Session)
12
+ SysteemConfig::Session.merge! session
13
+ end
14
+
15
+ it {
16
+ assert_response a[:status]
17
+
18
+ }
19
+ end
20
+ end
21
+
22
+ describe "db_cleaner_clean" do
23
+ before { DatabaseCleaner.clean }
24
+ end
@@ -0,0 +1,16 @@
1
+ require "rails/generators/active_record"
2
+
3
+ module SelfSysteem
4
+ module Generators
5
+ class TestGenerator < Rails::Generators::Base
6
+
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def add_test_and_support
10
+ copy_file "systeem_config.rb", "test/system/support/systeem_config.rb"
11
+ copy_file "systeem_test.rb", "test/system/systeem_test.rb"
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,67 @@
1
+ module SelfSysteem
2
+ class AffirmationBuilder
3
+
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ if env["REQUEST_PATH"].match(/\/assets/)
10
+ status, headers, response = @app.call(env)
11
+ else
12
+ status, headers, response = @app.call(env)
13
+ request_path = env["REQUEST_PATH"]
14
+ request_method = env["REQUEST_METHOD"]
15
+
16
+ request_parameters = {}
17
+ request_parameters.merge!(env["rack.request.form_hash"]) if env["rack.request.form_hash"].present?
18
+ request_parameters.merge!(env["action_controller.instance"].params.try(:to_hash)) if env["action_controller.instance"].params.present?
19
+
20
+ controller_instance = env["action_controller.instance"]
21
+ controller_class_name = controller_instance.try(:class).try(:name)
22
+ action = controller_instance.action_name
23
+
24
+ relevant_instance_varaibles = controller_instance
25
+ .instance_variable_names.reject {|v| v[/@_/] || v == "@marked_for_same_origin_verification"}
26
+ instance_variable_objects = {}
27
+ relevant_instance_varaibles.each do |v|
28
+ iv_val = controller_instance.instance_variable_get(v)
29
+ if iv_val.class.name.match(/ActiveRecord::AssociationRelation|ActiveRecord::Associations::CollectionProxy/)
30
+ instance_variable_objects.merge!(v.to_s => { })
31
+ iv_val.each do |o|
32
+ instance_variable_objects[v.to_s].merge!({ o.to_s => o.attributes })
33
+ end
34
+ elsif iv_val.is_a?(ActiveRecord::Base)
35
+ instance_variable_objects.merge!({ v.to_s => iv_val.attributes })
36
+ else
37
+ instance_variable_objects.merge!({ v.to_s => iv_val.to_s })
38
+ end
39
+ end
40
+
41
+ booster = {request_method: request_method,
42
+ request_path: request_path,
43
+ action: action,
44
+ request_parameters: request_parameters,
45
+ controller_class_name: controller_class_name,
46
+ status: status,
47
+ relevant_instance_varaibles: relevant_instance_varaibles.to_s,
48
+ instance_variable_objects: instance_variable_objects
49
+ }
50
+
51
+ unless File.exist?(Rails.root.to_s + "/test/system/support/systeem_booster.yml")
52
+ FileUtils.mkdir_p Rails.root.to_s + "/test/system/support"
53
+ File.open(Rails.root.to_s + "/test/system/support/systeem_booster.yml", "w") { |file| file.write({ affirmations: [] }.to_yaml) }
54
+ end
55
+
56
+ boosters = YAML.load_file(Rails.root.to_s + "/test/system/support/systeem_booster.yml")
57
+ boosters[:affirmations] << booster
58
+
59
+ File.open(Rails.root.to_s + "/test/system/support/systeem_booster.yml", 'w') do |file|
60
+ file.write(boosters.to_yaml)
61
+ end
62
+ end
63
+
64
+ [status, headers, [response.try(:body)].flatten]
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module SelfSysteem
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: self_systeem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Piccolo
@@ -64,7 +64,11 @@ files:
64
64
  - LICENSE.txt
65
65
  - README.md
66
66
  - Rakefile
67
+ - lib/generators/self_systeem/templates/systeem_config.rb
68
+ - lib/generators/self_systeem/templates/systeem_test.rb
69
+ - lib/generators/self_systeem/test_generator.rb
67
70
  - lib/self_systeem.rb
71
+ - lib/self_systeem/affirmation_builder.rb
68
72
  - lib/self_systeem/version.rb
69
73
  - self_systeem.gemspec
70
74
  homepage: ''