active_mocker 1.4.2 → 1.5

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.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +35 -29
  4. data/lib/active_mocker.rb +3 -1
  5. data/lib/active_mocker/active_record.rb +27 -5
  6. data/lib/active_mocker/active_record/scope.rb +5 -5
  7. data/lib/active_mocker/active_record/unknown_module.rb +4 -4
  8. data/lib/active_mocker/generate.rb +36 -15
  9. data/lib/active_mocker/loaded_mocks.rb +60 -54
  10. data/lib/active_mocker/mock.rb +24 -0
  11. data/lib/active_mocker/mock/association.rb +6 -0
  12. data/lib/{active_mock → active_mocker/mock}/base.rb +43 -89
  13. data/lib/{active_mock → active_mocker/mock}/collection.rb +14 -7
  14. data/lib/{active_mock → active_mocker/mock}/do_nothing_active_record_methods.rb +7 -1
  15. data/lib/active_mocker/mock/exceptions.rb +25 -0
  16. data/lib/active_mocker/mock/has_and_belongs_to_many.rb +6 -0
  17. data/lib/active_mocker/mock/has_many.rb +60 -0
  18. data/lib/active_mocker/mock/hash_process.rb +19 -0
  19. data/lib/active_mocker/mock/mock_abilities.rb +98 -0
  20. data/lib/{active_mock → active_mocker/mock}/next_id.rb +7 -2
  21. data/lib/{active_mock → active_mocker/mock}/object_inspect.rb +3 -1
  22. data/lib/{active_mock → active_mocker/mock}/queries.rb +32 -29
  23. data/lib/active_mocker/mock/records.rb +62 -0
  24. data/lib/{active_mock → active_mocker/mock}/relation.rb +4 -3
  25. data/lib/active_mocker/mock/template_methods.rb +39 -0
  26. data/lib/active_mocker/mock_template.erb +45 -31
  27. data/lib/active_mocker/model_reader.rb +29 -0
  28. data/lib/active_mocker/model_schema.rb +23 -16
  29. data/lib/active_mocker/model_schema/generate.rb +19 -8
  30. data/lib/active_mocker/railtie.rb +17 -0
  31. data/lib/active_mocker/reparameterize.rb +2 -4
  32. data/lib/active_mocker/rspec_helper.rb +18 -0
  33. data/lib/active_mocker/task.rake +15 -0
  34. data/lib/active_mocker/version.rb +1 -1
  35. metadata +80 -206
  36. data/.gitignore +0 -19
  37. data/.hound.yml +0 -0
  38. data/.travis.yml +0 -5
  39. data/Gemfile +0 -4
  40. data/Rakefile +0 -26
  41. data/active_mocker.gemspec +0 -40
  42. data/lib/active_mock/association.rb +0 -7
  43. data/lib/active_mock/creators.rb +0 -25
  44. data/lib/active_mock/has_and_belongs_to_many.rb +0 -7
  45. data/lib/active_mock/has_many.rb +0 -54
  46. data/lib/active_mock/records.rb +0 -83
  47. data/lib/active_mocker/active_mock.rb +0 -26
  48. data/lib/active_mocker/active_record/const_missing.rb +0 -5
  49. data/lib/active_mocker/class_exists.rb +0 -12
  50. data/lib/active_mocker/const_sets.rb +0 -24
  51. data/lib/active_mocker/mock_task.rb +0 -12
  52. data/sample_app_rails_4/.idea/.generators +0 -8
  53. data/sample_app_rails_4/.idea/.name +0 -1
  54. data/sample_app_rails_4/.idea/.rakeTasks +0 -7
  55. data/sample_app_rails_4/.idea/dataSources.ids +0 -141
  56. data/sample_app_rails_4/.idea/dataSources.xml +0 -36
  57. data/sample_app_rails_4/.idea/dictionaries/zeisler.xml +0 -3
  58. data/sample_app_rails_4/.idea/encodings.xml +0 -5
  59. data/sample_app_rails_4/.idea/inspectionProfiles/Project_Default.xml +0 -20
  60. data/sample_app_rails_4/.idea/inspectionProfiles/profiles_settings.xml +0 -7
  61. data/sample_app_rails_4/.idea/misc.xml +0 -5
  62. data/sample_app_rails_4/.idea/modules.xml +0 -10
  63. data/sample_app_rails_4/.idea/runConfigurations/Development__sample_app_rails_4.xml +0 -28
  64. data/sample_app_rails_4/.idea/runConfigurations/Production__sample_app_rails_4.xml +0 -28
  65. data/sample_app_rails_4/.idea/runConfigurations/spec__sample_app_rails_4.xml +0 -26
  66. data/sample_app_rails_4/.idea/runConfigurations/test__sample_app_rails_4.xml +0 -28
  67. data/sample_app_rails_4/.idea/sample_app_rails_4.iml +0 -262
  68. data/sample_app_rails_4/.idea/scopes/scope_settings.xml +0 -5
  69. data/sample_app_rails_4/.idea/vcs.xml +0 -7
  70. data/sample_app_rails_4/.idea/workspace.xml +0 -619
  71. data/sample_app_rails_4/.rspec +0 -1
  72. data/sample_app_rails_4/.secret +0 -1
  73. data/sample_app_rails_4/Gemfile +0 -13
  74. data/sample_app_rails_4/Guardfile +0 -53
  75. data/sample_app_rails_4/LICENSE +0 -21
  76. data/sample_app_rails_4/README.md +0 -25
  77. data/sample_app_rails_4/README.nitrous.md +0 -20
  78. data/sample_app_rails_4/Rakefile +0 -6
  79. data/sample_app_rails_4/app/assets/images/rails.png +0 -0
  80. data/sample_app_rails_4/app/assets/javascripts/application.js +0 -17
  81. data/sample_app_rails_4/app/assets/javascripts/sessions.js.coffee +0 -3
  82. data/sample_app_rails_4/app/assets/javascripts/static_pages.js.coffee +0 -3
  83. data/sample_app_rails_4/app/assets/javascripts/users.js.coffee +0 -3
  84. data/sample_app_rails_4/app/assets/stylesheets/application.css +0 -13
  85. data/sample_app_rails_4/app/assets/stylesheets/custom.css.scss +0 -246
  86. data/sample_app_rails_4/app/assets/stylesheets/sessions.css.scss +0 -3
  87. data/sample_app_rails_4/app/assets/stylesheets/static_pages.css.scss +0 -3
  88. data/sample_app_rails_4/app/assets/stylesheets/users.css.scss +0 -3
  89. data/sample_app_rails_4/app/controllers/application_controller.rb +0 -6
  90. data/sample_app_rails_4/app/controllers/concerns/.keep +0 -0
  91. data/sample_app_rails_4/app/controllers/microposts_controller.rb +0 -31
  92. data/sample_app_rails_4/app/controllers/relationships_controller.rb +0 -21
  93. data/sample_app_rails_4/app/controllers/sessions_controller.rb +0 -21
  94. data/sample_app_rails_4/app/controllers/static_pages_controller.rb +0 -18
  95. data/sample_app_rails_4/app/controllers/users_controller.rb +0 -80
  96. data/sample_app_rails_4/app/helpers/application_helper.rb +0 -12
  97. data/sample_app_rails_4/app/helpers/sessions_helper.rb +0 -49
  98. data/sample_app_rails_4/app/helpers/static_pages_helper.rb +0 -2
  99. data/sample_app_rails_4/app/helpers/users_helper.rb +0 -10
  100. data/sample_app_rails_4/app/mailers/.keep +0 -0
  101. data/sample_app_rails_4/app/models/.keep +0 -0
  102. data/sample_app_rails_4/app/models/concerns/.keep +0 -0
  103. data/sample_app_rails_4/app/models/micropost.rb +0 -24
  104. data/sample_app_rails_4/app/models/relationship.rb +0 -6
  105. data/sample_app_rails_4/app/models/user.rb +0 -39
  106. data/sample_app_rails_4/app/views/layouts/_footer.html.erb +0 -13
  107. data/sample_app_rails_4/app/views/layouts/_header.html.erb +0 -31
  108. data/sample_app_rails_4/app/views/layouts/_shim.html.erb +0 -3
  109. data/sample_app_rails_4/app/views/layouts/application.html.erb +0 -22
  110. data/sample_app_rails_4/app/views/microposts/_micropost.html.erb +0 -11
  111. data/sample_app_rails_4/app/views/relationships/create.js.erb +0 -2
  112. data/sample_app_rails_4/app/views/relationships/destroy.js.erb +0 -2
  113. data/sample_app_rails_4/app/views/sessions/new.html.erb +0 -19
  114. data/sample_app_rails_4/app/views/shared/_error_messages.html.erb +0 -12
  115. data/sample_app_rails_4/app/views/shared/_feed.html.erb +0 -6
  116. data/sample_app_rails_4/app/views/shared/_feed_item.html.erb +0 -15
  117. data/sample_app_rails_4/app/views/shared/_micropost_form.html.erb +0 -7
  118. data/sample_app_rails_4/app/views/shared/_stats.html.erb +0 -15
  119. data/sample_app_rails_4/app/views/shared/_user_info.html.erb +0 -12
  120. data/sample_app_rails_4/app/views/static_pages/about.html.erb +0 -8
  121. data/sample_app_rails_4/app/views/static_pages/contact.html.erb +0 -6
  122. data/sample_app_rails_4/app/views/static_pages/help.html.erb +0 -8
  123. data/sample_app_rails_4/app/views/static_pages/home.html.erb +0 -34
  124. data/sample_app_rails_4/app/views/static_pages/show.html.erb +0 -0
  125. data/sample_app_rails_4/app/views/users/_follow.html.erb +0 -5
  126. data/sample_app_rails_4/app/views/users/_follow_form.html.erb +0 -9
  127. data/sample_app_rails_4/app/views/users/_unfollow.html.erb +0 -5
  128. data/sample_app_rails_4/app/views/users/_user.html.erb +0 -8
  129. data/sample_app_rails_4/app/views/users/edit.html.erb +0 -27
  130. data/sample_app_rails_4/app/views/users/index.html.erb +0 -10
  131. data/sample_app_rails_4/app/views/users/new.html.erb +0 -24
  132. data/sample_app_rails_4/app/views/users/show.html.erb +0 -24
  133. data/sample_app_rails_4/app/views/users/show_follow.html.erb +0 -30
  134. data/sample_app_rails_4/bin/bundle +0 -3
  135. data/sample_app_rails_4/bin/rails +0 -4
  136. data/sample_app_rails_4/bin/rake +0 -4
  137. data/sample_app_rails_4/bin/rspec +0 -16
  138. data/sample_app_rails_4/config.ru +0 -4
  139. data/sample_app_rails_4/config/application.rb +0 -28
  140. data/sample_app_rails_4/config/boot.rb +0 -4
  141. data/sample_app_rails_4/config/database.yml +0 -27
  142. data/sample_app_rails_4/config/environment.rb +0 -5
  143. data/sample_app_rails_4/config/environments/development.rb +0 -25
  144. data/sample_app_rails_4/config/environments/production.rb +0 -79
  145. data/sample_app_rails_4/config/environments/test.rb +0 -38
  146. data/sample_app_rails_4/config/initializers/active_mocker.rb +0 -12
  147. data/sample_app_rails_4/config/initializers/backtrace_silencers.rb +0 -7
  148. data/sample_app_rails_4/config/initializers/filter_parameter_logging.rb +0 -4
  149. data/sample_app_rails_4/config/initializers/inflections.rb +0 -16
  150. data/sample_app_rails_4/config/initializers/mime_types.rb +0 -5
  151. data/sample_app_rails_4/config/initializers/secret_token.rb +0 -22
  152. data/sample_app_rails_4/config/initializers/session_store.rb +0 -3
  153. data/sample_app_rails_4/config/initializers/wrap_parameters.rb +0 -14
  154. data/sample_app_rails_4/config/locales/en.yml +0 -23
  155. data/sample_app_rails_4/config/routes.rb +0 -17
  156. data/sample_app_rails_4/db/migrate/20130311191400_create_users.rb +0 -10
  157. data/sample_app_rails_4/db/migrate/20130311194153_add_index_to_users_email.rb +0 -5
  158. data/sample_app_rails_4/db/migrate/20130311201841_add_password_digest_to_users.rb +0 -5
  159. data/sample_app_rails_4/db/migrate/20130314184954_add_remember_token_to_users.rb +0 -6
  160. data/sample_app_rails_4/db/migrate/20130315015932_add_admin_to_users.rb +0 -5
  161. data/sample_app_rails_4/db/migrate/20130315175534_create_microposts.rb +0 -11
  162. data/sample_app_rails_4/db/migrate/20130315230445_create_relationships.rb +0 -13
  163. data/sample_app_rails_4/db/schema.rb +0 -51
  164. data/sample_app_rails_4/db/seeds.rb +0 -7
  165. data/sample_app_rails_4/features/signing_in.feature +0 -13
  166. data/sample_app_rails_4/features/step_definitions/authentication_steps.rb +0 -30
  167. data/sample_app_rails_4/features/support/env.rb +0 -59
  168. data/sample_app_rails_4/lib/assets/.keep +0 -0
  169. data/sample_app_rails_4/lib/tasks/.keep +0 -0
  170. data/sample_app_rails_4/lib/tasks/active_mocker.rake +0 -10
  171. data/sample_app_rails_4/lib/tasks/cucumber.rake +0 -65
  172. data/sample_app_rails_4/lib/tasks/sample_data.rake +0 -42
  173. data/sample_app_rails_4/lib/unit_logger.rb +0 -22
  174. data/sample_app_rails_4/public/404.html +0 -27
  175. data/sample_app_rails_4/public/422.html +0 -26
  176. data/sample_app_rails_4/public/500.html +0 -26
  177. data/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css +0 -5091
  178. data/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css.gz +0 -0
  179. data/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js +0 -12952
  180. data/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js.gz +0 -0
  181. data/sample_app_rails_4/public/assets/glyphicons-halflings-c806376f05e4ccabe2c5315a8e95667c.png +0 -0
  182. data/sample_app_rails_4/public/assets/glyphicons-halflings-white-62b67d9edee3db90d18833087f848d6e.png +0 -0
  183. data/sample_app_rails_4/public/assets/manifest-802de9eb1c853769101852422b620883.json +0 -1
  184. data/sample_app_rails_4/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png +0 -0
  185. data/sample_app_rails_4/public/favicon.ico +0 -0
  186. data/sample_app_rails_4/public/robots.txt +0 -5
  187. data/sample_app_rails_4/script/cucumber +0 -10
  188. data/sample_app_rails_4/spec/compare_mocker_and_record_spec.rb +0 -1038
  189. data/sample_app_rails_4/spec/factories.rb +0 -17
  190. data/sample_app_rails_4/spec/micropost_mock_spec.rb +0 -145
  191. data/sample_app_rails_4/spec/mocks/micropost_mock.rb +0 -153
  192. data/sample_app_rails_4/spec/mocks/relationship_mock.rb +0 -151
  193. data/sample_app_rails_4/spec/mocks/user_mock.rb +0 -215
  194. data/sample_app_rails_4/spec/reload_spec.rb +0 -45
  195. data/sample_app_rails_4/spec/spec_helper.rb +0 -46
  196. data/sample_app_rails_4/spec/user_mock_spec.rb +0 -197
  197. data/sample_app_rails_4/vendor/assets/javascripts/.keep +0 -0
  198. data/sample_app_rails_4/vendor/assets/stylesheets/.keep +0 -0
  199. data/spec/lib/acitve_mock/queriable_spec.rb +0 -207
  200. data/spec/lib/active_mocker/db_to_ruby_type_spec.rb +0 -124
  201. data/spec/lib/active_mocker/generate_spec.rb +0 -40
  202. data/spec/lib/active_mocker/loaded_mocks_spec.rb +0 -167
  203. data/spec/lib/active_mocker/logger_spec.rb +0 -32
  204. data/spec/lib/active_mocker/model_reader_spec.rb +0 -206
  205. data/spec/lib/active_mocker/model_schema/generate_spec.rb +0 -111
  206. data/spec/lib/active_mocker/model_schema_spec.rb +0 -145
  207. data/spec/lib/active_mocker/schema_reader_spec.rb +0 -109
  208. data/spec/lib/model.rb +0 -43
  209. data/spec/lib/person.rb +0 -9
  210. data/spec/lib/readme_spec.rb +0 -199
  211. data/spec/lib/reparameterize_spec.rb +0 -202
  212. data/spec/lib/schema.rb +0 -40
  213. data/spec/unit_logger.rb +0 -24
