volt 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Rakefile +0 -1
  5. data/app/volt/models/user.rb +1 -3
  6. data/app/volt/tasks/live_query/live_query.rb +1 -1
  7. data/app/volt/tasks/store_tasks.rb +4 -5
  8. data/app/volt/tasks/user_tasks.rb +1 -1
  9. data/lib/volt.rb +2 -6
  10. data/lib/volt/boot.rb +0 -2
  11. data/lib/volt/cli.rb +0 -1
  12. data/lib/volt/cli/asset_compile.rb +0 -2
  13. data/lib/volt/cli/console.rb +3 -4
  14. data/lib/volt/cli/generate.rb +3 -4
  15. data/lib/volt/cli/new_gem.rb +1 -3
  16. data/lib/volt/controllers/actions.rb +6 -6
  17. data/lib/volt/controllers/model_controller.rb +4 -8
  18. data/lib/volt/data_stores/base.rb +1 -2
  19. data/lib/volt/data_stores/data_store.rb +2 -2
  20. data/lib/volt/data_stores/mongo_driver.rb +3 -3
  21. data/lib/volt/extra_core/hash.rb +1 -1
  22. data/lib/volt/extra_core/inflector/inflections.rb +10 -2
  23. data/lib/volt/extra_core/logger.rb +1 -4
  24. data/lib/volt/extra_core/object.rb +1 -1
  25. data/lib/volt/models.rb +2 -4
  26. data/lib/volt/models/array_model.rb +3 -7
  27. data/lib/volt/models/associations.rb +5 -4
  28. data/lib/volt/models/buffer.rb +1 -2
  29. data/lib/volt/models/dirty.rb +2 -2
  30. data/lib/volt/models/errors.rb +1 -1
  31. data/lib/volt/models/listener_tracker.rb +1 -3
  32. data/lib/volt/models/model.rb +16 -20
  33. data/lib/volt/models/permissions.rb +15 -18
  34. data/lib/volt/models/persistors/array_store.rb +5 -10
  35. data/lib/volt/models/persistors/cookies.rb +2 -2
  36. data/lib/volt/models/persistors/model_store.rb +3 -9
  37. data/lib/volt/models/persistors/params.rb +1 -3
  38. data/lib/volt/models/persistors/query/normalizer.rb +3 -3
  39. data/lib/volt/models/persistors/query/query_listener.rb +1 -1
  40. data/lib/volt/models/persistors/store.rb +2 -2
  41. data/lib/volt/models/state_helpers.rb +1 -1
  42. data/lib/volt/models/state_manager.rb +4 -4
  43. data/lib/volt/models/url.rb +2 -6
  44. data/lib/volt/models/validations.rb +8 -13
  45. data/lib/volt/models/validators/numericality_validator.rb +2 -6
  46. data/lib/volt/models/validators/unique_validator.rb +1 -1
  47. data/lib/volt/models/validators/user_validation.rb +0 -1
  48. data/lib/volt/page/bindings/attribute_binding.rb +9 -19
  49. data/lib/volt/page/bindings/content_binding.rb +1 -1
  50. data/lib/volt/page/bindings/each_binding.rb +3 -4
  51. data/lib/volt/page/bindings/if_binding.rb +1 -1
  52. data/lib/volt/page/bindings/view_binding.rb +15 -22
  53. data/lib/volt/page/bindings/view_binding/controller_handler.rb +5 -7
  54. data/lib/volt/page/bindings/view_binding/view_lookup_for_path.rb +1 -2
  55. data/lib/volt/page/bindings/yield_binding.rb +1 -2
  56. data/lib/volt/page/channel.rb +3 -3
  57. data/lib/volt/page/document_events.rb +1 -1
  58. data/lib/volt/page/page.rb +3 -6
  59. data/lib/volt/page/path_string_renderer.rb +7 -8
  60. data/lib/volt/page/sub_context.rb +1 -3
  61. data/lib/volt/page/targets/binding_document/component_node.rb +1 -3
  62. data/lib/volt/page/tasks.rb +3 -5
  63. data/lib/volt/reactive/class_eventable.rb +2 -2
  64. data/lib/volt/reactive/computation.rb +7 -7
  65. data/lib/volt/reactive/dependency.rb +1 -1
  66. data/lib/volt/reactive/eventable.rb +3 -4
  67. data/lib/volt/reactive/reactive_accessors.rb +0 -1
  68. data/lib/volt/reactive/reactive_array.rb +4 -12
  69. data/lib/volt/router/routes.rb +1 -3
  70. data/lib/volt/server.rb +6 -6
  71. data/lib/volt/server/component_handler.rb +1 -1
  72. data/lib/volt/server/component_templates.rb +2 -2
  73. data/lib/volt/server/forking_server.rb +6 -9
  74. data/lib/volt/server/html_parser/component_view_scope.rb +2 -2
  75. data/lib/volt/server/html_parser/each_scope.rb +1 -1
  76. data/lib/volt/server/html_parser/sandlebars_parser.rb +2 -6
  77. data/lib/volt/server/html_parser/view_handler.rb +1 -1
  78. data/lib/volt/server/html_parser/view_parser.rb +1 -1
  79. data/lib/volt/server/html_parser/view_scope.rb +2 -4
  80. data/lib/volt/server/rack/asset_files.rb +1 -3
  81. data/lib/volt/server/rack/component_paths.rb +1 -3
  82. data/lib/volt/server/rack/http_request.rb +1 -3
  83. data/lib/volt/server/rack/http_resource.rb +1 -3
  84. data/lib/volt/server/rack/http_response_renderer.rb +2 -2
  85. data/lib/volt/server/rack/index_files.rb +1 -1
  86. data/lib/volt/server/rack/opal_files.rb +1 -3
  87. data/lib/volt/server/socket_connection_handler.rb +1 -3
  88. data/lib/volt/server/websocket/rack_server_adaptor.rb +1 -1
  89. data/lib/volt/server/websocket/websocket_handler.rb +1 -2
  90. data/lib/volt/spec/capybara.rb +1 -1
  91. data/lib/volt/spec/setup.rb +18 -12
  92. data/lib/volt/tasks/dispatcher.rb +1 -2
  93. data/lib/volt/tasks/task_handler.rb +1 -3
  94. data/lib/volt/utils/boolean_patch.rb +1 -1
  95. data/lib/volt/utils/event_counter.rb +2 -2
  96. data/lib/volt/utils/generic_pool.rb +5 -9
  97. data/lib/volt/utils/logging/task_argument_filterer.rb +4 -4
  98. data/lib/volt/utils/logging/task_logger.rb +2 -2
  99. data/lib/volt/utils/modes.rb +2 -2
  100. data/lib/volt/utils/promise_patch.rb +1 -2
  101. data/lib/volt/utils/read_write_lock.rb +21 -23
  102. data/lib/volt/utils/tilt_patch.rb +1 -1
  103. data/lib/volt/utils/timers.rb +3 -7
  104. data/lib/volt/utils/volt_user_error.rb +1 -1
  105. data/lib/volt/version.rb +2 -2
  106. data/lib/volt/volt/app.rb +4 -6
  107. data/lib/volt/volt/users.rb +4 -3
  108. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +1 -1
  109. data/spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb +1 -1
  110. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +5 -5
  111. data/spec/apps/kitchen_sink/app/main/controllers/upload_controller.rb +1 -1
  112. data/spec/apps/kitchen_sink/app/main/controllers/yield_component_controller.rb +1 -1
  113. data/spec/controllers/actions_spec.rb +9 -10
  114. data/spec/controllers/model_controller_spec.rb +1 -1
  115. data/spec/extra_core/blank_spec.rb +2 -2
  116. data/spec/extra_core/logger_spec.rb +6 -8
  117. data/spec/extra_core/string_transformations_spec.rb +3 -3
  118. data/spec/integration/bindings_spec.rb +3 -9
  119. data/spec/integration/first_last_spec.rb +1 -1
  120. data/spec/integration/missing_spec.rb +1 -2
  121. data/spec/integration/raw_html_binding.rb +2 -2
  122. data/spec/integration/todos_spec.rb +22 -0
  123. data/spec/integration/yield_spec.rb +2 -2
  124. data/spec/models/associations_spec.rb +4 -4
  125. data/spec/models/buffer_spec.rb +2 -2
  126. data/spec/models/dirty_spec.rb +10 -11
  127. data/spec/models/model_spec.rb +19 -13
  128. data/spec/models/model_state_spec.rb +1 -1
  129. data/spec/models/permissions_spec.rb +8 -12
  130. data/spec/models/url_spec.rb +1 -1
  131. data/spec/models/user_spec.rb +17 -10
  132. data/spec/models/user_validation_spec.rb +2 -3
  133. data/spec/models/validations_spec.rb +7 -10
  134. data/spec/models/validators/email_validator_spec.rb +5 -7
  135. data/spec/models/validators/format_validator_spec.rb +21 -3
  136. data/spec/models/validators/length_validator_spec.rb +12 -22
  137. data/spec/models/validators/shared_examples_for_validators.rb +1 -1
  138. data/spec/models/validators/unique_validator_spec.rb +1 -2
  139. data/spec/page/bindings/content_binding_spec.rb +1 -1
  140. data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +0 -1
  141. data/spec/page/path_string_renderer_spec.rb +2 -3
  142. data/spec/reactive/class_eventable_spec.rb +1 -1
  143. data/spec/reactive/computation_spec.rb +30 -31
  144. data/spec/reactive/reactive_hash_spec.rb +1 -1
  145. data/spec/router/routes_spec.rb +14 -16
  146. data/spec/server/html_parser/view_handler_spec.rb +1 -1
  147. data/spec/server/html_parser/view_parser_spec.rb +0 -1
  148. data/spec/server/rack/quite_common_logger_spec.rb +3 -3
  149. data/spec/tasks/dispatcher_spec.rb +1 -1
  150. data/spec/tasks/query_tracker_spec.rb +1 -3
  151. data/spec/utils/task_argument_filtererer_spec.rb +5 -5
  152. data/templates/project/app/main/controllers/main_controller.rb +1 -1
  153. data/templates/project/spec/app/main/models/sample_model_spec.rb +2 -2
  154. data/templates/project/spec/app/main/tasks/sample_task_spec.rb +2 -2
  155. data/volt.gemspec +3 -5
  156. metadata +19 -4
