spec/projects_spec.rb in gerry-0.1.5 vs spec/projects_spec.rb in gerry-0.1.6

- old
+ new

@@ -1,37 +1,48 @@ require 'spec_helper' +require 'pry' describe '.projects' do + before(:all) do + @client = MockGerry.new + end + it 'should fetch all projects' do stub = stub_get('/projects/', 'projects.json') - client = MockGerry.new - projects = client.projects + projects = @client.projects expect(stub).to have_been_requested expect(projects['awesome']['description']).to eq('Awesome project') expect(projects['clean']['description']).to eq('Clean code!') end it 'should fetch a project' do stub = stub_get('/projects/awesome', 'projects.json') - client = MockGerry.new - projects = client.find_project('awesome') + projects = @client.find_project('awesome') expect(stub).to have_been_requested expect(projects['awesome']['description']).to eq('Awesome project') end + it 'should fetch file content' do + stub = stub_get('/projects/awesome/commits/djfkslj/files/README.md/content','README.md.json') + + file = @client.project_file('awesome','djfkslj','README.md') + + expect(stub).to have_been_requested + expect(file).to eq('Hello World!') + end + it 'should resolve the symbolic HEAD ref of a project' do project = 'awesome' stub = stub_get("/projects/#{project}/HEAD", 'project_head.json') - client = MockGerry.new - branch = client.get_head(project) + branch = @client.get_head(project) expect(stub).to have_been_requested expect(branch).to eq('refs/heads/stable') end @@ -42,13 +53,38 @@ input = { ref: 'refs/heads/' + branch } stub = stub_put("/projects/#{project}/HEAD", input.to_json, get_fixture('project_head.json')) - client = MockGerry.new - new_branch = client.set_head(project, branch) + new_branch = @client.set_head(project, branch) expect(stub).to have_been_requested expect(new_branch).to eq('refs/heads/' + branch) + end + + it 'list access rights' do + stub = stub_get('/projects/foo/access', 'branch_access.json') + + accesses = @client.project_access('foo') + expect(stub).to have_been_requested + end + + it 'create project access rights' do + access_rights = { + 'refs/heads/*' => { + 'permissions' => { + 'read' => { + 'rules' => { + 'user:kobe' => { + 'action' => 'ALLOW' + } + } + } + } + } + } + stub = stub_post('/projects/foo/access', 'add' => access_rights) + @client.create_project_access('foo', access_rights) + expect(stub).to have_been_requested end end