belly 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
data/belly.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{belly}
8
- s.version = "0.3.4"
8
+ s.version = "0.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Wynne"]
@@ -40,15 +40,15 @@ Gem::Specification.new do |s|
40
40
  "lib/belly.rb",
41
41
  "lib/belly/cli.rb",
42
42
  "lib/belly/cli/init.rb",
43
- "lib/belly/cli/rerun_cucumber.rb",
43
+ "lib/belly/cli/rerun.rb",
44
44
  "lib/belly/client.rb",
45
45
  "lib/belly/client/config.rb",
46
46
  "lib/belly/client/default_config.rb",
47
47
  "lib/belly/client/fakeweb_hack.rb",
48
48
  "lib/belly/client/hub_proxy.rb",
49
- "lib/belly/cucumber_rerun.rb",
50
49
  "lib/belly/for/cucumber.rb",
51
50
  "lib/belly/messages/cucumber_scenario_result_message.rb",
51
+ "lib/belly/rerun.rb",
52
52
  "spec/belly/project_initializer_spec.rb",
53
53
  "spec/spec_helper.rb"
54
54
  ]
data/bin/belly CHANGED
@@ -11,7 +11,7 @@ Trollop::options do
11
11
  === Commands
12
12
 
13
13
  init Initialize this project for use with Belly
14
- rerun:cucumber Show Cucumber scenarios that need to be re-run
14
+ rerun Show tests that need to be re-run
15
15
  help <command> Get some help on a particular command
16
16
 
17
17
  EOS
@@ -1,5 +1,8 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+
2
3
  require 'aruba'
4
+ bin_dir = File.expand_path(File.dirname(__FILE__) + '/../../bin/')
5
+ ENV["PATH"] = bin_dir + ":" + ENV["PATH"]
3
6
 
4
7
  require 'spec/expectations'
5
8
 
@@ -18,10 +18,6 @@ module Belly
18
18
  @requests ||= []
19
19
  end
20
20
 
21
- def add(data)
22
- all << data
23
- end
24
-
25
21
  def clear!
26
22
  @requests = []
27
23
  end
@@ -34,16 +30,11 @@ module Belly
34
30
  end
35
31
 
36
32
  post '*' do