@@ -6,4 +6,4 @@ class Tilt::Template
6
6
  def warn(*args)
7
7
  # Kernel.warn(*args)
8
8
  end
9
- end
9
+ end
@@ -1,5 +1,4 @@
1
1
  module Volt
2
-
3
2
  # The timers class provides useful methods for working in an asynchronus environment.
4
3
  class Timers
5
4
  # next tick (same as setImmediate) calls the block of code after any currently
@@ -7,7 +6,7 @@ module Volt
7
6
  def self.next_tick(&block)
8
7
  if Volt.in_browser?
9
8
  `setImmediate(function() {`
10
- yield
9
+ yield
11
10
  `})`
12
11
  else
13
12
  tick_timers = (Thread.current['tick_timers'] ||= [])
@@ -23,11 +22,8 @@ module Volt
23
22
  if tick_timers
24
23
  # clear
25
24
  Thread.current['tick_timers'] = nil
26
- tick_timers.each do |timer|
27
- # Run the timer
28
- timer.call
29
- end
25
+ tick_timers.each(&:call)
30
26
  end
31
27
  end
32
28
  end
33
- end
29
+ end
@@ -1,4 +1,4 @@
1
1
  # VoltUserError is a base class for Volt errors that you don't need backtraces on.
2
2
  # These are errors that you simply need to communicate something to developer with.
