forked from Agowan/imperator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests and change the name of the gem
- Loading branch information
Keith Gaddis
committed
May 8, 2012
1 parent
50665fe
commit 4e82f4b
Showing
10 changed files
with
97 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "imperator/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "imperator" | ||
s.version = Imperator::VERSION | ||
s.authors = ["Keith Gaddis"] | ||
s.email = ["keith.gaddis@gmail.com"] | ||
s.homepage = "http://github.com/karmajunkie/imperator" | ||
s.summary = %q{Imperator supports the command pattern} | ||
s.description = %q{Imperator is a small gem to help with command objects. The command pattern is a design pattern used to encapsulate all of the information needed to execute a method or process at a point in time. In a web application, commands are typically used to delay execution of a method from the request cycle to a background processor.} | ||
|
||
#s.rubyforge_project = "imperator" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
# specify any dependencies here; for example: | ||
s.add_development_dependency "rspec" | ||
s.add_development_dependency "pry" | ||
# s.add_runtime_dependency "rest-client" | ||
s.add_runtime_dependency "uuidtools" | ||
s.add_runtime_dependency "active_attr" | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'active_attr' | ||
require "imperator/version" | ||
require 'imperator/invalid_command_error' | ||
require 'imperator/command' | ||
require 'pry' | ||
|
||
module Imperator | ||
# Your code goes here... | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Imperator::InvalidCommandError < ArgumentError | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Commando | ||
module Imperator | ||
VERSION = "0.1.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'imperator' | ||
describe Imperator::Command do | ||
|
||
describe "#perform" do | ||
class CommandTestException < Exception; end | ||
class TestCommand < Imperator::Command | ||
action do | ||
raise CommandTestException.new | ||
end | ||
end | ||
|
||
let(:command){TestCommand.new} | ||
it "runs the action block when #perform is called" do | ||
lambda{command.perform}.should raise_exception(CommandTestException) | ||
end | ||
end | ||
|
||
describe "attributes" do | ||
class AttributeCommand < Imperator::Command | ||
attribute :gets_default, :default => "foo" | ||
attribute :declared_attr | ||
end | ||
|
||
it "throws away undeclared attributes in mass assignment" do | ||
command = AttributeCommand.new(:undeclared_attr => "foo") | ||
lambda{command.undeclared_attr}.should raise_exception(NoMethodError) | ||
end | ||
|
||
it "accepts declared attributes in mass assignment" do | ||
command = AttributeCommand.new(:declared_attr => "bar") | ||
command.declared_attr.should == "bar" | ||
end | ||
|
||
it "allows default values to be used on commands" do | ||
command = AttributeCommand.new | ||
command.gets_default.should == "foo" | ||
end | ||
it "overrides default when supplied in constructor args" do | ||
command = AttributeCommand.new :gets_default => "bar" | ||
command.gets_default.should == "bar" | ||
end | ||
end | ||
|
||
end | ||
|