37
- # For some reason env["PATH_INFO"] is blank, so we do this instead
38
- host = request.env["HTTP_HOST"]
39
- uri = request.env["REQUEST_URI"]
40
- path = uri.match(/#{host}(.*)/).captures[0]
41
-
42
- Requests.add({
43
- 'type' => request.env['REQUEST_METHOD'],
44
- 'path' => path,
45
- 'data' => request.body.read }
46
- )
33
+ Requests.all << {
34
+ 'type' => env['REQUEST_METHOD'],
35
+ 'path' => env["PATH_INFO"],
36
+ 'data' => request.body.read
37
+ }
47
38
  ''
48
39
  end
49
40
  end
data/lib/belly/cli.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Belly
2
2
  module Cli
3
- COMMANDS = %w(init rerun:cucumber)
3
+ COMMANDS = %w(init rerun)
4
4
  end
5
5
  end
@@ -0,0 +1,15 @@
1
+ require 'belly/rerun'
2
+
3
+ options = Trollop::options do
4
+ banner <<-EOF
5
+ This is the help for the rerun command. To see all commands availlable, type belly --help
6
+
7
+ Usage: belly rerun
8
+
9
+ Show the Cucumber scenarios that need to be rerun
10
+
11
+ EOF
12
+ opt :name, "Name of the project", :default => File.basename(Dir.pwd)
13
+ end
14
+
15
+ Belly::Rerun.new(options).run(Trollop)
@@ -1,5 +1,4 @@
1
- require 'net/http'
2
- require 'uri'
1
+ require 'rest_client'
3
2
 
4
3
  module Belly::Client
5
4
  class HubProxy
@@ -7,24 +6,50 @@ module Belly::Client
7
6
  @config = config
8
7
  end
9
8
 
10
- def post_test_result(data)
11
- request = Net::HTTP::Post.new(@config.url + '/test_results', {'Content-Type' =>'application/json'})
12
- request.body = data
13
- response = Net::HTTP.new(@config.host, @config.port).start do |http|
14
- if @around_request_block
15
- block = Proc.new { http.request(request) }
16
- @around_request_block.call(block)
17
- else
18
- http.request(request)
19
- end
20
- end
21
- unless response.code == "200"
22
- raise("Failed to talk to belly hub: Response #{response.code} #{response.message}: #{response.body}")
23
- end
9
+ def post_test_result(json_data)
10
+ request(:post, '/test_results', json_data, :content_type => :json)
11
+ end
12
+
13
+ def get_failing_scenarios_for_project_named(project_name)
14
+ project_id = get_project_id_by_name(project_name)
15
+ response = request(:get, "/projects/#{project_id}/cucumber_scenarios.json?status=failed")
16
+ JSON.parse(response)["cucumber_scenarios"]
17
+ end
18
+
19
+ def get_project_id_by_name(project_name)
20
+ response = request(:get, "/projects.json?name=#{project_name}")
21
+ projects = JSON.parse(response)["projects"]
22
+ raise("Couldn't find a project named #{project_name}") unless projects.any?
23
+ projects.first["id"].to_i
24
24
  end
25
25
 
26
26
  def around_request(&block)
27
27
  @around_request_block = block
28
28
  end
29
+
30
+ private
31
+
32
+ def request(method, path, data = nil, options = nil)
33
+ url = @config.url + path
34
+ args = [url]
35
+ args << data if data
36
+ args << options if options
37
+ Belly.log("Sending #{method} request to #{url}")
38
+ request_block = lambda { RestClient.send(method, *args) }
39
+
40
+ response = if @around_request_block
41
+ @around_request_block.call(request_block)
42
+ else
43
+ request_block.call
44
+ end
45
+
46
+ unless response.code == 200
47
+ raise("Failed to talk to belly hub: Response #{response.code} #{response.message}: #{response.body}")
48
+ end
49
+
50
+ Belly.log("response: #{response}")
51
+
52
+ response
53
+ end
29
54
  end
30
55
  end
@@ -0,0 +1,13 @@
1
+ module Belly
2
+ class Rerun
3
+ def initialize(options)
4
+
5
+ end
6
+
7
+ def run(ui)
8
+ Belly.hub.get_failing_scenarios_for_project_named(Belly.config.project).each do |scenario|
9
+ puts "#{scenario["file_name"]}:#{scenario["line_number"]}"
10
+ end
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Wynne
@@ -77,15 +77,15 @@ files:
77
77
  - lib/belly.rb
78
78
  - lib/belly/cli.rb
79
79
  - lib/belly/cli/init.rb
80
- - lib/belly/cli/rerun_cucumber.rb
80
+ - lib/belly/cli/rerun.rb
81
81
  - lib/belly/client.rb
82
82
  - lib/belly/client/config.rb
83
83
  - lib/belly/client/default_config.rb
84
84
  - lib/belly/client/fakeweb_hack.rb
85
85
  - lib/belly/client/hub_proxy.rb
86
- - lib/belly/cucumber_rerun.rb
87
86
  - lib/belly/for/cucumber.rb
88
87
  - lib/belly/messages/cucumber_scenario_result_message.rb
88
+ - lib/belly/rerun.rb
89
89
  - spec/belly/project_initializer_spec.rb
90
90
  - spec/spec_helper.rb
91
91
  has_rdoc: true
@@ -1,15 +0,0 @@
1
- require 'belly/cucumber_rerun'
2
-
3
- options = Trollop::options do
4
- banner <<-EOF
5
- This is the help for the rerun:cucumber command. To see all commands availlable, type belly --help
6
-
7
- Usage: belly rerun:cucumber
8
-
9
- Show the Cucumber scenarios that need to be rerun
10
-
11
- EOF
12
- opt :name, "Name of the project", :default => File.basename(Dir.pwd)
13
- end
14
-
15
- Belly::CucumberRerun.new(options).run(Trollop)
@@ -1,11 +0,0 @@
1
- module Belly
2
- class CucumberRerun
3
- def initialize(options)
4
-
5
- end
6
-
7
- def run(ui)
8
- ui.die("I lied. I have no idea how to do this yet, sorry")
9
- end
10
- end
11
- end