technicalpickles-file_fixture 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/Manifest +3 -0
- data/README.markdown +33 -0
- data/Rakefile +1 -1
- data/file_fixture.gemspec +3 -3
- metadata +6 -2
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008 Josh Nichols
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/Manifest
CHANGED
data/README.markdown
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# file\_fixture
|
2
|
+
|
3
|
+
## Installing
|
4
|
+
|
5
|
+
gem install technicalpickles-file_fixture -s http://gems.github.com
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
file\_fixture provide provides a convenience method for loading data from files. To use, you just add the snippet to your `test_helper.rb`:
|
10
|
+
|
11
|
+
require 'file_fixture/test_unit'
|
12
|
+
FileFixture::FIXTURE_DIR = File.join(File.dirname(__FILE__), "file_fixtures")
|
13
|
+
|
14
|
+
Place files into the `file_fixtures` directory, and then you can use `file_fixture 'foo'` to read and return `file_fixtures/foo`.
|
15
|
+
|
16
|
+
If you were building wrappers around web APIs, you should use static data instead of hitting the API directly. We can use file_fixture to implement this helper method:
|
17
|
+
|
18
|
+
def stubbing_http_response_with_fixture(file)
|
19
|
+
response = stub(:body => file_fixture(file), :value => nil)
|
20
|
+
Net::HTTP.any_instance.stubs(:request).returns(response)
|
21
|
+
|
22
|
+
yield
|
23
|
+
end
|
24
|
+
|
25
|
+
You could then use this in tests like:
|
26
|
+
|
27
|
+
stubbing_http_response_with_fixture('get_tags.xml') do
|
28
|
+
assert_equal 6, @user.tags.size # @user.tags does a HTTP request
|
29
|
+
end
|
30
|
+
|
31
|
+
## License
|
32
|
+
|
33
|
+
See LICENSE
|
data/Rakefile
CHANGED
data/file_fixture.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{file_fixture}
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.1"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new("= 1.2") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Josh Nichols"]
|
7
7
|
s.date = %q{2008-07-14}
|
8
8
|
s.description = %q{A helper method for loading files during test}
|
9
9
|
s.email = %q{josh@technicalpickles.com}
|
10
|
-
s.extra_rdoc_files = ["lib/file_fixture/test_unit.rb", "lib/file_fixture.rb"]
|
11
|
-
s.files = ["lib/file_fixture/test_unit.rb", "lib/file_fixture.rb", "Manifest", "Rakefile", "
|
10
|
+
s.extra_rdoc_files = ["lib/file_fixture/test_unit.rb", "lib/file_fixture.rb", "LICENSE", "README.markdown"]
|
11
|
+
s.files = ["file_fixture.gemspec", "lib/file_fixture/test_unit.rb", "lib/file_fixture.rb", "LICENSE", "Manifest", "Rakefile", "README.markdown"]
|
12
12
|
s.has_rdoc = true
|
13
13
|
s.homepage = %q{http://technicalpickles.com}
|
14
14
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "File_fixture", "--main", "README.markdown"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technicalpickles-file_fixture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -30,12 +30,16 @@ extensions: []
|
|
30
30
|
extra_rdoc_files:
|
31
31
|
- lib/file_fixture/test_unit.rb
|
32
32
|
- lib/file_fixture.rb
|
33
|
+
- LICENSE
|
34
|
+
- README.markdown
|
33
35
|
files:
|
36
|
+
- file_fixture.gemspec
|
34
37
|
- lib/file_fixture/test_unit.rb
|
35
38
|
- lib/file_fixture.rb
|
39
|
+
- LICENSE
|
36
40
|
- Manifest
|
37
41
|
- Rakefile
|
38
|
-
-
|
42
|
+
- README.markdown
|
39
43
|
has_rdoc: true
|
40
44
|
homepage: http://technicalpickles.com
|
41
45
|
post_install_message:
|