Skip to content

Commit 222e914

Browse files
committed
refactored and splitted specs for core and vue_js, cleanup and refactorings, dummy app tmp content
1 parent d677004 commit 222e914

File tree

158 files changed

+2166
-1998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+2166
-1998
lines changed

spec/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/core_spec_helper.rb

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
2+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3+
# The generated `.rspec` file contains `--require spec_helper` which will cause
4+
# this file to always be loaded, without a need to explicitly require it in any
5+
# files.
6+
#
7+
# Given that it is always loaded, you are encouraged to keep this file as
8+
# light-weight as possible. Requiring heavyweight dependencies from this file
9+
# will add to the boot time of your test suite on EVERY test run, even for an
10+
# individual file that may not need all of that loaded. Instead, consider making
11+
# a separate helper file that requires the additional dependencies and performs
12+
# the additional setup, and require it from the spec files that actually need
13+
# it.
14+
#
15+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16+
require 'simplecov'
17+
SimpleCov.start do
18+
enable_coverage :branch
19+
20+
add_filter "/spec"
21+
add_filter %r{^/config/}
22+
23+
24+
add_group "Concepts", "/app/concepts"
25+
add_group "Helpers", "/app/helpers"
26+
add_group "App Lib", "/app/lib"
27+
add_group "Lib", %r{^/lib/}
28+
29+
track_files "{app,lib}/**/*.rb"
30+
end
31+
32+
require 'webmock/rspec'
33+
WebMock.allow_net_connect!
34+
35+
require File.join File.dirname(__FILE__), 'dummy', 'config', 'environment.rb'
36+
37+
Dir[File.join File.dirname(__FILE__), 'test', 'core', 'support', '**', '*.rb'].each { |f| require f }
38+
39+
require 'pry'
40+
41+
# require 'rspec/retry'
42+
# require "rspec/wait"
43+
44+
RSpec.configure do |config|
45+
46+
# run retry only on features
47+
# config.around :each, :js do |ex|
48+
# ex.run_with_retry retry: 3
49+
# end
50+
51+
# config.include Capybara::DSL
52+
# rspec-expectations config goes here. You can use an alternate
53+
# assertion/expectation library such as wrong or the stdlib/minitest
54+
# assertions if you prefer.
55+
config.expect_with :rspec do |expectations|
56+
# This option will default to `true` in RSpec 4. It makes the `description`
57+
# and `failure_message` of custom matchers include text for helper methods
58+
# defined using `chain`, e.g.:
59+
# be_bigger_than(2).and_smaller_than(4).description
60+
# # => "be bigger than 2 and smaller than 4"
61+
# ...rather than:
62+
# # => "be bigger than 2"
63+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
64+
end
65+
66+
# rspec-mocks config goes here. You can use an alternate test double
67+
# library (such as bogus or mocha) by changing the `mock_with` option here.
68+
config.mock_with :rspec do |mocks|
69+
# Prevents you from mocking or stubbing a method that does not exist on
70+
# a real object. This is generally recommended, and will default to
71+
# `true` in RSpec 4.
72+
mocks.verify_partial_doubles = true
73+
end
74+
75+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
76+
# have no way to turn it off -- the option exists only for backwards
77+
# compatibility in RSpec 3). It causes shared context metadata to be
78+
# inherited by the metadata hash of host groups and examples, rather than
79+
# triggering implicit auto-inclusion in groups with matching metadata.
80+
config.shared_context_metadata_behavior = :apply_to_host_groups
81+
82+
# The settings below are suggested to provide a good initial experience
83+
# with RSpec, but feel free to customize to your heart's content.
84+
=begin
85+
# This allows you to limit a spec run to individual examples or groups
86+
# you care about by tagging them with `:focus` metadata. When nothing
87+
# is tagged with `:focus`, all examples get run. RSpec also provides
88+
# aliases for `it`, `describe`, and `context` that include `:focus`
89+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
90+
config.filter_run_when_matching :focus
91+
92+
# Allows RSpec to persist some state between runs in order to support
93+
# the `--only-failures` and `--next-failure` CLI options. We recommend
94+
# you configure your source control system to ignore this file.
95+
config.example_status_persistence_file_path = "spec/examples.txt"
96+
97+
# Limits the available syntax to the non-monkey patched syntax that is
98+
# recommended. For more details, see:
99+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
100+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
101+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
102+
config.disable_monkey_patching!
103+
104+
# Many RSpec users commonly either run the entire suite or an individual
105+
# file, and it's useful to allow more verbose output when running an
106+
# individual spec file.
107+
if config.files_to_run.one?
108+
# Use the documentation formatter for detailed output,
109+
# unless a formatter has already been configured
110+
# (e.g. via a command-line flag).
111+
config.default_formatter = "doc"
112+
end
113+
114+
# Print the 10 slowest examples and example groups at the
115+
# end of the spec run, to help surface which specs are running
116+
# particularly slow.
117+
config.profile_examples = 10
118+
119+
# Run specs in random order to surface order dependencies. If you find an
120+
# order dependency and want to debug it, you can fix the order by providing
121+
# the seed, which is printed after each run.
122+
# --seed 1234
123+
config.order = :random
124+
125+
# Seed global randomization in this process using the `--seed` CLI option.
126+
# Setting this allows you to use `--seed` to deterministically reproduce
127+
# test failures related to randomization by passing the same `--seed` value
128+
# as the one that triggered the failure.
129+
Kernel.srand config.seed
130+
=end
131+
132+
config.before :all, type: :feature do
133+
unless Rails.application.routes.url_helpers.method_defined?(:matestack_components_test_path)
134+
Rails.application.routes.append do
135+
get '/matestack_components_test', to: 'matestack_components#matestack_components_test', as: :matestack_components_test
136+
get '/matestack_transition_test', to: 'matestack_components#matestack_transition_test', as: :matestack_transition_test
137+
get '/example', to: 'example#page'
138+
get '/base_example', to: 'example#base'
139+
end
140+
Rails.application.reload_routes!
141+
end
142+
end
143+
144+
end

