MacSpec 0.4.0 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,5 +1,10 @@
1
1
  Copyright (c) 2010 Matthias Hennemeyer
2
2
 
3
+ The matcher_system is built around Jeremy McAnally's matchy
4
+ -> http://github.com/jm/matchy and is:
5
+
6
+ Copyright (c) 2008 Jeremy McAnally
7
+
3
8
  Permission is hereby granted, free of charge, to any person obtaining
4
9
  a copy of this software and associated documentation files (the
5
10
  "Software"), to deal in the Software without restriction, including
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{MacSpec}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthias Hennemeyer"]
@@ -72,6 +72,7 @@ Gem::Specification.new do |s|
72
72
  "test/mac_spec/testing_framework/regression/description_string_test.rb",
73
73
  "test/mac_spec/testing_framework/regression/example_name_test.rb",
74
74
  "test/mac_spec/testing_framework/regression/inherit_not_double_test.rb",
75
+ "test/mac_spec/testing_framework/regression/shared_examples_test.rb",
75
76
  "test/mac_spec/testing_framework/regression/surrounding_module_scope_test.rb",
76
77
  "test/mac_spec/testing_framework/regression/testing_functions_test.rb",
77
78
  "test/mac_spec/testing_framework/test_helper.rb",
@@ -110,6 +111,7 @@ Gem::Specification.new do |s|
110
111
  "test/mac_spec/testing_framework/regression/description_string_test.rb",
111
112
  "test/mac_spec/testing_framework/regression/example_name_test.rb",
112
113
  "test/mac_spec/testing_framework/regression/inherit_not_double_test.rb",
114
+ "test/mac_spec/testing_framework/regression/shared_examples_test.rb",
113
115
  "test/mac_spec/testing_framework/regression/surrounding_module_scope_test.rb",
114
116
  "test/mac_spec/testing_framework/regression/testing_functions_test.rb",
115
117
  "test/mac_spec/testing_framework/test_helper.rb",
@@ -64,6 +64,19 @@ Now set the active target to 'Unit Tests' and hit Cmd-B.
64
64
 
65
65
  The highest priority feature will always be MacRuby compatibility. We will expand MacSpec's feature set towards RSpec's feature set step by step.
66
66
 
67
+ == Features
68
+
69
+ === Lots of matchers
70
+
71
+ === A testing framework
72
+
73
+ With nested describe blocks, chained setup and teardown, fit and xit, shared_example_groups
74
+
75
+ === A mock framework
76
+
77
+ With mock objects, method stubs and method expectations (aka partials)
78
+
67
79
  == Copyright
68
80
 
69
81
  Copyright (c) 2010 Matthias Hennemeyer. See LICENSE for details.
82
+ matchy is (c) 2008 Jeremy McAnally
@@ -1,3 +1,26 @@
1
+ # The matchersystem is built around Jeremy McAnally's matchy
2
+ # -> http://github.com/jm/matchy
3
+ # Copyright (c) 2008 Jeremy McAnally
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
1
24
  $:.unshift(File.dirname(__FILE__)) unless
2
25
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
26
  require 'matcher_system/core/expectation_builder'
@@ -4,7 +4,7 @@ module MacSpec
4
4
  def self.build_expectation(match, exp, obj)
5
5
  return MacSpec::MatcherSystem::Expectations::OperatorExpectation.new(obj, match) unless exp
6
6
 
7
- (exp.matches?(obj) != match) ? exp.fail!(match) : exp.pass!(match)
7
+ (exp.matches?(obj) != match) ? MacSpec.flunk(match ? exp.failure_message : exp.negative_failure_message) : MacSpec.assert(true)
8
8
  end
9
9
  end
10
10
  end
@@ -36,13 +36,6 @@ module MacSpec
36
36
  @match_block.call(given, self)
37
37
  end
38
38
 
39
- def fail!(which)
40
- @test_case.flunk(which ? failure_message : negative_failure_message)
41
- end
42
-
43
- def pass!(which)
44
- @test_case.assert true
45
- end
46
39
  alias_method :failure_message, :positive_msg
47
40
  alias_method :negative_failure_message, :negative_msg
48
41
  end
@@ -1,8 +1,13 @@
1
1
 
2
2
  module Kernel
3
+
4
+ def shared_examples_for(sym, &block)
5
+ MacSpec.add_shared_example_group(sym, block)
6
+ end
7
+
3
8
  def describe(*args, &block)
4
9
  super_class = (Hash === args.last && (args.last[:type] || args.last[:testcase])) || MacSpec.test_case_class
