txgh 6.8.1 → 7.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/txgh/config/config_pair.rb +12 -4
  3. data/lib/txgh/config/key_manager.rb +4 -6
  4. data/lib/txgh/config/providers/git_provider.rb +5 -7
  5. data/lib/txgh/config/providers/github_provider.rb +16 -0
  6. data/lib/txgh/config/providers/gitlab_provider.rb +16 -0
  7. data/lib/txgh/config/providers.rb +5 -3
  8. data/lib/txgh/config/tx_manager.rb +2 -2
  9. data/lib/txgh/git_api.rb +85 -0
  10. data/lib/txgh/git_repo.rb +90 -0
  11. data/lib/txgh/git_status.rb +151 -0
  12. data/lib/txgh/github_api.rb +1 -13
  13. data/lib/txgh/github_repo.rb +1 -89
  14. data/lib/txgh/github_status.rb +1 -148
  15. data/lib/txgh/gitlab_api.rb +63 -0
  16. data/lib/txgh/gitlab_repo.rb +4 -0
  17. data/lib/txgh/gitlab_status.rb +4 -0
  18. data/lib/txgh/version.rb +1 -1
  19. data/lib/txgh.rb +10 -3
  20. data/spec/category_support_spec.rb +6 -8
  21. data/spec/config/config_pair_spec.rb +41 -16
  22. data/spec/config/key_manager_spec.rb +30 -17
  23. data/spec/config/provider_instance_spec.rb +3 -6
  24. data/spec/config/provider_support_spec.rb +2 -5
  25. data/spec/config/tx_config_spec.rb +2 -4
  26. data/spec/config/tx_manager_spec.rb +8 -11
  27. data/spec/diff_calculator_spec.rb +2 -4
  28. data/spec/events_spec.rb +2 -4
  29. data/spec/github_api_spec.rb +2 -4
  30. data/spec/github_repo_spec.rb +10 -16
  31. data/spec/github_status_spec.rb +5 -7
  32. data/spec/gitlab_api_spec.rb +112 -0
  33. data/spec/gitlab_repo_spec.rb +172 -0
  34. data/spec/gitlab_status_spec.rb +93 -0
  35. data/spec/helpers/standard_txgh_setup.rb +32 -6
  36. data/spec/merge_calculator_spec.rb +4 -6
  37. data/spec/parse_config_spec.rb +3 -5
  38. data/spec/resource_committer_spec.rb +3 -5
  39. data/spec/resource_contents_spec.rb +8 -10
  40. data/spec/resource_deleter_spec.rb +3 -5
  41. data/spec/resource_downloader_spec.rb +2 -4
  42. data/spec/resource_updater_spec.rb +3 -5
  43. data/spec/transifex_api_spec.rb +2 -4
  44. data/spec/tx_branch_resource_spec.rb +10 -12
  45. data/spec/tx_resource_spec.rb +2 -4
  46. data/spec/utils_spec.rb +22 -24
  47. data/txgh.gemspec +1 -1
  48. metadata +29 -4
@@ -1,151 +1,4 @@
1
- require 'celluloid/current'
2
-
3
1
  module Txgh
