Skip to content

Commit 9928919

Browse files
author
Kyle Decot
committed
refactoring
1 parent 086b961 commit 9928919

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

spec/kmdata_spec.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
require "kmdata"
33

44
describe KMData do
5+
describe '.get' do
6+
let(:json) { File.read(File.join('spec', 'fixtures', 'terms.json')) }
7+
it 'returns an array of terms' do
8+
response = double()
9+
response.stub!(:code) { "200" }
10+
response.stub!(:body) { json }
11+
12+
KMData.stub!(:path_with_params).with("/api/terms.json", {})
13+
KMData.stub!(:request).with(anything).and_return(response)
14+
KMData.get('terms').should == KMData.send(:process, JSON.parse(json))
15+
end
16+
end
17+
518
describe '.http' do
6-
subject { KMData.send(:http) }
19+
subject { KMData.instance_eval { http } }
720
it { should respond_to(:request) }
821
end
922

1023
describe '.request' do
11-
subject { KMData.send(:request, '/api/terms.json') }
24+
subject { KMData.instance_eval { request('/api/terms.json') } }
1225
before :each do
1326
response = Net::HTTPResponse.new('', '', '')
1427
Net::HTTP.any_instance.stub(:request).with(anything).and_return(response)
1528
end
1629
it { should respond_to(:body) }
1730
it { should respond_to(:code) }
1831
end
19-
20-
describe '.get' do
21-
it 'returns an array of terms' do
22-
json = File.read(File.join('spec', 'fixtures', 'terms.json'))
23-
response = double()
24-
response.stub!(:code) { "200" }
25-
response.stub!(:body) { json }
26-
27-
KMData.stub!(:path_with_params).with("/api/terms.json", {})
28-
KMData.stub!(:request).with(anything).and_return(response)
29-
KMData.get('terms').should == KMData.send(:process, JSON.parse(json))
30-
end
31-
end
3232
end

0 commit comments

Comments
 (0)