3
3
  class VoltUserError < RuntimeError
4
- end
4
+ end
data/lib/volt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Volt
2
2
  module Version
3
- STRING = '0.9.1'
3
+ STRING = '0.9.2'
4
4
  end
5
- end
5
+ end
data/lib/volt/volt/app.rb CHANGED
@@ -17,9 +17,7 @@ module Volt
17
17
  end
18
18
 
19
19
  # Require in app and initializers
20
- unless RUBY_PLATFORM == 'opal'
21
- Volt.run_app_and_initializers
22
- end
20
+ Volt.run_app_and_initializers unless RUBY_PLATFORM == 'opal'
23
21
 
24
22
  # Load component paths
25
23
  @component_paths = ComponentPaths.new(app_path)
@@ -45,12 +43,12 @@ module Volt
45
43
  @component_paths.app_folders do |app_folder|
46
44
  # Sort so we get consistent load order across platforms
47
45
  Dir["#{app_folder}/*/controllers/server/*.rb"].each do |ruby_file|
48
- #path = ruby_file.gsub(/^#{app_folder}\//, '')[0..-4]
49
- #require(path)
46
+ # path = ruby_file.gsub(/^#{app_folder}\//, '')[0..-4]
47
+ # require(path)
50
48
  require(ruby_file)
