spicycode-micronaut 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/RSPEC-LICENSE +23 -0
- data/Rakefile +2 -2
- data/examples/example_helper.rb +10 -0
- data/examples/lib/micronaut/behaviour_group_example.rb +170 -159
- data/examples/lib/micronaut/expectations/fail_with_example.rb +10 -64
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +3 -7
- data/examples/lib/micronaut/matchers/description_generation_example.rb +1 -1
- data/examples/lib/micronaut/matchers/have_example.rb +2 -2
- data/examples/lib/micronaut/matchers/operator_matcher_example.rb +0 -2
- data/examples/lib/micronaut/matchers/raise_error_example.rb +32 -1
- data/examples/lib/micronaut/{example_runner_example.rb → runner_example.rb} +0 -0
- data/examples/lib/micronaut/runner_options_example.rb +5 -0
- data/examples/lib/micronaut/world_example.rb +94 -0
- data/lib/micronaut.rb +1 -15
- data/lib/micronaut/behaviour_group.rb +34 -16
- data/lib/micronaut/behaviour_group_class_methods.rb +32 -47
- data/lib/micronaut/expectations.rb +0 -12
- data/lib/micronaut/extensions/kernel.rb +2 -2
- data/lib/micronaut/formatters/base_formatter.rb +4 -3
- data/lib/micronaut/formatters/base_text_formatter.rb +29 -17
- data/lib/micronaut/formatters/progress_formatter.rb +1 -1
- data/lib/micronaut/runner.rb +2 -2
- data/lib/micronaut/world.rb +36 -0
- metadata +7 -10
- data/examples/lib/micronaut/expectations/differs/default_example.rb +0 -125
- data/examples/lib/micronaut/matchers/exist_example.rb +0 -69
- data/lib/micronaut/example_world.rb +0 -17
- data/lib/micronaut/expectations/differs/default.rb +0 -58
- data/lib/micronaut/matchers/exist.rb +0 -16
@@ -1,69 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
-
|
3
|
-
class Substance
|
4
|
-
def initialize exists, description
|
5
|
-
@exists = exists
|
6
|
-
@description = description
|
7
|
-
end
|
8
|
-
|
9
|
-
def exist?
|
10
|
-
@exists
|
11
|
-
end
|
12
|
-
|
13
|
-
def inspect
|
14
|
-
@description
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class SubstanceTester
|
19
|
-
include Micronaut::Matchers
|
20
|
-
|
21
|
-
def initialize substance
|
22
|
-
@substance = substance
|
23
|
-
end
|
24
|
-
|
25
|
-
def should_exist
|
26
|
-
@substance.should exist
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "should exist," do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
describe "within an example group" do
|
36
|
-
|
37
|
-
before do
|
38
|
-
@real = Substance.new true, 'something real'
|
39
|
-
@imaginary = Substance.new false, 'something imaginary'
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should pass if target exists" do
|
43
|
-
@real.should exist
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should fail if target does not exist" do
|
47
|
-
lambda { @imaginary.should exist }.should fail
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should pass if target doesn't exist" do
|
51
|
-
lambda { @real.should_not exist }.should fail
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "outside of an example group" do
|
56
|
-
|
57
|
-
before do
|
58
|
-
@real = Substance.new true, 'something real'
|
59
|
-
@imaginary = Substance.new false, 'something imaginary'
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should pass if target exists" do
|
63
|
-
real_tester = SubstanceTester.new @real
|
64
|
-
real_tester.should_exist
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'rubygems'
|
3
|
-
require 'diff/lcs' #necessary due to loading bug on some machines - not sure why - DaC
|
4
|
-
require 'diff/lcs/hunk'
|
5
|
-
rescue LoadError ; raise "You must gem install diff-lcs to use diffing" ; end
|
6
|
-
|
7
|
-
require 'pp'
|
8
|
-
|
9
|
-
module Micronaut
|
10
|
-
module Expectations
|
11
|
-
module Differs
|
12
|
-
|
13
|
-
# TODO add some rdoc
|
14
|
-
class Default
|
15
|
-
def initialize(format = :unified, context_lines = 3)
|
16
|
-
@format, @context_lines = format, context_lines
|
17
|
-
end
|
18
|
-
|
19
|
-
# This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
|
20
|
-
def diff_as_string(data_new, data_old)
|
21
|
-
data_old = data_old.split(/\n/).map! { |e| e.chomp }
|
22
|
-
data_new = data_new.split(/\n/).map! { |e| e.chomp }
|
23
|
-
output = ""
|
24
|
-
diffs = Diff::LCS.diff(data_old, data_new)
|
25
|
-
return output if diffs.empty?
|
26
|
-
oldhunk = hunk = nil
|
27
|
-
file_length_difference = 0
|
28
|
-
diffs.each do |piece|
|
29
|
-
begin
|
30
|
-
hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, @context_lines,
|
31
|
-
file_length_difference)
|
32
|
-
file_length_difference = hunk.file_length_difference
|
33
|
-
next unless oldhunk
|
34
|
-
# Hunks may overlap, which is why we need to be careful when our
|
35
|
-
# diff includes lines of context. Otherwise, we might print
|
36
|
-
# redundant lines.
|
37
|
-
if (@context_lines > 0) and hunk.overlaps?(oldhunk)
|
38
|
-
hunk.unshift(oldhunk)
|
39
|
-
else
|
40
|
-
output << oldhunk.diff(@format)
|
41
|
-
end
|
42
|
-
ensure
|
43
|
-
oldhunk = hunk
|
44
|
-
output << "\n"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
#Handle the last remaining hunk
|
48
|
-
output << oldhunk.diff(@format) << "\n"
|
49
|
-
end
|
50
|
-
|
51
|
-
def diff_as_object(target,expected)
|
52
|
-
diff_as_string(PP.pp(target,""), PP.pp(expected,""))
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Micronaut
|
2
|
-
module Matchers
|
3
|
-
# :call-seq:
|
4
|
-
# should exist
|
5
|
-
# should_not exist
|
6
|
-
#
|
7
|
-
# Passes if actual.exist?
|
8
|
-
def exist
|
9
|
-
simple_matcher do |actual, matcher|
|
10
|
-
matcher.failure_message = "expected #{actual.inspect} to exist, but it doesn't."
|
11
|
-
matcher.negative_failure_message = "expected #{actual.inspect} to not exist, but it does."
|
12
|
-
actual.exist?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|