Top Level Namespace
Defined Under Namespace
Modules: Mspec
Constant Summary collapse
- COLOUR_CODES =
{ green: 32, red: 31, light_blue: 36 }
Instance Method Summary collapse
- #allow(obj) ⇒ Object
- #describe(str) ⇒ Object
- #eq(obj) ⇒ Object
- #expect(obj = nil, &block) ⇒ Object
- #it(str, specs = Mspec::Specs.instance) ⇒ Object
- #output(string) ⇒ Object
- #receive(method, &block) ⇒ Object
- #test_double(name = 'anonymous') ⇒ Object
Instance Method Details
#allow(obj) ⇒ Object
5 6 7 |
# File 'lib/m-spec/mocks/helpers/readable.rb', line 5 def allow(obj) Mspec::Mocks::Allow.new(obj) end |
#describe(str) ⇒ Object
7 8 9 10 |
# File 'lib/m-spec/core/helpers/readable.rb', line 7 def describe(str) puts str yield end |
#eq(obj) ⇒ Object
39 40 41 |
# File 'lib/m-spec/core/helpers/readable.rb', line 39 def eq(obj) Mspec::Matchers::Equal.new(obj) end |
#expect(obj = nil, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/m-spec/core/helpers/readable.rb', line 27 def expect(obj=nil, &block) if !obj.nil? Mspec::Expect.new(obj) else Mspec::Expect.new(block) end end |
#it(str, specs = Mspec::Specs.instance) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/m-spec/core/helpers/readable.rb', line 12 def it(str, specs = Mspec::Specs.instance) spec_example = Mspec::SpecExample.new(str, yield) specs.add(spec_example) if spec_example.success? puts " \e[#{COLOUR_CODES[:green]}m#{str}\e[0m" else puts " \e[#{COLOUR_CODES[:red]}m#{str}\n\e[0m" spec_example..each do |line| puts " \e[#{COLOUR_CODES[:red]}m#{line}\e[0m" end puts "\n \e[#{COLOUR_CODES[:light_blue]}m# #{spec_example.trace}\e[0m" end end |
#output(string) ⇒ Object
35 36 37 |
# File 'lib/m-spec/core/helpers/readable.rb', line 35 def output(string) Mspec::Matchers::Output.new(string) end |