neo-rails 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,13 +56,27 @@ module Neo
56
56
 
57
57
  class MockConfig
58
58
  def initialize(tags, options={})
59
- @tags = tags
59
+ @tags = Set.new(tags)
60
60
  @options = options
61
61
  end
62
62
 
63
63
  # Returns a human readable tag list.
64
64
  def description
65
- @tags.to_a.map { |tag| tag.to_s.capitalize }.join(", ")
65
+ @tags.map { |tag| tag.to_s.capitalize }.join(", ")
66
+ end
67
+
68
+ def tags
69
+ @tags.to_a
70
+ end
71
+
72
+ # Tag mock with +tags+.
73
+ def tag(*tags)
74
+ tags.each { |tag| @tags << tag }
75
+ end
76
+
77
+ # Untag mock.
78
+ def untag(*tags)
79
+ tags.each { |tag| @tags.delete(tag) }
66
80
  end
67
81
 
68
82
  # Checks if this mock is tagged with +tag+.
@@ -1,5 +1,5 @@
1
1
  module Neo
2
2
  module Rails
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
data/test/mock_test.rb CHANGED
@@ -31,6 +31,36 @@ class MockTest < NeoRailsCase
31
31
  end
32
32
  end
33
33
 
34
+ context :tag do
35
+ let(:mock) { Neo::Rails::Mock.new }
36
+
37
+ test "add tags" do
38
+ mock.mock.tag(:foo, :bar)
39
+ assert mock.mock.tagged?(:foo)
40
+ assert mock.mock.tagged?(:bar)
41
+ end
42
+
43
+ test "add tag uniquely" do
44
+ mock.mock.tag(:foo, :foo)
45
+ assert_equal [ :foo ], mock.mock.tags
46
+ end
47
+ end
48
+
49
+ context :untag do
50
+ let(:mock) { Neo::Rails::Mock.new(:foo, :bar) }
51
+
52
+ test "remove tags" do
53
+ mock.mock.untag(:bar, :foo)
54
+ refute mock.mock.tagged?(:foo)
55
+ refute mock.mock.tagged?(:bar)
56
+ end
57
+
58
+ test "remove unset tag works" do
59
+ refute mock.mock.tagged?(:nottagged)
60
+ mock.mock.untag(:nottagged)
61
+ end
62
+ end
63
+
34
64
  context :options do
35
65
  let(:mock) { Neo::Rails::Mock.new(:tag, :opt => true, "string" => :yes) }
36
66
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-13 00:00:00.000000000 Z
13
+ date: 2012-09-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake