Permalink
Browse files

Fixed an issue raising exception for bang version of #perform!

  • Loading branch information...
1 parent bb90619 commit f4039f167a817d6c194ecad38f7b573df6afdf83 @karmajunkie committed Feb 11, 2013
Showing with 15 additions and 4 deletions.
  1. +1 −0 Gemfile
  2. +1 −1 lib/imperator/command.rb
  3. +13 −3 spec/imperator/command_spec.rb
View
@@ -7,4 +7,5 @@ gem "pry", :group => [:test, :development]
group :test do
gem "rspec"
gem "rspec-mocks"
+ gem "debugger"
end
View
@@ -72,7 +72,7 @@ def perform
private
def check_valid_command
if self.respond_to?(:valid?)
- raise InvalidCommandError.new "Command was invalid" unless valid?
+ raise Imperator::InvalidCommandError.new "Command was invalid" unless valid?
end
end
@@ -32,16 +32,26 @@ def action
end
describe "performing" do
- it "bang version doesn't raise exception if validations not enabled" do
+ context "bang version" do
class PerformBangValidCommand < Imperator::Command
attribute :foo, String
def action
"this is fine"
end
end
- lambda{PerformBangValidCommand.new.perform!}.should_not raise_exception(Imperator::InvalidCommandError)
- lambda{PerformBangValidCommand.new.commit!}.should_not raise_exception(Imperator::InvalidCommandError)
+ it "bang version doesn't raise exception if validations not enabled" do
+ lambda{PerformBangValidCommand.new.perform!}.should_not raise_exception(Imperator::InvalidCommandError)
+ lambda{PerformBangValidCommand.new.commit!}.should_not raise_exception(Imperator::InvalidCommandError)
+ end
+
+ it "raises an exception if the command is invalid" do
+ command = PerformBangValidCommand.new
+ command.stub(:valid?).and_return(false)
+ lambda{command.perform!}.should raise_exception(Imperator::InvalidCommandError)
+ lambda{command.commit!}.should raise_exception(Imperator::InvalidCommandError)
+
+ end
end
end

0 comments on commit f4039f1

Please sign in to comment.