green_eggs_and_spam 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +4 -1
  2. data/README.md +91 -24
  3. data/Rakefile +30 -2
  4. data/green_eggs_and_spam.gemspec +5 -1
  5. data/lib/green_eggs_and_spam/action_controller.rb +10 -4
  6. data/lib/green_eggs_and_spam/active_record.rb +28 -0
  7. data/lib/green_eggs_and_spam/anti_spam_validator.rb +11 -0
  8. data/lib/green_eggs_and_spam/form_helper.rb +7 -8
  9. data/lib/green_eggs_and_spam/options.rb +45 -0
  10. data/lib/green_eggs_and_spam/version.rb +1 -1
  11. data/lib/green_eggs_and_spam.rb +31 -3
  12. data/test/dummy/Rakefile +7 -0
  13. data/test/dummy/app/controllers/application_controller.rb +3 -0
  14. data/test/dummy/app/controllers/comments_controller.rb +18 -0
  15. data/test/dummy/app/controllers/eggs_controller.rb +24 -0
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/models/egg.rb +7 -0
  18. data/test/dummy/app/views/comments/new.html.erb +14 -0
  19. data/test/dummy/app/views/eggs/index.html.erb +14 -0
  20. data/test/dummy/app/views/eggs/new.html.erb +21 -0
  21. data/test/dummy/app/views/layouts/application.html.erb +59 -0
  22. data/test/dummy/config/application.rb +45 -0
  23. data/test/dummy/config/boot.rb +10 -0
  24. data/test/dummy/config/database.yml +22 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +26 -0
  27. data/test/dummy/config/environments/production.rb +49 -0
  28. data/test/dummy/config/environments/test.rb +35 -0
  29. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy/config/initializers/inflections.rb +10 -0
  31. data/test/dummy/config/initializers/mime_types.rb +5 -0
  32. data/test/dummy/config/initializers/secret_token.rb +7 -0
  33. data/test/dummy/config/initializers/session_store.rb +8 -0
  34. data/test/dummy/config/locales/en.yml +5 -0
  35. data/test/dummy/config/routes.rb +5 -0
  36. data/test/dummy/config.ru +4 -0
  37. data/test/dummy/db/migrate/20110223073415_create_eggs.rb +11 -0
  38. data/test/dummy/db/schema.rb +19 -0
  39. data/test/dummy/public/404.html +26 -0
  40. data/test/dummy/public/422.html +26 -0
  41. data/test/dummy/public/500.html +26 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/dummy/public/images/antispam/1.png +0 -0
  44. data/test/dummy/public/images/antispam/2.png +0 -0
  45. data/test/dummy/public/images/antispam/3.png +0 -0
  46. data/test/dummy/script/rails +6 -0
  47. data/test/helper.rb +23 -0
  48. data/test/integration/navigation_test.rb +7 -0
  49. data/test/support/integration_case.rb +5 -0
  50. data/test/test_green_eggs_and_ham.rb +53 -0
  51. data/test/test_options.rb +37 -0
  52. metadata +126 -6
  53. data/lib/green_eggs_and_spam/anti_spam.rb +0 -29
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,26 @@
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 webserver 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_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end
@@ -0,0 +1,35 @@
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
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ 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,10 @@
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
@@ -0,0 +1,5 @@
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
@@ -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 = '45230672a827bf78e4be28ab7902fa2b555bb8cdb8b35fd41a20108f550be40a55985d8ae8074c9521c1cb7e769d4e9c3cd05dd50ef391d879bdf547c7ef9779'
@@ -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,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,5 @@
1
+ Dummy::Application.routes.draw do
2
+ resources :eggs
3
+ resources :comments
4
+ root :to => "eggs#index"
5
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,11 @@
1
+ class CreateEggs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :eggs do |t|
4
+ t.string :name
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :eggs
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20110223073415) do
14
+
15
+ create_table "eggs", :force => true do |t|
16
+ t.string "name"
17
+ end
18
+
19
+ end
@@ -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,26 @@
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
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </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'
data/test/helper.rb ADDED
@@ -0,0 +1,23 @@
1
+ # Configure Rails Envinronment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+ require "shoulda"
7
+
8
+ ActionMailer::Base.delivery_method = :test
9
+ ActionMailer::Base.perform_deliveries = true
10
+ ActionMailer::Base.default_url_options[:host] = "test.com"
11
+
12
+ Rails.backtrace_cleaner.remove_silencers!
13
+
14
+ # Configure capybara for integration testing
15
+ require "capybara/rails"
16
+ Capybara.default_driver = :rack_test
17
+ Capybara.default_selector = :css
18
+
19
+ # Run any available migration
20
+ ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
21
+
22
+ # Load support files
23
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActiveSupport::IntegrationCase
4
+ test "truth" do
5
+ assert_kind_of Dummy::Application, Rails.application
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # Define a bare test case to use with Capybara
2
+ class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
3
+ include Capybara
4
+ include Rails.application.routes.url_helpers
5
+ end
@@ -0,0 +1,53 @@
1
+ require 'helper'
2
+
3
+ class TestGreenEggsAndSpam < Test::Unit::TestCase
4
+
5
+ should "get key index" do
6
+ assert GreenEggsAndSpam.key_index.is_a?(Hash)
7
+ end
8
+
9
+ should "set key index" do
10
+ index = { "1" => "green", "2" => "pink" }
11
+ assert GreenEggsAndSpam.options[:key_index] = index
12
+ assert_equal "green", GreenEggsAndSpam.key_index["1"]
13
+ assert_equal "pink", GreenEggsAndSpam.key_index["2"]
14
+ end
15
+
16
+ should "validate key index" do
17
+ assert_raises RuntimeError do |e|
18
+ GreenEggsAndSpam.options[:key_index] = {}
19
+ asset_equal "InvalidKeyIndex", e.message
20
+ end
21
+ assert_raises RuntimeError do |e|
22
+ GreenEggsAndSpam.options[:key_index] = "some string"
23
+ asset_equal "InvalidKeyIndex", e.message
24
+ end
25
+ end
26
+
27
+ should "validate form options" do
28
+ assert_raises RuntimeError do |e|
29
+ GreenEggsAndSpam.options[:form_options] = "some string"
30
+ asset_equal "InvalidKeyIndex", e.message
31
+ end
32
+ end
33
+
34
+ should "merge default and new form options" do
35
+ GreenEggsAndSpam.options[:form_options] = { :extension => "png" }
36
+ assert GreenEggsAndSpam.options[:form_options].keys.include?(:alt)
37
+ assert GreenEggsAndSpam.options[:form_options].keys.include?(:class)
38
+ assert GreenEggsAndSpam.options[:form_options].keys.include?(:path)
39
+ end
40
+
41
+ should "set key index to things other than numbers" do
42
+ index = { "lime" => "green", "grapefruit" => "pink" }
43
+ GreenEggsAndSpam.options[:key_index] = index
44
+ assert_equal "green", GreenEggsAndSpam.key_index["lime"]
45
+ assert_equal "pink", GreenEggsAndSpam.key_index["grapefruit"]
46
+ end
47
+
48
+ should "generate a random key" do
49
+ key = GreenEggsAndSpam.random_key
50
+ assert GreenEggsAndSpam.key_index.include?(key)
51
+ end
52
+
53
+ end
@@ -0,0 +1,37 @@
1
+ require 'helper'
2
+
3
+ class TestOptions < Test::Unit::TestCase
4
+
5
+ def setup
6
+ GreenEggsAndSpam.options.default!
7
+ end
8
+
9
+ should "initiate new options" do
10
+ assert GreenEggsAndSpam.options.is_a?(GreenEggsAndSpam::Options)
11
+ assert GreenEggsAndSpam.options.is_a?(Hash)
12
+ end
13
+
14
+ should "initiate with default options" do
15
+ assert GreenEggsAndSpam.options.keys.include?(:key_index)
16
+ assert GreenEggsAndSpam.options.keys.include?(:form_options)
17
+ end
18
+
19
+ should "set new and get an option" do
20
+ GreenEggsAndSpam.options[:something] = 'nothing'
21
+ assert GreenEggsAndSpam.options.keys.include?(:something)
22
+ assert_equal 'nothing', GreenEggsAndSpam.options[:something]
23
+ end
24
+
25
+ should "convert keys into symbols" do
26
+ GreenEggsAndSpam.options['something'] = 'nothing'
27
+ assert !GreenEggsAndSpam.options.keys.include?('something')
28
+ assert GreenEggsAndSpam.options.keys.include?(:something)
29
+ assert_equal 'nothing', GreenEggsAndSpam.options[:something]
30
+ end
31
+
32
+ should "convert requested key into symbol" do
33
+ GreenEggsAndSpam.options[:something] = 'nothing'
34
+ assert_equal 'nothing', GreenEggsAndSpam.options['something']
35
+ end
36
+
37
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: green_eggs_and_spam
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Spencer Steffen
@@ -10,12 +10,11 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-22 00:00:00 -08:00
13
+ date: 2011-02-23 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- prerelease: false
19
18
  requirement: &id001 !ruby/object:Gem::Requirement
