Skip to content

Commit 3f74bcd

Browse files
author
Shaun Carlson
committed
fix tests, address warnings
1 parent 059cadb commit 3f74bcd

7 files changed

Lines changed: 100 additions & 103 deletions

spec/active_remote/cached/argument_keys_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
describe ::ActiveRemote::Cached::ArgumentKeys do
44
it "does not mutate a string by default" do
5-
::ActiveRemote::Cached::ArgumentKeys.new("hello", {}).cache_key.must_equal("hello")
5+
_(::ActiveRemote::Cached::ArgumentKeys.new("hello", {}).cache_key).must_equal("hello")
66
end
77

88
it "returns a string of a symbol by default" do
9-
::ActiveRemote::Cached::ArgumentKeys.new(:hello, {}).cache_key.must_equal("hello")
9+
_(::ActiveRemote::Cached::ArgumentKeys.new(:hello, {}).cache_key).must_equal("hello")
1010
end
1111

1212
it "does not mutate a string with special characters by default" do
13-
::ActiveRemote::Cached::ArgumentKeys.new("hello {}", {}).cache_key.must_equal("hello {}")
13+
_(::ActiveRemote::Cached::ArgumentKeys.new("hello {}", {}).cache_key).must_equal("hello {}")
1414
end
1515

1616
it "removes special characters from string with special characters when :active_remote_cached_remove_characters" do
1717
options = { :active_remote_cached_remove_characters => true }
18-
::ActiveRemote::Cached::ArgumentKeys.new("hello {}", options).cache_key.must_equal("hello")
18+
_(::ActiveRemote::Cached::ArgumentKeys.new("hello {}", options).cache_key).must_equal("hello")
1919
end
2020

2121
it "replaces special characters from string with special characters when :active_remote_cached_replace_characters" do
2222
options = { :active_remote_cached_replace_characters => true }
23-
::ActiveRemote::Cached::ArgumentKeys.new("hello {}", options).cache_key.must_equal("helloSPLBRB")
23+
_(::ActiveRemote::Cached::ArgumentKeys.new("hello {}", options).cache_key).must_equal("helloSPLBRB")
2424
end
2525
end

spec/active_remote/cached/cache_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44
describe "API" do
55
it "validates #delete present" do
66
cache = OpenStruct.new(:write => nil, :fetch => nil, :read => nil, :exist? => nil)
7-
error = lambda { ::ActiveRemote::Cached.cache(cache) }.must_raise(RuntimeError)
8-
error.message.must_match(/respond_to.*delete/i)
7+
error = _(lambda { ::ActiveRemote::Cached.cache(cache) }).must_raise(RuntimeError)
8+
_(error.message).must_match(/respond_to.*delete/i)
99
end
1010

1111
it "validates #exist? present" do
1212
cache = OpenStruct.new(:write => nil, :delete => nil, :read => nil, :fetch => nil)
13-
error = lambda { ::ActiveRemote::Cached.cache(cache) }.must_raise(RuntimeError)
14-
error.message.must_match(/respond_to.*exist/i)
13+
error = _(lambda { ::ActiveRemote::Cached.cache(cache) }).must_raise(RuntimeError)
14+
_(error.message).must_match(/respond_to.*exist/i)
1515
end
1616

1717
it "validates #fetch present" do
1818
cache = OpenStruct.new(:write => nil, :delete => nil, :read => nil, :exist? => nil)
19-
error = lambda { ::ActiveRemote::Cached.cache(cache) }.must_raise(RuntimeError)
20-
error.message.must_match(/respond_to.*fetch/i)
19+
error = _(lambda { ::ActiveRemote::Cached.cache(cache) }).must_raise(RuntimeError)
20+
_(error.message).must_match(/respond_to.*fetch/i)
2121
end
2222

2323
it "validates #read present" do
2424
cache = OpenStruct.new(:write => nil, :delete => nil, :fetch => nil, :exist? => nil)
25-
error = lambda { ::ActiveRemote::Cached.cache(cache) }.must_raise(RuntimeError)
26-
error.message.must_match(/respond_to.*read/i)
25+
error = _(lambda { ::ActiveRemote::Cached.cache(cache) }).must_raise(RuntimeError)
26+
_(error.message).must_match(/respond_to.*read/i)
2727
end
2828