51
49
  end
52
50
  end
53
51
  end
54
52
  end
55
53
  end
56
- end
54
+ end
@@ -64,7 +64,7 @@ module Volt
64
64
 
65
65
  # Put in a deprecation placeholder
66
66
  def user
67
- Volt.logger.warn("deprication: Volt.user has been renamed to Volt.current_user (to be more clear about what it returns). Volt.user will be deprecated in the future.")
67
+ Volt.logger.warn('deprication: Volt.user has been renamed to Volt.current_user (to be more clear about what it returns). Volt.user will be deprecated in the future.')
68
68
  current_user
69
69
  end
70
70
 
@@ -80,7 +80,7 @@ module Volt
80
80
 
81
81
  # Login the user, return a promise for success
82
82
  def login(username, password)
83
- UserTasks.login({login: username, password: password}).then do |result|
83
+ UserTasks.login(login: username, password: password).then do |result|
84
84
  # Assign the user_id cookie for the user
85
85
  $page.cookies._user_id = result
86
86
 
@@ -112,9 +112,10 @@ module Volt
112
112
  end
113
113
 
114
114
  private
115
+
115
116
  # Returns a query for the current user_id or nil if there is no user_id
116
117
  def user_query
117
- user_id = self.current_user_id
118
+ user_id = current_user_id
118
119
  if user_id
119
120
  $page.store._users.where(_id: user_id)
120
121
  else
@@ -59,4 +59,4 @@ module Main
59
59
  url.path.split('/')[1] == attrs.href.split('/')[1]
60
60
  end
61
61
  end
62
- end
62
+ end
@@ -14,4 +14,4 @@ module Main
14
14
  render text: 'Thanks for uploading'
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -1,18 +1,18 @@
1
1
  module Main
2
2
  class TodosController < Volt::ModelController
3
- model :page
3
+ model :store
4
4
 
5
5
  def add_todo
6
- _todos << { name: _new_todo }
7
- self._new_todo = ''
6
+ _todos << { name: page._new_todo }
7
+ page._new_todo = ''
8
8
  end
9
9
 
10
10
  def remove_todo(todo)
11
- _todos.delete(todo)
11
+ todo.destroy
12
12
  end
13
13
 
14
14
  def completed