4
- class GithubStatus
5
- class State
6
- PENDING = 'pending'
7
- SUCCESS = 'success'
8
- ERROR = 'error'
9
- FAILURE = 'failure'
10
-
11
- class << self
12
- def pending; PENDING; end
13
- def success; SUCCESS; end
14
- def error; ERROR; end
15
- def failure; failure; end
16
- end
17
- end
18
-
19
- ALL_COMPLETE_DESCRIPTION = "Translations complete!"
20
- TARGET_URL_TEMPLATE = "https://www.transifex.com/%{organization}/%{project_slug}/content"
21
- DESCRIPTION_TEMPLATE = "%{complete}/%{total} translations complete."
22
- CONTEXT = 'continuous-localization/txgh'
23
-
24
- class << self
25
- def update(project, repo, branch)
26
- new(project, repo, branch).update
27
- end
28
-
29
- def error(project, repo, branch, options = {})
30
- new(project, repo, branch).error(options)
31
- end
32
- end
33
-
34
- attr_reader :project, :repo, :branch
35
-
36
- def initialize(project, repo, branch)
37
- @project = project
38
- @repo = repo
39
- @branch = branch
40
- end
41
-
42
- def update
43
- return if tx_resources.empty?
44
-
45
- repo.api.create_status(
46
- sha, state, {
47
- context: context, target_url: target_url, description: description
48
- }
49
- )
50
- end
51
-
52
- def error(options = {})
53
- repo.api.create_status(
54
- sha, State.error, {
55
- context: context,
56
- target_url: options.fetch(:target_url),
57
- description: options.fetch(:description)
58
- }
59
- )
60
- end
61
-
62
- private
63
-
64
- def sha
65
- ref[:object][:sha]
66
- end
67
-
68
- def ref
69
- @ref ||= repo.api.get_ref(branch)
70
- end
71
-
72
- def context
73
- CONTEXT
74
- end
75
-
76
- def target_url
77
- # assume all resources are from the same project
78
- TARGET_URL_TEMPLATE % {
79
- organization: project.organization,
80
- project_slug: tx_resources.first.project_slug
81
- }
82
- end
83
-
84
- def state
85
- if all_complete?
86
- State.success
87
- else
88
- State.pending
89
- end
90
- end
91
-
92
- def description
93
- if all_complete?
94
- ALL_COMPLETE_DESCRIPTION
95
- else
96
- DESCRIPTION_TEMPLATE % stat_totals
97
- end
98
- end
99
-
100
- def all_complete?
101
- stats.all? do |resource_stats|
102
- resource_stats.all? do |locale, details|
103
- details['completed'] == '100%'
104
- end
105
- end
106
- end
107
-
108
- def stat_totals
109
- @stat_totals ||= { complete: 0, total: 0 }.tap do |counts|
110
- stats.each do |resource_stats|
111
- resource_stats.each_pair do |locale, details|
112
- counts[:total] += details['translated_entities'] + details['untranslated_entities']
113
- counts[:complete] += details['translated_entities']
114
- end
115
- end
116
- end
117
- end
118
-
119
- def stats
120
- @stats ||= tx_resources.map do |tx_resource|
121
- Celluloid::Future.new { project.api.get_stats(*tx_resource.slugs) }
122
- end.map(&:value)
123
- end
124
-
125
- def tx_resources
126
- @tx_resources ||=
127
- tx_config.resources.each_with_object([]) do |tx_resource, ret|
128
- if repo.process_all_branches?
129
- tx_resource = Txgh::TxBranchResource.new(tx_resource, branch)
130
- end
131
-
132
- next unless existing_slugs.include?(tx_resource.resource_slug)
133
- ret << tx_resource
134
- end
135
- end
136
-
137
- def existing_slugs
138
- @existing_slugs ||= existing_resources.map do |resource|
139
- resource['slug']
140
- end
141
- end
142
-
143
- def existing_resources
144
- @existing_resources ||= project.api.get_resources(project.name)
145
- end
146
-
147
- def tx_config
148
- @tx_config ||= Txgh::Config::TxManager.tx_config(project, repo, branch)
149
- end
2
+ class GithubStatus < GitStatus
150
3
  end
151
4
  end