2929
it "validates #write present" do
3030
cache = OpenStruct.new(:read => nil, :delete => nil, :fetch => nil, :exist? => nil)
31-
error = lambda { ::ActiveRemote::Cached.cache(cache)}.must_raise(RuntimeError)
32-
error.message.must_match(/respond_to.*write/i)
31+
error = _(lambda { ::ActiveRemote::Cached.cache(cache) }).must_raise(RuntimeError)
32+
_(error.message).must_match(/respond_to.*write/i)
3333
end
3434
end
3535
end

spec/active_remote/cached_delete_methods_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ def self.search; nil; end
1515
describe DeleteMethodClass do
1616
describe "API" do
1717
it "creates 'cached_delete_by_guid'" do
18-
DeleteMethodClass.must_respond_to("cached_delete_by_guid")
18+
_(DeleteMethodClass).must_respond_to("cached_delete_by_guid")
1919
end
2020

2121
it "creates 'cached_delete_by_user_guid'" do
22-
DeleteMethodClass.must_respond_to("cached_delete_by_user_guid")
22+
_(DeleteMethodClass).must_respond_to("cached_delete_by_user_guid")
2323
end
2424

2525
it "creates 'cached_delete_by_user_guid_and_client_guid'" do
26-
DeleteMethodClass.must_respond_to("cached_delete_by_user_guid_and_client_guid")
26+
_(DeleteMethodClass).must_respond_to("cached_delete_by_user_guid_and_client_guid")
2727
end
2828

2929
it "creates 'cached_delete_by_client_guid_and_user_guid'" do
30-
DeleteMethodClass.must_respond_to("cached_delete_by_client_guid_and_user_guid")
30+
_(DeleteMethodClass).must_respond_to("cached_delete_by_client_guid_and_user_guid")
3131
end
3232

3333
it "creates 'cached_delete_by_derp_and_user_guid_and_client_guid'" do
34-
DeleteMethodClass.must_respond_to("cached_delete_by_derp_and_user_guid_and_client_guid")
34+
_(DeleteMethodClass).must_respond_to("cached_delete_by_derp_and_user_guid_and_client_guid")
3535
end
3636

3737
it "creates 'cached_delete_by_client_guid_and_derp_and_user_guid'" do
38-
DeleteMethodClass.must_respond_to("cached_delete_by_client_guid_and_derp_and_user_guid")
38+
_(DeleteMethodClass).must_respond_to("cached_delete_by_client_guid_and_derp_and_user_guid")
3939
end
4040

4141
it "creates 'cached_delete_by_client_guid_and_user_guid_and_derp'" do
42-
DeleteMethodClass.must_respond_to("cached_delete_by_client_guid_and_user_guid_and_derp")
42+
_(DeleteMethodClass).must_respond_to("cached_delete_by_client_guid_and_user_guid_and_derp")
4343
end
4444
end
4545
end

spec/active_remote/cached_exist_methods_spec.rb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,116 +15,116 @@ def self.search; nil; end
1515
describe ExistMethodClass do
1616
describe "API" do
1717
it "creates 'cached_exist_find_by_guid'" do
18-
ExistMethodClass.must_respond_to("cached_exist_find_by_guid")
18+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_guid")
1919
end
2020

2121
it "creates 'cached_exist_search_by_guid'" do
22-
ExistMethodClass.must_respond_to("cached_exist_search_by_guid")
22+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_guid")
2323
end
2424

2525
it "creates 'cached_exist_find_by_user_guid'" do
26-
ExistMethodClass.must_respond_to("cached_exist_find_by_user_guid")
26+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_user_guid")
2727
end
2828

2929
it "creates 'cached_exist_search_by_user_guid'" do
30-
ExistMethodClass.must_respond_to("cached_exist_search_by_user_guid")
30+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_user_guid")
3131
end
3232

3333
it "creates 'cached_exist_find_by_user_guid_and_client_guid'" do
34-
ExistMethodClass.must_respond_to("cached_exist_find_by_user_guid_and_client_guid")
34+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_user_guid_and_client_guid")
3535
end
3636

3737
it "creates 'cached_exist_search_by_user_guid_and_client_guid'" do
38-
ExistMethodClass.must_respond_to("cached_exist_search_by_user_guid_and_client_guid")
38+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_user_guid_and_client_guid")
3939
end
4040

4141
it "creates 'cached_exist_find_by_client_guid_and_user_guid'" do
42-
ExistMethodClass.must_respond_to("cached_exist_find_by_client_guid_and_user_guid")
42+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_client_guid_and_user_guid")
4343
end
4444