20
19
  none: false
21
20
  requirements:
@@ -23,7 +22,41 @@ dependencies:
23
22
  - !ruby/object:Gem::Version
24
23
  version: 3.0.0
25
24
  type: :runtime
25
+ prerelease: false
26
26
  version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.4.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: shoulda
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 2.11.3
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: sqlite3
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.3.3
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
27
60
  description: "Green eggs and spam presents the user with a simple question: What color is this image? You'll supply the images and a key of which one's which, and the gem will help with the rest."
28
61
  email:
29
62
  - spencer@citrusme.com
@@ -41,12 +74,54 @@ files:
41
74
  - green_eggs_and_spam.gemspec
42
75
  - lib/green_eggs_and_spam.rb
43
76
  - lib/green_eggs_and_spam/action_controller.rb
44
- - lib/green_eggs_and_spam/anti_spam.rb
77
+ - lib/green_eggs_and_spam/active_record.rb
78
+ - lib/green_eggs_and_spam/anti_spam_validator.rb
45
79
  - lib/green_eggs_and_spam/form_helper.rb
80
+ - lib/green_eggs_and_spam/options.rb
46
81
  - lib/green_eggs_and_spam/version.rb
47
82
  - public/images/antispam/1.jpg
48
83
  - public/images/antispam/2.jpg
