<commit_before>require 'rubygems'
require 'rspec'
require 'spire_io'

RSpec::Matchers.define :be_a_resource do
  match do |actual|
    actual.url =~ /^http/
  end
end

RSpec::Matchers.define :be_a_privileged_resource do
  match do |actual|
    actual.url =~ /^http/ and
      not actual.capability.nil?
  end
end

def create_spire
  Spire.new("http://localhost:1337")
end

$email = "<EMAIL>"

describe "The spire.io API" do

  describe "Accounts and Sessions" do

    describe "Registration and Authentication" do

      describe "Register with a valid email and password" do

        before(:all) do
          @spire = create_spire
          @session = @spire.register(:email => $email, :password => "<PASSWORD>").instance_eval { @session }
          $secret = @spire.secret
        end

        specify "has a session" do
          @spire.session.should be_a_kind_of Spire::API::Session
        end

        specify "session has an account resource" do
          @session.resources["account"].should_not be_nil
        end


# TODO: This is having a problem due to shark currently, should reenable later
#       describe "Registering another account with the same email" do
#<commit_msg>organize the tests so its possible to run one at a time<commit_after>require 'rubygems'
require 'rspec'
require 'spire_io'

RSpec::Matchers.define :be_a_resource do
  match do |actual|
    actual.url =~ /^http/
  end
end

RSpec::Matchers.define :be_a_privileged_resource do
  match do |actual|
    actual.url =~ /^http/ and
      not actual.capability.nil?
  end
end

def create_spire
  Spire.new("http://localhost:1337")
end

$email = "<EMAIL>"

describe "The spire.io API" do
  before(:all) do
    @spire = create_spire
    @session = @spire.register(:email => $email, :password => "<PASSWORD>").instance_eval { @session }
    $secret = @spire.secret
  end

  describe "Accounts and Sessions" do

    describe "Registration and Authentication" do

      describe "Register with a valid email and password" do

        specify "has a session" do
          @spire.session.should be_a_kind_of Spire::API::Session
        end

        specify "session has an account resource" do
          @session.resources["account"].should_not be_nil
        end


# TODO: This is having a problem due to shark currently, should reenable later
#       describe "Registering another account with the same email" do
#
{'fraction_non_alphanumeric': 0.09711176224361658, 'fraction_numerical': 0.0033486814566764337, 'mean_word_length': 3.127806563039724, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4963782', 'n_tokens_mistral': 752, 'n_tokens_neox': 732, 'n_words': 237}