Sha256: 96611fce124eab3fd89209bfd51d9b4e016820e653e1179a36801e8ca65ec723

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

class BasicGoal
  attr_accessor :then_rules
end

describe Restfulie::Client::Mikyung::ThenCondition do
  
  before do
    @condition = Restfulie::Client::Mikyung::ThenCondition.new("launch a rocket")
    @resource = Object.new
    @goal = BasicGoal.new
    @mikyung = Object.new
    @goal.then_rules = []
    @goal.then_rules << ["send an email", ""]
  end
  
  it "should do nothing if there is no matching rule" do
    @condition.execute(@resource, @goal, @mikyung).should == nil
  end
  
  it "should invoke with resource if it receives one parameter" do
    @goal.then_rules << ["launch a rocket", lambda { |resource| true }]
    @condition.execute(@resource, @goal, @mikyung).should be_true
  end
  
  it "should invoke with two params if it receives two parameters" do
    @goal.then_rules << ["launch a rocket", lambda { |resource, params| true }]
    @condition.execute(@resource, @goal, @mikyung).should be_true
  end
  
  it "should invoke with all params if it receives three parameters" do
    @goal.then_rules << ["launch a rocket", lambda { |resource, params, mikyung| true }]
    @condition.execute(@resource, @goal, @mikyung).should be_true
  end
  
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
restfulie-nosqlite-1.0.4 spec/unit/client/mikyung/then_condition_spec.rb
restfulie-1.1.1 spec/unit/client/mikyung/then_condition_spec.rb
restfulie-1.1.0 spec/unit/client/mikyung/then_condition_spec.rb
restfulie-nosqlite-1.0.3 spec/unit/client/mikyung/then_condition_spec.rb
restfulie-1.0.3 spec/unit/client/mikyung/then_condition_spec.rb