49
84
  - public/images/antispam/3.jpg
85
+ - test/dummy/Rakefile
86
+ - test/dummy/app/controllers/application_controller.rb
87
+ - test/dummy/app/controllers/comments_controller.rb
88
+ - test/dummy/app/controllers/eggs_controller.rb
89
+ - test/dummy/app/helpers/application_helper.rb
90
+ - test/dummy/app/models/egg.rb
91
+ - test/dummy/app/views/comments/new.html.erb
92
+ - test/dummy/app/views/eggs/index.html.erb
93
+ - test/dummy/app/views/eggs/new.html.erb
94
+ - test/dummy/app/views/layouts/application.html.erb
95
+ - test/dummy/config.ru
96
+ - test/dummy/config/application.rb
97
+ - test/dummy/config/boot.rb
98
+ - test/dummy/config/database.yml
99
+ - test/dummy/config/environment.rb
100
+ - test/dummy/config/environments/development.rb
101
+ - test/dummy/config/environments/production.rb
102
+ - test/dummy/config/environments/test.rb
103
+ - test/dummy/config/initializers/backtrace_silencers.rb
104
+ - test/dummy/config/initializers/inflections.rb
105
+ - test/dummy/config/initializers/mime_types.rb
106
+ - test/dummy/config/initializers/secret_token.rb
107
+ - test/dummy/config/initializers/session_store.rb
108
+ - test/dummy/config/locales/en.yml
109
+ - test/dummy/config/routes.rb
110
+ - test/dummy/db/migrate/20110223073415_create_eggs.rb
111
+ - test/dummy/db/schema.rb
112
+ - test/dummy/public/404.html
113
+ - test/dummy/public/422.html
114
+ - test/dummy/public/500.html
115
+ - test/dummy/public/favicon.ico
116
+ - test/dummy/public/images/antispam/1.png
117
+ - test/dummy/public/images/antispam/2.png
118
+ - test/dummy/public/images/antispam/3.png
119
+ - test/dummy/script/rails
120
+ - test/helper.rb
121
+ - test/integration/navigation_test.rb
122
+ - test/support/integration_case.rb
123
+ - test/test_green_eggs_and_ham.rb
124
+ - test/test_options.rb
50
125
  has_rdoc: true
