octopart 0.1.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.
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Octopart::Configuration do
4
+ after(:each) { Octopart.configuration.apikey = nil }
5
+
6
+ describe ".apikey" do
7
+ it "can set the api key" do
8
+ Octopart.configure do |config|
9
+ config.apikey = 'apikey'
10
+ end
11
+
12
+ Octopart.configuration.apikey.should eq('apikey')
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe Octopart::Part do
4
+ describe "#find" do
5
+ context "when given 0 arguments" do
6
+ it "should raise an ArgumentError" do
7
+ expect {
8
+ described_class.find
9
+ }.to raise_error ArgumentError
10
+ end
11
+ end
12
+ context "when given a part uid" do
13
+ use_vcr_cassette
14
+ subject { described_class.find('39619421') }
15
+
16
+ it { should be_a(Octopart::Part) }
17
+ it { subject.uid.should eq(39619421) }
18
+ end
19
+
20
+ context "when given multiple part uids" do
21
+ use_vcr_cassette
22
+ subject { described_class.find(39619421, 29035751, 31119928)}
23
+
24
+ it { should be_a(Array) }
25
+
26
+ it "each object in the array should be a part" do
27
+ subject.each { |part| part.should be_a(Octopart::Part) }
28
+ end
29
+ end
30
+ end
31
+
32
+ describe "#search" do
33
+ context "when given a query" do
34
+ use_vcr_cassette
35
+ subject { described_class.search('resistor') }
36
+
37
+ it { should be_a(Array) }
38
+
39
+ it "each object in the array should be a part" do
40
+ subject.each { |part| part.should be_a(Octopart::Part) }
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "#match" do
46
+ context "when given a manufacturer and an mpn" do
47
+ use_vcr_cassette
48
+ subject { described_class.match('texas instruments', 'SN74LS240N') }
49
+
50
+ it { should eq(42315325996) }
51
+ end
52
+ end
53
+
54
+ describe "#bom" do
55
+ context "when give an mpn" do
56
+ use_vcr_cassette
57
+ subject { described_class.bom(mpn: 'SN74LS240N') }
58
+
59
+ it { should be_a(Array) }
60
+ it "each object in the array should be an array part" do
61
+ subject.each do |line|
62
+ line.should be_a(Array)
63
+ line.each do |part|
64
+ part.should be_a(Octopart::Part)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,15 @@
1
+ require "bundler"
2
+ Bundler.require :default, :development, :test
3
+
4
+ RSpec.configure do |c|
5
+ # so we can use `:vcr` rather than `:vcr => true`;
6
+ # in RSpec 3 this will no longer be necessary.
7
+ # c.treat_symbols_as_metadata_keys_with_true_values = true
8
+ c.extend VCR::RSpec::Macros
9
+ end
10
+
11
+ VCR.configure do |c|
12
+ c.cassette_library_dir = 'spec/fixtures/cassettes'
13
+ c.hook_into :fakeweb
14
+ # c.configure_rspec_metadata!
15
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Eric J. Holmes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashie
16
+ requirement: &2156957740 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2156957740
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &2156957320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2156957320
36
+ - !ruby/object:Gem::Dependency
37
+ name: rest-client
38
+ requirement: &2156956900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2156956900
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &2156956480 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2156956480
58
+ - !ruby/object:Gem::Dependency
59
+ name: vcr
60
+ requirement: &2156956060 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2156956060
69
+ - !ruby/object:Gem::Dependency
70
+ name: fakeweb
71
+ requirement: &2156955640 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2156955640
80
+ description: Ruby gem for the Octopart API
81
+ email:
82
+ - eric@ejholmes.net
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .gitignore
88
+ - .rspec
89
+ - .travis.yml
90
+ - Gemfile
91
+ - LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - lib/octopart.rb
95
+ - lib/octopart/base.rb
96
+ - lib/octopart/config.rb
97
+ - lib/octopart/part.rb
98
+ - lib/octopart/version.rb
99
+ - octopart.gemspec
100
+ - spec/fixtures/cassettes/Octopart_Part/_bom/when_give_an_mpn.yml
101
+ - spec/fixtures/cassettes/Octopart_Part/_find/when_given_a_part_uid.yml
102
+ - spec/fixtures/cassettes/Octopart_Part/_find/when_given_multiple_part_uids.yml
103
+ - spec/fixtures/cassettes/Octopart_Part/_match/when_given_a_manufacturer_and_an_mpn.yml
104
+ - spec/fixtures/cassettes/Octopart_Part/_search/when_given_a_query.yml
105
+ - spec/lib/config_spec.rb
106
+ - spec/lib/part_spec.rb
107
+ - spec/spec_helper.rb
108
+ homepage: https://github.com/ejholmes/octopart
109
+ licenses: []
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 1.8.11
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: Ruby gem for the Octopart API
132
+ test_files:
133
+ - spec/fixtures/cassettes/Octopart_Part/_bom/when_give_an_mpn.yml
134
+ - spec/fixtures/cassettes/Octopart_Part/_find/when_given_a_part_uid.yml
135
+ - spec/fixtures/cassettes/Octopart_Part/_find/when_given_multiple_part_uids.yml
136
+ - spec/fixtures/cassettes/Octopart_Part/_match/when_given_a_manufacturer_and_an_mpn.yml
137
+ - spec/fixtures/cassettes/Octopart_Part/_search/when_given_a_query.yml
138
+ - spec/lib/config_spec.rb
139
+ - spec/lib/part_spec.rb
140
+ - spec/spec_helper.rb