4545
it "creates 'cached_exist_search_by_client_guid_and_user_guid'" do
46-
ExistMethodClass.must_respond_to("cached_exist_search_by_client_guid_and_user_guid")
46+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_client_guid_and_user_guid")
4747
end
4848

4949
it "creates 'cached_exist_find_by_derp_and_user_guid_and_client_guid'" do
50-
ExistMethodClass.must_respond_to("cached_exist_find_by_derp_and_user_guid_and_client_guid")
50+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_derp_and_user_guid_and_client_guid")
5151
end
5252

5353
it "creates 'cached_exist_search_by_derp_and_user_guid_and_client_guid'" do
54-
ExistMethodClass.must_respond_to("cached_exist_search_by_derp_and_user_guid_and_client_guid")
54+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_derp_and_user_guid_and_client_guid")
5555
end
5656

5757
it "creates 'cached_exist_find_by_client_guid_and_derp_and_user_guid'" do
58-
ExistMethodClass.must_respond_to("cached_exist_find_by_client_guid_and_derp_and_user_guid")
58+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_client_guid_and_derp_and_user_guid")
5959
end
6060

6161
it "creates 'cached_exist_search_by_client_guid_and_derp_and_user_guid'" do
62-
ExistMethodClass.must_respond_to("cached_exist_search_by_client_guid_and_derp_and_user_guid")
62+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_client_guid_and_derp_and_user_guid")
6363
end
6464

6565
it "creates 'cached_exist_find_by_client_guid_and_user_guid_and_derp'" do
66-
ExistMethodClass.must_respond_to("cached_exist_find_by_client_guid_and_user_guid_and_derp")
66+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_client_guid_and_user_guid_and_derp")
6767
end
6868

6969
it "creates 'cached_exist_search_by_client_guid_and_user_guid_and_derp'" do
70-
ExistMethodClass.must_respond_to("cached_exist_search_by_client_guid_and_user_guid_and_derp")
70+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_client_guid_and_user_guid_and_derp")
7171
end
7272

7373
# ? based methods
7474
it "creates 'cached_exist_find_by_guid?'" do
75-
ExistMethodClass.must_respond_to("cached_exist_find_by_guid?")
75+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_guid?")
7676
end
7777

7878
it "creates 'cached_exist_search_by_guid?'" do
79-
ExistMethodClass.must_respond_to("cached_exist_search_by_guid?")
79+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_guid?")
8080
end
8181

8282
it "creates 'cached_exist_find_by_user_guid?'" do
83-
ExistMethodClass.must_respond_to("cached_exist_find_by_user_guid?")
83+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_user_guid?")
8484
end
8585

8686
it "creates 'cached_exist_search_by_user_guid?'" do
87-
ExistMethodClass.must_respond_to("cached_exist_search_by_user_guid?")
87+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_user_guid?")
8888
end
8989

9090
it "creates 'cached_exist_find_by_user_guid_and_client_guid?'" do
91-
ExistMethodClass.must_respond_to("cached_exist_find_by_user_guid_and_client_guid?")
91+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_user_guid_and_client_guid?")
9292
end
9393

9494
it "creates 'cached_exist_search_by_user_guid_and_client_guid?'" do
95-
ExistMethodClass.must_respond_to("cached_exist_search_by_user_guid_and_client_guid?")
95+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_user_guid_and_client_guid?")
9696
end
9797

9898
it "creates 'cached_exist_find_by_client_guid_and_user_guid?'" do
99-
ExistMethodClass.must_respond_to("cached_exist_find_by_client_guid_and_user_guid?")
99+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_client_guid_and_user_guid?")
100100
end
101101

102102
it "creates 'cached_exist_search_by_client_guid_and_user_guid?'" do
103-
ExistMethodClass.must_respond_to("cached_exist_search_by_client_guid_and_user_guid?")
103+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_client_guid_and_user_guid?")
104104
end
105105

106106
it "creates 'cached_exist_find_by_derp_and_user_guid_and_client_guid?'" do
107-
ExistMethodClass.must_respond_to("cached_exist_find_by_derp_and_user_guid_and_client_guid?")
107+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_derp_and_user_guid_and_client_guid?")
108108
end
109109

