Permalink
Browse files

Added simplecov for local coverage reporting and cleaned up Cucumber …

…step files
  • Loading branch information...
1 parent 3badf7e commit cfe177fe482503e8b6ac8840c92f0464a8645eb0 @visoft committed Jun 23, 2013
Showing with 30 additions and 64 deletions.
  1. +10 −0 .simplecov
  2. +10 −2 Rakefile
  3. +2 −58 features/step_definitions/service_steps.rb
  4. +4 −2 features/support/env.rb
  5. +1 −0 ruby_odata.gemspec
  6. +3 −2 spec/spec_helper.rb
View
@@ -0,0 +1,10 @@
+if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.9') && ENV['COVERAGE']
+ require 'simplecov'
+ require 'coveralls'
+
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
+ SimpleCov::Formatter::HTMLFormatter
+ ]
+
+ SimpleCov.start
+end
View
@@ -13,11 +13,19 @@ Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format progress"
end
-
Bundler::GemHelper.install_tasks
task :default => [:spec, :features]
-task :test_with_coveralls => [:spec, :features, 'coveralls_push_workaround']
+desc "Run with code coverage"
+task :coverage do
+ ENV['COVERAGE'] = 'true' if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.9')
+
+ Rake::Task["spec"].execute
+ Rake::Task["features"].execute
+end
+
+desc "Run test with coveralls"
+task :test_with_coveralls => [:coverage, 'coveralls_push_workaround']
task :coveralls_push_workaround do
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.9')
require 'coveralls/rake/task'
@@ -20,14 +20,6 @@
end
end
-Given /^a HTTP BasicAuth ODataService exists$/ do
- @service = OData::Service.new(BASICAUTH_URL)
-end
-
-Given /^a HTTPS BasicAuth ODataService exists$/ do
- @service = OData::Service.new(HTTPS_BASICAUTH_URL)
-end
-
Given /^a HTTP BasicAuth ODataService exists using username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
@service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password })
end
@@ -36,14 +28,6 @@
lambda { @service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password }) }.should raise_error(msg)
end
-Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message containing "([^\"]*)"$/ do |msg|
- lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
-end
-
-Given /^a HTTPS BasicAuth ODataService exists it should throw an exception with message containing "([^"]*)"$/ do |msg|
- lambda { @service = OData::Service.new(HTTPS_BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
-end
-
Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message "([^\"]*)"$/ do |msg|
lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(msg)
end
@@ -56,10 +40,6 @@
@service_query = @service.send(method)
end
-Then /^the result should be "([^\"]*)"$/ do |result|
- @service_result.should eq result
-end
-
Then /^the integer result should be ([^\"]*)$/ do |result|
@service_result.should eq result.to_i
end
@@ -216,27 +196,6 @@
table.diff!(result_table)
end
-Then /^the save result should be:$/ do |table|
- # table is a Cucumber::Ast::Table
-
- fields = table.hashes[0].keys
-
- # Build an array of hashes so that we can compare tables
- results = []
-
- @saved_result.each do |result|
- obj_hash = Hash.new
- fields.each do |field|
- obj_hash[field] = result.send(field)
- end
- results << obj_hash
- end
-
- result_table = Cucumber::Ast::Table.new(results)
-
- table.diff!(result_table)
-end
-
Then /^a class named "([^\"]*)" should exist$/ do |klass_name|
(Object.const_defined? klass_name).should eq true
end
@@ -261,14 +220,6 @@
end
# Type tests
-Then /^the "([^\"]*)" method should return a (.*)/ do |method_name, type|
- methods = method_name.split '.'
- if methods.length == 1
- @service_result.send(method_name).class.to_s.should eq type
- else
- @service_result.send(methods[0]).send(methods[1]).class.to_s.should eq type
- end
-end
Then /^the "([^\"]*)" method on the object should return a (.*)/ do |method_name, type|
methods = method_name.split '.'
if methods.length == 1
@@ -284,16 +235,9 @@
Then /^the new query result's time "([^\"]*)" should equal the saved query result$/ do |method_name|
methods = method_name.split '.'
- if methods.length == 1
- @service_result.send(method_name).xmlschema(3).should eq @stored_query_result.send(method_name).xmlschema(3)
- else
- @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should eq @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
- end
+ @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should eq @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
end
-Then /^show me the results$/ do
- puts @service_result
-end
Then /^the result count should be (\d+)$/ do |expected_count|
@service_result.count.should eq expected_count.to_i
@@ -313,4 +257,4 @@
When /^(.*) within a cassette named "([^"]*)"$/ do |the_step, cassette_name|
VCR.use_cassette(cassette_name) { step the_step }
-end
+end
View
@@ -3,5 +3,7 @@
require lib + '/ruby_odata'
require 'machinist'
-require 'coveralls'
-Coveralls.wear_merged!
+require 'simplecov'
+# require 'coveralls'
+
+# Coveralls.wear_merged!
View
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
s.add_development_dependency("guard-rspec", "~> 1.2.1")
s.add_development_dependency("guard-cucumber", "~> 1.2.0")
s.add_development_dependency("vcr", "~> 2.2.4")
+ s.add_development_dependency("simplecov", "~> 0.7.1")
s.add_development_dependency("coveralls", "~> 0.6.7")
s.files = `git ls-files`.split("\n")
View
@@ -1,6 +1,7 @@
require 'ruby_odata'
require 'webmock/rspec'
-require 'coveralls'
-Coveralls.wear_merged!
+require 'simplecov'
+# require 'coveralls'
+# Coveralls.wear_merged!
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }

0 comments on commit cfe177f

Please sign in to comment.