fuci-travis 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 473ae062aa685e13523dcad77521d7b7519c1579
4
- data.tar.gz: 6bea424e982e66a8232058100f4bd5be2aac0504
3
+ metadata.gz: f184101ecff65d9fe78fca05b796fff01d3e0d6e
4
+ data.tar.gz: 09b89a16374fb6f340f5979e62c2874ba2f84219
5
5
  SHA512:
6
- metadata.gz: c700f7f9263145c1e80e99b0ef98533696b94b234ddb53af44ee3c9f5fcab3a4f2a4d53c00541b851807d132d584b88bcd5fba8c25e7fe04894a114ecfa67d12
7
- data.tar.gz: 76b46d53724383366c3a854a4a937f86d2ac9d63552d0c94131d03fa12e3bb3f4f20d94b4b0457c3250e7bd4e4409fee65a7452aeb20c60df2ec1fd4dcabfe27
6
+ metadata.gz: 36492be64d384e5edee1ca0a1f0277a270646da4fea6fed1ffafa8f5e846a65360ed15d0b2fd0f3c1d795656af37670a0c13a0dcb4019cffd78544f13f444e0d
7
+ data.tar.gz: 6aead93c5384ea50a562b516166a0e4d22c126db0c4711958c389ca7bc1fea2c0b416254c0f5162537d8206168833b0c6dce2f63c699408e174f1eb2644d9bc5
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Fuci::Travis
2
2
 
3
- TODO: Write a gem description
3
+ Run Travis failures locally.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'fuci-travis'
9
+ gem 'fuci-travis', '~> 0.1'
10
10
 
11
11
  And then execute:
12
12
 
@@ -16,9 +16,112 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install fuci-travis
18
18
 
19
+ ## Configuration
20
+ ### Configuration file
21
+
22
+ To configure itself, fuci-travis looks for a file called
23
+ ".fuci-travis.rb" in your project's root directory. You should create
24
+ that file and configure fuci-travis there. The configuration must
25
+ include your Travis access token. **Therefore, you should include
26
+ ./.fuci-travis.rb in .gitignore.**
27
+
28
+ That configuration file should include a call to
29
+ `Fuci::Travis.configure` with a block that sets your access token and
30
+ other configurations.
31
+
32
+ ### Access tokens
33
+
34
+ fuci-travis ships with the
35
+ [Travis CI Client](https://github.com/travis-ci/travis) which includes
36
+ the Travis CLI. You'll use the Travis CLI to get your access token.
37
+
38
+ #### Travis for public repositories
39
+
40
+ On the command line, log into Travis via Github OAuth:
41
+ ```sh
42
+ $ travis login
43
+ ```
44
+
45
+ Then get your token:
46
+ ```sh
47
+ $ travis token
48
+ # Your access token is <access token>
49
+ ```
50
+
51
+ Configure fuci-travis with your access token as a string in
52
+ .fuci-travis.rb:
53
+ ```ruby
54
+ Fuci::Travis.configure do |fu|
55
+ fu.access_token = '<access token>'
56
+ end
57
+ ```
58
+
59
+ #### Travis for private repositories
60
+
61
+ This is the same as above, but uses the Travis CLI `--pro` flag.
62
+
63
+ On the command line, log into Travis via Github OAuth:
64
+ ```sh
65
+ $ travis login --pro
66
+ ```
67
+
68
+ Then get your token:
69
+ ```sh
70
+ $ travis token --pro
71
+ # Your access token is <access token>
72
+ ```
73
+
74
+ Then, in .fuci-travis.rb, configure fuci-travis with your access token
75
+ as a string and **set `pro` to true**:
76
+ ```ruby
77
+ Fuci::Travis.configure do |fu|
78
+ fu.pro = true
79
+ fu.access_token = '<access token>'
80
+ end
81
+ ```
82
+
83
+ ### Default branch
84
+
85
+ If you push to a dedicated ci branch to check your changes before
86
+ merging them into master, set that branch as the default in the
87
+ configuration:
88
+ ```ruby
89
+ Fuci::Travis.configure do |fu|
90
+ fu.default_branch = 'my-ci'
91
+ fu.access_token = '<access token>'
92
+ end
93
+ ```
94
+
95
+ ### Adding custom tester plugins
96
+
97
+ Fuci ships with some tester plugins. If you want to add custom testers,
98
+ add them in the configuration:
99
+ ```ruby
100
+ Fuci::Travis.configure do |fu|
101
+ fu.add_testers Fuci::Spec, Fuci::Jasmine
102
+ fu.access_token = '<access token>'
103
+ end
104
+ ```
105
+
106
+ See the base Fuci repo for more information on custom testers.
107
+
19
108
  ## Usage
20
109
 
21
- TODO: Write usage instructions here
110
+ Run your latest ci failures locally:
111
+ ```sh
112
+ $ fuci
113
+ ```
114
+ `fuci` will fetch the CI failures from the default branch declared in
115
+ your configuration. If no default branch is declared in the
116
+ configuration, `fuci` will fetch the CI failures from the branch of the
117
+ same name as your current local branch.
118
+
119
+ To run a specific branch's failures branch, call `fuci` with the branch.
120
+ For example, this will run the failures from the latest master build
121
+ on your local code:
122
+ ```sh
123
+ $ fuci master
124
+ ```
22
125
 
23
126
  ## Contributing
24
127
 
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ desc 'Run the tests'
5
+ task :default => :test
6
+
7
+ desc 'Run the tests'
8
+ Rake::TestTask.new do |t|
9
+ t.pattern = 'spec/**/*.rb'
10
+ end
data/bin/fuci ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fuci/travis'
4
+
5
+ begin
6
+ load '.fuci-travis.rb'
7
+ rescue
8
+ p 'No .fuci.rb file detected.'
9
+ end
10
+
11
+ Fuci.options[:branch] = ARGV[0]
12
+
13
+ Fuci.run
data/fuci-travis.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Fuci::Travis::VERSION
9
9
  spec.authors = ["Dave Jachimiak"]
10
10
  spec.email = ["dave.jachimiak@gmail.com"]
11
- spec.description = %q{Run failures from your last Travis build from the command line.}
12
- spec.summary = %q{Run failures from your last Travis build from the command line.}
13
- spec.homepage = ""
11
+ spec.description = %q{FUCK YOU CI: For Travis! :).}
12
+ spec.summary = %q{Run failures from your recent Travis builds locally.}
13
+ spec.homepage = "https://github.com/davejachimiak/fuci-travis"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -18,6 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency 'fuci', '~> 0.1'
22
+ spec.add_dependency 'travis', '~> 1.4'
21
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "minitest-spec-expect", "~> 0.1"
25
+ spec.add_development_dependency "mocha", "~> 0.14"
22
26
  spec.add_development_dependency "rake"
23
27
  end
@@ -0,0 +1,17 @@
1
+ require_relative '../build'
2
+
3
+ module Fuci
4
+ module Travis
5
+ class Build
6
+ class Master < Fuci::Travis::Build
7
+ def initialize; end;
8
+
9
+ def build_branch
10
+ repo.builds.detect do |build|
11
+ build.commit.sha == remote_master_sha
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,75 @@
1
+ require 'forwardable'
2
+ require 'fuci/git'
3
+ require 'fuci/travis/build/master'
4
+
5
+ module Fuci
6
+ module Travis
7
+ class Build
8
+ extend Forwardable, Fuci::Git
9
+ include Fuci::Git
10
+
11
+ FAILED = 'failed'
12
+ PASSED = 'passed'
13
+
14
+ attr_reader :branch_name
15
+ def_delegators :branch, :state, :jobs
16
+
17
+ def initialize branch_name
18
+ @branch_name = branch_name
19
+ end
20
+
21
+ def branch
22
+ @branch ||= build_branch
23
+ end
24
+
25
+ def status
26
+ case state
27
+ when FAILED
28
+ :red
29
+ when PASSED
30
+ :green
31
+ else
32
+ :yellow
33
+ end
34
+ end
35
+
36
+ def log
37
+ jobs.first.log.body
38
+ end
39
+
40
+ def self.create
41
+ branch_name =
42
+ Fuci.options[:branch] ||
43
+ Fuci::Travis.default_branch ||
44
+ current_branch_name
45
+
46
+ from_branch_name branch_name
47
+ end
48
+
49
+ def self.from_branch_name branch_name
50
+ if branch_name == 'master'
51
+ Fuci::Travis::Build::Master.new
52
+ else
53
+ new branch_name
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ def build_branch
60
+ puts "Fetching #{branch_name} branch..."
61
+ if branch = repo.branches[branch_name]
62
+ puts "Using #{branch_name} branch."
63
+ branch
64
+ else
65
+ puts "#{branch_name} branch not found on Travis."
66
+ exit
67
+ end
68
+ end
69
+
70
+ def repo
71
+ Fuci::Travis.repo
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,23 @@
1
+ require 'fuci/server'
2
+ require 'fuci/travis/build'
3
+ require 'forwardable'
4
+
5
+ module Fuci
6
+ module Travis
7
+ class Server < Fuci::Server
8
+ extend Forwardable
9
+
10
+ attr_reader :build
11
+ def_delegator :build, :status, :build_status
12
+ def_delegator :build, :log
13
+
14
+ def initialize
15
+ @build = Fuci::Travis::Build.create
16
+ end
17
+
18
+ def fetch_log
19
+ remove_ascii_color_chars log
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Fuci
2
2
  module Travis
3
- VERSION = "0.0.1"
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
data/lib/fuci/travis.rb CHANGED
@@ -1,7 +1,66 @@
1
- require "fuci/travis/version"
1
+ require 'fuci'
2
+ require 'fuci/git'
3
+ require 'fuci/configurable'
4
+ require 'fuci/travis/server'
5
+ require 'fuci/travis/version'
6
+
7
+ require 'travis'
8
+ require 'travis/pro'
9
+
10
+ require 'forwardable'
2
11
 
3
12
  module Fuci
13
+ configure do |fu|
14
+ fu.server = Fuci::Travis::Server
15
+ end
16
+
4
17
  module Travis
5
- # Your code goes here...
18
+ include Fuci::Configurable
19
+ extend Fuci::Git
20
+
21
+ DEFAULT_CLIENT = ::Travis
22
+ PRO_CLIENT = ::Travis::Pro
23
+
24
+ class << self
25
+ extend Forwardable
26
+
27
+ attr_accessor :default_branch, :access_token
28
+ attr_writer :pro
29
+ def_delegator :Fuci, :add_testers
30
+ end
31
+
32
+ def self.repo
33
+ return @repo if @repo
34
+ puts 'Finding repo...'
35
+ @repo = client::Repository.find remote_repo_name
36
+ puts "Using repo: #{remote_repo_name}"
37
+ @repo
38
+ rescue
39
+ puts "#{remote_repo_name} repo could not be found on Travis."
40
+ end
41
+
42
+ def self.pro
43
+ @pro ||= false
44
+ end
45
+
46
+ def self.configure
47
+ super
48
+ set_client
49
+ set_access_token
50
+ end
51
+
52
+ private
53
+
54
+ def self.set_client
55
+ @client = PRO_CLIENT if pro
56
+ end
57
+
58
+ def self.client
59
+ @client ||= DEFAULT_CLIENT
60
+ end
61
+
62
+ def self.set_access_token
63
+ client.access_token = access_token
64
+ end
6
65
  end
7
66
  end