@@ -0,0 +1,63 @@
1
+ require 'gitlab'
2
+
3
+ module Txgh
4
+ class GitlabApi < GitApi
5
+ class << self
6
+ def create_from_credentials(_login, access_token, repo_name)
7
+ Gitlab.endpoint = 'https://gitlab.com/api/v4'
8
+ create_from_client(
9
+ Gitlab.client(private_token: access_token),
10
+ repo_name
11
+ )
12
+ end
13
+ end
14
+
15
+ def update_contents(branch, content_list, message)
16
+ content_list.each do |file_params|
17
+ path = file_params.fetch(:path)
18
+ new_contents = file_params.fetch(:contents)
19
+ branch = Utils.relative_branch(branch)
20
+
21
+ file_sha = file_params.fetch(:sha) do
22
+ begin
23
+ client.get_file(repo_name, path, branch).content_sha256
24
+ rescue ::Gitlab::Error::NotFound
25
+ nil
26
+ end
27
+ end
28
+
29
+ # If the file doesnt exist, then it isn't tracked by git and file_sha
30
+ # will be nil. In git land, a SHA of all zeroes means create a new file
31
+ # instead of updating an existing one.
32
+ current_sha = file_sha || '0' * 40
33
+ new_sha = Utils.git_hash_blob(new_contents)
34
+
35
+ if current_sha != new_sha
36
+ client.edit_file(repo_name, path, branch, new_contents, message)
37
+ end
38
+ end
39
+ end
40
+
41
+ def get_ref(ref)
42
+ # mock github response
43
+ {
44
+ object: {
45
+ sha: client.commit(repo_name, ref.gsub('heads/', '')).short_id
46
+ }
47
+ }
48
+ end
49
+
50
+ def download(path, branch)
51
+ file = client.get_file(repo_name, path, branch.gsub('heads/', ''))
52
+
53
+ # mock github response
54
+ {
55
+ content: file.encoding == 'base64' ? Base64.decode64(file.content) : file.content.force_encoding(file.encoding)
56
+ }
57
+ end
58
+
59
+ def create_status(sha, state, options = {})
60
+ client.update_commit_status(repo_name, sha, state, options)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,4 @@
1
+ module Txgh
2
+ class GitlabRepo < Txgh::GitRepo
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Txgh
2
+ class GitlabStatus < Txgh::GitStatus
3
+ end
4
+ end
data/lib/txgh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '6.8.1'
2
+ VERSION = '7.0.0.beta'
3
3
  end
data/lib/txgh.rb CHANGED
@@ -7,9 +7,15 @@ module Txgh
7
7
  autoload :DiffCalculator, 'txgh/diff_calculator'
8
8
  autoload :EmptyResourceContents, 'txgh/empty_resource_contents'
9
9
  autoload :Events, 'txgh/events'
10
+ autoload :GitApi, 'txgh/git_api'
10
11
  autoload :GithubApi, 'txgh/github_api'
12
+ autoload :GitlabApi, 'txgh/gitlab_api'
13
+ autoload :GitRepo, 'txgh/git_repo'
11
14
  autoload :GithubRepo, 'txgh/github_repo'
15
+ autoload :GitlabRepo, 'txgh/gitlab_repo'
16
+ autoload :GitStatus, 'txgh/git_status'
12
17
  autoload :GithubStatus, 'txgh/github_status'
18
+ autoload :GitlabStatus, 'txgh/gitlab_status'
13
19
  autoload :MergeCalculator, 'txgh/merge_calculator'
14
20
  autoload :ParseConfig, 'txgh/parse_config'
15
21
  autoload :Puller, 'txgh/puller'
@@ -51,9 +57,10 @@ module Txgh
51
57
  end
52
58
 
53
59
  # default set of tx config providers
54
- tx_manager.register_provider(providers::FileProvider, Txgh::Config::TxConfig)
55
- tx_manager.register_provider(providers::GitProvider, Txgh::Config::TxConfig)
56
- tx_manager.register_provider(providers::RawProvider, Txgh::Config::TxConfig, default: true)
60
+ tx_manager.register_provider(providers::FileProvider, Txgh::Config::TxConfig)
61
+ tx_manager.register_provider(providers::GithubProvider, Txgh::Config::TxConfig)
62
+ tx_manager.register_provider(providers::GitlabProvider, Txgh::Config::TxConfig)
63
+ tx_manager.register_provider(providers::RawProvider, Txgh::Config::TxConfig, default: true)
57
64
 
58
65
  # default set of base config providers
59
66
  key_manager.register_provider(providers::FileProvider, YAML)
@@ -1,18 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- include Txgh
4
-
5
- describe CategorySupport do
3
+ describe Txgh::CategorySupport do
6
4
  describe '.deserialize_categories' do
