popolo 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -2
  3. data/Rakefile +13 -4
  4. data/app/models/popolo/area.rb +3 -3
  5. data/app/models/popolo/contact_detail.rb +4 -0
  6. data/app/models/popolo/motion.rb +3 -1
  7. data/app/models/popolo/organization.rb +8 -4
  8. data/app/models/popolo/other_name.rb +12 -0
  9. data/app/models/popolo/person.rb +3 -3
  10. data/app/models/popolo/post.rb +2 -0
  11. data/app/models/popolo/vote_event.rb +1 -1
  12. data/lib/popolo/version.rb +1 -1
  13. data/spec/controllers/popolo/memberships_controller_spec.rb +13 -11
  14. data/spec/controllers/popolo/organizations_controller_spec.rb +18 -17
  15. data/spec/controllers/popolo/people_controller_spec.rb +13 -11
  16. data/spec/controllers/popolo/posts_controller_spec.rb +13 -11
  17. data/spec/dummy/README.rdoc +28 -0
  18. data/spec/dummy/Rakefile +1 -2
  19. data/spec/dummy/app/assets/javascripts/application.js +3 -3
  20. data/spec/dummy/app/assets/stylesheets/application.css +5 -4
  21. data/spec/dummy/app/controllers/application_controller.rb +3 -1
  22. data/spec/dummy/app/views/layouts/application.html.erb +2 -4
  23. data/spec/dummy/bin/bundle +3 -0
  24. data/spec/dummy/bin/rails +4 -0
  25. data/spec/dummy/bin/rake +4 -0
  26. data/spec/dummy/config/application.rb +1 -38
  27. data/spec/dummy/config/boot.rb +4 -9
  28. data/spec/dummy/config/environment.rb +3 -3
  29. data/spec/dummy/config/environments/development.rb +19 -19
  30. data/spec/dummy/config/environments/production.rb +44 -28
  31. data/spec/dummy/config/environments/test.rb +17 -15
  32. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  33. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  34. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  35. data/spec/dummy/config/initializers/inflections.rb +16 -0
  36. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  37. data/spec/dummy/config/initializers/session_store.rb +1 -6
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  39. data/spec/dummy/config/locales/en.yml +20 -2
  40. data/spec/dummy/config/mongoid.yml +21 -20
  41. data/spec/dummy/config/secrets.yml +22 -0
  42. data/spec/dummy/config.ru +1 -1
  43. data/spec/dummy/log/development.log +0 -0
  44. data/spec/dummy/log/test.log +4423 -0
  45. data/spec/dummy/public/404.html +54 -13
  46. data/spec/dummy/public/422.html +54 -13
  47. data/spec/dummy/public/500.html +53 -12
  48. data/spec/helpers/popolo_helper_spec.rb +2 -2
  49. data/spec/models/popolo/area_spec.rb +4 -2
  50. data/spec/models/popolo/contact_detail_spec.rb +6 -4
  51. data/spec/models/popolo/count_spec.rb +6 -4
  52. data/spec/models/popolo/date_string_spec.rb +92 -90
  53. data/spec/models/popolo/group_result_spec.rb +6 -4
  54. data/spec/models/popolo/identifier_spec.rb +5 -3
  55. data/spec/models/popolo/link_spec.rb +5 -3
  56. data/spec/models/popolo/membership_spec.rb +9 -7
  57. data/spec/models/popolo/motion_spec.rb +5 -3
  58. data/spec/models/popolo/organization_spec.rb +6 -4
  59. data/spec/models/popolo/other_name_spec.rb +7 -5
  60. data/spec/models/popolo/person_spec.rb +22 -20
  61. data/spec/models/popolo/post_spec.rb +5 -3
  62. data/spec/models/popolo/vote_event_spec.rb +4 -2
  63. data/spec/models/popolo/vote_spec.rb +4 -2
  64. data/spec/popolo_spec.rb +15 -15
  65. data/spec/rails_helper.rb +68 -0
  66. data/spec/routing/popolo/memberships_routing_spec.rb +8 -6
  67. data/spec/routing/popolo/organizations_routing_spec.rb +11 -9
  68. data/spec/routing/popolo/people_routing_spec.rb +8 -6
  69. data/spec/routing/popolo/posts_routing_spec.rb +8 -6
  70. data/spec/spec_helper.rb +70 -80
  71. data/spec/support/{shared_examples.rb → shared_examples/date.rb} +1 -1
  72. metadata +52 -89
  73. data/spec/controllers/popolo_controller_spec.rb +0 -4
  74. data/spec/dummy/config/initializers/secret_token.rb +0 -7
