evented-spec 0.4.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,2 @@
1
+ --color
2
+ --format nested
@@ -0,0 +1,54 @@
1
+ $LOAD_PATH << "." unless $LOAD_PATH.include? "." # moronic 1.9.2 breaks things bad
2
+
3
+ require 'bundler'
4
+ Bundler.setup
5
+ Bundler.require :default, :test
6
+
7
+ require 'yaml'
8
+ require 'evented-spec/rspec'
9
+ require 'shared_examples'
10
+
11
+ require 'amqp'
12
+ require 'cool.io'
13
+
14
+ def rspec2?
15
+ defined?(RSpec)
16
+ end
17
+
18
+ # Done is defined as noop to help share examples between evented and non-evented specs
19
+ def done
20
+ end
21
+
22
+ RSPEC = rspec2? ? RSpec : Spec
23
+
24
+ amqp_config = File.dirname(__FILE__) + '/amqp.yml'
25
+
26
+ AMQP_OPTS = unless File.exists? amqp_config
27
+ {:user => 'guest',
28
+ :pass => 'guest',
29
+ :host => '10.211.55.2',
30
+ :vhost => '/'}
31
+ else
32
+ class Hash
33
+ def symbolize_keys
34
+ self.inject({}) { |result, (key, value)|
35
+ new_key = case key
36
+ when String then
37
+ key.to_sym
38
+ else
39
+ key
40
+ end
41
+ new_value = case value
42
+ when Hash then
43
+ value.symbolize_keys
44
+ else
45
+ value
46
+ end
47
+ result[new_key] = new_value
48
+ result
49
+ }
50
+ end
51
+ end
52
+
53
+ YAML::load_file(amqp_config).symbolize_keys[:test]
54
+ end
@@ -0,0 +1,51 @@
1
+ require "spec_helper"
2
+
3
+ describe EventedSpec::Util do
4
+ describe ".deep_clone" do
5
+ context "for non-clonables" do
6
+ it "should return the argument" do
7
+ described_class.deep_clone(nil).object_id.should == nil.object_id
8
+ described_class.deep_clone(0).object_id.should == 0.object_id
9
+ described_class.deep_clone(false).object_id.should == false.object_id
10
+ end
11
+ end
12
+
13
+ context "for strings and other simple clonables" do
14
+ let(:string) { "Hello!" }
15
+ it "should return a clone" do
16
+ clone = described_class.deep_clone(string)
17
+ clone.should == string
18
+ clone.object_id.should_not == string.object_id
19
+ end
20
+ end
21
+
22
+ context "for arrays" do
23
+ let(:array) { [child_hash, child_string] }
24
+ let(:child_string) { "Hello!" }
25
+ let(:child_hash) { {} }
26
+ it "should return a deep clone" do
27
+ clone = described_class.deep_clone(array)
28
+ clone.should == array
29
+ clone.object_id.should_not == array.object_id
30
+ clone[0].object_id.should_not == child_hash.object_id
31
+ clone[1].object_id.should_not == child_string.object_id
32
+ end
33
+ end
34
+
35
+ context "for hash" do
36
+ let(:hash) {
37
+ {:child_hash => child_hash, :child_array => child_array}
38
+ }
39
+ let(:child_hash) { {:hello => "world"} }
40
+ let(:child_array) { ["One"] }
41
+
42
+ it "should return a deep clone" do
43
+ clone = described_class.deep_clone(hash)
44
+ clone.should == hash
45
+ clone.object_id.should_not == hash.object_id
46
+ clone[:child_hash].object_id.should_not == child_hash.object_id
47
+ clone[:child_array].object_id.should_not == child_array.object_id
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,18 @@
1
+ #task :default => 'test:run'
2
+ #task 'gem:release' => 'test:run'
3
+
4
+ task :notes do
5
+ puts 'Output annotations (TBD)'
6
+ end
7
+
8
+ #Bundler not ready for prime time just yet
9
+ #desc 'Bundle dependencies'
10
+ #task :bundle do
11
+ # output = `bundle check 2>&1`
12
+ #
13
+ # unless $?.to_i == 0
14
+ # puts output
15
+ # system "bundle install"
16
+ # puts
17
+ # end
18
+ #end
@@ -0,0 +1,14 @@
1
+ desc 'Alias to doc:rdoc'
2
+ task :doc => 'doc:rdoc'
3
+
4
+ namespace :doc do
5
+ require 'rake/rdoctask'
6
+ Rake::RDocTask.new do |rdoc|
7
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "clobber", :rerdoc => "rerdoc") do |rdoc|
8
+ rdoc.rdoc_dir = DOC_PATH.basename.to_s
9
+ rdoc.title = "#{NAME} #{VERSION} Documentation"
10
+ rdoc.main = "README.doc"
11
+ rdoc.rdoc_files.include('README*')
12
+ rdoc.rdoc_files.include('lib/**/*.rb')
13
+ end
14
+ end
@@ -0,0 +1,40 @@
1
+ desc "Alias to gem:release"
2
+ task :release => 'gem:release'
3
+
4
+ desc "Alias to gem:install"
5
+ task :install => 'gem:install'
6
+
7
+ desc "Alias to gem:build"
8
+ task :gem => 'gem:build'
9
+
10
+ namespace :gem do
11
+ gem_file = "#{NAME}-#{VERSION}.gem"
12
+
13
+ desc "(Re-)Build gem"
14
+ task :build do
15
+ puts "Remove existing gem package"
16
+ rm_rf PKG_PATH
17
+ puts "Build new gem package"
18
+ system "gem build #{NAME}.gemspec"
19
+ puts "Move built gem to package dir"
20
+ mkdir_p PKG_PATH
21
+ mv gem_file, PKG_PATH
22
+ end
23
+
24
+ desc "Cleanup already installed gem(s)"
25
+ task :cleanup do
26
+ puts "Cleaning up installed gem(s)"
27
+ system "gem cleanup #{NAME}"
28
+ end
29
+
30
+ desc "Build and install gem"
31
+ task :install => :build do
32
+ system "gem install #{PKG_PATH}/#{gem_file}"
33
+ end
34
+
35
+ desc "Build and push gem to Gemcutter"
36
+ task :release => [:build, 'git:tag'] do
37
+ puts "Pushing gem to Gemcutter"
38
+ system "gem push #{PKG_PATH}/#{gem_file}"
39
+ end
40
+ end
@@ -0,0 +1,34 @@
1
+ desc "Alias to git:commit"
2
+ task :git => 'git:commit'
3
+
4
+ namespace :git do
5
+
6
+ desc "Stage and commit your work [with message]"
7
+ task :commit, [:message] do |t, args|
8
+ puts "Staging new (unversioned) files"
9
+ system "git add --all"
10
+ if args.message
11
+ puts "Committing with message: #{args.message}"
12
+ system %Q[git commit -a -m "#{args.message}" --author arvicco]
13
+ else
14
+ puts "Committing"
15
+ system %Q[git commit -a -m "No message" --author arvicco]
16
+ end
17
+ end
18
+
19
+ desc "Push local changes to Github"
20
+ task :push => :commit do
21
+ puts "Pushing local changes to remote"
22
+ system "git push"
23
+ end
24
+
25
+ desc "Create (release) tag on Github"
26
+ task :tag => :push do
27
+ tag = VERSION
28
+ puts "Creating git tag: #{tag}"
29
+ system %Q{git tag -a -m "Release tag #{tag}" #{tag}}
30
+ puts "Pushing #{tag} to remote"
31
+ system "git push origin #{tag}"
32
+ end
33
+
34
+ end
@@ -0,0 +1,15 @@
1
+ desc 'Alias to spec:spec'
2
+ task :spec => 'spec:spec'
3
+
4
+ namespace :spec do
5
+ require 'rspec/core/rake_task'
6
+
7
+ desc "Run all specs"
8
+ RSpec::Core::RakeTask.new(:spec){|task|}
9
+
10
+ desc "Run specs with RCov"
11
+ RSpec::Core::RakeTask.new(:rcov) do |t|
12
+ t.rcov = true
13
+ t.rcov_opts = ['--exclude', 'spec']
14
+ end
15
+ end
@@ -0,0 +1,71 @@
1
+ class Version
2
+ attr_accessor :major, :minor, :patch, :build
3
+
4
+ def initialize(version_string)
5
+ raise "Invalid version #{version_string}" unless version_string =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
6
+ @major = $1.to_i
7
+ @minor = $2.to_i
8
+ @patch = $3.to_i
9
+ @build = $4
10
+ end
11
+
12
+ def bump_major(x)
13
+ @major += x.to_i
14
+ @minor = 0
15
+ @patch = 0
16
+ @build = nil
17
+ end
18
+
19
+ def bump_minor(x)
20
+ @minor += x.to_i
21
+ @patch = 0
22
+ @build = nil
23
+ end
24
+
25
+ def bump_patch(x)
26
+ @patch += x.to_i
27
+ @build = nil
28
+ end
29
+
30
+ def update(major, minor, patch, build=nil)
31
+ @major = major
32
+ @minor = minor
33
+ @patch = patch
34
+ @build = build
35
+ end
36
+
37
+ def write(desc = nil)
38
+ CLASS_NAME::VERSION_FILE.open('w') {|file| file.puts to_s }
39
+ (BASE_PATH + 'HISTORY').open('a') do |file|
40
+ file.puts "\n== #{to_s} / #{Time.now.strftime '%Y-%m-%d'}\n"
41
+ file.puts "\n* #{desc}\n" if desc
42
+ end
43
+ end
44
+
45
+ def to_s
46
+ [major, minor, patch, build].compact.join('.')
47
+ end
48
+ end
49
+
50
+ desc 'Set version: [x.y.z] - explicitly, [1/10/100] - bump major/minor/patch, [.build] - build'
51
+ task :version, [:command, :desc] do |t, args|
52
+ version = Version.new(VERSION)
53
+ case args.command
54
+ when /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ # Set version explicitly
55
+ version.update($1, $2, $3, $4)
56
+ when /^\.(.*?)$/ # Set build
57
+ version.build = $1
58
+ when /^(\d{1})$/ # Bump patch
59
+ version.bump_patch $1
60
+ when /^(\d{1})0$/ # Bump minor
61
+ version.bump_minor $1
62
+ when /^(\d{1})00$/ # Bump major
63
+ version.bump_major $1
64
+ else # Unknown command, just display VERSION
65
+ puts "#{NAME} #{version}"
66
+ next
67
+ end
68
+
69
+ puts "Writing version #{version} to VERSION file"
70
+ version.write args.desc
71
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: evented-spec
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.4.0
6
+ platform: ruby
7
+ authors:
8
+ - Arvicco
9
+ - Markiz
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-04-12 00:00:00 -05:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rspec
19
+ prerelease: false
20
+ requirement: &id001 !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ~>
24
+ - !ruby/object:Gem::Version
25
+ version: 2.5.0
26
+ type: :development
27
+ version_requirements: *id001
28
+ - !ruby/object:Gem::Dependency
29
+ name: amqp
30
+ prerelease: false
31
+ requirement: &id002 !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - "="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.8.0.pre
37
+ type: :development
38
+ version_requirements: *id002
39
+ - !ruby/object:Gem::Dependency
40
+ name: bundler
41
+ prerelease: false
42
+ requirement: &id003 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :development
49
+ version_requirements: *id003
50
+ - !ruby/object:Gem::Dependency
51
+ name: RedCloth
52
+ prerelease: false
53
+ requirement: &id004 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: 4.2.7
59
+ type: :runtime
60
+ version_requirements: *id004
61
+ description: Simple API for writing asynchronous EventMachine and AMQP specs. Runs legacy EM-Spec based examples. Supports RSpec and RSpec2.
62
+ email: arvitallian@gmail.com
63
+ executables: []
64
+
65
+ extensions: []
66
+
67
+ extra_rdoc_files:
68
+ - LICENSE
69
+ - HISTORY
70
+ - README.textile
71
+ files:
72
+ - lib/amqp-spec.rb
73
+ - lib/evented-spec/amqp.rb
74
+ - lib/evented-spec/evented_example/amqp_example.rb
75
+ - lib/evented-spec/evented_example/coolio_example.rb
76
+ - lib/evented-spec/evented_example/em_example.rb
77
+ - lib/evented-spec/evented_example.rb
78
+ - lib/evented-spec/rspec.rb
79
+ - lib/evented-spec/util.rb
80
+ - lib/evented-spec/version.rb
81
+ - lib/evented-spec.rb
82
+ - spec/cool_io_spec.rb
83
+ - spec/em_defaults_spec.rb
84
+ - spec/em_hooks_spec.rb
85
+ - spec/em_metadata_spec.rb
86
+ - spec/failing_rspec_spec.rb
87
+ - spec/rspec_amqp_spec.rb
88
+ - spec/rspec_em_spec.rb
89
+ - spec/shared_examples.rb
90
+ - spec/spec.opts
91
+ - spec/spec_helper.rb
92
+ - spec/util_spec.rb
93
+ - tasks/common.rake
94
+ - tasks/doc.rake
95
+ - tasks/gem.rake
96
+ - tasks/git.rake
97
+ - tasks/spec.rake
98
+ - tasks/version.rake
99
+ - Rakefile
100
+ - README.textile
101
+ - LICENSE
102
+ - VERSION
103
+ - HISTORY
104
+ - .gitignore
105
+ has_rdoc: true
106
+ homepage: http://github.com/ruby-amqp/evented-spec
107
+ licenses: []
108
+
109
+ post_install_message:
110
+ rdoc_options:
111
+ - --charset
112
+ - UTF-8
113
+ - --main
114
+ - README.textile
115
+ - --title
116
+ - evented-spec
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: "0"
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: "0"
131
+ requirements: []
132
+
133
+ rubyforge_project:
134
+ rubygems_version: 1.6.2
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: Simple API for writing asynchronous EventMachine/AMQP specs. Supports RSpec and RSpec2.
138
+ test_files:
139
+ - spec/cool_io_spec.rb
140
+ - spec/em_defaults_spec.rb
141
+ - spec/em_hooks_spec.rb
142
+ - spec/em_metadata_spec.rb
143
+ - spec/failing_rspec_spec.rb
144
+ - spec/rspec_amqp_spec.rb
145
+ - spec/rspec_em_spec.rb
146
+ - spec/shared_examples.rb
147
+ - spec/spec.opts
148
+ - spec/spec_helper.rb
149
+ - spec/util_spec.rb