spec/dummy/app/channels/matestack_ui_core_channel.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class MatestackUiVueJsChannel < ApplicationCable::Channel
2+
3+
def subscribed
4+
stream_from "matestack_ui_vue_js"
5+
end
6+
7+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class DemoCoreController < ActionController::Base
2+
include Matestack::Ui::Core::Helper
3+
4+
layout "application_core"
5+
6+
matestack_layout Demo::Core::Layout
7+
8+
def first
9+
render Demo::Core::Pages::FirstPage
10+
end
11+
12+
def second
13+
render Demo::Core::Pages::SecondPage
14+
end
15+
16+
end

spec/dummy/app/controllers/demo_controller.rb renamed to spec/dummy/app/controllers/demo_vue_js_controller.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
class DemoController < ActionController::Base
1+
class DemoVueJsController < ActionController::Base
22
include Matestack::Ui::Core::Helper
33

4-
matestack_app Demo::App
4+
layout "application_vue_js"
5+
matestack_layout Demo::VueJs::Layout
56

67
def first
7-
render Demo::Pages::FirstPage
8-
# render html: Demo::Components::StaticComponent.call(foo: "bar"), layout: 'application'
8+
render Demo::VueJs::Pages::FirstPage
99
end
1010

1111
def second
12-
render Demo::Pages::SecondPage
12+
render Demo::VueJs::Pages::SecondPage
1313
end
1414