@@ -0,0 +1,27 @@
1
+ require_relative '../../../../spec_helper'
2
+ require_relative '../../../../../lib/fuci/travis/build/master'
3
+
4
+ describe Fuci::Travis::Build::Master do
5
+ before do
6
+ @master = Fuci::Travis::Build::Master.new
7
+ end
8
+
9
+ describe 'composition' do
10
+ it 'inherits from ::Travis::Build' do
11
+ expect(@master).to_be_kind_of Fuci::Travis::Build
12
+ end
13
+ end
14
+
15
+ describe '#build_branch' do
16
+ it 'detects the build branch' do
17
+ Fuci::Travis.stubs(:repo).returns repo = mock
18
+
19
+ @master.stubs(:remote_master_sha).returns master_sha = '123abc'
20
+ commit = OpenStruct.new(sha: master_sha)
21
+ build = OpenStruct.new(commit: commit)
22
+ repo.stubs(:builds).returns [build]
23
+
24
+ expect(@master.build_branch).to_equal build
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,175 @@
1
+ require_relative '../../../spec_helper'
2
+ require_relative '../../../../lib/fuci/travis/build'
3
+
4
+ stub_class 'Fuci::Travis::Build::Master'
5
+
6
+ describe Fuci::Travis::Build do
7
+ describe '#initialize' do
8
+ it 'sets the branch name' do
9
+ build = Fuci::Travis::Build.new branch_name = 'name'
10
+ expect(build.branch_name).to_equal branch_name
11
+ end
12
+ end
13
+
14
+ describe '#branch' do
15
+ it 'sets a memoized branch with build_branch' do
16
+ build = Fuci::Travis::Build.new 'name'
17
+ build.stubs(:build_branch).returns branch = mock
18
+ expect(build.branch).to_equal branch
19
+ end
20
+ end
21
+
22
+ describe '#status' do
23
+ before do
24
+ Fuci::Travis::Build.any_instance.stubs(:build_branch).
25
+ returns branch = mock
26
+ @build = Fuci::Travis::Build.new ''
27
+ @state = @build.branch.stubs :state
28
+ end
29
+
30
+ describe 'when the build passed' do
31
+ it 'returns :green' do
32
+ green = :green
33
+ @state.returns 'passed'
34
+
35
+ expect(@build.status).to_equal green
36
+ end
37
+ end
38
+
39
+ describe 'when the build failed' do
40
+ it 'returns :red' do
41
+ red = :red
42
+ @state.returns 'failed'
43
+
44
+ expect(@build.status).to_equal red
45
+ end
46
+ end
47
+
48
+ describe 'when the build neither passed nor failed' do
49
+ it 'returns :yellow' do
50
+ yellow = :yellow
51
+ expect(@build.status).to_equal yellow
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#log' do
57
+ it 'returns the log body from the build' do
58
+ Fuci::Travis::Build.any_instance.
59
+ stubs(:build_branch).
60
+ returns branch = mock
61
+
62
+ build = Fuci::Travis::Build.new ''
63
+ log_body = 'brody'
64
+ log = OpenStruct.new(body: log_body)
65
+ jobs = [OpenStruct.new(log: log)]
66
+
67
+ build.branch.stubs(:jobs).returns jobs
68
+
69
+ expect(build.log).to_equal log_body
70
+ end
71
+ end
72
+
73
+ describe '.create' do
74
+ before do
75
+ @expect_from_branch_name = Fuci::Travis::Build.expects :from_branch_name
76
+ end
77
+
78
+ describe 'a branch option is declared from the command line' do
79
+ before do
80
+ @branch = 'master'
81
+ Fuci.stubs(:options).returns branch: @branch
82
+ end
83
+
84
+ it 'takes priority' do
85
+ @expect_from_branch_name.with @branch
86
+ Fuci::Travis::Build.create
87
+ end
88
+ end
89
+
90
+ describe 'a branch option is not declared from the command line' do
91
+ before { Fuci.stubs(:options).returns branch: nil }
92
+
93
+ describe 'a default branch is specfied on Fuci::Travis' do
94
+ before do
95
+ @branch = 'dj-ci'
96
+ Fuci::Travis.stubs(:default_branch).returns @branch
97
+ end
98
+
99
+ it 'creates a new ::Build with the default branch' do
100
+ @expect_from_branch_name.with @branch
101
+ Fuci::Travis::Build.create
102
+ end
103
+ end
104
+
105
+ describe 'a default branch is not specified on Fuci::Travis' do
106
+ before { Fuci::Travis.stubs(:default_branch).returns nil }
107
+
108
+ it 'creates a new ::Build with the current branch' do
109
+ Fuci::Travis::Build.
110
+ stubs(:current_branch_name).
111
+ returns branch_name = mock
112
+ @expect_from_branch_name.with branch_name
113
+ Fuci::Travis::Build.create
114
+ end
115
+ end
116
+ end
117
+ end
118
+
119
+ describe '.from_branch_name' do
120
+ describe 'the branch name is master' do
121
+ before { @branch_name = 'master' }
122
+
123
+ it 'creates a new Master build' do
124
+ Fuci::Travis::Build::Master.stubs(:new).returns master_build = mock
125
+ build = Fuci::Travis::Build.from_branch_name @branch_name
126
+ expect(build).to_equal master_build
127
+ end
128
+ end
129
+
130
+ describe 'the branch name is not master' do
131
+ before { @branch_name = 'limb' }
132
+
133
+ it 'creates a new generic build' do
134
+ Fuci::Travis::Build.stubs(:new).with(@branch_name).
135
+ returns generic_build = mock
136
+ build = Fuci::Travis::Build.from_branch_name @branch_name
137
+ expect(build).to_equal generic_build
138
+ end
139
+ end
140
+ end
141
+
142
+ describe '#build_branch' do
143
+ before do
144
+ @branch_name = 'my-ci'
145
+ @build = mock
146
+ Fuci::Travis.stubs(:repo).returns @repo = mock
147
+ @build_wrapper = Fuci::Travis::Build.new @branch_name
148
+ @build_wrapper.expects(:puts).with "Fetching #{@branch_name} branch..."
149
+ end
150
+
151
+ describe 'when the branch is found' do
152
+ before do
153
+ @repo.stubs(:branches).returns branches = { @branch_name => @build }
154
+ @build_wrapper.expects(:puts).with "Using #{@branch_name} branch."
155
+ end
156
+
157
+ it 'logs fetching and calls branch hash with the branch_name on the repo' do
158
+ expect(@build_wrapper.send :build_branch ).to_equal @build
159
+ end
160
+ end
161
+
162
+ describe 'when branch is not found' do
163
+ before do
164
+ @repo.stubs(:branches).returns branches = {}
165
+ @build_wrapper.expects(:puts).
166
+ with "#{@branch_name} branch not found on Travis."
167
+ @build_wrapper.expects :exit
168
+ end
169
+
170
+ it 'logs that the branch could not be found and exits' do
171
+ @build_wrapper.send :build_branch
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../../spec_helper'
2
+ require_relative '../../../../lib/fuci/travis/server'
3
+
4
+ describe Fuci::Travis::Server do
5
+ before do
6
+ Fuci::Travis::Build.stubs(:create).returns @build = mock
7
+ @server = Fuci::Travis::Server.new
8
+ end
9
+
10
+ describe 'composition' do
11
+ it 'inherits from Fuci::Server' do
12
+ expect(@server).to_be_kind_of Fuci::Server
13
+ end
14
+ end
15
+
16
+ describe '#initialize' do
17
+ it 'sets a build instance' do
18
+ server = Fuci::Travis::Server.new
19
+ expect(server.build).to_equal @build
20
+ end
21
+ end
22
+
23
+ describe '#build_status' do
24
+ it 'delegates to the build object' do
25
+ @server.stubs(:build).
26
+ returns OpenStruct.new status: build_status = mock
27
+
28
+ expect(@server.build_status).to_equal build_status
29
+ end
30
+ end
31
+
32
+ describe '#fetch_log' do
33
+ it 'delegates to the build object' do
34
+ @server.stubs(:build).
35
+ returns OpenStruct.new log: log = mock
36
+ @server.stubs(:remove_ascii_color_chars).
37
+ with(log).
38
+ returns sanitized_log = mock
39
+
40
+ expect(@server.fetch_log).to_equal sanitized_log
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,152 @@
1
+ require_relative '../../spec_helper'
2
+ require_relative '../../../lib/fuci/travis'
3
+
4
+ stub_class 'Travis::Repository'
5
+ stub_class 'Travis::Pro::Repository'
6
+
7
+ describe Fuci::Travis do
8
+ describe '.default_branch' do
9
+ after { Fuci::Travis.instance_variable_set :@default_branch, nil }
10
+
11
+ it 'is an accessor' do
12
+ @branch = 'branch'
13
+ expect(Fuci::Travis.default_branch).to_be_nil
14
+ Fuci::Travis.default_branch = @branch
15
+ expect(Fuci::Travis.default_branch).to_equal @branch
16
+ end
17
+ end
18
+
19
+ describe '.repo' do
20
+ after { Fuci::Travis.instance_variable_set :@repo, nil }
21
+
22
+ describe 'on initial call' do
23
+ before do
24
+ Fuci::Travis.stubs(:remote_repo_name).
25
+ returns @repo_name = 'dj/fuci'
26
+ class Client
27
+ class Repository
28
+ def self.find r
29
+ end
30
+ end
31
+ end
32
+ Fuci::Travis.stubs(:client).returns Client
33
+ Fuci::Travis.expects(:puts).with 'Finding repo...'
34
+ end
35
+
36
+ describe 'if the repo can be found' do
37
+ before do
38
+ Client::Repository.stubs(:find).
39
+ with(@repo_name).
40
+ returns @repo = mock
41
+ Fuci::Travis.expects(:puts).with "Using repo: #{@repo_name}"
42
+ end
43
+
44
+ it 'logs the query and returns the repo from ::Travis::Pro' do
45
+ expect(Fuci::Travis.repo).to_equal @repo
46
+ end
47
+ end
48
+
49
+ describe 'if the repo cannot be found' do
50
+ before do
51
+ Client::Repository.stubs(:find).raises
52
+ Fuci::Travis.expects(:puts).
53
+ with "#{@repo_name} repo could not be found on Travis."
54
+ end
55
+
56
+ it "logs that the repo couldn't be found and exits" do
57
+ Fuci::Travis.repo
58
+ end
59
+ end
60
+ end
61
+
62
+ describe 'after memoized' do
63
+ before do
64
+ @repo = mock
65
+ Fuci::Travis.instance_variable_set :@repo, @repo
66
+ end
67
+
68
+ it 'just returns the repo' do
69
+ Fuci::Travis.expects(:puts).never
70
+ expect(Fuci::Travis.repo).to_equal @repo
71
+ end
72
+ end
73
+ end
74
+
75
+ describe '.pro/=' do
76
+ after { Fuci::Travis.instance_variable_set :@pro, false }
77
+
78
+ it "is either false or what it's set to" do
79
+ expect(Fuci::Travis.pro).to_equal false
80
+ Fuci::Travis.pro = true
81
+ expect(Fuci::Travis.pro).to_equal true
82
+ end
83
+ end
84
+
85
+ describe '.access_token' do
86
+ it 'is an accessor' do
87
+ @access_token = 'access token'
88
+ expect(Fuci::Travis.access_token).to_be_nil
89
+ Fuci::Travis.access_token = @access_token
90
+ expect(Fuci::Travis.access_token).to_equal @access_token
91
+ end
92
+ end
93
+
94
+ describe '.add_testers' do
95
+ it 'delegates to Fuci module' do
96
+ testers = [mock, mock]
97
+ Fuci.expects(:add_testers).with testers
98
+
99
+ Fuci::Travis.add_testers testers
100
+ end
101
+ end
102
+
103
+ describe '.configure' do
104
+ before do
105
+ Fuci::Travis.expects(:puts).with 'configuring'
106
+ Fuci::Travis.expects :set_client
107
+ Fuci::Travis.expects :set_access_token
108
+ end
109
+
110
+ it 'yields the block with self, ' +
111
+ 'sets the client, ' +
112
+ 'and sets the access token' do
113
+ Fuci::Travis.configure do |fu|
114
+ fu.puts 'configuring'
115
+ end
116
+ end
117
+ end
118
+
119
+ describe '.set_client' do
120
+ after { Fuci::Travis.instance_variable_set :@client, nil }
121
+
122
+ describe 'when pro' do
123
+ before { Fuci::Travis.stubs(:pro).returns true }
124
+
125
+ it 'sets the travis strategy to ::Travis::Pro' do
126
+ Fuci::Travis.set_client
127
+
128
+ expect(Fuci::Travis.client).to_equal ::Travis::Pro
129
+ end
130
+ end
131
+
132
+ describe 'when not pro' do
133
+ before { Fuci::Travis.stubs(:pro).returns false }
134
+
135
+ it 'sets the travis strategy to ::Travis' do
136
+ Fuci::Travis.set_client
137
+
138
+ expect(Fuci::Travis.client).to_equal ::Travis
139
+ end
140
+ end
141
+ end
142
+
143
+ describe '.set_access_token' do
144
+ it 'sets the access token on the client' do
145
+ Fuci::Travis.stubs(:access_token).returns access_token = mock
146
+ Fuci::Travis.stubs(:client).returns client = mock
147
+ client.expects(:access_token=).with access_token
148
+
149
+ Fuci::Travis.set_access_token
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,30 @@
1
+ require 'minitest/spec/expect'
2
+ require 'minitest/autorun'
3
+ require 'mocha/setup'
4
+ require 'ostruct'
5
+
6
+ def stub_class klass
7
+ objects = klass.split '::'
8
+
9
+ klass = objects.inject(Object) do |memo, obj|
10
+ unless obj == objects.last
11
+ begin
12
+ memo.const_get obj
13
+ rescue
14
+ memo.const_set obj, Module.new
15
+ end
16
+ else
17
+ begin
18
+ memo.const_get obj
19
+ rescue
20
+ memo.const_set obj, Class.new
21
+ end
22
+ end
23
+
24
+ memo.const_get obj
25
+ end
26
+
27
+ klass.class_eval do
28
+ yield if block_given?
29
+ end
30
+ end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuci-travis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Jachimiak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-22 00:00:00.000000000 Z
11
+ date: 2013-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fuci
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: travis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +52,34 @@ dependencies:
24
52
  - - ~>