110110
it "creates 'cached_exist_search_by_derp_and_user_guid_and_client_guid?'" do
111-
ExistMethodClass.must_respond_to("cached_exist_search_by_derp_and_user_guid_and_client_guid?")
111+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_derp_and_user_guid_and_client_guid?")
112112
end
113113

114114
it "creates 'cached_exist_find_by_client_guid_and_derp_and_user_guid?'" do
115-
ExistMethodClass.must_respond_to("cached_exist_find_by_client_guid_and_derp_and_user_guid?")
115+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_client_guid_and_derp_and_user_guid?")
116116
end
117117

118118
it "creates 'cached_exist_search_by_client_guid_and_derp_and_user_guid?'" do
119-
ExistMethodClass.must_respond_to("cached_exist_search_by_client_guid_and_derp_and_user_guid?")
119+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_client_guid_and_derp_and_user_guid?")
120120
end
121121

122122
it "creates 'cached_exist_find_by_client_guid_and_user_guid_and_derp?'" do
123-
ExistMethodClass.must_respond_to("cached_exist_find_by_client_guid_and_user_guid_and_derp?")
123+
_(ExistMethodClass).must_respond_to("cached_exist_find_by_client_guid_and_user_guid_and_derp?")
124124
end
125125

126126
it "creates 'cached_exist_search_by_client_guid_and_user_guid_and_derp?'" do
127-
ExistMethodClass.must_respond_to("cached_exist_search_by_client_guid_and_user_guid_and_derp?")
127+
_(ExistMethodClass).must_respond_to("cached_exist_search_by_client_guid_and_user_guid_and_derp?")
128128
end
129129
end
130130
end

spec/active_remote/cached_find_methods_spec.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,35 @@ def self.search; nil; end
1616
describe FindMethodClass do
1717
describe "API" do
1818
it "creates 'cached_find_by_foo'" do
19-
FindMethodClass.must_respond_to("cached_find_by_foo")
19+
_(FindMethodClass).must_respond_to("cached_find_by_foo")
2020
end
2121

2222
it "creates 'cached_find_by_guid'" do
23-
FindMethodClass.must_respond_to("cached_find_by_guid")
23+
_(FindMethodClass).must_respond_to("cached_find_by_guid")
2424
end
2525

2626
it "creates 'cached_find_by_user_guid'" do
27-
FindMethodClass.must_respond_to("cached_find_by_user_guid")
27+
_(FindMethodClass).must_respond_to("cached_find_by_user_guid")
2828
end
2929

3030
it "creates 'cached_find_by_user_guid_and_client_guid'" do
31-
FindMethodClass.must_respond_to("cached_find_by_user_guid_and_client_guid")
31+
_(FindMethodClass).must_respond_to("cached_find_by_user_guid_and_client_guid")
3232
end
3333

3434
it "creates 'cached_find_by_client_guid_and_user_guid'" do
35-
FindMethodClass.must_respond_to("cached_find_by_client_guid_and_user_guid")
35+
_(FindMethodClass).must_respond_to("cached_find_by_client_guid_and_user_guid")
3636
end
3737

3838
it "creates 'cached_find_by_derp_and_user_guid_and_client_guid'" do
39-
FindMethodClass.must_respond_to("cached_find_by_derp_and_user_guid_and_client_guid")
39+
_(FindMethodClass).must_respond_to("cached_find_by_derp_and_user_guid_and_client_guid")
4040
end
4141

4242
it "creates 'cached_find_by_client_guid_and_derp_and_user_guid'" do
43-
FindMethodClass.must_respond_to("cached_find_by_client_guid_and_derp_and_user_guid")
43+
_(FindMethodClass).must_respond_to("cached_find_by_client_guid_and_derp_and_user_guid")
4444
end
4545

4646
it "creates 'cached_find_by_client_guid_and_user_guid_and_derp'" do
47-
FindMethodClass.must_respond_to("cached_find_by_client_guid_and_user_guid_and_derp")
47+
_(FindMethodClass).must_respond_to("cached_find_by_client_guid_and_user_guid_and_derp")
4848
end
4949
end
5050

@@ -60,29 +60,29 @@ def self.search; nil; end
6060

6161
it "executes find_by_guid when cached_find with guid called" do
6262
FindMethodClass.stub(:find, :hello) do
63-
FindMethodClass.cached_find(:guid => :guid).must_equal(:hello)
63+
_(FindMethodClass.cached_find(:guid => :guid)).must_equal(:hello)
6464
end
6565
end
6666

