Sha256: 75051a8b9920191e2898c6f9a6fbcac2b830c52fb6eb51b69c5370f8f95d5b1c

Contents?: true

Size: 1.65 KB

Versions: 13

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

describe Gitmine::Issue do
  let(:issue) { Gitmine::Issue.new }
  [:id, :subject, :status].each do |a|
    it "should have an #{a}" do
      issue.should respond_to a
    end
  end

  describe "#get_for_commit" do
    it "should parse the commit message to find a commit_id and call #get" do
      commit_msg = 'A commit msg Issue #123'
      Gitmine::Issue.should_receive(:parse_for_issue_id).with(commit_msg)
      Gitmine::Issue.get_for_commit(commit_msg)
    end
  end

  describe "#find (class method)" do
    it "should build_via_issue_id" do
      issue = Gitmine::Issue.new
      Gitmine::Issue.should_receive(:new) { issue }
      issue.should_receive(:build_via_issue_id)
      Gitmine::Issue.find(123)
    end
  end

  describe "#build_via_issue_id" do
    before do
      @httparty = mock(:http_party_response, :parsed_response => {'issue' => { 'subject' => 'A subject', 'status' => {'name' => 'Completed'}}})
      issue.stub!(:http_get) { @httparty }
    end

    it "should get issue data and load attributes" do
      issue.should_receive(:build_via_issue_id).with(123) { @httparty }
      issue.build_via_issue_id(123)
    end

    it "should load attributes" do
      issue.build_via_issue_id(123)
      issue.id.should == 123
      issue.subject.should == 'A subject'
      issue.status.should == 'Completed'
    end
  end

  describe "#add_note" do
    let(:httparty_response) { mock(:http_party_response, :code => 200) }
    it "should PUT a note" do
      issue.stub!(:id) { 1 }
      issue.class.should_receive(:put).with('/1.xml', :query => {:notes => "Hello"}, :body => "") { httparty_response }
      issue.add_note("Hello")
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gitmine-0.2.1 spec/issue_spec.rb
gitmine-0.2.0 spec/issue_spec.rb
gitmine-0.1.16 spec/issue_spec.rb
gitmine-0.1.15 spec/issue_spec.rb
gitmine-0.1.14 spec/issue_spec.rb
gitmine-0.1.13 spec/issue_spec.rb
gitmine-0.1.12 spec/issue_spec.rb
gitmine-0.1.11 spec/issue_spec.rb
gitmine-0.1.10 spec/issue_spec.rb
gitmine-0.1.9 spec/issue_spec.rb
gitmine-0.1.8 spec/issue_spec.rb
gitmine-0.1.7 spec/issue_spec.rb
gitmine-0.1.6 spec/issue_spec.rb