7
5
  it 'converts an array of categories into a hash' do
8
6
  categories = %w(captain:janeway commander:chakotay)
9
- result = CategorySupport.deserialize_categories(categories)
7
+ result = described_class.deserialize_categories(categories)
10
8
  expect(result).to eq('captain' => 'janeway', 'commander' => 'chakotay')
11
9
  end
12
10
 
13
11
  it 'converts an array of space-separated categories' do
14
12
  categories = ['captain:janeway commander:chakotay']
15
- result = CategorySupport.deserialize_categories(categories)
13
+ result = described_class.deserialize_categories(categories)
16
14
  expect(result).to eq('captain' => 'janeway', 'commander' => 'chakotay')
17
15
  end
18
16
  end
@@ -20,14 +18,14 @@ describe CategorySupport do
20
18
  describe '.serialize_categories' do
21
19
  it 'converts a hash of categories into an array' do
22
20
  categories = { 'captain' => 'janeway', 'commander' => 'chakotay' }
23
- result = CategorySupport.serialize_categories(categories)
21
+ result = described_class.serialize_categories(categories)
24
22
  expect(result.sort).to eq(['captain:janeway', 'commander:chakotay'])
25
23
  end
26
24
  end
27
25
 
28
26
  describe '.escape_category' do
29
27
  it 'replaces spaces in category values' do