51
126
  homepage: ""
52
127
  licenses: []
@@ -61,12 +136,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
136
  requirements:
62
137
  - - ">="
63
138
  - !ruby/object:Gem::Version
139
+ hash: 3011029944543464221
140
+ segments:
141
+ - 0
64
142
  version: "0"
65
143
  required_rubygems_version: !ruby/object:Gem::Requirement
66
144
  none: false
67
145
  requirements:
68
146
  - - ">="
69
147
  - !ruby/object:Gem::Version
148
+ hash: 3011029944543464221
149
+ segments:
150
+ - 0
70
151
  version: "0"
71
152
  requirements: []
72
153
 
@@ -75,5 +156,44 @@ rubygems_version: 1.5.0
75
156
  signing_key:
76
157
  specification_version: 3
77
158
  summary: A simple way to filter spam in your rails forms.
78
- test_files: []
79
-
159
+ test_files:
160
+ - test/dummy/Rakefile
161
+ - test/dummy/app/controllers/application_controller.rb
162
+ - test/dummy/app/controllers/comments_controller.rb
163
+ - test/dummy/app/controllers/eggs_controller.rb
164
+ - test/dummy/app/helpers/application_helper.rb
165
+ - test/dummy/app/models/egg.rb
166
+ - test/dummy/app/views/comments/new.html.erb
167
+ - test/dummy/app/views/eggs/index.html.erb
168
+ - test/dummy/app/views/eggs/new.html.erb
169
+ - test/dummy/app/views/layouts/application.html.erb
170
+ - test/dummy/config.ru
171
+ - test/dummy/config/application.rb
172
+ - test/dummy/config/boot.rb
173
+ - test/dummy/config/database.yml
174
+ - test/dummy/config/environment.rb
175
+ - test/dummy/config/environments/development.rb
176
+ - test/dummy/config/environments/production.rb
177
+ - test/dummy/config/environments/test.rb
178
+ - test/dummy/config/initializers/backtrace_silencers.rb
179
+ - test/dummy/config/initializers/inflections.rb
180
+ - test/dummy/config/initializers/mime_types.rb
181
+ - test/dummy/config/initializers/secret_token.rb
182
+ - test/dummy/config/initializers/session_store.rb
183
+ - test/dummy/config/locales/en.yml
184
+ - test/dummy/config/routes.rb
185
+ - test/dummy/db/migrate/20110223073415_create_eggs.rb
186
+ - test/dummy/db/schema.rb
187
+ - test/dummy/public/404.html
188
+ - test/dummy/public/422.html
189
+ - test/dummy/public/500.html
190
+ - test/dummy/public/favicon.ico
191
+ - test/dummy/public/images/antispam/1.png
192
+ - test/dummy/public/images/antispam/2.png
193
+ - test/dummy/public/images/antispam/3.png
194
+ - test/dummy/script/rails
195
+ - test/helper.rb
196
+ - test/integration/navigation_test.rb
197
+ - test/support/integration_case.rb
198
+ - test/test_green_eggs_and_ham.rb
199
+ - test/test_options.rb
@@ -1,29 +0,0 @@
1
- module GreenEggsAndSpam
2
- module AntiSpam
3
-
4
- extend self
5
-
6
- def key_index
7
- @key_index ||= { "1" => "blue", "2" => "green", "3" => "red" }
8
- end
9
-
10
- def key_index=(value)
11
- @key_index = value
12
- end
13
-
14
- def random_key
15
- rand(key_index.keys.length) + 1
16
- end
17
-
18
- def valid?(params={})
19
- key = params[:antispam_key].to_s
20
- val = params[:antispam].to_s
21
- return false if key.empty? || val.empty?
22
- answer = key_index[key.to_s]
23
- regex = Regexp.new(answer, 'i')
24
- return val.match(regex) != nil
25
- end
26
-
27
- end
28
-
29
- end