3 |
4 | {{ yield }}
--------------------------------------------------------------------------------
/spec/apps/kitchen_sink/config.ru:
--------------------------------------------------------------------------------
1 | # Run via rack server
2 | require 'bundler/setup'
3 | require 'volt/server'
4 | run Volt::Server.new.app
5 |
--------------------------------------------------------------------------------
/spec/apps/kitchen_sink/config/app.rb:
--------------------------------------------------------------------------------
1 | Volt.setup do |config|
2 | config.app_secret = 'vFYUzMiPIdMw1Iox0ggDpBYorLm_d55YtRPc0eGrdCpoN4h9E5FcWySIT_D8JIEOllU'
3 | end
4 |
--------------------------------------------------------------------------------
/spec/apps/kitchen_sink/config/base/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | <%= javascript_tags %>
6 |
7 | <%= css_tags %>
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/spec/controllers/model_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | if RUBY_PLATFORM != 'opal'
4 | describe Volt::ModelController do
5 | it 'should accept a promise as a model and resolve it' do
6 | controller = Volt::ModelController.new(volt_app)
7 |
8 | promise = Promise.new
9 |
10 | controller.model = promise
11 |
12 | expect(controller.model).to eq(nil)
13 |
14 | promise.resolve(20)
15 |
16 | expect(controller.model).to eq(20)
17 | end
18 |
19 | it 'should not return true from loaded until the promise is resolved' do
20 | controller = Volt::ModelController.new(volt_app)
21 |
22 | promise = Promise.new
23 | controller.model = promise
24 |
25 | expect(controller.loaded?).to eq(false)
26 |
27 | promise.resolve(Volt::Model.new)
28 | expect(controller.loaded?).to eq(true)
29 | end
30 |
31 | it 'should provide a u method that disables reactive updates' do
32 | expect(Volt::Computation).to receive(:run_without_tracking)
33 |
34 | controller = Volt::ModelController.new(volt_app)
35 | controller.u { 5 }
36 | end
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/spec/controllers/reactive_accessors_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/reactive/reactive_accessors'
3 |
4 | class TestReactiveAccessors
5 | include Volt::ReactiveAccessors
6 |
7 | reactive_accessor :_name
8 | end
9 |
10 | describe Volt::ReactiveAccessors do
11 | it 'should assign a reactive value' do
12 | inst = TestReactiveAccessors.new
13 |
14 | inst._name = 'Ryan'
15 | expect(inst._name).to eq('Ryan')
16 | end
17 |
18 | it 'should start nil' do
19 | inst = TestReactiveAccessors.new
20 |
21 | expect(inst._name).to eq(nil)
22 | end
23 |
24 | it 'should trigger changed when assigning a new value' do
25 | inst = TestReactiveAccessors.new
26 | values = []
27 |
28 | -> { values << inst._name }.watch!
29 |
30 | expect(values).to eq([nil])
31 |
32 | inst._name = 'Ryan'
33 | Volt::Computation.flush!
34 | expect(values).to eq([nil, 'Ryan'])
35 |
36 | inst._name = 'Stout'
37 | Volt::Computation.flush!
38 | expect(values).to eq([nil, 'Ryan', 'Stout'])
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/spec/extra_core/array_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/extra_core/array'
3 |
4 | describe Array do
5 | describe '#sum' do
6 | it 'calculates sum of array of integers' do
7 | expect([1, 2, 3].sum).to eq(6)
8 | end
9 | end
10 |
11 | describe "#to_sentence" do
12 | it 'should return an empty string' do
13 | expect([].to_sentence).to eq('')
14 | end
15 |
16 | it 'should return a single entry' do
17 | expect([1].to_sentence).to eq('1')
18 | end
19 |
20 | it 'should combine an array into a string with a conjunection and commas' do
21 | expect([1,2,3].to_sentence).to eq('1, 2, and 3')
22 | end
23 |
24 | it 'should allow you to build an incorrect sentence' do
25 | expect([1,2,3].to_sentence(oxford: false)).to eq('1, 2 and 3')
26 | end
27 |
28 | it 'let you change the conjunction' do
29 | expect([1,2,3].to_sentence(conjunction: 'or')).to eq('1, 2, or 3')
30 | end
31 |
32 | it 'let you change the comma' do
33 | expect([1,2,3].to_sentence(comma: '!')).to eq('1! 2! and 3')
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/spec/extra_core/blank_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'blank' do
4 | it 'should report blank when blank' do
5 | expect(' '.blank?).to eq(true)
6 | end
7 |
8 | it 'should report not blank when not blank' do
9 | expect(' text '.blank?).to eq(false)
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/extra_core/class_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/extra_core/array'
3 |
4 | class TestClassAttributes
5 | class_attribute :some_data
6 | class_attribute :attr2
7 | end
8 |
9 | class TestSubClassAttributes < TestClassAttributes
10 | end
11 |
12 | class TestSubClassAttributes2 < TestClassAttributes
13 | end
14 |
15 | describe 'extra_core class addons' do
16 | it 'should provide class_attributes that can be inherited' do
17 | expect(TestClassAttributes.some_data).to eq(nil)
18 |
19 | TestClassAttributes.some_data = 5
20 | expect(TestClassAttributes.some_data).to eq(5)
21 | expect(TestSubClassAttributes.some_data).to eq(5)
22 | expect(TestSubClassAttributes2.some_data).to eq(5)
23 |
24 | TestSubClassAttributes.some_data = 10
25 | expect(TestClassAttributes.some_data).to eq(5)
26 | expect(TestSubClassAttributes.some_data).to eq(10)
27 | expect(TestSubClassAttributes2.some_data).to eq(5)
28 |
29 | TestSubClassAttributes2.some_data = 15
30 | expect(TestClassAttributes.some_data).to eq(5)
31 | expect(TestSubClassAttributes.some_data).to eq(10)
32 | expect(TestSubClassAttributes2.some_data).to eq(15)
33 | end
34 |
35 | it 'should let you change a class attribute on the child without affecting the parent' do
36 | TestClassAttributes.attr2 = 1
37 | expect(TestSubClassAttributes.attr2).to eq(1)
38 |
39 | TestSubClassAttributes.attr2 = 2
40 | expect(TestClassAttributes.attr2).to eq(1)
41 | expect(TestSubClassAttributes.attr2).to eq(2)
42 | expect(TestSubClassAttributes2.attr2).to eq(1)
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/spec/extra_core/hash_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Hash do
4 | it 'should return a hash without the speicified keys' do
5 | a = {one: 1, two: 2, three: 3}
6 |
7 | expect(a.without(:one, :three)).to eq({two: 2})
8 | end
9 | end
--------------------------------------------------------------------------------
/spec/extra_core/inflector_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/extra_core/inflector'
3 |
4 | describe Volt::Inflector do
5 | it 'should pluralize correctly' do
6 | expect('car'.pluralize).to eq('cars')
7 | # expect('database'.pluralize).to eq('database')
8 | end
9 |
10 | it 'should singularize correctly' do
11 | expect('cars'.singularize).to eq('car')
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/extra_core/object_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/extra_core/blank'
3 |
4 | describe Object do
5 | it 'should add blank? to all objects' do
6 | expect(Object.new.blank?).to eq(false)
7 | expect(nil.blank?).to eq(true)
8 | end
9 |
10 | it 'should add present? to all objects' do
11 | expect(Object.new.present?).to eq(true)
12 | expect(nil.present?).to eq(false)
13 | end
14 |
15 | it 'should allow you to call .then to get a Promise with the object resolved' do
16 | promise = 5.then
17 |
18 | expect(promise.resolved?).to eq(true)
19 | expect(promise.value).to eq(5)
20 | end
21 |
22 | it 'should allow you to call .then with a block that will yield the promise' do
23 | 5.then do |val|
24 | expect(val).to eq(5)
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/spec/extra_core/string_transformation_test_cases.rb:
--------------------------------------------------------------------------------
1 | CamelToUnderscore = {
2 | 'Product' => 'product',
3 | 'SpecialGuest' => 'special_guest',
4 | 'ApplicationController' => 'application_controller',
5 | 'Area51Controller' => 'area51_controller'
6 | }
7 |
8 | UnderscoreToLowerCamel = {
9 | 'product' => 'product',
10 | 'special_guest' => 'specialGuest',
11 | 'application_controller' => 'applicationController',
12 | 'area51_controller' => 'area51Controller'
13 | }
14 |
15 | UnderscoresToDashes = {
16 | 'street' => 'street',
17 | 'street_address' => 'street-address',
18 | 'person_street_address' => 'person-street-address'
19 | }
20 |
21 | UnderscoresToHeaders = {
22 | 'proxy_authenticate' => 'Proxy-Authenticate',
23 | 'set_cookie' => 'Set-Cookie',
24 | 'set-cookie' => 'Set-Cookie',
25 | 'via' => 'Via',
26 | 'WWW_Authenticate' => 'WWW-Authenticate'
27 | }
28 |
--------------------------------------------------------------------------------
/spec/extra_core/symbol_spec.rb:
--------------------------------------------------------------------------------
1 | if RUBY_PLATFORM == 'opal'
2 | else
3 | require 'spec_helper'
4 | require 'volt/extra_core/symbol'
5 |
6 | describe Symbol do
7 | it 'should pluralize correctly' do
8 | expect(:car.pluralize).to eq(:cars)
9 | end
10 |
11 | it 'should singularize correctly' do
12 | expect(:cars.singularize).to eq(:car)
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/helpers/distance_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/helpers/time'
3 |
4 | describe Volt::Duration do
5 | it 'should return a sentence describing the time' do
6 | dist = 1.hour + 2.days + 1.month + 305.seconds + 1.5.days
7 |
8 | expect(dist.duration_in_words(nil, :seconds)).to eq('1 month, 3 days, 13 hours, 5 minutes, and 5 seconds')
9 | end
10 |
11 | it 'should show a recent_message and' do
12 | expect(0.seconds.duration_in_words).to eq('just now')
13 | expect(1.minute.duration_in_words).to eq('1 minute')
14 | expect(0.seconds.duration_in_words(nil)).to eq('just now')
15 | end
16 |
17 | it 'should trim to the unit count' do
18 | dist = 1.hour + 2.days + 1.month + 305.seconds + 1.5.days
19 | expect(dist.duration_in_words(3)).to eq('1 month, 3 days, and 13 hours')
20 | expect(dist.duration_in_words(2)).to eq('1 month and 3 days')
21 | end
22 |
23 | it 'should return distance in words' do
24 | time1 = (1.hours + 5.minutes).ago
25 | expect(time1.time_distance_in_words).to eq('1 hour and 5 minutes ago')
26 |
27 | time2 = VoltTime.now
28 | time3 = time2 - (3.hours + 1.day + 2.seconds)
29 |
30 | expect(time3.time_distance_in_words(time2, nil, :seconds)).to eq('1 day, 3 hours, and 2 seconds ago')
31 |
32 | time4 = 1.second.ago
33 | expect(time4.time_distance_in_words).to eq('just now')
34 | end
35 | end
--------------------------------------------------------------------------------
/spec/integration/callbacks_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'lifecycle callbacks', type: :feature, sauce: true do
4 |
5 | context 'with a user' do
6 | before do
7 | # Add the user
8 | store._users! << { email: 'test@test.com', password: 'awes0mesEcRet', name: 'Test Account 9550' }
9 | end
10 |
11 | it 'should trigger a user_connect event when a user logs in and a user_disconnect event when a user logs out' do
12 | visit '/'
13 |
14 | click_link 'Login'
15 |
16 | fields = all(:css, 'form .form-control')
17 | fields[0].set('test@test.com')
18 | fields[1].set('awes0mesEcRet')
19 | click_button 'Login'
20 |
21 | visit '/callbacks'
22 |
23 | expect(page).to have_content('user_connect')
24 |
25 | click_link 'Test Account 9550'
26 | click_link 'Logout'
27 |
28 | # TODO: This part of the spec fails for some reason.
29 | # expect(page).to have_content('user_disconnect')
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/spec/integration/client_require_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'client require', type: :feature, sauce: true do
4 | it 'should require code in controllers' do
5 | visit '/require_test'
6 |
7 | expect(page).to have_content('Date Class: true')
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/spec/integration/cookies_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'cookies collection', type: :feature, sauce: true do
4 | if ENV['BROWSER'] != 'phantom'
5 | # TODO: fails in phantom for some reason
6 | it 'should add' do
7 | visit '/'
8 |
9 | click_link 'Cookies'
10 |
11 | fill_in('cookieName', with: 'one')
12 | fill_in('cookieValue', with: 'one')
13 | click_button 'Add Cookie'
14 |
15 | expect(page).to have_content('one: one')
16 |
17 | # Reload the page
18 | page.evaluate_script('document.location.reload()')
19 |
20 | # Check again
21 | expect(page).to have_content('one: one')
22 | end
23 | end
24 |
25 | it 'should delete cookies' do
26 | visit '/'
27 |
28 | click_link 'Cookies'
29 |
30 | fill_in('cookieName', with: 'two')
31 | fill_in('cookieValue', with: 'two')
32 | click_button 'Add Cookie'
33 |
34 | expect(page).to have_content('two: two')
35 |
36 | find('.cookieDelete').click
37 |
38 | expect(page).to_not have_content('two: two')
39 |
40 | # Reload the page
41 | page.evaluate_script('document.location.reload()')
42 |
43 | expect(page).to_not have_content('two: two')
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/spec/integration/event_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'events and bubbling', type: :feature, sauce: true do
4 | it 'should bubble events through the dom' do
5 | visit '/events'
6 |
7 | click_button 'Run Some Event'
8 |
9 | expect(page).to have_content('ran some_event')
10 | end
11 |
12 | it 'should let you specify an e- handler on components' do
13 | visit '/events'
14 |
15 | click_button 'Run Other Event'
16 |
17 | expect(page).to have_content('ran other_event')
18 | end
19 | end
--------------------------------------------------------------------------------
/spec/integration/first_last_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'first, last', type: :feature, sauce: true do
4 | # Currently failing, fixing
5 | # it 'should render first with a number argument' do
6 | # store._messages << {body: 'hey, sup?'}
7 | # store._messages << {body: 'not much'}
8 | # store._messages << {body: 'you?'}
9 | # store._messages << {body: 'just being awesome?'}
10 | # store._messages << {body: 'writing some specs'}
11 | #
12 | # visit '/first_last'
13 | # end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/integration/flash_spec.rb:
--------------------------------------------------------------------------------
1 | # This spec fails on sauce randomly, disable for now
2 | if ENV['BROWSER'] && ENV['BROWSER'] != 'sauce'
3 | require 'spec_helper'
4 |
5 | describe 'flash messages', type: :feature, sauce: true do
6 | it 'should flash on sucesses, notices, warnings, and errors' do
7 | visit '/'
8 |
9 | click_link 'Flash'
10 |
11 | click_link 'Flash Notice'
12 | expect(page).to have_content('A notice message')
13 | # sleep 40
14 | find('.alert').click
15 | expect(page).to_not have_content('A notice message')
16 |
17 | click_link 'Flash Success'
18 | expect(page).to have_content('A success message')
19 | find('.alert').click
20 | expect(page).to_not have_content('A success message')
21 |
22 | click_link 'Flash Warning'
23 | expect(page).to have_content('A warning message')
24 | find('.alert').click
25 | expect(page).to_not have_content('A warning message')
26 |
27 | click_link 'Flash Error'
28 | expect(page).to have_content('An error message')
29 | find('.alert').click
30 | expect(page).to_not have_content('An error message')
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/spec/integration/http_endpoints_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'http endpoints', type: :feature, sauce: true do
4 | it 'should show the page' do
5 | visit '/simple_http'
6 | expect(page).to have_content('this is just some text')
7 | end
8 |
9 | it 'should have access to the store' do
10 | store._simple_http_tests << { name: 'hello' }
11 | visit '/simple_http/store'
12 | expect(page).to have_content('You had me at hello')
13 | end
14 |
15 | it 'should upload and store a file' do
16 | file = 'tmp/uploaded_file'
17 | FileUtils.rm(file) if File.exist?(file)
18 | visit '/upload'
19 | attach_file('file', __FILE__)
20 | find('#submit_file_upload').click
21 | expect(page).to have_content('successfully uploaded')
22 | expect(File.exist?(file)).to be(true)
23 | FileUtils.rm(file) if File.exist?(file)
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/spec/integration/images_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'image loading', type: :feature, sauce: true do
4 | it 'should load images in assets' do
5 | visit '/images'
6 |
7 | loaded = page.evaluate_script("$('img').get(0).complete")
8 | expect(loaded).to eq(true)
9 | end
10 | end
--------------------------------------------------------------------------------
/spec/integration/missing_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe "missing tags and view's", type: :feature do
4 | it 'should show a message about the missing tag/view' do
5 | visit '/missing'
6 |
7 | expect(page).to have_content('view or tag at "some/wrong/path"')
8 | expect(page).to have_content('view or tag at "not/a/component"')
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/integration/raw_html_binding.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'HTML safe/raw', type: :feature do
4 | it 'should render html with the raw helper' do
5 | visit '/html_safe'
6 |
7 | expect(page).to have_selector('button[id="examplebutton"]')
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/spec/integration/save_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'saving', type: :feature, sauce: true do
4 | it 'should return an error as an instance of Volt::Error' do
5 | visit '/save'
6 |
7 | fill_in 'post_title', with: 'ok'
8 |
9 | click_button 'Save'
10 |
11 | expect(page).to have_content('#["must be at least 5 characters"]}>')
12 | end
13 | end
--------------------------------------------------------------------------------
/spec/integration/store_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | # describe 'store', type: :feature, sauce: true do
4 | # it 'should sync between nested root properties on store' do
5 | # visit '/store'
6 |
7 | # fill_in('field1', with: 'should sync')
8 | # expect(find('#field2').value).to eq('should sync')
9 | # end
10 | # end
--------------------------------------------------------------------------------
/spec/integration/templates_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'bindings test', type: :feature, sauce: true do
4 | it 'should change the title when changing pages' do
5 | visit '/'
6 |
7 | expect(page).to have_title 'KitchenSink - KitchenSink'
8 | click_link 'Bindings'
9 |
10 | expect(page).to have_title 'Bindings - KitchenSink'
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/integration/todos_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'todos app', type: :feature, sauce: true do
4 | ENTER_KEY = ENV["BROWSER"] == 'phantom' ? :Enter : :return
5 | it 'should add a todo and remove it' do
6 | visit '/todos'
7 | store._todos
8 |
9 | fill_in 'newtodo', with: 'Todo 1'
10 | find('#newtodo').native.send_keys(ENTER_KEY)
11 |
12 | expect(page).to have_content('Todo 1')
13 |
14 | expect(find('#newtodo').value).to eq('')
15 |
16 | click_button 'X'
17 |
18 | expect(page).to_not have_content('Todo 1')
19 |
20 | # Make sure it deleted
21 | if ENV['BROWSER'] == 'phantom'
22 | visit '/todos'
23 | else
24 | page.driver.browser.navigate.refresh
25 | end
26 | expect(page).to_not have_content('Todo 1')
27 | end
28 |
29 | it 'should update a todo check state and persist' do
30 | visit '/todos'
31 | store._todos
32 |
33 | fill_in 'newtodo', with: 'Todo 1'
34 | find('#newtodo').native.send_keys(ENTER_KEY)
35 |
36 | expect(page).to have_content('Todo 1')
37 |
38 | find("input[type='checkbox']").click
39 |
40 | if ENV['BROWSER'] == 'phantom'
41 | visit '/todos'
42 | else
43 | page.evaluate_script('document.location.reload()')
44 | end
45 |
46 | expect(find("input[type='checkbox']").checked?).to eq(true)
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/spec/integration/url_spec.rb:
--------------------------------------------------------------------------------
1 | if ENV['BROWSER'] && ENV['BROWSER'] != 'phantom'
2 | require 'spec_helper'
3 |
4 | describe 'url features', type: :feature, sauce: true do
5 | it 'should update the page when using the back button' do
6 | visit '/'
7 | expect(current_url).to match(/\/$/)
8 |
9 | click_link 'Bindings'
10 | expect(current_url).to match(/\/bindings$/)
11 | expect(page).to have_content('Checkbox')
12 |
13 | click_link 'Todos'
14 | expect(current_url).to match(/\/todos$/)
15 | expect(page).to have_content('Todos Example')
16 |
17 | # "Click" back button
18 | page.evaluate_script('window.history.back()')
19 |
20 | click_link 'Bindings'
21 | expect(current_url).to match(/\/bindings$/)
22 | expect(page).to have_content('Checkbox')
23 |
24 | # "Click" back button
25 | page.evaluate_script('window.history.back()')
26 |
27 | expect(current_url).to match(/\/$/)
28 | end
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/spec/integration/yield_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'yield binding', type: :feature, sauce: true do
4 | before do
5 | visit '/yield'
6 | end
7 |
8 | it 'should render the yielded content multiple times' do
9 | expect(page).to have_content('My yielded content 1')
10 | expect(page).to have_content('My yielded content 2')
11 | end
12 |
13 | it 'should render the content from the tag\'s controller when yielding' do
14 | expect(page).to have_content('This is my content')
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/models/helpers/base_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Volt::Models::Helpers::Base do
4 | # it 'should have a root method on models that returns the root collection' do
5 | # model = store._posts.create
6 | # expect(model.root).to eq(store)
7 | # end
8 | end
--------------------------------------------------------------------------------
/spec/models/helpers/model_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Volt::Models::Helpers::Model do
4 | describe "saved_state" do
5 | it 'should start not_saved for a buffer' do
6 | item = the_page._items.buffer
7 | expect(item.saved_state).to eq(:not_saved)
8 | end
9 |
10 | it 'should move to saved when the buffer is saved' do
11 | item = the_page._items.buffer
12 | item.save!.then do
13 | expect(item.saved_state).to eq(:saved)
14 | end
15 | end
16 |
17 | it 'should start as saved after create' do
18 | item = the_page._items.create({name: 'One'})
19 |
20 | expect(item.saved_state).to eq(:saved)
21 | end
22 |
23 | # TODO: because server side model loading is done synchronusly, we can't
24 | # test the
25 | end
26 | end
--------------------------------------------------------------------------------
/spec/models/model_state_spec.rb:
--------------------------------------------------------------------------------
1 | # Models automatically unload if no dependencies are listening and they have not been .keep (kept)
2 |
3 | if RUBY_PLATFORM != 'opal'
4 | require 'spec_helper'
5 |
6 | describe Volt::Model do
7 | it 'should stay loaded while a computaiton is watching some data' do
8 | expect(store._items!.loaded_state).to eq(:not_loaded)
9 |
10 | comp = -> { store._items.size }.watch!
11 |
12 | # On the server models do a blocking load
13 | expect(store._items.loaded_state).to eq(:loaded)
14 |
15 | comp.stop
16 |
17 | Volt::Timers.flush_next_tick_timers!
18 |
19 | # Computation stopped listening, so the collection should unload and be set to
20 | # a dirty state
21 | expect(store._items.loaded_state).to eq(:dirty)
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/spec/models/persistors/flash_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | module Volt
4 | module Persistors
5 | describe Flash do
6 | let(:fake_parent) { double('Parent', delete: true) }
7 | let(:fake_passed_model) { double }
8 |
9 | let(:fake_model) do
10 | double(
11 | 'Model',
12 | size: 1,
13 | parent: fake_parent,
14 | path: '12',
15 | delete: true
16 | )
17 | end
18 |
19 | describe '#added' do
20 | it 'returns nil' do
21 | flash = described_class.new double
22 |
23 | expect(flash.added(double, 0)).to be_nil
24 | end
25 | end
26 |
27 | describe '#clear_model' do
28 | it 'sends #delete to @model' do
29 | described_class.new(fake_model).clear_model fake_passed_model
30 |
31 | expect(fake_model).to have_received(:delete).with(fake_passed_model)
32 | end
33 |
34 | it 'with a size of zero, parent receives #delete' do
35 | collection_name = fake_model.path[-1]
36 | allow(fake_model).to receive(:size).and_return 0
37 |
38 | described_class.new(fake_model).clear_model fake_passed_model
39 |
40 | expect(fake_parent).to have_received(:delete).with(collection_name)
41 | end
42 | end
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/spec/models/persistors/page_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | module Volt
4 | module Persistors
5 | describe Page do
6 | describe '#where' do
7 | it 'searches for records in the page collection with the given values' do
8 | juan = Volt::Model.new(name: 'Juan', city: 'Quito', age: 13)
9 | pedro = Volt::Model.new(name: 'Pedro', city: 'Quito', age: 15)
10 | jose = Volt::Model.new(name: 'Jose', city: 'Quito', age: 13)
11 |
12 | page = described_class.new [jose, juan, pedro]
13 |
14 | expect(page.where age: 13, city: 'Quito').to match_array [juan, jose]
15 | end
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/models/persistors/params_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/models'
3 |
4 | describe Volt::Persistors::Params do
5 | it 'should stay as params classes when used' do
6 | a = Volt::Model.new({}, persistor: Volt::Persistors::Params)
7 | # expect(a._test!.class).to eq(Volt::Model)
8 | #
9 | # expect(a._test!._cool!.persistor.class).to eq(Volt::Persistors::Params)
10 |
11 | a._items << { name: 'Test' }
12 | #
13 | # expect(a._items.persistor.class).to eq(Volt::Persistors::Params)
14 | # expect(a._items[0].persistor.class).to eq(Volt::Persistors::Params)
15 | # expect(a._items[0]._name!.class).to eq(String)
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/models/user_validation_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | class TestUserTodo < Volt::Model
4 | own_by_user
5 |
6 | permissions(:update) do
7 | deny :user_id
8 | end
9 | end
10 |
11 | describe Volt::UserValidatorHelpers do
12 | context 'with user' do
13 | before do
14 | allow(Volt).to receive(:current_user_id) { 294 }
15 | end
16 |
17 | it 'should assign user_id when owning by a user' do
18 | todo = TestUserTodo.new
19 | expect(todo._user_id).to eq(294)
20 | end
21 |
22 | it 'should not allow the user_id to be changed' do
23 | todo = TestUserTodo.new
24 | expect(todo._user_id).to eq(294)
25 |
26 | todo._user_id = 500
27 |
28 | expect(todo._user_id).to eq(294)
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/spec/models/validators/block_validations_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | unless RUBY_PLATFORM == 'opal'
4 | describe 'validations block' do
5 | let(:model) { test_model_class.new }
6 |
7 | let(:test_model_class) do
8 | Class.new(Volt::Model) do
9 | validations do
10 | if _is_ready == true
11 | validate :name, length: 5
12 | end
13 | end
14 | end
15 | end
16 |
17 | let(:test_model_action_pass_class) do
18 | Class.new(Volt::Model) do
19 | validations do |action|
20 | # Only validation the name on update
21 | if action == :update
22 | validate :name, length: 5
23 | end
24 | end
25 | end
26 | end
27 |
28 | it 'should run conditional validations in the validations block' do
29 | a = test_model_class.new(name: 'Jo')
30 |
31 | a.validate!.sync
32 | expect(a.errors.size).to eq(0)
33 |
34 | a._is_ready = true
35 | a.validate!.sync
36 |
37 | expect(a.errors.size).to eq(1)
38 | end
39 |
40 | it 'should send the action name to the validations block' do
41 | jo = test_model_action_pass_class.new(name: 'Jo')
42 |
43 | jo.validate!.sync
44 | expect(jo.errors.size).to eq(0)
45 |
46 | store._people << jo
47 |
48 | jo.validate!.sync
49 | expect(jo.errors.size).to eq(1)
50 |
51 | end
52 | end
53 | end
--------------------------------------------------------------------------------
/spec/models/validators/unique_validator_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | unless RUBY_PLATFORM == 'opal'
4 | class Fridge < Volt::Model
5 | validate :name, unique: true
6 | end
7 |
8 | describe 'unique spec' do
9 | it 'should reject save if there are records with existing attributes already' do
10 | store._fridges << { name: 'swift' }
11 | fridge = store._fridges.buffer name: 'swift'
12 | fridge.save!.then do
13 | expect(false).to be_true
14 | end.fail do
15 | expect(true).to be_true
16 | end
17 | end
18 |
19 | it 'should not increase count of the total records in the store' do
20 | store._fridges << { name: 'swift' }
21 | store._fridges << { name: 'swift' }
22 | expect(store._fridges.count.sync).to eq(1)
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/spec/page/bindings/content_binding_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/page/bindings/content_binding'
3 | require 'volt/page/targets/attribute_target'
4 | require 'volt/page/targets/dom_section'
5 | require 'volt/page/template_renderer'
6 |
7 | describe Volt::ContentBinding do
8 | it 'should render the content in a content binding' do
9 | dom = Volt::AttributeTarget.new(0)
10 | context = { name: 'jimmy' }
11 | binding = Volt::ContentBinding.new(nil, dom, context, 0, proc { self[:name] })
12 |
13 | expect(dom.to_html).to eq('jimmy')
14 | end
15 |
16 | it 'should render with a template' do
17 | context = { name: 'jimmy' }
18 | binding = ->(volt_app, target, context, id) { Volt::ContentBinding.new(volt_app, target, context, id, proc { self[:name] }) }
19 |
20 | templates = {
21 | 'main/main' => {
22 | 'html' => 'hello ',
23 | 'bindings' => { 1 => [binding] }
24 | }
25 | }
26 |
27 | volt_app = double('volt/app')
28 | expect(volt_app).to receive(:templates).and_return(templates)
29 |
30 |
31 |
32 | dom = Volt::AttributeTarget.new(0)
33 |
34 | Volt::TemplateRenderer.new(volt_app, dom, context, 'main', 'main/main')
35 |
36 | expect(dom.to_html).to eq('hello jimmy')
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/spec/page/bindings/if_binding_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | class ::TestIfBindingController < Volt::ModelController
4 | model :page
5 | end
6 |
7 | describe Volt::IfBinding do
8 | it 'should render an if' do
9 | dom = Volt::AttributeTarget.new(0)
10 | context = ::TestIfBindingController.new(volt_app)
11 | context._name = 'jimmy'
12 |
13 | branches = [
14 | [
15 | proc { _name == 'jimmy' },
16 | 'main/if_true'
17 | ],
18 | [
19 | nil,
20 | 'main/if_false'
21 | ]
22 | ]
23 |
24 | binding = ->(volt_app, target, context, id) do
25 | Volt::IfBinding.new(volt_app, target, context, 0, branches)
26 | end
27 |
28 | templates = {
29 | 'main/main' => {
30 | 'html' => 'hello ',
31 | 'bindings' => { 1 => [binding] }
32 | },
33 | 'main/if_true' => {
34 | 'html' => 'yes, true',
35 | 'bindings' => {}
36 | },
37 | 'main/if_false' => {
38 | 'html' => 'no, false',
39 | 'bindings' => {}
40 | }
41 | }
42 |
43 | volt_app = double('volt/app')
44 | expect(volt_app).to receive(:templates).and_return(templates).at_least(1).times
45 |
46 | Volt::TemplateRenderer.new(volt_app, dom, context, 'main', 'main/main')
47 |
48 | expect(dom.to_html).to eq('yes, true')
49 |
50 | context._name = 'bob'
51 | Volt::Computation.flush!
52 | expect(dom.to_html).to eq('no, false')
53 | end
54 | end
--------------------------------------------------------------------------------
/spec/page/bindings/template_binding_spec.rb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/spec/page/bindings/template_binding_spec.rb
--------------------------------------------------------------------------------
/spec/page/sub_context_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/page/sub_context'
3 |
4 | describe Volt::SubContext do
5 | it 'should respond_to correctly on locals' do
6 | sub_context = Volt::SubContext.new(name: 'Name')
7 |
8 | expect(sub_context.respond_to?(:name)).to eq(true)
9 | expect(sub_context.respond_to?(:missing)).to eq(false)
10 | end
11 |
12 | it 'should return correctly for missing methods on SubContext' do
13 | sub_context = Volt::SubContext.new(name: 'Name')
14 |
15 | expect(sub_context.send(:name)).to eq('Name')
16 | expect { sub_context.send(:missing) }.to raise_error(NoMethodError)
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/spec/reactive/class_eventable_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | class TestClassEventable
4 | include Volt::ClassEventable
5 |
6 | attr_reader :run_count
7 |
8 | def initialize
9 | @run_count = 0
10 | end
11 |
12 | on(:works) do
13 | ran_works
14 | end
15 |
16 | def ran_works
17 | @run_count += 1
18 | end
19 |
20 | def trigger_works_event!
21 | trigger!(:works, 20)
22 | end
23 | end
24 |
25 | describe Volt::ClassEventable do
26 | it 'does something' do
27 | test_ev = TestClassEventable.new
28 |
29 | expect(test_ev.run_count).to eq(0)
30 | test_ev.trigger_works_event!
31 |
32 | expect(test_ev.run_count).to eq(1)
33 | test_ev.trigger_works_event!
34 |
35 | expect(test_ev.run_count).to eq(2)
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/spec/reactive/reactive_hash_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Volt::ReactiveHash do
4 | it 'should clear' do
5 | a = Volt::ReactiveHash.new
6 | a[:name] = 'Bob'
7 |
8 | expect(a[:name]).to eq('Bob')
9 | a.clear
10 | expect(a[:name]).to eq(nil)
11 | end
12 |
13 | it 'should return to_json' do
14 | a = Volt::ReactiveHash.new({name: 'bob'})
15 | expect(a.to_json).to eq("{\"name\":\"bob\"}")
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/server/component_templates_spec.rb:
--------------------------------------------------------------------------------
1 | if RUBY_PLATFORM == 'opal'
2 | else
3 | require 'spec_helper'
4 | require 'benchmark'
5 | require 'volt/server/component_templates'
6 |
7 | describe Volt::ComponentTemplates do
8 | let(:haml_handler) do
9 | double(:haml_handler)
10 | end
11 |
12 | it 'can be extended' do
13 | expect( Volt::ComponentTemplates::Preprocessors.extensions ).to eq([ :html, :email ])
14 |
15 | Volt::ComponentTemplates.register_template_handler(:haml, haml_handler)
16 |
17 | expect( Volt::ComponentTemplates::Preprocessors.extensions ).to eq([ :html, :email, :haml ])
18 | end
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/spec/server/forking_server_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | unless RUBY_PLATFORM == 'opal'
3 | require 'volt/server'
4 |
5 | describe Volt::ForkingServer do
6 | it 'should set polling an an option when using POLL_FS env' do
7 | ENV['POLL_FS'] = 'true'
8 | forking_server = Volt::ForkingServer.allocate
9 |
10 | # Lots of stubs, since we're working with the FS
11 | listener = double('listener')
12 | expect(listener).to receive(:start)
13 | expect(listener).to receive(:stop)
14 | expect(Listen).to receive(:to).with('/app/', {force_polling: true}).and_return(listener)
15 | expect(forking_server).to receive(:sync_mod_time)
16 |
17 | server = double('server')
18 | expect(server).to receive(:app_path).and_return('/app')
19 | forking_server.instance_variable_set(:@server, server)
20 |
21 | forking_server.start_change_listener
22 | ENV.delete('POLL_FS')
23 |
24 | forking_server.stop_change_listener
25 | end
26 | end
27 | end
--------------------------------------------------------------------------------
/spec/server/html_parser/view_handler_spec.rb:
--------------------------------------------------------------------------------
1 | if RUBY_PLATFORM == 'opal'
2 | else
3 | require 'benchmark'
4 | require 'volt/server/html_parser/view_handler'
5 |
6 | describe Volt::ViewHandler do
7 | let(:handler) { Volt::ViewHandler.new('main/main/main') }
8 |
9 | it 'handles tags' do
10 | handler.comment('Yowza!')
11 | handler.start_tag('a', { href: 'yahoo.com' }, false)
12 | handler.text('Cool in 1996')
13 | handler.end_tag('a')
14 |
15 | expectation = 'Cool in 1996'
16 | expect(handler.html).to eq(expectation)
17 | end
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/spec/server/html_parser/view_scope_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Volt::ViewScope do
4 | describe "methodize strings" do
5 | def methodize(str)
6 | Volt::ViewScope.methodize_string(str)
7 | end
8 |
9 | it 'should methodize a method without args' do
10 | code = methodize('something')
11 | expect(code).to eq('method(:something)')
12 | end
13 |
14 | it 'should methodize a method without args2' do
15 | code = methodize('something?')
16 | expect(code).to eq('method(:something?)')
17 | end
18 |
19 | it 'should methodize a method wit args1' do
20 | code = methodize('set_something(true)')
21 | expect(code).to eq('set_something(true)')
22 | end
23 |
24 | it 'should not methodize a method call with args' do
25 | code = methodize('something(item1, item2)')
26 | expect(code).to eq('something(item1, item2)')
27 | end
28 |
29 | it 'should not methodize on assignment' do
30 | code = methodize('params._something = 5')
31 | expect(code).to eq('params._something = 5')
32 | end
33 |
34 | it 'should not methodize on hash lookup' do
35 | code = methodize('hash[:something]')
36 | expect(code).to eq('hash[:something]')
37 | end
38 |
39 | it 'should not methodize on instance variables' do
40 | code = methodize('@something.call')
41 | expect(code).to eq('@something.call')
42 | end
43 | end
44 | end
--------------------------------------------------------------------------------
/spec/server/message_bus/peer_to_peer/socket_with_timeout_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | unless RUBY_PLATFORM == 'opal'
4 | describe Volt::SocketWithTimeout do
5 | it 'should setup a connection manually and then specify a timeout' do
6 | allow_any_instance_of(Socket).to receive(:connect)
7 |
8 | Volt::SocketWithTimeout.new('google.com', 80, 10)
9 | end
10 | end
11 | end
--------------------------------------------------------------------------------
/spec/server/message_bus/peer_to_peer_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | unless RUBY_PLATFORM == 'opal'
4 | describe Volt::MessageBus::PeerToPeer do
5 | before do
6 | # Stub socket stuff
7 | allow_any_instance_of(Volt::MessageBus::PeerToPeer).to receive(:connect_to_peers).and_return(nil)
8 | end
9 |
10 | end
11 | end
--------------------------------------------------------------------------------
/spec/server/middleware/middleware_stack_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | unless RUBY_PLATFORM == 'opal'
4 | describe Volt::MiddlewareStack do
5 | before do
6 | @stack = Volt::MiddlewareStack.new
7 | end
8 |
9 | it 'should insert a middleware at the end of the stack when calling use' do
10 | middleware1 = double('middleware1')
11 | @stack.use(middleware1, 'arg1')
12 |
13 | expect(@stack.middlewares).to eq([
14 | [[middleware1, 'arg1'], nil]
15 | ])
16 | end
17 | end
18 | end
--------------------------------------------------------------------------------
/spec/server/rack/component_paths_spec.rb:
--------------------------------------------------------------------------------
1 | if RUBY_PLATFORM != 'opal'
2 | require 'volt/server/rack/component_paths'
3 |
4 | describe Volt::ComponentPaths do
5 | before do
6 | spec_app_root = File.join(File.dirname(__FILE__), '../../apps/file_loading')
7 |
8 | path_to_main = File.join(File.dirname(__FILE__), '../../apps/file_loading/app/main')
9 | @component_paths = Volt::ComponentPaths.new(spec_app_root)
10 | end
11 |
12 | it 'should return the paths to all app folders' do
13 | match_count = 0
14 | @component_paths.app_folders do |app_folder|
15 | if app_folder[/spec\/apps\/file_loading\/app$/] || app_folder[/spec\/apps\/file_loading\/vendor\/app$/]
16 | match_count += 1
17 | end
18 | end
19 |
20 | expect(match_count).to eq(2)
21 | end
22 |
23 | it 'should return the path to a component' do
24 | main_path = @component_paths.component_paths('main').first
25 | expect(main_path).to match(/spec\/apps\/file_loading\/app\/main$/)
26 | end
27 |
28 | it 'should not return paths to non-volt gems' do
29 | Gem.loaded_specs['fake-gem'] = Gem::Specification.new do |s|
30 | s.name = 'fake-gem'
31 | s.version = Gem::Version.new('1.0')
32 | s.full_gem_path = '/home/volt/projects/volt-app'
33 | end
34 | app_folders = @component_paths.app_folders { |f| f }
35 | expect(app_folders).to_not include('/home/volt/projects/volt-app/app')
36 | Gem.loaded_specs.delete 'fake-gem'
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/spec/server/rack/http_response_header_spec.rb:
--------------------------------------------------------------------------------
1 | require 'volt/server/rack/http_response_header'
2 |
3 | describe Volt::HttpResponseHeader do
4 | it 'it should headerize the keys' do
5 | header = Volt::HttpResponseHeader.new
6 | header[:content_type] = 'test'
7 | expect(header['Content-Type']).to eq('test')
8 | expect(header['content-type']).to eq('test')
9 | expect(header['content_type']).to eq('test')
10 | expect(header[:content_type]).to eq('test')
11 | expect(header.keys).to eq(['Content-Type'])
12 | end
13 |
14 | it 'should delete keys' do
15 | header = Volt::HttpResponseHeader.new
16 | header[:content_type] = 'test'
17 | expect(header.delete(:content_type)).to eq('test')
18 | expect(header.size).to eq 0
19 | end
20 |
21 | it 'should merge other plain hashes and headerize their keys' do
22 | header = Volt::HttpResponseHeader.new
23 | header[:content_type] = 'test'
24 |
25 | hash = {}
26 | hash[:transfer_encoding] = 'encoding'
27 |
28 | expect(header.merge(hash)).to be_a(Volt::HttpResponseHeader)
29 | expect(header.merge(hash)['Transfer-Encoding']).to eq('encoding')
30 |
31 | header.merge!(hash)
32 | expect(header['Transfer-Encoding']).to eq('encoding')
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/spec/server/rack/http_response_renderer_spec.rb:
--------------------------------------------------------------------------------
1 | require 'volt/server/rack/http_response_renderer'
2 |
3 | describe Volt::HttpResponseRenderer do
4 | let(:renderer) { Volt::HttpResponseRenderer.new }
5 |
6 | it 'should render json' do
7 | hash = { a: 'aa', bb: 'bbb' }
8 | body, additional_headers = renderer.render json: hash
9 | expect(body).to eq(hash.to_json)
10 | expect(additional_headers[:content_type]).to eq('application/json')
11 | end
12 |
13 | it 'should render plain text' do
14 | text = 'just some text'
15 | body, additional_headers = renderer.render(text: text)
16 | expect(body).to eq(text)
17 | expect(additional_headers[:content_type]).to eq('text/plain')
18 | end
19 |
20 | it 'should give renderer error if no suitable renderer could be found' do
21 | body, additional_headers = renderer.render(some: 'text')
22 | expect(body).to eq('Error: render only supports json, text')
23 | expect(additional_headers[:content_type]).to eq('text/plain')
24 | end
25 |
26 | it 'should add all remaining keys as additional_headers' do
27 | text = 'just some text'
28 | body, additional_headers = renderer.render(text: text,
29 | additional: 'headers')
30 | expect(body).to eq(text)
31 | expect(additional_headers[:additional]).to eq('headers')
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/spec/server/rack/rack_requests_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | if ENV['BROWSER'] && ENV['BROWSER'] == 'phantom'
4 | describe 'Rack Requests', type: :feature do
5 | it 'should send JS file with JS mimetype' do
6 | visit '/app/components/main.js'
7 |
8 | expect(page.response_headers['Content-Type']).to include 'application/javascript'
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/spec/server/rack/sprockets_helpers_setup.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe "sprockets helpers" do
4 | it 'should expand paths' do
5 | result = Volt::SprocketsHelpersSetup.expand('/something/cool/../awesome/beans/../../five/six/seven')
6 |
7 | expect(result).to eq('/something/five/six/seven')
8 | end
9 |
10 | it 'should expand paths2' do
11 | result = Volt::SprocketsHelpersSetup.expand('bootstrap/assets/css/../fonts/glyphicons-halflings-regular.svg')
12 |
13 | expect(result).to eq('bootstrap/assets/fonts/glyphicons-halflings-regular.svg')
14 | end
15 | end
--------------------------------------------------------------------------------
/spec/tasks/live_query_spec.rb:
--------------------------------------------------------------------------------
1 | if RUBY_PLATFORM != 'opal'
2 | describe 'LiveQuery' do
3 | before do
4 | load File.join(File.dirname(__FILE__), '../../app/volt/tasks/live_query/live_query.rb')
5 | end
6 |
7 | it 'should run a query' do
8 | pool = double('volt/pool')
9 | data_store = double('volt/data store')
10 |
11 | expect(data_store).to receive(:query).with('_items', {}).and_return([
12 | { 'id' => 0, '_name' => 'one' }
13 | ])
14 |
15 | live_query = LiveQuery.new(pool, data_store, '_items', {})
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/spec/tasks/query_tasks.rb:
--------------------------------------------------------------------------------
1 | if RUBY_PLATFORM != 'opal'
2 | describe 'Volt::QueryTasks' do
3 | before do
4 | load File.join(File.dirname(__FILE__), '../../app/volt/tasks/query_tasks.rb')
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/templates/targets/binding_document/component_node_spec.rb:
--------------------------------------------------------------------------------
1 | require 'volt/page/targets/binding_document/component_node'
2 |
3 | describe Volt::ComponentNode do
4 | before do
5 | html = <<-END
6 | Before Inside After
7 | END
8 |
9 | @component = Volt::ComponentNode.new
10 | @component.html = html
11 | end
12 |
13 | it 'should find a component from a binding id' do
14 | expect(@component.find_by_binding_id(1).to_html).to eq('Inside')
15 | expect(@component.find_by_binding_id(0).to_html).to eq('Before Inside After')
16 | end
17 |
18 | # it "should render if blocks" do
19 | # view = <<-END
20 | # {#if _show}show{/} title
21 | # END
22 | #
23 | # page = Page.new
24 | #
25 | # template = ViewParser.new(view, main/main/main/index/index/title')
26 | #
27 | # page.add_template
28 | # end
29 | end
30 |
--------------------------------------------------------------------------------
/spec/utils/data_transformer_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'volt/utils/data_transformer'
3 |
4 | describe Volt::DataTransformer do
5 | it 'should transform values' do
6 | data = {
7 | name: 'Bob',
8 | stuff: [
9 | {key: /regex/}
10 | ],
11 | other: /another regex/,
12 | /some reg/ => 'value'
13 | }
14 |
15 | transformed = {
16 | :name=>"Bob",
17 | :stuff=>[
18 | {:key=>"a regex"}
19 | ],
20 | :other=>"a regex",
21 | "a regex"=>"value"
22 | }
23 |
24 | result = Volt::DataTransformer.transform(data) do |value|
25 | if value.is_a?(Regexp)
26 | 'a regex'
27 | else
28 | value
29 | end
30 | end
31 |
32 | expect(result).to eq(transformed)
33 | end
34 |
35 | it 'should transform keys' do
36 | data = {
37 | 'name' => 'Ryan',
38 | 'info' => [
39 | {'place' => 'Bozeman'}
40 | ]
41 | }
42 | transformed = {:name=>"Ryan", :info=>[{:place=>"Bozeman"}]}
43 | result = Volt::DataTransformer.transform_keys(data) do |key|
44 | key.to_sym
45 | end
46 |
47 | expect(result).to eq(transformed)
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/spec/utils/generic_counting_pool_spec.rb:
--------------------------------------------------------------------------------
1 | require 'volt/utils/generic_counting_pool'
2 |
3 | class CountingPoolTest < Volt::GenericCountingPool
4 | def create(id, name = nil)
5 | Object.new
6 | end
7 | end
8 |
9 | describe Volt::GenericCountingPool do
10 | before do
11 | @count_pool = CountingPoolTest.new
12 | end
13 |
14 | it 'should lookup and retrieve' do
15 | item1 = @count_pool.find('one')
16 |
17 | item2 = @count_pool.find('one')
18 | item3 = @count_pool.find('two')
19 |
20 | expect(item1).to eq(item2)
21 | expect(item2).to_not eq(item3)
22 | end
23 |
24 | it 'should only remove items when the same number have been removed as have been added' do
25 | item1 = @count_pool.find('_items', 'one')
26 | item2 = @count_pool.find('_items', 'one')
27 | expect(@count_pool.instance_variable_get('@pool')).to_not eq({})
28 |
29 | @count_pool.remove('_items', 'one')
30 | expect(@count_pool.instance_variable_get('@pool')).to_not eq({})
31 |
32 | @count_pool.remove('_items', 'one')
33 | expect(@count_pool.instance_variable_get('@pool')).to eq({})
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/spec/utils/parsing_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Volt::Parsing do
4 | subject { Volt::Parsing }
5 | context 'surrounding encoding/decoding' do
6 | it 'does not mangle characters' do
7 | raw = ' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~''"'
8 | encoded = subject.encodeURI raw
9 | decoded = subject.decodeURI encoded
10 |
11 | expect(decoded).to eq raw
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/utils/task_argument_filtererer_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | if RUBY_PLATFORM != 'opal'
4 | describe TaskArgumentFilterer do
5 | it 'should filter arguments' do
6 | filtered_args = TaskArgumentFilterer.new(login: 'jim@jim.com', password: 'some password no one should see').run
7 |
8 | expect(filtered_args).to eq(login: 'jim@jim.com', password: '[FILTERED]')
9 | end
10 |
11 | it 'should filter in nested args' do
12 | filtered_args = TaskArgumentFilterer.new([:login, { login: 'jim@jim.com', password: 'some password' }]).run
13 |
14 | expect(filtered_args).to eq([:login, { login: 'jim@jim.com', password: '[FILTERED]' }])
15 | end
16 |
17 | it 'should create and run a new TaskArgumentFilterer when its filter method is called' do
18 | filtered_args = TaskArgumentFilterer.filter([{login: 'jam@jam.com', password: 'some password'}])
19 | expect(filtered_args).to eq([{login:"jam@jam.com", password:"[FILTERED]"}])
20 | end
21 |
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/volt/repos_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Volt::App do
4 | [:cookies, :flash, :local_store].each do |repo|
5 | it "should raise an error when accessing #{repo} from the server" do
6 | expect do
7 | volt_app.send(repo)
8 | end.to raise_error("The #{repo} collection can only be accessed from the client side currently")
9 | end
10 | end
11 | end
--------------------------------------------------------------------------------
/templates/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle
2 | .config
3 | .yardoc
4 | _yardoc
5 | coverage
6 | doc/
7 | rdoc
8 | tmp
9 | .idea
10 | .yardoc
11 | .sass-cache
12 | .DS_Store
--------------------------------------------------------------------------------
/templates/component/assets/css/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/assets/css/.empty_directory
--------------------------------------------------------------------------------
/templates/component/assets/images/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/assets/images/.empty_directory
--------------------------------------------------------------------------------
/templates/component/assets/js/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/assets/js/.empty_directory
--------------------------------------------------------------------------------
/templates/component/config/dependencies.rb:
--------------------------------------------------------------------------------
1 | # Specify which components you wish to include when
2 | # this component loads.
3 |
--------------------------------------------------------------------------------
/templates/component/config/initializers/boot.rb:
--------------------------------------------------------------------------------
1 | # Place any code you want to run when the component is included on the client
2 | # or server.
3 |
4 | # To include code only on the client use:
5 | # if RUBY_PLATFORM == 'opal'
6 | #
7 | # To include code only on the server, use:
8 | # unless RUBY_PLATFORM == 'opal'
9 | # ^^ this will not send compile in code in the conditional to the client.
10 | # ^^ this include code required in the conditional.
--------------------------------------------------------------------------------
/templates/component/config/initializers/client/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/config/initializers/client/.empty_directory
--------------------------------------------------------------------------------
/templates/component/config/initializers/server/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/config/initializers/server/.empty_directory
--------------------------------------------------------------------------------
/templates/component/config/routes.rb:
--------------------------------------------------------------------------------
1 | # See https://github.com/voltrb/volt#routes for more info on routes
2 |
--------------------------------------------------------------------------------
/templates/component/controllers/main_controller.rb.tt:
--------------------------------------------------------------------------------
1 | module <%= config[:component_name].camelize %>
2 | class MainController < Volt::ModelController
3 | def index
4 | # Add code for when the index view is loaded
5 | end
6 |
7 | def about
8 | # Add code for when the about view is loaded
9 | end
10 |
11 | private
12 |
13 | # the main template contains a #template binding that shows another
14 | # template. This is the path to that template. It may change based
15 | # on the params._controller and params._action values.
16 | def main_path
17 | "#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}"
18 | end
19 | end
20 | end
--------------------------------------------------------------------------------
/templates/component/controllers/server/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/controllers/server/.empty_directory
--------------------------------------------------------------------------------
/templates/component/lib/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/lib/.empty_directory
--------------------------------------------------------------------------------
/templates/component/models/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/models/.empty_directory
--------------------------------------------------------------------------------
/templates/component/tasks/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component/tasks/.empty_directory
--------------------------------------------------------------------------------
/templates/component/views/main/index.html.tt:
--------------------------------------------------------------------------------
1 | <:Title>
2 | Component Index
3 |
4 | <:Body>
5 |
Component Index
--------------------------------------------------------------------------------
/templates/component_specs/controllers/server/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component_specs/controllers/server/.empty_directory
--------------------------------------------------------------------------------
/templates/component_specs/integration/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component_specs/integration/.empty_directory
--------------------------------------------------------------------------------
/templates/component_specs/models/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component_specs/models/.empty_directory
--------------------------------------------------------------------------------
/templates/component_specs/tasks/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/component_specs/tasks/.empty_directory
--------------------------------------------------------------------------------
/templates/controller/http_controller.rb.tt:
--------------------------------------------------------------------------------
1 | module <%= config[:component_module] %>
2 | class <%= config[:http_controller_name] %> < Volt::HttpController
3 |
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/templates/controller/http_controller_spec.rb.tt:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe <%= config[:component_module] %>::<%= config[:http_controller_name] %>, type: :http_controller do
4 | # Specs here
5 | end
6 |
--------------------------------------------------------------------------------
/templates/controller/model_controller.rb.tt:
--------------------------------------------------------------------------------
1 | module <%= config[:component_module] %>
2 | class <%= config[:model_controller_name] %> < Volt::ModelController
3 |
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/templates/controller/model_controller_spec.rb.tt:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe '<%= config[:name] %>', type: :feature do
4 | # Specs here
5 | end
6 |
--------------------------------------------------------------------------------
/templates/model/model.rb.tt:
--------------------------------------------------------------------------------
1 | class <%= config[:model_name] %> < Volt::Model
2 |
3 | end
4 |
--------------------------------------------------------------------------------
/templates/model/model_spec.rb.tt:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe <%= config[:model_name] %> do
4 | # Specs here
5 | end
6 |
--------------------------------------------------------------------------------
/templates/newgem/CODE_OF_CONDUCT.md.tt:
--------------------------------------------------------------------------------
1 | # Contributor Code of Conduct
2 |
3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4 |
5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6 |
7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8 |
9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10 |
11 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12 |
13 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
14 |
--------------------------------------------------------------------------------
/templates/newgem/Gemfile.tt:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # Specify your gem's dependencies in <%=config[:name]%>.gemspec
4 | gemspec
5 |
6 | # Optional Gems for testing/dev
7 |
8 | # The implementation of ReadWriteLock in Volt uses concurrent ruby and ext helps performance.
9 | gem 'concurrent-ruby-ext', '~> 0.8.0'
10 |
11 | # Gems you use for development should be added to the gemspec file as
12 | # development dependencies.
--------------------------------------------------------------------------------
/templates/newgem/LICENSE.txt.tt:
--------------------------------------------------------------------------------
1 | Copyright (c) <%=Time.now.year%> <%=config[:author]%>
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/templates/newgem/README.md.tt:
--------------------------------------------------------------------------------
1 | # <%=config[:constant_name]%>
2 |
3 | TODO: Write a gem description
4 |
5 | ## Installation
6 |
7 | Add this line to your application's Gemfile:
8 |
9 | gem '<%=config[:name]%>'
10 |
11 | And then execute:
12 |
13 | $ bundle
14 |
15 | Or install it yourself as:
16 |
17 | $ gem install <%=config[:name]%>
18 |
19 | ## Usage
20 |
21 | TODO: Write usage instructions here
22 |
23 | ## Contributing
24 |
25 | 1. Fork it ( http://github.com/[my-github-username]/<%=config[:name]%>/fork )
26 | 2. Create your feature branch (`git checkout -b my-new-feature`)
27 | 3. Commit your changes (`git commit -am 'Add some feature'`)
28 | 4. Push to the branch (`git push origin my-new-feature`)
29 | 5. Create new Pull Request
30 |
--------------------------------------------------------------------------------
/templates/newgem/Rakefile.tt:
--------------------------------------------------------------------------------
1 | require "bundler/gem_tasks"
2 | <% if config[:test] == 'minitest' -%>
3 | require "rake/testtask"
4 |
5 | Rake::TestTask.new(:test) do |t|
6 | t.libs << "test"
7 | end
8 |
9 | task :default => :test
10 | <% elsif config[:test] == 'rspec' -%>
11 | require "rspec/core/rake_task"
12 |
13 | RSpec::Core::RakeTask.new(:spec)
14 |
15 | task :default => :spec
16 | <% end -%>
17 |
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/assets/css/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/assets/css/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/assets/js/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/assets/js/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/config/dependencies.rb:
--------------------------------------------------------------------------------
1 | # Component dependencies
2 |
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/config/initializers/boot.rb:
--------------------------------------------------------------------------------
1 | # Place any code you want to run when the component is included on the client
2 | # or server.
3 |
4 | # To include code only on the client use:
5 | # if RUBY_PLATFORM == 'opal'
6 | #
7 | # To include code only on the server, use:
8 | # unless RUBY_PLATFORM == 'opal'
9 | # ^^ this will not send compile in code in the conditional to the client.
10 | # ^^ this include code required in the conditional.
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/config/initializers/client/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/config/initializers/client/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/config/initializers/server/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/config/initializers/server/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/config/routes.rb:
--------------------------------------------------------------------------------
1 | # Component routes
2 |
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/controllers/main_controller.rb.tt:
--------------------------------------------------------------------------------
1 | module <%=config[:name].gsub(/^volt[-]/, '').gsub('-', '_').split("_").map {|s| s.capitalize }.join("") %>
2 | class MainController < Volt::ModelController
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/controllers/server/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/controllers/server/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/lib/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/lib/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/models/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/models/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/tasks/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/app/newgem/tasks/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/app/newgem/views/main/index.html:
--------------------------------------------------------------------------------
1 | <:Body>
2 | -- component --
3 |
--------------------------------------------------------------------------------
/templates/newgem/bin/newgem.tt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require '<%= config[:namespaced_path] %>'
4 |
--------------------------------------------------------------------------------
/templates/newgem/gitignore.tt:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | .yardoc
6 | Gemfile.lock
7 | InstalledFiles
8 | _yardoc
9 | coverage
10 | doc/
11 | lib/bundler/man
12 | pkg
13 | rdoc
14 | spec/reports
15 | test/tmp
16 | test/version_tmp
17 | tmp
18 |
--------------------------------------------------------------------------------
/templates/newgem/lib/newgem.rb.tt:
--------------------------------------------------------------------------------
1 | # If you need to require in code in the gem's app folder, keep in mind that
2 | # the app is not on the load path when the gem is required. Use
3 | # app/{gemname}/config/initializers/boot.rb to require in client or server
4 | # code.
5 | #
6 | # Also, in volt apps, you typically use the lib folder in the
7 | # app/{componentname} folder instead of this lib folder. This lib folder is
8 | # for setting up gem code when Bundler.require is called. (or the gem is
9 | # required.)
10 | #
11 | # If you need to configure volt in some way, you can add a Volt.configure block
12 | # in this file.
13 |
14 | <%- config[:constant_array].each_with_index do |c,i| -%>
15 | <%= ' '*i %>module <%= c %>
16 | <%- end -%>
17 | <%= ' '*config[:constant_array].size %># Your code goes here...
18 | <%- (config[:constant_array].size-1).downto(0) do |i| -%>
19 | <%= ' '*i %>end
20 | <%- end -%>
21 |
--------------------------------------------------------------------------------
/templates/newgem/lib/newgem/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/newgem/lib/newgem/.empty_directory
--------------------------------------------------------------------------------
/templates/newgem/lib/newgem/version.rb.tt:
--------------------------------------------------------------------------------
1 | <%- config[:constant_array].each_with_index do |c,i| -%>
2 | <%= ' '*i %>module <%= c %>
3 | <%- end -%>
4 | <%= ' '*config[:constant_array].size %>VERSION = "0.1.0"
5 | <%- (config[:constant_array].size-1).downto(0) do |i| -%>
6 | <%= ' '*i %>end
7 | <%- end -%>
--------------------------------------------------------------------------------
/templates/newgem/rspec.tt:
--------------------------------------------------------------------------------
1 | --format documentation
2 | --color
3 |
--------------------------------------------------------------------------------
/templates/newgem/spec/integration/sample_integration_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'sample integration test', type: :feature do
4 | # An example integration spec, this will only be run if ENV['BROWSER'] is
5 | # specified. Current values for ENV['BROWSER'] are 'firefox' and 'phantom'
6 | it 'should load the page' do
7 | visit '/'
8 |
9 | expect(page).to have_content('Home')
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/templates/newgem/spec/newgem_spec.rb.tt:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe <%= config[:constant_name] %> do
4 | it 'should do something useful' do
5 | expect(false).to be true
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/templates/newgem/spec/spec_helper.rb.tt:
--------------------------------------------------------------------------------
1 | # Volt sets up rspec and capybara for testing.
2 | require 'volt/spec/setup'
3 |
4 | # When testing Volt component gems, we boot up a dummy app first to run the
5 | # test in, so we have access to Volt itself.
6 | dummy_app_path = File.join(File.dirname(__FILE__), 'dummy')
7 | Volt.spec_setup(dummy_app_path)
8 |
9 | RSpec.configure do |config|
10 | config.run_all_when_everything_filtered = true
11 | config.filter_run :focus
12 |
13 | # Run specs in random order to surface order dependencies. If you find an
14 | # order dependency and want to debug it, you can fix the order by providing
15 | # the seed, which is printed after each run.
16 | # --seed 1234
17 | config.order = 'random'
18 | end
19 |
--------------------------------------------------------------------------------
/templates/newgem/test/minitest_helper.rb.tt:
--------------------------------------------------------------------------------
1 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2 | require '<%= config[:namespaced_path] %>'
3 |
4 | require 'minitest/autorun'
5 |
--------------------------------------------------------------------------------
/templates/newgem/test/test_newgem.rb.tt:
--------------------------------------------------------------------------------
1 | require 'minitest_helper'
2 |
3 | class Test<%= config[:constant_name] %> < MiniTest::Unit::TestCase
4 | def test_that_it_has_a_version_number
5 | refute_nil ::<%= config[:constant_name] %>::VERSION
6 | end
7 |
8 | def test_it_does_something_useful
9 | assert false
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/templates/project/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle
2 | .config
3 | .yardoc
4 | tmp
5 | .idea
6 | .yardoc
7 | .sass-cache
8 | .DS_Store
9 | compiled
--------------------------------------------------------------------------------
/templates/project/README.md.tt:
--------------------------------------------------------------------------------
1 | # Welcome to Volt
2 |
3 | You can start your volt app by running:
4 |
5 | ```bundle exec volt server```
6 |
7 | ## New to Volt?
8 |
9 | Be sure to read the volt docs at http://voltframework.com/docs
10 |
--------------------------------------------------------------------------------
/templates/project/app/main/assets/css/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/project/app/main/assets/css/.empty_directory
--------------------------------------------------------------------------------
/templates/project/app/main/assets/css/app.css.scss:
--------------------------------------------------------------------------------
1 | // Place your apps css here
--------------------------------------------------------------------------------
/templates/project/app/main/assets/images/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/project/app/main/assets/images/.empty_directory
--------------------------------------------------------------------------------
/templates/project/app/main/assets/js/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/project/app/main/assets/js/.empty_directory
--------------------------------------------------------------------------------
/templates/project/app/main/config/dependencies.rb:
--------------------------------------------------------------------------------
1 | # Specify which components you wish to include when
2 | # the "home" component loads.
3 |
4 | # bootstrap css framework
5 | component 'bootstrap'
6 |
7 | # a default theme for the bootstrap framework
8 | component 'bootstrap_jumbotron_theme'
9 |
10 | # provides templates for login, signup, and logout
11 | component 'user_templates'
12 |
--------------------------------------------------------------------------------
/templates/project/app/main/config/initializers/boot.rb:
--------------------------------------------------------------------------------
1 | # Place any code you want to run when the component is included on the client
2 | # or server.
3 |
4 | # To include code only on the client use:
5 | # if RUBY_PLATFORM == 'opal'
6 | #
7 | # To include code only on the server, use:
8 | # unless RUBY_PLATFORM == 'opal'
9 | # ^^ this will not send compile in code in the conditional to the client.
10 | # ^^ this include code required in the conditional.
--------------------------------------------------------------------------------
/templates/project/app/main/config/initializers/client/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/project/app/main/config/initializers/client/.empty_directory
--------------------------------------------------------------------------------
/templates/project/app/main/config/initializers/server/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/project/app/main/config/initializers/server/.empty_directory
--------------------------------------------------------------------------------
/templates/project/app/main/config/routes.rb:
--------------------------------------------------------------------------------
1 | # See https://github.com/voltrb/volt#routes for more info on routes
2 |
3 | client '/about', action: 'about'
4 |
5 | # Routes for login and signup, provided by user_templates component gem
6 | client '/signup', component: 'user_templates', controller: 'signup'
7 | client '/login', component: 'user_templates', controller: 'login', action: 'index'
8 | client '/password_reset', component: 'user_templates', controller: 'password_reset', action: 'index'
9 | client '/forgot', component: 'user_templates', controller: 'login', action: 'forgot'
10 | client '/account', component: 'user_templates', controller: 'account', action: 'index'
11 |
12 | # The main route, this should be last. It will match any params not
13 | # previously matched.
14 | client '/', {}
15 |
--------------------------------------------------------------------------------
/templates/project/app/main/controllers/main_controller.rb:
--------------------------------------------------------------------------------
1 | # By default Volt generates this controller for your Main component
2 | module Main
3 | class MainController < Volt::ModelController
4 | def index
5 | # Add code for when the index view is loaded
6 | end
7 |
8 | def about
9 | # Add code for when the about view is loaded
10 | end
11 |
12 | private
13 |
14 | # The main template contains a #template binding that shows another
15 | # template. This is the path to that template. It may change based
16 | # on the params._component, params._controller, and params._action values.
17 | def main_path
18 | "#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}"
19 | end
20 |
21 | # Determine if the current nav component is the active one by looking
22 | # at the first part of the url against the href attribute.
23 | def active_tab?
24 | url.path.split('/')[1] == attrs.href.split('/')[1]
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/templates/project/app/main/lib/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/project/app/main/lib/.empty_directory
--------------------------------------------------------------------------------
/templates/project/app/main/models/user.rb:
--------------------------------------------------------------------------------
1 | # By default Volt generates this User model which inherits from Volt::User,
2 | # you can rename this if you want.
3 | class User < Volt::User
4 | # login_field is set to :email by default and can be changed to :username
5 | # in config/app.rb
6 | field login_field
7 | field :name
8 |
9 | validate login_field, unique: true, length: 8
10 | validate :email, email: true
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/templates/project/app/main/tasks/.empty_directory:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/voltrb/volt/f942b92385adbc894ee4a37903ee6a9c1a65e9a4/templates/project/app/main/tasks/.empty_directory
--------------------------------------------------------------------------------
/templates/project/app/main/views/main/about.html:
--------------------------------------------------------------------------------
1 | <:Title>
2 | About
3 |
4 | <:Body>
5 |
29 |
30 |
--------------------------------------------------------------------------------
/templates/project/config.ru:
--------------------------------------------------------------------------------
1 | # Run via rack server
2 | require 'bundler/setup'
3 | require 'volt/server'
4 | run Volt::Server.new.app
5 |
--------------------------------------------------------------------------------
/templates/project/config/base/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%# IMPORTANT: Please read before changing! %>
4 | <%# This file is rendered on the server using ERB, so it does NOT use Volt's %>
5 | <%# normal template system. You can add to it, but keep in mind the template %>
6 | <%# language difference. This file handles auto-loading all JS/Opal and CSS. %>
7 |
8 |
9 | <%= javascript_tags %>
10 | <%= css_tags %>
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/templates/project/config/initializers/boot.rb:
--------------------------------------------------------------------------------
1 | # Any ./config/initializers/*.rb files will when the app starts up on the server.
2 | # To load code on the client (or client and server), you can use the
3 | # config/initializers folder in a component in the app directory. This folder
4 | # is only for things that are server only. (Usually for things like config)
--------------------------------------------------------------------------------
/templates/project/spec/app/main/controllers/server/sample_http_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'sample http controller test', type: :http_controller do
4 | # Specs here
5 | end
6 |
--------------------------------------------------------------------------------
/templates/project/spec/app/main/integration/sample_integration_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'sample integration test', type: :feature do
4 | # An example integration spec, this will only be run if ENV['BROWSER'] is
5 | # specified. Current values for ENV['BROWSER'] are 'firefox' and 'phantom'
6 | it 'should load the page' do
7 | visit '/'
8 |
9 | expect(page).to have_content('Home')
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/templates/project/spec/app/main/models/sample_model_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'sample model' do
4 | # Specs here
5 | end
6 |
--------------------------------------------------------------------------------
/templates/project/spec/app/main/tasks/sample_task_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'sample task', type: :task do
4 | # Specs here
5 | end
6 |
--------------------------------------------------------------------------------
/templates/project/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # Volt sets up rspec and capybara for testing.
2 | require 'volt/spec/setup'
3 | Volt.spec_setup
4 |
5 | RSpec.configure do |config|
6 | config.run_all_when_everything_filtered = true
7 | config.filter_run :focus
8 |
9 | # Run specs in random order to surface order dependencies. If you find an
10 | # order dependency and want to debug it, you can fix the order by providing
11 | # the seed, which is printed after each run.
12 | # --seed 1234
13 | config.order = 'random'
14 | end
15 |
--------------------------------------------------------------------------------
/templates/task/task.rb.tt:
--------------------------------------------------------------------------------
1 | class <%= config[:task_name] %> < Volt::Task
2 |
3 | end
4 |
--------------------------------------------------------------------------------
/templates/task/task_spec.rb.tt:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe <%= config[:task_name] %>, type: :task do
4 | # Specs here
5 | end
6 |
--------------------------------------------------------------------------------
/templates/view/index.html.tt:
--------------------------------------------------------------------------------
1 | <:Title>
2 | <%= config[:view_name] %> index
3 |
4 | <:Body>
5 |
Find me in app/<%= config[:component] %>/views/<%= config[:view_name] %>/index.html