|
2 | 2 | require "kmdata" |
3 | 3 |
|
4 | 4 | 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 | + |
5 | 18 | describe '.http' do |
6 | | - subject { KMData.send(:http) } |
| 19 | + subject { KMData.instance_eval { http } } |
7 | 20 | it { should respond_to(:request) } |
8 | 21 | end |
9 | 22 |
|
10 | 23 | describe '.request' do |
11 | | - subject { KMData.send(:request, '/api/terms.json') } |
| 24 | + subject { KMData.instance_eval { request('/api/terms.json') } } |
12 | 25 | before :each do |
13 | 26 | response = Net::HTTPResponse.new('', '', '') |
14 | 27 | Net::HTTP.any_instance.stub(:request).with(anything).and_return(response) |
15 | 28 | end |
16 | 29 | it { should respond_to(:body) } |
17 | 30 | it { should respond_to(:code) } |
18 | 31 | 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 |
32 | 32 | end |
0 commit comments