copperegg-revealmetrics 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{Users/reto/Projects/copperegg-revealmetrics/LICENSE → LICENSE} +0 -0
- data/{Users/reto/Projects/copperegg-revealmetrics/README.md → README.md} +1 -1
- data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg.rb +0 -0
- data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg/api.rb +0 -0
- data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg/custom_dashboard.rb +0 -0
- data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg/metric_group.rb +0 -0
- data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg/metric_sample.rb +0 -0
- data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg/mixins/persistence.rb +0 -0
- data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg/tag.rb +0 -0
- data/lib/copperegg/ver.rb +3 -0
- metadata +12 -30
- data/Users/reto/Projects/copperegg-revealmetrics/CHANGELOG.md +0 -64
- data/Users/reto/Projects/copperegg-revealmetrics/Gemfile +0 -3
- data/Users/reto/Projects/copperegg-revealmetrics/Gemfile.lock +0 -28
- data/Users/reto/Projects/copperegg-revealmetrics/Rakefile +0 -3
- data/Users/reto/Projects/copperegg-revealmetrics/copperegg.gemspec +0 -24
- data/Users/reto/Projects/copperegg-revealmetrics/lib/copperegg/ver.rb +0 -3
- data/Users/reto/Projects/copperegg-revealmetrics/pkg/copperegg-revealmetrics-0.6.1.gem +0 -0
- data/Users/reto/Projects/copperegg-revealmetrics/pkg/copperegg-revealmetrics-0.6.2.gem +0 -0
- data/Users/reto/Projects/copperegg-revealmetrics/pkg/copperegg-revealmetrics-0.7.0.gem +0 -0
- data/Users/reto/Projects/copperegg-revealmetrics/test/custom_dashboard_test.rb +0 -118
- data/Users/reto/Projects/copperegg-revealmetrics/test/metric_group_test.rb +0 -61
- data/Users/reto/Projects/copperegg-revealmetrics/test/metric_sample_test.rb +0 -6
- data/Users/reto/Projects/copperegg-revealmetrics/test/tag_test.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fd0a9c916d336895ea615212e8fdff1c4e62e38
|
4
|
+
data.tar.gz: 64fc8b11e3f72888a3e8f3afbd1e2ac3040d4a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85749a44833212b1ffc7259ac035e5fd200b0c49784ac0f4b3aff7be8320c391dcf6e1294bcae4efc838098d65f618511776757de3d08f463b42ccb2250e6b63
|
7
|
+
data.tar.gz: fd3527fe79c80d13ba37e012d405840561e439c7e64fde985911966d10e887af7e173f243c987ac12b0ba29093cef5106d3ee6682b498ad5ce8bcc99975a727c
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/{Users/reto/Projects/copperegg-revealmetrics/lib → lib}/copperegg/mixins/persistence.rb
RENAMED
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copperegg-revealmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Anderson
|
@@ -59,28 +59,16 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/lib/copperegg/metric_group.rb"
|
73
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/lib/copperegg/metric_sample.rb"
|
74
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/lib/copperegg/mixins/persistence.rb"
|
75
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/lib/copperegg/tag.rb"
|
76
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/lib/copperegg/ver.rb"
|
77
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/pkg/copperegg-revealmetrics-0.6.1.gem"
|
78
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/pkg/copperegg-revealmetrics-0.6.2.gem"
|
79
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/pkg/copperegg-revealmetrics-0.7.0.gem"
|
80
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/test/custom_dashboard_test.rb"
|
81
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/test/metric_group_test.rb"
|
82
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/test/metric_sample_test.rb"
|
83
|
-
- "/Users/reto/Projects/copperegg-revealmetrics/test/tag_test.rb"
|
62
|
+
- LICENSE
|
63
|
+
- README.md
|
64
|
+
- lib/copperegg.rb
|
65
|
+
- lib/copperegg/api.rb
|
66
|
+
- lib/copperegg/custom_dashboard.rb
|
67
|
+
- lib/copperegg/metric_group.rb
|
68
|
+
- lib/copperegg/metric_sample.rb
|
69
|
+
- lib/copperegg/mixins/persistence.rb
|
70
|
+
- lib/copperegg/tag.rb
|
71
|
+
- lib/copperegg/ver.rb
|
84
72
|
- test/custom_dashboard_test.rb
|
85
73
|
- test/metric_group_test.rb
|
86
74
|
- test/metric_sample_test.rb
|
@@ -90,13 +78,7 @@ licenses:
|
|
90
78
|
- MIT
|
91
79
|
metadata: {}
|
92
80
|
post_install_message:
|
93
|
-
rdoc_options:
|
94
|
-
- "--line-numbers"
|
95
|
-
- "--inline-source"
|
96
|
-
- "--title"
|
97
|
-
- copperegg-revealmetrics
|
98
|
-
- "--main"
|
99
|
-
- README.md
|
81
|
+
rdoc_options: []
|
100
82
|
require_paths:
|
101
83
|
- lib
|
102
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -1,64 +0,0 @@
|
|
1
|
-
## 0.7.0
|
2
|
-
- Cover "tags" functionality of API with `CopperEgg::Tag`.
|
3
|
-
|
4
|
-
|
5
|
-
## 0.6.2
|
6
|
-
- Fork from `CopperEgg/copperegg-ruby` to `cargomedia/copperegg-revealmetrics`
|
7
|
-
|
8
|
-
|
9
|
-
## 0.6.1 (January 17, 2013)
|
10
|
-
|
11
|
-
Changes:
|
12
|
-
|
13
|
-
- Existing metric groups are used rather than automatically versioning metric group name upon creation.
|
14
|
-
|
15
|
-
|
16
|
-
## 0.6.0 (January 3, 2013)
|
17
|
-
|
18
|
-
Changes:
|
19
|
-
|
20
|
-
- Substantial changes to syntax. API resources now represented by Ruby classes. See README for details.
|
21
|
-
- Replaced multi_json requirement with json_pure.
|
22
|
-
|
23
|
-
Features:
|
24
|
-
|
25
|
-
- Automatic dashboard creation for metric groups.
|
26
|
-
- Metric groups and custom dashboards can be updated and deleted.
|
27
|
-
- Client-side validation added.
|
28
|
-
- Added automated test suite.
|
29
|
-
|
30
|
-
Bugfixes:
|
31
|
-
|
32
|
-
- Metric group versioning is encorporated and recognized.
|
33
|
-
|
34
|
-
|
35
|
-
## 0.5.3 (Dec 21, 2012)
|
36
|
-
|
37
|
-
Changes:
|
38
|
-
|
39
|
-
- Remove Gemfile.lock from git tracking
|
40
|
-
|
41
|
-
Bugfixes:
|
42
|
-
|
43
|
-
- format to match changes in CopperEgg API
|
44
|
-
|
45
|
-
|
46
|
-
## 0.5.2 (Dec 3, 2012)
|
47
|
-
|
48
|
-
Bugfixes:
|
49
|
-
|
50
|
-
- add explicit requires to make 1.8.7 work
|
51
|
-
|
52
|
-
|
53
|
-
## 0.5.1 (Nov 5, 2012)
|
54
|
-
|
55
|
-
Changes:
|
56
|
-
|
57
|
-
- Use SSL
|
58
|
-
- updated gemspec and variable names
|
59
|
-
|
60
|
-
|
61
|
-
## 0.5.0 (Nov 5, 2012)
|
62
|
-
|
63
|
-
Initial commit
|
64
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
copperegg-revealmetrics (0.6.1)
|
5
|
-
json_pure (~> 1.7.6)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
diff-lcs (1.2.5)
|
11
|
-
json_pure (1.7.7)
|
12
|
-
rake (10.4.2)
|
13
|
-
rspec (2.99.0)
|
14
|
-
rspec-core (~> 2.99.0)
|
15
|
-
rspec-expectations (~> 2.99.0)
|
16
|
-
rspec-mocks (~> 2.99.0)
|
17
|
-
rspec-core (2.99.2)
|
18
|
-
rspec-expectations (2.99.2)
|
19
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
20
|
-
rspec-mocks (2.99.3)
|
21
|
-
|
22
|
-
PLATFORMS
|
23
|
-
ruby
|
24
|
-
|
25
|
-
DEPENDENCIES
|
26
|
-
copperegg-revealmetrics!
|
27
|
-
rake
|
28
|
-
rspec (~> 2.0)
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.expand_path('../lib/copperegg/ver', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'copperegg-revealmetrics'
|
5
|
-
s.version = CopperEgg::GEM_VERSION
|
6
|
-
s.summary = 'API client for CopperEgg Revealmetrics'
|
7
|
-
s.description = 'API client for CopperEgg Revealmetrics'
|
8
|
-
s.authors = ['Eric Anderson', 'Cargo Media']
|
9
|
-
s.email = 'hello@cargomedia.ch'
|
10
|
-
s.homepage = 'https://github.com/cargomedia/copperegg-revealmetrics'
|
11
|
-
s.license = 'MIT'
|
12
|
-
|
13
|
-
s.platform = Gem::Platform::RUBY
|
14
|
-
s.require_paths = %w[lib]
|
15
|
-
s.files = Dir["#{File.dirname(__FILE__)}/**/*"]
|
16
|
-
s.test_files = Dir.glob("{test,spec,features}/*")
|
17
|
-
|
18
|
-
s.add_dependency('json_pure', '~> 1.7.6')
|
19
|
-
|
20
|
-
s.add_development_dependency 'rake'
|
21
|
-
s.add_development_dependency 'rspec', '~> 2.0'
|
22
|
-
|
23
|
-
s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'copperegg-revealmetrics', '--main', 'README.md']
|
24
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "copperegg"
|
3
|
-
|
4
|
-
class CustomDashboardTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_name_accessor_and_setter
|
7
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
8
|
-
|
9
|
-
assert_equal "My Dashboard", dashboard.name
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_save_should_fail_if_name_is_not_set
|
13
|
-
dashboard = CopperEgg::CustomDashboard.new
|
14
|
-
|
15
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
16
|
-
assert_equal "Name can't be blank.", error.message
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_save_should_fail_for_an_invalid_widget_type
|
20
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
21
|
-
dashboard.data["widgets"]["0"] = {:type => "foo", :style => "value", :match => "tag", :match_param => ["test"],
|
22
|
-
:metric => {"my_metric_group" => [[0, "metric1"]]}}
|
23
|
-
|
24
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
25
|
-
assert_equal "Invalid widget type foo.", error.message
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_save_should_fail_for_an_invalid_widget_style
|
29
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
30
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "foo", :match => "tag", :match_param => ["test"],
|
31
|
-
:metric => {"my_metric_group" => [[0, "metric1"]]}}
|
32
|
-
|
33
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
34
|
-
assert_equal "Invalid widget style foo.", error.message
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_save_should_ail_for_an_invalidvwidget_match
|
38
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
39
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "foo", :match_param => ["test"],
|
40
|
-
:metric => {"my_metric_group" => [[0, "metric1"]]}}
|
41
|
-
|
42
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
43
|
-
assert_equal "Invalid widget match foo.", error.message
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_save_should_fail_for_a_missing_match_parameter
|
47
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
48
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "select", :metric => {"my_metric_group" => [[0, "metric1"]]}}
|
49
|
-
|
50
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
51
|
-
assert_equal "Missing match parameter.", error.message
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_save_should_fail_if_metric_is_not_a_hash
|
55
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
56
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => ["my_metric_group", 0, "metric1"]}
|
57
|
-
|
58
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
59
|
-
assert_match /invalid widget metric/i, error.message
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_save_should_fail_if_metric_does_not_contain_an_array
|
63
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
64
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => "metric1"}}
|
65
|
-
|
66
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
67
|
-
assert_match /invalid widget metric/i, error.message
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_save_should_fail_if_metric_contains_an_empty_array
|
71
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
72
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => []}}
|
73
|
-
|
74
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
75
|
-
assert_match /invalid widget metric/i, error.message
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_save_should_fail_if_metric_contains_an_array_with_invalid_values
|
79
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
80
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => ["metric1"]}}
|
81
|
-
|
82
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
83
|
-
assert_match /invalid widget metric/i, error.message
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_save_should_fail_if_metric_contains_an_array_with_an_invalid_position
|
87
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
88
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => [["four", "metric1"]]}}
|
89
|
-
|
90
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
91
|
-
assert_match /invalid widget metric/i, error.message
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_save_should_fail_if_metric_contains_an_array_with_no_metric_name
|
95
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
96
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => [[0]]}}
|
97
|
-
|
98
|
-
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
99
|
-
assert_match /invalid widget metric/i, error.message
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_to_hash
|
103
|
-
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
104
|
-
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => [[1, "metric1"]]}}
|
105
|
-
|
106
|
-
assert dashboard.valid?
|
107
|
-
|
108
|
-
hash = dashboard.to_hash
|
109
|
-
|
110
|
-
assert_equal "My Dashboard", hash["name"]
|
111
|
-
assert_equal "metric", hash["data"]["widgets"]["0"][:type]
|
112
|
-
assert_equal "value", hash["data"]["widgets"]["0"][:style]
|
113
|
-
assert_equal "tag", hash["data"]["widgets"]["0"][:match]
|
114
|
-
assert_equal ["test"], hash["data"]["widgets"]["0"][:match_param]
|
115
|
-
assert_equal [[1, "metric1"]], hash["data"]["widgets"]["0"][:metric]["my_metric_group"]
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "copperegg"
|
3
|
-
|
4
|
-
class MetricGroupTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_name_accessor_and_setter
|
7
|
-
metric_group = CopperEgg::MetricGroup.new(:name => "my_metric_group")
|
8
|
-
|
9
|
-
assert_equal "my_metric_group", metric_group.name
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_save_should_fail_if_name_is_blank
|
13
|
-
metric_group = CopperEgg::MetricGroup.new
|
14
|
-
|
15
|
-
error = assert_raise(CopperEgg::ValidationError) { metric_group.save }
|
16
|
-
assert_equal "Name can't be blank.", error.message
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_save_should_fail_if_no_metrics_are_declared
|
20
|
-
metric_group = CopperEgg::MetricGroup.new(:name => "my_metric_group")
|
21
|
-
|
22
|
-
error = assert_raise(CopperEgg::ValidationError) { metric_group.save }
|
23
|
-
assert_equal "You must define at least one metric.", error.message
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_save_should_fail_if_metrics_include_non_metric
|
27
|
-
metric_group = CopperEgg::MetricGroup.new(:name => "my_metric_group", :metrics => ["metric"])
|
28
|
-
|
29
|
-
error = assert_raise(CopperEgg::ValidationError) { metric_group.save }
|
30
|
-
assert_equal "Metric expected.", error.message
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_save_should_fail_for_invalid_metric
|
34
|
-
metric_group = CopperEgg::MetricGroup.new(:name => "my_metric_group", :metrics => [{:name => "test", :type => "invalid"}])
|
35
|
-
|
36
|
-
error = assert_raise(CopperEgg::ValidationError) { metric_group.save }
|
37
|
-
assert_equal "Invalid metric type invalid.", error.message
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_to_hash
|
41
|
-
metric_group = CopperEgg::MetricGroup.new(:name => "test", :label => "Test Metric", :frequency => 5)
|
42
|
-
metric_group.metrics << {:type => "ce_counter", :name => "metric1", :label => "Metric 1", :unit => "ticks"}
|
43
|
-
metric_group.metrics << {:type => "ce_counter_f", :name => "metric2", :label => "Metric 2"}
|
44
|
-
|
45
|
-
assert metric_group.valid?
|
46
|
-
hash = metric_group.to_hash
|
47
|
-
|
48
|
-
assert_nil hash["id"]
|
49
|
-
assert_equal "test", hash["name"]
|
50
|
-
assert_equal "Test Metric", hash["label"]
|
51
|
-
assert_equal 5, hash["frequency"]
|
52
|
-
assert_equal "ce_counter", hash["metrics"].first["type"]
|
53
|
-
assert_equal "metric1", hash["metrics"].first["name"]
|
54
|
-
assert_equal "Metric 1", hash["metrics"].first["label"]
|
55
|
-
assert_equal "ticks", hash["metrics"].first["unit"]
|
56
|
-
assert_equal "ce_counter_f", hash["metrics"].last["type"]
|
57
|
-
assert_equal "metric2", hash["metrics"].last["name"]
|
58
|
-
assert_equal "Metric 2", hash["metrics"].last["label"]
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "copperegg"
|
3
|
-
|
4
|
-
class TagTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_name_accessor_and_setter
|
7
|
-
tag = CopperEgg::Tag.new(:name => "my_tag")
|
8
|
-
|
9
|
-
assert_equal "my_tag", tag.name
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_save_should_fail_if_name_is_blank
|
13
|
-
tag = CopperEgg::Tag.new
|
14
|
-
|
15
|
-
error = assert_raise(CopperEgg::ValidationError) { tag.save }
|
16
|
-
assert_equal "Name can't be blank.", error.message
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_save_should_fail_if_name_contains_invalid_characters
|
20
|
-
tag = CopperEgg::Tag.new(:name => "my%%%tag")
|
21
|
-
|
22
|
-
error = assert_raise(CopperEgg::ValidationError) { tag.save }
|
23
|
-
assert_equal "Name contains invalid characters.", error.message
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_objects_accessor_and_setter
|
27
|
-
tag = CopperEgg::Tag.new(:name => "my_tag", :objects => [{"idv" => "obj1"}, {"idv" => "obj2"}])
|
28
|
-
|
29
|
-
assert_equal ["obj1", "obj2"], tag.objects
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_save_should_fail_if_no_objects_are_declared
|
33
|
-
tag = CopperEgg::Tag.new(:name => "my_tag")
|
34
|
-
|
35
|
-
error = assert_raise(CopperEgg::ValidationError) { tag.save }
|
36
|
-
assert_equal "You must define at least one object.", error.message
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_save_should_fail_if_objects_include_non_strings
|
40
|
-
tag = CopperEgg::Tag.new(:name => "my_tag")
|
41
|
-
tag.objects = ["obj1", 12323]
|
42
|
-
|
43
|
-
error = assert_raise(CopperEgg::ValidationError) { tag.save }
|
44
|
-
assert_equal "Invalid object identifier.", error.message
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_to_hash
|
48
|
-
tag = CopperEgg::Tag.new(:name => "test")
|
49
|
-
tag.objects = ["obj1", "obj2"]
|
50
|
-
|
51
|
-
assert tag.valid?
|
52
|
-
hash = tag.to_hash
|
53
|
-
|
54
|
-
assert_nil hash["id"]
|
55
|
-
assert_equal "test", hash["tag"]
|
56
|
-
assert_equal ["obj1", "obj2"], hash["ids"]
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|