@@ -1,5 +1,7 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo::Post do
4
- it {should validate_presence_of :organization_id}
3
+ module Popolo
4
+ RSpec.describe Post do
5
+ it {should validate_presence_of :organization_id}
6
+ end
5
7
  end
@@ -1,4 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo::VoteEvent do
3
+ module Popolo
4
+ RSpec.describe VoteEvent do
5
+ end
4
6
  end
@@ -1,4 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo::Vote do
3
+ module Popolo
4
+ RSpec.describe Vote do
5
+ end
4
6
  end
data/spec/popolo_spec.rb CHANGED
@@ -1,10 +1,10 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo do
3
+ RSpec.describe Popolo do
4
4
  describe '.storage_options' do
5
5
  context 'when using default storage options' do
6
6
  it 'should use default storage options' do
7
- Popolo.storage_options.should == {}
7
+ expect(Popolo.storage_options).to eq({})
8
8
  end
9
9
  end
10
10
 
@@ -14,13 +14,13 @@ describe Popolo do
14
14
  end
15
15
 
16
16
  it 'should use custom storage options' do
17
- Popolo.storage_options.should == {database: :test}
17
+ expect(Popolo.storage_options).to eq({database: :test})
18
18
 
19
19
  # We would need to reload the app.
20
- # Popolo::Membership.storage_options.should == {database: :test}
21
- # Popolo::Organization.storage_options.should == {database: :test}
22
- # Popolo::Person.storage_options.should == {database: :test}
23
- # Popolo::Post.storage_options.should == {database: :test}
20
+ # expect(Popolo::Membership.storage_options).to eq({database: :test})
21
+ # expect(Popolo::Organization.storage_options).to eq({database: :test})
22
+ # expect(Popolo::Person.storage_options).to eq({database: :test})
23
+ # expect(Popolo::Post.storage_options).to eq({database: :test})
24
24
  end
25
25
 
26
26
  after do
@@ -32,7 +32,7 @@ describe Popolo do
32
32
  describe '.storage_options_per_class' do
33
33
  context 'when using default storage options' do
34
34
  it 'should use default storage options' do
35
- Popolo.storage_options_per_class.should == {}
35
+ expect(Popolo.storage_options_per_class).to eq({})
36
36
  end
37
37
  end
38
38
 
@@ -47,18 +47,18 @@ describe Popolo do
47
47
  end
48
48
 
49
49
  it 'should use custom storage options' do
50
- Popolo.storage_options_per_class.should == {
50
+ expect(Popolo.storage_options_per_class).to eq({
51
51
  :Membership => {collection: 'a'},
52
52
  :Organization => {collection: 'b'},
53
53
  :Person => {collection: 'c'},
54
54
  :Post => {collection: 'd'},
55
- }
55
+ })
56
56
 
57
57
  # We would need to reload the app.
58
- # Popolo::Membership.storage_options.should == {collection: 'a'}
59
- # Popolo::Organization.storage_options.should == {collection: 'b'}
60
- # Popolo::Person.storage_options.should == {collection: 'c'}
61
- # Popolo::Post.storage_options.should == {collection: 'd'}
58
+ # expect(Popolo::Membership.storage_options).to eq({collection: 'a'})
59
+ # expect(Popolo::Organization.storage_options).to eq({collection: 'b'})
60
+ # expect(Popolo::Person.storage_options).to eq({collection: 'c'})
61
+ # expect(Popolo::Post.storage_options).to eq({collection: 'd'})
62
62
  end
63
63
 
64
64
  after do
@@ -0,0 +1,68 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ require 'spec_helper'
8
+ require File.expand_path("../dummy/config/environment", __FILE__)
9
+ require 'rspec/rails'
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+
13
+ # Requires supporting ruby files with custom matchers and macros, etc, in
14
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
15
+ # run as spec files by default. This means that files in spec/support that end
16
+ # in _spec.rb will both be required and run as specs, causing the specs to be
17
+ # run twice. It is recommended that you do not name files matching this glob to
18
+ # end with _spec.rb. You can configure this pattern with the --pattern
19
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
20
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
21
+
22
+ # Checks for pending migrations before tests are run.
23
+ # If you are not using ActiveRecord, you can remove this line.
24
+ # ActiveRecord::Migration.maintain_test_schema!
25
+
26
+ require 'database_cleaner'
27
+ require 'mongoid-rspec'
28
+ require 'factory_girl_rails'
29
+
30
+ RSpec.configure do |config|
31
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
32
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
33
+
34
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
35
+ # examples within a transaction, remove the following line or assign false
36
+ # instead of true.
37
+ config.use_transactional_fixtures = true
38
+
39
+ # RSpec Rails can automatically mix in different behaviours to your tests
40
+ # based on their file location, for example enabling you to call `get` and
41
+ # `post` in specs under `spec/controllers`.
42
+ #
43
+ # You can disable this behaviour by removing the line below, and instead
44
+ # explicitly tag your specs with their type, e.g.:
45
+ #
46
+ # RSpec.describe UsersController, :type => :controller do
47
+ # # ...
48
+ # end
49
+ #
50
+ # The different available types are documented in the features, such as in
51
+ # https://relishapp.com/rspec/rspec-rails/docs
52
+ config.infer_spec_type_from_file_location!
53
+
54
+ config.include Mongoid::Matchers
55
+
56
+ config.before(:suite) do
57
+ DatabaseCleaner.strategy = :truncation
58
+ DatabaseCleaner.clean_with(:truncation)
59
+ end
60
+
61
+ config.before(:each) do
62
+ DatabaseCleaner.start
63
+ end
64
+
65
+ config.after(:each) do
66
+ DatabaseCleaner.clean
67
+ end
68
+ end
@@ -1,11 +1,13 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo::MembershipsController do
4
- describe 'routing' do
5
- routes { Popolo::Engine.routes }
3
+ module Popolo
4
+ RSpec.describe MembershipsController, type: :routing do
5
+ describe 'routing' do
6
+ routes { Engine.routes }
6
7
 
7
- it 'routes to #show' do
8
- get('/memberships/1').should route_to('popolo/memberships#show', id: '1')
8
+ it 'routes to #show' do
9
+ expect(get: '/memberships/1').to route_to('popolo/memberships#show', id: '1')
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -1,15 +1,17 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo::OrganizationsController do
4
- describe 'routing' do
5
- routes { Popolo::Engine.routes }
3
+ module Popolo
4
+ RSpec.describe OrganizationsController, type: :routing do
5
+ describe 'routing' do
6
+ routes { Engine.routes }
6
7
 
7
- it 'routes to #index' do
8
- get('/organizations').should route_to('popolo/organizations#index')
9
- end
8
+ it 'routes to #index' do
9
+ expect(get: '/organizations').to route_to('popolo/organizations#index')
10
+ end
10
11
 
11
- it 'routes to #show' do
12
- get('/organizations/1').should route_to('popolo/organizations#show', id: '1')
12
+ it 'routes to #show' do
13
+ expect(get: '/organizations/1').to route_to('popolo/organizations#show', id: '1')
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -1,11 +1,13 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo::PeopleController do
4
- describe 'routing' do
5
- routes { Popolo::Engine.routes }
3
+ module Popolo
4
+ RSpec.describe PeopleController, type: :routing do
5
+ describe 'routing' do
6
+ routes { Engine.routes }
6
7
 
7
- it 'routes to #show' do
8
- get('/people/1').should route_to('popolo/people#show', id: '1')
8
+ it 'routes to #show' do
9
+ expect(get: '/people/1').to route_to('popolo/people#show', id: '1')
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -1,11 +1,13 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Popolo::PostsController do
4
- describe 'routing' do
5
- routes { Popolo::Engine.routes }
3
+ module Popolo
4
+ RSpec.describe PostsController, type: :routing do
5
+ describe 'routing' do
6
+ routes { Engine.routes }
6
7
 
7
- it 'routes to #show' do
8
- get('/posts/1').should route_to('popolo/posts#show', id: '1')
8
+ it 'routes to #show' do
9
+ expect(get: '/posts/1').to route_to('popolo/posts#show', id: '1')
10
+ end
9
11
  end
10
12
  end
11
13
  end
data/spec/spec_helper.rb CHANGED
@@ -1,86 +1,76 @@
1
- require 'spork'
2
-
3
- Spork.prefork do
4
- ENV["RAILS_ENV"] ||= 'test'
5
-
6
- require 'coveralls'
7
- Coveralls.wear!
8
-
9
- require 'rails/application'
10
- # Prevent Spork from caching the routes.
11
- Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
12
- # Prevent Spork from caching Popolo classes (see below).
13
- Spork.trap_method(Rails::Application, :eager_load!)
14
-
15
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
16
- require 'rspec/rails'
17
-
18
- # Requires supporting ruby files with custom matchers and macros, etc,
19
- # in spec/support/ and its subdirectories.
20
- Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f}
21
-
22
- # Prevent Spork from caching Popolo classes (see above).
23
- Rails.application.railties.all do |railtie|
24
- unless railtie.respond_to?(:engine_name) && railtie.engine_name == 'popolo'
25
- railtie.eager_load!
26
- end
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ # These two settings work together to allow you to limit a spec run
21
+ # to individual examples or groups you care about by tagging them with
22
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
23
+ # get run.
24
+ config.filter_run :focus
25
+ config.run_all_when_everything_filtered = true
26
+
27
+ # Many RSpec users commonly either run the entire suite or an individual
28
+ # file, and it's useful to allow more verbose output when running an
29
+ # individual spec file.
30
+ if config.files_to_run.one?
31
+ # Use the documentation formatter for detailed output,
32
+ # unless a formatter has already been configured
33
+ # (e.g. via a command-line flag).
34
+ config.default_formatter = 'doc'
27
35
  end
