Byclosure-common_steps 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.
@@ -0,0 +1,29 @@
1
+ require "rubygems"
2
+ require 'spec'
3
+ require 'spec/mocks'
4
+
5
+ require "facets"
6
+ require "ruby-debug"
7
+ Debugger.start
8
+
9
+
10
+ require "active_record"
11
+ ActiveRecord::Schema.verbose = false
12
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
13
+ ActiveRecord::Base.configurations = true
14
+ ActiveRecord::Schema.define(:version => 1) do
15
+ create_table "artists", :force => true do |t|
16
+ t.string "name"
17
+ t.integer "age"
18
+ t.timestamps
19
+ end
20
+ end
21
+
22
+ require 'cucumber'
23
+ require 'factory_girl'
24
+
25
+ class Artist < ActiveRecord::Base
26
+ end
27
+
28
+ Factory.define :artist do |f|
29
+ end
data/spec/spec.opts CHANGED
@@ -1,4 +1,5 @@
1
1
  --colour
2
- --format progress
2
+ --format specdoc
3
3
  --loadby mtime
4
4
  --reverse
5
+ --debugger
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,105 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'cucumber_steps'
4
3
  require 'spec'
5
4
  require 'spec/autorun'
5
+ require 'spec/mocks'
6
+
7
+ module TreetopParserMatchers
8
+ class ParserMatcher
9
+ def initialize(input_string)
10
+ @input_string = input_string
11
+ end
12
+ def matches?(parser)
13
+ @parser = parser
14
+ !@parser.parse(@input_string).nil?
15
+ end
16
+ def failure_message_for_should
17
+ "expected #{@parser} to parse '#{@input_string}'\n" +
18
+ "failure column: #{@parser.failure_column}\n" +
19
+ "failure index: #{@parser.failure_index}\n" +
20
+ "failure line: #{@parser.failure_line}\n" +
21
+ # "terminal failures: #{@parser.terminal_failures}\n" + PROBLEMS: raising exception on treetop side
22
+ "failure reason: #{@parser.failure_reason}\n"
23
+ end
24
+ def failure_message_for_should_not
25
+ "expected #{@parser} not to parse '#{@input_string}'"
26
+ end
27
+ def description
28
+ "parse `#{@input_string}'"
29
+ end
30
+ end
31
+
32
+ def treetop_parse(input_string)
33
+ ParserMatcher.new(input_string)
34
+ end
35
+ end
36
+
37
+
6
38
 
7
39
  Spec::Runner.configure do |config|
8
40
  end
41
+
42
+ Spec::Matchers.define :step_match do |expected_string|
43
+ match do |step_mother|
44
+ begin
45
+ step_mother.step_match(expected_string)
46
+ rescue Exception => @exception
47
+ @exception
48
+ end
49
+ @exception.nil?
50
+ end
51
+
52
+ failure_message_for_should do |step_mother|
53
+ "expected #{step_mother} to StepMatch[#{expected_string}], exception raised:\n" +
54
+ "Type: #{@exception.class}\n" +
55
+ "Message: #{@exception.message}"
56
+ end
57
+
58
+ failure_message_for_should_not do |step_mother|
59
+ # "expected #{collection} count not to be #{num}"
60
+ "TODO"
61
+ end
62
+
63
+ description do
64
+ "StepMatch[#{expected_string}]"
65
+ end
66
+ end
67
+
68
+ #Copied from count.rb
69
+ Spec::Matchers.define :count do |num|
70
+ match do |collection|
71
+ collection.count == num
72
+ end
73
+
74
+ failure_message_for_should do |collection|
75
+ "expected #{collection} count to be #{num} instead of #{collection.count}"
76
+ end
77
+
78
+ failure_message_for_should_not do |collection|
79
+ "expected #{collection} count not to be #{num}"
80
+ end
81
+
82
+ description do
83
+ "count should be #{num}"
84
+ end
85
+ end
86
+
87
+ Spec::Matchers.define :exist_given do |hash|
88
+ match do |@ar_class|
89
+ @ar_class.exists?(hash)
90
+ end
91
+
92
+ failure_message_for_should do |ar_class|
93
+ "expected an instance of #{ar_class} to exist, when #{ar_class}.exists?(#{hash.inspect})\n" +
94
+ "Counting a total of: #{ar_class.count} #{ar_class}"
95
+ end
96
+
97
+ failure_message_for_should_not do |ar_class|
98
+ "expected an instance of #{ar_class} _not_ to exist, when #{ar_class}.exists?(#{hash.inspect})\n" +
99
+ "Counting a total of: #{ar_class.count} #{ar_class}"
100
+ end
101
+
102
+ description do
103
+ "should exist at least one instance of #{@ar_class} with the attributes #{hash.inspect}"
104
+ end
105
+ end
data/tasks/rspec.rake CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'spec/rake/spectask'
3
3
  Spec::Rake::SpecTask.new(:spec) do |spec|
4
4
  spec.libs << 'lib' << 'spec'
5
+ spec.spec_opts = File.read('spec/spec.opts').split("\n")
5
6
  spec.spec_files = FileList['spec/**/*_spec.rb']
6
7
  end
7
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Byclosure-common_steps
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
  - Vasco Andrade e Silva
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-09-09 00:00:00 -07:00
13
+ date: 2009-09-15 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -33,6 +33,26 @@ dependencies:
33
33
  - !ruby/object:Gem::Version
34
34
  version: "0"
35
35
  version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: activesupport
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ - !ruby/object:Gem::Dependency
47
+ name: cucumber
48
+ type: :runtime
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
36
56
  description: common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers
37
57
  email:
38
58
  - vasco@byclosure.com
@@ -56,6 +76,9 @@ files:
56
76
  - features/support/env.rb
57
77
  - lib/common_steps.rb
58
78
  - lib/common_steps/helpers.rb
79
+ - lib/common_steps/helpers/conditions.treetop
80
+ - lib/common_steps/helpers/conditions_parser.rb
81
+ - lib/common_steps/helpers/rake_helper.rb
59
82
  - lib/common_steps/helpers/record_helper.rb
60
83
  - lib/common_steps/matchers/count.rb
61
84
  - lib/common_steps/step_definitions.rb
@@ -64,20 +87,22 @@ files:
64
87
  - lib/common_steps/step_definitions/webrat_steps.rb
65
88
  - lib/common_steps/support/database.rb
66
89
  - lib/common_steps/support/email.rb
67
- - lib/common_steps/support/env.rb
68
90
  - lib/common_steps/support/spec.rb
69
91
  - lib/common_steps/tasks/cucumber.rake
70
92
  - lib/common_steps/tasks/rspec.rake
71
93
  - spec/common_steps/common_steps_spec.rb
94
+ - spec/common_steps/helpers/conditions_parser_spec.rb
95
+ - spec/common_steps/helpers/record_helper_spec.rb
96
+ - spec/common_steps_helper.rb
72
97
  - spec/spec.opts
73
98
  - spec/spec_helper.rb
74
99
  - tasks/cucumber.rake
75
- - tasks/jeweler.rake
76
100
  - tasks/rdoc.rake
77
101
  - tasks/roodi.rake
78
102
  - tasks/rspec.rake
79
- has_rdoc: false
103
+ has_rdoc: true
80
104
  homepage: http://github.com/Byclosure/common_steps
105
+ licenses:
81
106
  post_install_message:
82
107
  rdoc_options:
83
108
  - --charset=UTF-8
@@ -98,10 +123,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
123
  requirements: []
99
124
 
100
125
  rubyforge_project:
101
- rubygems_version: 1.2.0
126
+ rubygems_version: 1.3.5
102
127
  signing_key:
103
- specification_version: 3
128
+ specification_version: 2
104
129
  summary: common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers
105
130
  test_files:
106
- - spec/common_steps/common_steps_spec.rb
107
131
  - spec/spec_helper.rb
132
+ - spec/common_steps_helper.rb
133
+ - spec/common_steps/helpers/record_helper_spec.rb
134
+ - spec/common_steps/helpers/conditions_parser_spec.rb
135
+ - spec/common_steps/common_steps_spec.rb
@@ -1,24 +0,0 @@
1
- # Sets up the Rails environment for Cucumber
2
- require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
3
- require 'cucumber/rails/world'
4
- require 'cucumber/rails/rspec'
5
-
6
- require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
7
-
8
- require 'rake'
9
-
10
- def rake(task)
11
- `cd #{RAILS_ROOT} && RAILS_ENV=#{RAILS_ENV} rake #{task}`
12
- end
13
-
14
- require 'webrat'
15
-
16
- Webrat.configure do |config|
17
- config.mode = ENV["MODE"] == "selenium" ? :selenium : :rails
18
- end
19
-
20
- require 'webrat/core/matchers'
21
-
22
- require File.expand_path(File.dirname(__FILE__) + '../../../spec/spec_helper')
23
-
24
-
data/tasks/jeweler.rake DELETED
@@ -1,52 +0,0 @@
1
- begin
2
- require 'jeweler'
3
- Jeweler::Tasks.new do |gem|
4
- gem.name = "common_steps"
5
- gem.summary = %Q{common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers}
6
- gem.description = gem.summary
7
- gem.email = ["vasco@byclosure.com", "duarte@byclosure.com"]
8
- gem.homepage = "http://github.com/Byclosure/common_steps"
9
- gem.authors = ["Vasco Andrade e Silva", "Duarte Henriques"]
10
- gem.add_development_dependency "rspec"
11
- gem.add_development_dependency "cucumber"
12
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
- end
14
- rescue LoadError
15
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
16
- end
17
-
18
-
19
- =begin
20
- spec = Gem::Specification.new do |s|
21
- s.name = "common_steps"
22
- s.version = "0.1.0" # CommonSteps::VERSION::STRING
23
- s.authors = ["Vasco Andrade e Silva", "Duarte Henriques"]
24
- s.email = "vasco@byclosure.com"
25
- s.homepage = "http://github.com/Byclosure/common_steps"
26
- s.summary = "common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers"
27
- s.description = s.summary
28
- s.files = %w[MIT-LICENSE.txt README.rdoc Rakefile] + Dir["lib/**/*"]# + Dir["vendor/**/*"]
29
-
30
- #s.add_dependency ""
31
- end
32
-
33
- Rake::GemPackageTask.new(spec) do |package|
34
- package.gem_spec = spec
35
- end
36
-
37
- desc 'Show information about the gem.'
38
- task :gemspec do
39
- File.open("common_steps.gemspec", 'w') do |f|
40
- f.write spec.to_ruby
41
- end
42
- puts "Generated: common_steps.gemspec"
43
- end
44
-
45
- CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
46
-
47
- desc 'Install the package as a gem.'
48
- task :install => [:clean, :package] do
49
- gem = Dir['pkg/*.gem'].first
50
- sh "sudo gem install --no-ri --no-rdoc --local #{gem}"
51
- end
52
- =end