@@ -1,79 +0,0 @@
1
- SampleApp::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
- # Eager load code on boot. This eager loads most of Rails and
8
- # your application in memory, allowing both thread web servers
9
- # and those relying on copy on write to perform better.
10
- # Rake tasks automatically ignore this option for performance.
11
- config.eager_load = true
12
-
13
- # Full error reports are disabled and caching is turned on.
14
- config.consider_all_requests_local = false
15
- config.action_controller.perform_caching = true
16
-
17
- # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
- # Add `rack-cache` to your Gemfile before enabling this.
19
- # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
- # config.action_dispatch.rack_cache = true
21
-
22
- config.serve_static_assets = false
23
-
24
- # Compress JavaScripts and CSS.
25
- config.assets.js_compressor = :uglifier
26
- # config.assets.css_compressor = :sass
27
-
28
- # Whether to fallback to assets pipeline if a precompiled asset is missed.
29
- config.assets.compile = false
30
-
31
- # Generate digests for assets URLs.
32
- config.assets.digest = true
33
-
34
- # Version of your assets, change this if you want to expire all your assets.
35
- config.assets.version = '1.0'
36
-
37
- # Specifies the header that your server uses for sending files.
38
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
39
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
40
-
41
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
42
- config.force_ssl = true
43
-
44
- # Set to :debug to see everything in the log.
45
- config.log_level = :info
46
-
47
- # Prepend all log lines with the following tags.
48
- # config.log_tags = [ :subdomain, :uuid ]
49
-
50
- # Use a different logger for distributed setups.
51
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
52
-
53
- # Use a different cache store in production.
54
- # config.cache_store = :mem_cache_store
55
-
56
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
57
- # config.action_controller.asset_host = "http://assets.example.com"
58
-
59
- # Precompile additional assets.
60
- # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
61
- # config.assets.precompile += %w( search.js )
62
-
63
- # Ignore bad email addresses and do not raise email delivery errors.
64
- # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
- # config.action_mailer.raise_delivery_errors = false
66
-
67
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
- # the I18n.default_locale when a translation can not be found).
69
- config.i18n.fallbacks = true
70
-
71
- # Send deprecation notices to registered listeners.
72
- config.active_support.deprecation = :notify
73
-
74
- # Disable automatic flushing of the log to improve performance.
75
- # config.autoflush_log = false
76
-
77
- # Use default logging formatter so that PID and timestamp are not suppressed.
78
- config.log_formatter = ::Logger::Formatter.new
79
- end
@@ -1,38 +0,0 @@
1
- SampleApp::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
- # Do not eager load code on boot. This avoids loading your whole application
11
- # just for the purpose of running a single test. If you are using a tool that
12
- # preloads Rails for running tests, you may have to set it to true.
13
- config.eager_load = false
14
-
15
- # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
17
- config.static_cache_control = "public, max-age=3600"
18
-
19
- # Show full error reports and disable caching.
20
- config.consider_all_requests_local = true
21
- config.action_controller.perform_caching = false
22
-
23
- # Raise exceptions instead of rendering exception templates.
24
- config.action_dispatch.show_exceptions = false
25
-
26
- # Disable request forgery protection in test environment.
27
- config.action_controller.allow_forgery_protection = false
28
-
29
- # Tell Action Mailer not to deliver emails to the real world.
30
- # The :test delivery method accumulates sent emails in the
31
- # ActionMailer::Base.deliveries array.
32
-
33
- # Print deprecation notices to the stderr.
34
- config.active_support.deprecation = :stderr
35
-
36
- # Speed up tests by lowering bcrypt's cost function.
37
- ActiveModel::SecurePassword.min_cost = true
38
- end
@@ -1,12 +0,0 @@
1
- require 'active_mocker'
2
- root = APP_ROOT unless defined? Rails
3
- root = Rails.root if defined? Rails
4
- require "#{root}/lib/unit_logger"
5
- ActiveMocker::Generate.configure do |config|
6
- # Required Options
7
- config.schema_file = File.join(root, 'db/schema.rb')
8
- config.model_dir = File.join(root, 'app/models')
9
- config.mock_dir = File.join(root, 'spec/mocks')
10
- # Logging
11
- config.logger = UnitLogger
12
- end
@@ -1,7 +0,0 @@
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!
@@ -1,4 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
@@ -1,16 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format. Inflections
4
- # are locale specific, and you may define rules for as many different
5
- # locales as you wish. All of these examples are active by default:
6
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
- # inflect.plural /^(ox)$/i, '\1en'
8
- # inflect.singular /^(ox)en/i, '\1'
9
- # inflect.irregular 'person', 'people'
10
- # inflect.uncountable %w( fish sheep )
11
- # end
12
-
13
- # These inflection rules are supported but not enabled by default:
14
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
- # inflect.acronym 'RESTful'
16
- # end
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
@@ -1,22 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Make sure your secret_key_base is kept private
4
- # if you're sharing your code publicly, such as by adding
5
- # .secret to your .gitignore file.
6
-
7
- require 'securerandom'
8
-
9
- def secure_token
10
- token_file = Rails.root.join('.secret')
11
- if File.exist?(token_file)
12
- # Use the existing token.
13
- File.read(token_file).chomp
14
- else
15
- # Generate a new token and store it in token_file.
16
- token = SecureRandom.hex(64)
17
- File.write(token_file, token)
18
- token
19
- end
20
- end
21
-
22
- SampleApp::Application.config.secret_key_base = secure_token
@@ -1,3 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- SampleApp::Application.config.session_store :cookie_store, key: '_sample_app_session'
@@ -1,14 +0,0 @@
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] if respond_to?(:wrap_parameters)
9
- end
10
-
11
- # To enable root element in JSON for ActiveRecord objects.
12
- # ActiveSupport.on_load(:active_record) do
13
- # self.include_root_in_json = true
14
- # end
@@ -1,23 +0,0 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t 'hello'
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t('hello') %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # To learn more, please read the Rails Internationalization guide
20
- # available at http://guides.rubyonrails.org/i18n.html.
21
-
22
- en:
23
- hello: "Hello world"
@@ -1,17 +0,0 @@
1
- SampleApp::Application.routes.draw do
2
- resources :users do
3
- member do
4
- get :following, :followers
5
- end
6
- end
7
- resources :sessions, only: [:new, :create, :destroy]
8
- resources :microposts, only: [:create, :destroy]
9
- resources :relationships, only: [:create, :destroy]
10
- root to: 'static_pages#home'
11
- match '/signup', to: 'users#new', via: 'get'
12
- match '/signin', to: 'sessions#new', via: 'get'
13
- match '/signout', to: 'sessions#destroy', via: 'delete'
14
- match '/help', to: 'static_pages#help', via: 'get'
15
- match '/about', to: 'static_pages#about', via: 'get'
16
- match '/contact', to: 'static_pages#contact', via: 'get'
17
- end
@@ -1,10 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table :users do |t|
4
- t.string :name
5
- t.string :email
6
- t.decimal :credits
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- class AddIndexToUsersEmail < ActiveRecord::Migration
2
- def change
3
- add_index :users, :email, unique: true
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddPasswordDigestToUsers < ActiveRecord::Migration
2
- def change
3
- add_column :users, :password_digest, :string
4
- end
5
- end
@@ -1,6 +0,0 @@
1
- class AddRememberTokenToUsers < ActiveRecord::Migration
2
- def change
3
- add_column :users, :remember_token, :string
4
- add_index :users, :remember_token
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class AddAdminToUsers < ActiveRecord::Migration
2
- def change
3
- add_column :users, :admin, :boolean, default: false
4
- end
5
- end
@@ -1,11 +0,0 @@
1
- class CreateMicroposts < ActiveRecord::Migration
2
- def change
3
- create_table :microposts do |t|
4
- t.string :content
5
- t.integer :user_id
6
-
7
- t.timestamps
8
- end
9
- add_index :microposts, [:user_id, :created_at]
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- class CreateRelationships < ActiveRecord::Migration
2
- def change
3
- create_table :relationships do |t|
4
- t.integer :follower_id
5
- t.integer :followed_id
6
-
7
- t.timestamps
8
- end
9
- add_index :relationships, :follower_id
10
- add_index :relationships, :followed_id
11
- add_index :relationships, [:follower_id, :followed_id], unique: true
12
- end
13
- end
@@ -1,51 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 20130315230445) do
15
-
16
- create_table "microposts", force: true do |t|
17
- t.string "content"
18
- t.integer "user_id"
19
- t.integer "up_votes"
20
- t.datetime "created_at"
21
- t.datetime "updated_at"
22
- end
23
-
24
- add_index "microposts", ["user_id", "created_at"], name: "index_microposts_on_user_id_and_created_at"
25
-
26
- create_table "relationships", force: true do |t|
27
- t.integer "follower_id"
28
- t.integer "followed_id"
29
- t.datetime "created_at"
30
- t.datetime "updated_at"
31
- end
32
-
33
- add_index "relationships", ["followed_id"], name: "index_relationships_on_followed_id"
34
- add_index "relationships", ["follower_id", "followed_id"], name: "index_relationships_on_follower_id_and_followed_id", unique: true
35
- add_index "relationships", ["follower_id"], name: "index_relationships_on_follower_id"
36
-
37
- create_table "users", force: true do |t|
38
- t.string "name"
39
- t.string "email", default: ""
40
- t.decimal "credits", precision: 19, scale: 6
41
- t.datetime "created_at"
42
- t.datetime "updated_at"
43
- t.string "password_digest"
44
- t.boolean "remember_token", default: true
45
- t.boolean "admin", default: false
46
- end
47
-
48
- add_index "users", ["email"], name: "index_users_on_email", unique: true
49
- add_index "users", ["remember_token"], name: "index_users_on_remember_token"
50
-
51
- end
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
- # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -1,13 +0,0 @@
1
- Feature: Signing in
2
-
3
- Scenario: Unsuccessful signin
4
- Given a user visits the signin page
5
- When they submit invalid signin information
6
- Then they should see an error message
7
-
8
- Scenario: Successful signin
9
- Given a user visits the signin page
10
- And the user has an account
11
- When the user submits valid signin information
12
- Then they should see their profile page
13
- And they should see a signout link
@@ -1,30 +0,0 @@
1
- Given /^a user visits the signin page$/ do
2
- visit signin_path
3
- end
4
-
5
- When /^they submit invalid signin information$/ do
6
- click_button "Sign in"
7
- end
8
-
9
- Then /^they should see an error message$/ do
10
- expect(page).to have_selector('div.alert.alert-error')
11
- end
12
-
13
- Given /^the user has an account$/ do
14
- @user = User.create(name: "Example User", email: "user@example.com",
15
- password: "foobar", password_confirmation: "foobar")
16
- end
17
-
18
- When /^the user submits valid signin information$/ do
19
- fill_in "Email", with: @user.email
20
- fill_in "Password", with: @user.password
21
- click_button "Sign in"
22
- end
23
-
24
- Then /^they should see their profile page$/ do
25
- expect(page).to have_title(@user.name)
26
- end
27
-
28
- Then /^they should see a signout link$/ do
29
- expect(page).to have_link('Sign out', href: signout_path)
30
- end
@@ -1,59 +0,0 @@
1
- # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
4
- # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
- # files.
6
-
7
- require 'cucumber/rails'
8
-
9
- # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
10
- # order to ease the transition to Capybara we set the default here. If you'd
11
- # prefer to use XPath just remove this line and adjust any selectors in your
12
- # steps to use the XPath syntax.
13
- Capybara.default_selector = :css
14
-
15
- # By default, any exception happening in your Rails application will bubble up
16
- # to Cucumber so that your scenario will fail. This is a different from how
17
- # your application behaves in the production environment, where an error page will
18
- # be rendered instead.
19
- #
20
- # Sometimes we want to override this default behaviour and allow Rails to rescue
21
- # exceptions and display an error page (just like when the app is running in production).
22
- # Typical scenarios where you want to do this is when you test your error pages.
23
- # There are two ways to allow Rails to rescue exceptions:
24
- #
25
- # 1) Tag your scenario (or feature) with @allow-rescue
26
- #
27
- # 2) Set the value below to true. Beware that doing this globally is not
28
- # recommended as it will mask a lot of errors for you!
29
- #
30
- ActionController::Base.allow_rescue = false
31
-
32
- # Remove/comment out the lines below if your app doesn't have a database.
33
- # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
34
- begin
35
- DatabaseCleaner.strategy = :transaction
36
- rescue NameError
37
- raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
38
- end
39
-
40
- # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
41
- # See the DatabaseCleaner documentation for details. Example:
42
- #
43
- # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
44
- # # { :except => [:widgets] } may not do what you expect here
45
- # # as tCucumber::Rails::Database.javascript_strategy overrides
46
- # # this setting.
47
- # DatabaseCleaner.strategy = :truncation
48
- # end
49
- #
50
- # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
51
- # DatabaseCleaner.strategy = :transaction
52
- # end
53
- #
54
-
55
- # Possible values are :truncation and :transaction
56
- # The :transaction strategy is faster, but might give you threading problems.
57
- # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
58
- Cucumber::Rails::Database.javascript_strategy = :truncation
59
-