28
36
 
29
- # Create non-Popolo indexes.
30
- Rails.application.railties.engines.each do |engine|
31
- unless engine.engine_name == 'popolo'
32
- engine.paths["app/models"].expanded.each do |path|
33
- Rails::Mongoid.create_indexes("#{path}/**/*.rb")
34
- end
35
- end
37
+ # Print the 10 slowest examples and example groups at the
38
+ # end of the spec run, to help surface which specs are running
39
+ # particularly slow.
40
+ # config.profile_examples = 10
41
+
42
+ # Run specs in random order to surface order dependencies. If you find an
43
+ # order dependency and want to debug it, you can fix the order by providing
44
+ # the seed, which is printed after each run.
45
+ # --seed 1234
46
+ # config.order = :random
47
+
48
+ # Seed global randomization in this process using the `--seed` CLI option.
49
+ # Setting this allows you to use `--seed` to deterministically reproduce
50
+ # test failures related to randomization by passing the same `--seed` value
51
+ # as the one that triggered the failure.
52
+ Kernel.srand config.seed
53
+
54
+ # rspec-expectations config goes here. You can use an alternate
55
+ # assertion/expectation library such as wrong or the stdlib/minitest
56
+ # assertions if you prefer.
57
+ config.expect_with :rspec do |expectations|
58
+ # Enable only the newer, non-monkey-patching expect syntax.
59
+ # For more details, see:
60
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
61
+ expectations.syntax = :expect
36
62
  end
37
63
 
38
- require 'database_cleaner'
39
- require 'mongoid-rspec'
40
-
41
- RSpec.configure do |config|
42
- config.include Mongoid::Matchers
43
-
44
- config.mock_with :rspec
45
-
46
- config.after(:each) do
47
- DatabaseCleaner.clean
48
- end
49
-
50
- # http://railscasts.com/episodes/285-spork
51
- config.treat_symbols_as_metadata_keys_with_true_values = true
52
- config.run_all_when_everything_filtered = true
53
- config.filter_run focus: true
54
- config.infer_spec_type_from_file_location!
64
+ # rspec-mocks config goes here. You can use an alternate test double
65
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
66
+ config.mock_with :rspec do |mocks|
67
+ # Enable only the newer, non-monkey-patching expect syntax.
68
+ # For more details, see:
69
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
70
+ mocks.syntax = :expect
71
+
72
+ # Prevents you from mocking or stubbing a method that does not exist on
73
+ # a real object. This is generally recommended.
74
+ mocks.verify_partial_doubles = true
55
75
  end
56
76
  end
57
-
58
- Spork.each_run do
59
- # DatabaseCleaner will not truncate system.indexes between tests, but it
60
- # should be truncated before running the full test suite.
61
- Mongoid::Sessions.default.drop
62
-
63
- # It's now okay to load Popolo.
64
- Rails.application.railties.engines.each do |engine|
65
- if engine.engine_name == 'popolo'
66
- engine.eager_load!
67
- end
68
- end
69
-
70
- # Create Popolo indexes.
71
- Rails.application.railties.engines.each do |engine|
72
- if engine.engine_name == 'popolo'
73
- engine.paths["app/models"].expanded.each do |path|
74
- Rails::Mongoid.create_indexes("#{path}/**/*.rb")
75
- end
76
- end
77
- end
78
-
79
- # Create dummy indexes.
80
- Rails::Mongoid.create_indexes(File.expand_path("../dummy/app/models/**/*.rb", __FILE__))
81
-
82
- # @todo I18n.backend.reload!
83
-
84
- require 'factory_girl_rails'
85
- FactoryGirl.reload
86
- end
@@ -1,4 +1,4 @@
1
- shared_examples_for 'a model with a date attribute' do |attribute|
1
+ RSpec.shared_examples 'a model with a date attribute' do |attribute|
2
2
  it {
3
3
  should validate_format_of(attribute).
4
4
  # 4.1.2.2 Basic format