behave 0.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/behave-0.1.gem ADDED
Binary file
data/bin/behave-cli CHANGED
File without changes
@@ -1,3 +1,3 @@
1
1
  module Behave
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
data/lib/behave.rb CHANGED
@@ -43,29 +43,39 @@ module Behave
43
43
 
44
44
  def fetch()
45
45
  path = @host + 'rest/cucumber/1.0/project/' + @key + '/features'
46
- if @user.nil? then
47
- response = RestClient::Resource.new(path, :content_type => 'application/zip')
48
- else
49
- response = RestClient::Resource.new(path, :user => @user, :password => @pass, :content_type => 'application/zip')
50
- end
51
-
46
+ args = { :content_type => 'application/zip' }
47
+ args[:user] = @user unless @user.nil?
48
+ args[:password] = @pass unless @user.nil?
49
+ resource = RestClient::Resource.new(path, :user => @user, :password => @pass, :content_type => 'application/zip')
50
+ #resource = RestClient::Resource.new(path, args)
52
51
  begin
53
- @contents = response.get(:accept => 'application/zip', :params => {:manual => @manual})
52
+ @contents = resource.get(:accept => 'application/zip', :params => {:manual => @manual})
54
53
  puts '--------------------------------------------------------------'
55
54
  puts 'Fetched file from server...'
56
55
  rescue => e
57
56
  puts '--------------------------------------------------------------'
58
- case e.response.code
59
- when 401
60
- puts 'User unauthorized (401)'
61
- when 406
62
- puts 'Behave running on server is outdated, cannot download features'
63
- puts 'Please upgrade your version of Behave for Jira and try again'
64
- when 500
65
- puts 'Jira server error (500)'
57
+ if e.respond_to?('response') then
58
+ case e.response.code
59
+ when 401
60
+ puts 'User unauthorized (401)'
61
+ puts 'Could not authenticate using supplied username and password'
62
+ when 403
63
+ puts 'User forbidden (403)'
64
+ puts 'Too many attempts with this user'
65
+ when 405
66
+ puts 'Method not Allowed (405)'
67
+ when 406
68
+ puts 'Behave running on server is outdated, cannot download features'
69
+ puts 'Please upgrade your version of Behave for Jira and try again'
70
+ when 500
71
+ puts 'Jira server error (500)'
72
+ end
73
+ puts 'Writing server response to error.log...'
74
+ File.open('error.log', 'w') {|f| f.write(e.response) }
75
+ else
76
+ puts 'Could not connect to host.'
77
+ puts e.message
66
78
  end
67
- puts 'Writing server response to error.log...'
68
- File.open('error.log', 'w') {|f| f.write(e.response) }
69
79
  puts 'ABORTING'
70
80
  puts '--------------------------------------------------------------'
71
81
  exit 1
@@ -0,0 +1,9 @@
1
+ require "rspec"
2
+ require "behave.rb"
3
+
4
+ describe "Behave Feature Downloader" do
5
+
6
+ it "should work" do
7
+ pending
8
+ end
9
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: behave
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.1"
5
+ version: "0.2"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jack Bastow
@@ -69,6 +69,7 @@ files:
69
69
  - pkg/behave-0.0.1.gem
70
70
  - target/maven-archiver/pom.properties
71
71
  - target/rubycli-1.0.0-BETA7-SNAPSHOT.jar
72
+ - tests/behaviour_spec.rb
72
73
  homepage: http://www.hindsighttesting.com
73
74
  licenses: []
74
75