communist 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,12 @@
1
- 0.2.0 (Aug , 2012)
2
- ===================
1
+ 0.3.0 (Sept 22, 2012)
2
+ =====================
3
+
4
+ * Add ability to handle json response bodies.
5
+ * Remove init signal trapping.
6
+ * Update docs with further examples.
7
+
8
+ 0.2.0 (Aug 26, 2012)
9
+ ====================
3
10
 
4
11
  * Add NullServer.
5
12
  * Add Constants.
data/README.md CHANGED
@@ -51,6 +51,22 @@ Scenario: Get blob
51
51
  Then the exit status should be 0
52
52
  ```
53
53
 
54
+ Further, by including `aruba` cucumber steps and using `sinatra` dsl you can easily describe canned responses:
55
+
56
+ ```ruby
57
+ Scenario: List watchers
58
+ Given the GitHub API server:
59
+ """
60
+ get('/repos/wycats/thor/subscribers') {
61
+ body :login => 'octokit', :id => 1,
62
+ :url => 'https://api.github.com/users/peter-murach'
63
+ status 200
64
+ }
65
+ """
66
+ When I successfully run `gcli watch ls wycats thor`
67
+ Then the stdout should contain "octokit"
68
+ ```
69
+
54
70
  ## Contributing
55
71
 
56
72
  1. Fork it
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Communist::VERSION
17
17
 
18
18
  gem.add_dependency 'rack'
19
+ gem.add_dependency 'json'
19
20
  gem.add_dependency 'sinatra'
20
21
 
21
22
  gem.add_development_dependency 'rspec'
@@ -2,7 +2,6 @@ require 'communist/server'
2
2
 
3
3
  Before do
4
4
  ENV['TEST_HOST'] = '127.0.0.1:0'
5
- puts 'RUNNING LOCALLY'
6
5
  end
7
6
 
8
7
  After do
@@ -7,6 +7,8 @@ module Communist
7
7
  def method_missing(*)
8
8
  return nil
9
9
  end
10
+
11
+ def nil?; true; end
10
12
  end
11
13
 
12
14
  end # Communist
@@ -3,6 +3,7 @@ require 'thread'
3
3
  require 'sinatra/base'
4
4
  require 'net/http'
5
5
  require 'communist'
6
+ require 'json'
6
7
 
7
8
  module Communist
8
9
  class Server
@@ -67,7 +68,6 @@ module Communist
67
68
  @server_thread = Thread.new do
68
69
  Communist.run_default_server(Identify.new(app), port) do |server|
69
70
  Communist.servers[app.object_id] = server
70
- trap "INT" do server.shutdown end
71
71
  end
72
72
  end
73
73
 
@@ -108,6 +108,13 @@ module Communist
108
108
  nil
109
109
  end
110
110
  end
111
+
112
+ after do
113
+ if !response.body.empty?
114
+ content_type :json
115
+ body JSON.generate(response.body)
116
+ end
117
+ end
111
118
  end
112
119
 
113
120
  new(app).start
@@ -1,3 +1,3 @@
1
1
  module Communist
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Communist::Server do
4
4
 
5
- let(:app) { proc { |env| [200, {}, "Hello Server!"] } }
5
+ let(:app) { proc { |env| [200, {'Content-Length' => '13'}, "Hello Server!"] } }
6
6
 
7
7
  context 'initialization' do
8
8
  it 'sets application' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: communist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-26 00:00:00.000000000 Z
12
+ date: 2012-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &2152389520 !ruby/object:Gem::Requirement
16
+ requirement: &2151864960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152389520
24
+ version_requirements: *2151864960
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &2151863860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2151863860
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: sinatra
27
- requirement: &2152389080 !ruby/object:Gem::Requirement
38
+ requirement: &2151863020 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: '0'
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *2152389080
46
+ version_requirements: *2151863020
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rspec
38
- requirement: &2152388600 !ruby/object:Gem::Requirement
49
+ requirement: &2151862380 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *2152388600
57
+ version_requirements: *2151862380
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rake
49
- requirement: &2152388160 !ruby/object:Gem::Requirement
60
+ requirement: &2151861760 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,7 +65,7 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *2152388160
68
+ version_requirements: *2151861760
58
69
  description: Library for mocking CLI calls to external APIs
59
70
  email:
60
71
  - ''