Sha256: 06ce09932f7bd15155473072106c4c7ce4abd3a93b6fea56d9f9ca58a6bab3bd
Contents?: true
Size: 1.37 KB
Versions: 5
Compression:
Stored size: 1.37 KB
Contents
require "rails_helper" module Scram class SimpleDSLImplementation include Scram::DSL::ModelConditions attr_accessor :owner scram_define do condition :owner do |instance| instance.owner end end end describe Scram::DSL::ModelConditions do it "defines and retrieves conditions" do test = SimpleDSLImplementation.new test.owner = "bob" owner_retrieval_condition = SimpleDSLImplementation.scram_conditions[:owner] expect(owner_retrieval_condition.call(test)).to eq("bob") end it "handles retrieval of condition methods" do test = SimpleDSLImplementation.new test.owner = "bob" expect(test.send("*owner")).to eq("bob") end end describe Scram::DSL::Definitions do it "defines and retrieves default comparators" do equal_comparator = Scram::DSL::Definitions::COMPARATORS[:equals] expect(equal_comparator.call("a", "a")).to be true expect(equal_comparator.call("a", "b")).to be false end it "can define new comparators" do builder = Scram::DSL::Builders::ComparatorBuilder.new do comparator :asdf do |a,b| true end end Scram::DSL::Definitions.add_comparators(builder) asdf_comparator = Scram::DSL::Definitions::COMPARATORS[:asdf] expect(asdf_comparator.call("basically", "anything")).to be true end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
scram-0.1.4 | spec/scram/dsl_spec.rb |
scram-0.1.3 | spec/scram/dsl_spec.rb |
scram-0.1.2 | spec/scram/dsl_spec.rb |
scram-0.1.1 | spec/scram/dsl_spec.rb |
scram-0.1.0 | spec/scram/dsl_spec.rb |