Top Level Namespace

Defined Under Namespace

Modules: Enumerable, Hamster, I8, NRSER Classes: Array, Binding, Exception, Hash, Method, Module, Object, OpenStruct, Pathname, String, Symbol, Time, UnboundMethod, Wrapper

Instance Method Summary collapse

Methods included from NRSER::RSpex::ExampleGroup

#describe_attribute, #describe_called, #describe_called_with, #describe_case, #describe_class, #describe_group, #describe_instance, #describe_instance_method, #describe_message, #describe_method, #describe_module, #describe_response_to, #describe_section, #describe_sent_to, #describe_setup, #describe_source_file, #describe_spec_file, #describe_subject, #describe_when, #describe_x, #dive_x

Instance Method Details

#Args(*args) ⇒ Object



132
133
134
# File 'lib/nrser/rspex.rb', line 132

def Args *args
  NRSER::RSpex::Args.new args
end

#I8(value = nil) ⇒ Object

Method proxy to I8.[] allowing for different syntaxes.



121
122
123
# File 'lib/nrser/labs/i8.rb', line 121

def I8 value = nil
  I8[ value || yield ]
end

#List(*args) ⇒ Object



128
129
130
# File 'lib/nrser/rspex.rb', line 128

def List *args
  NRSER::RSpex::List.new args
end

#merge_expectations(*expectations) ⇒ Object

Merge “expectation” hashes by appending all clauses for each state.

Parameters:

  • expectations (Array<Hash>)

    Splat of “expectation” hashes - see the examples.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/nrser/rspex.rb', line 50

def merge_expectations *expectations
  Hash.new { |result, state|
    result[state] = []
  }.tap { |result|
    expectations.each { |ex|
      ex.each { |state, clauses|
        result[state] += clauses.to_a
      }
    }
  }
end

#msg(*args, &block) ⇒ Object



123
124
125
# File 'lib/nrser/rspex.rb', line 123

def msg *args, &block
  NRSER::Message.from *args, &block
end

#unwrap(obj, context: nil) ⇒ Object



115
116
117
118
119
120
121
# File 'lib/nrser/rspex.rb', line 115

def unwrap obj, context: nil
  if obj.is_a? Wrapper
    obj.unwrap context: context
  else
    obj
  end
end

#wrap(description = nil, &block) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/nrser/rspex.rb', line 105

def wrap description = nil, &block
  if block
    Wrapper.new description: description, &block
  else
    Wrapper.new description: description.to_s do
      send description
    end
  end
end