Skip to content
This repository
Browse code

specs for 'issues open|closed'

  • Loading branch information...
commit b5166fce5364265db530aec40e3268762674c537 1 parent 959ca7c
Dr Nic Williams drnic authored
2  lib/commands/issues.rb
@@ -7,7 +7,7 @@
7 7
8 8 case command
9 9 when 'open', 'closed'
10   - report = YAML.load(Kernel.open(@helper.list_issues_for(user, command)))
  10 + report = YAML.load(open(@helper.list_issues_for(user, command)))
11 11 @helper.print_issues(report['issues'], options)
12 12 when 'web'
13 13 helper.open helper.issues_page_for(user)
56 spec/commands/command_issues_spec.rb
@@ -21,6 +21,39 @@
21 21 end
22 22
23 23 specify "issues web opens the project's issues page" do
  24 + running :issues, "open" do
  25 + setup_url_for
  26 + mock_issues_for "open"
  27 + stdout.should == <<-EOS.gsub(/^ /, '')
  28 + -----
  29 + Issue #1 (0 votes): members.json 500 error
  30 + * Opened about 19 hours ago by kdmny
  31 + * Last updated about 18 hours ago
  32 +
  33 + I have a nasty bug.
  34 + -----
  35 + EOS
  36 + end
  37 + end
  38 +
  39 + specify "issues web closed the project's issues page" do
  40 + running :issues, "closed" do
  41 + setup_url_for
  42 + mock_issues_for "closed"
  43 + stdout.should == <<-EOS.gsub(/^ /, '')
  44 + -----
  45 + Issue #1 (0 votes): members.json 500 error
  46 + * Opened about 19 hours ago by kdmny
  47 + * Closed about 18 hours ago
  48 + * Last updated about 18 hours ago
  49 +
  50 + I have a nasty bug.
  51 + -----
  52 + EOS
  53 + end
  54 + end
  55 +
  56 + specify "issues web opens the project's issues page" do
24 57 running :issues, "web" do
25 58 setup_url_for
26 59 @helper.should_receive(:open).once.with("https://github.com/user/project/issues")
@@ -33,4 +66,27 @@
33 66 @helper.should_receive(:open).once.with("https://github.com/drnic/project/issues")
34 67 end
35 68 end
  69 +
  70 + class CommandHelper::Runner
  71 + def mock_issues_for(state = "open", user = "user", project = "project")
  72 + yaml = <<-YAML.gsub(/^ /, '')
  73 + ---
  74 + issues:
  75 + - number: 1
  76 + votes: 0
  77 + created_at: 2009-11-04 20:25:02 -08:00
  78 + body: |-
  79 + I have a nasty bug.
  80 + title: members.json 500 error
  81 + updated_at: 2009-11-04 21:26:39 -08:00
  82 + #{"closed_at: 2009-11-04 21:25:17 -08:00" if state == "closed"}
  83 + user: kdmny
  84 + labels: []
  85 +
  86 + state: #{state}
  87 + YAML
  88 + api_url = "http://github.com/api/v2/yaml/issues/list/#{user}/#{project}/#{state}"
  89 + @command.should_receive(:open).with(api_url).and_return(yaml)
  90 + end
  91 + end
36 92 end

0 comments on commit b5166fc

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