acts_as_caesar 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +27 -0
- data/.rvmrc +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.textile +61 -0
- data/Rakefile +65 -0
- data/acts_as_caesar.gemspec +38 -0
- data/lib/acts_as_caesar/modules/act_as_candidate.rb +26 -0
- data/lib/acts_as_caesar/objects/candidate.rb +25 -0
- data/lib/acts_as_caesar/objects/key.rb +15 -0
- data/lib/acts_as_caesar/objects/notification.rb +24 -0
- data/lib/acts_as_caesar/objects/persistence.rb +45 -0
- data/lib/acts_as_caesar/objects/vote.rb +77 -0
- data/lib/acts_as_caesar/objects/voter.rb +43 -0
- data/lib/acts_as_caesar/rack.rb +63 -0
- data/lib/acts_as_caesar/rails/engine.rb +11 -0
- data/lib/acts_as_caesar/rails/view_helpers.rb +17 -0
- data/lib/acts_as_caesar/version.rb +3 -0
- data/lib/acts_as_caesar.rb +21 -0
- data/spec/assets/jasmine_helper.js.coffee +5 -0
- data/spec/assets/jquery_helper.js.coffee +2 -0
- data/spec/assets/vote_cache_spec.js.coffee +63 -0
- data/spec/assets/vote_persistence_spec.js.coffee +31 -0
- data/spec/assets/vote_spec.js.coffee +59 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +3 -0
- data/spec/dummy/app/assets/stylesheets/application.css +52 -0
- data/spec/dummy/app/controllers/albums_controller.rb +58 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/album.rb +15 -0
- data/spec/dummy/app/views/albums/form.html.erb +10 -0
- data/spec/dummy/app/views/albums/index.html.erb +12 -0
- data/spec/dummy/app/views/layouts/application.html.erb +16 -0
- data/spec/dummy/config/application.rb +69 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +34 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/mongoid.rb +2 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/mongoid.yml +7 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/controllers/albums_controller_spec.rb +33 -0
- data/spec/dummy/spec/models/album_spec.rb +8 -0
- data/spec/javascripts/support/jasmine.yml +74 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/modules/act_as_candidate_spec.rb +43 -0
- data/spec/objects/candidate_spec.rb +37 -0
- data/spec/objects/notification_spec.rb +19 -0
- data/spec/objects/persistence_spec.rb +87 -0
- data/spec/objects/vote_spec.rb +131 -0
- data/spec/objects/voter_spec.rb +80 -0
- data/spec/rack_spec.rb +97 -0
- data/spec/rails/engine_spec.rb +11 -0
- data/spec/rails/view_helpers_spec.rb +30 -0
- data/spec/rails_helper.rb +8 -0
- data/spec/spec_helper.rb +4 -0
- data/vendor/assets/javascripts/acts_as_caesar.js +1 -0
- data/vendor/assets/javascripts/initialization.js.coffee +36 -0
- data/vendor/assets/javascripts/vote.js.coffee +45 -0
- data/vendor/assets/javascripts/vote_cache.js.coffee +42 -0
- data/vendor/assets/javascripts/vote_persistence.js.coffee +51 -0
- data/vendor/assets/javascripts/vote_view.js.coffee +23 -0
- metadata +329 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Dummy::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# In the development environment your application's code is reloaded on
|
|
5
|
+
# every request. This slows down response time but is perfect for development
|
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
|
7
|
+
config.cache_classes = false
|
|
8
|
+
|
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
|
10
|
+
config.whiny_nils = true
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Don't care if the mailer can't send
|
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
|
18
|
+
|
|
19
|
+
# Print deprecation notices to the Rails logger
|
|
20
|
+
config.active_support.deprecation = :log
|
|
21
|
+
|
|
22
|
+
# Only use best-standards-support built into browsers
|
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
|
24
|
+
|
|
25
|
+
# Do not compress assets
|
|
26
|
+
config.assets.compress = false
|
|
27
|
+
|
|
28
|
+
# Expands the lines which load the assets
|
|
29
|
+
config.assets.debug = true
|
|
30
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Dummy::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# Code is not reloaded between requests
|
|
5
|
+
config.cache_classes = true
|
|
6
|
+
|
|
7
|
+
# Full error reports are disabled and caching is turned on
|
|
8
|
+
config.consider_all_requests_local = false
|
|
9
|
+
config.action_controller.perform_caching = true
|
|
10
|
+
|
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
|
12
|
+
config.serve_static_assets = false
|
|
13
|
+
|
|
14
|
+
# Compress JavaScripts and CSS
|
|
15
|
+
config.assets.compress = true
|
|
16
|
+
|
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
|
18
|
+
config.assets.compile = false
|
|
19
|
+
|
|
20
|
+
# Generate digests for assets URLs
|
|
21
|
+
config.assets.digest = true
|
|
22
|
+
|
|
23
|
+
# Defaults to Rails.root.join("public/assets")
|
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
|
25
|
+
|
|
26
|
+
# Specifies the header that your server uses for sending files
|
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
|
29
|
+
|
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
|
31
|
+
# config.force_ssl = true
|
|
32
|
+
|
|
33
|
+
# See everything in the log (default is :info)
|
|
34
|
+
# config.log_level = :debug
|
|
35
|
+
|
|
36
|
+
# Prepend all log lines with the following tags
|
|
37
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
|
38
|
+
|
|
39
|
+
# Use a different logger for distributed setups
|
|
40
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
|
41
|
+
|
|
42
|
+
# Use a different cache store in production
|
|
43
|
+
# config.cache_store = :mem_cache_store
|
|
44
|
+
|
|
45
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
|
46
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
|
47
|
+
|
|
48
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
|
49
|
+
# config.assets.precompile += %w( search.js )
|
|
50
|
+
|
|
51
|
+
# Disable delivery errors, bad email addresses will be ignored
|
|
52
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
53
|
+
|
|
54
|
+
# Enable threaded mode
|
|
55
|
+
# config.threadsafe!
|
|
56
|
+
|
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
58
|
+
# the I18n.default_locale when a translation can not be found)
|
|
59
|
+
config.i18n.fallbacks = true
|
|
60
|
+
|
|
61
|
+
# Send deprecation notices to registered listeners
|
|
62
|
+
config.active_support.deprecation = :notify
|
|
63
|
+
|
|
64
|
+
# Log the query plan for queries taking more than this (works
|
|
65
|
+
# with SQLite, MySQL, and PostgreSQL)
|
|
66
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
|
67
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Dummy::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# The test environment is used exclusively to run your application's
|
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
8
|
+
config.cache_classes = true
|
|
9
|
+
|
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
|
11
|
+
config.serve_static_assets = true
|
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
|
13
|
+
|
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
|
15
|
+
config.whiny_nils = true
|
|
16
|
+
|
|
17
|
+
# Show full error reports and disable caching
|
|
18
|
+
config.consider_all_requests_local = true
|
|
19
|
+
config.action_controller.perform_caching = false
|
|
20
|
+
|
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
|
22
|
+
config.action_dispatch.show_exceptions = false
|
|
23
|
+
|
|
24
|
+
# Disable request forgery protection in test environment
|
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
|
26
|
+
|
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
|
29
|
+
# ActionMailer::Base.deliveries array.
|
|
30
|
+
config.action_mailer.delivery_method = :test
|
|
31
|
+
|
|
32
|
+
# Print deprecation notices to the stderr
|
|
33
|
+
config.active_support.deprecation = :stderr
|
|
34
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
|
5
|
+
|
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Add new inflection rules using the following format
|
|
4
|
+
# (all these examples are active by default):
|
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
|
8
|
+
# inflect.irregular 'person', 'people'
|
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
|
10
|
+
# end
|
|
11
|
+
#
|
|
12
|
+
# These inflection rules are supported but not enabled by default:
|
|
13
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
|
14
|
+
# inflect.acronym 'RESTful'
|
|
15
|
+
# end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
|
7
|
+
Dummy::Application.config.secret_token = 'c6930a0b44bc2175d4f15c389d08698b2e0c4cac1ba8fac23481af22cb7092a868c3d2833575dfd41b1a6fec25d42441e74dfffea3936701c59bc75cf4c5339a'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
|
4
|
+
|
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
|
6
|
+
# which shouldn't be used to store highly confidential information
|
|
7
|
+
# (create the session table with "rails generate session_migration")
|
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
#
|
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
|
4
|
+
# is enabled by default.
|
|
5
|
+
|
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
|
8
|
+
wrap_parameters format: [:json]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Disable root element in JSON by default.
|
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
|
13
|
+
self.include_root_in_json = false
|
|
14
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/404.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/422.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/500.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
23
|
+
</div>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
+
require 'rails/commands'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
describe AlbumsController do
|
|
4
|
+
context "viewing the list of albums" do
|
|
5
|
+
before { get :index }
|
|
6
|
+
it { should render_template :index }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "viewing the new album form" do
|
|
10
|
+
before { get :new }
|
|
11
|
+
it { should render_template :form }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "viewing the edit album form" do
|
|
15
|
+
before { get :edit, id: Album.create(name: "Hybrid Theory") }
|
|
16
|
+
it { should render_template :form }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context "creating an album" do
|
|
20
|
+
before { post :create, album: { name: "Minutes To Midnight" } }
|
|
21
|
+
it { should redirect_to albums_path }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "updating an album" do
|
|
25
|
+
before { put :update, id: Album.create(name: "Live In Texas"), album: { name: "Reanimation" } }
|
|
26
|
+
it { should redirect_to albums_path }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "deleting an album" do
|
|
30
|
+
before { delete :destroy, id: Album.create(name: "Meteora") }
|
|
31
|
+
it { should redirect_to albums_path }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# src_files
|
|
2
|
+
#
|
|
3
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
|
4
|
+
# Default: []
|
|
5
|
+
#
|
|
6
|
+
# EXAMPLE:
|
|
7
|
+
#
|
|
8
|
+
# src_files:
|
|
9
|
+
# - lib/source1.js
|
|
10
|
+
# - lib/source2.js
|
|
11
|
+
# - dist/**/*.js
|
|
12
|
+
#
|
|
13
|
+
src_files:
|
|
14
|
+
- '**/*.js'
|
|
15
|
+
|
|
16
|
+
# stylesheets
|
|
17
|
+
#
|
|
18
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
|
19
|
+
# Default: []
|
|
20
|
+
#
|
|
21
|
+
# EXAMPLE:
|
|
22
|
+
#
|
|
23
|
+
# stylesheets:
|
|
24
|
+
# - css/style.css
|
|
25
|
+
# - stylesheets/*.css
|
|
26
|
+
#
|
|
27
|
+
stylesheets:
|
|
28
|
+
|
|
29
|
+
# helpers
|
|
30
|
+
#
|
|
31
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
|
32
|
+
# Default: ["helpers/**/*.js"]
|
|
33
|
+
#
|
|
34
|
+
# EXAMPLE:
|
|
35
|
+
#
|
|
36
|
+
# helpers:
|
|
37
|
+
# - helpers/**/*.js
|
|
38
|
+
#
|
|
39
|
+
helpers:
|
|
40
|
+
- '*_helper.js'
|
|
41
|
+
|
|
42
|
+
# spec_files
|
|
43
|
+
#
|
|
44
|
+
# Return an array of filepaths relative to spec_dir to include.
|
|
45
|
+
# Default: ["**/*[sS]pec.js"]
|
|
46
|
+
#
|
|
47
|
+
# EXAMPLE:
|
|
48
|
+
#
|
|
49
|
+
# spec_files:
|
|
50
|
+
# - **/*[sS]pec.js
|
|
51
|
+
#
|
|
52
|
+
spec_files:
|
|
53
|
+
|
|
54
|
+
# src_dir
|
|
55
|
+
#
|
|
56
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
|
57
|
+
# Default: project root
|
|
58
|
+
#
|
|
59
|
+
# EXAMPLE:
|
|
60
|
+
#
|
|
61
|
+
# src_dir: public
|
|
62
|
+
#
|
|
63
|
+
src_dir: spec/javascripts/compiled
|
|
64
|
+
|
|
65
|
+
# spec_dir
|
|
66
|
+
#
|
|
67
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
|
68
|
+
# Default: spec/javascripts
|
|
69
|
+
#
|
|
70
|
+
# EXAMPLE:
|
|
71
|
+
#
|
|
72
|
+
# spec_dir: spec/javascripts
|
|
73
|
+
#
|
|
74
|
+
spec_dir:
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Jasmine
|
|
2
|
+
class Config
|
|
3
|
+
|
|
4
|
+
# Add your overrides or custom config code here
|
|
5
|
+
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Note - this is necessary for rspec2, which has removed the backtrace
|
|
11
|
+
module Jasmine
|
|
12
|
+
class SpecBuilder
|
|
13
|
+
def declare_spec(parent, spec)
|
|
14
|
+
me = self
|
|
15
|
+
example_name = spec["name"]
|
|
16
|
+
@spec_ids << spec["id"]
|
|
17
|
+
backtrace = @example_locations[parent.description + " " + example_name]
|
|
18
|
+
parent.it example_name, {} do
|
|
19
|
+
me.report_spec(spec["id"])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'jasmine'
|
|
5
|
+
jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
|
|
6
|
+
require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
|
|
7
|
+
if Jasmine::Dependencies.rspec2?
|
|
8
|
+
require 'rspec'
|
|
9
|
+
else
|
|
10
|
+
require 'spec'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
jasmine_config = Jasmine::Config.new
|
|
14
|
+
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
|
|
15
|
+
|
|
16
|
+
should_stop = false
|
|
17
|
+
|
|
18
|
+
if Jasmine::Dependencies.rspec2?
|
|
19
|
+
RSpec.configuration.after(:suite) do
|
|
20
|
+
spec_builder.stop if should_stop
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
Spec::Runner.configure do |config|
|
|
24
|
+
config.after(:suite) do
|
|
25
|
+
spec_builder.stop if should_stop
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
spec_builder.start
|
|
31
|
+
should_stop = true
|
|
32
|
+
spec_builder.declare_suites
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require_relative '../../lib/acts_as_caesar/modules/act_as_candidate'
|
|
2
|
+
require_relative '../../lib/acts_as_caesar/objects/notification'
|
|
3
|
+
|
|
4
|
+
class TestActAsCandidate
|
|
5
|
+
attr_accessor :score
|
|
6
|
+
include ActsAsCaesar::ActAsCandidate
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe ActsAsCaesar::ActAsCandidate do
|
|
10
|
+
subject { TestActAsCandidate.new }
|
|
11
|
+
|
|
12
|
+
it "should setup a subscription using the class name as a key" do
|
|
13
|
+
ActsAsCaesar::Notification.subscriptions.map do |s|
|
|
14
|
+
s[:options][:key]
|
|
15
|
+
end.should include /^#{subject.class.name.downcase}\_[\da-f]+$/
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "when calculating score" do
|
|
19
|
+
before(:each) do
|
|
20
|
+
ActsAsCaesar::Candidate.any_instance.should_receive(:total).and_return(456)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should return an integer" do
|
|
24
|
+
subject.total_candidate_score.should == 456
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "when updating the score" do
|
|
29
|
+
before(:each) do
|
|
30
|
+
subject.should_receive(:total_candidate_score).and_return(987)
|
|
31
|
+
subject.should_receive(:save!).and_return(true)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should set the score to the total candidate score" do
|
|
35
|
+
subject.update_total_candidate_score
|
|
36
|
+
subject.score.should == 987
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should return true" do
|
|
40
|
+
subject.update_total_candidate_score.should == true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require_relative '../../lib/acts_as_caesar/objects/candidate'
|
|
3
|
+
require_relative '../../lib/acts_as_caesar/objects/persistence'
|
|
4
|
+
|
|
5
|
+
describe ActsAsCaesar::Candidate do
|
|
6
|
+
let(:source) { mock('answer', id: 123) }
|
|
7
|
+
let(:candidate) { ActsAsCaesar::Candidate.new(source) }
|
|
8
|
+
subject { candidate }
|
|
9
|
+
|
|
10
|
+
context "the key" do
|
|
11
|
+
subject { candidate.key }
|
|
12
|
+
|
|
13
|
+
it "should return the custom key when set" do
|
|
14
|
+
source.should_receive(:acts_as_caesar_key).and_return('banana')
|
|
15
|
+
subject.should == 'banana'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should default to being generated from class name and id" do
|
|
19
|
+
subject.should == "#{source.class.name.downcase}_123"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "when calculating the total" do
|
|
24
|
+
it "should load from persistence layer" do
|
|
25
|
+
ActsAsCaesar::Persistence.should_receive(:vote_total).with(candidate).and_return(123)
|
|
26
|
+
candidate.total.should == 123
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "when generating JSON" do
|
|
31
|
+
subject { candidate.to_json }
|
|
32
|
+
|
|
33
|
+
it "should output a JSON string containing the key" do
|
|
34
|
+
subject.should == candidate.key
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative '../../lib/acts_as_caesar/objects/notification'
|
|
2
|
+
|
|
3
|
+
describe ActsAsCaesar::Notification do
|
|
4
|
+
subject { ActsAsCaesar::Notification }
|
|
5
|
+
|
|
6
|
+
it "should hold subscriptions" do
|
|
7
|
+
count = subject.subscriptions.size
|
|
8
|
+
subject.subscribe(key: /^class\_[\da-f]+$/) do |c|
|
|
9
|
+
puts c
|
|
10
|
+
end
|
|
11
|
+
subject.subscriptions.size.should == count + 1
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should receive candidate publishings with a key" do
|
|
15
|
+
lambda {
|
|
16
|
+
subject.publish(mock('candidate', key: 'somerandomkeythatwillnotmatch'))
|
|
17
|
+
}.should_not raise_error
|
|
18
|
+
end
|
|
19
|
+
end
|