Sha256: 87f2a30d5c1e7ec84ddd8d3e9fb36f129478418338194a0a261dbd2a8c1860c0

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

require_relative 'spec_helper'
require 'simple_command'

describe 'Mutations - inheritance' do
  
  class SimpleInherited < SimpleCommand
    
    required do
      integer :age
    end
    
    def execute
      @filtered_input
    end
  end
  
  it 'should filter with inherited command' do
    mutation = SimpleInherited.run(name: "bob", email: "jon@jones.com", age: 10, amount: 22)
    assert mutation.success?
    assert_equal HashWithIndifferentAccess.new(name: "bob", email: "jon@jones.com", age: 10, amount: 22), mutation.result
  end
  
  it 'should filter with original command' do
    mutation = SimpleCommand.run(name: "bob", email: "jon@jones.com", age: 10, amount: 22)
    assert mutation.success?
    assert_equal HashWithIndifferentAccess.new(name: "bob", email: "jon@jones.com", amount: 22), mutation.result
  end
  
  it 'shouldnt collide' do
    mutation = SimpleInherited.run(name: "bob", email: "jon@jones.com", age: 10, amount: 22)
    assert mutation.success?
    assert_equal HashWithIndifferentAccess.new(name: "bob", email: "jon@jones.com", age: 10, amount: 22), mutation.result
    
    mutation = SimpleCommand.run(name: "bob", email: "jon@jones.com", age: 10, amount: 22)
    assert mutation.success?
    assert_equal HashWithIndifferentAccess.new(name: "bob", email: "jon@jones.com", amount: 22), mutation.result
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutations-0.5.9 spec/inheritance_spec.rb
mutations-0.5.4 spec/inheritance_spec.rb
mutations-0.5.3 spec/inheritance_spec.rb
mutations-0.5.2 spec/inheritance_spec.rb
mutations-0.5.1 spec/inheritance_spec.rb
mutations-0.5.0 spec/inheritance_spec.rb