slurper 1.1.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +0,0 @@
1
- require 'active_resource'
2
-
3
- class Story < ActiveResource::Base
4
-
5
- def self.yaml
6
- YAML.load_file('slurper_config.yml')
7
- end
8
-
9
- def self.config
10
- @@config = yaml
11
- scheme = if !!@@config['ssl']
12
- self.ssl_options = { :verify_mode => OpenSSL::SSL::VERIFY_PEER,
13
- :ca_file => File.join(File.dirname(__FILE__), "cacert.pem") }
14
- "https"
15
- else
16
- "http"
17
- end
18
- self.site = "#{scheme}://www.pivotaltracker.com/services/v3/projects/#{@@config['project_id']}"
19
- @@config
20
- end
21
-
22
-
23
- headers['X-TrackerToken'] = config.delete("token")
24
-
25
- def prepare
26
- scrub_description
27
- default_requested_by
28
- end
29
-
30
- protected
31
-
32
- def scrub_description
33
- if respond_to?(:description)
34
- self.description = description.gsub(" ", "").gsub(" \n", "\n")
35
- end
36
- if respond_to?(:description) && description == ""
37
- self.attributes["description"] = nil
38
- end
39
- end
40
-
41
- def default_requested_by
42
- if (!respond_to?(:requested_by) || requested_by == "") && Story.config["requested_by"]
43
- self.attributes["requested_by"] = Story.config["requested_by"]
44
- end
45
- end
46
-
47
- end
@@ -1,68 +0,0 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'slurper'
4
-
5
- describe Slurper do
6
-
7
- context "deals with leading/trailing whitespace" do
8
- before do
9
- slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "whitespacey_story.slurper"))
10
- slurper.load_stories
11
- @story = slurper.stories.first
12
- end
13
-
14
- it "strips whitespace from the name" do
15
- @story.name.should == "Profit"
16
- end
17
- end
18
-
19
- context "given values for all attributes" do
20
- before do
21
- slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "full_story.slurper"))
22
- slurper.load_stories
23
- @story = slurper.stories.first
24
- end
25
-
26
- it "parses the name correctly" do
27
- @story.name.should == "Profit"
28
- end
29
-
30
- it "parses the label correctly" do
31
- @story.labels.should == "money,power,fame"
32
- end
33
-
34
- it "parses the story type correctly" do
35
- @story.story_type.should == "feature"
36
- end
37
- end
38
-
39
- context "given only a name" do
40
- before do
41
- slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "name_only.slurper"))
42
- slurper.load_stories
43
- @story = slurper.stories.first
44
- end
45
-
46
- it "should parse the name correctly" do
47
- @story.name.should == "Profit"
48
- end
49
-
50
- end
51
-
52
- context "given empty attributes" do
53
- before do
54
- slurper = Slurper.new(File.join(File.dirname(__FILE__), "fixtures", "empty_attributes.slurper"))
55
- slurper.load_stories
56
- @story = slurper.stories.first
57
- end
58
-
59
- it "should not set any name" do
60
- @story.name.should be_nil
61
- end
62
-
63
- it "should not set any labels" do
64
- @story.labels.should be_nil
65
- end
66
- end
67
-
68
- end
@@ -1,111 +0,0 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'slurper'
4
-
5
- describe Story do
6
-
7
- context "#prepare" do
8
- it "scrubs the description" do
9
- story = Story.new
10
- story.stub!(:default_requested_by)
11
- story.should_receive(:scrub_description)
12
- story.prepare
13
- end
14
-
15
- it "scrubs the defaults the requested_by attribute" do
16
- story = Story.new
17
- story.stub!(:scrub_description)
18
- story.should_receive(:default_requested_by)
19
- story.prepare
20
- end
21
-
22
- it "uses http by default" do
23
- Story.site.scheme.should == "http"
24
- Story.yaml['ssl'].should be_nil
25
- end
26
-
27
- it "uses https if set in the config" do
28
- Story.stub(:yaml => {"ssl" => true})
29
- Story.config['ssl'].should be_true
30
- Story.site.scheme.should == "https"
31
- Story.ssl_options[:verify_mode].should == 1
32
-
33
- # Not sure what this next line is testing
34
- File.open(File.expand_path('lib/cacert.pem')).readlines.find_all{ |l| l.starts_with?("Equifax") }.count.should == 4
35
- end
36
- end
37
-
38
- context "requested_by attribute" do
39
- it "uses the default if not given one" do
40
- Story.stub!(:config).and_return({"requested_by" => "Mr. Client"})
41
- story = Story.new
42
- story.send(:default_requested_by)
43
- story.requested_by.should == "Mr. Client"
44
- end
45
-
46
- it "uses the default if given a blank requested_by" do
47
- Story.stub!(:config).and_return({"requested_by" => "Mr. Client"})
48
- story = Story.new(:requested_by => "")
49
- story.send(:default_requested_by)
50
- story.requested_by.should == "Mr. Client"
51
- end
52
-
53
- it "uses the name given in the story file if there is one" do
54
- Story.stub!(:config).and_return({"requested_by" => "Mr. Client"})
55
- story = Story.new(:requested_by => "Mr. Stakeholder")
56
- story.send(:default_requested_by)
57
- story.requested_by.should == "Mr. Stakeholder"
58
- end
59
- end
60
-
61
- context "scrubs the descriptions correctly" do
62
- it "when the description is blank" do
63
- story = Story.new(:description => "")
64
- story.send(:scrub_description)
65
- story.description.should be_nil
66
- end
67
-
68
- it "when there is no description given" do
69
- story = Story.new
70
- lambda {
71
- story.send(:scrub_description)
72
- }.should_not raise_error
73
- end
74
-
75
- it "when it contains quotes" do
76
- desc = <<-STRING
77
- I have a "quote"
78
- STRING
79
- story = Story.new(:description => desc)
80
- story.send(:scrub_description)
81
- story.description.should == "I have a \"quote\"\n"
82
- end
83
-
84
- it "when it is full of whitespace" do
85
- desc = <<-STRING
86
- In order to do something
87
- As a role
88
- I want to click a thingy
89
- STRING
90
- story = Story.new(:description => desc)
91
- story.send(:scrub_description)
92
- story.description.should == "In order to do something\nAs a role\nI want to click a thingy\n"
93
- end
94
-
95
- it "when it contains acceptance criteria" do
96
- desc = <<-STRING
97
- In order to do something
98
- As a role
99
- I want to click a thingy
100
-
101
- Acceptance:
102
- - do the thing
103
- - don't forget the other thing
104
- STRING
105
- story = Story.new(:description => desc)
106
- story.send(:scrub_description)
107
- story.description.should == "In order to do something\nAs a role\nI want to click a thingy\n\nAcceptance:\n- do the thing\n- don't forget the other thing\n"
108
- end
109
- end
110
-
111
- end