5
- super_class.class_eval {extend MacSpec::TestingFramework::TestCaseClassMethods}
10
+ super_class.class_eval {extend MacSpec::TestingFramework::TestCaseClassMethods}
6
11
  cls = Class.new(super_class)
7
12
  cnst, desc = args
8
13
  cnst = MacSpec::TestingFramework::Functions.make_constantizeable(cnst)
@@ -37,7 +37,7 @@ module MacSpec
37
37
  # == Run before each Test.
38
38
  # The code in the block attached to this method will be run before each
39
39
  # test in all subsequent, eventually nested testcases.
40
- def setup(&block)
40
+ def setup(type = :each, &block)
41
41
  passed_through_setup = self.setup_chained
42
42
  self.setup_chained = lambda { instance_eval(&passed_through_setup);instance_eval(&block) }
43
43
  define_method :setup, &self.setup_chained
@@ -47,7 +47,7 @@ module MacSpec
47
47
  # == Run after each Test.
48
48
  # The code in the block attached to this method will be run after each
49
49
  # test in all subsequent, eventually nested testcases.
50
- def teardown(&block)
50
+ def teardown(type = :each, &block)
51
51
  passed_through_teardown = self.teardown_chained
52
52
  self.teardown_chained = lambda {instance_eval(&block);instance_eval(&passed_through_teardown) }
53
53
  define_method :teardown, &self.teardown_chained
@@ -84,6 +84,10 @@ module MacSpec
84
84
  test.to_sym
85
85
  end
86
86
 
87
+ def it_should_behave_like(sym)
88
+ class_eval(&MacSpec.shared_example_group_for(sym))
89
+ end
90
+
87
91
  # == prepend 'f' to focus on a test
88
92
  def fit desc, &block
89
93
  MacSpec.add_focused_test(self, self.it(desc, &block).to_sym)
@@ -1,3 +1,3 @@
1
1
  module MacSpec
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -39,6 +39,14 @@ module MacSpec
39
39
  @focused_tests
40
40
  end
41
41
 
42
+ def add_shared_example_group(name, block)
43
+ (@shared_example_groups ||= {}).update({name => block})
44
+ end
45
+
46
+ def shared_example_group_for(name)
47
+ @shared_example_groups && @shared_example_groups[name]
48
+ end
49
+
42
50
  def assertions_module
43
51
  MiniTest::Assertions
44
52
  end
@@ -17,7 +17,7 @@ describe "top level" do
17
17
  @horst = "NoHorst!"
18
18
  end
19
19
 
20
- it "there should be NoHorst" do
20
+ it "there should be NoHorst" do
21
21
  @horst.should eql("NoHorst!")
22
22
  end
23
23
 
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + "/../test_helper.rb"
2
+
3
+ shared_examples_for "blahing objects" do
4
+ it "can blah" do
5
+ @object.should respond_to(:blah)
6
+ end
7
+ end
8
+
9
+ describe "shared examples" do
10
+ before do
11
+ @object = Object.new
12
+ def @object.blah
13
+ "blah"
14
+ end
15
+ end
16
+
17
+ it_should_behave_like "blahing objects"
18
+
19
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 5
9
+ version: 0.4.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matthias Hennemeyer
@@ -83,6 +83,7 @@ files:
83
83
  - test/mac_spec/testing_framework/regression/description_string_test.rb
84
84
  - test/mac_spec/testing_framework/regression/example_name_test.rb
85
85
  - test/mac_spec/testing_framework/regression/inherit_not_double_test.rb
86
+ - test/mac_spec/testing_framework/regression/shared_examples_test.rb
86
87
  - test/mac_spec/testing_framework/regression/surrounding_module_scope_test.rb
87
88
  - test/mac_spec/testing_framework/regression/testing_functions_test.rb
88
89
  - test/mac_spec/testing_framework/test_helper.rb
@@ -145,6 +146,7 @@ test_files:
145
146
  - test/mac_spec/testing_framework/regression/description_string_test.rb
146
147
  - test/mac_spec/testing_framework/regression/example_name_test.rb
147
148
  - test/mac_spec/testing_framework/regression/inherit_not_double_test.rb
149
+ - test/mac_spec/testing_framework/regression/shared_examples_test.rb
148
150
  - test/mac_spec/testing_framework/regression/surrounding_module_scope_test.rb
149
151
  - test/mac_spec/testing_framework/regression/testing_functions_test.rb
150
152
  - test/mac_spec/testing_framework/test_helper.rb