leek 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.swp
6
+ *.log
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,16 @@
1
+ # Leek
2
+
3
+ Cucumber and RSpec extension that allows to test filesystem operations without leaving any trace on your system.
4
+
5
+ * it uses mocks for Ruby file access libraries
6
+ * provides set of predefined cucumber steps
7
+
8
+ ## Installation
9
+
10
+ Add to your Gemfile and run the `bundle` command to install.
11
+
12
+ ```ruby
13
+ gem 'leek'
14
+ ```
15
+
16
+ ## Usage
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "cucumber/rake/task"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ desc "Run tests, both RSpec and Cucumber"
8
+ task :test => [:spec, :cucumber]
9
+
10
+ task :default => :test
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
11
+ require 'leek'
12
+ require 'rspec/expectations'
13
+ require 'fakefs/safe'
14
+ require 'open3'
15
+ require 'fileutils'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "leek/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "leek"
7
+ s.version = Leek::VERSION
8
+ s.authors = ["Piotr Murach"]
9
+ s.email = [""]
10
+ s.homepage = ""
11
+ s.summary = %q{Cucumber and RSpec extension that allows to test filesystem operations without leaving any trace on your system.}
12
+ s.description = %q{Cucumber and RSpec extension that allows to test filesystem operations without leaving any trace on your system.}
13
+
14
+ s.rubyforge_project = "leek"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency 'cucumber', '>= 1.1.1'
22
+ s.add_runtime_dependency 'fakefs', '>= 0.4.0'
23
+ s.add_runtime_dependency 'rspec', '>= 1.1.1'
24
+ end
@@ -0,0 +1,4 @@
1
+ require "leek/version"
2
+
3
+ module Leek
4
+ end # Leek
@@ -0,0 +1,21 @@
1
+ require 'fileutils'
2
+ require 'fakefs'
3
+
4
+ module Leek
5
+ module Api
6
+
7
+ def remove_dir dir_name
8
+ FakeFS::FileUtils.rmdir dir_name
9
+ end
10
+
11
+ def write_file file_name, file_content
12
+ end
13
+
14
+ private
15
+
16
+ def _create_file
17
+ FakeFile.new
18
+ end
19
+
20
+ end # Api
21
+ end # Leek
@@ -0,0 +1 @@
1
+ # Directory operations wrapper
@@ -0,0 +1,2 @@
1
+ # File operation wrapper
2
+
@@ -0,0 +1 @@
1
+ # System operations wrapper
@@ -0,0 +1,19 @@
1
+ module Leek
2
+ class Config
3
+
4
+ attr_writer :dirs
5
+
6
+ def initialize &block
7
+ configure(&block) if block_given?
8
+ end
9
+
10
+ def configure &block
11
+ yield self
12
+ end
13
+
14
+ def dirs
15
+ @dirs ||= []
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,73 @@
1
+ ['api', 'cucumber/hooks'].each do |path|
2
+ require "leek/#{path}"
3
+ end
4
+
5
+ World(Leek::Api)
6
+
7
+ Given /^file called "([^"]*)"$/ do |file_name|
8
+ FakeFS::FileUtils.touch file_name
9
+ end
10
+
11
+ Given /^directory called "([^"]*)"$/ do |directory|
12
+ FakeFS::FileUtils.mkdir directory
13
+ end
14
+
15
+ Given /^directory called "([^"]*)" exists$/ do |directory|
16
+ FakeFS::FileSystem.find(directory).should_not be_nil
17
+ end
18
+
19
+ Given /^I remove directory called "([^"]*)"$/ do |directory|
20
+ FakeFS::FileUtils.rmdir directory
21
+ end
22
+
23
+ Given /^directory called "([^"]*)" with files:$/ do |directory, text|
24
+ text.split('\n').each do |file_name|
25
+ step "file called \"#{file_name}\""
26
+ end
27
+ end
28
+
29
+ Given /^file called "([^"]*)" with content:$/ do |file_name, file_content|
30
+ unless FakeFS::FileSystem.files.include? file_name
31
+ file = FakeFS::FakeFile.new
32
+ file.content << file_content
33
+ FakeFS::FileSystem.add file_name, file
34
+ end
35
+ end
36
+
37
+ Given /^root directory$/ do
38
+ chdir fs
39
+ end
40
+
41
+ Given /^current directory$/ do
42
+ chdir current_dir
43
+ end
44
+
45
+ Given /^current directory with files:$/ do |text|
46
+ text.split('\n').each do |file_name|
47
+ step "file called \"#{file_name}\""
48
+ end
49
+ end
50
+
51
+ Given /^I symlink "" to ""$/ do |target, source|
52
+ ln_s target, source
53
+ end
54
+
55
+ Then /^the output should be empty$/ do
56
+ step "the output should contain \"\""
57
+ end
58
+
59
+ When /^I execute `([^`]*)`$/ do |cmd|
60
+ @stdin, @stdout, @stderr = Open3.popen3 cmd
61
+ end
62
+
63
+ When /^I input "([^"]*)"$/ do |input|
64
+ @stdin.puts input
65
+ end
66
+
67
+ Then /^the output contains "([^"]*)"$/ do |text|
68
+ @stdout.gets.should =~ /#{text}/m
69
+ end
70
+
71
+ Then /^file called "([^"]*)" is a symlink$/ do |file_name|
72
+ file_name.symlink?
73
+ end
@@ -0,0 +1,8 @@
1
+ Before "@fake" do
2
+ FakeFS.activate!
3
+ end
4
+
5
+ After "@fake" do
6
+ FakeFS::FileSystem.clear
7
+ FakeFS.deactivate!
8
+ end
@@ -0,0 +1,17 @@
1
+ module Leek
2
+ module SpecHelpers
3
+
4
+ def self.extended example_group
5
+ example_group.use_leek example_group
6
+ end
7
+
8
+ def self.included example_group
9
+ example_group.extend self
10
+ end
11
+
12
+ def use_leek describe_block
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Leek
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,12 @@
1
+ require 'leek'
2
+ require 'rspec/core'
3
+
4
+ Rails.backtrace_cleaner.remove_silencers!
5
+
6
+ RSpec.configure do |config|
7
+ config.include ActionController
8
+ config.include ActionView
9
+ end
10
+
11
+ # Load support files
12
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: leek
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Piotr Murach
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cucumber
16
+ requirement: &2156412720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.1.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2156412720
25
+ - !ruby/object:Gem::Dependency
26
+ name: fakefs
27
+ requirement: &2156411100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2156411100
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &2152766100 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.1
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2152766100
47
+ description: Cucumber and RSpec extension that allows to test filesystem operations
48
+ without leaving any trace on your system.
49
+ email:
50
+ - ''
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - README.md
58
+ - Rakefile
59
+ - features/step_definitions/.common_steps.rb.swp
60
+ - features/support/env.rb
61
+ - leek.gemspec
62
+ - lib/leek.rb
63
+ - lib/leek/api.rb
64
+ - lib/leek/api/dir.rb
65
+ - lib/leek/api/file.rb
66
+ - lib/leek/api/system.rb
67
+ - lib/leek/config.rb
68
+ - lib/leek/cucumber.rb
69
+ - lib/leek/cucumber/hooks.rb
70
+ - lib/leek/spec_helpers.rb
71
+ - lib/leek/version.rb
72
+ - spec/spec_helper.rb
73
+ homepage: ''
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project: leek
93
+ rubygems_version: 1.8.10
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Cucumber and RSpec extension that allows to test filesystem operations without
97
+ leaving any trace on your system.
98
+ test_files:
99
+ - features/step_definitions/.common_steps.rb.swp
100
+ - features/support/env.rb
101
+ - spec/spec_helper.rb