6767
it "executes the fetch block if not present in cache" do
6868
FindMethodClass.stub(:find, :hello) do
69-
FindMethodClass.cached_find_by_guid(:guid).must_equal(:hello)
69+
_(FindMethodClass.cached_find_by_guid(:guid)).must_equal(:hello)
7070
end
7171
end
7272

7373
it "merges the default options in for the fetch call" do
74-
::ActiveRemote::Cached.cache.expects(:fetch).with([FindMethodClass.name, "#find", "guid"], :expires_in => 100).returns(:hello)
74+
::ActiveRemote::Cached.cache.expects(:fetch).with([::ActiveRemote::Cached::RUBY_AND_ACTIVE_SUPPORT_VERSION, FindMethodClass.name, "#find", "guid"], { :expires_in => 100 }).returns(:hello)
7575

7676
FindMethodClass.stub(:find, :hello) do
77-
FindMethodClass.cached_find_by_guid(:guid).must_equal(:hello)
77+
_(FindMethodClass.cached_find_by_guid(:guid)).must_equal(:hello)
7878
end
7979
end
8080

8181
it "overrides the default options with local options for the fetch call" do
82-
::ActiveRemote::Cached.cache.expects(:fetch).with([FindMethodClass.name, "#find", "guid"], :expires_in => 200).returns(:hello)
82+
::ActiveRemote::Cached.cache.expects(:fetch).with([::ActiveRemote::Cached::RUBY_AND_ACTIVE_SUPPORT_VERSION, FindMethodClass.name, "#find", "guid"], { :expires_in => 200 }).returns(:hello)
8383

8484
FindMethodClass.stub(:find, :hello) do
85-
FindMethodClass.cached_find_by_guid(:guid, :expires_in => 200).must_equal(:hello)
85+
_(FindMethodClass.cached_find_by_guid(:guid, :expires_in => 200)).must_equal(:hello)
8686
end
8787
end
8888

@@ -92,7 +92,7 @@ def self.search; nil; end
9292
end
9393

9494
it "uses the namespace as a prefix to the cache key" do
95-
::ActiveRemote::Cached.cache.expects(:fetch).with(["MyApp", FindMethodClass.name, "#find", "guid"], :expires_in => 100).returns(:hello)
95+
::ActiveRemote::Cached.cache.expects(:fetch).with([::ActiveRemote::Cached::RUBY_AND_ACTIVE_SUPPORT_VERSION, "MyApp", FindMethodClass.name, "#find", "guid"], { :expires_in => 100 }).returns(:hello)
9696

9797
FindMethodClass.stub(:find, :hello) do
9898
FindMethodClass.cached_find_by_guid(:guid)
@@ -112,18 +112,18 @@ def self.search; nil; end
112112
end
113113

114114
it "overrides the default options with cached_finder options for the fetch call" do
115-
::ActiveRemote::Cached.cache.expects(:fetch).with([FindMethodClass.name, "#find", "foo"], :expires_in => 500).returns(:hello)
115+
::ActiveRemote::Cached.cache.expects(:fetch).with([::ActiveRemote::Cached::RUBY_AND_ACTIVE_SUPPORT_VERSION, FindMethodClass.name, "#find", "foo"], { :expires_in => 500 }).returns(:hello)
116116

117117
FindMethodClass.stub(:find, :hello) do
118-
FindMethodClass.cached_find_by_foo(:foo).must_equal(:hello)
118+
_(FindMethodClass.cached_find_by_foo(:foo)).must_equal(:hello)
119119
end
120120
end
121121

122122
it "overrides the cached_finder options with local options for the fetch call" do
123-
::ActiveRemote::Cached.cache.expects(:fetch).with([FindMethodClass.name, "#find", "foo"], :expires_in => 200).returns(:hello)
123+
::ActiveRemote::Cached.cache.expects(:fetch).with([::ActiveRemote::Cached::RUBY_AND_ACTIVE_SUPPORT_VERSION, FindMethodClass.name, "#find", "foo"], { :expires_in => 200 }).returns(:hello)
124124

125125
FindMethodClass.stub(:find, :hello) do
126-
FindMethodClass.cached_find_by_foo(:foo, :expires_in => 200).must_equal(:hello)
126+
_(FindMethodClass.cached_find_by_foo(:foo, :expires_in => 200)).must_equal(:hello)
127127
end
128128
end
129129
end

0 commit comments

Comments
 (0)