ruby-trello 0.2.1 → 0.3.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.
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,8 @@
1
1
  require 'rubygems'
2
+ unless defined? Rubinius
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ end
2
6
 
3
7
  # Set up gems listed in the Gemfile.
4
8
  begin
@@ -16,16 +20,11 @@ Bundler.require(:spec)
16
20
  require 'trello'
17
21
  require 'webmock/rspec'
18
22
 
19
- module Helpers
20
- def stub_trello_request!(http_method, path, data, returning = '')
21
- uri = Addressable::URI.parse("https://api.trello.com/#{Trello::API_VERSION}#{path}")
22
- uri.query_values = data.kind_of?(String) ? JSON.parse(data) : data if data
23
-
24
- stub_request(http_method, uri.to_s).
25
- with(:headers => {'Accept'=>'*/*', 'Authorization'=>/.*/, 'User-Agent' => /.*/}).
26
- to_return(:status => 200, :headers => {}, :body => returning)
27
- end
23
+ RSpec.configure do |c|
24
+ c.filter_run_excluding :broken => true
25
+ end
28
26
 
27
+ module Helpers
29
28
  def user_details
30
29
  {
31
30
  "id" => "abcdef123456789012345678",
@@ -56,6 +55,23 @@ module Helpers
56
55
  JSON.generate(boards_details)
57
56
  end
58
57
 
58
+ def checklists_details
59
+ [{
60
+ "id" => "abcdef123456789123456789",
61
+ "name" => "Test Checklist",
62
+ "desc" => "A marvelous little checklist",
63
+ "closed" => false,
64
+ "url" => "https://trello.com/blah/blah",
65
+ "idBoard" => "abcdef123456789123456789",
66
+ "idMembers" => ["abcdef123456789123456789"],
67
+ "checkItems" => {}
68
+ }]
69
+ end
70
+
71
+ def checklists_payload
72
+ JSON.generate(checklists_details)
73
+ end
74
+
59
75
  def lists_details
60
76
  [{
61
77
  "id" => "abcdef123456789123456789",
@@ -104,7 +120,7 @@ module Helpers
104
120
  def actions_details
105
121
  [{
106
122
  "id" => "4ee2482134a81a757a08af47",
107
- "idMemberCreator" => "4ec33ef93a7537000010676d",
123
+ "idMemberCreator" => "abcdef123456789123456789",
108
124
  "data"=> {
109
125
  "card" => {
110
126
  "id" => "4ee2482134a81a757a08af45",
@@ -126,4 +142,4 @@ module Helpers
126
142
  def actions_payload
127
143
  JSON.generate(actions_details)
128
144
  end
129
- end
145
+ end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+ require "trello/string"
3
+
4
+ describe String, "#json_into" do
5
+ include Helpers
6
+
7
+ def example_class
8
+ @example_class ||= Class.new do
9
+ attr_accessor :name, :description
10
+
11
+ def initialize(options = {})
12
+ @name = options['name']
13
+ @description = options['description']
14
+ end
15
+ end
16
+ end
17
+
18
+ it "converts json into an instance of a class" do
19
+ "{}".json_into(example_class).should be_an_instance_of example_class
20
+ end
21
+
22
+ it "supplies the parsed json to the class's ctor as a hash" do
23
+ example_class.should_receive(:new).once.with({
24
+ "name" => "Jazz Kang",
25
+ "description" => "Plonker"
26
+ })
27
+
28
+ json_text = '{"name" : "Jazz Kang", "description": "Plonker"}'
29
+
30
+ json_text.json_into example_class
31
+ end
32
+
33
+ it "can also handle arrays of instances of a class" do
34
+ json_text = <<-JSON
35
+ [
36
+ {"name" : "Jazz Kang", "description": "Plonker"},
37
+ {"name" : "Phil Murphy", "description": "Shoreditch hipster"}
38
+ ]
39
+ JSON
40
+
41
+ result = json_text.json_into example_class
42
+
43
+ result.should be_an Array
44
+ result.size.should == 2
45
+ result.each do |parsed|
46
+ parsed.should be_an_instance_of example_class
47
+ end
48
+ end
49
+ end
50
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
16
- requirement: &70096518301420 !ruby/object:Gem::Requirement
16
+ requirement: &70257771954980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70096518301420
24
+ version_requirements: *70257771954980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: oauth
27
- requirement: &70096518300720 !ruby/object:Gem::Requirement
27
+ requirement: &70257771954200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.4.5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70096518300720
35
+ version_requirements: *70257771954200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: addressable
38
- requirement: &70096518300060 !ruby/object:Gem::Requirement
38
+ requirement: &70257771953700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.2.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70096518300060
46
+ version_requirements: *70257771953700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70096518299380 !ruby/object:Gem::Requirement
49
+ requirement: &70257771953240 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70096518299380
57
+ version_requirements: *70257771953240
58
58
  description: A wrapper around the trello.com API.
59
59
  email: jeremy@tregunna.ca
60
60
  executables: []
@@ -63,6 +63,7 @@ extra_rdoc_files:
63
63
  - README.md
64
64
  files:
65
65
  - lib/trello/action.rb
66
+ - lib/trello/authorization.rb
66
67
  - lib/trello/basic_data.rb
67
68
  - lib/trello/board.rb
68
69
  - lib/trello/card.rb
@@ -72,22 +73,29 @@ files:
72
73
  - lib/trello/item_state.rb
73
74
  - lib/trello/list.rb
74
75
  - lib/trello/member.rb
76
+ - lib/trello/net.rb
75
77
  - lib/trello/notification.rb
76
78
  - lib/trello/organization.rb
77
79
  - lib/trello/string.rb
78
80
  - lib/trello.rb
79
81
  - README.md
80
82
  - spec/action_spec.rb
83
+ - spec/basic_auth_policy_spec.rb
81
84
  - spec/board_spec.rb
82
85
  - spec/card_spec.rb
83
86
  - spec/checklist_spec.rb
84
87
  - spec/client_spec.rb
88
+ - spec/integration/how_to_authorize_spec.rb
89
+ - spec/integration/how_to_use_boards_spec.rb
90
+ - spec/integration/integration_test.rb
85
91
  - spec/item_spec.rb
86
92
  - spec/item_state_spec.rb
87
93
  - spec/list_spec.rb
88
94
  - spec/member_spec.rb
95
+ - spec/oauth_policy_spec.rb
89
96
  - spec/organization_spec.rb
90
97
  - spec/spec_helper.rb
98
+ - spec/string_spec.rb
91
99
  homepage: https://github.com/jeremytregunna/ruby-trello
92
100
  licenses: []
93
101
  post_install_message:
@@ -115,13 +123,19 @@ specification_version: 3
115
123
  summary: A wrapper around the trello.com API.
116
124
  test_files:
117
125
  - spec/action_spec.rb
126
+ - spec/basic_auth_policy_spec.rb
118
127
  - spec/board_spec.rb
119
128
  - spec/card_spec.rb
120
129
  - spec/checklist_spec.rb
121
130
  - spec/client_spec.rb
131
+ - spec/integration/how_to_authorize_spec.rb
132
+ - spec/integration/how_to_use_boards_spec.rb
133
+ - spec/integration/integration_test.rb
122
134
  - spec/item_spec.rb
123
135
  - spec/item_state_spec.rb
124
136
  - spec/list_spec.rb
125
137
  - spec/member_spec.rb
138
+ - spec/oauth_policy_spec.rb
126
139
  - spec/organization_spec.rb
127
140
  - spec/spec_helper.rb
141
+ - spec/string_spec.rb