Skip to content
Browse files

specs for 'issues open|closed'

  • Loading branch information...
1 parent 959ca7c commit b5166fce5364265db530aec40e3268762674c537 @drnic drnic committed Nov 6, 2009
Showing with 57 additions and 1 deletion.
  1. +1 −1 lib/commands/issues.rb
  2. +56 −0 spec/commands/command_issues_spec.rb
View
2 lib/commands/issues.rb
@@ -7,7 +7,7 @@
case command
when 'open', 'closed'
- report = YAML.load(Kernel.open(@helper.list_issues_for(user, command)))
+ report = YAML.load(open(@helper.list_issues_for(user, command)))
@helper.print_issues(report['issues'], options)
when 'web'
helper.open helper.issues_page_for(user)
View
56 spec/commands/command_issues_spec.rb
@@ -21,6 +21,39 @@
end
specify "issues web opens the project's issues page" do
+ running :issues, "open" do
+ setup_url_for
+ mock_issues_for "open"
+ stdout.should == <<-EOS.gsub(/^ /, '')
+ -----
+ Issue #1 (0 votes): members.json 500 error
+ * Opened about 19 hours ago by kdmny
+ * Last updated about 18 hours ago
+
+ I have a nasty bug.
+ -----
+ EOS
+ end
+ end
+
+ specify "issues web closed the project's issues page" do
+ running :issues, "closed" do
+ setup_url_for
+ mock_issues_for "closed"
+ stdout.should == <<-EOS.gsub(/^ /, '')
+ -----
+ Issue #1 (0 votes): members.json 500 error
+ * Opened about 19 hours ago by kdmny
+ * Closed about 18 hours ago
+ * Last updated about 18 hours ago
+
+ I have a nasty bug.
+ -----
+ EOS
+ end
+ end
+
+ specify "issues web opens the project's issues page" do
running :issues, "web" do
setup_url_for
@helper.should_receive(:open).once.with("https://github.com/user/project/issues")
@@ -33,4 +66,27 @@
@helper.should_receive(:open).once.with("https://github.com/drnic/project/issues")
end
end
+
+ class CommandHelper::Runner
+ def mock_issues_for(state = "open", user = "user", project = "project")
+ yaml = <<-YAML.gsub(/^ /, '')
+ ---
+ issues:
+ - number: 1
+ votes: 0
+ created_at: 2009-11-04 20:25:02 -08:00
+ body: |-
+ I have a nasty bug.
+ title: members.json 500 error
+ updated_at: 2009-11-04 21:26:39 -08:00
+ #{"closed_at: 2009-11-04 21:25:17 -08:00" if state == "closed"}
+ user: kdmny
+ labels: []
+
+ state: #{state}
+ YAML
+ api_url = "http://github.com/api/v2/yaml/issues/list/#{user}/#{project}/#{state}"
+ @command.should_receive(:open).with(api_url).and_return(yaml)
+ end
+ end
end

0 comments on commit b5166fc

Please sign in to comment.
Something went wrong with that request. Please try again.