composable_fixtures 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be1032be623a2fbb0a11d939764f6be915dc90bb
4
- data.tar.gz: 2a7cab596fd2911f8465c2fc1e5d6ff5dcb4cae5
3
+ metadata.gz: 749b9a6cd2a2d0214718eb83a9cdac29092fc583
4
+ data.tar.gz: af55c640b941784f6e62347d898fcef196160a6c
5
5
  SHA512:
6
- metadata.gz: 508c0eb1a0ff441691deb96d6d3bb57d46baf7cfbe9a5401695ee190562169e8b20d2db09691078d956fbb2746757135aa90cbbfde662f82769d075144f8baa0
7
- data.tar.gz: a73a64a659f0f89cfab02de0cb0b06e58e8fa1d48e99287195dd1fe676eb233052b2585577caf1895aa88d6091f4cc9c4513a50d24386648e977d3ffb8f7a2a4
6
+ metadata.gz: ae31d4e8133dcb952ddaafaea955f446a0364576d7b227ec333e9226ac885228fccc0611c2e9de483a0224e203932e11fcc60956df80df8ddae828deb0e2e836
7
+ data.tar.gz: 5176b83c2b717ea1b31910b59274e543c463db7e797a87ca48d19b67a1726500a3b076e7b0d01fe79763e64f693057b355a15544ad9b6efb9fff5185b96e061b
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
+
2
+ [![Build Status](https://secure.travis-ci.org/optoro/composable_fixtures.png?branch=master)](http://travis-ci.org/optoro/composable_fixtures)
3
+
1
4
  # composable_fixtures
2
5
 
3
- A [elight](http://github.com/elight) and [bhaibel](http://github.com/bhaibel) joint.
6
+ An [elight](http://github.com/elight) and [bhaibel](http://github.com/bhaibel) joint.
4
7
 
5
8
  ## Installation
6
9
 
@@ -16,12 +19,12 @@ end
16
19
  require 'rspec/rails'
17
20
  ```
18
21
 
19
- You will also want ot add a FixtureSetDefinition. An example is given below.
22
+ You will also want to add a FixtureSetDefinition. An example is given below.
20
23
 
21
24
  ## Rough Example
22
25
 
23
26
  ```ruby
24
- FixtureSetDefinition.create do
27
+ ComposableFixtures.define do
25
28
  set :normal_shipped, "spec/auditor/fixtures/normal_shipped"
26
29
  set :normal_shipped_amazon, "spec/auditor/fixtures/normal_shipped_amazon"
27
30
  set :multiple "spec/foo/fixtures", "spec/bar/fixtures"
@@ -1,12 +1,6 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: composable_fixtures 0.0.1 ruby lib
6
-
7
1
  Gem::Specification.new do |s|
8
2
  s.name = "composable_fixtures"
9
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
10
4
 
11
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
6
  s.require_paths = ["lib"]
@@ -23,7 +17,6 @@ Gem::Specification.new do |s|
23
17
  s.add_development_dependency("rspec", "~> 3.1")
24
18
  s.add_development_dependency("bundler", "~> 1.0")
25
19
  s.add_development_dependency("simplecov", ">= 0")
26
- s.add_development_dependency("rspec-rails", ">= 3")
27
20
  s.add_development_dependency("pry", ">= 0.10")
28
21
 
29
22
  s.add_runtime_dependency("rspec", "~> 3.1")
@@ -6,15 +6,21 @@ require 'composable_fixtures/fixture_composer'
6
6
  module ComposableFixtures
7
7
  module ExampleGroupHelpers
8
8
  def use_composed_fixture_set(*fixtures)
9
- FixtureDirectory.create
10
- FixtureDirectory.write(
11
- FixtureComposer.new(fixtures).as_filename_to_yaml
12
- )
9
+ unless dir = FixtureDirectory.get(fixtures)
10
+ dir = FixtureDirectory.create(fixtures)
11
+ dir.write(
12
+ FixtureComposer.new(fixtures).as_filename_to_yaml
13
+ )
14
+ end
13
15
 
14
- self.fixture_path = FixtureDirectory.path
16
+ self.fixture_path = dir.path
17
+ end
15
18
 
16
- after(:all) do
17
- FixtureDirectory.destroy
19
+ def self.extended(base)
20
+ RSpec.configure do |config|
21
+ config.after(:suite) do
22
+ FixtureDirectory.destroy_all
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -3,14 +3,11 @@ require 'singleton'
3
3
 
4
4
  module ComposableFixtures
5
5
  class FixtureDirectory
6
- include Singleton
7
-
8
6
  class DirectoryAlreadyExistsError < StandardError; end
9
7
  class DirectoryDoesntExistError < StandardError; end
10
8
 
11
- def create
12
- raise DirectoryAlreadyExistsError if @dir
13
- @dir = Dir.mktmpdir
9
+ def initialize(name)
10
+ @dir = Dir.mktmpdir(name)
14
11
  end
15
12
 
16
13
  def destroy
@@ -30,20 +27,30 @@ module ComposableFixtures
30
27
  @dir.to_s
31
28
  end
32
29
 
33
- def self.create
34
- instance.create
30
+ def self.get(fixtures)
31
+ key = repository_key(fixtures)
32
+ repository.fetch(key, nil)
33
+ end
34
+
35
+ def self.create(fixtures)
36
+ key = repository_key(fixtures)
37
+ raise DirectoryAlreadyExistsError if @@repository.has_key?(key)
38
+
39
+ repository[key] = new(key)
35
40
  end
36
41
 
37
- def self.write(fixtures)
38
- instance.write(fixtures)
42
+ def self.destroy_all
43
+ repository.each do |key, dir|
44
+ dir.destroy
45
+ end
39
46
  end
40
47
 
41
- def self.destroy
42
- instance.destroy
48
+ def self.repository_key(fixtures)
49
+ fixtures.join('-')
43
50
  end
44
51
 
45
- def self.path
46
- instance.path
52
+ def self.repository
53
+ @@repository ||= {}
47
54
  end
48
55
  end
49
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composable_fixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Light
@@ -53,20 +53,6 @@ dependencies:
53
53
  - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: rspec-rails
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - '>='
61
- - !ruby/object:Gem::Version
62
- version: '3'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - '>='
68
- - !ruby/object:Gem::Version
69
- version: '3'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: pry
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -123,10 +109,7 @@ files:
123
109
  - lib/composable_fixtures/fixture_directory.rb
124
110
  - lib/composable_fixtures/fixture_set_definition.rb
125
111
  - lib/composable_fixtures/fixture_set_repository.rb
126
- - lib/composable_fixtures/rspec_integration.rb
127
- - lib/composable_fixtures/rspec_rails_integration.rb
128
112
  - lib/composable_fixtures.rb
129
- - lib/fixture_directory.rb
130
113
  homepage: http://github.com/optoro/composable_fixtures
131
114
  licenses:
132
115
  - MIT
@@ -1,3 +0,0 @@
1
- class RSpec::Core::ExampleGroup
2
- extend ComposableFixtures::ExampleGroupHelpers
3
- end
@@ -1,22 +0,0 @@
1
- if defined?(Rails)
2
- require 'rspec/rails'
3
- else
4
- # FIXME: This breaks when you go to access a fixture by name because the
5
- # fixture_cache is nil
6
- module Rails
7
- module VERSION
8
- STRING = "3.2.17"
9
- end
10
- end
11
-
12
- require 'rspec/rails/adapters'
13
- require 'rspec/rails/fixture_support'
14
-
15
- RSpec.configure do |c|
16
- c.include RSpec::Rails::FixtureSupport
17
- c.add_setting :fixture_path
18
- c.add_setting :use_transactional_fixtures, :alias_with => :use_transactional_examples
19
- c.add_setting :use_instantiated_fixtures
20
- c.add_setting :global_fixtures
21
- end
22
- end
@@ -1,46 +0,0 @@
1
- require 'tmpdir'
2
- require 'singleton'
3
-
4
- module ComposableFixtures
5
- class FixtureDirectory
6
- include Singleton
7
-
8
- class DirectoryAlreadyExistsError < StandardError; end
9
- class DirectoryDoesntExistError < StandardError; end
10
-
11
- def create
12
- raise DirectoryAlreadyExistsError if @dir
13
- @dir = Dir.mktmpdir
14
- end
15
-
16
- def destroy
17
- raise DirectoryDoesntExistError unless @dir
18
- FileUtils.remove_entry @dir
19
- end
20
-
21
- def write
22
- name_to_fixtures.each do |(name, yaml)|
23
- File.open(File.join(path, name), "w") do |f|
24
- f.write yaml
25
- end
26
- end
27
- end
28
-
29
- def path
30
- @dir.to_s
31
- end
32
-
33
-
34
- def self.create
35
- instance.create
36
- end
37
-
38
- def self.write(fixtures)
39
- instance.write(fixtures)
40
- end
41
-
42
- def self.destroy
43
- instance.destroy
44
- end
45
- end
46
- end