1515
def ssr_call
16-
ActionCable.server.broadcast("matestack_ui_core", {
16+
ActionCable.server.broadcast("matestack_ui_vue_js", {
1717
event: "some_server_event",
18-
data: Demo::Components::StaticComponent.call(foo: "bar from server")
18+
data: Demo::VueJs::Components::StaticComponent.call(foo: "bar from server")
1919
})
2020
end
2121

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import consumer from "./consumer"
2-
import MatestackUiCore from 'matestack-ui-core'
2+
import MatestackUiVueJs from 'matestack-ui-vue_js'
33

4-
consumer.subscriptions.create("MatestackUiCoreChannel", {
4+
consumer.subscriptions.create("MatestackUiVueJsChannel", {
55
connected() {
66
console.log('connected')
77
// Called when the subscription is ready for use on the server
@@ -12,7 +12,6 @@ consumer.subscriptions.create("MatestackUiCoreChannel", {
1212
},
1313

1414
received(data) {
15-
console.log('received data')
16-
MatestackUiCore.matestackEventHub.$emit(data.event, data)
15+
MatestackUiVueJs.eventHub.$emit(data.event, data)
1716
}
1817
});

spec/dummy/app/javascript/js/components.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//used in specs!
22

3-
import MatestackUiCore from 'matestack-ui-core'
3+
import MatestackUiVueJs from 'matestack-ui-vue_js'
44

55
const testComponent = {
6-
mixins: [MatestackUiCore.componentMixin],
7-
template: MatestackUiCore.componentHelpers.inlineTemplate,
6+
mixins: [MatestackUiVueJs.componentMixin],
7+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
88
data: function data() {
99
return {
1010
dynamic_value: "foo",
@@ -13,23 +13,23 @@ const testComponent = {
1313
},
1414
methods:{
1515
emitMessage: function(event_name, message){
16-
MatestackUiCore.eventHub.$emit(event_name, message)
16+
MatestackUiVueJs.eventHub.$emit(event_name, message)
1717
}
1818
},
1919
mounted(){
2020
const self = this
2121
setTimeout(function () {
2222
self.dynamic_value = "test-component: bar"
2323
}, 300);
24-
MatestackUiCore.eventHub.$on("some_external_event", function(data){
24+
MatestackUiVueJs.eventHub.$on("some_external_event", function(data){
2525
self.received_message = data;
2626
})
2727
}
2828
};
2929

3030
const myTestComponent = {
31-
mixins: [MatestackUiCore.componentMixin],
32-
template: MatestackUiCore.componentHelpers.inlineTemplate,
31+
mixins: [MatestackUiVueJs.componentMixin],
32+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
3333
data: function data() {
3434
return {
3535
dynamic_value: "foo"
@@ -44,8 +44,8 @@ const myTestComponent = {
4444
};
4545

4646
const customFormInputComponent = {
47-
mixins: [MatestackUiCore.componentMixin, MatestackUiCore.formInputMixin],
48-
template: MatestackUiCore.componentHelpers.inlineTemplate,
47+
mixins: [MatestackUiVueJs.componentMixin, MatestackUiVueJs.formInputMixin],
48+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
4949
data() {
5050
return {};
5151
},
@@ -70,8 +70,8 @@ const customFormInputComponent = {
7070
};
7171

7272
const customFormTextareaComponent = {
73-
mixins: [MatestackUiCore.componentMixin, MatestackUiCore.formTextareaMixin],
74-
template: MatestackUiCore.componentHelpers.inlineTemplate,
73+
mixins: [MatestackUiVueJs.componentMixin, MatestackUiVueJs.formTextareaMixin],
74+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
7575
data() {
7676
return {};
7777
},
@@ -93,8 +93,8 @@ const customFormTextareaComponent = {
9393
};
9494

9595
const customFormRadioComponent = {
96-
mixins: [MatestackUiCore.componentMixin, MatestackUiCore.formRadioMixin],
97-
template: MatestackUiCore.componentHelpers.inlineTemplate,
96+
mixins: [MatestackUiVueJs.componentMixin, MatestackUiVueJs.formRadioMixin],
97+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
9898
data() {
9999
return {};
100100
},
@@ -116,8 +116,8 @@ const customFormRadioComponent = {
116116
};
117117

118118
const customFormCheckboxComponent = {
119-
mixins: [MatestackUiCore.componentMixin, MatestackUiCore.formCheckboxMixin],
120-
template: MatestackUiCore.componentHelpers.inlineTemplate,
119+
mixins: [MatestackUiVueJs.componentMixin, MatestackUiVueJs.formCheckboxMixin],
120+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
121121
data() {
122122
return {};
123123
},
@@ -139,8 +139,8 @@ const customFormCheckboxComponent = {
139139
};
140140

141141
const customFormSelectComponent = {
142-
mixins: [MatestackUiCore.componentMixin, MatestackUiCore.formSelectMixin],
143-
template: MatestackUiCore.componentHelpers.inlineTemplate,
142+
mixins: [MatestackUiVueJs.componentMixin, MatestackUiVueJs.formSelectMixin],
143+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
144144
data() {
145145
return {};
146146
},

spec/dummy/app/javascript/packs/application.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@ require("@rails/ujs").start()
1111
require("channels")
1212

1313
import { createApp } from 'vue'
14-
import MatestackUiCore from 'matestack-ui-core'
15-
16-
//for specs only
17-
window.MatestackUiCore = MatestackUiCore // making MatestackUiCore globally available for test compatability
18-
// MatestackUiCore.Vue = Vue // test compatability
19-
import registerCustomComponents from '../js/components' //for specs only
20-
//for specs only
14+
import MatestackUiVueJs from 'matestack-ui-vue_js'
2115

2216
const appInstance = createApp({})
2317

24-
registerCustomComponents(appInstance) //for specs only
25-
2618
document.addEventListener('DOMContentLoaded', () => {
27-
MatestackUiCore.mount(appInstance, '#matestack-ui')
19+
MatestackUiVueJs.mount(appInstance)
2820
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint no-console:0 */
2+
// This file is automatically compiled by Webpack, along with any other files
3+
// present in this directory. You're encouraged to place your actual application logic in
4+
// a relevant structure within app/javascript and only use these pack files to reference
5+
// that code so it'll be compiled.
6+
//
7+
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8+
// layout file, like app/views/layouts/application.html.erb
9+
10+
// require("@rails/ujs").start()
11+
// require("channels")

0 commit comments

Comments
 (0)