Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more meat TDDing the ORM part

  • Loading branch information...
commit 68c9fc69080b00e31a5df51b320f1ce49d929031 1 parent fc6dd72
@NoamB authored
View
17 Rakefile
@@ -1,12 +1,11 @@
-require 'rubygems'
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
+# require 'bundler'
+# begin
+# Bundler.setup(:default, :development)
+# rescue Bundler::BundlerError => e
+# $stderr.puts e.message
+# $stderr.puts "Run `bundle install` to install missing gems"
+# exit e.status_code
+# end
require 'rake'
require 'jeweler'
View
9 features/simple_auth.feature
@@ -1,9 +0,0 @@
-Feature: something something
- In order to something something
- A user something something
- something something something
-
- Scenario: something something
- Given inspiration
- When I create a sweet new gem
- Then everyone should see how awesome I am
View
0  features/step_definitions/simple_auth_steps.rb
No changes.
View
14 lib/simple_auth/orm.rb
@@ -4,8 +4,20 @@ module ORM
module ClassMethods
def activate_simple_auth!
- puts "hurray!"
+ yield Config if block_given?
+
+ self.class_eval do
+ def self.authentic?(username, password)
+
+ end
+ end
end
end
+
+ module Config
+ mattr_accessor :username_attribute_name
+
+ @@username_attribute_name = :username
+ end
end
end
View
2  spec/rails3/app_root/app/models/user.rb
@@ -1,3 +1,3 @@
class User < ActiveRecord::Base
- #activate_simple_auth!
+ activate_simple_auth!
end
View
7 spec/rails3/rails3_spec.rb
@@ -1,7 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-
-describe "Rails3Auth" do
- it "passes" do
- 1.should == 1
- end
-end
View
24 spec/rails3/user_spec.rb
@@ -7,8 +7,28 @@
end
end
+describe User, "plugin activation" do
+ it "should enable configuration option 'username_attribute_name'" do
+ SimpleAuth::ORM::Config.username_attribute_name.should equal(:username)
+
+ class User
+ activate_simple_auth! do |config|
+ config.username_attribute_name = :email
+ end
+ end
+
+ SimpleAuth::ORM::Config.username_attribute_name.should equal(:email)
+ end
+end
+
describe User, "when activated with simple_auth" do
- it "should respond to the plugin added instance methods" do
- pending
+ it "should respond to class method authentic?" do
+ ActiveRecord::Base.should_not respond_to(:authentic?)
+ User.should respond_to(:authentic?)
end
+
+ # it "authentic? should return true if credentials are good" do
+ # @user = users(:noam)
+ # User.authentic?(@user.username, 'secret').should be_true
+ # end
end
Please sign in to comment.
Something went wrong with that request. Please try again.