30
- expect(CategorySupport.escape_category('Katherine Janeway')).to(
28
+ expect(described_class.escape_category('Katherine Janeway')).to(
31
29
  eq('Katherine_Janeway')
32
30
  )
33
31
  end
@@ -35,7 +33,7 @@ describe CategorySupport do
35
33
 
36
34
  describe '.join_categories' do
37
35
  it 'joins an array of categories by spaces' do
38
- expect(CategorySupport.join_categories(%w(foo:bar baz:boo))).to(
36
+ expect(described_class.join_categories(%w(foo:bar baz:boo))).to(
39
37
  eq('foo:bar baz:boo')
40
38
  )
41
39
  end
@@ -1,28 +1,41 @@
1
1
  require 'spec_helper'
2
2
  require 'helpers/standard_txgh_setup'
3
3
 
4
- include Txgh::Config
5
-
6
- describe ConfigPair do
4
+ describe Txgh::Config::ConfigPair do
7
5
  include StandardTxghSetup
8
6
 
9
7
  let(:config) do
10
- ConfigPair.new(project_config, repo_config)
8
+ described_class.new(project_config, github_config)
11
9
  end
12
10
 
13
- describe '#github_repo' do
14
- it 'instantiates a github repo with the right config' do
15
- repo = config.github_repo
16
- expect(repo).to be_a(GithubRepo)
17
- expect(repo.name).to eq(repo_name)
18
- expect(repo.branch).to eq(branch)
11
+ describe '#git_repo' do
12
+ context 'Github' do
13
+ it 'instantiates a github repo with the right config' do
14
+ repo = config.git_repo
15
+ expect(repo).to be_a(Txgh::GithubRepo)
16
+ expect(repo.name).to eq(github_repo_name)
17
+ expect(repo.branch).to eq(branch)
18
+ end
19
+ end
20
+
21
+ context 'Gitlab' do
22
+ let(:config) do
23
+ described_class.new(project_config, gitlab_config)
24
+ end
25
+
26
+ it 'instantiates a github repo with the right config' do
27
+ repo = config.git_repo
28
+ expect(repo).to be_a(Txgh::GitlabRepo)
29
+ expect(repo.name).to eq(gitlab_repo_name)
30
+ expect(repo.branch).to eq(branch)
31
+ end
19
32
  end
20
33
  end
21
34
 
22
35
  describe '#transifex_project' do
23
36
  it 'instantiates a transifex project with the right config' do
24
37
  project = config.transifex_project
25
- expect(project).to be_a(TransifexProject)
38
+ expect(project).to be_a(Txgh::TransifexProject)
26
39
  expect(project.name).to eq(project_name)
27
40
  expect(tx_config.resources.first.resource_slug).to eq(resource_slug)
28
41
  end
@@ -31,17 +44,29 @@ describe ConfigPair do
31
44
  describe '#transifex_api' do
32
45
  it 'instantiates an API instance' do
33
46
  api = config.transifex_api
34
- expect(api).to be_a(TransifexApi)
47
+ expect(api).to be_a(Txgh::TransifexApi)
35
48
  expect(api.connection.headers).to include('Authorization')
36
49
  end
37
50
  end
38
51
 
39
52
  describe '#github_api' do
40
- it 'instantiates an API instance' do
53
+ it 'instantiates a github API instance' do
41
54
  api = config.github_api
42
- expect(api).to be_a(GithubApi)
43
- expect(api.client.login).to eq(repo_config['api_username'])
44
- expect(api.client.access_token).to eq(repo_config['api_token'])
55
+ expect(api).to be_a(Txgh::GithubApi)
56
+ expect(api.client.login).to eq(github_config['api_username'])
57
+ expect(api.client.access_token).to eq(github_config['api_token'])
58
+ end
59
+ end
60
+
61
+ describe '#gitlab_api' do
62
+ let(:config) do
63
+ described_class.new(project_config, gitlab_config)
64
+ end
65
+
66
+ it 'instantiates a gitlab API instance' do
67
+ api = config.gitlab_api
68
+ expect(api).to be_a(Txgh::GitlabApi)
69
+ expect(api.client.private_token).to eq(gitlab_config['api_token'])
45
70
  end
46
71
  end
47
72
  end
@@ -13,10 +13,22 @@ describe KeyManager do
13
13
  expect(config).to be_a(Txgh::Config)
14
14
  end
15
15
 
16
- it 'creates a config object that contains both project and repo configs' do
17
- config = KeyManager.config_from_project(project_name)
18
- expect(config.project_config).to eq(project_config)
19
- expect(config.repo_config).to eq(repo_config)
16
+ context 'Github' do
17
+ it 'creates a config object that contains both project and repo configs' do
18
+ config = KeyManager.config_from_project(project_name)
19
+ expect(config.project_config).to eq(project_config)
20
+ expect(config.repo_config).to eq(github_config)
21
+ end
22
+ end
23
+
24
+ context 'Gitlab' do
25
+ let(:push_translations_to) { gitlab_repo_name }
26
+
27
+ it 'creates a config object that contains both project and repo configs' do
28
+ config = KeyManager.config_from_project(project_name)
29
+ expect(config.project_config).to eq(project_config)
30
+ expect(config.repo_config).to eq(gitlab_config)
31
+ end
20
32
  end
21
33
 
22
34
  it "raises an error if config can't be found" do
@@ -39,14 +51,21 @@ describe KeyManager do
39
51
 
40
52
  describe '.config_from_repo' do
41
53
  it 'creates a config object' do
42
- config = KeyManager.config_from_repo(repo_name)
54
+ config = KeyManager.config_from_repo(github_repo_name)
55
+ expect(config).to be_a(Txgh::Config)
56
+
57
+ config = KeyManager.config_from_repo(gitlab_repo_name)
43
58
  expect(config).to be_a(Txgh::Config)
44
59
  end
45
60
 
46
61
  it 'creates a config object that contains both project and repo configs' do
47
- config = KeyManager.config_from_repo(repo_name)
62
+ config = KeyManager.config_from_repo(github_repo_name)
63
+ expect(config.project_config).to eq(project_config)
64
+ expect(config.repo_config).to eq(github_config)
65
+
66
+ config = KeyManager.config_from_repo(gitlab_repo_name)
48
67
  expect(config.project_config).to eq(project_config)
49
- expect(config.repo_config).to eq(repo_config)
68
+ expect(config.repo_config).to eq(gitlab_config)
50
69
  end
51
70
 
52
71
  it "raises an error if config can't be found" do
@@ -61,7 +80,7 @@ describe KeyManager do
61
80
  receive(:raw_config).and_return(YAML.dump(base_config))
62
81
  )
63
82
 
64
- expect { KeyManager.config_from_repo(repo_name) }.to(
83
+ expect { KeyManager.config_from_repo(github_repo_name) }.to(
65
84
  raise_error(InvalidProviderError)
66
85
  )
67
86
  end
@@ -69,14 +88,14 @@ describe KeyManager do
69
88
 
70
89
  describe '.config_from' do
71
90
  it 'creates a config object' do
72
- config = KeyManager.config_from(project_name, repo_name)
91
+ config = KeyManager.config_from(project_name, github_repo_name)
73
92
  expect(config).to be_a(Txgh::Config)
74
93
  end
75
94
 
76
95
  it 'creates a config object that contains both project and repo configs' do
77
- config = KeyManager.config_from(project_name, repo_name)
96
+ config = KeyManager.config_from(project_name, github_repo_name)
78
97
  expect(config.project_config).to eq(project_config)
79
- expect(config.repo_config).to eq(repo_config)
98
+ expect(config.repo_config).to eq(github_config)
80
99
  end
81
100
  end
82
101
 
@@ -85,10 +104,4 @@ describe KeyManager do
85
104
  expect(KeyManager.project_names).to eq([project_name])
86
105
  end
87
106
  end
88
-
89
- describe '#repo_names' do
90
- it "gets an array of all the configured repo's names" do
91
- expect(KeyManager.repo_names).to eq([repo_name])
92
- end
93
- end
94
107
  end
@@ -1,15 +1,12 @@
1
1
  require 'spec_helper'
2
2
  require 'helpers/test_provider'
3
3
 
4
- include Txgh
5
- include Txgh::Config
6
-
7
- describe ProviderInstance do
4
+ describe Txgh::Config::ProviderInstance do
8
5
  let(:provider) { TestProvider }
9
6
  let(:payload) { :fake_payload }
10
7
  let(:parser) { :fake_parser }
11
8
  let(:options) { :fake_options }
12
- let(:instance) { ProviderInstance.new(provider, parser) }
9
+ let(:instance) { described_class.new(provider, parser) }
13
10
 
14
11
  describe '#supports?' do
15
12
  it 'returns true if the scheme matches' do
@@ -27,7 +24,7 @@ describe ProviderInstance do
27
24
  end
28
25
 
29
26
  context 'with a default provider' do
30
- let(:instance) { ProviderInstance.new(provider, parser, default: true) }
27
+ let(:instance) { described_class.new(provider, parser, default: true) }
31
28
 
32
29
  it 'returns true if marked as the default provider' do
33
30
  expect(instance).to be_default
@@ -1,12 +1,9 @@
1
1
  require 'spec_helper'
2
2
  require 'helpers/test_provider'
3
3
 
4
- include Txgh
5
- include Txgh::Config
6
-
7
- describe ProviderSupport do
4
+ describe Txgh::Config::ProviderSupport do
8
5
  let(:klass) do
9
- Class.new { extend ProviderSupport }
6
+ Class.new { extend Txgh::Config::ProviderSupport }
10
7
  end
11
8
 
12
9
  let(:provider) { TestProvider }
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'helpers/standard_txgh_setup'
3
3
 
4
- include Txgh::Config
5
-
6
- describe TxConfig do
4
+ describe Txgh::Config::TxConfig do
7
5
  include StandardTxghSetup
8
6
 
9
7
  describe '.load' do
@@ -20,7 +18,7 @@ describe TxConfig do
20
18
  type = PO
21
19
  """
22
20
 
23
- config = TxConfig.load(config_str)
21
+ config = described_class.load(config_str)
24
22
  expect(config.lang_map).to eq('pt-BR' => 'pt', 'ko-KR' => 'ko')
25
23
  expect(config.resources.size).to eq(1)
26
24
 
@@ -1,22 +1,19 @@
1
1
  require 'spec_helper'
2
2
  require 'helpers/standard_txgh_setup'
3
3
 
4
- include Txgh
5
- include Txgh::Config
6
-
7
- describe TxManager do
4
+ describe Txgh::Config::TxManager do
8
5
  include StandardTxghSetup
9
6
 
10
7
  describe '.tx_config' do
11
- let(:config) { KeyManager.config_from(project_name, repo_name) }
8
+ let(:config) { KeyManager.config_from(project_name, github_repo_name) }
12
9
  let(:project) { config.transifex_project }
13
- let(:repo) { config.github_repo }
10
+ let(:repo) { config.git_repo }
14
11
 
15
12
  it 'loads tx config from the given file' do
16
13
  path = 'file://path/to/tx_config'
17
14
  project_config.merge!('tx_config' => path)
18
15
  expect(File).to receive(:read).with('path/to/tx_config').and_return('{}')
19
- config = TxManager.tx_config(project, repo)
16
+ config = described_class.tx_config(project, repo)
20
17
  expect(config).to be_a(TxConfig)
21
18
  end
22
19
 
@@ -26,12 +23,12 @@ describe TxManager do
26
23
  end
27
24
 
28
25
  it 'raises an error if asked to load config from a git repository and no ref is given' do
29
- expect { TxManager.tx_config(project, repo) }.to raise_error(TxghError)
26
+ expect { described_class.tx_config(project, repo) }.to raise_error(TxghError)
30
27
  end
31
28
 
32
29
  it "raises an error if the git repo doesn't contain the requested config file" do
33
30
  expect(repo.api).to receive(:download).and_raise(Octokit::NotFound)
34
- expect { TxManager.tx_config(project, repo, 'my_branch') }.to(
31
+ expect { described_class.tx_config(project, repo, 'my_branch') }.to(
35
32
  raise_error(GitConfigNotFoundError)
36
33
  )
37
34
  end
@@ -43,14 +40,14 @@ describe TxManager do
43
40
  .and_return(content: "[main]\nlang_map = ko:ko_KR")
44
41
  )
45
42
 
46
- config = TxManager.tx_config(project, repo, 'my_branch')
43
+ config = described_class.tx_config(project, repo, 'my_branch')
47
44
  expect(config.lang_map).to eq({ 'ko' => 'ko_KR' })
48
45
  end
49
46
  end
50
47
 
51
48
  it 'loads raw tx config' do
52
49
  project_config.merge!('tx_config' => "raw://[main]\nlang_map = ko:ko_KR")
53
- config = TxManager.tx_config(project, repo)
50
+ config = described_class.tx_config(project, repo)
54
51
  expect(config.lang_map).to eq({ 'ko' => 'ko_KR' })
55
52
  end
56
53
  end
@@ -1,15 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- include Txgh
4
-
5
- describe DiffCalculator do
3
+ describe Txgh::DiffCalculator do
6
4
  def phrase(key, string)
7
5
  { 'key' => key, 'string' => string }
8
6
  end
9
7
 
10
8
  describe '.compare' do
11
9
  let(:diff) do
12
- DiffCalculator.compare(head_phrases, diff_point_phrases)
10
+ described_class.compare(head_phrases, diff_point_phrases)
13
11
  end
14
12
 
15
13
  context 'with phrases added to HEAD' do
data/spec/events_spec.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- include Txgh
4
-
5
- describe Events do
6
- let(:events) { Events.new }
3
+ describe Txgh::Events do
4
+ let(:events) { subject }
7
5
 
8
6
  describe '#subscribe and #channels' do
9
7
  it "adds a channel if it doesn't already exist" do
@@ -1,11 +1,9 @@
1
1
  require 'spec_helper'
2
2
  require 'base64'
3
3
 
4
- include Txgh
5
-
6
- describe GithubApi do
4
+ describe Txgh::GithubApi do
7
5
  let(:client) { double(:client) }
8
- let(:api) { GithubApi.create_from_client(client, repo) }
6
+ let(:api) { described_class.create_from_client(client, repo) }
9
7
  let(:repo) { 'my_org/my_repo' }
10
8
  let(:branch) { 'master' }
11
9
  let(:sha) { 'abc123' }