Sha256: e704f82044f86c0fcf708cea14d455fd305f44a617a57c7b23d3feed73337049

Contents?: true

Size: 1.95 KB

Versions: 2

Compression:

Stored size: 1.95 KB

Contents

require_relative "spec_helper"

describe Card do

  describe "parses name" do
    before(:each) do
      allow_any_instance_of(Card).to receive(:init_data)
      @card = Card.new(double, double)
    end

    it "extracts single digit story point value from card name" do
      allow(@card).to receive(:name).and_return("(3) P1: Refactor cards")
      expect(@card.story_points).to eq(3)
    end

    it "extracts double digit story point value from card name" do
      allow(@card).to receive(:name).and_return "(13) P1: Refactor cards"
      expect(@card.story_points).to eq(13)
    end

    it "extracts fractional story point value from card name" do
      allow(@card).to receive(:name).and_return "(0.5) P1: Refactor cards"
      expect(@card.story_points).to eq(0.5)
    end

    it "extracts story points when value is not at beginning of card name" do
      allow(@card).to receive(:name).and_return "P01: (3) Refactor cards"
      expect(@card.story_points).to eq(3)
    end
  end

  describe "#parse_yaml_from_description" do
    it "parses description only having YAML" do
      description = <<EOT
```yaml
total_days: 18
weekend_lines:
  - 1.5
  - 6.5
```
EOT
      meta = Card.parse_yaml_from_description(description)
      expect(meta["total_days"]).to eq(18)
      expect(meta["weekend_lines"]).to eq([1.5, 6.5])
    end

    it "parses description only having unmarked YAML" do
      description = <<EOT
```
total_days: 18
weekend_lines:
  - 1.5
  - 6.5
```
EOT
      meta = Card.parse_yaml_from_description(description)
      expect(meta["total_days"]).to eq(18)
      expect(meta["weekend_lines"]).to eq([1.5, 6.5])
    end

    it "parses description having YAML and text" do
      description = <<EOT
This is some text

```yaml
total_days: 18
weekend_lines:
  - 1.5
  - 6.5
```

And more text.
EOT
      meta = Card.parse_yaml_from_description(description)
      expect(meta["total_days"]).to eq(18)
      expect(meta["weekend_lines"]).to eq([1.5, 6.5])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trollolo-0.0.5 spec/unit/card_spec.rb
trollolo-0.0.4 spec/unit/card_spec.rb