25
53
  - !ruby/object:Gem::Version
26
54
  version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-spec-expect
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.14'
27
83
  - !ruby/object:Gem::Dependency
28
84
  name: rake
29
85
  requirement: !ruby/object:Gem::Requirement
@@ -38,10 +94,11 @@ dependencies:
38
94
  - - '>='
39
95
  - !ruby/object:Gem::Version
40
96
  version: '0'
41
- description: Run failures from your last Travis build from the command line.
97
+ description: 'FUCK YOU CI: For Travis! :).'
42
98
  email:
43
99
  - dave.jachimiak@gmail.com
44
- executables: []
100
+ executables:
101
+ - fuci
45
102
  extensions: []
46
103
  extra_rdoc_files: []
47
104
  files:
@@ -50,10 +107,19 @@ files:
50
107
  - LICENSE.txt
51
108
  - README.md
52
109
  - Rakefile
110
+ - bin/fuci
53
111
  - fuci-travis.gemspec
54
112
  - lib/fuci/travis.rb
113
+ - lib/fuci/travis/build.rb
114
+ - lib/fuci/travis/build/master.rb
115
+ - lib/fuci/travis/server.rb
55
116
  - lib/fuci/travis/version.rb
56
- homepage: ''
117
+ - spec/lib/fuci/travis/build/master_spec.rb
118
+ - spec/lib/fuci/travis/build_spec.rb
119
+ - spec/lib/fuci/travis/server_spec.rb
120
+ - spec/lib/fuci/travis_spec.rb
121
+ - spec/spec_helper.rb
122
+ homepage: https://github.com/davejachimiak/fuci-travis
57
123
  licenses:
58
124
  - MIT
59
125
  metadata: {}
@@ -73,8 +139,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
139
  version: '0'
74
140
  requirements: []
75
141
  rubyforge_project:
76
- rubygems_version: 2.0.2
142
+ rubygems_version: 2.0.6
77
143
  signing_key:
78
144
  specification_version: 4
79
- summary: Run failures from your last Travis build from the command line.
80
- test_files: []
145
+ summary: Run failures from your recent Travis builds locally.
146
+ test_files:
147
+ - spec/lib/fuci/travis/build/master_spec.rb
148
+ - spec/lib/fuci/travis/build_spec.rb
149
+ - spec/lib/fuci/travis/server_spec.rb
150
+ - spec/lib/fuci/travis_spec.rb
151
+ - spec/spec_helper.rb