15
15
  _todos.count(&:_completed)
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -21,4 +21,4 @@ module Main
21
21
  });`
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -4,4 +4,4 @@ module Main
4
4
  'wrong'
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -93,13 +93,12 @@ describe Volt::Actions do
93
93
 
94
94
  expect(test_class.ran_one).to eq(true)
95
95
  expect(test_class.ran_two).to eq(true)
96
-
97
96
  end
98
97
 
99
98
  it 'should raise an exception if no symbol or block is provided' do
100
99
  expect do
101
100
  TestActions2.before_action
102
- end.to raise_error(RuntimeError, "No callback symbol or block provided")
101
+ end.to raise_error(RuntimeError, 'No callback symbol or block provided')
103
102
  end
104
103
 
105
104
  it 'should support multiple symbols passed an action helper' do
@@ -116,15 +115,15 @@ describe Volt::Actions do
116
115
  end
117
116
 
118
117
  it 'should stop the chain when #stop_chain is called and return false from #run_actions' do
119
- test_class = TestStopCallbacks.new
118
+ test_class = TestStopCallbacks.new
120
119
 
121
- result = test_class.run_actions(:before, :index)
122
- expect(result).to eq(true)
120
+ result = test_class.run_actions(:before, :index)
121
+ expect(result).to eq(true)
123
122
 
124
- expect(test_class.ran_one).to eq(true)
125
- expect(test_class.ran_two).to eq(true)
126
- expect(test_class.ran_end_of_two).to eq(nil)
127
- expect(test_class.ran_three).to eq(nil)
123
+ expect(test_class.ran_one).to eq(true)
124
+ expect(test_class.ran_two).to eq(true)
125
+ expect(test_class.ran_end_of_two).to eq(nil)
126
+ expect(test_class.ran_three).to eq(nil)
128
127
  end
129
128
 
130
129
  it 'should call without any callbacks' do
@@ -145,4 +144,4 @@ describe Volt::Actions do
145
144
  expect(test_only.ran_one).to eq(true)
146
145
  expect(test_only.ran_two).to eq(true)
147
146
  end
148
- end
147
+ end
@@ -28,4 +28,4 @@ if RUBY_PLATFORM != 'opal'
28
28
  expect(controller.loaded?).to eq(true)
29
29
  end
30
30
  end
31
- end
31
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "blank" do
3
+ describe 'blank' do
4
4
  it 'should report blank when blank' do
5
5
  expect(' '.blank?).to eq(true)
6
6
  end
@@ -8,4 +8,4 @@ describe "blank" do
8
8
  it 'should report not blank when not blank' do
9
9
  expect(' text '.blank?).to eq(false)
10
10
  end
11
- end
11
+ end
@@ -8,17 +8,15 @@ if RUBY_PLATFORM != 'opal'
8
8
  let(:logger) { Volt::VoltLogger.new }
9
9
 
10
10
  let(:logger_with_opts) do
11
- Volt::VoltLogger.new({
12
- args: args,
13
- class_name: class_name,
14
- method_name: method_name,
15
- run_time: run_time
16
- })
11
+ Volt::VoltLogger.new(args: args,
12
+ class_name: class_name,
13
+ method_name: method_name,
14
+ run_time: run_time)
17
15
  end
18
16
 
19
17
  it 'should log only severity and message wrapped in line breaks' do
20
18
  expect(STDOUT).to receive(:write).with("\n\n[INFO] message\n")
21
- logger.log(Logger::INFO, "message")
19
+ logger.log(Logger::INFO, 'message')
22
20
  end
23
21
 
24
22
  it 'should convert an array of arguments into a string' do
@@ -27,7 +25,7 @@ if RUBY_PLATFORM != 'opal'
27
25
 
28
26
  describe 'when STDOUT is a TTY' do
29
27
  before { allow(STDOUT).to receive(:tty?).and_return(true) }
30
-
28
+
31
29
  it 'should return a blue class name' do
32
30
  expect(logger_with_opts.class_name).to eq("\e[1;34m#{class_name}\e[0;37m")
33
31
  end
@@ -47,7 +47,7 @@ describe '#camelize' do
47
47
  end
48
48
 
49
49
  describe '#headerize' do
50
- it "headerizes" do
50
+ it 'headerizes' do
51
51
  expect('test_case'.headerize).to eq('Test-Case')
52
52
  end
53
53
 
@@ -55,5 +55,5 @@ describe '#headerize' do
55
55
  it 'underscores' do
56
56
  expect(underscored.headerize).to eq(headerized)
57
57
  end
58
- end
59
- end
58
+ end
59
+ end
@@ -32,9 +32,7 @@ describe 'bindings test', type: :feature, sauce: true do
32
32
 
33
33
  # phantom does not support the html5 history api
34
34
  # TODO: We could probably polyfill this in phantom
35
- if ENV['BROWSER'] != 'phantom'
36
- expect(current_path).to eq('/bindings')
37
- end
35
+ expect(current_path).to eq('/bindings') if ENV['BROWSER'] != 'phantom'
38
36
 
39
37
  # Fill in one field and see if it updates the rest
40
38
  fill_in('paramsName1', with: 'Params bindings')
@@ -59,9 +57,7 @@ describe 'bindings test', type: :feature, sauce: true do
59
57
 
60
58
  # phantom does not support the html5 history api
61
59
  # TODO: We could probably polyfill this in phantom
62
- if ENV['BROWSER'] != 'phantom'
63
- expect(current_path).to eq('/bindings')
64
- end
60
+ expect(current_path).to eq('/bindings') if ENV['BROWSER'] != 'phantom'
65
61
 
66
62
  # Fill in one field and see if it updates the rest
67
63
  fill_in('routesName1', with: 'Routes bindings')
@@ -166,9 +162,7 @@ describe 'bindings test', type: :feature, sauce: true do
166
162
 
167
163
  click_link 'Bindings'
168
164
 
169
- if ENV['BROWSER'] != 'phantom'
170
- expect(current_path).to eq('/bindings')
171
- end
165
+ expect(current_path).to eq('/bindings') if ENV['BROWSER'] != 'phantom'
172
166
 
173
167
  expect(find('#paramsCheck3')).to have_content('')
174
168
  # Fill in one field and see if it updates the rest
@@ -11,4 +11,4 @@ describe 'first, last', type: :feature, sauce: true do
11
11
  #
12
12
  # visit '/first_last'
13
13
  # end
14
- end
14
+ end
@@ -6,6 +6,5 @@ describe "missing tags and view's", type: :feature do
6
6
 
7
7
  expect(page).to have_content('view or tag at "some/wrong/path"')
8
8
  expect(page).to have_content('view or tag at "not/a/component"')
9
-
10
9
  end
11
- end
10
+ end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "HTML safe/raw", type: :feature do
3
+ describe 'HTML safe/raw', type: :feature do
4
4
  it 'should render html with the raw helper' do
5
5
  visit '/html_safe'
6
6
 
7
7
  expect(page).to have_selector('button[id="examplebutton"]')
8
8
  end
9
- end
9
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'todos app', type: :feature, sauce: true do
4
+ it 'should add a todo and remove it' do
5
+ visit '/todos'
6
+
7
+ fill_in 'newtodo', :with => 'Todo 1'
8
+ find('#newtodo').native.send_keys(:return)
9
+
10
+ expect(page).to have_content('Todo 1')
11
+
12
+ expect(find('#newtodo').value).to eq('')
13
+
14
+ click_button 'X'
15
+
16
+ expect(page).to_not have_content('Todo 1')
17
+
18
+ # Make sure it deleted
19
+ page.driver.browser.navigate.refresh
20
+ expect(page).to_not have_content('Todo 1')
21
+ end
22
+ end
@@ -6,8 +6,8 @@ describe 'yield binding', type: :feature, sauce: true do
6
6
  end
7
7
 
8
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")
9
+ expect(page).to have_content('My yielded content 1')
10
+ expect(page).to have_content('My yielded content 2')
11
11
  end
12
12
 
13
13
  it 'should render the content from the tag\'s controller when yielding' do
@@ -11,10 +11,10 @@ end
11
11
  describe Volt::Associations do
12
12
  if RUBY_PLATFORM != 'opal'
13
13
  before do
14
- store._people! << {name: 'Jimmy'}
14
+ store._people! << { name: 'Jimmy' }
15
15
  @person = store._people[0]
16
- @person._addresses! << {city: 'Bozeman'}
17
- @person._addresses << {city: 'Portland'}
16
+ @person._addresses! << { city: 'Bozeman' }
17
+ @person._addresses << { city: 'Portland' }
18
18
  end
19
19
 
20
20
  it 'should associate via belongs_to' do
@@ -31,4 +31,4 @@ describe Volt::Associations do
31
31
  expect(addresses[0]._city).to eq('Bozeman')
32
32
  end
33
33
  end
34
- end
34
+ end
@@ -37,7 +37,7 @@ describe Volt::Buffer do
37
37
  expect(then_count).to eq(0)
38
38
  expect(fail_count).to eq(1)
39
39
  expect(error.class).to eq(Volt::Errors)
40
- expect(error).to eq({:name=>["must be at least 5 characters"]})
40
+ expect(error).to eq(name: ['must be at least 5 characters'])
41
41
  end
42
42
  end
43
- end
43
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Volt::Dirty" do
3
+ describe 'Volt::Dirty' do
4
4
  let(:model) do
5
5
  model = Volt::Model.new
6
6
 
@@ -30,7 +30,7 @@ describe "Volt::Dirty" do
30
30
  expect(model.name_was).to eq(nil)
31
31
  expect(model.name_changes).to eq([nil, 'Bob', 'Jimmy', 'Martin', nil])
32
32
 
33
- expect(model.changed_attributes).to eq({:name=>[nil, "Bob", "Jimmy", "Martin", nil]})
33
+ expect(model.changed_attributes).to eq(name: [nil, 'Bob', 'Jimmy', 'Martin', nil])
34
34
  end
35
35
 
36
36
  it 'should say models are changed' do
@@ -46,9 +46,8 @@ describe "Volt::Dirty" do
46
46
  expect(model.changed?(:name)).to eq(false)
47
47
 
48
48
  expect(model.changed?).to eq(false)
49
- model._some_other_attr = "Wow!"
49
+ model._some_other_attr = 'Wow!'
50
50
  expect(model.changed?).to eq(true)
51
-
52
51
  end
53
52
 
54
53
  it 'should reset changes' do
@@ -81,26 +80,26 @@ describe "Volt::Dirty" do
81
80
 
82
81
  it 'should revert changes' do
83
82
  expect(model.attributes).to eq({})
84
- model.attributes = {first: 'Bob', last: 'Smith'}
85
- expect(model.attributes).to eq({first: 'Bob', last: 'Smith'})
83
+ model.attributes = { first: 'Bob', last: 'Smith' }
84
+ expect(model.attributes).to eq(first: 'Bob', last: 'Smith')
86
85
 
87
86
  model.revert_changes!
88
- expect(model.attributes).to eq({first: nil, last: nil})
87
+ expect(model.attributes).to eq(first: nil, last: nil)
89
88
  end
90
89
 
91
90
  it 'should revert changes after a clear_tracked_changed!' do
92
91
  expect(model.attributes).to eq({})
93
- model.attributes = {first: 'Bob', last: 'Smith'}
94
- expect(model.attributes).to eq({first: 'Bob', last: 'Smith'})
92
+ model.attributes = { first: 'Bob', last: 'Smith' }
93
+ expect(model.attributes).to eq(first: 'Bob', last: 'Smith')
95
94
 
96
95
  model.clear_tracked_changes!
97
96
  expect(model.changed_attributes).to eq({})
98
97
 
99
98
  model._first = 'Jimmy'
100
99
  model._last = 'Dean'
101
- expect(model.attributes).to eq({first: 'Jimmy', last: 'Dean'})
100
+ expect(model.attributes).to eq(first: 'Jimmy', last: 'Dean')
102
101
 
103
102
  model.revert_changes!
104
- expect(model.attributes).to eq({first: 'Bob', last: 'Smith'})
103
+ expect(model.attributes).to eq(first: 'Bob', last: 'Smith')
105
104
  end
106
105
  end